summaryrefslogtreecommitdiff
path: root/qmap/mainwindow.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
committerChristoph Berg <myon@debian.org>2026-10-09 14:12:49 +0200
commit76956486fa7ef52a51d4e56df1e13a9f19a6c93c (patch)
treefe0c394439fdc167d1970372e8998874090854dd /qmap/mainwindow.cpp
parent0685fcada9f95fe90f70b387cd7d757da8209624 (diff)
parentffc62c792c9a5196cb4ce7a353287dfe20db6524 (diff)
Update upstream source from tag 'upstream/3.3.0_beta1+dfsg'
Update to upstream version '3.3.0~beta1+dfsg' with Debian dir 85037bbb9376721108594b59b54ead82ac6924a3
Diffstat (limited to 'qmap/mainwindow.cpp')
-rw-r--r--qmap/mainwindow.cpp91
1 files changed, 33 insertions, 58 deletions
diff --git a/qmap/mainwindow.cpp b/qmap/mainwindow.cpp
index 7f3b5352..aafce2c6 100644
--- a/qmap/mainwindow.cpp
+++ b/qmap/mainwindow.cpp
@@ -25,14 +25,11 @@
#include "qmap_ipc.h"
#include "qmap_decode_record.h"
#include "validators/LiveCQCallsign.hpp"
+#include "../Network/LiveCQUpload.hpp"
#include <QCoreApplication> //liveCQ
-#include <QNetworkAccessManager> //liveCQ
-#include <QNetworkRequest>
-#include <QNetworkReply>
#include <QUrl>
#include <QUrlQuery>
-#include <QEventLoop>
#define NFFT 32768
@@ -378,6 +375,10 @@ void MainWindow::readSettings()
}
m_w3szUrl=settings.value("w3szUrl",true).toBool(); //liveCQ
m_otherUrl=settings.value("otherUrl","").toString(); //liveCQ
+ m_livecq = std::make_unique<LiveCQUpload>(this);
+ m_livecq->setUserAgent(http_user_agent().toUtf8());
+ connect(m_livecq.get(), &LiveCQUpload::errorOccurred, this,
+ [](QString const& error) { qDebug() << error; });
ui->fAddComboBox->setVisible(ui->actionFadd_controls->isChecked());
ui->fAdd_label->setVisible(ui->actionFadd_controls->isChecked());
ui->pbSet->setVisible(ui->actionFadd_controls->isChecked());
@@ -1133,7 +1134,7 @@ void MainWindow::CreateLiveCQ(QStringList cqliveText)
QStringList bandInfo;
bandInfo = ui->labFreq->text().split(".",SkipEmptyParts);
QString bandFreq = bandInfo.at(0);
- QString theDate = ui->labUTC->text().trimmed().mid(0,12);
+ auto const nowUtc = QDateTime::currentDateTimeUtc();
QList<QStringList> decodeList;
for (const QString &item : cqliveText) {
@@ -1142,6 +1143,12 @@ void MainWindow::CreateLiveCQ(QStringList cqliveText)
if (!QMapLiveCQ::parse(thePieces, freqOffset, record)) {
continue;
}
+ // Built from numbers only: going through the month name shown in labUTC
+ // failed on non-English Windows and uploaded an empty date.
+ auto const spotTime = QMapLiveCQ::spotTime(thePieces.at(0), nowUtc);
+ if (!spotTime.isValid()) {
+ continue;
+ }
qDebug () << "item is: " << item;
if (m_myCall.length() >= 3 && m_myGrid.length() >= 4) {
QString theCall = record.callsign;
@@ -1162,7 +1169,7 @@ void MainWindow::CreateLiveCQ(QStringList cqliveText)
thePostLine.insert(8, theCall); //dx call
thePostLine.insert(9, theGrid); //dx grid
thePostLine.insert(10, m_myGrid.toUpper()); //myGrid
- thePostLine.insert(11, theDate); //the date
+ thePostLine.insert(11, spotTime.toString("yyyy-MM-ddTHH:mm:ss") + "Z"); //utc date and time
thePostLine.insert(12, m_myCall.toUpper()); //myCall
thePostLine.insert(13, "--"); //txpol
decodeList.append(thePostLine);
@@ -1184,64 +1191,32 @@ void MainWindow::sendLiveCQData(QList<QStringList>decodeList)
theUrl = m_otherUrl;
}
- QNetworkAccessManager *manager = new QNetworkAccessManager(this);
- QUrl url(theUrl);
- QNetworkRequest request(url);
- 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");
+ if (!m_livecq->setEndpoint(QUrl {theUrl})) return;
for (const QStringList &thePostLine : decodeList) {
- QString utcdatetimestringOriginal = thePostLine.at(11) + " " + thePostLine.at(3);
- QDateTime utcdatetimeUTC = QDateTime::fromString(utcdatetimestringOriginal, "yyyy MMM dd HHmmss");
- utcdatetimeUTC.setTimeSpec((Qt::UTC));
- QString utcdatetimeUTCString = utcdatetimeUTC.toString("yyyy-MM-ddTHH:mm:ss");
- utcdatetimeUTCString = utcdatetimeUTCString + "Z";
-
- QString postString = "skedfreq=" + thePostLine.at(0) + "&rxfreq=" + thePostLine.at(1) + "&rpol=" + thePostLine.at(2) + "&dt=" + thePostLine.at(4) + "&dB=" + thePostLine.at(5) + "&msgtype=" + thePostLine.at(7) + "&callsign=" + thePostLine.at(8) + "&grid=" + thePostLine.at(9) + "&mode=" + thePostLine.at(6) + "&utcdatetime=" + utcdatetimeUTCString + "&spotter=" + thePostLine.at(12) + "&spottergrid=" + thePostLine.at(10) + "&txpol=" + thePostLine.at(13) + "&apptype=QMAP";
-
- QByteArray postByteArray = postString.toUtf8();
- request.setRawHeader("Content-Length",QByteArray::number(postByteArray.size()));
-
-
- try {
- QNetworkReply *reply = manager->post(request,postByteArray);
- QObject::connect(reply, &QNetworkReply::finished, this, &MainWindow::handleReply);
- }
- catch (const std::exception& e) {
- // Handle standard C++ exceptions
- QMessageBox::critical(this, "Exception", "Exception at line 1165 MainWindow::sendLiveCQData " + QString::fromStdString(e.what()));
- }
- catch (...) {
- // Handle any other type of exception
- QMessageBox::critical(this, "Exception", "Unknown Exception at line 1170 MainWindow::sendLiveCQData");
- }
+ QString utcdatetimeUTCString = thePostLine.at(11);
+
+ QUrlQuery query;
+ query.addQueryItem("skedfreq", thePostLine.at(0));
+ query.addQueryItem("rxfreq", thePostLine.at(1));
+ query.addQueryItem("rpol", thePostLine.at(2));
+ query.addQueryItem("dt", thePostLine.at(4));
+ query.addQueryItem("dB", thePostLine.at(5));
+ query.addQueryItem("msgtype", thePostLine.at(7));
+ query.addQueryItem("callsign", thePostLine.at(8));
+ query.addQueryItem("grid", thePostLine.at(9));
+ query.addQueryItem("mode", thePostLine.at(6));
+ query.addQueryItem("utcdatetime", utcdatetimeUTCString);
+ query.addQueryItem("spotter", thePostLine.at(12));
+ query.addQueryItem("spottergrid", thePostLine.at(10));
+ query.addQueryItem("txpol", thePostLine.at(13));
+ query.addQueryItem("apptype", "QMAP");
+
+ m_livecq->postSpot(query);
}
}
-void MainWindow::handleReply()
-{
- try {
- QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
- if (reply->error() == QNetworkReply::NoError) {
- qDebug() << reply->readAll();
- } else {
- qDebug() << reply->errorString();
- }
- }
- catch (const std::exception& e) {
- // Handle standard C++ exceptions
- QMessageBox::critical(this, "Exception", "Exception at line 1188 MainWindow::handleReply " + QString::fromStdString(e.what()));
- }
- catch (...) {
- // Handle any other type of exception
- QMessageBox::critical(this, "Exception", "Unknown Exception at line 1193 MainWindow::handleReply");
- }
-}
-
//------------------------------------------------------------- //guiUpdate()
void MainWindow::guiUpdate()