diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-06-16 06:08:31 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-06-16 06:08:31 -0700 |
commit | 854f55fd89f399ba59881b8b11a52d20e3847f72 (patch) | |
tree | db23f2fbad65cea9b533591fd0f2499ddb239164 /qt-ui | |
parent | 0fa0eb2879bf72654a7febf8b977b0ba6f515658 (diff) | |
download | subsurface-854f55fd89f399ba59881b8b11a52d20e3847f72.tar.gz |
Move checking the cloud connection into its own files
This isn't UI related and shouldn't have been in a file full of UI
functionality.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 45 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.h | 7 |
2 files changed, 0 insertions, 52 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 665bcf43a..969025d9a 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -1007,48 +1007,3 @@ void CloudStorageAuthenticate::sslErrors(QList<QSslError> errorList) qDebug() << err.errorString(); } } - -CheckCloudConnection::CheckCloudConnection(QObject *parent) -{ - -} - -#define TEAPOT "/make-latte?number-of-shots=3" -#define HTTP_I_AM_A_TEAPOT 418 -#define MILK "Linus does not like non-fat milk" -bool CheckCloudConnection::checkServer() -{ - QTimer timer; - timer.setSingleShot(true); - QEventLoop loop; - QNetworkRequest request; - request.setRawHeader("Accept", "text/plain"); - request.setRawHeader("User-Agent", getUserAgent().toUtf8()); - request.setUrl(QString(prefs.cloud_base_url) + TEAPOT); - QNetworkAccessManager *mgr = new QNetworkAccessManager(); - QNetworkReply *reply = mgr->get(request); - connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - timer.start(2000); // wait two seconds - loop.exec(); - if (timer.isActive()) { - // didn't time out, did we get the right response? - timer.stop(); - if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == HTTP_I_AM_A_TEAPOT && - reply->readAll() == QByteArray(MILK)) { - reply->deleteLater(); - mgr->deleteLater(); - return true; - } - // qDebug() << "did not get expected response - server unreachable" << - // reply->error() << reply->errorString() << - // reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() << - // reply->readAll(); - } else { - disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit())); - reply->abort(); - } - reply->deleteLater(); - mgr->deleteLater(); - return false; -} diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 43d1a8add..e4866c529 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -129,13 +129,6 @@ private: }; -class CheckCloudConnection : public QObject { - Q_OBJECT -public: - explicit CheckCloudConnection(QObject *parent = 0); - static bool checkServer(); -}; - #ifdef __cplusplus extern "C" { #endif |