mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Location service: set user agent string
This allows the backend to know which version of Subsurface is contacting it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4cf20c3448
commit
d9ded26b86
3 changed files with 8 additions and 0 deletions
|
@ -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());
|
||||
|
|
|
@ -24,6 +24,7 @@ private:
|
|||
void status(QString msg);
|
||||
QSettings *geoSettings;
|
||||
QNetworkReply *reply;
|
||||
QString userAgent;
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue