mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Settings update: Fix "Network" and "CloudStorage"
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
81d5d82b7b
commit
b5e98ec993
1 changed files with 16 additions and 29 deletions
|
@ -52,20 +52,18 @@ void PreferencesNetwork::syncSettings()
|
|||
cloud->setUserId(ui->default_uid->text().toUpper());
|
||||
cloud->setSaveUserIdLocal(ui->save_uid_local->checkState());
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup("Network");
|
||||
s.setValue("proxy_type", ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
||||
s.setValue("proxy_host", ui->proxyHost->text());
|
||||
s.setValue("proxy_port", ui->proxyPort->value());
|
||||
SB("proxy_auth", ui->proxyAuthRequired);
|
||||
s.setValue("proxy_user", ui->proxyUsername->text());
|
||||
s.setValue("proxy_pass", ui->proxyPassword->text());
|
||||
s.endGroup();
|
||||
proxy->setType(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
||||
proxy->setHost(ui->proxyHost->text());
|
||||
proxy->setPort(ui->proxyPort->value());
|
||||
proxy->setAuth(ui->proxyAuthRequired->isChecked());
|
||||
proxy->setUser(ui->proxyUsername->text());
|
||||
proxy->setPass(ui->proxyPassword->text());
|
||||
|
||||
s.beginGroup("CloudStorage");
|
||||
QString email = ui->cloud_storage_email->text();
|
||||
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 == CS_VERIFIED && !newpassword.isEmpty()) {
|
||||
// deal with password change
|
||||
if (!email.isEmpty() && !password.isEmpty()) {
|
||||
|
@ -79,8 +77,7 @@ void PreferencesNetwork::syncSettings()
|
|||
connect(cloudAuth, SIGNAL(passwordChangeSuccessful()), this, SLOT(passwordUpdateSuccessfull()));
|
||||
cloudAuth->backend(email, password, "", newpassword);
|
||||
ui->cloud_storage_new_passwd->setText("");
|
||||
free(prefs.cloud_storage_newpassword);
|
||||
prefs.cloud_storage_newpassword = strdup(qPrintable(newpassword));
|
||||
cloud->setNewPassword(newpassword);
|
||||
}
|
||||
}
|
||||
} else if (prefs.cloud_verification_status == CS_UNKNOWN ||
|
||||
|
@ -89,7 +86,7 @@ void PreferencesNetwork::syncSettings()
|
|||
password != prefs.cloud_storage_password) {
|
||||
|
||||
// different credentials - reset verification status
|
||||
prefs.cloud_verification_status = CS_UNKNOWN;
|
||||
cloud->setVerificationStatus(CS_UNKNOWN);
|
||||
if (!email.isEmpty() && !password.isEmpty()) {
|
||||
// connect to backend server to check / create credentials
|
||||
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
||||
|
@ -114,22 +111,12 @@ void PreferencesNetwork::syncSettings()
|
|||
cloudAuth->backend(email, password, pin);
|
||||
}
|
||||
}
|
||||
SAVE_OR_REMOVE("email", default_prefs.cloud_storage_email, email);
|
||||
SAVE_OR_REMOVE("save_password_local", default_prefs.save_password_local, ui->save_password_local->isChecked());
|
||||
if (ui->save_password_local->isChecked()) {
|
||||
SAVE_OR_REMOVE("password", default_prefs.cloud_storage_password, password);
|
||||
} else {
|
||||
s.remove("password");
|
||||
free(prefs.cloud_storage_password);
|
||||
prefs.cloud_storage_password = strdup(qPrintable(password));
|
||||
}
|
||||
SAVE_OR_REMOVE("cloud_verification_status", default_prefs.cloud_verification_status, prefs.cloud_verification_status);
|
||||
SAVE_OR_REMOVE("cloud_background_sync", default_prefs.cloud_background_sync, ui->cloud_background_sync->isChecked());
|
||||
|
||||
// at this point we intentionally do not have a UI for changing this
|
||||
// it could go into some sort of "advanced setup" or something
|
||||
SAVE_OR_REMOVE("cloud_base_url", default_prefs.cloud_base_url, prefs.cloud_base_url);
|
||||
s.endGroup();
|
||||
cloud->setEmail(email);
|
||||
cloud->setSavePasswordLocal(ui->save_password_local->isChecked());
|
||||
cloud->setPassword(password);
|
||||
cloud->setVerificationStatus(prefs.cloud_verification_status);
|
||||
cloud->setBackgroundSync(ui->cloud_background_sync->isChecked());
|
||||
cloud->setBaseUrl(prefs.cloud_base_url);
|
||||
}
|
||||
|
||||
void PreferencesNetwork::cloudPinNeeded()
|
||||
|
|
Loading…
Add table
Reference in a new issue