diff options
| author | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:44 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:44 +0200 |
| commit | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (patch) | |
| tree | 6d9c83527c56458a8360ba080bf5f4ca73d526dc /map65/cqdatasender.cpp | |
| parent | 4b089ae3f7e9e2d5662f718f663b26a4e8ee63ca (diff) | |
New upstream version 3.0.2+dfsgupstream/3.0.2+dfsg
Diffstat (limited to 'map65/cqdatasender.cpp')
| -rw-r--r-- | map65/cqdatasender.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/map65/cqdatasender.cpp b/map65/cqdatasender.cpp index 6e437c44..182b40b5 100644 --- a/map65/cqdatasender.cpp +++ b/map65/cqdatasender.cpp @@ -5,6 +5,7 @@ #include <QNetworkReply> #include <QJsonDocument> #include <QJsonObject> +#include <QCoreApplication> #include <QDebug> #include <QThread> @@ -25,27 +26,30 @@ void CQDataSender::send(QString theUrl, const QString &data) { QUrl url(theUrl); QNetworkRequest request(url); - request.setRawHeader("User-Agent", "QMAP v0.5"); - request.setRawHeader("X-Custom-User-Agent", "QMAP v0.5"); + QByteArray userAgent = (QCoreApplication::applicationName() + " v" + + QCoreApplication::applicationVersion()).toUtf8(); + request.setRawHeader("User-Agent", userAgent); + request.setRawHeader("X-Custom-User-Agent", userAgent); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QByteArray payload = data.toUtf8(); request.setRawHeader("Content-Length",QByteArray::number(payload.size())); QNetworkReply *reply = m_networkManager->post(request, payload); qDebug() << "Current thread for CQDataSender::send:" << QThread::currentThread(); - // Use the OLD signal name: 'error' instead of 'errorOccurred' -#if QT_VERSION >= QT_VERSION_CHECK (5, 15, 0) - connect(reply, &QNetworkReply::errorOccurred, this, [this, reply](QNetworkReply::NetworkError) { - emit errorOccurred(reply->errorString()); - }); -#else - connect(reply, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), - this, [this, reply](QNetworkReply::NetworkError error) { - Q_UNUSED(error) - emit errorOccurred(reply->errorString()); - }); -#endif - // Connect to sslErrors without QOverload + // Qt 5.15+ (ignored on 5.12) + connect(reply, + SIGNAL(errorOccurred(QNetworkReply::NetworkError)), + this, + SLOT(onReplyError())); + +// Qt 5.12 (ignored on Qt 6) + connect(reply, + SIGNAL(error(QNetworkReply::NetworkError)), + this, + SLOT(onReplyError())); + + + // SSL errors unchanged connect(reply, &QNetworkReply::sslErrors, this, [this](const QList<QSslError> &errors) { QStringList errList; for (const auto &e : errors) @@ -65,3 +69,10 @@ void CQDataSender::onFinished(QNetworkReply *reply) reply->deleteLater(); qDebug() << "Current thread for CQDataSender::onFinished:" << QThread::currentThread(); } + +void CQDataSender::onReplyError() +{ + QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); + if (!reply) return; + emit errorOccurred(reply->errorString()); +} |
