diff options
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 7 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.h | 1 | ||||
-rw-r--r-- | qt-ui/updatemanager.cpp | 8 | ||||
-rw-r--r-- | qt-ui/usersurvey.cpp | 31 | ||||
-rw-r--r-- | qt-ui/usersurvey.h | 1 |
5 files changed, 34 insertions, 14 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index e0b411b06..565dc3fc7 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -1,6 +1,7 @@ #include "subsurfacewebservices.h" #include "webservice.h" #include "mainwindow.h" +#include "usersurvey.h" #include <libxml/parser.h> #include <zip.h> #include <errno.h> @@ -219,6 +220,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", " "); } void WebServices::hidePassword() @@ -397,6 +399,7 @@ void SubsurfaceWebServices::startDownload() QNetworkRequest request; request.setUrl(url); request.setRawHeader("Accept", "text/xml"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); reply = manager()->get(request); ui.status->setText(tr("Connecting...")); ui.progressBar->setEnabled(true); @@ -674,6 +677,7 @@ void DivelogsDeWebServices::startUpload() QNetworkRequest request; request.setUrl(QUrl("https://divelogs.de/DivelogsDirectImport.php")); request.setRawHeader("Accept", "text/xml, application/xml"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); QHttpPart part; part.setRawHeader("Content-Disposition", "form-data; name=\"user\""); @@ -705,6 +709,7 @@ void DivelogsDeWebServices::startDownload() QNetworkRequest request; request.setUrl(QUrl("https://divelogs.de/xml_available_dives.php")); request.setRawHeader("Accept", "text/xml, application/xml"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) @@ -749,6 +754,7 @@ void DivelogsDeWebServices::listDownloadFinished() QNetworkRequest request; request.setUrl(QUrl("https://divelogs.de/DivelogsDirectExport.php")); request.setRawHeader("Accept", "application/zip, */*"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) @@ -923,6 +929,7 @@ QNetworkReply* UserSurveyServices::sendSurvey(QString values) QNetworkRequest request; request.setUrl(QString("http://subsurface.hohndel.org/survey?%1").arg(values)); request.setRawHeader("Accept", "text/xml"); + request.setRawHeader("User-Agent", userAgent.toUtf8()); reply = manager()->get(request); return reply; } diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 97f35f235..a9735382c 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -43,6 +43,7 @@ protected: QTimer timeout; QByteArray downloadedData; QString defaultApplyText; + QString userAgent; }; class SubsurfaceWebServices : public WebServices { diff --git a/qt-ui/updatemanager.cpp b/qt-ui/updatemanager.cpp index f92eeb873..47554fcc5 100644 --- a/qt-ui/updatemanager.cpp +++ b/qt-ui/updatemanager.cpp @@ -1,4 +1,5 @@ #include "updatemanager.h" +#include "usersurvey.h" #include <QtNetwork> #include <QMessageBox> #include "subsurfacewebservices.h" @@ -24,7 +25,12 @@ void UpdateManager::checkForUpdates() QString version = VERSION_STRING; QString url = QString("http://subsurface.hohndel.org/updatecheck.html?os=%1&ver=%2").arg(os, version); - connect(SubsurfaceWebServices::manager()->get(QNetworkRequest(QUrl(url))), SIGNAL(finished()), this, SLOT(requestReceived())); + QNetworkRequest request; + request.setUrl(url); + request.setRawHeader("Accept", "text/xml"); + QString userAgent = UserSurvey::getVersion().replace("\n", " "); + request.setRawHeader("User-Agent", userAgent.toUtf8()); + connect(SubsurfaceWebServices::manager()->get(request), SIGNAL(finished()), this, SLOT(requestReceived())); } void UpdateManager::requestReceived() diff --git a/qt-ui/usersurvey.cpp b/qt-ui/usersurvey.cpp index 8e57df940..ff55e8133 100644 --- a/qt-ui/usersurvey.cpp +++ b/qt-ui/usersurvey.cpp @@ -14,7 +14,6 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), ui(new Ui::UserSurvey) { - QString osArch, arch; ui->setupUi(this); this->adjustSize(); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); @@ -22,24 +21,30 @@ UserSurvey::UserSurvey(QWidget *parent) : QDialog(parent), QShortcut *quitKey = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quitKey, SIGNAL(activated()), parent, SLOT(close())); - // fill in the system data - QString sysInfo = QString("Subsurface %1").arg(VERSION_STRING); os = QString("ssrfVers=%1").arg(VERSION_STRING); - sysInfo.append(tr("\nOperating System: %1").arg(SubsurfaceSysInfo::prettyOsName())); os.append(QString("&prettyOsName=%1").arg(SubsurfaceSysInfo::prettyOsName())); - arch = SubsurfaceSysInfo::cpuArchitecture(); - sysInfo.append(tr("\nCPU Architecture: %1").arg(arch)); + QString arch = SubsurfaceSysInfo::cpuArchitecture(); os.append(QString("&appCpuArch=%1").arg(arch)); if (arch == "i386") { - osArch = SubsurfaceSysInfo::osArch(); - if (!osArch.isEmpty()) { - sysInfo.append(tr("\nOS CPU Architecture: %1").arg(osArch)); - os.append(QString("&osCpuArch=%1").arg(osArch)); - } + QString osArch = SubsurfaceSysInfo::osArch(); + os.append(QString("&osCpuArch=%1").arg(osArch)); } - sysInfo.append(tr("\nLanguage: %1").arg(uiLanguage(NULL))); os.append(QString("&uiLang=%1").arg(uiLanguage(NULL))); - ui->system->setPlainText(sysInfo); + ui->system->setPlainText(getVersion()); +} + +QString UserSurvey::getVersion() +{ + QString arch; + // fill in the system data + QString sysInfo = QString("Subsurface %1").arg(VERSION_STRING); + sysInfo.append(tr("\nOperating System: %1").arg(SubsurfaceSysInfo::prettyOsName())); + arch = SubsurfaceSysInfo::cpuArchitecture(); + sysInfo.append(tr("\nCPU Architecture: %1").arg(arch)); + if (arch == "i386") + sysInfo.append(tr("\nOS CPU Architecture: %1").arg(SubsurfaceSysInfo::osArch())); + sysInfo.append(tr("\nLanguage: %1").arg(uiLanguage(NULL))); + return sysInfo; } UserSurvey::~UserSurvey() diff --git a/qt-ui/usersurvey.h b/qt-ui/usersurvey.h index 8dacb7bb8..1dd5aaab3 100644 --- a/qt-ui/usersurvey.h +++ b/qt-ui/usersurvey.h @@ -15,6 +15,7 @@ class UserSurvey : public QDialog { public: explicit UserSurvey(QWidget *parent = 0); ~UserSurvey(); + static QString getVersion(); private slots: |