diff --git a/dbus/org.nemomobile.devicelock.DeviceLock.xml b/dbus/org.nemomobile.devicelock.DeviceLock.xml index 2f449b8..15ba7bf 100644 --- a/dbus/org.nemomobile.devicelock.DeviceLock.xml +++ b/dbus/org.nemomobile.devicelock.DeviceLock.xml @@ -7,5 +7,9 @@ + + + + diff --git a/src/nemo-devicelock/authenticationinput.cpp b/src/nemo-devicelock/authenticationinput.cpp index cf49547..0aa8807 100644 --- a/src/nemo-devicelock/authenticationinput.cpp +++ b/src/nemo-devicelock/authenticationinput.cpp @@ -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( diff --git a/src/nemo-devicelock/authenticationinput.h b/src/nemo-devicelock/authenticationinput.h index 1712339..43461e6 100644 --- a/src/nemo-devicelock/authenticationinput.h +++ b/src/nemo-devicelock/authenticationinput.h @@ -83,6 +83,7 @@ class NEMODEVICELOCK_EXPORT AuthenticationInput : public QObject, private Connec SecurityCodesDoNotMatch, SecurityCodeInHistory, SecurityCodeExpired, + SecurityCodeDueToExpire, PartialPrint, PrintIsUnclear, SensorIsDirty, diff --git a/src/nemo-devicelock/devicelock.cpp b/src/nemo-devicelock/devicelock.cpp index b721257..d63fc60 100644 --- a/src/nemo-devicelock/devicelock.cpp +++ b/src/nemo-devicelock/devicelock.cpp @@ -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(QStringLiteral("Enabled"), [this](bool enabled) { if (m_enabled != enabled) { m_enabled = enabled; diff --git a/src/nemo-devicelock/devicelock.h b/src/nemo-devicelock/devicelock.h index 0f02224..e73b12b 100644 --- a/src/nemo-devicelock/devicelock.h +++ b/src/nemo-devicelock/devicelock.h @@ -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 @@ class NEMODEVICELOCK_EXPORT DeviceLock : public QObject, private ConnectionClien 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 @@ class NEMODEVICELOCK_EXPORT DeviceLock : public QObject, private ConnectionClien void unlocked(); void unlockError(); + void notice(Notice notice, const QVariantMap &data); + +private slots: + void handleNotice(uint notice, const QVariantMap &data); + private: inline void connected(); diff --git a/src/nemo-devicelock/host/hostdevicelock.cpp b/src/nemo-devicelock/host/hostdevicelock.cpp index c2b7513..73c9660 100644 --- a/src/nemo-devicelock/host/hostdevicelock.cpp +++ b/src/nemo-devicelock/host/hostdevicelock.cpp @@ -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; diff --git a/src/nemo-devicelock/host/hostdevicelock.h b/src/nemo-devicelock/host/hostdevicelock.h index afdcafd..63625fb 100644 --- a/src/nemo-devicelock/host/hostdevicelock.h +++ b/src/nemo-devicelock/host/hostdevicelock.h @@ -105,6 +105,9 @@ class HostDeviceLock : public HostAuthenticationInput void unlockFinished(int result); void setCodeFinished(int result); + // Signals + void notice(DeviceLock::Notice notice, const QVariantMap &data); + protected: virtual void stateChanged(); diff --git a/src/nemo-devicelock/host/hostobject.cpp b/src/nemo-devicelock/host/hostobject.cpp index 2ecf2bb..94b9e48 100644 --- a/src/nemo-devicelock/host/hostobject.cpp +++ b/src/nemo-devicelock/host/hostobject.cpp @@ -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); diff --git a/src/nemo-devicelock/host/hostobject.h b/src/nemo-devicelock/host/hostobject.h index 6bc1b0d..97171c7 100644 --- a/src/nemo-devicelock/host/hostobject.h +++ b/src/nemo-devicelock/host/hostobject.h @@ -70,6 +70,7 @@ class HostObject : public QObject, protected QDBusContext protected: void propertyChanged(const QString &interface, const QString &property, const QVariant &value); + void broadcastSignal(const QString &interface, const QString &name, const QVariantList &arguments); template inline bool sendToActiveClient( const QString &interface,