diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2016-01-26 12:45:03 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-26 09:51:38 -0800 |
commit | 6575a0b4b84780ead4743aac72adde03bd3dfcdf (patch) | |
tree | c8081d306f519edef1ffa01fc31ad99c125b10c0 | |
parent | ccf29679ae6e9eebf63a925dc99021c8f1e402dc (diff) | |
download | subsurface-6575a0b4b84780ead4743aac72adde03bd3dfcdf.tar.gz |
We already have a QNetworkAcessManager global, use it
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 24 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 1 |
2 files changed, 11 insertions, 14 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 8767cef93..70d27d90d 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -14,14 +14,15 @@ #include "qthelper.h" #include "qt-gui.h" #include "git-access.h" +#include "subsurface-core/cloudstorage.h" QMLManager *QMLManager::m_instance = NULL; static void appendTextToLogStandalone(const char *text) { - QMLManager *mgr = QMLManager::instance(); - if (mgr) - mgr->appendTextToLog(QString(text)); + QMLManager *self = QMLManager::instance(); + if (self) + self->appendTextToLog(QString(text)); } extern "C" int gitProgressCB(int percent) @@ -30,9 +31,9 @@ extern "C" int gitProgressCB(int percent) if (percent - lastPercent >= 10) { lastPercent += 10; - QMLManager *mgr = QMLManager::instance(); - if (mgr) - mgr->loadDiveProgress(percent); + QMLManager *self = QMLManager::instance(); + if (self) + self->loadDiveProgress(percent); } // return 0 so that we don't end the download return 0; @@ -41,8 +42,7 @@ extern "C" int gitProgressCB(int percent) QMLManager::QMLManager() : m_locationServiceEnabled(false), m_verboseEnabled(false), m_loadFromCloud(false), - reply(0), - mgr(0) + reply(0) { m_instance = this; appendTextToLog(getUserAgent()); @@ -165,15 +165,13 @@ void QMLManager::checkCredentialsAndExecute(execute_function_type execute) !same_string(prefs.cloud_storage_password, "")) { setStartPageText(tr("Testing cloud credentials")); appendTextToLog("Have credentials, let's see if they are valid"); - if (!mgr) - mgr = new QNetworkAccessManager(this); - connect(mgr, &QNetworkAccessManager::authenticationRequired, this, &QMLManager::provideAuth, Qt::UniqueConnection); - connect(mgr, &QNetworkAccessManager::finished, this, execute, Qt::UniqueConnection); + connect(manager(), &QNetworkAccessManager::authenticationRequired, this, &QMLManager::provideAuth, Qt::UniqueConnection); + connect(manager(), &QNetworkAccessManager::finished, this, execute, Qt::UniqueConnection); QUrl url(CLOUDREDIRECTURL); request = QNetworkRequest(url); request.setRawHeader("User-Agent", getUserAgent().toUtf8()); request.setRawHeader("Accept", "text/html"); - reply = mgr->get(request); + reply = manager()->get(request); connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(handleError(QNetworkReply::NetworkError))); connect(reply, &QNetworkReply::sslErrors, this, &QMLManager::handleSslErrors); } diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index bcaf9c726..f06ff0868 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -105,7 +105,6 @@ private: static QMLManager *m_instance; QNetworkReply *reply; QNetworkRequest request; - QNetworkAccessManager *mgr; signals: void cloudUserNameChanged(); |