summaryrefslogtreecommitdiff
path: root/map65/messages.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2025-09-15 23:04:33 +0200
committerChristoph Berg <myon@debian.org>2025-09-15 23:04:33 +0200
commite1c678ef00f0159bbeb5571e5ebb0d4697121334 (patch)
tree6547edef81a62a812a4d0f64e03fda226b5f0a7e /map65/messages.cpp
parentb9daa22c4c3ad51cd4bc0ef624a19f21d01c9305 (diff)
parent0a13f1fdb9928b6d012569dd65f7f6ef18fac2f8 (diff)
Update upstream source from tag 'upstream/3.0.0_rc1+repack'
Update to upstream version '3.0.0~rc1+repack' with Debian dir 68c212e23136fecf9ebc6f12ff355579224d27ee
Diffstat (limited to 'map65/messages.cpp')
-rwxr-xr-xmap65/messages.cpp151
1 files changed, 146 insertions, 5 deletions
diff --git a/map65/messages.cpp b/map65/messages.cpp
index eacb6335..631e936f 100755
--- a/map65/messages.cpp
+++ b/map65/messages.cpp
@@ -5,6 +5,17 @@
#include "mainwindow.h"
#include "qt_helpers.hpp"
+#include <QCoreApplication> //liveCQ
+#include <QNetworkAccessManager> //liveCQ
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QUrl>
+#include <QUrlQuery>
+#include <QEventLoop>
+
+#include <iostream>
+#include <string>
+
Messages::Messages (QString const& settings_filename, QWidget * parent) :
QDialog {parent},
ui {new Ui::Messages},
@@ -22,6 +33,8 @@ Messages::Messages (QString const& settings_filename, QWidget * parent) :
ui->messagesTextBrowser->clear();
m_cqOnly=false;
m_cqStarOnly=false;
+ QString guiDate;
+ QStringList allDecodes = { "" };
connect (ui->messagesTextBrowser, &DisplayText::selectCallsign, this, &Messages::selectCallsign2);
}
@@ -33,11 +46,126 @@ Messages::~Messages()
delete ui;
}
+void Messages::sendLiveCQData(QStringList decodeList) {
+
+ QSettings settings(m_settings_filename, QSettings::IniFormat);
+ {
+ SettingsGroup g {&settings, "MainWindow"};
+ }
+
+ SettingsGroup g {&settings, "Common"};
+ bool m_w3szUrl = settings.value("w3szUrl",true).toBool();
+ QString m_otherUrl = settings.value("otherUrl","").toString();
+ QString m_myCall=settings.value("MyCall","").toString();
+ QString m_myGrid=settings.value("MyGrid","").toString();
+ bool m_xpol = settings.value("Xpol",false).toBool();
+ QString theDate = guiDate;
+ QString rpol = "--";
+ QString theUrl;
+
+ if(m_w3szUrl) {
+ theUrl = w3szUrlAddr;
+ } else {
+ theUrl = m_otherUrl;
+ }
+
+ QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+ QUrl url(theUrl);
+ QNetworkRequest request(url);
+ request.setRawHeader("User-Agent", "QMAP v0.5");
+ request.setRawHeader("X-Custom-User-Agent", "QMAP v0.5");
+ request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ for (const QString &theLine : decodeList) {
+ QStringList thePostLine = theLine.split(" ",SkipEmptyParts);
+ if((thePostLine.at(5) == "CQ" || thePostLine.at(5) == "QRZ" || thePostLine.at(5) == "CQV" || thePostLine.at(5) == "CQH" || thePostLine.at(5) == "QRT") && m_myCall.length() >=3 && m_myGrid.length()>=4) {
+ if(allDecodes.filter(theLine.mid(0,53)).length() == 0) {
+ allDecodes.append(theLine);
+ QString freq = thePostLine.at(0).trimmed();
+ QString dF = thePostLine.at(1).trimmed();
+ QString utcdatetimestringOriginal = guiDate + " " + thePostLine.at(3).trimmed() + "00"; //needs 2 spaces between date and time
+ 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 dB = thePostLine.at(4).trimmed();
+ QString msgType = thePostLine.at(5).trimmed().toUpper();
+ QString callsign = thePostLine.at(6).trimmed().toUpper();
+ QString grid = "--";
+ QString mode="";
+ QString txpol = " ";
+ QString dT = "";
+ QString modeChar = "";
+ if(thePostLine.at(7).contains(".")) {
+ dT =thePostLine.at(7).trimmed();
+ modeChar = thePostLine.at(8).trimmed();
+ if(modeChar.contains("#")) mode = "JT65" + modeChar.back();
+ else if(modeChar.contains(":")) mode = "Q65-60" + modeChar.back();
+ if(m_xpol) {
+ rpol = thePostLine.at(2).trimmed();
+ } else {
+ rpol = "--";
+ }
+ txpol = "--";
+ } else {
+ grid = thePostLine.at(7).trimmed();
+ dT =thePostLine.at(8).trimmed();
+ modeChar = thePostLine.at(9).trimmed();
+ if(modeChar.contains("#"))
+ {
+ mode = "JT65" + modeChar.back();
+ if (m_xpol) {
+ rpol = thePostLine.at(2).trimmed();
+ if(thePostLine.at(10).contains("H")) txpol = "H";
+ else if(thePostLine.at(10).contains("V")) txpol = "V";
+ } else txpol="--";
+ } else if(modeChar.contains(":")) {
+ mode = "Q65-60" + modeChar.back();
+ if (m_xpol) {
+ rpol = thePostLine.at(2).trimmed();
+ if(thePostLine.at(10).contains("H")) txpol = "H";
+ else if(thePostLine.at(10).contains("V")) txpol = "V";
+ } else txpol="--";
+ }
+ }
+ if(mode.contains("JT65") || mode.contains("Q65")) {
+ QString postString = "skedfreq=" + freq + "&rxfreq=" + dF + "&rpol=" + rpol + "&dt=" + dT + "&dB=" + dB + "&msgtype=" + msgType.toUpper() + "&callsign=" + callsign.toUpper() + "&grid=" + grid.toUpper() + "&mode=" + mode + "&utcdatetime=" + utcdatetimeUTCString + "&spotter=" + m_myCall.toUpper() + "&spottergrid=" + m_myGrid.toUpper() + "&txpol=" + txpol + "&apptype=MAP65";
+ //qDebug() << postString;
+ 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, &Messages::handleReply);
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+ }
+ }
+ // qDebug() << "Size of allDecodes = " << allDecodes.size() ;
+}
+
+void Messages::handleReply()
+{
+ QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
+ if (reply->error() == QNetworkReply::NoError) {
+ qDebug() << reply->readAll();
+ } else {
+ qDebug() << reply->errorString();
+ }
+}
+
void Messages::setText(QString t, QString t2)
{
QString cfreq,cfreq0;
m_t=t;
m_t2=t2;
+ //bool firstTime = true;
+
+ QStringList cqliveText; //liveCQ
+ doLiveCQ = true; //liveCQ
QString s="QTextBrowser{background-color: "+m_colorBackground+"}";
ui->messagesTextBrowser->setStyleSheet(s);
@@ -45,7 +173,7 @@ void Messages::setText(QString t, QString t2)
ui->messagesTextBrowser->clear();
QStringList lines = t.split( "\n", SkipEmptyParts );
foreach( QString line, lines ) {
- QString t1=line.mid(0,50);
+ QString t1=line.mid(0,81); //was 0,75
int ncq=t1.indexOf(" CQ ");
if((m_cqOnly or m_cqStarOnly) and ncq< 0) continue;
if(m_cqStarOnly) {
@@ -55,20 +183,33 @@ void Messages::setText(QString t, QString t2)
int i=t2.indexOf(caller);
if(t2.mid(i-1,1)==" ") continue;
}
- int n=line.mid(50,2).toInt();
+ int n=line.mid(61,2).toInt(); //was 55,2
// if(line.indexOf(":")>0) n=-1;
// if(n==-1) ui->messagesTextBrowser->setTextColor("#ffffff"); // white
if(n==0) ui->messagesTextBrowser->setTextColor(m_color0);
if(n==1) ui->messagesTextBrowser->setTextColor(m_color1);
if(n==2) ui->messagesTextBrowser->setTextColor(m_color2);
if(n>=3) ui->messagesTextBrowser->setTextColor(m_color3);
- cfreq=t1.mid(0,3);
+ QString livecqStr = t1.mid(0,59) + t1.mid(62,t1.length()-62) + " " + t1.mid(60,2); // was 53,56,56,54
+ // QMessageBox msgBox;
+ // msgBox.setText(livecqStr);
+ // if(firstTime) msgBox.exec();
+ // firstTime = false;
+ if(cqliveText.filter(livecqStr.mid(0,59)).length()==0) cqliveText.append(livecqStr); // was 0,53
+ cfreq=t1.mid(5,3);
if(cfreq == cfreq0) {
- t1=" " + t1.mid(3,-1);
+ t1=" " + t1.mid(8,-1);
}
cfreq0=cfreq;
- ui->messagesTextBrowser->append(t1);
+ ui->messagesTextBrowser->append(t1.mid(5,67)); //was 5,61
}
+
+ if(doLiveCQ) { //liveCQ
+ if(cqliveText.size() > 0) { //liveCQ
+ sendLiveCQData(cqliveText); //liveCQ
+ doLiveCQ = false; //liveCQ
+ } //liveCQ
+ } //liveCQ
}
void Messages::selectCallsign2(bool ctrl)