diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-04-30 12:40:52 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-30 12:40:52 -0700 |
commit | 241dd7cb81364521d78250f800e8508211575254 (patch) | |
tree | 1ea443fe4589f0f247db4304de38e857e18100f6 /core | |
parent | 2e6588dc0ef8d7698cc5dbe831f524a6e394145d (diff) | |
parent | ba9288fab6d7aa8527f7a75a717cdc88a68facd9 (diff) | |
download | subsurface-241dd7cb81364521d78250f800e8508211575254.tar.gz |
Merge branch 'offlineDefault'
Diffstat (limited to 'core')
-rw-r--r-- | core/file.c | 2 | ||||
-rw-r--r-- | core/git-access.c | 19 | ||||
-rw-r--r-- | core/git-access.h | 1 | ||||
-rw-r--r-- | core/qt-init.cpp | 11 | ||||
-rw-r--r-- | core/subsurface-qt/SettingsObjectWrapper.cpp | 7 | ||||
-rw-r--r-- | core/subsurfacestartup.c | 12 | ||||
-rw-r--r-- | core/subsurfacestartup.h | 2 |
7 files changed, 51 insertions, 3 deletions
diff --git a/core/file.c b/core/file.c index 82eb684b0..4c0ae8fd0 100644 --- a/core/file.c +++ b/core/file.c @@ -485,7 +485,7 @@ int parse_file(const char *filename) /* opening the cloud storage repository failed for some reason * give up here and don't send errors about git repositories */ free(current_sha); - return 0; + return -1; } /* if this is a git repository, do we already have this exact state loaded ? * get the SHA and compare with what we currently have */ diff --git a/core/git-access.c b/core/git-access.c index dba9cbec5..fe3a918ac 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -450,6 +450,11 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference return report_error("Unable to get local or remote SHA1"); } if (git_merge_base(&base, repo, local_id, remote_id)) { + // TODO: + // if they have no merge base, they actually are different repos + // so instead merge this as merging a commit into a repo - git_merge() appears to do that + // but needs testing and cleanup afterwards + // if (is_subsurface_cloud) goto cloud_data_error; else @@ -940,3 +945,17 @@ struct git_repository *is_git_repository(const char *filename, const char **bran *branchp = branch; return repo; } + +int git_create_local_repo(const char *filename) +{ + git_repository *repo; + char *path = strdup(filename); + char *branch = strchr(path, '['); + if (branch) + *branch = '\0'; + int ret = git_repository_init(&repo, path, false); + free(path); + if (ret != 0) + (void)report_error("Create local repo failed with error code %d", ret); + return ret; +} diff --git a/core/git-access.h b/core/git-access.h index f098f1e8d..b8b8181fe 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -27,6 +27,7 @@ extern void set_git_id(const struct git_oid *); void set_git_update_cb(int(*)(bool, const char *)); int git_storage_update_progress(bool reset, const char *text); char *get_local_dir(const char *remote, const char *branch); +int git_create_local_repo(const char *filename); extern int last_git_storage_update_val; diff --git a/core/qt-init.cpp b/core/qt-init.cpp index b52dfd970..5dc25f9fc 100644 --- a/core/qt-init.cpp +++ b/core/qt-init.cpp @@ -4,6 +4,8 @@ #include <QTextCodec> #include "helpers.h" +char *settings_suffix = NULL; + void init_qt_late() { QApplication *application = qApp; @@ -19,7 +21,14 @@ void init_qt_late() QCoreApplication::setOrganizationName("Subsurface"); QCoreApplication::setOrganizationDomain("subsurface.hohndel.org"); - QCoreApplication::setApplicationName("Subsurface"); + // enable user specific settings (based on command line argument) + if (settings_suffix) { + if (verbose) + qDebug() << "using custom config for" << QString("Subsurface-%1").arg(settings_suffix); + QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix)); + } else { + QCoreApplication::setApplicationName("Subsurface"); + } // find plugins installed in the application directory (without this SVGs don't work on Windows) QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath()); QLocale loc; diff --git a/core/subsurface-qt/SettingsObjectWrapper.cpp b/core/subsurface-qt/SettingsObjectWrapper.cpp index e43be1a9b..ed305ef28 100644 --- a/core/subsurface-qt/SettingsObjectWrapper.cpp +++ b/core/subsurface-qt/SettingsObjectWrapper.cpp @@ -1315,6 +1315,7 @@ int GeneralSettingsObjectWrapper::pscrRatio() const void GeneralSettingsObjectWrapper::setDefaultFilename(const QString& value) { QSettings s; + s.beginGroup(group); s.setValue("default_filename", value); prefs.default_filename = copy_string(qPrintable(value)); emit defaultFilenameChanged(value); @@ -1323,6 +1324,7 @@ void GeneralSettingsObjectWrapper::setDefaultFilename(const QString& value) void GeneralSettingsObjectWrapper::setDefaultCylinder(const QString& value) { QSettings s; + s.beginGroup(group); s.setValue("default_cylinder", value); prefs.default_cylinder = copy_string(qPrintable(value)); emit defaultCylinderChanged(value); @@ -1331,6 +1333,7 @@ void GeneralSettingsObjectWrapper::setDefaultCylinder(const QString& value) void GeneralSettingsObjectWrapper::setDefaultFileBehavior(short value) { QSettings s; + s.beginGroup(group); s.setValue("default_file_behavior", value); prefs.default_file_behavior = value; if (prefs.default_file_behavior == UNDEFINED_DEFAULT_FILE) { @@ -1347,6 +1350,7 @@ void GeneralSettingsObjectWrapper::setDefaultFileBehavior(short value) void GeneralSettingsObjectWrapper::setUseDefaultFile(bool value) { QSettings s; + s.beginGroup(group); s.setValue("use_default_file", value); prefs.use_default_file = value; emit useDefaultFileChanged(value); @@ -1355,6 +1359,7 @@ void GeneralSettingsObjectWrapper::setUseDefaultFile(bool value) void GeneralSettingsObjectWrapper::setDefaultSetPoint(int value) { QSettings s; + s.beginGroup(group); s.setValue("defaultsetpoint", value); prefs.defaultsetpoint = value; emit defaultSetPointChanged(value); @@ -1363,6 +1368,7 @@ void GeneralSettingsObjectWrapper::setDefaultSetPoint(int value) void GeneralSettingsObjectWrapper::setO2Consumption(int value) { QSettings s; + s.beginGroup(group); s.setValue("o2consumption", value); prefs.o2consumption = value; emit o2ConsumptionChanged(value); @@ -1371,6 +1377,7 @@ void GeneralSettingsObjectWrapper::setO2Consumption(int value) void GeneralSettingsObjectWrapper::setPscrRatio(int value) { QSettings s; + s.beginGroup(group); s.setValue("pscr_ratio", value); prefs.pscr_ratio = value; emit pscrRatioChanged(value); diff --git a/core/subsurfacestartup.c b/core/subsurfacestartup.c index 6e0dede1c..c2881a17f 100644 --- a/core/subsurfacestartup.c +++ b/core/subsurfacestartup.c @@ -10,6 +10,9 @@ struct preferences prefs, informational_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, @@ -197,6 +200,11 @@ void parse_argument(const char *arg) continue; case '-': /* long options with -- */ + /* first test for --user=bla which allows the use of user specific settings */ + if (strncmp(arg, "--user=", sizeof("--user=") - 1) == 0) { + settings_suffix = strdup(arg + sizeof("--user=") - 1); + return; + } if (strcmp(arg, "--help") == 0) { print_help(); exit(0); @@ -254,8 +262,10 @@ void setup_system_prefs(void) subsurface_OS_pref_setup(); default_prefs.divelist_font = strdup(system_divelist_default_font); default_prefs.font_size = system_divelist_default_font_size; - default_prefs.default_filename = system_default_filename(); +#if !defined(SUBSURFACE_MOBILE) + default_prefs.default_filename = system_default_filename(); +#endif env = getenv("LC_MEASUREMENT"); if (!env) env = getenv("LC_ALL"); diff --git a/core/subsurfacestartup.h b/core/subsurfacestartup.h index 3ccc24aa4..53d44f28d 100644 --- a/core/subsurfacestartup.h +++ b/core/subsurfacestartup.h @@ -19,6 +19,8 @@ void free_prefs(void); void copy_prefs(struct preferences *src, struct preferences *dest); void print_files(void); +extern char *settings_suffix; + #ifdef __cplusplus } #endif |