Commit 98fbfd96 authored by Andrew den Exter's avatar Andrew den Exter

[devicelock] Add feedback about soon to expire codes. Contributes to JB#18948

parent 669d3e09
......@@ -7,5 +7,9 @@
<property name="Unlocking" type="b" access="read"/>
<method name="Unlock"/>
<method name="Cancel"/>
<signal name="Notice">
<arg name="notice" type="u" direction="in"/>
<arg name="data" type="a{sv}" direction="in"/>
</signal>
</interface>
</node>
......@@ -134,6 +134,8 @@ void AuthenticationInputAdaptor::Error(uint error)
repeating their new security code.
\value SecurityCodeInHistory Inform the user that the code they entered has already been used.
\value SecurityCodeExpired Inform the user that their current code has expired.
\value SecurityCodeDueToExpire Inform the user that their current code is due to expire. The
expiration date is provided as the \c expirationDate member of the feedback data.
\value PartialPrint Inform the user that the fingerprint reader wasn't able to capture a full
print.
\value PrintIsUnclear Inform the user that fingerprint reader wasn't able to capture a clear
......@@ -583,7 +585,8 @@ void AuthenticationInput::handleAuthenticationEnded(bool confirmed)
\signal NemoDeviceLock::AuthenticationInput::feedback(Feedback feedback, object data)
Signals that a \a feedback message should be shown to the user. Some feedback will also
include \a data that should be incorporated into the message.
include \a data that should be incorporated into the message, the members of data
accompanying a feedback message will be described in the documentation for that feedback.
*/
void AuthenticationInput::handleFeedback(
......
......@@ -83,6 +83,7 @@ public:
SecurityCodesDoNotMatch,
SecurityCodeInHistory,
SecurityCodeExpired,
SecurityCodeDueToExpire,
PartialPrint,
PrintIsUnclear,
SensorIsDirty,
......
......@@ -47,6 +47,17 @@ namespace NemoDeviceLock
AuthenticationInput provider.
*/
/*!
\enum NemoDeviceLock::DeviceLock::Notice
Broadcast notifications decribing events of importance.
\value SecurityCodeDueToExpire The user's security code is due to due to expire in the near
future. The expiration date is provided as an ISO 8601 formatted string in the
\c expirationDate member of the notice data.
\value SecurityCodeChanged The user's security code has been changed.
*/
/*!
Constructs a device lock interface instance which is a child of \a parent.
*/
......@@ -217,10 +228,25 @@ void DeviceLock::cancel()
Signals that there was an error requesting authentication to unlock the device.
*/
/*!
\signal NemoDeviceLock::DeviceLock::notice(Notice notice, const QVariantMap &map)
Emits a broadcast \a notice from the device lock. Some noteices will also
include \a data that should be incorporated into the message, the members of data
accompanying a notice will be described in the documentation for that notice.
*/
void DeviceLock::handleNotice(uint notice, const QVariantMap &data)
{
emit DeviceLock::notice(DeviceLock::Notice(notice), data);
}
void DeviceLock::connected()
{
registerObject();
connectToSignal(QStringLiteral("Notice"), SLOT(handleNotice(uint,QVariantMap)));
subscribeToProperty<bool>(QStringLiteral("Enabled"), [this](bool enabled) {
if (m_enabled != enabled) {
m_enabled = enabled;
......
......@@ -28,7 +28,6 @@ class SettingsWatcher;
class NEMODEVICELOCK_EXPORT DeviceLock : public QObject, private ConnectionClient
{
Q_OBJECT
Q_ENUMS(LockState)
Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool unlocking READ isUnlocking NOTIFY unlockingChanged)
Q_PROPERTY(LockState state READ state NOTIFY stateChanged)
......@@ -46,6 +45,14 @@ public:
CodeEntryLockout, /*!< CodeEntryLockout - Access has been restricted because of excessive incorrect unlock attempts. */
Undefined /*!< Undefined - The state of the lock is unknown */
};
Q_ENUM(LockState)
enum Notice
{
SecurityCodeDueToExpire,
SecurityCodeChanged
};
Q_ENUM(Notice)
bool isEnabled() const;
bool isUnlocking() const;
......@@ -68,6 +75,11 @@ signals:
void unlocked();
void unlockError();
void notice(Notice notice, const QVariantMap &data);
private slots:
void handleNotice(uint notice, const QVariantMap &data);
private:
inline void connected();
......
......@@ -369,6 +369,14 @@ void HostDeviceLock::abortAuthentication(AuthenticationInput::Error error)
HostAuthenticationInput::abortAuthentication(error);
}
void HostDeviceLock::notice(DeviceLock::Notice notice, const QVariantMap &data)
{
broadcastSignal(
QStringLiteral("org.nemomobile.devicelock.DeviceLock"),
QStringLiteral("Notice"),
NemoDBus::marshallArguments(uint(notice), data));
}
void HostDeviceLock::stateChanged()
{
const auto previousState = m_lockState;
......
......@@ -105,6 +105,9 @@ public:
void unlockFinished(int result);
void setCodeFinished(int result);
// Signals
void notice(DeviceLock::Notice notice, const QVariantMap &data);
protected:
virtual void stateChanged();
......
......@@ -100,12 +100,17 @@ void HostObject::propertyChanged(const QString &interface, const QString &proper
const QVariantMap properties = { { property, value } };
QDBusMessage message = QDBusMessage::createSignal(
m_path,
broadcastSignal(
QStringLiteral("org.freedesktop.DBus.Properties"),
QStringLiteral("PropertiesChanged"));
QStringLiteral("PropertiesChanged"),
NemoDBus::marshallArguments(interface, properties, QStringList()));
}
void HostObject::broadcastSignal(const QString &interface, const QString &name, const QVariantList &arguments)
{
QDBusMessage message = QDBusMessage::createSignal(m_path, interface, name);
message.setArguments(NemoDBus::marshallArguments(interface, properties, QStringList()));
message.setArguments(arguments);
for (const auto connectionName : m_connections) {
QDBusConnection(connectionName).send(message);
......
......@@ -70,6 +70,7 @@ public:
protected:
void propertyChanged(const QString &interface, const QString &property, const QVariant &value);
void broadcastSignal(const QString &interface, const QString &name, const QVariantList &arguments);
template <typename... Arguments> inline bool sendToActiveClient(
const QString &interface,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment