prefs: git_local_only is not a preference

It's the current state of the app, so it should be a global variable, not a
preference.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-09-10 06:30:01 -07:00
parent 6e4a253896
commit ae653703a5
11 changed files with 44 additions and 62 deletions

View file

@ -63,7 +63,7 @@ bool CheckCloudConnection::checkServer()
} }
} }
git_storage_update_progress(qPrintable(tr("Cloud connection failed"))); git_storage_update_progress(qPrintable(tr("Cloud connection failed")));
prefs.git_local_only = true; git_local_only = true;
if (verbose) if (verbose)
qDebug() << "connection test to cloud server failed" << qDebug() << "connection test to cloud server failed" <<
reply->error() << reply->errorString() << reply->error() << reply->errorString() <<

View file

@ -27,6 +27,15 @@
bool is_subsurface_cloud = false; bool is_subsurface_cloud = false;
// the mobile app assumes that it shouldn't talk to the cloud
// the desktop app assumes that it should
#if defined(SUBSURFACE_MOBILE)
bool git_local_only = true;
#else
bool git_local_only = false;
#endif
int (*update_progress_cb)(const char *) = NULL; int (*update_progress_cb)(const char *) = NULL;
static bool includes_string_caseinsensitive(const char *haystack, const char *needle) static bool includes_string_caseinsensitive(const char *haystack, const char *needle)
@ -590,7 +599,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
char *proxy_string; char *proxy_string;
git_config *conf; git_config *conf;
if (prefs.git_local_only) { if (git_local_only) {
if (verbose) if (verbose)
fprintf(stderr, "don't sync with remote - read from cache only\n"); fprintf(stderr, "don't sync with remote - read from cache only\n");
return 0; return 0;
@ -650,7 +659,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc
fprintf(stderr, "remote fetch failed (%s)\n", fprintf(stderr, "remote fetch failed (%s)\n",
giterr_last() ? giterr_last()->message : "authentication failed"); giterr_last() ? giterr_last()->message : "authentication failed");
// Since we failed to sync with online repository, enter offline mode // Since we failed to sync with online repository, enter offline mode
prefs.git_local_only = true; git_local_only = true;
error = 0; error = 0;
} else { } else {
error = check_remote_status(repo, origin, remote, branch, rt); error = check_remote_status(repo, origin, remote, branch, rt);
@ -676,7 +685,7 @@ static git_repository *update_local_repo(const char *localdir, const char *remot
report_error("Unable to open git cache repository at %s: %s", localdir, giterr_last()->message); report_error("Unable to open git cache repository at %s: %s", localdir, giterr_last()->message);
return NULL; return NULL;
} }
if (!prefs.git_local_only) if (!git_local_only)
sync_with_remote(repo, remote, branch, rt); sync_with_remote(repo, remote, branch, rt);
return repo; return repo;
@ -837,10 +846,10 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
* remote cloud repo. * remote cloud repo.
*/ */
git_repository *ret; git_repository *ret;
bool glo = prefs.git_local_only; bool glo = git_local_only;
prefs.git_local_only = false; git_local_only = false;
ret = create_local_repo(localdir, remote, branch, rt); ret = create_local_repo(localdir, remote, branch, rt);
prefs.git_local_only = glo; git_local_only = glo;
return ret; return ret;
} }

View file

@ -23,6 +23,7 @@ extern int git_load_dives(struct git_repository *, const char *);
extern const char *get_sha(git_repository *repo, const char *branch); extern const char *get_sha(git_repository *repo, const char *branch);
extern int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty); extern int do_git_save(git_repository *repo, const char *branch, const char *remote, bool select_only, bool create_empty);
extern const char *saved_git_id; extern const char *saved_git_id;
extern bool git_local_only;
extern void clear_git_id(void); extern void clear_git_id(void);
extern void set_git_id(const struct git_oid *); extern void set_git_id(const struct git_oid *);
extern enum remote_transport url_to_remote_transport(const char *remote); extern enum remote_transport url_to_remote_transport(const char *remote);

View file

