mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 19:13:23 +00:00
core: activate qPrefCloudStorage
remove CloudStorage from SettingsObjectWrapper and reference qPrefCloudStorage update files using SettingsObjectWrapper/CloudStorage to use qPrefCloudStorage this activated qPrefCloudStorage and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
4b68329c9d
commit
b9b1f03f0d
7 changed files with 58 additions and 315 deletions
|
@ -3,7 +3,6 @@
|
||||||
#include "pref.h"
|
#include "pref.h"
|
||||||
#include "qthelper.h"
|
#include "qthelper.h"
|
||||||
#include "settings/qPref.h"
|
#include "settings/qPref.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
|
CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) :
|
||||||
|
@ -49,10 +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());
|
qPrefCloudStorage csSettings(parent());
|
||||||
|
|
||||||
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
|
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
|
||||||
csSettings.setVerificationStatus(qPref::CS_VERIFIED);
|
csSettings.set_cloud_verification_status(qPref::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)
|
||||||
|
@ -61,7 +60,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
myLastError.clear();
|
myLastError.clear();
|
||||||
} else if (cloudAuthReply == QLatin1String("[VERIFY]") ||
|
} else if (cloudAuthReply == QLatin1String("[VERIFY]") ||
|
||||||
cloudAuthReply == QLatin1String("Invalid PIN")) {
|
cloudAuthReply == QLatin1String("Invalid PIN")) {
|
||||||
csSettings.setVerificationStatus(qPref::CS_NEED_TO_VERIFY);
|
csSettings.set_cloud_verification_status(qPref::CS_NEED_TO_VERIFY);
|
||||||
report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
|
report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
|
||||||
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
|
||||||
free((void *)prefs.cloud_storage_password);
|
free((void *)prefs.cloud_storage_password);
|
||||||
|
@ -70,7 +69,7 @@ void CloudStorageAuthenticate::uploadFinished()
|
||||||
emit passwordChangeSuccessful();
|
emit passwordChangeSuccessful();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
csSettings.setVerificationStatus(qPref::CS_INCORRECT_USER_PASSWD);
|
csSettings.set_cloud_verification_status(qPref::CS_INCORRECT_USER_PASSWD);
|
||||||
myLastError = cloudAuthReply;
|
myLastError = cloudAuthReply;
|
||||||
report_error("%s", qPrintable(cloudAuthReply));
|
report_error("%s", qPrintable(cloudAuthReply));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ static qPref *self = new qPref;
|
||||||
|
|
||||||
void qPref::loadSync(bool doSync)
|
void qPref::loadSync(bool doSync)
|
||||||
{
|
{
|
||||||
|
qPrefCloudStorage::instance()->loadSync(doSync);
|
||||||
qPrefDisplay::instance()->loadSync(doSync);
|
qPrefDisplay::instance()->loadSync(doSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -975,185 +975,6 @@ void ProxySettings::setPass(const QString& value)
|
||||||
emit passChanged(value);
|
emit passChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudStorageSettings::CloudStorageSettings(QObject *parent) :
|
|
||||||
QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CloudStorageSettings::gitLocalOnly() const
|
|
||||||
{
|
|
||||||
return prefs.git_local_only;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::password() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_storage_password);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::newPassword() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_storage_newpassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::email() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_storage_email);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::emailEncoded() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_storage_email_encoded);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CloudStorageSettings::savePasswordLocal() const
|
|
||||||
{
|
|
||||||
return prefs.save_password_local;
|
|
||||||
}
|
|
||||||
|
|
||||||
short CloudStorageSettings::verificationStatus() const
|
|
||||||
{
|
|
||||||
return prefs.cloud_verification_status;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::userId() const
|
|
||||||
{
|
|
||||||
return QString(prefs.userid);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::baseUrl() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_base_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CloudStorageSettings::gitUrl() const
|
|
||||||
{
|
|
||||||
return QString(prefs.cloud_git_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setPassword(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_storage_password)
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("password", value);
|
|
||||||
free((void *)prefs.cloud_storage_password);
|
|
||||||
prefs.cloud_storage_password = copy_qstring(value);
|
|
||||||
emit passwordChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setNewPassword(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_storage_newpassword)
|
|
||||||
return;
|
|
||||||
/*TODO: This looks like wrong, but 'new password' is not saved on disk, why it's on prefs? */
|
|
||||||
free((void *)prefs.cloud_storage_newpassword);
|
|
||||||
prefs.cloud_storage_newpassword = copy_qstring(value);
|
|
||||||
emit newPasswordChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setEmail(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_storage_email)
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("email", value);
|
|
||||||
free((void *)prefs.cloud_storage_email);
|
|
||||||
prefs.cloud_storage_email = copy_qstring(value);
|
|
||||||
emit emailChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setUserId(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.userid)
|
|
||||||
return;
|
|
||||||
//WARNING: UserId is stored outside of any group, but it belongs to Cloud Storage.
|
|
||||||
QSettings s;
|
|
||||||
s.setValue("subsurface_webservice_uid", value);
|
|
||||||
free((void *)prefs.userid);
|
|
||||||
prefs.userid = copy_qstring(value);
|
|
||||||
emit userIdChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setEmailEncoded(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_storage_email_encoded)
|
|
||||||
return;
|
|
||||||
/*TODO: This looks like wrong, but 'email encoded' is not saved on disk, why it's on prefs? */
|
|
||||||
free((void *)prefs.cloud_storage_email_encoded);
|
|
||||||
prefs.cloud_storage_email_encoded = copy_qstring(value);
|
|
||||||
emit emailEncodedChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setSavePasswordLocal(bool value)
|
|
||||||
{
|
|
||||||
if (value == prefs.save_password_local)
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("save_password_local", value);
|
|
||||||
prefs.save_password_local = value;
|
|
||||||
emit savePasswordLocalChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setVerificationStatus(short value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_verification_status)
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("cloud_verification_status", value);
|
|
||||||
prefs.cloud_verification_status = value;
|
|
||||||
emit verificationStatusChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setSaveUserIdLocal(bool value)
|
|
||||||
{
|
|
||||||
//TODO: this is not saved on disk?
|
|
||||||
if (value == prefs.save_userid_local)
|
|
||||||
return;
|
|
||||||
prefs.save_userid_local = value;
|
|
||||||
emit saveUserIdLocalChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CloudStorageSettings::saveUserIdLocal() const
|
|
||||||
{
|
|
||||||
return prefs.save_userid_local;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setBaseUrl(const QString& value)
|
|
||||||
{
|
|
||||||
if (value == prefs.cloud_base_url)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// dont free data segment.
|
|
||||||
if (prefs.cloud_base_url != default_prefs.cloud_base_url) {
|
|
||||||
free((void *)prefs.cloud_base_url);
|
|
||||||
free((void *)prefs.cloud_git_url);
|
|
||||||
}
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("cloud_base_url", value);
|
|
||||||
prefs.cloud_base_url = copy_qstring(value);
|
|
||||||
prefs.cloud_git_url = copy_qstring(QString(prefs.cloud_base_url) + "/git");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setGitUrl(const QString&)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CloudStorageSettings::setGitLocalOnly(bool value)
|
|
||||||
{
|
|
||||||
if (value == prefs.git_local_only)
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup("CloudStorage");
|
|
||||||
s.setValue("git_local_only", value);
|
|
||||||
prefs.git_local_only = value;
|
|
||||||
emit gitLocalOnlyChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
DivePlannerSettings::DivePlannerSettings(QObject *parent) :
|
DivePlannerSettings::DivePlannerSettings(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
|
@ -2100,7 +1921,7 @@ QObject(parent),
|
||||||
facebook(new FacebookSettings(this)),
|
facebook(new FacebookSettings(this)),
|
||||||
geocoding(new GeocodingPreferences(this)),
|
geocoding(new GeocodingPreferences(this)),
|
||||||
proxy(new ProxySettings(this)),
|
proxy(new ProxySettings(this)),
|
||||||
cloud_storage(new CloudStorageSettings(this)),
|
cloud_storage(new qPrefCloudStorage(this)),
|
||||||
planner_settings(new DivePlannerSettings(this)),
|
planner_settings(new DivePlannerSettings(this)),
|
||||||
unit_settings(new UnitsSettings(this)),
|
unit_settings(new UnitsSettings(this)),
|
||||||
general_settings(new GeneralSettingsObjectWrapper(this)),
|
general_settings(new GeneralSettingsObjectWrapper(this)),
|
||||||
|
@ -2212,28 +2033,7 @@ void SettingsObjectWrapper::load()
|
||||||
GET_TXT("proxy_pass", proxy_pass);
|
GET_TXT("proxy_pass", proxy_pass);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup("CloudStorage");
|
qPrefCloudStorage::instance()->load();
|
||||||
GET_TXT("email", cloud_storage_email);
|
|
||||||
#ifndef SUBSURFACE_MOBILE
|
|
||||||
GET_BOOL("save_password_local", save_password_local);
|
|
||||||
#else
|
|
||||||
// always save the password in Subsurface-mobile
|
|
||||||
prefs.save_password_local = true;
|
|
||||||
#endif
|
|
||||||
if (prefs.save_password_local) { // GET_TEXT macro is not a single statement
|
|
||||||
GET_TXT("password", cloud_storage_password);
|
|
||||||
}
|
|
||||||
GET_INT("cloud_verification_status", cloud_verification_status);
|
|
||||||
GET_BOOL("git_local_only", git_local_only);
|
|
||||||
|
|
||||||
// creating the git url here is simply a convenience when C code wants
|
|
||||||
// to compare against that git URL - it's always derived from the base URL
|
|
||||||
GET_TXT("cloud_base_url", cloud_base_url);
|
|
||||||
prefs.cloud_git_url = copy_qstring(QString(prefs.cloud_base_url) + "/git");
|
|
||||||
s.endGroup();
|
|
||||||
|
|
||||||
// Subsurface webservice id is stored outside of the groups
|
|
||||||
GET_TXT("subsurface_webservice_uid", userid);
|
|
||||||
|
|
||||||
// GeoManagement
|
// GeoManagement
|
||||||
s.beginGroup("geocoding");
|
s.beginGroup("geocoding");
|
||||||
|
|
|
@ -326,63 +326,6 @@ private:
|
||||||
const QString group = QStringLiteral("Network");
|
const QString group = QStringLiteral("Network");
|
||||||
};
|
};
|
||||||
|
|
||||||
class CloudStorageSettings : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
|
|
||||||
Q_PROPERTY(QString newpassword READ newPassword WRITE setNewPassword NOTIFY newPasswordChanged)
|
|
||||||
Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged)
|
|
||||||
Q_PROPERTY(QString email_encoded READ emailEncoded WRITE setEmailEncoded NOTIFY emailEncodedChanged)
|
|
||||||
Q_PROPERTY(QString userid READ userId WRITE setUserId NOTIFY userIdChanged)
|
|
||||||
Q_PROPERTY(QString base_url READ baseUrl WRITE setBaseUrl NOTIFY baseUrlChanged)
|
|
||||||
Q_PROPERTY(QString git_url READ gitUrl WRITE setGitUrl NOTIFY gitUrlChanged)
|
|
||||||
Q_PROPERTY(bool save_userid_local READ saveUserIdLocal WRITE setSaveUserIdLocal NOTIFY saveUserIdLocalChanged)
|
|
||||||
Q_PROPERTY(bool git_local_only READ gitLocalOnly WRITE setGitLocalOnly NOTIFY gitLocalOnlyChanged)
|
|
||||||
Q_PROPERTY(bool save_password_local READ savePasswordLocal WRITE setSavePasswordLocal NOTIFY savePasswordLocalChanged)
|
|
||||||
Q_PROPERTY(short verification_status READ verificationStatus WRITE setVerificationStatus NOTIFY verificationStatusChanged)
|
|
||||||
public:
|
|
||||||
CloudStorageSettings(QObject *parent);
|
|
||||||
QString password() const;
|
|
||||||
QString newPassword() const;
|
|
||||||
QString email() const;
|
|
||||||
QString emailEncoded() const;
|
|
||||||
QString userId() const;
|
|
||||||
QString baseUrl() const;
|
|
||||||
QString gitUrl() const;
|
|
||||||
bool savePasswordLocal() const;
|
|
||||||
short verificationStatus() const;
|
|
||||||
bool gitLocalOnly() const;
|
|
||||||
bool saveUserIdLocal() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setPassword(const QString& value);
|
|
||||||
void setNewPassword(const QString& value);
|
|
||||||
void setEmail(const QString& value);
|
|
||||||
void setEmailEncoded(const QString& value);
|
|
||||||
void setUserId(const QString& value);
|
|
||||||
void setBaseUrl(const QString& value);
|
|
||||||
void setGitUrl(const QString& value);
|
|
||||||
void setSavePasswordLocal(bool value);
|
|
||||||
void setVerificationStatus(short value);
|
|
||||||
void setGitLocalOnly(bool value);
|
|
||||||
void setSaveUserIdLocal(bool value);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void passwordChanged(const QString& value);
|
|
||||||
void newPasswordChanged(const QString& value);
|
|
||||||
void emailChanged(const QString& value);
|
|
||||||
void emailEncodedChanged(const QString& value);
|
|
||||||
void userIdChanged(const QString& value);
|
|
||||||
void baseUrlChanged(const QString& value);
|
|
||||||
void gitUrlChanged(const QString& value);
|
|
||||||
void savePasswordLocalChanged(bool value);
|
|
||||||
void verificationStatusChanged(short value);
|
|
||||||
void gitLocalOnlyChanged(bool value);
|
|
||||||
void saveUserIdLocalChanged(bool value);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QString group = QStringLiteral("CloudStorage");
|
|
||||||
};
|
|
||||||
|
|
||||||
class DivePlannerSettings : public QObject {
|
class DivePlannerSettings : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool last_stop READ lastStop WRITE setLastStop NOTIFY lastStopChanged)
|
Q_PROPERTY(bool last_stop READ lastStop WRITE setLastStop NOTIFY lastStopChanged)
|
||||||
|
@ -666,7 +609,7 @@ class SettingsObjectWrapper : public QObject {
|
||||||
Q_PROPERTY(FacebookSettings* facebook MEMBER facebook CONSTANT)
|
Q_PROPERTY(FacebookSettings* facebook MEMBER facebook CONSTANT)
|
||||||
Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT)
|
Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT)
|
||||||
Q_PROPERTY(ProxySettings* proxy MEMBER proxy CONSTANT)
|
Q_PROPERTY(ProxySettings* proxy MEMBER proxy CONSTANT)
|
||||||
Q_PROPERTY(CloudStorageSettings* cloud_storage MEMBER cloud_storage CONSTANT)
|
Q_PROPERTY(qPrefCloudStorage* cloud_storage MEMBER cloud_storage CONSTANT)
|
||||||
Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
|
Q_PROPERTY(DivePlannerSettings* planner MEMBER planner_settings CONSTANT)
|
||||||
Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
|
Q_PROPERTY(UnitsSettings* units MEMBER unit_settings CONSTANT)
|
||||||
|
|
||||||
|
@ -686,7 +629,7 @@ public:
|
||||||
FacebookSettings *facebook;
|
FacebookSettings *facebook;
|
||||||
GeocodingPreferences *geocoding;
|
GeocodingPreferences *geocoding;
|
||||||
ProxySettings *proxy;
|
ProxySettings *proxy;
|
||||||
CloudStorageSettings *cloud_storage;
|
qPrefCloudStorage *cloud_storage;
|
||||||
DivePlannerSettings *planner_settings;
|
DivePlannerSettings *planner_settings;
|
||||||
UnitsSettings *unit_settings;
|
UnitsSettings *unit_settings;
|
||||||
GeneralSettingsObjectWrapper *general_settings;
|
GeneralSettingsObjectWrapper *general_settings;
|
||||||
|
|
|
@ -48,8 +48,8 @@ void PreferencesNetwork::syncSettings()
|
||||||
auto cloud = SettingsObjectWrapper::instance()->cloud_storage;
|
auto cloud = SettingsObjectWrapper::instance()->cloud_storage;
|
||||||
auto proxy = SettingsObjectWrapper::instance()->proxy;
|
auto proxy = SettingsObjectWrapper::instance()->proxy;
|
||||||
|
|
||||||
cloud->setUserId(ui->default_uid->text().toUpper());
|
cloud->set_userid(ui->default_uid->text().toUpper());
|
||||||
cloud->setSaveUserIdLocal(ui->save_uid_local->checkState());
|
cloud->set_save_userid_local(ui->save_uid_local->checkState());
|
||||||
|
|
||||||
proxy->setType(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
proxy->setType(ui->proxyType->itemData(ui->proxyType->currentIndex()).toInt());
|
||||||
proxy->setHost(ui->proxyHost->text());
|
proxy->setHost(ui->proxyHost->text());
|
||||||
|
@ -82,7 +82,7 @@ void PreferencesNetwork::syncSettings()
|
||||||
connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful);
|
connect(cloudAuth, &CloudStorageAuthenticate::passwordChangeSuccessful, this, &PreferencesNetwork::passwordUpdateSuccessful);
|
||||||
cloudAuth->backend(email, password, "", newpassword);
|
cloudAuth->backend(email, password, "", newpassword);
|
||||||
ui->cloud_storage_new_passwd->setText("");
|
ui->cloud_storage_new_passwd->setText("");
|
||||||
cloud->setNewPassword(newpassword);
|
cloud->set_cloud_storage_newpassword(newpassword);
|
||||||
}
|
}
|
||||||
} else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN ||
|
} else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN ||
|
||||||
prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD ||
|
prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD ||
|
||||||
|
@ -90,14 +90,14 @@ void PreferencesNetwork::syncSettings()
|
||||||
password != prefs.cloud_storage_password) {
|
password != prefs.cloud_storage_password) {
|
||||||
|
|
||||||
// different credentials - reset verification status
|
// different credentials - reset verification status
|
||||||
int oldVerificationStatus = cloud->verificationStatus();
|
int oldVerificationStatus = cloud->cloud_verification_status();
|
||||||
cloud->setVerificationStatus(qPref::CS_UNKNOWN);
|
cloud->set_cloud_verification_status(qPref::CS_UNKNOWN);
|
||||||
if (!email.isEmpty() && !password.isEmpty()) {
|
if (!email.isEmpty() && !password.isEmpty()) {
|
||||||
// connect to backend server to check / create credentials
|
// connect to backend server to check / create credentials
|
||||||
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
QRegularExpression reg("^[a-zA-Z0-9@.+_-]+$");
|
||||||
if (!reg.match(email).hasMatch() || (!password.isEmpty() && !reg.match(password).hasMatch())) {
|
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 '+'.")));
|
report_error(qPrintable(tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.")));
|
||||||
cloud->setVerificationStatus(oldVerificationStatus);
|
cloud->set_cloud_verification_status(oldVerificationStatus);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
CloudStorageAuthenticate *cloudAuth = new CloudStorageAuthenticate(this);
|
||||||
|
@ -118,11 +118,11 @@ void PreferencesNetwork::syncSettings()
|
||||||
cloudAuth->backend(email, password, pin);
|
cloudAuth->backend(email, password, pin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cloud->setEmail(email);
|
cloud->set_cloud_storage_email(email);
|
||||||
cloud->setSavePasswordLocal(ui->save_password_local->isChecked());
|
cloud->set_save_password_local(ui->save_password_local->isChecked());
|
||||||
cloud->setPassword(password);
|
cloud->set_cloud_storage_password(password);
|
||||||
cloud->setVerificationStatus(prefs.cloud_verification_status);
|
cloud->set_cloud_verification_status(prefs.cloud_verification_status);
|
||||||
cloud->setBaseUrl(prefs.cloud_base_url);
|
cloud->set_cloud_base_url(prefs.cloud_base_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesNetwork::updateCloudAuthenticationState()
|
void PreferencesNetwork::updateCloudAuthenticationState()
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "desktop-widgets/subsurfacewebservices.h"
|
#include "desktop-widgets/subsurfacewebservices.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/webservice.h"
|
#include "core/webservice.h"
|
||||||
|
#include "core/settings/qPref.h"
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
#include "desktop-widgets/usersurvey.h"
|
#include "desktop-widgets/usersurvey.h"
|
||||||
#include "core/divelist.h"
|
#include "core/divelist.h"
|
||||||
|
@ -9,7 +10,6 @@
|
||||||
#include "desktop-widgets/tab-widgets/maintab.h"
|
#include "desktop-widgets/tab-widgets/maintab.h"
|
||||||
#include "core/display.h"
|
#include "core/display.h"
|
||||||
#include "core/membuffer.h"
|
#include "core/membuffer.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "core/cloudstorage.h"
|
#include "core/cloudstorage.h"
|
||||||
#include "core/subsurface-string.h"
|
#include "core/subsurface-string.h"
|
||||||
|
@ -436,7 +436,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
|
||||||
QSettings s;
|
QSettings s;
|
||||||
QString qDialogUid = ui.userID->text().toUpper();
|
QString qDialogUid = ui.userID->text().toUpper();
|
||||||
bool qSaveUid = ui.saveUidLocal->checkState();
|
bool qSaveUid = ui.saveUidLocal->checkState();
|
||||||
SettingsObjectWrapper::instance()->cloud_storage->setSaveUserIdLocal(qSaveUid);
|
qPrefCloudStorage::instance()->set_save_userid_local(qSaveUid);
|
||||||
|
|
||||||
//WARN: Dirk, this seems to be wrong, I coundn't really understand the code.
|
//WARN: Dirk, this seems to be wrong, I coundn't really understand the code.
|
||||||
if (qSaveUid) {
|
if (qSaveUid) {
|
||||||
|
|
|
@ -26,51 +26,51 @@ void TestPreferences::testPreferences()
|
||||||
|
|
||||||
auto cloud = pref->cloud_storage;
|
auto cloud = pref->cloud_storage;
|
||||||
|
|
||||||
cloud->setBaseUrl("test_one");
|
cloud->set_cloud_base_url("test_one");
|
||||||
TEST(cloud->baseUrl(), QStringLiteral("test_one"));
|
TEST(cloud->cloud_base_url(), QStringLiteral("test_one"));
|
||||||
cloud->setBaseUrl("test_two");
|
cloud->set_cloud_base_url("test_two");
|
||||||
TEST(cloud->baseUrl(), QStringLiteral("test_two"));
|
TEST(cloud->cloud_base_url(), QStringLiteral("test_two"));
|
||||||
|
|
||||||
cloud->setEmail("tomaz@subsurface.com");
|
cloud->set_cloud_storage_email("tomaz@subsurface.com");
|
||||||
TEST(cloud->email(), QStringLiteral("tomaz@subsurface.com"));
|
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@subsurface.com"));
|
||||||
cloud->setEmail("tomaz@gmail.com");
|
cloud->set_cloud_storage_email("tomaz@gmail.com");
|
||||||
TEST(cloud->email(), QStringLiteral("tomaz@gmail.com"));
|
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com"));
|
||||||
|
|
||||||
cloud->setGitLocalOnly(true);
|
cloud->set_git_local_only(true);
|
||||||
TEST(cloud->gitLocalOnly(), true);
|
TEST(cloud->git_local_only(), true);
|
||||||
cloud->setGitLocalOnly(false);
|
cloud->set_git_local_only(false);
|
||||||
TEST(cloud->gitLocalOnly(), false);
|
TEST(cloud->git_local_only(), false);
|
||||||
|
|
||||||
// Why there's new password and password on the prefs?
|
// Why there's new password and password on the prefs?
|
||||||
cloud->setNewPassword("ABCD");
|
cloud->set_cloud_storage_newpassword("ABCD");
|
||||||
TEST(cloud->newPassword(), QStringLiteral("ABCD"));
|
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD"));
|
||||||
cloud->setNewPassword("ABCDE");
|
cloud->set_cloud_storage_newpassword("ABCDE");
|
||||||
TEST(cloud->newPassword(), QStringLiteral("ABCDE"));
|
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCDE"));
|
||||||
|
|
||||||
cloud->setPassword("ABCDE");
|
cloud->set_cloud_storage_password("ABCDE");
|
||||||
TEST(cloud->password(), QStringLiteral("ABCDE"));
|
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCDE"));
|
||||||
cloud->setPassword("ABCABC");
|
cloud->set_cloud_storage_password("ABCABC");
|
||||||
TEST(cloud->password(), QStringLiteral("ABCABC"));
|
TEST(cloud->cloud_storage_password(), QStringLiteral("ABCABC"));
|
||||||
|
|
||||||
cloud->setSavePasswordLocal(true);
|
cloud->set_save_password_local(true);
|
||||||
TEST(cloud->savePasswordLocal(), true);
|
TEST(cloud->save_password_local(), true);
|
||||||
cloud->setSavePasswordLocal(false);
|
cloud->set_save_password_local(false);
|
||||||
TEST(cloud->savePasswordLocal(), false);
|
TEST(cloud->save_password_local(), false);
|
||||||
|
|
||||||
cloud->setSaveUserIdLocal(1);
|
cloud->set_save_userid_local(1);
|
||||||
TEST(cloud->saveUserIdLocal(), true);
|
TEST(cloud->save_userid_local(), true);
|
||||||
cloud->setSaveUserIdLocal(0);
|
cloud->set_save_userid_local(0);
|
||||||
TEST(cloud->saveUserIdLocal(), false);
|
TEST(cloud->save_userid_local(), false);
|
||||||
|
|
||||||
cloud->setUserId("Tomaz");
|
cloud->set_userid("Tomaz");
|
||||||
TEST(cloud->userId(), QStringLiteral("Tomaz"));
|
TEST(cloud->userid(), QStringLiteral("Tomaz"));
|
||||||
cloud->setUserId("Zamot");
|
cloud->set_userid("Zamot");
|
||||||
TEST(cloud->userId(), QStringLiteral("Zamot"));
|
TEST(cloud->userid(), QStringLiteral("Zamot"));
|
||||||
|
|
||||||
cloud->setVerificationStatus(0);
|
cloud->set_cloud_verification_status(0);
|
||||||
TEST(cloud->verificationStatus(), (short)0);
|
TEST(cloud->cloud_verification_status(), (short)0);
|
||||||
cloud->setVerificationStatus(1);
|
cloud->set_cloud_verification_status(1);
|
||||||
TEST(cloud->verificationStatus(), (short)1);
|
TEST(cloud->cloud_verification_status(), (short)1);
|
||||||
|
|
||||||
auto tecDetails = pref->techDetails;
|
auto tecDetails = pref->techDetails;
|
||||||
tecDetails->setModpO2(0.2);
|
tecDetails->setModpO2(0.2);
|
||||||
|
|
Loading…
Add table
Reference in a new issue