summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-25 11:27:42 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-25 12:02:13 -0800
commit0f967063c0d4487ad71081564bfef139426c50b1 (patch)
tree2c37ff07b92c8c4800cd6fcb527cd0445200c1b8
parented9a060d76db4b56f89b2f0d3f7fd87c9d98f239 (diff)
downloadsubsurface-0f967063c0d4487ad71081564bfef139426c50b1.tar.gz
Add unique but random UUID to server queries
With this we can easily eliminate duplicates from our user statistics. The UUID is completely random and there is no way to link it back to a specific user. By deleting the settings a user can force a new UUID. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/updatemanager.cpp20
-rw-r--r--qt-ui/updatemanager.h1
-rw-r--r--qt-ui/usersurvey.cpp2
3 files changed, 22 insertions, 1 deletions
diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp
index b920a8ebb..e972c4496 100644
--- a/qt-ui/updatemanager.cpp
+++ b/qt-ui/updatemanager.cpp
@@ -2,6 +2,7 @@
#include "usersurvey.h"
#include <QtNetwork>
#include <QMessageBox>
+#include <QUuid>
#include "subsurfacewebservices.h"
#include "ssrf-version.h"
#include "mainwindow.h"
@@ -47,7 +48,8 @@ void UpdateManager::checkForUpdates(bool automatic)
#endif
isAutomaticCheck = automatic;
QString version = CANONICAL_VERSION_STRING;
- QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2").arg(os, version);
+ QString uuidString = getUUID();
+ QString url = QString("http://subsurface-divelog.org/updatecheck.html?os=%1&version=%2&uuid=%3").arg(os, version, uuidString);
QNetworkRequest request;
request.setUrl(url);
request.setRawHeader("Accept", "text/xml");
@@ -56,6 +58,22 @@ 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/qt-ui/updatemanager.h b/qt-ui/updatemanager.h
index 4e95d740f..f91c82dc8 100644
--- a/qt-ui/updatemanager.h
+++ b/qt-ui/updatemanager.h
@@ -11,6 +11,7 @@ class UpdateManager : public QObject {
public:
explicit UpdateManager(QObject *parent = 0);
void checkForUpdates(bool automatic = false);
+ static QString getUUID();
public
slots:
diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp
index ed5d121e2..4061d46df 100644
--- a/qt-ui/usersurvey.cpp
+++ b/qt-ui/usersurvey.cpp
@@ -6,6 +6,7 @@
#include "ui_usersurvey.h"
#include "ssrf-version.h"
#include "subsurfacewebservices.h"
+#include "updatemanager.h"
#include "helpers.h"
#include "subsurfacesysinfo.h"
@@ -30,6 +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()));
ui->system->setPlainText(getVersion());
}