@ -96,7 +96,6 @@ struct preferences {
const char *cloud_storage_pin; const char *cloud_storage_pin;
short cloud_timeout; short cloud_timeout;
short cloud_verification_status; short cloud_verification_status;
bool git_local_only;
bool save_password_local; bool save_password_local;
bool save_userid_local; bool save_userid_local;
const char *userid; const char *userid;

View file

@ -1271,7 +1271,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
return report_error("creating commit failed"); return report_error("creating commit failed");
/* now sync the tree with the remote server */ /* now sync the tree with the remote server */
if (remote && !prefs.git_local_only) if (remote && !git_local_only)
return sync_with_remote(repo, remote, branch, url_to_remote_transport(remote)); return sync_with_remote(repo, remote, branch, url_to_remote_transport(remote));
return 0; return 0;
} }

View file

@ -23,7 +23,6 @@ void qPrefCloudStorage::loadSync(bool doSync)
disk_cloud_storage_pin(doSync); disk_cloud_storage_pin(doSync);
disk_cloud_timeout(doSync); disk_cloud_timeout(doSync);
disk_cloud_verification_status(doSync); disk_cloud_verification_status(doSync);
disk_git_local_only(doSync);
disk_save_password_local(doSync); disk_save_password_local(doSync);
disk_save_userid_local(doSync); disk_save_userid_local(doSync);
disk_userid(doSync); disk_userid(doSync);
@ -92,8 +91,6 @@ HANDLE_PREFERENCE_INT(CloudStorage, "timeout", cloud_timeout);
HANDLE_PREFERENCE_INT(CloudStorage, "cloud_verification_status", cloud_verification_status); HANDLE_PREFERENCE_INT(CloudStorage, "cloud_verification_status", cloud_verification_status);
HANDLE_PREFERENCE_BOOL(CloudStorage, "git_local_only", git_local_only);
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local); HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local);
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_userid_local", save_userid_local); HANDLE_PREFERENCE_BOOL(CloudStorage, "save_userid_local", save_userid_local);

View file

@ -16,7 +16,6 @@ class qPrefCloudStorage : public QObject {
Q_PROPERTY(QString cloud_storage_pin READ cloud_storage_pin WRITE set_cloud_storage_pin NOTIFY cloud_storage_pin_changed); Q_PROPERTY(QString cloud_storage_pin READ cloud_storage_pin WRITE set_cloud_storage_pin NOTIFY cloud_storage_pin_changed);
Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_status_changed); Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_status_changed);
Q_PROPERTY(int cloud_timeout READ cloud_timeout WRITE set_cloud_timeout NOTIFY cloud_timeout_changed); Q_PROPERTY(int cloud_timeout READ cloud_timeout WRITE set_cloud_timeout NOTIFY cloud_timeout_changed);
Q_PROPERTY(bool git_local_only READ git_local_only WRITE set_git_local_only NOTIFY git_local_only_changed);
Q_PROPERTY(bool save_password_local READ save_password_local WRITE set_save_password_local NOTIFY save_password_local_changed); Q_PROPERTY(bool save_password_local READ save_password_local WRITE set_save_password_local NOTIFY save_password_local_changed);
Q_PROPERTY(bool save_userid_local READ save_userid_local WRITE set_save_userid_local NOTIFY save_userid_local_changed); Q_PROPERTY(bool save_userid_local READ save_userid_local WRITE set_save_userid_local NOTIFY save_userid_local_changed);
Q_PROPERTY(QString userid READ userid WRITE set_userid NOTIFY userid_changed); Q_PROPERTY(QString userid READ userid WRITE set_userid NOTIFY userid_changed);
@ -40,7 +39,6 @@ public:
static QString cloud_storage_pin() { return prefs.cloud_storage_pin; } static QString cloud_storage_pin() { return prefs.cloud_storage_pin; }
static int cloud_timeout() { return prefs.cloud_timeout; } static int cloud_timeout() { return prefs.cloud_timeout; }
static int cloud_verification_status() { return prefs.cloud_verification_status; } static int cloud_verification_status() { return prefs.cloud_verification_status; }
static bool git_local_only() { return prefs.git_local_only; }
static bool save_password_local() { return prefs.save_password_local; } static bool save_password_local() { return prefs.save_password_local; }
static bool save_userid_local() { return prefs.save_userid_local; } static bool save_userid_local() { return prefs.save_userid_local; }
static QString userid() { return prefs.userid; } static QString userid() { return prefs.userid; }
@ -54,7 +52,6 @@ public slots:
static void set_cloud_storage_pin(const QString &value); static void set_cloud_storage_pin(const QString &value);
static void set_cloud_timeout(int value); static void set_cloud_timeout(int value);
static void set_cloud_verification_status(int value); static void set_cloud_verification_status(int value);
static void set_git_local_only(bool value);
static void set_save_password_local(bool value); static void set_save_password_local(bool value);
static void set_save_userid_local(bool value); static void set_save_userid_local(bool value);
static void set_userid(const QString &value); static void set_userid(const QString &value);
@ -68,7 +65,6 @@ signals:
void cloud_storage_pin_changed(const QString &value); void cloud_storage_pin_changed(const QString &value);
void cloud_timeout_changed(int value); void cloud_timeout_changed(int value);
void cloud_verification_status_changed(int value); void cloud_verification_status_changed(int value);
void git_local_only_changed(bool value);
void save_password_local_changed(bool value); void save_password_local_changed(bool value);
void save_userid_local_changed(bool value); void save_userid_local_changed(bool value);
void userid_changed(const QString &value); void userid_changed(const QString &value);
@ -83,7 +79,6 @@ private:
static void disk_cloud_storage_pin(bool doSync); static void disk_cloud_storage_pin(bool doSync);
static void disk_cloud_timeout(bool doSync); static void disk_cloud_timeout(bool doSync);
static void disk_cloud_verification_status(bool doSync); static void disk_cloud_verification_status(bool doSync);
static void disk_git_local_only(bool doSync);
static void disk_save_password_local(bool doSync); static void disk_save_password_local(bool doSync);
static void disk_save_userid_local(bool doSync); static void disk_save_userid_local(bool doSync);
static void disk_userid(bool doSync); static void disk_userid(bool doSync);

