diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-12-04 19:34:59 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-12-04 19:51:35 -0800 |
commit | fd78f8dc1ae3e64c7e861957d3207923f8df4714 (patch) | |
tree | 50cdf60c21ff7ff4f5964368d2e0c0d0afbb7302 /qt-mobile/qmlmanager.h | |
parent | 426660025402e47e8de89b6e741fd372cbcac8fb (diff) | |
download | subsurface-fd78f8dc1ae3e64c7e861957d3207923f8df4714.tar.gz |
QML-UI: re-architect the way we access network resources
We really need to verify that the credentials are valid before trying to access
our backend resources. Trying to do so in a clean manner caused quite a bit of
changes to how we retrieve the webservice userid and how we load the dive list
from cloud storage.
So instead of accessing the network resources directly, this adds a handler
function that first checks the validity of the credentials (by using the
rederict handler on the cloud server), and only calls the function that does
the actual work (looks up the web service userid, loads the dives) if that
succeeds.
Right now there is no good user feedback mechanism - this just gets logged on
the log page. But this is a massive improvement if there are issues with
network connectivity or if the user mistyped their credentials.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.h')
-rw-r--r-- | qt-mobile/qmlmanager.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index 22feadba3..bd6884894 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -3,6 +3,7 @@ #include <QObject> #include <QString> +#include <QNetworkAccessManager> #include "gpslocation.h" @@ -48,16 +49,26 @@ public: void setLogText(const QString &logText); void appendTextToLog(const QString &newText); + typedef void(QMLManager::*execute_function_type)(); + public slots: void savePreferences(); void saveCloudCredentials(); + void checkCredentialsAndExecute(execute_function_type execute); + void tryRetrieveDataFromBackend(); + void handleError(QNetworkReply::NetworkError nError); + void handleSslErrors(const QList<QSslError> &errors); + void retrieveUserid(); void loadDives(); + void loadDivesWithValidCredentials(); + void provideAuth(QNetworkReply *reply, QAuthenticator *auth); void commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes); void saveChanges(); void addDive(); void applyGpsData(); void sendGpsData(); void clearGpsData(); + void finishSetup(); private: QString m_cloudUserName; @@ -71,6 +82,9 @@ private: GpsLocation *locationProvider; bool m_loadFromCloud; static QMLManager *m_instance; + QNetworkReply *reply; + QNetworkRequest request; + QNetworkAccessManager *mgr; signals: void cloudUserNameChanged(); |