diff options
-rw-r--r-- | qt-mobile/gpslocation.cpp | 3 | ||||
-rw-r--r-- | qt-mobile/gpslocation.h | 1 | ||||
-rw-r--r-- | subsurface-core/qthelper.cpp | 4 |
3 files changed, 8 insertions, 0 deletions
diff --git a/qt-mobile/gpslocation.cpp b/qt-mobile/gpslocation.cpp index f78a482a0..b109a01a3 100644 --- a/qt-mobile/gpslocation.cpp +++ b/qt-mobile/gpslocation.cpp @@ -28,6 +28,7 @@ GpsLocation::GpsLocation(QObject *parent) } else { status("don't have GPS source"); } + userAgent = getUserAgent(); } void GpsLocation::serviceEnable(bool toggle) @@ -95,6 +96,7 @@ QString GpsLocation::getUserid(QString user, QString passwd) data = user + " " + passwd; QNetworkRequest request; request.setUrl(url); + request.setRawHeader("User-Agent", getUserAgent().toUtf8()); request.setRawHeader("Accept", "text/html"); request.setRawHeader("Content-type", "application/x-www-form-urlencoded"); reply = manager->post(request, data.toUtf8()); @@ -299,6 +301,7 @@ void GpsLocation::uploadToServer() status(data.toString(QUrl::FullyEncoded).toUtf8()); QNetworkRequest request; request.setUrl(url); + request.setRawHeader("User-Agent", getUserAgent().toUtf8()); request.setRawHeader("Accept", "text/json"); request.setRawHeader("Content-type", "application/x-www-form-urlencoded"); reply = manager->post(request, data.toString(QUrl::FullyEncoded).toUtf8()); diff --git a/qt-mobile/gpslocation.h b/qt-mobile/gpslocation.h index d00fbae6a..82cab8082 100644 --- a/qt-mobile/gpslocation.h +++ b/qt-mobile/gpslocation.h @@ -24,6 +24,7 @@ private: void status(QString msg); QSettings *geoSettings; QNetworkReply *reply; + QString userAgent; signals: diff --git a/subsurface-core/qthelper.cpp b/subsurface-core/qthelper.cpp index cc41db2da..ac1624aa3 100644 --- a/subsurface-core/qthelper.cpp +++ b/subsurface-core/qthelper.cpp @@ -790,7 +790,11 @@ QString getUserAgent() QString arch; // fill in the system data - use ':' as separator // replace all other ':' with ' ' so that this is easy to parse +#ifdef SUBSURFACE_MOBILE + QString userAgent = QString("Subsurface-mobile:%1:").arg(subsurface_version()); +#else QString userAgent = QString("Subsurface:%1:").arg(subsurface_version()); +#endif userAgent.append(SubsurfaceSysInfo::prettyOsName().replace(':', ' ') + ":"); arch = SubsurfaceSysInfo::buildCpuArchitecture().replace(':', ' '); userAgent.append(arch); |