diff options
-rw-r--r-- | core/checkcloudconnection.cpp | 5 | ||||
-rw-r--r-- | core/git-access.c | 28 | ||||
-rw-r--r-- | core/git-access.h | 2 | ||||
-rw-r--r-- | core/load-git.c | 10 | ||||
-rw-r--r-- | core/save-git.c | 9 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 16 |
6 files changed, 31 insertions, 39 deletions
diff --git a/core/checkcloudconnection.cpp b/core/checkcloudconnection.cpp index b9a11046a..a80739829 100644 --- a/core/checkcloudconnection.cpp +++ b/core/checkcloudconnection.cpp @@ -52,18 +52,17 @@ bool CheckCloudConnection::checkServer() mgr->deleteLater(); if (verbose > 1) qWarning() << "Cloud storage: successfully checked connection to cloud server"; - git_storage_update_progress("successfully checked cloud connection"); return true; } } else if (seconds < prefs.cloud_timeout) { - QString text = QString("waited %1 sec for cloud connetion").arg(seconds); + QString text = tr("Waiting for cloud connetion (%1 seconds passed)").arg(seconds); git_storage_update_progress(qPrintable(text)); } else { disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit())); reply->abort(); } } - git_storage_update_progress("cloud connection failed"); + git_storage_update_progress(qPrintable(tr("Cloud connection failed"))); prefs.git_local_only = true; if (verbose) qDebug() << "connection test to cloud server failed" << diff --git a/core/git-access.c b/core/git-access.c index d7f971c54..dbb8dabd4 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -97,7 +97,7 @@ static int push_transfer_progress_cb(unsigned int current, unsigned int total, s (void) payload; char buf[80]; snprintf(buf, sizeof(buf), translate("gettextFromC", "Transfer to storage (%d/%d)"), current, total); - return git_storage_update_progress("push trasfer cb"); + return git_storage_update_progress(buf); } char *get_local_dir(const char *remote, const char *branch) @@ -432,7 +432,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference if (verbose) fprintf(stderr, "git storage: try to update\n"); - git_storage_update_progress("try to update"); + if (!git_reference_cmp(local, remote)) return 0; @@ -466,7 +466,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference } /* Is the remote strictly newer? Use it */ if (git_oid_equal(&base, local_id)) { - git_storage_update_progress("fast forward to remote"); + git_storage_update_progress(translate("gettextFromC", "Update local storage to match cloud storage")); return reset_to_remote(repo, local, remote_id); } @@ -474,7 +474,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference if (git_oid_equal(&base, remote_id)) { if (verbose) fprintf(stderr, "local is newer than remote, update remote\n"); - git_storage_update_progress("git_update_remote, local was newer"); + git_storage_update_progress(translate("gettextFromC", "Push local changes to cloud storage")); return update_remote(repo, origin, local, remote, rt); } /* Merging a bare repository always needs user action */ @@ -492,7 +492,7 @@ static int try_to_update(git_repository *repo, git_remote *origin, git_reference return report_error("Local and remote do not match, local branch not HEAD - cannot update"); } /* Ok, let's try to merge these */ - git_storage_update_progress("try to merge"); + git_storage_update_progress(translate("gettextFromC", "Try to merge local changes into cloud storage")); ret = try_to_git_merge(repo, &local, remote, &base, local_id, remote_id); if (ret == 0) return update_remote(repo, origin, local, remote, rt); @@ -514,7 +514,6 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c if (verbose) fprintf(stderr, "git storage: check remote status\n"); - git_storage_update_progress("git check remote status"); if (git_branch_lookup(&local_ref, repo, branch, GIT_BRANCH_LOCAL)) { if (is_subsurface_cloud) @@ -535,7 +534,7 @@ static int check_remote_status(git_repository *repo, git_remote *origin, const c else if (rt == RT_HTTPS) opts.callbacks.credentials = credential_https_cb; opts.callbacks.certificate_check = certificate_check_cb; - git_storage_update_progress("git remote push (no remote existed)"); + git_storage_update_progress(translate("gettextFromC", "Store data into cloud storage")); error = git_remote_push(origin, &refspec, &opts); } else { error = try_to_update(repo, origin, local_ref, remote_ref, remote, branch, rt); @@ -559,7 +558,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc } if (verbose) fprintf(stderr, "sync with remote %s[%s]\n", remote, branch); - git_storage_update_progress("sync with remote"); + git_storage_update_progress(translate("gettextFromC", "Sync with cloud storage")); git_repository_config(&conf, repo); if (rt == RT_HTTPS && getProxyString(&proxy_string)) { if (verbose) @@ -586,7 +585,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc if (rt == RT_HTTPS && !canReachCloudServer()) { // this is not an error, just a warning message, so return 0 report_error("Cannot connect to cloud server, working with local copy"); - git_storage_update_progress("can't reach cloud server, working with local copy"); + git_storage_update_progress(translate("gettextFromC", "Can't reach cloud server, working with local data")); return 0; } if (verbose) @@ -599,7 +598,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc else if (rt == RT_HTTPS) opts.callbacks.credentials = credential_https_cb; opts.callbacks.certificate_check = certificate_check_cb; - git_storage_update_progress("git fetch remote"); + git_storage_update_progress(translate("gettextFromC", "Successful cloud connection, fetch remote")); error = git_remote_fetch(origin, NULL, &opts, NULL); // NOTE! A fetch error is not fatal, we just report it if (error) { @@ -614,7 +613,7 @@ int sync_with_remote(git_repository *repo, const char *remote, const char *branc error = check_remote_status(repo, origin, remote, branch, rt); } git_remote_free(origin); - git_storage_update_progress("done with sync with remote"); + git_storage_update_progress(translate("gettextFromC", "Done syncing with cloud storage")); return error; } @@ -634,10 +633,9 @@ 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) { - git_storage_update_progress("update remote repo"); + if (!prefs.git_local_only) sync_with_remote(repo, remote, branch, rt); - } + return repo; } @@ -773,7 +771,7 @@ static struct git_repository *get_remote_repo(const char *localdir, const char * if (verbose > 1) { fprintf(stderr, "git_remote_repo: accessing %s\n", remote); } - git_storage_update_progress("start git interaction"); + git_storage_update_progress(translate("gettextFromC", "Synchronising data file")); /* Do we already have a local cache? */ if (!subsurface_stat(localdir, &st)) { if (!S_ISDIR(st.st_mode)) { diff --git a/core/git-access.h b/core/git-access.h index 395f5ed2b..6dec7a56b 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -30,8 +30,6 @@ int git_storage_update_progress(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; - #ifdef __cplusplus } #endif diff --git a/core/load-git.c b/core/load-git.c index 01c231c77..8c39c494e 100644 --- a/core/load-git.c +++ b/core/load-git.c @@ -1675,19 +1675,19 @@ static int do_git_load(git_repository *repo, const char *branch) git_commit *commit; git_tree *tree; - git_storage_update_progress("do_git_load, find the commit"); ret = find_commit(repo, branch, &commit); if (ret) return ret; - git_storage_update_progress("git commit tree"); if (git_commit_tree(&tree, commit)) return report_error("Could not look up tree of commit in branch '%s'", branch); - git_storage_update_progress("load dives from tree"); + git_storage_update_progress(translate("gettextFromC", "Load dives from local cache")); ret = load_dives_from_tree(repo, tree); - if (!ret) + if (!ret) { set_git_id(git_commit_id(commit)); + git_storage_update_progress(translate("gettextFromC", "Successfully opened dive data")); + } git_object_free((git_object *)tree); - git_storage_update_progress("done do_git_load"); + return ret; } diff --git a/core/save-git.c b/core/save-git.c index 8f4e4ff0b..dae9cf6a2 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -23,6 +23,7 @@ #include "git-access.h" #include "version.h" #include "qthelperfromc.h" +#include "gettext.h" #define VA_BUF(b, fmt) do { va_list args; va_start(args, fmt); put_vformat(b, fmt, args); va_end(args); } while (0) @@ -936,7 +937,7 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o struct dive *dive; dive_trip_t *trip; - git_storage_update_progress("start create git tree"); + git_storage_update_progress(translate("gettextFromC", "Start saving data")); save_settings(repo, root); save_divesites(repo, root); @@ -945,7 +946,7 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o trip->index = 0; /* save the dives */ - git_storage_update_progress("start saving dives"); + git_storage_update_progress(translate("gettextFromC", "Start saving dives")); for_each_dive(i, dive) { struct tm tm; struct dir *tree; @@ -978,7 +979,7 @@ static int create_git_tree(git_repository *repo, struct dir *root, bool select_o save_one_dive(repo, tree, dive, &tm, cached_ok); } - git_storage_update_progress("done creating git tree"); + git_storage_update_progress(translate("gettextFromC", "Done creating local cache")); return 0; } @@ -1209,7 +1210,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo fprintf(stderr, "git storage: do git save\n"); if (!create_empty) // so we are actually saving the dives - git_storage_update_progress("start git save"); + git_storage_update_progress(translate("gettextFromC", "Preparing to save data")); /* * Check if we can do the cached writes - we need to diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 0c598bd37..fef7e72ce 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -44,7 +44,7 @@ static void appendTextToLogStandalone(const char *text) extern "C" int gitProgressCB(const char *text) { static QElapsedTimer timer; - static qint64 lastTime; + static qint64 lastTime = 0; static QMLManager *self; if (!self) @@ -58,8 +58,9 @@ extern "C" int gitProgressCB(const char *text) qint64 elapsed = timer.elapsed(); self->appendTextToLog(text); self->setNotificationText(text); - if (elapsed - lastTime > 500) - qApp->processEvents(); + if (elapsed - lastTime > 50) { // 20 Hz refresh + qApp->processEvents(QEventLoop::ExcludeUserInputEvents); + } lastTime = elapsed; } // return 0 so that we don't end the download @@ -419,8 +420,7 @@ void QMLManager::retrieveUserid() s.sync(); } setCredentialStatus(VALID); - setStartPageText("Cloud credentials valid, loading dives..."); - git_storage_update_progress("load dives with valid credentials"); + setStartPageText(tr("Cloud credentials valid, loading dives...")); // this only gets called with "alreadySaving" already locked loadDivesWithValidCredentials(); } @@ -475,7 +475,7 @@ successful_exit: // if we came from local storage mode, let's merge the local data into the local cache // for the remote data - which then later gets merged with the remote data if necessary if (oldStatus() == NOCLOUD) { - git_storage_update_progress("import dives from nocloud local storage"); + git_storage_update_progress(qPrintable(tr("Loading dives from local storage ('no cloud' mode)"))); dive_table.preexisting = dive_table.nr; mergeLocalRepo(); DiveListModel::instance()->clear(); @@ -941,7 +941,6 @@ void QMLManager::changesNeedSaving() void QMLManager::saveChangesLocal() { if (unsaved_changes()) { - git_storage_update_progress("saving dives locally"); if (credentialStatus() == NOCLOUD) { if (same_string(existing_filename, "")) { char *filename = NOCLOUD_LOCALSTORAGE; @@ -976,7 +975,6 @@ void QMLManager::saveChangesLocal() } prefs.git_local_only = glo; mark_divelist_changed(false); - git_storage_update_progress("done with local save"); alreadySaving = false; } else { appendTextToLog("local save requested with no unsaved changes"); @@ -1007,12 +1005,10 @@ void QMLManager::saveChangesCloud(bool forceRemoteSync) } bool glo = prefs.git_local_only; - git_storage_update_progress("start save change to cloud"); prefs.git_local_only = false; alreadySaving = true; loadDivesWithValidCredentials(); alreadySaving = false; - git_storage_update_progress("finished syncing dive list to cloud server"); prefs.git_local_only = glo; } |