aboutsummaryrefslogtreecommitdiffstats
path: root/core/settings/qPrefCloudStorage.cpp
AgeCommit message (Collapse)Author
2021-04-19cloudstorage: try to pick between multiple cloud serversGravatar Dirk Hohndel
The backend infrastructure will soon be able to support more than one cloud server which automagically stay in sync with each other. One critical requirement for that to work is that once a session was started with one of the servers, the complete session happens with that server - we must not switch from server to server while doing a git transaction. To make sure that's the case, we aren't trying to use DNS tricks to make this load balancing scheme work, but instead try to determine at program start which server is the best one to use. Right now this is super simplistic. Two servers, one in the US, one in Europe. By default we use the European server (most of our users appear to be in Europe), but if we can figure out that the client is actually in the Americas, use the US server. We might improve that heuristic over time, but as a first attempt it seems not entirely bogus. The way this is implemented is a simple combination of two free webservices that together appear to give us a very reliable estimate which continent the user is located on. api.ipify.org gives us our external IP address ip-api.com gives us the continent that IP address is on If any of this fails or takes too long to respond, we simply ignore it since either server will work. One oddity is that if we decide to change servers we only change the settings that are stored on disk, not the runtime preferences. This goes back to the comment above that we have to avoid changing servers in mid sync. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19cloudstorage: add API to just update on-disk settingGravatar Dirk Hohndel
This way we can change the host that we will use next time the app runs. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-04-19cloudstorage: some cleanup of cloud url handlingGravatar Dirk Hohndel
We know the preference is never empty, so stop testing for this. But don't maintain two different preferences with basically the same content. Instead add the '/git' suffix where needed and keep this all in one place. Simplify the extraction of the branch name from the cloud URL. Also a typo fix and a new comment. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-11core/settings: extend qPrefCloudStorage with divelogsde user infoGravatar jan Iversen
Add divelogsde_userid and divelogsde_password to qPrefCloudStorage to be used in Export.qml Extending qPrefCloudStorage is more logical than adding QSettings (and securing the same behaviour) outside qPref. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-11core/settings: extend qPrefCloudStorage with diveshare uid/privateGravatar jan Iversen
Add diveshare/uid and diveshare/private to qPrefCloudStorage to be used in Export.qml as well as diveshareexportdialog Extending qPrefCloudStorage is more logical than adding QSettings (and securing the same behaviour) outside qPref. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-05core/settings: make qPref* constructors privateGravatar jan Iversen
Signed-off-by: Jan Iversen <jani@apache.org>
2018-10-09Prefs: add bool preference cloud_auto_sync [1/3]Gravatar Jan Mulder
With removal of the git_local_only from the preferences (see ae653703a5d3f), the users choice, in the mobile app, was not stored any more in between sessions. This resulted in issue 1725. So, in order to store that user preference, we need a new preference. This is added here, but its not yet hooked up in the app yet. This deals only with the preference handling. And adapted tests are included. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-11core/settings: optimize base_url functions.Gravatar jan Iversen
Remove unused variable and create of QString. Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11core/setting: change *_changed to *Changed for the sake of QML.Gravatar jan Iversen
QML demands signals to be of the form <name>Changed Changing all of qPref REMARK: this commit is not compileable, since it only change qPref and not the rest of the system Signed-off-by: Jan Iversen <jani@apache.org>
2018-09-11Cleanup[5/6]: remove unused preferencesGravatar Jan Mulder
Remove all the code to handle the preferences itself. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-10prefs: cloud_new_password is not a preferenceGravatar Dirk Hohndel
It's a mamber of the cloud storage authentication class, used to hold the proposed new password until the backend has accepted it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-10prefs: git_local_only is not a preferenceGravatar Dirk Hohndel
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>
2018-09-07qPref: use helper function to ensure key/name groupingGravatar Dirk Hohndel
We had a couple of instances of names being incorrectly merged with their group, this should handle that better. It's a bit of a big hammer to use, but it seems to work (and it makes it easy to then git grep for cases that don't use the new helper function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07Preferences: more missing /Gravatar Jan Mulder
subsurface_webservice_uid ends up in the wrong group due missing /. Notice that this does not fix the issues I mentioned in #1648. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-09-06Revert "core/tests: add loadFromCloud var to qPrefCloudStorage"Gravatar jan Iversen
This reverts commit b7a1bb670ce11b22e52361f4152b4853b97e13f5. Signed-off-by: Jan Iversen <jani@apache.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-06qPref: only save settings that aren't the defaultGravatar Dirk Hohndel
This brings us back to the previous behavior. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-25core/tests: add loadFromCloud var to qPrefCloudStorageGravatar jan Iversen
Add special property loadFromCloud + mail to qPrefCloudStorage this variable is used by qmlmanager.cpp Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-25core: make methods in qPrefPrivate staticGravatar jan Iversen
Small cleanup, using static methods is simpler and faster Added propSetValue and propValue instead of exposing setting variable. Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15core: qPref limit header includesGravatar jan Iversen
replace qPref.h with qPrefFoo.h to limit header includes Signed-off-by: Jan Iversen <jani@apache.org>
2018-08-15core: make methods in qPref* staticGravatar jan Iversen
Make methods static to allow fast and esay access use qPrefXYZ::foo() instead of qPrefXYZ::instance()->foo() Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-27core: fix qPrefCloudStorage to derive git_urlGravatar jan Iversen
remove set_git_url and git_url_changed, because it is not possible to set git_url, this is done inderectly through set_base_url Update disk_base_url to generated git_url for both load/sync Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-26Whitespace cleanup core/settingsGravatar Dirk Hohndel
We can argue about any of the changes here, but they are the result of our whitespace.pl script - so if any of this is offensive to you, part of the resolution will be fixing the script... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-25core: qPrefCloudStorage save userid to new locationGravatar jan Iversen
userid was saved outside all groups, even though it belongs to cloudStorage Add code to save in new location and read from new/old location Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25core: remove LOADSYNC* macrosGravatar jan Iversen
expend LOADSYNC* into DISK_* macros remove LOADSYNC* from qPrefPrivate.h update qPrefDisplay to not use LOADSYNC* Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25core: make qPrefAnimations/CloudStorage getters static and inlineGravatar jan Iversen
Add static and inline to getter in all qPref header files Remove call to GET_PREFERENCE_* in qPrefDisplay.cpp Remove GET_PREFERENCE_* from qPrefPrivate.h static inline is slightly faster than a function call, but it saves a lot of coding lines (no lines in qPref*.cpp). Getters are a direct reference to struct preferences, so they will normally only be used from QML. Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25core: qPref replace COPY_TXT with copy_txt in qPrefPrivateGravatar jan Iversen
Add copy_txt function to qPrefPrivate class Remove macro COPY_TXT from qPrefPrivate.h Replace use of COPY_TXT with copy_txt in qPref classes copy_txt is only once, COPY_TXT was expanded approx. 160 times, so this commit saves space (and removes a macro). Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21core: create qPrefCloudStorage from SettingsObjectWrapperGravatar jan Iversen
Update set/get functions to follow common name scheme: - get function have same name as in struct preferences - set function have set_<name> (from struct preferences>) - signal function have <name>_changed (from struct preferences>) one class one .h/.cpp is the C++ idiom. Having load/sync of each variable in 1 functions (in contrast to the distributed way SettingsObjectWrapper handles it) secures the same storage name is used. Having the set/get/load/sync functions grouped together makes it easier to get an overview. REMARK: this commit only defines the class, it is not active in production Signed-off-by: Jan Iversen <jani@apache.org>