Commit ee510b97 authored by Andrew den Exter's avatar Andrew den Exter

Merge branch 'jb44746' into 'master'

[devicelock] Add settings accessors for code length properties. Contributes to JB#44746

See merge request !45
parents dd20dae4 5f75d1af
...@@ -70,6 +70,12 @@ DeviceLockSettings::DeviceLockSettings(QObject *parent) ...@@ -70,6 +70,12 @@ DeviceLockSettings::DeviceLockSettings(QObject *parent)
this, &DeviceLockSettings::inputIsKeyboardChanged); this, &DeviceLockSettings::inputIsKeyboardChanged);
connect(m_settings.data(), &SettingsWatcher::currentCodeIsDigitOnlyChanged, connect(m_settings.data(), &SettingsWatcher::currentCodeIsDigitOnlyChanged,
this, &DeviceLockSettings::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, connect(m_settings.data(), &SettingsWatcher::maximumAutomaticLockingChanged,
this, &DeviceLockSettings::maximumAutomaticLockingChanged); this, &DeviceLockSettings::maximumAutomaticLockingChanged);
connect(m_settings.data(), &SettingsWatcher::absoluteMaximumAttemptsChanged, connect(m_settings.data(), &SettingsWatcher::absoluteMaximumAttemptsChanged,
...@@ -252,6 +258,36 @@ bool DeviceLockSettings::currentCodeIsDigitOnly() const ...@@ -252,6 +258,36 @@ bool DeviceLockSettings::currentCodeIsDigitOnly() const
return m_settings->currentCodeIsDigitOnly; 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 \property NemoDeviceLock::DeviceLockSettings::homeEncrypted
......
...@@ -51,6 +51,9 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connect ...@@ -51,6 +51,9 @@ class NEMODEVICELOCK_EXPORT DeviceLockSettings : public QObject, private Connect
Q_PROPERTY(bool showNotifications READ showNotifications NOTIFY showNotificationsChanged) Q_PROPERTY(bool showNotifications READ showNotifications NOTIFY showNotificationsChanged)
Q_PROPERTY(bool inputIsKeyboard READ inputIsKeyboard NOTIFY inputIsKeyboardChanged) Q_PROPERTY(bool inputIsKeyboard READ inputIsKeyboard NOTIFY inputIsKeyboardChanged)
Q_PROPERTY(bool currentCodeIsDigitOnly READ currentCodeIsDigitOnly NOTIFY currentCodeIsDigitOnlyChanged) 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(bool homeEncrypted READ isHomeEncrypted CONSTANT)
Q_PROPERTY(int maximumAutomaticLocking READ maximumAutomaticLocking NOTIFY maximumAutomaticLockingChanged) Q_PROPERTY(int maximumAutomaticLocking READ maximumAutomaticLocking NOTIFY maximumAutomaticLockingChanged)
Q_PROPERTY(int absoluteMaximumAttempts READ absoluteMaximumAttempts NOTIFY absoluteMaximumAttemptsChanged) Q_PROPERTY(int absoluteMaximumAttempts READ absoluteMaximumAttempts NOTIFY absoluteMaximumAttemptsChanged)
...@@ -79,6 +82,9 @@ public: ...@@ -79,6 +82,9 @@ public:
Q_INVOKABLE void setInputIsKeyboard(const QVariant &authenticationToken, bool value); Q_INVOKABLE void setInputIsKeyboard(const QVariant &authenticationToken, bool value);
bool currentCodeIsDigitOnly() const; bool currentCodeIsDigitOnly() const;
int currentCodeLength() const;
int minimumCodeLength() const;
int maximumCodeLength() const;
bool isHomeEncrypted() const; bool isHomeEncrypted() const;
...@@ -93,6 +99,9 @@ signals: ...@@ -93,6 +99,9 @@ signals:
void showNotificationsChanged(); void showNotificationsChanged();
void inputIsKeyboardChanged(); void inputIsKeyboardChanged();
void currentCodeIsDigitOnlyChanged(); void currentCodeIsDigitOnlyChanged();
void currentCodeLengthChanged();
void minimumCodeLengthChanged();
void maximumCodeLengthChanged();
void maximumAutomaticLockingChanged(); void maximumAutomaticLockingChanged();
void absoluteMaximumAttemptsChanged(); void absoluteMaximumAttemptsChanged();
......
...@@ -66,6 +66,7 @@ int flagsFromString(const QMetaEnum &enumeration, const char *string) ...@@ -66,6 +66,7 @@ int flagsFromString(const QMetaEnum &enumeration, const char *string)
} }
const char * const SettingsWatcher::automaticLockingKey = "automatic_locking"; 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::minimumLengthKey = "code_min_length";
const char * const SettingsWatcher::maximumLengthKey = "code_max_length"; const char * const SettingsWatcher::maximumLengthKey = "code_max_length";
const char * const SettingsWatcher::maximumAttemptsKey = "maximum_attempts"; const char * const SettingsWatcher::maximumAttemptsKey = "maximum_attempts";
...@@ -82,6 +83,7 @@ SettingsWatcher *SettingsWatcher::sharedInstance = nullptr; ...@@ -82,6 +83,7 @@ SettingsWatcher *SettingsWatcher::sharedInstance = nullptr;
SettingsWatcher::SettingsWatcher(QObject *parent) SettingsWatcher::SettingsWatcher(QObject *parent)
: QSocketNotifier(inotify_init(), Read, parent) : QSocketNotifier(inotify_init(), Read, parent)
, automaticLocking(0) , automaticLocking(0)
, currentLength(0)
, minimumLength(5) , minimumLength(5)
, maximumLength(42) , maximumLength(42)
, maximumAttempts(-1) , maximumAttempts(-1)
...@@ -254,6 +256,7 @@ void SettingsWatcher::reloadSettings() ...@@ -254,6 +256,7 @@ void SettingsWatcher::reloadSettings()
g_key_file_load_from_file(settings, m_settingsPath.toUtf8().constData(), G_KEY_FILE_NONE, 0); 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, automaticLockingKey, 0, &automaticLocking, &SettingsWatcher::automaticLockingChanged);
read(settings, this, currentLengthKey, 0, &currentLength, &SettingsWatcher::currentLengthChanged);
read(settings, this, minimumLengthKey, 5, &minimumLength, &SettingsWatcher::minimumLengthChanged); read(settings, this, minimumLengthKey, 5, &minimumLength, &SettingsWatcher::minimumLengthChanged);
read(settings, this, maximumLengthKey, 42, &maximumLength, &SettingsWatcher::maximumLengthChanged); read(settings, this, maximumLengthKey, 42, &maximumLength, &SettingsWatcher::maximumLengthChanged);
read(settings, this, maximumAttemptsKey, -1, &maximumAttempts, &SettingsWatcher::maximumAttemptsChanged); read(settings, this, maximumAttemptsKey, -1, &maximumAttempts, &SettingsWatcher::maximumAttemptsChanged);
......
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
static SettingsWatcher *instance(); static SettingsWatcher *instance();
int automaticLocking; int automaticLocking;
int currentLength;
int minimumLength; int minimumLength;
int maximumLength; int maximumLength;
int maximumAttempts; int maximumAttempts;
...@@ -88,6 +89,7 @@ public: ...@@ -88,6 +89,7 @@ public:
bool codeIsMandatory; bool codeIsMandatory;
static const char * const automaticLockingKey; static const char * const automaticLockingKey;
static const char * const currentLengthKey;
static const char * const minimumLengthKey; static const char * const minimumLengthKey;
static const char * const maximumLengthKey; static const char * const maximumLengthKey;
static const char * const maximumAttemptsKey; static const char * const maximumAttemptsKey;
...@@ -105,6 +107,7 @@ signals: ...@@ -105,6 +107,7 @@ signals:
void automaticLockingChanged(); void automaticLockingChanged();
void maximumAttemptsChanged(); void maximumAttemptsChanged();
void currentAttemptsChanged(); void currentAttemptsChanged();
void currentLengthChanged();
void minimumLengthChanged(); void minimumLengthChanged();
void maximumLengthChanged(); void maximumLengthChanged();
void peekingAllowedChanged(); void peekingAllowedChanged();
......
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