View file

@ -12,9 +12,6 @@
struct preferences prefs, git_prefs; struct preferences prefs, git_prefs;
struct preferences default_prefs = { struct preferences default_prefs = {
.cloud_base_url = "https://cloud.subsurface-divelog.org/", .cloud_base_url = "https://cloud.subsurface-divelog.org/",
#if defined(SUBSURFACE_MOBILE)
.git_local_only = true,
#endif
.units = SI_UNITS, .units = SI_UNITS,
.unit_system = METRIC, .unit_system = METRIC,
.coordinates_traditional = true, .coordinates_traditional = true,

View file

@ -660,7 +660,7 @@ void MainWindow::on_actionCloudstoragesave_triggered()
void MainWindow::on_actionCloudOnline_triggered() void MainWindow::on_actionCloudOnline_triggered()
{ {
bool isOffline = !ui.actionCloudOnline->isChecked(); bool isOffline = !ui.actionCloudOnline->isChecked();
if (isOffline == prefs.git_local_only) if (isOffline == git_local_only)
return; return;
// Refuse to go online if there is an edit in progress // Refuse to go online if there is an edit in progress
@ -673,7 +673,7 @@ void MainWindow::on_actionCloudOnline_triggered()
return; return;
} }
prefs.git_local_only = isOffline; git_local_only = isOffline;
if (!isOffline) { if (!isOffline) {
// User requests to go online. Try to sync cloud storage // User requests to go online. Try to sync cloud storage
if (unsaved_changes()) { if (unsaved_changes()) {
@ -689,7 +689,7 @@ void MainWindow::on_actionCloudOnline_triggered()
// If there are no unsaved changes, let's just try to load the remote cloud // If there are no unsaved changes, let's just try to load the remote cloud
on_actionCloudstorageopen_triggered(); on_actionCloudstorageopen_triggered();
} }
if (prefs.git_local_only) if (git_local_only)
report_error(qPrintable(tr("Failure taking cloud storage online"))); report_error(qPrintable(tr("Failure taking cloud storage online")));
} }
@ -747,7 +747,7 @@ 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 == qPref::CS_VERIFIED &&
strstr(existing_filename, prefs.cloud_git_url); strstr(existing_filename, prefs.cloud_git_url);
ui.actionCloudOnline->setEnabled(is_cloud); ui.actionCloudOnline->setEnabled(is_cloud);
ui.actionCloudOnline->setChecked(is_cloud && !prefs.git_local_only); ui.actionCloudOnline->setChecked(is_cloud && !git_local_only);
} }
void MainWindow::setCurrentFile(const char *f) void MainWindow::setCurrentFile(const char *f)
@ -1729,7 +1729,7 @@ QString MainWindow::displayedFilename(QString fullFilename)
if (fullFilename.contains(prefs.cloud_git_url)) { if (fullFilename.contains(prefs.cloud_git_url)) {
QString email = fileName.left(fileName.indexOf('[')); QString email = fileName.left(fileName.indexOf('['));
if (prefs.git_local_only) if (git_local_only)
return tr("[local cache for] %1").arg(email); return tr("[local cache for] %1").arg(email);
else else
return tr("[cloud storage for] %1").arg(email); return tr("[cloud storage for] %1").arg(email);

View file

@ -253,10 +253,10 @@ void QMLManager::openLocalThenRemote(QString url)
clear_dive_file_data(); clear_dive_file_data();
setNotificationText(tr("Open local dive data file")); setNotificationText(tr("Open local dive data file"));
QByteArray fileNamePrt = QFile::encodeName(url); QByteArray fileNamePrt = QFile::encodeName(url);
bool glo = prefs.git_local_only; bool glo = git_local_only;
prefs.git_local_only = true; git_local_only = true;
int error = parse_file(fileNamePrt.data(), &dive_table); int error = parse_file(fileNamePrt.data(), &dive_table);
prefs.git_local_only = glo; git_local_only = glo;
if (error) { if (error) {
appendTextToLog(QStringLiteral("loading dives from cache failed %1").arg(error)); appendTextToLog(QStringLiteral("loading dives from cache failed %1").arg(error));
setNotificationText(tr("Opening local data file failed")); setNotificationText(tr("Opening local data file failed"));
@ -299,11 +299,11 @@ void QMLManager::openLocalThenRemote(QString url)
} }
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) { if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
// if we switch to credentials from CS_NOCLOUD, we take things online temporarily // if we switch to credentials from CS_NOCLOUD, we take things online temporarily
prefs.git_local_only = false; git_local_only = false;
appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account")); appendTextToLog(QStringLiteral("taking things online to be able to switch to cloud account"));
} }
set_filename(fileNamePrt.data()); set_filename(fileNamePrt.data());
if (prefs.git_local_only) { if (git_local_only) {
appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network")); appendTextToLog(QStringLiteral("have cloud credentials, but user asked not to connect to network"));
alreadySaving = false; alreadySaving = false;
} else { } else {
@ -373,7 +373,7 @@ void QMLManager::finishSetup()
// Initialize cloud credentials. // Initialize cloud credentials.
QMLPrefs::instance()->setCloudUserName(qPrefCloudStorage::cloud_storage_email()); QMLPrefs::instance()->setCloudUserName(qPrefCloudStorage::cloud_storage_email());
QMLPrefs::instance()->setCloudPassword(qPrefCloudStorage::cloud_storage_password()); QMLPrefs::instance()->setCloudPassword(qPrefCloudStorage::cloud_storage_password());
setSyncToCloud(!prefs.git_local_only); setSyncToCloud(!git_local_only);
QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status); QMLPrefs::instance()->setCredentialStatus((qPref::cloud_status) prefs.cloud_verification_status);
// if the cloud credentials are valid, we should get the GPS Webservice ID as well // if the cloud credentials are valid, we should get the GPS Webservice ID as well
QString url; QString url;
@ -505,8 +505,8 @@ void QMLManager::saveCloudCredentials()
alreadySaving = true; alreadySaving = true;
// since we changed credentials, we need to try to connect to the cloud, regardless // since we changed credentials, we need to try to connect to the cloud, regardless
// of whether we're in offline mode or not, to make sure the repository is synced // of whether we're in offline mode or not, to make sure the repository is synced
currentGitLocalOnly = prefs.git_local_only; currentGitLocalOnly = git_local_only;
prefs.git_local_only = false; git_local_only = false;
openLocalThenRemote(url); openLocalThenRemote(url);
} else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY && } else if (prefs.cloud_verification_status == qPref::CS_NEED_TO_VERIFY &&
!QMLPrefs::instance()->cloudPin().isEmpty()) { !QMLPrefs::instance()->cloudPin().isEmpty()) {
@ -708,13 +708,13 @@ successful_exit:
saveChangesLocal(); saveChangesLocal();
if (m_syncToCloud == false) { if (m_syncToCloud == false) {
appendTextToLog(QStringLiteral("taking things back offline now that storage is synced")); appendTextToLog(QStringLiteral("taking things back offline now that storage is synced"));
prefs.git_local_only = m_syncToCloud; git_local_only = m_syncToCloud;
} }
} }
// if we got here just for an initial connection to the cloud, reset to offline // if we got here just for an initial connection to the cloud, reset to offline
if (currentGitLocalOnly) { if (currentGitLocalOnly) {
currentGitLocalOnly = false; currentGitLocalOnly = false;
prefs.git_local_only = true; git_local_only = true;
} }
return; return;
} }
@ -724,7 +724,7 @@ void QMLManager::revertToNoCloudIfNeeded()
if (currentGitLocalOnly) { if (currentGitLocalOnly) {
// we tried to connect to the cloud for the first time and that failed // we tried to connect to the cloud for the first time and that failed
currentGitLocalOnly = false; currentGitLocalOnly = false;
prefs.git_local_only = true; git_local_only = true;
} }
if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) { if (QMLPrefs::instance()->oldStatus() == qPref::CS_NOCLOUD) {
// we tried to switch to a cloud account and had previously used local data, // we tried to switch to a cloud account and had previously used local data,
@ -734,7 +734,7 @@ void QMLManager::revertToNoCloudIfNeeded()
// dives // dives
if (m_syncToCloud == false) { if (m_syncToCloud == false) {
appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed")); appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed"));
prefs.git_local_only = m_syncToCloud; git_local_only = m_syncToCloud;
} }
free((void *)prefs.cloud_storage_email); free((void *)prefs.cloud_storage_email);
prefs.cloud_storage_email = NULL; prefs.cloud_storage_email = NULL;
@ -1240,16 +1240,16 @@ void QMLManager::saveChangesLocal()
return; return;
} }
alreadySaving = true; alreadySaving = true;
bool glo = prefs.git_local_only; bool glo = git_local_only;
prefs.git_local_only = true; git_local_only = true;
if (save_dives(existing_filename)) { if (save_dives(existing_filename)) {
setNotificationText(consumeError()); setNotificationText(consumeError());
set_filename(NULL); set_filename(NULL);
prefs.git_local_only = glo; git_local_only = glo;
alreadySaving = false; alreadySaving = false;
return; return;
} }
prefs.git_local_only = glo; git_local_only = glo;
mark_divelist_changed(false); mark_divelist_changed(false);
alreadySaving = false; alreadySaving = false;
} else { } else {
@ -1272,7 +1272,7 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
saveChangesLocal(); saveChangesLocal();
// if the user asked not to push to the cloud we are done // if the user asked not to push to the cloud we are done
if (prefs.git_local_only && !forceRemoteSync) if (git_local_only && !forceRemoteSync)
return; return;
if (!m_loadFromCloud) { if (!m_loadFromCloud) {
@ -1280,12 +1280,12 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync)
return; return;
} }
bool glo = prefs.git_local_only; bool glo = git_local_only;
prefs.git_local_only = false; git_local_only = false;
alreadySaving = true; alreadySaving = true;
loadDivesWithValidCredentials(); loadDivesWithValidCredentials();
alreadySaving = false; alreadySaving = false;
prefs.git_local_only = glo; git_local_only = glo;
} }
bool QMLManager::undoDelete(int id) bool QMLManager::undoDelete(int id)
@ -1535,8 +1535,7 @@ void QMLManager::setNotificationText(QString text)
void QMLManager::setSyncToCloud(bool status) void QMLManager::setSyncToCloud(bool status)
{ {
m_syncToCloud = status; m_syncToCloud = status;
prefs.git_local_only = !status; git_local_only = !status;
qPrefCloudStorage::set_git_local_only(prefs.git_local_only);
emit syncToCloudChanged(); emit syncToCloudChanged();
} }

