void QMLManager::retrieveUserid() { if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 302) { appendTextToLog(QStringLiteral("Cloud storage connection not working correctly: (%1) %2") .arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()) .arg(QString(reply->readAll()))); setStartPageText(RED_FONT + tr("Cannot connect to cloud storage") + END_FONT); revertToNoCloudIfNeeded(); return; } setCredentialStatus(VALID); QString userid(prefs.userid); if (userid.isEmpty()) { if (same_string(prefs.cloud_storage_email, "") || same_string(prefs.cloud_storage_password, "")) { appendTextToLog("cloud user name or password are empty, can't retrieve web user id"); revertToNoCloudIfNeeded(); return; } appendTextToLog(QStringLiteral("calling getUserid with user %1").arg(prefs.cloud_storage_email)); userid = locationProvider->getUserid(prefs.cloud_storage_email, prefs.cloud_storage_password); } if (!userid.isEmpty()) { // overwrite the existing userid free(prefs.userid); prefs.userid = strdup(qPrintable(userid)); QSettings s; s.setValue("subsurface_webservice_uid", prefs.userid); s.sync(); } setCredentialStatus(VALID); setStartPageText("Cloud credentials valid, loading dives..."); git_storage_update_progress(true, "load dives with valid credentials"); // this only gets called with "alreadySaving" already locked loadDivesWithValidCredentials(); }
void QMLManager::saveChangesCloud(bool forceRemoteSync) { if (!unsaved_changes() && !forceRemoteSync) { appendTextToLog("asked to save changes but no unsaved changes"); return; } if (alreadySaving) { appendTextToLog("save operation in progress already"); return; } // first we need to store any unsaved changes to the local repo saveChangesLocal(); // if the user asked not to push to the cloud we are done if (prefs.git_local_only && !forceRemoteSync) return; if (!loadFromCloud()) { appendTextToLog("Don't save dives without loading from the cloud, first."); return; } bool glo = prefs.git_local_only; git_storage_update_progress(false, "start save change to cloud"); prefs.git_local_only = false; alreadySaving = true; loadDivesWithValidCredentials(); alreadySaving = false; git_storage_update_progress(false, "finished syncing dive list to cloud server"); setAccessingCloud(-1); prefs.git_local_only = glo; }
void QMLManager::saveChangesCloud() { git_storage_update_progress(true, "start save change to cloud"); if (!loadFromCloud()) { appendTextToLog("Don't save dives without loading from the cloud, first."); return; } bool glo = prefs.git_local_only; bool cbs = prefs.cloud_background_sync; // first we need to store any unsaved changes to the local repo saveChangesLocal(); if (alreadySaving) { appendTextToLog("save operation in progress already, can't sync with server"); return; } prefs.git_local_only = false; alreadySaving = true; loadDivesWithValidCredentials(); alreadySaving = false; git_storage_update_progress(false, "finished syncing dive list to cloud server"); setAccessingCloud(-1); prefs.git_local_only = glo; prefs.cloud_background_sync = cbs; alreadySaving = false; }