summaryrefslogtreecommitdiffstats
path: root/qt-mobile/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-07-21 11:57:10 +0300
committerGravatar Grace Karanja <gracie.karanja89@gmail.com>2015-07-22 09:53:19 +0300
commitea11eff27900b0929068c2fd18728db6412484cf (patch)
treef6a115c7fa9f20548a022b94e6aec79e19f27aed /qt-mobile/qmlmanager.cpp
parentb28517b9b002bbdaac867d0b720c17ae865cf17d (diff)
downloadsubsurface-ea11eff27900b0929068c2fd18728db6412484cf.tar.gz
QML UI: Implement saving of cloud password
If the user ticks the 'Save Password' box, then we save the password for future use. Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r--qt-mobile/qmlmanager.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index a1c64191b..8cefbe95f 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -20,6 +20,7 @@ QMLManager::QMLManager()
//Initialize cloud credentials.
setCloudUserName(prefs.cloud_storage_email);
setCloudPassword(prefs.cloud_storage_password);
+ setSaveCloudPassword(prefs.save_password_local);
}
QMLManager::~QMLManager()
@@ -31,15 +32,22 @@ void QMLManager::savePreferences()
QSettings s;
s.beginGroup("CloudStorage");
s.setValue("email", cloudUserName());
- s.setValue("password", cloudPassword());
+ s.setValue("save_password_local", saveCloudPassword());
+ if (saveCloudPassword())
+ s.setValue("password", cloudPassword());
s.sync();
if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUserName()))) {
free(prefs.cloud_storage_email);
prefs.cloud_storage_email = strdup(qPrintable(cloudUserName()));
}
- if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) {
- free(prefs.cloud_storage_password);
- prefs.cloud_storage_password = strdup(qPrintable(cloudPassword()));
+ if (saveCloudPassword() != prefs.save_password_local) {
+ prefs.save_password_local = saveCloudPassword();
+ }
+ if (saveCloudPassword()) {
+ if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) {
+ free(prefs.cloud_storage_password);
+ prefs.cloud_storage_password = strdup(qPrintable(cloudPassword()));
+ }
}
}
@@ -114,6 +122,16 @@ void QMLManager::saveChanges()
set_filename(fileName.toUtf8().data(), true);
mark_divelist_changed(false);
}
+bool QMLManager::saveCloudPassword() const
+{
+ return m_saveCloudPassword;
+}
+
+void QMLManager::setSaveCloudPassword(bool saveCloudPassword)
+{
+ m_saveCloudPassword = saveCloudPassword;
+}
+
QString QMLManager::cloudPassword() const
{