summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/preferences/preferences_network.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/preferences/preferences_network.cpp')
-rw-r--r--desktop-widgets/preferences/preferences_network.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/desktop-widgets/preferences/preferences_network.cpp b/desktop-widgets/preferences/preferences_network.cpp
index a1f264b73..8a48b5a25 100644
--- a/desktop-widgets/preferences/preferences_network.cpp
+++ b/desktop-widgets/preferences/preferences_network.cpp
@@ -2,9 +2,7 @@
#include "preferences_network.h"
#include "ui_preferences_network.h"
#include "subsurfacewebservices.h"
-#include "core/cloudstorage.h"
#include "core/errorhelper.h"
-#include "core/settings/qPrefCloudStorage.h"
#include "core/settings/qPrefProxy.h"
#include <QNetworkProxy>
@@ -35,15 +33,10 @@ void PreferencesNetwork::refreshSettings()
ui->proxyUsername->setText(prefs.proxy_user);
ui->proxyPassword->setText(prefs.proxy_pass);
ui->proxyType->setCurrentIndex(ui->proxyType->findData(prefs.proxy_type));
- ui->cloud_storage_email->setText(prefs.cloud_storage_email);
- ui->cloud_storage_password->setText(prefs.cloud_storage_password);
- ui->save_password_local->setChecked(prefs.save_password_local);
- updateCloudAuthenticationState();
}
void PreferencesNetwork::syncSettings()
{
- auto cloud = qPrefCloudStorage::instance();
auto proxy = qPrefProxy::instance();
proxy->set_proxy_type(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
@@ -52,94 +45,8 @@ void PreferencesNetwork::syncSettings()
proxy->set_proxy_auth(ui->proxyAuthRequired->isChecked());
proxy->set_proxy_user(ui->proxyUsername->text());
proxy->set_proxy_pass(ui->proxyPassword->text());
-
- QString email = ui->cloud_storage_email->text().toLower();
- QString password = ui->cloud_storage_password->text();
- QString newpassword = ui->cloud_storage_new_passwd->text();
-
- //TODO: Change this to the Cloud Storage Stuff, not preferences.
- if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED && !newpassword.isEmpty()) {
- // deal with password change
- if (!email.isEmpty() && !password.isEmpty()) {
- // connect to backend server to check / create credentials
- QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
- if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
- report_error(qPrintable(tr("Change ignored. Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
- return;
- }
- if (!reg.match(email).hasMatch() || (!newpassword.isEmpty() && !reg.match(newpassword).hasMatch())) {
- report_error(qPrintable(tr("Change ignored. Cloud storage email and new password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
- ui->cloud_storage_new_passwd->setText("");
- return;
- }
- CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
- connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
- connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful);
- cloudAuth->backend(email, password, "", newpassword);
- ui->cloud_storage_new_passwd->setText("");
- }
- } else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_UNKNOWN ||
- prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD ||
- email != prefs.cloud_storage_email ||
- password != prefs.cloud_storage_password) {
-
- // different credentials - reset verification status
- int oldVerificationStatus = cloud->cloud_verification_status();
- cloud->set_cloud_verification_status(qPrefCloudStorage::CS_UNKNOWN);
- if (!email.isEmpty() && !password.isEmpty()) {
- // connect to backend server to check / create credentials
- QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
- if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
- report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
- cloud->set_cloud_verification_status(oldVerificationStatus);
- return;
- }
- CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
- connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
- cloudAuth->backend(email, password);
- }
- } else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
- QString pin = ui->cloud_storage_pin->text();
- if (!pin.isEmpty()) {
- // connect to backend server to check / create credentials
- QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
- if (!reg.match(email).hasMatch() || !reg.match(password).hasMatch()) {
- report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
- return;
- }
- CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
- connect(cloudAuth, SIGNAL(finishedAuthenticate()), this, SLOT(updateCloudAuthenticationState()));
- cloudAuth->backend(email, password, pin);
- }
- }
- cloud->set_cloud_storage_email(email);
- cloud->set_save_password_local(ui->save_password_local->isChecked());
- cloud->set_cloud_storage_password(password);
- cloud->set_cloud_verification_status(prefs.cloud_verification_status);
- cloud->set_cloud_base_url(prefs.cloud_base_url);
}
-void PreferencesNetwork::updateCloudAuthenticationState()
-{
- ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
- ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
- ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
- ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY);
- ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
- ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
- ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
- ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
- if (prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED) {
- ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (credentials verified)"));
- } else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
- ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (incorrect password)"));
- } else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
- ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage (PIN required)"));
- } else {
- ui->cloudStorageGroupBox->setTitle(tr("Subsurface cloud storage"));
- }
- emit settingsChanged();
-}
void PreferencesNetwork::proxyType_changed(int idx)
{
@@ -157,7 +64,3 @@ void PreferencesNetwork::proxyType_changed(int idx)
ui->proxyAuthRequired->setChecked(ui->proxyAuthRequired->isChecked());
}
-void PreferencesNetwork::passwordUpdateSuccessful()
-{
- ui->cloud_storage_password->setText(prefs.cloud_storage_password);
-}