diff options
| author | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2026-10-06 21:24:40 +0100 |
| commit | c25cbdf6fb6d946175f4335fab77bfea601b56db (patch) | |
| tree | 6f7a94b7b81f999e434f61b73d47e337dfd26bf2 /Decoder | |
| parent | 71f5689252c9f13e70e1c24856904475b2307809 (diff) | |
| parent | 0685fcada9f95fe90f70b387cd7d757da8209624 (diff) | |
Merge tag 'debian/3.2.0_rc1+dfsg-2' into debian/trixie-backportsdebian/trixie-backports
tagging wsjtx 3.2.0~rc1+dfsg-2
Diffstat (limited to 'Decoder')
| -rw-r--r-- | Decoder/decodedtext.cpp | 55 | ||||
| -rw-r--r-- | Decoder/decodedtext.h | 9 | ||||
| -rw-r--r-- | Decoder/decodedtext.pri | 3 |
3 files changed, 55 insertions, 12 deletions
diff --git a/Decoder/decodedtext.cpp b/Decoder/decodedtext.cpp index 3c684f82..52780e02 100644 --- a/Decoder/decodedtext.cpp +++ b/Decoder/decodedtext.cpp @@ -7,6 +7,7 @@ extern "C" { bool stdmsg_(char const * msg, fortran_charlen_t); + bool stdmsg72_(char const * msg, bool * is_jt65, fortran_charlen_t); } namespace @@ -44,6 +45,32 @@ namespace )? )" , QRegularExpression::ExtendedPatternSyntaxOption}; + QRegularExpression const ap_suffix_re {R"(^(.*?)(?:\?\s)?[aq][0-9].*$)"}; + QRegularExpression const angle_bracket_re {"[<>]"}; + QRegularExpression const cq_qrz_re {"^(CQ|QRZ)\\s"}; + QRegularExpression const grid_re {R"(^(?!RR73$)[A-R]{2}[0-9]{2}(?:[A-X]{2})?$)"}; +} + +DecodedMessageFields parseDecodedMessage (QString message) +{ + message = message.trimmed ().remove (angle_bracket_re); + if (message.startsWith ("TU; ")) message.remove (0, 4); + auto const match = tokens_re.match (message); + if (!match.hasMatch ()) return {}; + + DecodedMessageFields fields; + fields.destination = match.captured ("word1"); + fields.sender = match.captured ("word2"); + fields.cq = fields.destination == "CQ" || fields.destination == "CQDX" + || fields.destination.startsWith ("CQ "); + for (auto const& name : {"word3", "word4", "word5"}) { + auto const candidate = match.captured (name); + if (grid_re.match (candidate).hasMatch ()) { + fields.grid = candidate; + break; + } + } + return fields; } DecodedText::DecodedText (QString const& the_string) @@ -55,7 +82,7 @@ DecodedText::DecodedText (QString const& the_string) , is_standard_ {false} { // discard appended AP info - clean_string_.replace (QRegularExpression {R"(^(.*?)(?:\?\s)?[aq][0-9].*$)"}, "\\1"); + clean_string_.replace (ap_suffix_re, "\\1"); // qDebug () << "DecodedText: the_string:" << the_string << "Nbsp pos:" << the_string.indexOf (QChar::Nbsp); if (message_.length() >= 1) @@ -63,13 +90,13 @@ DecodedText::DecodedText (QString const& the_string) // remove appended confidence (?) and ap designators before truncating the message message_ = clean_string_.mid (column_qsoText + padding_).trimmed (); message0_ = message_.left(37); - message_ = message_.left(37).remove (QRegularExpression {"[<>]"}); + message_ = message_.left(37).remove (angle_bracket_re); int i1 = message_.indexOf ('\r'); if (i1 > 0) { message_ = message_.left (i1 - 1); } - if (message_.contains (QRegularExpression {"^(CQ|QRZ)\\s"})) + if (message_.contains (cq_qrz_re)) { // TODO this magic position 16 is guaranteed to be after the // last space in a decoded CQ or QRZ message but before any @@ -80,11 +107,18 @@ DecodedText::DecodedText (QString const& the_string) // remove DXCC entity and worked B4 status. TODO need a better way to do this message_ = message_.left (eom_pos + 1); } - // stdmsg is a Fortran routine that packs the text, unpacks it - // and compares the result auto message_c_string = message0_.toLocal8Bit (); message_c_string += QByteArray {37 - message_c_string.size (), ' '}; - is_standard_ = stdmsg_(message_c_string.constData(),37); + auto const mode = string_.mid (column_mode + padding_, 1); + if (mode == "$" || mode == "@" || mode == "#") + { + bool is_jt65 = mode == "#"; + is_standard_ = stdmsg72_(message_c_string.constData(), &is_jt65, 37); + } + else + { + is_standard_ = stdmsg_(message_c_string.constData(), 37); + } } }; @@ -107,8 +141,10 @@ QStringList DecodedText::messageWords () const QString DecodedText::CQersCall() const { - QRegularExpression callsign_re {R"(^(CQ|DE|QRZ)(\s?DX|\s([A-Z]{1,4}|\d{3}))?\s(?<callsign>[A-Z0-9/]{2,})(\s[A-R]{2}[0-9]{2})?)"}; - return callsign_re.match (message_).captured ("callsign"); + auto const fields = parseDecodedMessage (message_); + auto const callType = fields.destination.section (' ', 0, 0); + return callType == "CQ" || callType == "CQDX" || callType == "DE" || callType == "QRZ" + ? fields.sender : QString {}; } @@ -171,6 +207,7 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, / { offset = 2; } + if (w.size () <= offset + 2) return false; if (is_standard_ && (w[offset] == myBaseCall || w[offset].endsWith ("/" + myBaseCall) || w[offset].startsWith (myBaseCall + "/") @@ -205,7 +242,7 @@ bool DecodedText::report(QString const& myBaseCall, QString const& dxBaseCall, / // get the first text word, usually the call QString DecodedText::call() const { - return tokens_re.match (message_).captured ("word1"); + return parseDecodedMessage (message_).destination; } // get the second word, most likely the de call and the third word, most likely grid diff --git a/Decoder/decodedtext.h b/Decoder/decodedtext.h index 1e6706b5..d911c53a 100644 --- a/Decoder/decodedtext.h +++ b/Decoder/decodedtext.h @@ -11,7 +11,15 @@ #include <QString> +struct DecodedMessageFields +{ + QString destination; + QString sender; + QString grid; + bool cq {}; +}; +DecodedMessageFields parseDecodedMessage (QString message); /* 012345678901234567890123456789012345678901 @@ -33,6 +41,7 @@ public: QString string() const { return string_; }; QString clean_string() const { return clean_string_; }; + QString message() const { return message_; }; QStringList messageWords () const; int indexOf(QString s) const { return string_.indexOf(s); }; int indexOf(QString s, int i) const { return string_.indexOf(s,i); }; diff --git a/Decoder/decodedtext.pri b/Decoder/decodedtext.pri deleted file mode 100644 index 6aa33dc3..00000000 --- a/Decoder/decodedtext.pri +++ /dev/null @@ -1,3 +0,0 @@ -SOURCES += Decoder/decodedtext.cpp - -HEADERS += Decoder/decodedtext.h |
