core: declare cloud_status in qPrefCloudStorage

qml declaration of cloud_status (defined in pref.h) does not
belong in qPref.h but in qPrefCloudStorage

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-09-02 16:22:16 +02:00 committed by Dirk Hohndel
parent 4d57b52062
commit 684e334fb6
13 changed files with 82 additions and 82 deletions

View file

@ -52,7 +52,7 @@ void CloudStorageAuthenticate::uploadFinished()
qPrefCloudStorage csSettings(parent());
if (cloudAuthReply == QLatin1String("[VERIFIED]") || cloudAuthReply == QLatin1String("[OK]")) {
csSettings.set_cloud_verification_status(qPref::CS_VERIFIED);
csSettings.set_cloud_verification_status(qPrefCloudStorage::CS_VERIFIED);
/* TODO: Move this to a correct place
NotificationWidget *nw = MainWindow::instance()->getNotificationWidget();
if (nw->getNotificationText() == myLastError)
@ -61,7 +61,7 @@ void CloudStorageAuthenticate::uploadFinished()
myLastError.clear();
} else if (cloudAuthReply == QLatin1String("[VERIFY]") ||
cloudAuthReply == QLatin1String("Invalid PIN")) {
csSettings.set_cloud_verification_status(qPref::CS_NEED_TO_VERIFY);
csSettings.set_cloud_verification_status(qPrefCloudStorage::CS_NEED_TO_VERIFY);
report_error(qPrintable(tr("Cloud account verification required, enter PIN in preferences")));
} else if (cloudAuthReply == QLatin1String("[PASSWDCHANGED]")) {
csSettings.set_cloud_storage_password(cloudNewPassword);
@ -69,7 +69,7 @@ void CloudStorageAuthenticate::uploadFinished()
emit passwordChangeSuccessful();
return;
} else {
csSettings.set_cloud_verification_status(qPref::CS_INCORRECT_USER_PASSWD);
csSettings.set_cloud_verification_status(qPrefCloudStorage::CS_INCORRECT_USER_PASSWD);
myLastError = cloudAuthReply;
report_error("%s", qPrintable(cloudAuthReply));
}

View file

@ -64,7 +64,7 @@ void qPref::registerQML(QQmlEngine *engine)
}
// Register special types
qmlRegisterUncreatableType<qPref>("org.subsurfacedivelog.mobile",1,0,"CloudStatus","Enum is not a type");
qmlRegisterUncreatableType<qPrefCloudStorage>("org.subsurfacedivelog.mobile",1,0,"CloudStatus","Enum is not a type");
qRegisterMetaType<deco_mode>();
qRegisterMetaType<def_file_behavior>();
qRegisterMetaType<taxonomy_category>();

View file

@ -39,15 +39,6 @@ public:
void registerQML(QQmlEngine *engine);
public:
enum cloud_status {
CS_UNKNOWN,
CS_INCORRECT_USER_PASSWD,
CS_NEED_TO_VERIFY,
CS_VERIFIED,
CS_NOCLOUD
};
Q_ENUM(cloud_status);
static const QString canonical_version() { return QString(CANONICAL_VERSION_STRING); }
static const QString mobile_version() { return QString(MOBILE_VERSION_STRING); }

View file

@ -27,6 +27,15 @@ public:
static void sync() { loadSync(true); }
public:
enum cloud_status {
CS_UNKNOWN,
CS_INCORRECT_USER_PASSWD,
CS_NEED_TO_VERIFY,
CS_VERIFIED,
CS_NOCLOUD
};
Q_ENUM(cloud_status);
static QString cloud_base_url() { return prefs.cloud_base_url; }
static QString cloud_git_url() { return prefs.cloud_git_url; }
static QString cloud_storage_email() { return prefs.cloud_storage_email; }

View file

@ -441,8 +441,8 @@ void MainWindow::on_actionDiveSiteEdit_triggered() {
void MainWindow::enableDisableCloudActions()
{
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
ui.actionCloudstorageopen->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
ui.actionCloudstoragesave->setEnabled(prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED);
}
PlannerDetails *MainWindow::plannerDetails() const {
@ -744,7 +744,7 @@ void MainWindow::closeCurrentFile()
void MainWindow::updateCloudOnlineStatus()
{
bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == qPref::CS_VERIFIED &&
bool is_cloud = existing_filename && prefs.cloud_git_url && prefs.cloud_verification_status == qPrefCloudStorage::CS_VERIFIED &&
strstr(existing_filename, prefs.cloud_git_url);
ui.actionCloudOnline->setEnabled(is_cloud);
ui.actionCloudOnline->setChecked(is_cloud && !git_local_only);

View file

@ -77,7 +77,7 @@ void PreferencesDefaults::refreshSettings()
ui->velocitySlider->setValue(qPrefDisplay::animation_speed());
ui->btnUseDefaultFile->setChecked(qPrefGeneral::use_default_file());
if (qPrefCloudStorage::cloud_verification_status() == qPref::CS_VERIFIED) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_VERIFIED) {
ui->cloudDefaultFile->setEnabled(true);
} else {
if (ui->cloudDefaultFile->isChecked())

View file

@ -57,7 +57,7 @@ void PreferencesNetwork::syncSettings()
QString newpassword = ui->cloud_storage_new_passwd->text();
//TODO: Change this to the Cloud Storage Stuff, not preferences.
if (prefs.cloud_verification_status == qPref::CS_VERIFIED && !newpassword.isEmpty()) {
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
@ -77,14 +77,14 @@ void PreferencesNetwork::syncSettings()
cloudAuth->backend(email, password, "", newpassword);
ui->cloud_storage_new_passwd->setText("");
}
} else if (prefs.cloud_verification_status == qPref::CS_UNKNOWN ||
prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD ||
} 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(qPref::CS_UNKNOWN);
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@.+_-]+$");
@ -97,7 +97,7 @@ void PreferencesNetwork::syncSettings()
connect(cloudAuth, &CloudStorageAuthenticate::finishedAuthenticate, this, &PreferencesNetwork::updateCloudAuthenticationState);
cloudAuth->backend(email, password);
}
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY) {
} 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
@ -120,19 +120,19 @@ void PreferencesNetwork::syncSettings()
void PreferencesNetwork::updateCloudAuthenticationState()
{
ui->cloud_storage_pin->setEnabled(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
ui->cloud_storage_pin->setVisible(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
ui->cloud_storage_pin_label->setEnabled(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
ui->cloud_storage_pin_label->setVisible(prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY);
ui->cloud_storage_new_passwd->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
ui->cloud_storage_new_passwd->setVisible(prefs.cloud_verification_status == qPref::CS_VERIFIED);
ui->cloud_storage_new_passwd_label->setEnabled(prefs.cloud_verification_status == qPref::CS_VERIFIED);
ui->cloud_storage_new_passwd_label->setVisible(prefs.cloud_verification_status == qPref::CS_VERIFIED);
if (prefs.cloud_verification_status == qPref::CS_VERIFIED) {
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 == qPref::CS_INCORRECT_USER_PASSWD) {
} 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 == qPref::CS_NEED_TO_VERIFY) {
} 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"));

View file

@ -270,12 +270,12 @@ void QMLManager::openLocalThenRemote(QString url)
* no cloud repo solves this.
*/
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD)
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NEED_TO_VERIFY);
if (QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_NOCLOUD)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NEED_TO_VERIFY);
} else {
// if we can load from the cache, we know that we have a valid cloud account
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_UNKNOWN)
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_UNKNOWN)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_VERIFIED);
prefs.unit_system = git_prefs.unit_system;
if (git_prefs.unit_system == IMPERIAL)
git_prefs.units = IMPERIAL_units;
@ -293,11 +293,11 @@ void QMLManager::openLocalThenRemote(QString url)
appendTextToLog(QStringLiteral("%1 dives loaded from cache").arg(dive_table.nr));
setNotificationText(tr("%1 dives loaded from local dive data file").arg(dive_table.nr));
}
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_NEED_TO_VERIFY) {
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
appendTextToLog(QStringLiteral("have cloud credentials, but still needs PIN"));
QMLPrefs::instance()->setShowPin(true);
}
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
if (QMLPrefs::instance()->oldStatus() == qPrefCloudStorage::CS_NOCLOUD) {
// if we switch to credentials from CS_NOCLOUD, we take things online temporarily
git_local_only = false;
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
@ -374,7 +374,7 @@ void QMLManager::finishSetup()
QMLPrefs::instance()->setCloudUserName(qPrefCloudStorage::cloud_storage_email());
QMLPrefs::instance()->setCloudPassword(qPrefCloudStorage::cloud_storage_password());
setSyncToCloud(!git_local_only);
QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status);
QMLPrefs::instance()->setCredentialStatus((qPrefCloudStorage::cloud_status) prefs.cloud_verification_status);
// if the cloud credentials are valid, we should get the GPS Webservice ID as well
QString url;
if (!QMLPrefs::instance()->cloudUserName().isEmpty() &&
@ -385,8 +385,8 @@ void QMLManager::finishSetup()
alreadySaving = true;
openLocalThenRemote(url);
} else if (!empty_string(existing_filename) &&
QMLPrefs::instance()->credentialStatus() != qPref::CS_UNKNOWN) {
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NOCLOUD);
QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_UNKNOWN) {
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NOCLOUD);
saveCloudCredentials();
appendTextToLog(tr("working in no-cloud mode"));
int error = parse_file(existing_filename, &dive_table);
@ -400,7 +400,7 @@ void QMLManager::finishSetup()
appendTextToLog(QString("working in no-cloud mode, finished loading %1 dives from %2").arg(dive_table.nr).arg(existing_filename));
}
} else {
QMLPrefs::instance()->setCredentialStatus(qPref::CS_UNKNOWN);
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_UNKNOWN);
appendTextToLog(tr("no cloud credentials"));
setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT);
}
@ -437,7 +437,7 @@ void QMLManager::saveCloudCredentials()
bool cloudCredentialsChanged = false;
// make sure we only have letters, numbers, and +-_. in password and email address
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD) {
if (QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_NOCLOUD) {
// in case of NO_CLOUD, the email address + passwd do not care, so do not check it.
if (QMLPrefs::instance()->cloudPassword().isEmpty() ||
!regExp.match(QMLPrefs::instance()->cloudPassword()).hasMatch() ||
@ -467,7 +467,7 @@ void QMLManager::saveCloudCredentials()
cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password,
qPrintable(QMLPrefs::instance()->cloudPassword()));
if (QMLPrefs::instance()->credentialStatus() != qPref::CS_NOCLOUD &&
if (QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_NOCLOUD &&
!cloudCredentialsChanged) {
// just go back to the dive list
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
@ -478,7 +478,7 @@ void QMLManager::saveCloudCredentials()
free((void *)prefs.cloud_storage_password);
prefs.cloud_storage_password = copy_qstring(QMLPrefs::instance()->cloudPassword());
}
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
if (QMLPrefs::instance()->oldStatus() == qPrefCloudStorage::CS_NOCLOUD && cloudCredentialsChanged && dive_table.nr) {
// we came from NOCLOUD and are connecting to a cloud account;
// since we already have dives in the table, let's remember that so we can keep them
noCloudToCloud = true;
@ -506,7 +506,7 @@ void QMLManager::saveCloudCredentials()
currentGitLocalOnly = git_local_only;
git_local_only = false;
openLocalThenRemote(url);
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY &&
} else if (prefs.cloud_verification_status == qPrefCloudStorage::CS_NEED_TO_VERIFY &&
!QMLPrefs::instance()->cloudPin().isEmpty()) {
// the user entered a PIN?
tryRetrieveDataFromBackend();
@ -540,12 +540,12 @@ void QMLManager::tryRetrieveDataFromBackend()
}
myTimer.stop();
QMLPrefs::instance()->setCloudPin("");
if (prefs.cloud_verification_status == qPref::CS_INCORRECT_USER_PASSWD) {
if (prefs.cloud_verification_status == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
appendTextToLog(QStringLiteral("Incorrect cloud credentials"));
setStartPageText(RED_FONT + tr("Incorrect cloud credentials") + END_FONT);
revertToNoCloudIfNeeded();
return;
} else if (prefs.cloud_verification_status != qPref::CS_VERIFIED) {
} else if (prefs.cloud_verification_status != qPrefCloudStorage::CS_VERIFIED) {
// here we need to enter the PIN
appendTextToLog(QStringLiteral("Need to verify the email address - enter PIN"));
setStartPageText(RED_FONT + tr("Cannot connect to cloud storage - cloud account not verified") + END_FONT);
@ -576,7 +576,7 @@ void QMLManager::provideAuth(QNetworkReply *reply, QAuthenticator *auth)
// OK, credentials have been tried and didn't work, so they are invalid
appendTextToLog("Cloud credentials are invalid");
setStartPageText(RED_FONT + tr("Cloud credentials are invalid") + END_FONT);
QMLPrefs::instance()->setCredentialStatus(qPref::CS_INCORRECT_USER_PASSWD);
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_INCORRECT_USER_PASSWD);
reply->disconnect();
reply->abort();
reply->deleteLater();
@ -620,8 +620,7 @@ void QMLManager::retrieveUserid()
revertToNoCloudIfNeeded();
return;
}
QMLPrefs::instance()->setCredentialStatus(qPref::CS_VERIFIED);
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_VERIFIED);
setStartPageText(tr("Cloud credentials valid, loading dives..."));
// this only gets called with "alreadySaving" already locked
loadDivesWithValidCredentials();
@ -706,7 +705,7 @@ void QMLManager::revertToNoCloudIfNeeded()
currentGitLocalOnly = false;
git_local_only = true;
}
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
if (QMLPrefs::instance()->oldStatus() == qPrefCloudStorage::CS_NOCLOUD) {
// we tried to switch to a cloud account and had previously used local data,
// but connecting to the cloud account (and subsequently merging the local
// and cloud data) failed - so let's delete the cloud credentials and go
@ -722,7 +721,7 @@ void QMLManager::revertToNoCloudIfNeeded()
prefs.cloud_storage_password = NULL;
QMLPrefs::instance()->setCloudUserName("");
QMLPrefs::instance()->setCloudPassword("");
QMLPrefs::instance()->setCredentialStatus(qPref::CS_NOCLOUD);
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NOCLOUD);
set_filename(NOCLOUD_LOCALSTORAGE);
setStartPageText(RED_FONT + tr("Failed to connect to cloud server, reverting to no cloud status") + END_FONT);
}
@ -1200,7 +1199,7 @@ void QMLManager::openNoCloudRepo()
void QMLManager::saveChangesLocal()
{
if (unsaved_changes()) {
if (QMLPrefs::instance()->credentialStatus() == qPref::CS_NOCLOUD) {
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_NOCLOUD) {
if (empty_string(existing_filename)) {
char *filename = NOCLOUD_LOCALSTORAGE;
git_create_local_repo(filename);

View file

@ -11,10 +11,10 @@
QMLPrefs *QMLPrefs::m_instance = NULL;
QMLPrefs::QMLPrefs() :
m_credentialStatus(qPref::CS_UNKNOWN),
m_credentialStatus(qPrefCloudStorage::CS_UNKNOWN),
m_developer(false),
m_distanceThreshold(1000),
m_oldStatus(qPref::CS_UNKNOWN),
m_oldStatus(qPrefCloudStorage::CS_UNKNOWN),
m_showPin(false),
m_timeThreshold(60)
{
@ -69,16 +69,16 @@ void QMLPrefs::setCloudUserName(const QString &cloudUserName)
emit cloudUserNameChanged();
}
qPref::cloud_status QMLPrefs::credentialStatus() const
qPrefCloudStorage::cloud_status QMLPrefs::credentialStatus() const
{
return m_credentialStatus;
}
void QMLPrefs::setCredentialStatus(const qPref::cloud_status value)
void QMLPrefs::setCredentialStatus(const qPrefCloudStorage::cloud_status value)
{
if (m_credentialStatus != value) {
setOldStatus(m_credentialStatus);
if (value == qPref::CS_NOCLOUD) {
if (value == qPrefCloudStorage::CS_NOCLOUD) {
QMLManager::instance()->appendTextToLog("Switching to no cloud mode");
set_filename(NOCLOUD_LOCALSTORAGE);
clearCredentials();
@ -105,12 +105,12 @@ void QMLPrefs::setDistanceThreshold(int distance)
emit distanceThresholdChanged();
}
qPref::cloud_status QMLPrefs::oldStatus() const
qPrefCloudStorage::cloud_status QMLPrefs::oldStatus() const
{
return m_oldStatus;
}
void QMLPrefs::setOldStatus(const qPref::cloud_status value)
void QMLPrefs::setOldStatus(const qPrefCloudStorage::cloud_status value)
{
if (m_oldStatus != value) {
m_oldStatus = value;
@ -172,7 +172,7 @@ void QMLPrefs::cancelCredentialsPinSetup()
* cloud account, so the name is not perfect.
*/
setCredentialStatus(qPref::CS_UNKNOWN);
setCredentialStatus(qPrefCloudStorage::CS_UNKNOWN);
qPrefCloudStorage::set_cloud_storage_email(m_cloudUserName);
qPrefCloudStorage::set_cloud_storage_password(m_cloudPassword);
qPrefCloudStorage::set_cloud_verification_status(m_credentialStatus);

View file

@ -20,7 +20,7 @@ class QMLPrefs : public QObject {
MEMBER m_cloudUserName
WRITE setCloudUserName
NOTIFY cloudUserNameChanged)
Q_PROPERTY(qPref::cloud_status credentialStatus
Q_PROPERTY(qPrefCloudStorage::cloud_status credentialStatus
MEMBER m_credentialStatus
WRITE setCredentialStatus
NOTIFY credentialStatusChanged)
@ -36,7 +36,7 @@ class QMLPrefs : public QObject {
MEMBER m_showPin
WRITE setShowPin
NOTIFY showPinChanged)
Q_PROPERTY(qPref::cloud_status oldStatus
Q_PROPERTY(qPrefCloudStorage::cloud_status oldStatus
MEMBER m_oldStatus
WRITE setOldStatus
NOTIFY oldStatusChanged)
@ -64,16 +64,16 @@ public:
const QString cloudUserName() const;
void setCloudUserName(const QString &cloudUserName);
qPref::cloud_status credentialStatus() const;
void setCredentialStatus(const qPref::cloud_status value);
qPrefCloudStorage::cloud_status credentialStatus() const;
void setCredentialStatus(const qPrefCloudStorage::cloud_status value);
void setDeveloper(bool value);
int distanceThreshold() const;
void setDistanceThreshold(int distance);
qPref::cloud_status oldStatus() const;
void setOldStatus(const qPref::cloud_status value);
qPrefCloudStorage::cloud_status oldStatus() const;
void setOldStatus(const qPrefCloudStorage::cloud_status value);
bool showPin() const;
void setShowPin(bool enable);
@ -92,11 +92,11 @@ private:
QString m_cloudPassword;
QString m_cloudPin;
QString m_cloudUserName;
qPref::cloud_status m_credentialStatus;
qPrefCloudStorage::cloud_status m_credentialStatus;
bool m_developer;
int m_distanceThreshold;
static QMLPrefs *m_instance;
qPref::cloud_status m_oldStatus;
qPrefCloudStorage::cloud_status m_oldStatus;
bool m_showPin;
int m_timeThreshold;

View file

@ -27,7 +27,7 @@ void TestQPrefCloudStorage::test_struct_get()
prefs.cloud_storage_password = copy_qstring("more secret");
prefs.cloud_storage_pin = copy_qstring("a pin");
prefs.cloud_timeout = 117;
prefs.cloud_verification_status = qPref::CS_NOCLOUD;
prefs.cloud_verification_status = qPrefCloudStorage::CS_NOCLOUD;
prefs.save_password_local = true;
QCOMPARE(tst->cloud_base_url(), QString(prefs.cloud_base_url));
@ -53,7 +53,7 @@ void TestQPrefCloudStorage::test_set_struct()
tst->set_cloud_storage_password("t2 pass2");
tst->set_cloud_storage_pin("t2 pin");
tst->set_cloud_timeout(123);
tst->set_cloud_verification_status(qPref::CS_VERIFIED);
tst->set_cloud_verification_status(qPrefCloudStorage::CS_VERIFIED);
tst->set_save_password_local(false);
QCOMPARE(QString(prefs.cloud_base_url), QString("t2 base"));
@ -62,7 +62,7 @@ void TestQPrefCloudStorage::test_set_struct()
QCOMPARE(QString(prefs.cloud_storage_password), QString("t2 pass2"));
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t2 pin"));
QCOMPARE((int)prefs.cloud_timeout, 123);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
QCOMPARE(prefs.save_password_local, false);
// remark is set with set_base_url
@ -82,7 +82,7 @@ void TestQPrefCloudStorage::test_set_load_struct()
tst->set_cloud_storage_password("t3 pass2");
tst->set_cloud_storage_pin("t3 pin");
tst->set_cloud_timeout(321);
tst->set_cloud_verification_status(qPref::CS_NOCLOUD);
tst->set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
prefs.cloud_base_url = copy_qstring("error1");
prefs.cloud_git_url = copy_qstring("error1");
@ -91,7 +91,7 @@ void TestQPrefCloudStorage::test_set_load_struct()
prefs.cloud_storage_password = copy_qstring("error1");
prefs.cloud_storage_pin = copy_qstring("error1");
prefs.cloud_timeout = 324;
prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
prefs.save_password_local = false;
tst->load();
@ -101,7 +101,7 @@ void TestQPrefCloudStorage::test_set_load_struct()
QCOMPARE(QString(prefs.cloud_storage_password), QString("t3 pass2"));
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t3 pin"));
QCOMPARE((int)prefs.cloud_timeout, 321);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_NOCLOUD);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_NOCLOUD);
QCOMPARE(prefs.save_password_local, true);
// remark is set with set_base_url
@ -121,7 +121,7 @@ void TestQPrefCloudStorage::test_struct_disk()
prefs.cloud_storage_password = copy_qstring("t4 pass2");
prefs.cloud_storage_pin = copy_qstring("t4 pin");
prefs.cloud_timeout = 123;
prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
tst->sync();
@ -132,7 +132,7 @@ void TestQPrefCloudStorage::test_struct_disk()
prefs.cloud_storage_password = copy_qstring("error1");
prefs.cloud_storage_pin = copy_qstring("error1");
prefs.cloud_timeout = 324;
prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.cloud_verification_status = qPrefCloudStorage::CS_VERIFIED;
prefs.save_password_local = false;
tst->load();
@ -143,7 +143,7 @@ void TestQPrefCloudStorage::test_struct_disk()
QCOMPARE(QString(prefs.cloud_storage_password), QString("t4 pass2"));
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t4 pin"));
QCOMPARE((int)prefs.cloud_timeout, 123);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPrefCloudStorage::CS_VERIFIED);
QCOMPARE(prefs.save_password_local, true);
// remark is set with set_base_url

View file

@ -7,6 +7,7 @@
#include <QDate>
#include <QTest>
#include <QSignalSpy>
void TestQPrefDisplay::initTestCase()
{

View file

@ -43,8 +43,8 @@ TestCase {
compare(tst.cloud_timeout, 137)
var x9 = tst.cloud_verification_status
tst.cloud_verification_status = SsrfPrefs.CS_VERIFIED
compare(tst.cloud_verification_status, SsrfPrefs.CS_VERIFIED)
tst.cloud_verification_status = tst.CS_VERIFIED
compare(tst.cloud_verification_status, tst.CS_VERIFIED)
var x11 = tst.save_password_local
tst.save_password_local = true