summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-10 06:30:01 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-09-10 16:26:49 -0700
commitae653703a5d3ff1da84053d4542420fc70325c5f (patch)
tree3c93c581dc3d7a2209b7dc021d14515c34b75c04 /core
parent6e4a2538968d945d471489270136c4891b47b270 (diff)
downloadsubsurface-ae653703a5d3ff1da84053d4542420fc70325c5f.tar.gz
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>
Diffstat (limited to 'core')
-rw-r--r--core/checkcloudconnection.cpp2
-rw-r--r--core/git-access.c21
-rw-r--r--core/git-access.h1
-rw-r--r--core/pref.h1
-rw-r--r--core/save-git.c2
-rw-r--r--core/settings/qPrefCloudStorage.cpp3
-rw-r--r--core/settings/qPrefCloudStorage.h5
-rw-r--r--core/subsurfacestartup.c3
8 files changed, 18 insertions, 20 deletions
diff --git a/core/checkcloudconnection.cpp b/core/checkcloudconnection.cpp
index ce396ebf6..ffe2094f6 100644
--- a/core/checkcloudconnection.cpp
+++ b/core/checkcloudconnection.cpp
@@ -63,7 +63,7 @@ bool CheckCloudConnection::checkServer()
}
}
git_storage_update_progress(qPrintable(tr("Cloud connection failed")));
- prefs.git_local_only = true;
+ git_local_only = true;
if (verbose)
qDebug() << "connection test to cloud server failed" <<
reply->error() << reply->errorString() <<
diff --git a/core/git-access.c b/core/git-access.c
index 1fe71b80c..d71bed797 100644
--- a/core/git-access.c
+++ b/core/git-access.c
@@ -27,6 +27,15 @@
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;
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;
git_config *conf;
- if (prefs.git_local_only) {
+ if (git_local_only) {
if (verbose)
fprintf(stderr, "don't sync with remote - read from cache only\n");
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",
giterr_last() ? giterr_last()->message : "authentication failed");
// Since we failed to sync with online repository, enter offline mode
- prefs.git_local_only = true;
+ git_local_only = true;
error = 0;
} else {
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);
return NULL;
}
- if (!prefs.git_local_only)
+ if (!git_local_only)
sync_with_remote(repo, remote, branch, rt);
return repo;
@@ -837,10 +846,10 @@ static struct git_repository *get_remote_repo(const char *localdir, const char *
* remote cloud repo.
*/
git_repository *ret;
- bool glo = prefs.git_local_only;
- prefs.git_local_only = false;
+ bool glo = git_local_only;
+ git_local_only = false;
ret = create_local_repo(localdir, remote, branch, rt);
- prefs.git_local_only = glo;
+ git_local_only = glo;
return ret;
}
diff --git a/core/git-access.h b/core/git-access.h
index 77ff106a0..82927b87f 100644
--- a/core/git-access.h
+++ b/core/git-access.h
@@ -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 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 bool git_local_only;
extern void clear_git_id(void);
extern void set_git_id(const struct git_oid *);
extern enum remote_transport url_to_remote_transport(const char *remote);
diff --git a/core/pref.h b/core/pref.h
index 895006f7e..f66a463cc 100644
--- a/core/pref.h
+++ b/core/pref.h
@@ -96,7 +96,6 @@ struct preferences {
const char *cloud_storage_pin;
short cloud_timeout;
short cloud_verification_status;
- bool git_local_only;
bool save_password_local;
bool save_userid_local;
const char *userid;
diff --git a/core/save-git.c b/core/save-git.c
index 2824b22ca..df5abf9e1 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -1271,7 +1271,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo
return report_error("creating commit failed");
/* 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 0;
}
diff --git a/core/settings/qPrefCloudStorage.cpp b/core/settings/qPrefCloudStorage.cpp
index dfb9c435b..4576de6fb 100644
--- a/core/settings/qPrefCloudStorage.cpp
+++ b/core/settings/qPrefCloudStorage.cpp
@@ -23,7 +23,6 @@ void qPrefCloudStorage::loadSync(bool doSync)
disk_cloud_storage_pin(doSync);
disk_cloud_timeout(doSync);
disk_cloud_verification_status(doSync);
- disk_git_local_only(doSync);
disk_save_password_local(doSync);
disk_save_userid_local(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_BOOL(CloudStorage, "git_local_only", git_local_only);
-
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local);
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_userid_local", save_userid_local);
diff --git a/core/settings/qPrefCloudStorage.h b/core/settings/qPrefCloudStorage.h
index 91864afbc..f9a08372f 100644
--- a/core/settings/qPrefCloudStorage.h
+++ b/core/settings/qPrefCloudStorage.h
@@ -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(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(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_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);
@@ -40,7 +39,6 @@ public:
static QString cloud_storage_pin() { return prefs.cloud_storage_pin; }
static int cloud_timeout() { return prefs.cloud_timeout; }
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_userid_local() { return prefs.save_userid_local; }
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_timeout(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_userid_local(bool value);
static void set_userid(const QString &value);
@@ -68,7 +65,6 @@ signals:
void cloud_storage_pin_changed(const QString &value);
void cloud_timeout_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_userid_local_changed(bool value);
void userid_changed(const QString &value);
@@ -83,7 +79,6 @@ private:
static void disk_cloud_storage_pin(bool doSync);
static void disk_cloud_timeout(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_userid_local(bool doSync);
static void disk_userid(bool doSync);
diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c
index f3f9e4bda..7e7ba0c9e 100644
--- a/core/subsurfacestartup.c
+++ b/core/subsurfacestartup.c
@@ -12,9 +12,6 @@
struct preferences prefs, git_prefs;
struct preferences default_prefs = {
.cloud_base_url = "https://cloud.subsurface-divelog.org/",
-#if defined(SUBSURFACE_MOBILE)
- .git_local_only = true,
-#endif
.units = SI_UNITS,
.unit_system = METRIC,
.coordinates_traditional = true,