summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-08 11:13:05 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-08 11:13:05 -0700
commit827d4740c3bc2d449ab32a1ef829191bff20d46f (patch)
treed93378fce52b3456c0438c0f73e876c45fba3b11
parenta9f59c0cb3c1aa038a1d0c035d47130ddba58beb (diff)
downloadsubsurface-827d4740c3bc2d449ab32a1ef829191bff20d46f.tar.gz
Better User Agent for Subsurface
This one is less verbose and very easy to parse. It's guaranteed to have five components, separated by ':' with no other ':' in the string: Subsurface:<version>:<PrettyOSName>:<appCpuArch[/osCpuArch]>:<UILang> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/subsurfacewebservices.cpp2
-rw-r--r--qt-ui/updatemanager.cpp2
-rw-r--r--qt-ui/usersurvey.cpp16
-rw-r--r--qt-ui/usersurvey.h1
4 files changed, 19 insertions, 2 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 2b988c7a6..c3661e0ef 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -223,7 +223,7 @@ WebServices::WebServices(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f
ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
timeout.setSingleShot(true);
defaultApplyText = ui.buttonBox->button(QDialogButtonBox::Apply)->text();
- userAgent = UserSurvey::getVersion().replace("\n", " ");
+ userAgent = UserSurvey::getUserAgent();
}
void WebServices::hidePassword()
diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp
index 4729998c7..4ea9f188e 100644
--- a/qt-ui/updatemanager.cpp
+++ b/qt-ui/updatemanager.cpp
@@ -28,7 +28,7 @@ void UpdateManager::checkForUpdates()
QNetworkRequest request;
request.setUrl(url);
request.setRawHeader("Accept", "text/xml");
- QString userAgent = UserSurvey::getVersion().replace("\n", " ");
+ QString userAgent = UserSurvey::getUserAgent();
request.setRawHeader("User-Agent", userAgent.toUtf8());
connect(SubsurfaceWebServices::manager()->get(request), SIGNAL(finished()), this, SLOT(requestReceived()));
}
diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp
index ff55e8133..f436fce47 100644
--- a/qt-ui/usersurvey.cpp
+++ b/qt-ui/usersurvey.cpp
@@ -47,6 +47,22 @@ QString UserSurvey::getVersion()
return sysInfo;
}
+QString UserSurvey::getUserAgent()
+{
+ QString arch;
+ // fill in the system data - use ':' as separator
+ // replace all other ':' with ' ' so that this is easy to parse
+ QString userAgent = QString("Subsurface:%1:").arg(VERSION_STRING);
+ userAgent.append(SubsurfaceSysInfo::prettyOsName().replace(':', ' ') + ":");
+ arch = SubsurfaceSysInfo::cpuArchitecture().replace(':', ' ');
+ userAgent.append(arch);
+ if (arch == "i386")
+ userAgent.append("/" + SubsurfaceSysInfo::osArch());
+ userAgent.append(":" + uiLanguage(NULL));
+ return userAgent;
+
+}
+
UserSurvey::~UserSurvey()
{
delete ui;
diff --git a/qt-ui/usersurvey.h b/qt-ui/usersurvey.h
index 1dd5aaab3..55140521e 100644
--- a/qt-ui/usersurvey.h
+++ b/qt-ui/usersurvey.h
@@ -16,6 +16,7 @@ public:
explicit UserSurvey(QWidget *parent = 0);
~UserSurvey();
static QString getVersion();
+ static QString getUserAgent();
private
slots: