summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-22 15:06:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-07-22 15:06:57 -0700
commit9a68e356af425b4268589b014eb50ef1f276b893 (patch)
treee965b82aa5b4d1bbe6c60db756977dc48f5fc353 /qt-ui
parentaa9c2b738427dade65a0a273f57e2773f781e50a (diff)
downloadsubsurface-9a68e356af425b4268589b014eb50ef1f276b893.tar.gz
Make password change asynchronous
This isn't perfect (if you make multiple requests things could go badly), but it's better than just slapping the new password into the settings, even if the update failed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/preferences.cpp10
-rw-r--r--qt-ui/preferences.h1
-rw-r--r--qt-ui/subsurfacewebservices.cpp6
-rw-r--r--qt-ui/subsurfacewebservices.h1
4 files changed, 16 insertions, 2 deletions
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index b5fbc601c..04fb3a825 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -423,10 +423,11 @@ void PreferencesDialog::syncSettings()
} else {
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(cloudPinNeeded()));
+ connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull()));
QNetworkReply *reply = cloudAuth->backend(email, password, "", newpassword);
ui.cloud_storage_new_passwd->setText("");
- ui.cloud_storage_password->setText(newpassword);
- password = newpassword;
+ free(prefs.cloud_storage_newpassword);
+ prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword));
}
}
} else if (prefs.cloud_verification_status == CS_UNKNOWN ||
@@ -688,6 +689,11 @@ void PreferencesDialog::on_resetSettings_clicked()
}
}
+void PreferencesDialog::passwordUpdateSuccessfull()
+{
+ ui.cloud_storage_password->setText(prefs.cloud_storage_password);
+}
+
void PreferencesDialog::emitSettingsChanged()
{
emit settingsChanged();
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index 2402a7964..326b1f964 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -40,6 +40,7 @@ slots:
void facebookLoggedIn();
void facebookDisconnect();
void cloudPinNeeded();
+ void passwordUpdateSuccessfull();
private:
explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
void setUiFromPrefs();
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 875b8e65c..8154ce5fb 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -1029,6 +1029,12 @@ void CloudStorageAuthenticate::uploadFinished()
myLastError.clear();
} else if (cloudAuthReply == "[VERIFY]") {
prefs.cloud_verification_status = CS_NEED_TO_VERIFY;
+ } else if (cloudAuthReply == "[PASSWDCHANGED]") {
+ free(prefs.cloud_storage_password);
+ prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
+ prefs.cloud_storage_newpassword = NULL;
+ emit passwordChangeSuccessful();
+ return;
} else {
prefs.cloud_verification_status = CS_INCORRECT_USER_PASSWD;
myLastError = cloudAuthReply;
diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h
index 01aa11713..2b454ebc7 100644
--- a/qt-ui/subsurfacewebservices.h
+++ b/qt-ui/subsurfacewebservices.h
@@ -118,6 +118,7 @@ public:
explicit CloudStorageAuthenticate(QObject *parent);
signals:
void finishedAuthenticate();
+ void passwordChangeSuccessful();
private
slots:
void uploadError(QNetworkReply::NetworkError error);