Skip to content

Commit

Permalink
[devicelock] Add feedback about soon to expire codes. Contributes to …
Browse files Browse the repository at this point in the history
…JB#18948
  • Loading branch information
adenexter committed May 24, 2017
1 parent 669d3e0 commit 98fbfd9
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 6 deletions.
4 changes: 4 additions & 0 deletions dbus/org.nemomobile.devicelock.DeviceLock.xml
Expand Up @@ -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>
5 changes: 4 additions & 1 deletion src/nemo-devicelock/authenticationinput.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/nemo-devicelock/authenticationinput.h
Expand Up @@ -83,6 +83,7 @@ class NEMODEVICELOCK_EXPORT AuthenticationInput : public QObject, private Connec
SecurityCodesDoNotMatch,
SecurityCodeInHistory,
SecurityCodeExpired,
SecurityCodeDueToExpire,
PartialPrint,
PrintIsUnclear,
SensorIsDirty,
Expand Down
26 changes: 26 additions & 0 deletions src/nemo-devicelock/devicelock.cpp
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion src/nemo-devicelock/devicelock.h
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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();

Expand Down
8 changes: 8 additions & 0 deletions src/nemo-devicelock/host/hostdevicelock.cpp
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/nemo-devicelock/host/hostdevicelock.h
Expand Up @@ -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();

Expand Down
13 changes: 9 additions & 4 deletions src/nemo-devicelock/host/hostobject.cpp
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/nemo-devicelock/host/hostobject.h
Expand Up @@ -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 <typename... Arguments> inline bool sendToActiveClient(
const QString &interface,
Expand Down

0 comments on commit 98fbfd9

Please sign in to comment.