Use preferences object to correctly store cloud status

There are a lot more places all over Subsurface where this needs to be
cleaned up. The converstion of the preferences system has been a complete
mess.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-07-23 12:53:37 +09:00
parent 0b5a1719a1
commit 9815eaf1ed

View file

@ -2,7 +2,7 @@
#include "pref.h" #include "pref.h"
#include "dive.h" #include "dive.h"
#include "helpers.h" #include "helpers.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include <QApplication> #include <QApplication>
CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) : CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
@ -48,8 +48,10 @@ void CloudStorageAuthenticate::uploadFinished()
QString cloudAuthReply(reply->readAll()); QString cloudAuthReply(reply->readAll());
qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply; qDebug() << "Completed connection with cloud storage backend, response" << cloudAuthReply;
CloudStorageSettings csSettings(parent());
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) { if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
prefs.cloud_verification_status = CS_VERIFIED; csSettings.setVerificationStatus(CS_VERIFIED);
/* TODO: Move this to a correct place /* TODO: Move this to a correct place
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget(); NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
if (nw->getNotificationText() == myLastError) if (nw->getNotificationText() == myLastError)
@ -57,7 +59,7 @@ void CloudStorageAuthenticate::uploadFinished()
*/ */
myLastError.clear(); myLastError.clear();
} else if (cloudAuthReply == QLatin1String("[VERIFY]")) { } else if (cloudAuthReply == QLatin1String("[VERIFY]")) {
prefs.cloud_verification_status = CS_NEED_TO_VERIFY; csSettings.setVerificationStatus(CS_NEED_TO_VERIFY);
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) { } else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
free(prefs.cloud_storage_password); free(prefs.cloud_storage_password);
prefs.cloud_storage_password = prefs.cloud_storage_newpassword; prefs.cloud_storage_password = prefs.cloud_storage_newpassword;
@ -65,7 +67,7 @@ void CloudStorageAuthenticate::uploadFinished()
emit passwordChangeSuccessful(); emit passwordChangeSuccessful();
return; return;
} else { } else {
prefs.cloud_verification_status = CS_INCORRECT_USER_PASSWD; csSettings.setVerificationStatus(CS_INCORRECT_USER_PASSWD);
myLastError = cloudAuthReply; myLastError = cloudAuthReply;
report_error("%s", qPrintable(cloudAuthReply)); report_error("%s", qPrintable(cloudAuthReply));
/* TODO: Emit a signal with the error /* TODO: Emit a signal with the error