View file

@ -29,7 +29,6 @@ void TestQPrefCloudStorage::test_struct_get()
prefs.cloud_storage_pin = copy_qstring("a pin"); prefs.cloud_storage_pin = copy_qstring("a pin");
prefs.cloud_timeout = 117; prefs.cloud_timeout = 117;
prefs.cloud_verification_status = qPref::CS_NOCLOUD; prefs.cloud_verification_status = qPref::CS_NOCLOUD;
prefs.git_local_only = true;
prefs.save_password_local = true; prefs.save_password_local = true;
prefs.save_userid_local = true; prefs.save_userid_local = true;
prefs.userid = copy_qstring("my user"); prefs.userid = copy_qstring("my user");
@ -43,7 +42,6 @@ void TestQPrefCloudStorage::test_struct_get()
QCOMPARE(tst->cloud_storage_pin(), QString(prefs.cloud_storage_pin)); QCOMPARE(tst->cloud_storage_pin(), QString(prefs.cloud_storage_pin));
QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout); QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout);
QCOMPARE(tst->cloud_verification_status(), (int)prefs.cloud_verification_status); QCOMPARE(tst->cloud_verification_status(), (int)prefs.cloud_verification_status);
QCOMPARE(tst->git_local_only(), prefs.git_local_only);
QCOMPARE(tst->save_password_local(), prefs.save_password_local); QCOMPARE(tst->save_password_local(), prefs.save_password_local);
QCOMPARE(tst->save_userid_local(), prefs.save_userid_local); QCOMPARE(tst->save_userid_local(), prefs.save_userid_local);
QCOMPARE(tst->userid(), QString(prefs.userid)); QCOMPARE(tst->userid(), QString(prefs.userid));
@ -63,7 +61,6 @@ void TestQPrefCloudStorage::test_set_struct()
tst->set_cloud_storage_pin("t2 pin"); tst->set_cloud_storage_pin("t2 pin");
tst->set_cloud_timeout(123); tst->set_cloud_timeout(123);
tst->set_cloud_verification_status(qPref::CS_VERIFIED); tst->set_cloud_verification_status(qPref::CS_VERIFIED);
tst->set_git_local_only(false);
tst->set_save_password_local(false); tst->set_save_password_local(false);
tst->set_save_userid_local(false); tst->set_save_userid_local(false);
tst->set_userid("t2 user"); tst->set_userid("t2 user");
@ -76,7 +73,6 @@ void TestQPrefCloudStorage::test_set_struct()
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t2 pin")); QCOMPARE(QString(prefs.cloud_storage_pin), QString("t2 pin"));
QCOMPARE((int)prefs.cloud_timeout, 123); QCOMPARE((int)prefs.cloud_timeout, 123);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED); QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
QCOMPARE(prefs.git_local_only, false);
QCOMPARE(prefs.save_password_local, false); QCOMPARE(prefs.save_password_local, false);
QCOMPARE(prefs.save_userid_local, false); QCOMPARE(prefs.save_userid_local, false);
QCOMPARE(QString(prefs.userid), QString("t2 user")); QCOMPARE(QString(prefs.userid), QString("t2 user"));
@ -100,7 +96,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
tst->set_cloud_storage_pin("t3 pin"); tst->set_cloud_storage_pin("t3 pin");
tst->set_cloud_timeout(321); tst->set_cloud_timeout(321);
tst->set_cloud_verification_status(qPref::CS_NOCLOUD); tst->set_cloud_verification_status(qPref::CS_NOCLOUD);
tst->set_git_local_only(true);
tst->set_save_userid_local(true); tst->set_save_userid_local(true);
tst->set_userid("t3 user"); tst->set_userid("t3 user");
@ -113,7 +108,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
prefs.cloud_storage_pin = copy_qstring("error1"); prefs.cloud_storage_pin = copy_qstring("error1");
prefs.cloud_timeout = 324; prefs.cloud_timeout = 324;
prefs.cloud_verification_status = qPref::CS_VERIFIED; prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.git_local_only = false;
prefs.save_password_local = false; prefs.save_password_local = false;
prefs.save_userid_local = false; prefs.save_userid_local = false;
prefs.userid = copy_qstring("error1"); prefs.userid = copy_qstring("error1");
@ -126,7 +120,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t3 pin")); QCOMPARE(QString(prefs.cloud_storage_pin), QString("t3 pin"));
QCOMPARE((int)prefs.cloud_timeout, 321); QCOMPARE((int)prefs.cloud_timeout, 321);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_NOCLOUD); QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_NOCLOUD);
QCOMPARE(prefs.git_local_only, true);
QCOMPARE(prefs.save_password_local, true); QCOMPARE(prefs.save_password_local, true);
QCOMPARE(prefs.save_userid_local, true); QCOMPARE(prefs.save_userid_local, true);
QCOMPARE(QString(prefs.userid), QString("t3 user")); QCOMPARE(QString(prefs.userid), QString("t3 user"));
@ -153,7 +146,6 @@ void TestQPrefCloudStorage::test_struct_disk()
prefs.cloud_storage_pin = copy_qstring("t4 pin"); prefs.cloud_storage_pin = copy_qstring("t4 pin");
prefs.cloud_timeout = 123; prefs.cloud_timeout = 123;
prefs.cloud_verification_status = qPref::CS_VERIFIED; prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.git_local_only = true;
prefs.save_userid_local = true; prefs.save_userid_local = true;
prefs.userid = copy_qstring("t4 user"); prefs.userid = copy_qstring("t4 user");
@ -168,7 +160,6 @@ void TestQPrefCloudStorage::test_struct_disk()
prefs.cloud_storage_pin = copy_qstring("error1"); prefs.cloud_storage_pin = copy_qstring("error1");
prefs.cloud_timeout = 324; prefs.cloud_timeout = 324;
prefs.cloud_verification_status = qPref::CS_VERIFIED; prefs.cloud_verification_status = qPref::CS_VERIFIED;
prefs.git_local_only = false;
prefs.save_password_local = false; prefs.save_password_local = false;
prefs.save_userid_local = false; prefs.save_userid_local = false;
prefs.userid = copy_qstring("error1"); prefs.userid = copy_qstring("error1");
@ -182,7 +173,6 @@ void TestQPrefCloudStorage::test_struct_disk()
QCOMPARE(QString(prefs.cloud_storage_pin), QString("t4 pin")); QCOMPARE(QString(prefs.cloud_storage_pin), QString("t4 pin"));
QCOMPARE((int)prefs.cloud_timeout, 123); QCOMPARE((int)prefs.cloud_timeout, 123);
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED); QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
QCOMPARE(prefs.git_local_only, true);
QCOMPARE(prefs.save_password_local, true); QCOMPARE(prefs.save_password_local, true);
QCOMPARE(prefs.save_userid_local, true); QCOMPARE(prefs.save_userid_local, true);
QCOMPARE(QString(prefs.userid), QString("t4 user")); QCOMPARE(QString(prefs.userid), QString("t4 user"));
@ -229,11 +219,6 @@ void TestQPrefCloudStorage::test_oldPreferences()
cloud->set_cloud_storage_email("tomaz@gmail.com"); cloud->set_cloud_storage_email("tomaz@gmail.com");
TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com")); TEST(cloud->cloud_storage_email(), QStringLiteral("tomaz@gmail.com"));
cloud->set_git_local_only(true);
TEST(cloud->git_local_only(), true);
cloud->set_git_local_only(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->set_cloud_storage_newpassword("ABCD"); cloud->set_cloud_storage_newpassword("ABCD");
TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD")); TEST(cloud->cloud_storage_newpassword(), QStringLiteral("ABCD"));