Commit d21fda68 authored by Karel Slaný's avatar Karel Slaný
Browse files

Added support for inactivity interval into settings structures.

parent 5fe73c52
......@@ -45,6 +45,7 @@ Settings::Settings(void)
pinAlg(),
pinSalt(),
pinCode(),
pinInactTimeoutInSecs(DEFAULT_PIN_INACT_TIMEOUT),
dbsLocation(""),
m_lastUpdate()
{
......@@ -80,6 +81,12 @@ void Settings::saveToSettings(QSettings &settings) const
Q_ASSERT(!pinCode.isEmpty());
settings.setValue(SETTINGS_PIN_CODE,
QString::fromUtf8(pinCode.toBase64()));
if (pinInactTimeoutInSecs > 0) {
/* Only when some value is used. */
settings.setValue(SETTINGS_PIN_INACT_TIMEOUT_IN_SECS,
pinInactTimeoutInSecs);
}
}
settings.setValue(SETTINGS_LAST_UPDATE, m_lastUpdate);
......@@ -125,6 +132,10 @@ void Settings::loadFromSettings(const QSettings &settings)
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_CODE,
QString()).toString().toUtf8());
pinInactTimeoutInSecs = settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_PIN_INACT_TIMEOUT_IN_SECS,
DEFAULT_PIN_INACT_TIMEOUT).toInt();
setLastUpdate(settings.value(
SETTINGS_GLOBAL_GROUP "/" SETTINGS_LAST_UPDATE).toString());
......
......@@ -37,6 +37,7 @@
* attachment files stored in local database (in days)*/
#define DEFAULT_MSG_LIFETIME 90
#define DEFAULT_FILE_LIFETIME 10
#define DEFAULT_PIN_INACT_TIMEOUT 0
/* Names of setting items in GLOBALS group in the datovka.conf file */
#define SETTINGS_GLOBAL_GROUP "GLOBALS"
#define SETTINGS_ONLY_NEW_MSGS "only_new_msgs"
......@@ -47,6 +48,7 @@
#define SETTINGS_PIN_ALG "pin_alg"
#define SETTINGS_PIN_SALT "pin_salt"
#define SETTINGS_PIN_CODE "pin_code"
#define SETTINGS_PIN_INACT_TIMEOUT_IN_SECS "pin_inact_timeout"
#define SETTINGS_LAST_UPDATE "last_update"
#define SETTINGS_LANGUAGE "language"
#define SETTINGS_FONTSIZE "font_size"
......@@ -124,6 +126,7 @@ public:
QString pinAlg; /*!< PIN algorithm identifier. */
QByteArray pinSalt; /*!< Salt value used to generate PIN hash. */
QByteArray pinCode; /*!< Hashed PIN code. */
int pinInactTimeoutInSecs; /*!< Inactivity locking interval. */
QString dbsLocation;
private:
......
......@@ -300,3 +300,13 @@ QString GlobalSettingsQmlWrapper::changeDbPath(const QString &currentLocation,
return newLocation;
}
int GlobalSettingsQmlWrapper::inactivityInterval(void) const
{
return globSet.pinInactTimeoutInSecs;
}
void GlobalSettingsQmlWrapper::setInactivityInterval(int secs)
{
globSet.pinInactTimeoutInSecs = (secs > 0) ? secs : 0;
}
......@@ -140,6 +140,22 @@ public:
QString changeDbPath(const QString &currentLocation,
bool setDefaultLocation);
/*!
* @brief Get inactivity timeout length.
*
* @return Inactivity interval in seconds.
*/
Q_INVOKABLE
int inactivityInterval(void) const;
/*!
* @brief Set inactivity timeout length.
*
* @param[in] secs Inactivity interval length in seconds.
*/
Q_INVOKABLE
void setInactivityInterval(int secs);
signals:
/*!
......
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