fix issue with braces; change type

This commit is contained in:
Brian Moran 2024-09-03 13:18:00 -07:00
commit 869cff683f
5 changed files with 11492 additions and 21 deletions

View File

@ -1,7 +1,7 @@
#include "FoxVerifier.hpp" #include "FoxVerifier.hpp"
#include "Logger.hpp" #include "Logger.hpp"
FoxVerifier::FoxVerifier(QString user_agent, QNetworkAccessManager *manager,QString base_url, QString callsign, QDateTime timestamp, QString code) : QObject(nullptr) FoxVerifier::FoxVerifier(QString user_agent, QNetworkAccessManager *manager,QString base_url, QString callsign, QDateTime timestamp, QString code, unsigned int hz=750) : QObject(nullptr)
{ {
manager_ = manager; manager_ = manager;
finished_ = false; finished_ = false;
@ -9,6 +9,7 @@ FoxVerifier::FoxVerifier(QString user_agent, QNetworkAccessManager *manager,QStr
callsign_ = callsign; callsign_ = callsign;
code_ = code; code_ = code;
ts_ = timestamp; ts_ = timestamp;
hz_ = hz;
QString url = QString("%1/check/%2/%3/%4.text").arg(base_url).arg(callsign).arg(timestamp.toString(Qt::ISODate)).arg(code); QString url = QString("%1/check/%2/%3/%4.text").arg(base_url).arg(callsign).arg(timestamp.toString(Qt::ISODate)).arg(code);
LOG_INFO(QString("FoxVerifier: url %1").arg(url).toStdString()); LOG_INFO(QString("FoxVerifier: url %1").arg(url).toStdString());
@ -72,14 +73,14 @@ void FoxVerifier::httpFinished()
if (reply_->error() != QNetworkReply::NoError) { if (reply_->error() != QNetworkReply::NoError) {
LOG_INFO(QString("FoxVerifier: httpFinished error:[%1 - %2] msg:[%3]").arg(status).arg(reason).arg(reply_->errorString()).toStdString()); LOG_INFO(QString("FoxVerifier: httpFinished error:[%1 - %2] msg:[%3]").arg(status).arg(reason).arg(reply_->errorString()).toStdString());
reply_->abort(); reply_->abort();
emit verifyError(status, ts_, callsign_, code_, reply_->errorString()); emit verifyError(status, ts_, callsign_, code_, hz_, reply_->errorString());
} }
return_value = reply_->read(1024); // limit amount we get return_value = reply_->read(1024); // limit amount we get
LOG_INFO(QString("FoxVerifier: httpFinished status:[%1 - %2] body:[%3] ").arg(status).arg(reason).arg(return_value).toStdString()); LOG_INFO(QString("FoxVerifier: httpFinished status:[%1 - %2] body:[%3] ").arg(status).arg(reason).arg(return_value).toStdString());
finished_ = true; finished_ = true;
reply_->deleteLater(); reply_->deleteLater();
if (status >= 200 && status <= 299) { if (status >= 200 && status <= 299) {
emit verifyComplete(status, ts_, callsign_, code_, return_value); emit verifyComplete(status, ts_, callsign_, code_, hz_, return_value);
} }
} }
@ -97,15 +98,16 @@ void FoxVerifier::httpEncrypted() {
LOG_INFO("FoxVerifier: httpEncrypted"); LOG_INFO("FoxVerifier: httpEncrypted");
} }
QString FoxVerifier::formatDecodeMessage(QDateTime ts, QString callsign, QString const& verify_message) { QString FoxVerifier::formatDecodeMessage(QDateTime ts, QString callsign, unsigned int hz_, QString const& verify_message) {
//"172100 -00 0.0 750 ~ K8R VERIFIED" //"172100 -00 0.0 750 ~ K8R VERIFIED"
QTime rx_time = ts.time(); QTime rx_time = ts.time();
QString hz=QString("%1").arg(hz_, 4, 10 ); // insert Hz
if (verify_message.endsWith(" VERIFIED")) { if (verify_message.endsWith(" VERIFIED")) {
return QString("%1 -00 0.0 750 ~ %2 VERIFIED").arg(rx_time.toString("hhmmss")).arg(callsign); return QString("%1 0 0.0 %2 ~ %3 VERIFIED").arg(rx_time.toString("hhmmss")).arg(hz).arg(callsign);
} else } else
if (verify_message.endsWith(" INVALID")) if (verify_message.endsWith(" INVALID"))
{ {
return QString("%1 0 0.0 750 ~ %2 INVALID").arg(rx_time.toString("hhmmss")).arg(callsign); return QString("%1 0 0.0 %2 ~ %3 INVALID").arg(rx_time.toString("hhmmss")).arg(hz).arg(callsign);
} }
else else
return QString{}; return QString{};

View File

@ -17,12 +17,12 @@ class FoxVerifier : public QObject {
QMutex mutex_; QMutex mutex_;
public: public:
explicit FoxVerifier(QString user_agent, QNetworkAccessManager *manager, QString base_url, QString callsign, QDateTime timestamp, QString code); explicit FoxVerifier(QString user_agent, QNetworkAccessManager *manager, QString base_url, QString callsign, QDateTime timestamp, QString code, unsigned int);
~FoxVerifier(); ~FoxVerifier();
QString return_value; QString return_value;
bool finished(); bool finished();
static QString formatDecodeMessage(QDateTime ts, QString callsign, QString const& verify_message); static QString formatDecodeMessage(QDateTime ts, QString callsign, unsigned int hz, QString const& verify_message);
static QString default_url(); static QString default_url();
private: private:
@ -32,6 +32,7 @@ private:
QUrl q_url_; QUrl q_url_;
bool finished_; bool finished_;
bool errored_; bool errored_;
unsigned int hz_;
QString error_reason_; QString error_reason_;
QDateTime ts_; QDateTime ts_;
QString callsign_; QString callsign_;
@ -55,8 +56,8 @@ private slots:
public slots: public slots:
signals: signals:
void verifyComplete(int status, QDateTime ts, QString callsign, QString code, QString const& response); void verifyComplete(int status, QDateTime ts, QString callsign, QString code, unsigned int hz, QString const& response);
void verifyError(int status, QDateTime ts, QString callsign, QString code, QString const& response); void verifyError(int status, QDateTime ts, QString callsign, QString code, unsigned int hz, QString const& response);
}; };

View File

@ -2494,11 +2494,10 @@ void MainWindow::keyPressEvent (QKeyEvent * e)
QMainWindow::keyPressEvent (e); QMainWindow::keyPressEvent (e);
} }
void MainWindow::handleVerifyMsg(int status, QDateTime ts, QString callsign, QString code, QString const &response) { void MainWindow::handleVerifyMsg(int status, QDateTime ts, QString callsign, QString code, unsigned int hz, QString const &response) { (void)status;
(void)status;
(void)code; (void)code;
if (response.length() > 0) { if (response.length() > 0) {
QString msg = FoxVerifier::formatDecodeMessage(ts, callsign, response); QString msg = FoxVerifier::formatDecodeMessage(ts, callsign, hz, response);
if (msg.length() > 0) { if (msg.length() > 0) {
ui->decodedTextBrowser->displayDecodedText(DecodedText{msg}, m_config.my_callsign(), m_mode, m_config.DXCC(), ui->decodedTextBrowser->displayDecodedText(DecodedText{msg}, m_config.my_callsign(), m_mode, m_config.DXCC(),
m_logBook, m_currentBand, m_config.ppfx()); m_logBook, m_currentBand, m_config.ppfx());
@ -4294,6 +4293,7 @@ void MainWindow::readFromStdout() //readFromStdout
} }
} else { } else {
#ifdef FOX_OTP
// remove verifications that are done // remove verifications that are done
QMutableListIterator < FoxVerifier * > it(m_verifications); QMutableListIterator < FoxVerifier * > it(m_verifications);
while (it.hasNext()) { while (it.hasNext()) {
@ -4301,34 +4301,38 @@ void MainWindow::readFromStdout() //readFromStdout
it.remove(); it.remove();
} }
} }
#endif
DecodedText decodedtext1 = decodedtext0; DecodedText decodedtext1 = decodedtext0;
if ((m_mode == "FT4" or m_mode == "FT8") and bDisplayPoints and decodedtext1.isStandardMessage()) { if ((m_mode == "FT4" or m_mode == "FT8") and bDisplayPoints and decodedtext1.isStandardMessage()) {
ARRL_Digi_Update(decodedtext1); ARRL_Digi_Update(decodedtext1);
} }
#ifdef FOX_OTP
if ((SpecOp::HOUND == m_specOp) && if ((SpecOp::HOUND == m_specOp) &&
((m_config.superFox() && (decodedtext0.mid(24, 8) == "$VERIFY$")) || // $VERIFY$ K8R 920749 ((m_config.superFox() && (decodedtext0.mid(24, 8) == "$VERIFY$")) || // $VERIFY$ K8R 920749
(decodedtext0.mid(24, 8).contains(QRegularExpression{"^[A-Z0-9]{2,5}\\.V[0-9]{6}$"})))) // K8R.V920749 (decodedtext0.mid(24,-1).contains(QRegularExpression{"^[A-Z0-9]{2,5}\\.V[0-9]{6}"})))) // K8R.V920749
{ {
// two cases: // two cases:
// QString test_return = QString{"203630 -12 0.1 775 ~ K8R.V920749"}; // QString test_return = QString{"203630 -12 0.1 775 ~ K8R.V920749"};
// $VERIFY$ foxcall otp // $VERIFY$ foxcall otp
// QString test_return = QString{"203630 -12 0.1 775 ~ $VERIFY$ K8R 920749"}; // QString test_return = QString{"203630 -12 0.1 775 ~ $VERIFY$ K8R 920749"};
QStringList lineparts; QStringList lineparts;
QStringList otp_parts;
QString callsign, otp; QString callsign, otp;
unsigned int hz;
lineparts = decodedtext0.string().split(' ', SkipEmptyParts); lineparts = decodedtext0.string().split(' ', SkipEmptyParts);
if (lineparts.length() <= 6) { if (lineparts.length() <= 6) {
QStringList otp_parts;
// split K8R.V920749 into K8R and 920749 // split K8R.V920749 into K8R and 920749
otp_parts = lineparts[5].split('.', SkipEmptyParts); otp_parts = lineparts[5].split('.', SkipEmptyParts);
callsign = otp_parts[0]; callsign = otp_parts[0];
otp = otp_parts[1].mid(1); // remove the V otp = otp_parts[1].mid(1); // remove the V
hz = lineparts[3].toInt();
} else } else
{ {
// split $VERIFY$ K8R 920749 into K8R and 920749 // split $VERIFY$ K8R 920749 into K8R and 920749
callsign = lineparts[6]; callsign = lineparts[6];
otp = lineparts[7]; otp = lineparts[7];
hz = 750; // SF is 750
} }
QDateTime verifyDateTime; QDateTime verifyDateTime;
if (m_diskData) { if (m_diskData) {
@ -4342,11 +4346,13 @@ void MainWindow::readFromStdout() //readFromStdout
FOXVERIFIER_DEFAULT_BASE_URL, FOXVERIFIER_DEFAULT_BASE_URL,
callsign, // foxcall callsign, // foxcall
verifyDateTime, verifyDateTime,
otp); // otp otp,
hz); // freq
connect(fv, &FoxVerifier::verifyComplete, this, &MainWindow::handleVerifyMsg); connect(fv, &FoxVerifier::verifyComplete, this, &MainWindow::handleVerifyMsg);
m_verifications << fv; m_verifications << fv;
} else { }
#endif
{
if (ui->labDXped->text() == "Super Hound" && decodedtext0.mid(3, 18).contains(" verified")) { if (ui->labDXped->text() == "Super Hound" && decodedtext0.mid(3, 18).contains(" verified")) {
verified = true; verified = true;
write_all("Vf",decodedtext0.string()); write_all("Vf",decodedtext0.string());
@ -10202,7 +10208,7 @@ void MainWindow::on_comboBoxHoundSort_activated(int index)
{ {
if(index!=-99) houndCallers(); //Silence compiler warning if(index!=-99) houndCallers(); //Silence compiler warning
} }
#ifdef FOX_OTP
QString MainWindow::foxOTPcode() QString MainWindow::foxOTPcode()
{ {
QString code; QString code;
@ -10229,6 +10235,7 @@ QString MainWindow::foxOTPcode()
} }
return code; return code;
} }
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB) QString MainWindow::sortHoundCalls(QString t, int isort, int max_dB)
@ -10603,6 +10610,7 @@ void MainWindow::foxTxSequencer()
goto Transmit; goto Transmit;
} }
#ifdef FOX_OTP
// Send OTP message maybe for regular fox mode // Send OTP message maybe for regular fox mode
if (!m_config.superFox() && m_config.OTPEnabled() && (islot < m_Nslots) && (m_tFoxTxSinceOTP >= m_config.OTPinterval())) if (!m_config.superFox() && m_config.OTPEnabled() && (islot < m_Nslots) && (m_tFoxTxSinceOTP >= m_config.OTPinterval()))
{ {
@ -10613,6 +10621,7 @@ void MainWindow::foxTxSequencer()
islot++; islot++;
foxGenWaveform(islot - 1, fm); foxGenWaveform(islot - 1, fm);
} }
#endif
//Compile list1: up to NSLots Hound calls to be sent RR73 //Compile list1: up to NSLots Hound calls to be sent RR73
for(QString hc: m_foxQSO.keys()) { //Check all Hound calls: First priority for(QString hc: m_foxQSO.keys()) { //Check all Hound calls: First priority

11459
widgets/mainwindow.cppNEW Normal file

File diff suppressed because it is too large Load Diff

View File

@ -896,7 +896,7 @@ private:
void read_log(); void read_log();
void refreshPileupList(); void refreshPileupList();
QString userAgent(); QString userAgent();
void handleVerifyMsg(int status, QDateTime ts, QString callsign, QString code, QString const &response); void handleVerifyMsg(int status, QDateTime ts, QString callsign, QString code, unsigned int hz, QString const &response);
void writeFoxTxMsgs(); void writeFoxTxMsgs();
QString foxOTPcode(); QString foxOTPcode();
}; };