summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-09-02 16:22:16 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-11 17:25:00 -0700
commit684e334fb6098e604a91d140c1e2ea0883dff081 (patch)
tree99dd5050bb53385125aa5fa6dc69514acbc2b40e /mobile-widgets
parent4d57b52062ab902dee8d82e453eda586ce78ab3e (diff)
downloadsubsurface-684e334fb6098e604a91d140c1e2ea0883dff081.tar.gz
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>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp43
-rw-r--r--mobile-widgets/qmlprefs.cpp16
-rw-r--r--mobile-widgets/qmlprefs.h16
3 files changed, 37 insertions, 38 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index a7ef0e420..90fdded5b 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -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);
diff --git a/mobile-widgets/qmlprefs.cpp b/mobile-widgets/qmlprefs.cpp
index 145ddf91f..8fd6811c8 100644
--- a/mobile-widgets/qmlprefs.cpp
+++ b/mobile-widgets/qmlprefs.cpp
@@ -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);
diff --git a/mobile-widgets/qmlprefs.h b/mobile-widgets/qmlprefs.h
index b628ef3fe..1676c2e64 100644
--- a/mobile-widgets/qmlprefs.h
+++ b/mobile-widgets/qmlprefs.h
@@ -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;