mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:13:24 +00:00
mobile: No cloud repo creation more explicit
Before this change, there was only one way to create the local no cloud repo on the device. The user needed to add at least one dive to the no cloud account (so that there is something to save). While this worked in some scenarios, it could also get things in an inconsistent state: credential status = CS_NOCLOUD but no local repo. This was a dead end. In this commit, the creation of the no cloud repo is made more explicit. When asking for no cloud mode, just create an (empty) repo for it when it does not yet exist, and otherwise, just open the existing (possibly empty) repo. Now, a user can have no cloud repo, next to (any number of) cloud accounts. This leaves one functional aspect left: how does a user abandon the no cloud repo, by merging his data into a true cloud account. This is code for this, that tries to do this merge in a smart way. This seems to be broken (too). To be clear: this is no part of this commit. Fixes: #667 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
90fcfca02c
commit
16b395a898
3 changed files with 38 additions and 1 deletions
|
@ -148,6 +148,7 @@ Item {
|
|||
manager.syncToCloud = false
|
||||
manager.credentialStatus = QMLManager.CS_NOCLOUD
|
||||
manager.saveCloudCredentials()
|
||||
manager.openNoCloudRepo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,6 +247,13 @@ void QMLManager::mergeLocalRepo()
|
|||
process_dives(true, false);
|
||||
}
|
||||
|
||||
void QMLManager::clearCredentials()
|
||||
{
|
||||
setCloudUserName(NULL);
|
||||
setCloudPassword(NULL);
|
||||
setCloudPin(NULL);
|
||||
}
|
||||
|
||||
void QMLManager::cancelCredentialsPinSetup()
|
||||
{
|
||||
/*
|
||||
|
@ -374,7 +381,7 @@ void QMLManager::saveCloudCredentials()
|
|||
|
||||
cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password, qPrintable(cloudPwd));
|
||||
|
||||
if (!cloudCredentialsChanged) {
|
||||
if (credentialStatus() != CS_NOCLOUD && !cloudCredentialsChanged) {
|
||||
// just go back to the dive list
|
||||
setCredentialStatus(oldStatus());
|
||||
}
|
||||
|
@ -1067,6 +1074,32 @@ void QMLManager::changesNeedSaving()
|
|||
saveChangesCloud(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QMLManager::openNoCloudRepo()
|
||||
/*
|
||||
* Open the No Cloud repo. In case this repo does not (yet)
|
||||
* exists, create one first. When done, open the repo, which
|
||||
* is obviously empty when just created.
|
||||
*/
|
||||
{
|
||||
char *filename = NOCLOUD_LOCALSTORAGE;
|
||||
const char *branch;
|
||||
struct git_repository *git;
|
||||
|
||||
git = is_git_repository(filename, &branch, NULL, false);
|
||||
|
||||
if (git == dummy_git_repository) {
|
||||
if (git_create_local_repo(filename))
|
||||
appendTextToLog(get_error_string());
|
||||
set_filename(filename, true);
|
||||
GeneralSettingsObjectWrapper s(this);
|
||||
s.setDefaultFilename(filename);
|
||||
s.setDefaultFileBehavior(LOCAL_DEFAULT_FILE);
|
||||
}
|
||||
|
||||
openLocalThenRemote(filename);
|
||||
}
|
||||
|
||||
void QMLManager::saveChangesLocal()
|
||||
{
|
||||
if (unsaved_changes()) {
|
||||
|
@ -1445,6 +1478,7 @@ void QMLManager::setCredentialStatus(const cloud_status_qml value)
|
|||
if (value == CS_NOCLOUD) {
|
||||
appendTextToLog("Switching to no cloud mode");
|
||||
set_filename(NOCLOUD_LOCALSTORAGE, true);
|
||||
clearCredentials();
|
||||
}
|
||||
m_credentialStatus = value;
|
||||
emit credentialStatusChanged();
|
||||
|
|
|
@ -163,6 +163,7 @@ public slots:
|
|||
QString diveMaster, QString weight, QString notes, QString startpressure,
|
||||
QString endpressure, QString gasmix, QString cylinder, int rating, int visibility);
|
||||
void changesNeedSaving();
|
||||
void openNoCloudRepo();
|
||||
void saveChangesLocal();
|
||||
void saveChangesCloud(bool forceRemoteSync);
|
||||
void deleteDive(int id);
|
||||
|
@ -175,6 +176,7 @@ public slots:
|
|||
void populateGpsData();
|
||||
void cancelDownloadDC();
|
||||
void clearGpsData();
|
||||
void clearCredentials();
|
||||
void cancelCredentialsPinSetup();
|
||||
void finishSetup();
|
||||
void openLocalThenRemote(QString url);
|
||||
|
|
Loading…
Add table
Reference in a new issue