Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb44746' into 'master'
[devicelock] Add settings accessors for code length properties. Contributes to JB#44746

See merge request mer-core/nemo-qml-plugin-devicelock!45
  • Loading branch information
adenexter committed Mar 11, 2020
2 parents dd20dae + 5f75d1a commit ee510b9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/nemo-devicelock/devicelocksettings.cpp
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/nemo-devicelock/devicelocksettings.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand All @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions src/nemo-devicelock/private/settingswatcher.cpp
Expand Up @@ -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";
Expand All @@ -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)
Expand Down Expand Up @@ -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, &currentLength, &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);
Expand Down
3 changes: 3 additions & 0 deletions src/nemo-devicelock/private/settingswatcher.h
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand Down

0 comments on commit ee510b9

Please sign in to comment.