From beec31c9b8ca50ee085441c6b95a7f9eb6786f85 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 3 Oct 2018 21:32:00 -0400 Subject: [PATCH] Extracted function to write messages to log file --- mainwindow.cpp | 34 +++++++++++++++++++--------------- mainwindow.h | 1 + 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 964b743..99d23b1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -9365,6 +9365,8 @@ void MainWindow::processCommandActivity() { QSound::play(wav); } } + + writeDirectedCommandToFile(d); } // and mark the offset as a directed offset so future free text is displayed @@ -9500,21 +9502,6 @@ void MainWindow::processCommandActivity() { // PROCESS BUFFERED MESSAGE else if (d.cmd == "#" && !isAllCall) { - // open file /save/messages/[callsign].txt and append a message log entry... - QFile f(QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + QString("/save/messages/%1.txt").arg(Radio::base_callsign(d.from))); - if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { - QTextStream out(&f); - auto df = dialFrequency(); - auto text = QString("%1\t%2MHz\t%3Hz\t%4dB\t%5"); - text = text.arg(d.utcTimestamp.toString("yyyy-MM-dd hh:mm:ss")); - text = text.arg(Radio::frequency_MHz_string(df)); - text = text.arg(d.freq); - text = text.arg(Varicode::formatSNR(d.snr)); - text = text.arg(d.text); - out << text << endl; - f.close(); - } - reply = QString("%1 ACK").arg(d.from); } @@ -9642,6 +9629,23 @@ void MainWindow::processCommandActivity() { } } +void MainWindow::writeDirectedCommandToFile(CommandDetail d){ + // open file /save/messages/[callsign].txt and append a message log entry... + QFile f(QDir::toNativeSeparators(m_config.writeable_data_dir ().absolutePath()) + QString("/save/messages/%1.txt").arg(Radio::base_callsign(d.from))); + if (f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QTextStream out(&f); + auto df = dialFrequency(); + auto text = QString("%1\t%2MHz\t%3Hz\t%4dB\t%5"); + text = text.arg(d.utcTimestamp.toString("yyyy-MM-dd hh:mm:ss")); + text = text.arg(Radio::frequency_MHz_string(df)); + text = text.arg(d.freq); + text = text.arg(Varicode::formatSNR(d.snr)); + text = text.arg(d.text.isEmpty() ? QString("%1 %2").arg(d.cmd).arg(d.extra).trimmed() : d.text); + out << text << endl; + f.close(); + } +} + void MainWindow::processAlertReplyForCommand(CommandDetail d, QString from, QString cmd){ QMessageBox * msgBox = new QMessageBox(this); msgBox->setIcon(QMessageBox::Information); diff --git a/mainwindow.h b/mainwindow.h index f6de882..5c28350 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -898,6 +898,7 @@ private: void processCompoundActivity(); void processBufferedActivity(); void processCommandActivity(); + void writeDirectedCommandToFile(CommandDetail d); void processAlertReplyForCommand(CommandDetail d, QString from, QString cmd); void processSpots(); void processTxQueue();