mobile-widgets: credentialStatus() -> cloud_verification_status()

Replace all credentialStatus() with cloud_verification_status()

Where both prefs.credentialStatus and
PrefCloudStorage.cloud_verification_status are being set, remove
prefs.credentialStatus.

These replacements are valid since credentialStatus() is a simple
envelope over cloud_verification_status().

Also remove qmlPrefs::credentialStatus() from qmlPrefs (mostly to ensure no
replacements was forgotten).

Signed-off-by: Jan Iversen <jan@casacondor.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
jan Iversen 2019-12-28 17:30:14 +01:00 committed by Dirk Hohndel
parent beacc00f2d
commit 783332561a
5 changed files with 11 additions and 25 deletions

View file

@ -110,7 +110,6 @@ Item {
text: qsTr("Cancel")
onClicked: {
PrefCloudStorage.cloud_verification_status = CloudStatus.CS_UNKNOWN
prefs.cloudCredentials = CloudStatus.CS_UNKNOWN
manager.startPageText = qsTr("Check credentials...");
prefs.showPin = false;
}
@ -140,7 +139,8 @@ Item {
onClicked: {
manager.setGitLocalOnly(true)
PrefCloudStorage.cloud_auto_sync = false
prefs.credentialStatus = CloudStatus.CS_NOCLOUD
prefs.oldStatus = PrefCloudStorage.cloud_verification_status
PrefCloudStorage.cloud_verification_status = CloudStatus.CS_NOCLOUD
manager.saveCloudCredentials("", "", "")
manager.openNoCloudRepo()
}

View file

@ -55,7 +55,6 @@ Kirigami.ScrollablePage {
text: qsTr("Change")
onClicked: {
PrefCloudStorage.cloud_verification_status = CloudStatus.CS_UNKNOWN
prefs.credentialStatus = CloudStatus.CS_UNKNOWN
manager.startPageText = qsTr("Starting...");
prefs.showPin = false;
}
@ -68,7 +67,7 @@ Kirigami.ScrollablePage {
color: subsurfaceTheme.textColor
}
Controls.Label {
text: describe[prefs.credentialStatus]
text: describe[PrefCloudStorage.cloud_verification_status]
font.pointSize: subsurfaceTheme.regularPointSize
Layout.preferredWidth: gridWidth * 0.60
Layout.preferredHeight: Kirigami.Units.gridUnit * 1.5

View file

@ -312,7 +312,7 @@ void QMLManager::openLocalThenRemote(QString url)
* care about this, as the very first commit of dive data to the
* no cloud repo solves this.
*/
auto credStatus = QMLPrefs::instance()->credentialStatus();
auto credStatus = qPrefCloudStorage::cloud_verification_status();
if (credStatus != qPrefCloudStorage::CS_NOCLOUD &&
credStatus != qPrefCloudStorage::CS_INCORRECT_USER_PASSWD)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NEED_TO_VERIFY);
@ -321,7 +321,7 @@ void QMLManager::openLocalThenRemote(QString url)
// and we know that there was at least one successful sync with the cloud when
// that local cache was created - so there is a common ancestor
setLoadFromCloud(true);
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_UNKNOWN)
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_UNKNOWN)
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_VERIFIED);
if (git_prefs.unit_system == IMPERIAL)
qPrefUnits::set_unit_system("imperial");
@ -339,11 +339,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() == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NEED_TO_VERIFY) {
appendTextToLog(QStringLiteral("have cloud credentials, but still needs PIN"));
QMLPrefs::instance()->setShowPin(true);
}
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_INCORRECT_USER_PASSWD) {
appendTextToLog(QStringLiteral("incorrect password for cloud credentials"));
setNotificationText(tr("Incorrect cloud credentials"));
}
@ -455,7 +455,7 @@ void QMLManager::finishSetup()
alreadySaving = true;
openLocalThenRemote(url);
} else if (!empty_string(existing_filename) &&
QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_UNKNOWN) {
qPrefCloudStorage::cloud_verification_status() != qPrefCloudStorage::CS_UNKNOWN) {
QMLPrefs::instance()->setCredentialStatus(qPrefCloudStorage::CS_NOCLOUD);
saveCloudCredentials(qPrefCloudStorage::cloud_storage_email(), qPrefCloudStorage::cloud_storage_password(), qPrefCloudStorage::cloud_storage_pin());
appendTextToLog(tr("working in no-cloud mode"));
@ -496,7 +496,7 @@ QMLManager *QMLManager::instance()
void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &newPassword, const QString &pin)
{
bool cloudCredentialsChanged = false;
bool noCloud = QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_NOCLOUD;
bool noCloud = qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD;
// make sure we only have letters, numbers, and +-_. in password and email address
QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$");
@ -523,7 +523,7 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
cloudCredentialsChanged = true;
}
if (QMLPrefs::instance()->credentialStatus() != qPrefCloudStorage::CS_NOCLOUD &&
if (qPrefCloudStorage::cloud_verification_status() != qPrefCloudStorage::CS_NOCLOUD &&
!cloudCredentialsChanged) {
// just go back to the dive list
QMLPrefs::instance()->setCredentialStatus(QMLPrefs::instance()->oldStatus());
@ -535,7 +535,6 @@ void QMLManager::saveCloudCredentials(const QString &newEmail, const QString &ne
qPrefCloudStorage::set_cloud_storage_email(newEmail);
qPrefCloudStorage::set_cloud_storage_password(newPassword);
qPrefCloudStorage::set_cloud_verification_status(QMLPrefs::instance()->credentialStatus());
if (noCloud && cloudCredentialsChanged && dive_table.nr) {
// we came from NOCLOUD and are connecting to a cloud account;
@ -1306,7 +1305,7 @@ void QMLManager::openNoCloudRepo()
void QMLManager::saveChangesLocal()
{
if (unsaved_changes()) {
if (QMLPrefs::instance()->credentialStatus() == qPrefCloudStorage::CS_NOCLOUD) {
if (qPrefCloudStorage::cloud_verification_status() == qPrefCloudStorage::CS_NOCLOUD) {
if (empty_string(existing_filename)) {
char *filename = NOCLOUD_LOCALSTORAGE;
git_create_local_repo(filename);

View file

@ -33,11 +33,6 @@ QMLPrefs *QMLPrefs::instance()
/*** public functions ***/
qPrefCloudStorage::cloud_status QMLPrefs::credentialStatus() const
{
return (qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status();
}
void QMLPrefs::setCredentialStatus(const qPrefCloudStorage::cloud_status value)
{
if ((qPrefCloudStorage::cloud_status)qPrefCloudStorage::cloud_verification_status() != value) {
@ -53,7 +48,6 @@ void QMLPrefs::setCredentialStatus(const qPrefCloudStorage::cloud_status value)
prefs.units = SI_units;
}
qPrefCloudStorage::set_cloud_verification_status(value);
emit credentialStatusChanged();
}
}

View file

@ -9,10 +9,6 @@
class QMLPrefs : public QObject {
Q_OBJECT
Q_PROPERTY(qPrefCloudStorage::cloud_status credentialStatus
READ credentialStatus
WRITE setCredentialStatus
NOTIFY credentialStatusChanged)
Q_PROPERTY(bool showPin
MEMBER m_showPin
WRITE setShowPin
@ -27,7 +23,6 @@ public:
static QMLPrefs *instance();
qPrefCloudStorage::cloud_status credentialStatus() const;
void setCredentialStatus(const qPrefCloudStorage::cloud_status value);
qPrefCloudStorage::cloud_status oldStatus() const;
@ -42,7 +37,6 @@ private:
bool m_showPin;
signals:
void credentialStatusChanged();
void oldStatusChanged();
void showPinChanged();
};