mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
4266600254
commit
fd78f8dc1a
3 changed files with 117 additions and 20 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue