aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-18 17:57:13 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-18 17:57:13 -0800
commitd70f85ce35c95115438fecd26c70dc08ae4a3dbb (patch)
tree41abbe296ebb6f566aa116fc30ca3a4d9ea64fd0
parentd9ded26b86e9df8a87f92a5d7ad21f7fbce6edb6 (diff)
downloadsubsurface-d70f85ce35c95115438fecd26c70dc08ae4a3dbb.tar.gz
Cloud storage: modify protocol for checking cloud connectivity
In order to allow the backend to match account in multi user mode, it needs to know if the requests are coming from the same instance of Subsurface. Since I had to change the backend to add the ability to retrieve a location service userid I added this capability at the same time. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--desktop-widgets/updatemanager.cpp17
-rw-r--r--desktop-widgets/updatemanager.h1
-rw-r--r--desktop-widgets/usersurvey.cpp2
-rw-r--r--subsurface-core/checkcloudconnection.cpp1
-rw-r--r--subsurface-core/qthelper.cpp16
-rw-r--r--subsurface-core/qthelper.h1
6 files changed, 20 insertions, 18 deletions
diff --git a/desktop-widgets/updatemanager.cpp b/desktop-widgets/updatemanager.cpp
index 0760d6407..2ab92b3a5 100644
--- a/desktop-widgets/updatemanager.cpp
+++ b/desktop-widgets/updatemanager.cpp
@@ -1,5 +1,6 @@
#include "updatemanager.h"
#include "helpers.h"
+#include "qthelper.h"
#include <QtNetwork>
#include <QMessageBox>
#include <QUuid>
@@ -60,22 +61,6 @@ void UpdateManager::checkForUpdates(bool automatic)
connect(SubsurfaceWebServices::manager()->get(request), SIGNAL(finished()), this, SLOT(requestReceived()), Qt::UniqueConnection);
}
-QString UpdateManager::getUUID()
-{
- QString uuidString;
- QSettings settings;
- settings.beginGroup("UpdateManager");
- if (settings.contains("UUID")) {
- uuidString = settings.value("UUID").toString();
- } else {
- QUuid uuid = QUuid::createUuid();
- uuidString = uuid.toString();
- settings.setValue("UUID", uuidString);
- }
- uuidString.replace("{", "").replace("}", "");
- return uuidString;
-}
-
void UpdateManager::requestReceived()
{
bool haveNewVersion = false;
diff --git a/desktop-widgets/updatemanager.h b/desktop-widgets/updatemanager.h
index f91c82dc8..4e95d740f 100644
--- a/desktop-widgets/updatemanager.h
+++ b/desktop-widgets/updatemanager.h
@@ -11,7 +11,6 @@ class UpdateManager : public QObject {
public:
explicit UpdateManager(QObject *parent = 0);
void checkForUpdates(bool automatic = false);
- static QString getUUID();
public
slots:
diff --git a/desktop-widgets/usersurvey.cpp b/desktop-widgets/usersurvey.cpp
index 05da582a1..2d5d5b07e 100644
--- a/desktop-widgets/usersurvey.cpp
+++ b/desktop-widgets/usersurvey.cpp
@@ -31,7 +31,7 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent),
os.append(QString("&osCpuArch=%1").arg(osArch));
}
os.append(QString("&uiLang=%1").arg(uiLanguage(NULL)));
- os.append(QString("&uuid=%1").arg(UpdateManager::getUUID()));
+ os.append(QString("&uuid=%1").arg(getUUID()));
ui->system->setPlainText(getVersion());
}
diff --git a/subsurface-core/checkcloudconnection.cpp b/subsurface-core/checkcloudconnection.cpp
index be2a2fa18..428c4cda6 100644
--- a/subsurface-core/checkcloudconnection.cpp
+++ b/subsurface-core/checkcloudconnection.cpp
@@ -28,6 +28,7 @@ bool CheckCloudConnection::checkServer()
QNetworkRequest request;
request.setRawHeader("Accept", "text/plain");
request.setRawHeader("User-Agent", getUserAgent().toUtf8());
+ request.setRawHeader("Client-Id", getUUID().toUtf8());
request.setUrl(QString(prefs.cloud_base_url) + TEAPOT);
QNetworkAccessManager *mgr = new QNetworkAccessManager();
reply = mgr->get(request);
diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp
index ac1624aa3..23eb34e0f 100644
--- a/subsurface-core/qthelper.cpp
+++ b/subsurface-core/qthelper.cpp
@@ -1780,3 +1780,19 @@ void init_proxy()
}
QNetworkProxy::setApplicationProxy(proxy);
}
+
+QString getUUID()
+{
+ QString uuidString;
+ QSettings settings;
+ settings.beginGroup("UpdateManager");
+ if (settings.contains("UUID")) {
+ uuidString = settings.value("UUID").toString();
+ } else {
+ QUuid uuid = QUuid::createUuid();
+ uuidString = uuid.toString();
+ settings.setValue("UUID", uuidString);
+ }
+ uuidString.replace("{", "").replace("}", "");
+ return uuidString;
+}
diff --git a/subsurface-core/qthelper.h b/subsurface-core/qthelper.h
index 4345afae0..5b3e5bdee 100644
--- a/subsurface-core/qthelper.h
+++ b/subsurface-core/qthelper.h
@@ -142,5 +142,6 @@ void setCurrentAppState(QByteArray state);
extern "C" bool in_planner();
extern "C" void subsurface_mkdir(const char *dir);
void init_proxy();
+QString getUUID();
#endif // QTHELPER_H