diff --git a/src/nemo-devicelock/devicelocksettings.cpp b/src/nemo-devicelock/devicelocksettings.cpp index ad7247c..d4a76bb 100644 --- a/src/nemo-devicelock/devicelocksettings.cpp +++ b/src/nemo-devicelock/devicelocksettings.cpp @@ -70,6 +70,12 @@ DeviceLockSettings::DeviceLockSettings(QObject *parent) this, &DeviceLockSettings::inputIsKeyboardChanged); connect(m_settings.data(), &SettingsWatcher::currentCodeIsDigitOnlyChanged, this, &DeviceLockSettings::currentCodeIsDigitOnlyChanged); + connect(m_settings.data(), &SettingsWatcher::currentLengthChanged, + this, &DeviceLockSettings::currentCodeLengthChanged); + connect(m_settings.data(), &SettingsWatcher::minimumLengthChanged, + this, &DeviceLockSettings::minimumCodeLengthChanged); + connect(m_settings.data(), &SettingsWatcher::maximumLengthChanged, + this, &DeviceLockSettings::maximumCodeLengthChanged); connect(m_settings.data(), &SettingsWatcher::maximumAutomaticLockingChanged, this, &DeviceLockSettings::maximumAutomaticLockingChanged); connect(m_settings.data(), &SettingsWatcher::absoluteMaximumAttemptsChanged, @@ -252,6 +258,36 @@ bool DeviceLockSettings::currentCodeIsDigitOnly() const return m_settings->currentCodeIsDigitOnly; } +/*! + \property NemoDeviceLock::DeviceLockSettings::currentCodeLength + + This property holds the length of the current security code. +*/ +int DeviceLockSettings::currentCodeLength() const +{ + return m_settings->currentLength; +} + +/*! + \property NemoDeviceLock::DeviceLockSettings::minimumCodeLength + + This property holds the minimum allowed length of a security code. +*/ +int DeviceLockSettings::minimumCodeLength() const +{ + return m_settings->minimumLength; +} + +/*! + \property NemoDeviceLock::DeviceLockSettings::maximumCodeLength + + This property holds the maximum allowed length of a security code. +*/ +int DeviceLockSettings::maximumCodeLength() const +{ + return m_settings->maximumLength; +} + /*! \property NemoDeviceLock::DeviceLockSettings::homeEncrypted diff --git a/src/nemo-devicelock/devicelocksettings.h b/src/nemo-devicelock/devicelocksettings.h index 2c936b2..1e70de3 100644 --- a/src/nemo-devicelock/devicelocksettings.h +++ b/src/nemo-devicelock/devicelocksettings.h @@ -51,6 +51,9 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connect Q_PROPERTY(bool showNotifications READ showNotifications NOTIFY showNotificationsChanged) Q_PROPERTY(bool inputIsKeyboard READ inputIsKeyboard NOTIFY inputIsKeyboardChanged) Q_PROPERTY(bool currentCodeIsDigitOnly READ currentCodeIsDigitOnly NOTIFY currentCodeIsDigitOnlyChanged) + Q_PROPERTY(int currentCodeLength READ currentCodeLength NOTIFY currentCodeLengthChanged) + Q_PROPERTY(int minimumCodeLength READ minimumCodeLength NOTIFY minimumCodeLengthChanged) + Q_PROPERTY(int maximumCodeLength READ maximumCodeLength NOTIFY maximumCodeLengthChanged) Q_PROPERTY(bool homeEncrypted READ isHomeEncrypted CONSTANT) Q_PROPERTY(int maximumAutomaticLocking READ maximumAutomaticLocking NOTIFY maximumAutomaticLockingChanged) Q_PROPERTY(int absoluteMaximumAttempts READ absoluteMaximumAttempts NOTIFY absoluteMaximumAttemptsChanged) @@ -79,6 +82,9 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connect Q_INVOKABLE void setInputIsKeyboard(const QVariant &authenticationToken, bool value); bool currentCodeIsDigitOnly() const; + int currentCodeLength() const; + int minimumCodeLength() const; + int maximumCodeLength() const; bool isHomeEncrypted() const; @@ -93,6 +99,9 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connect void showNotificationsChanged(); void inputIsKeyboardChanged(); void currentCodeIsDigitOnlyChanged(); + void currentCodeLengthChanged(); + void minimumCodeLengthChanged(); + void maximumCodeLengthChanged(); void maximumAutomaticLockingChanged(); void absoluteMaximumAttemptsChanged(); diff --git a/src/nemo-devicelock/private/settingswatcher.cpp b/src/nemo-devicelock/private/settingswatcher.cpp index 2256cb5..1b50583 100644 --- a/src/nemo-devicelock/private/settingswatcher.cpp +++ b/src/nemo-devicelock/private/settingswatcher.cpp @@ -66,6 +66,7 @@ int flagsFromString(const QMetaEnum &enumeration, const char *string) } const char * const SettingsWatcher::automaticLockingKey = "automatic_locking"; +const char * const SettingsWatcher::currentLengthKey = "code_current_length"; const char * const SettingsWatcher::minimumLengthKey = "code_min_length"; const char * const SettingsWatcher::maximumLengthKey = "code_max_length"; const char * const SettingsWatcher::maximumAttemptsKey = "maximum_attempts"; @@ -82,6 +83,7 @@ SettingsWatcher *SettingsWatcher::sharedInstance = nullptr; SettingsWatcher::SettingsWatcher(QObject *parent) : QSocketNotifier(inotify_init(), Read, parent) , automaticLocking(0) + , currentLength(0) , minimumLength(5) , maximumLength(42) , maximumAttempts(-1) @@ -254,6 +256,7 @@ void SettingsWatcher::reloadSettings() g_key_file_load_from_file(settings, m_settingsPath.toUtf8().constData(), G_KEY_FILE_NONE, 0); read(settings, this, automaticLockingKey, 0, &automaticLocking, &SettingsWatcher::automaticLockingChanged); + read(settings, this, currentLengthKey, 0, ¤tLength, &SettingsWatcher::currentLengthChanged); read(settings, this, minimumLengthKey, 5, &minimumLength, &SettingsWatcher::minimumLengthChanged); read(settings, this, maximumLengthKey, 42, &maximumLength, &SettingsWatcher::maximumLengthChanged); read(settings, this, maximumAttemptsKey, -1, &maximumAttempts, &SettingsWatcher::maximumAttemptsChanged); diff --git a/src/nemo-devicelock/private/settingswatcher.h b/src/nemo-devicelock/private/settingswatcher.h index b262a77..ea649a3 100644 --- a/src/nemo-devicelock/private/settingswatcher.h +++ b/src/nemo-devicelock/private/settingswatcher.h @@ -71,6 +71,7 @@ class NEMODEVICELOCK_EXPORT SettingsWatcher : public QSocketNotifier, public QSh static SettingsWatcher *instance(); int automaticLocking; + int currentLength; int minimumLength; int maximumLength; int maximumAttempts; @@ -88,6 +89,7 @@ class NEMODEVICELOCK_EXPORT SettingsWatcher : public QSocketNotifier, public QSh bool codeIsMandatory; static const char * const automaticLockingKey; + static const char * const currentLengthKey; static const char * const minimumLengthKey; static const char * const maximumLengthKey; static const char * const maximumAttemptsKey; @@ -105,6 +107,7 @@ class NEMODEVICELOCK_EXPORT SettingsWatcher : public QSocketNotifier, public QSh void automaticLockingChanged(); void maximumAttemptsChanged(); void currentAttemptsChanged(); + void currentLengthChanged(); void minimumLengthChanged(); void maximumLengthChanged(); void peekingAllowedChanged();