JS8Call-Improved master
Loading...
Searching...
No Matches
mainwindow.h
1// -*- Mode: C++ -*-
2#ifndef MAINWINDOW_H
3#define MAINWINDOW_H
4
10#include "JS8_Include/commons.h"
11#include "JS8_Include/qpriorityqueue.h"
12#include "JS8_JSC/JSC_checker.h"
13#include "JS8_Logbook/LogBook.h"
17#include "JS8_Main/Bands.h"
18#include "JS8_Main/CallDetail.h"
19#include "JS8_Main/DirectedMessageHighlighter.h"
20#include "JS8_Main/DriftingDateTime.h"
21#include "JS8_Main/FrequencyList.h"
22#include "JS8_Main/Geodesic.h"
23#include "JS8_Main/HBBlockingDB.h"
24#include "JS8_Main/HelpTextWindow.h"
25#include "JS8_Main/Inbox.h"
26#include "JS8_Main/JS8MessageBox.h"
27#include "JS8_Main/MessageClient.h"
28#include "JS8_Main/MessageServer.h"
29#include "JS8_Main/Modes.h"
30#include "JS8_Main/MultiSettings.h"
32#include "JS8_Main/ProcessThread.h"
33#include "JS8_Main/Radio.h"
34#include "JS8_Main/SelfDestructMessageBox.h"
35#include "JS8_Main/SignalMeter.h"
36#include "JS8_Main/StationList.h"
37#include "JS8_Main/TxLoop.h"
38#include "JS8_Main/Varicode.h"
39#include "JS8_Main/qt_helpers.h"
40#include "JS8_Main/revision_utils.h"
42#include "JS8_Mode/Decoder.h"
43#include "JS8_Mode/Detector.h"
44#include "JS8_Mode/JS8.h"
45#include "JS8_Mode/JS8Submode.h"
46#include "JS8_Mode/Modulator.h"
51#include "JS8_Transceiver/Transceiver.h"
52#include "JS8_Transceiver/TransceiverFactory.h"
55#include "JS8_UI/About.h"
56#include "JS8_UI/Configuration.h"
57#include "JS8_UI/WideGraph.h"
58#include "JS8_UI/MessagePanel.h"
59#include "LogQSO.h"
60#include "MessageReplyDialog.h"
61#include "styles.h"
62#include "ui_mainwindow.h"
63
64#include <QAbstractSocket>
65#include <QAction>
66#include <QActionGroup>
67#include <QApplication>
68#include <QAudioDevice>
69#include <QByteArrayView>
70#include <QCursor>
71#include <QDateTime>
72#include <QDesktopServices>
73#include <QDir>
74#include <QDockWidget>
75#include <QElapsedTimer>
76#include <QFileDialog>
77#include <QHash>
78#include <QHostAddress>
79#include <QHostInfo>
80#include <QInputDialog>
81#include <QLabel>
82#include <QLineEdit>
83#include <QList>
84#include <QLoggingCategory>
85#include <QMainWindow>
86#include <QMdiSubWindow>
87#include <QMutex>
88#include <QMutexLocker>
89#include <QNetworkAccessManager>
90#include <QNetworkReply>
91#include <QNetworkRequest>
92#include <QPair>
93#include <QPixmap>
94#include <QPointer>
95#include <QProgressDialog>
96#include <QRegularExpression>
97#include <QRegularExpressionValidator>
98#include <QScopedPointer>
99#include <QScrollBar>
100#include <QSet>
101#include <QSoundEffect>
102#include <QStandardPaths>
103#include <QStatusBar>
104#include <QStringBuilder>
105#include <QStyleFactory>
106#include <QtCore/QtGlobal>
107#include <QTableWidget>
108#include <QTextEdit>
109#include <QThread>
110#include <QTime>
111#include <QTimeZone>
112#include <QTimer>
113#include <QToolButton>
114#include <QPushButton>
115#include <QMenu>
116#include <QToolTip>
117#include <QUdpSocket>
118#include <QUrl>
119#include <QVariant>
120#include <QVector>
121#include <QVersionNumber>
122#include <QtConcurrent/QtConcurrentRun>
123#include <QtGui>
124#include <boost/crc.hpp>
125#include <fftw3.h>
126
127#include <algorithm>
128#include <array>
129#include <cmath>
130#include <complex>
131#include <cstring>
132#include <functional>
133#include <iterator>
134#include <memory>
135#include <mutex>
136#include <stdexcept>
137#include <string_view>
138#include <unordered_map>
139#include <vector>
140
141#if QT_VERSION < QT_VERSION_CHECK(6,12,0)
142#error "Qt >= 6.12.0 is required to build JS8Call. Please upgrade your Qt toolchain."
143#endif
144
145Q_DECLARE_LOGGING_CATEGORY(mainwindow_js8)
146
147extern int volatile itone[JS8_NUM_SYMBOLS]; // Audio tones for all Tx symbols
148
149//--------------------------------------------------------------- mainwindow
150// How often to poll the UI, in MS.
151// Some things may depend on this being a divisor of 1000.
152constexpr quint32 UI_POLL_INTERVAL_MS = 100;
153
154namespace {
155namespace Default {
156constexpr Radio::Frequency DIAL_FREQUENCY = 14078000;
157constexpr auto FREQUENCY = 1500;
158constexpr auto SUBMODE = Varicode::JS8CallNormal;
159} // namespace Default
160
161namespace State {
162constexpr auto RX = 1;
163constexpr auto TX = 2;
164} // namespace State
165} // namespace
166
167namespace Ui {
168class UI_Constructor;
169}
170
171class QSettings;
172class QLineEdit;
173class QFont;
174class QHostInfo;
175class WideGraph;
176class LogQSO;
177class Transceiver;
178class MessageClient;
179class QTime;
180class HelpTextWindow;
181class SoundOutput;
182class Modulator;
183class SoundInput;
184class Detector;
185class AprsInboundRelay;
186class MultiSettings;
187class DecodedText;
188class JSCChecker;
189class MessagePanel;
190
191using namespace std;
192typedef std::function<void()> Callback;
193
194class WSJTXMessageMapper; // Forward declaration
195
196class UI_Constructor : public QMainWindow {
197 Q_OBJECT;
198 friend class WSJTXMessageMapper; // Allow WSJTXMessageMapper to access
199 // private members
200
201 // Defined in JS8_Main/CallDetail.h so the activity storage layer can
202 // convert to and from it without including this header.
203 using CallDetail = ::CallDetail;
204 struct CommandDetail;
205
206 public:
207 using Frequency = Radio::Frequency;
208 using FrequencyDelta = Radio::FrequencyDelta;
209 using Mode = Modes::Mode;
210
211 explicit UI_Constructor(QString const &program_info,
212 QDir const &temp_directory, bool multiple,
213 MultiSettings *settings, QWidget *parent = nullptr);
215
216 private:
217 struct SortByReverse {
218 QString by;
219 bool reverse;
220 };
221
232 bool m_stopTxButtonIsLongterm;
233 bool m_hbButtonIsLongterm;
234 bool m_cqButtonIsLongterm;
235
236 public slots:
237 void showSoundInError(const QString &errorMsg);
238 void showSoundOutError(const QString &errorMsg);
239 void dataSink(qint64 frames); // JS8_Mainwindow/dataSink.cpp
245 void guiUpdate();
246 void setXIT(int n);
247 void qsy(int hzDelta);
248 void onDriftChanged(qint64 new_drift_ms);
249 bool tryRestoreFreqOffset();
250 void changeFreq(int);
251
252 bool hasExistingMessageBufferToMe(int *pOffset);
253 bool hasExistingMessageBuffer(int submode, int offset, bool drift,
254 int *pPrevOffset);
255 void logCallActivity(CallDetail d, bool spot = true);
256 void logHeardGraph(QString from, QString to);
257 QString lookupCallInCompoundCache(QString const &call);
258 void cacheActivity(QString key);
259 void restoreActivity(QString key);
260 void clearActivity();
261 void clearBandActivity();
262 void clearRXActivity();
263 void clearCallActivity();
264 void createGroupCallsignTableRows(QTableWidget *table,
265 const QString &selectedCall,
266 bool &showIconColumn);
267 void displayTextForFreq(QString text, int freq, QDateTime date, bool isTx,
268 bool isNewLine, bool isLast);
269 void writeNoticeTextToUI(QDateTime date, QString text);
270 int writeMessageTextToUI(QDateTime date, QString text, int freq, bool isTx,
271 int block = -1);
272 bool isMessageQueuedForTransmit();
273 bool isInDecodeDelayThreshold(int seconds);
274 void prependMessageText(QString text);
275 void addMessageText(QString text, bool clear = false,
276 bool selectFirstPlaceholder = false);
277 void confirmThenEnqueueMessage(int timeout, int priority, QString message,
278 int offset, Callback c); // JS8_Mainwindow/confirmThenEnqueueMessage.cpp
279 void enqueueMessage(int priority, QString message, int offset, Callback c);
280 void resetMessage();
281 void resetMessageUI();
282 void restoreMessage();
283 void initializeDummyData(); // JS8_Mainwindow/initializeDummyData.cpp
284 void initializeGroupMessage(); // JS8_Mainwindow/initializeGroupMessage.cpp
285 bool ensureCallsignSet(bool alert = true);
286 bool ensureKeyNotStuck(QString const &text);
287 bool ensureNotIdle();
288 bool ensureCanTransmit();
289 bool ensureCreateMessageReady(const QString &text);
290 QString createMessage(QString const &text, bool *pDisableTypeahead);
291 QString appendMessage(QString const &text, bool isData,
292 bool *pDisableTypeahead);
293 QString createMessageTransmitQueue(QString const &text, bool reset,
294 bool isData, bool *pDisableTypeahead);
296 QPair<QString, int> popMessageFrame();
297 void tryNotify(const QString &key);
298 void processDecodeEvent(JS8::Event::Variant const &); // JS8_Mainwindow/processDecodeEvent.cpp
299
300 void updateCQButtonDisplay();
301 void updateHBButtonDisplay();
302
303 protected:
304 void keyPressEvent(QKeyEvent *) override;
305 void closeEvent(QCloseEvent *) override;
306 void childEvent(QChildEvent *) override;
307 bool eventFilter(QObject *, QEvent *) override;
308 void resizeEvent(QResizeEvent *) override;
309
310 private slots:
311 void initialize_fonts();
312 void on_menuModeJS8_aboutToShow();
313 void on_menuControl_aboutToShow();
314 void on_actionCheck_for_Updates_triggered();
315 void on_actionEnable_Monitor_RX_toggled(bool checked);
316 void on_actionEnable_Transmitter_TX_toggled(bool checked);
317 void on_actionEnable_Reporting_SPOT_toggled(bool checked);
318 void on_actionEnable_Tuning_Tone_TUNE_toggled(bool checked);
319 void on_menuWindow_aboutToShow();
320 void on_actionFocus_Message_Receive_Area_triggered();
321 void on_actionFocus_Message_Reply_Area_triggered();
322 void on_actionFocus_Band_Activity_Table_triggered();
323 void on_actionFocus_Call_Activity_Table_triggered();
324 void on_actionClear_All_Activity_triggered();
325 void on_actionClear_Band_Activity_triggered();
326 void on_actionClear_RX_Activity_triggered();
327 void on_actionClear_Call_Activity_triggered();
328 void on_actionSetOffset_triggered();
329 void on_actionShow_Fullscreen_triggered(bool checked);
330 void on_actionShow_Band_Activity_triggered(bool checked);
331 void on_actionShow_Band_Heartbeats_and_ACKs_triggered(bool checked);
332 void on_actionShow_Call_Activity_triggered(bool checked);
333 void on_actionShow_Waterfall_triggered(bool checked);
334 void on_actionShow_Waterfall_Controls_triggered(bool checked);
335 void on_actionShow_Waterfall_Time_Drift_Controls_triggered(bool checked);
336 void on_actionReset_Window_Sizes_triggered();
337 void on_actionSettings_triggered();
338 void openSettings(int tab = 0);
339 void prepareApi();
340 void prepareSpotting();
341 void handleSpotButton_clicked(bool checked);
342 void handleMonitorButton_clicked(bool);
343 void on_actionAbout_triggered();
344 void resetPushButtonToggleText(QPushButton *btn);
345 void on_stopTxButton_clicked();
346 void on_dialFreqUpButton_clicked();
347 void on_dialFreqDownButton_clicked();
348 void on_actionAdd_Log_Entry_triggered();
349 void on_actionOpen_log_directory_triggered();
350 void on_actionCopyright_Notice_triggered();
351 void on_actionUser_Guide_triggered();
352 bool decode(qint32 k);
354 void publishDecodePressure(qint32 k);
355 bool isDecodeReady(int submode, qint32 k, qint32 k0,
356 qint32 *pCurrentDecodeStart, qint32 *pNextDecodeStart,
357 qint32 *pStart, qint32 *pSz, qint32 *pCycle);
358 bool decodeEnqueueReady(qint32 k, qint32 k0);
359 bool decodeEnqueueReadyExperiment(qint32 k, qint32 k0);
360 bool decodeProcessQueue(qint32 *pSubmode);
361 void decodeStart();
362 void decodeBusy(bool b);
363 void decodeDone();
364 void handleLogQSOButton_clicked();
365 void on_actionModeJS8HB_toggled(bool checked);
366 void on_actionModeJS8Normal_triggered();
367 void on_actionModeJS8Fast_triggered();
368 void on_actionModeJS8Turbo_triggered();
369 void on_actionModeJS8Slow_triggered();
370 void on_actionModeJS8Ultra_triggered();
371 void on_actionHeartbeatAcknowledgements_toggled(bool checked);
372 void on_actionModeAutoreply_toggled(bool checked);
373 bool canCurrentModeSendHeartbeat() const;
374 void prepareMonitorControls();
375 void prepareHeartbeatMode(bool enabled);
376 void f11f12(int n);
377 void on_actionErase_ALL_TXT_triggered();
378 void on_actionErase_js8call_log_adi_triggered();
379 void startTx();
380 void stopTx();
381 void stopTx2();
382 void buildFrequencyMenu(QMenu *menu);
383 void buildHeartbeatMenu(QMenu *menu);
384 void buildCQMenu(QMenu *menu);
385 void buildRepeatMenu(QMenu *menu, QPushButton *button, bool isLowInterval,
386 int *interval);
387 void sendHB();
388 void sendHeartbeatAck(QString to, int snr, QString extra);
389 void on_hbMacroButton_toggled(bool checked);
390 void on_hbMacroButton_clicked();
391 void sendCQ(bool repeat = false);
392 void on_cqMacroButton_toggled(bool checked);
393 void on_cqMacroButton_clicked();
394 void on_replyMacroButton_clicked();
395 void on_snrMacroButton_clicked();
396 void on_infoMacroButton_clicked();
397 void on_statusMacroButton_clicked();
398 void setShowColumn(QString tableKey, QString columnKey, bool value);
399 bool showColumn(QString tableKey, QString columnKey, bool default_ = true);
400 void buildShowColumnsMenu(QMenu *menu, QString tableKey);
401 void setSortBy(QString key, QString value);
402 QString getSortBy(QString const &key, QString const &defaultValue) const;
403 SortByReverse getSortByReverse(QString const &key,
404 QString const &defaultValue) const;
405 void buildSortByMenu(QMenu *menu, QString key, QString defaultValue,
406 QList<QPair<QString, QString>> values);
407 void buildBandActivitySortByMenu(QMenu *menu);
408 void buildCallActivitySortByMenu(QMenu *menu);
409 void buildQueryMenu(QMenu *, QString callsign); // JS8_Mainwindow/buildQueryMenu.cpp
410 QMap<QString, QString> buildMacroValues();
411 void buildColumnLabelMap();
412 void buildSuggestionsMenu(QMenu *menu, QTextEdit *edit,
413 const QPoint &point);
414 void buildSavedMessagesMenu(QMenu *menu);
415 void buildRelayMenu(QMenu *menu);
416 QAction *buildRelayAction(QString call);
417 void buildEditMenu(QMenu *, QTextEdit *);
418 void on_queryButton_pressed();
419 void on_macrosMacroButton_pressed();
420 void on_deselectButton_pressed();
421 void on_tableWidgetRXAll_cellClicked(int row, int col);
422 void on_tableWidgetRXAll_cellDoubleClicked(int row, int col);
423 QString generateCallDetail(QString selectedCall);
424 void on_tableWidgetCalls_cellClicked(int row, int col);
425 void on_tableWidgetCalls_cellDoubleClicked(int row, int col);
426 QList<QPair<QString, int>> buildMessageFrames(QString const &text,
427 bool isData,
428 bool *pDisableTypeahead);
429 bool prepareNextMessageFrame();
430 bool isFreqOffsetFree(int f, int bw);
431 int findFreeFreqOffset(int fmin, int fmax, int bw);
432 void setDrift(int n);
433 void handleTuneButton_clicked(bool);
434 void acceptQSO(QDateTime const &, QString const &call, QString const &grid,
435 Frequency dial_freq, QString const &mode,
436 QString const &submode, QString const &rpt_sent,
437 QString const &rpt_received, QString const &comments,
438 QString const &name, QDateTime const &QSO_date_on,
439 QString const &operator_call, QString const &my_call,
440 QString const &my_grid, QByteArray const &ADIF,
441 QVariantMap const &additionalFields);
442 void on_readFreq_clicked();
443 void on_outAttenuation_valueChanged(int);
444 void rigOpen();
445 void handle_transceiver_update(Transceiver::TransceiverState const &);
446 void handle_transceiver_failure(QString const &reason);
447 void band_changed();
448 void monitor(bool);
449 void end_tuning();
450 void stop_tuning();
451 void stopTuneATU();
452 void auto_tx_mode(bool);
453 void handleMonitorButton_toggled(bool checked);
454 void handleMonitorTxButton_toggled(bool checked);
455 void handleTuneButton_toggled(bool checked);
456 void handleSpotButton_toggled(bool checked);
457
458 void emitPTT(bool on);
459 void emitTones();
460 void udpNetworkMessage(Message const &message);
461 void tcpNetworkMessage(Message const &message);
462 void networkMessage(Message const &message, bool internal = false); // JS8_Mainwindow/networkMessage.cpp
463 bool canSendNetworkMessage();
464 void sendNetworkMessage(QString const &type, QString const &message);
465 void sendNetworkMessage(QString const &type, QString const &message,
466 const QVariantMap &params);
467 void pskReporterError(QString const &);
468 void TxAgain();
469 void checkVersion(bool alertOnUpToDate); // JS8_Mainwindow/checkVersion.cpp
470 void checkStartupWarnings();
471 void clearCallsignSelected();
472 void refreshTextDisplay();
473
474 void manualBandHop(const StationList::Station station);
475
476 private:
477 Q_SIGNAL void apiSetMaxConnections(int n);
478 Q_SIGNAL void apiSetServer(QString host, quint16 port);
479 Q_SIGNAL void apiStartServer();
480 Q_SIGNAL void apiStopServer();
481
482 Q_SIGNAL void aprsClientEnqueueSpot(QString by_call, QString from_call,
483 QString grid, QString comment);
484 Q_SIGNAL void aprsClientEnqueueThirdParty(QString by_call,
485 QString from_call, QString text);
492 Q_SIGNAL void aprsClientEnqueueAck(QString from_call, QString to_call,
493 QString messageId);
494 Q_SIGNAL void aprsClientSetSkipPercent(float skipPercent);
495 Q_SIGNAL void aprsClientSetIncomingRelayEnabled(bool enabled);
496 Q_SIGNAL void aprsClientSetServer(QString host, quint16 port);
497 Q_SIGNAL void aprsClientSetPaused(bool paused);
498 Q_SIGNAL void aprsClientSetLocalStation(QString mycall, QString passcode);
499 Q_SIGNAL void aprsClientSendReports();
500
501 Q_SIGNAL void pskReporterSendReport(bool);
502 Q_SIGNAL void pskReporterSetLocalStation(QString, QString, QString);
503 Q_SIGNAL void pskReporterAddRemoteStation(QString, QString,
504 Radio::Frequency, QString, int,
505 QDateTime);
506
507 Q_SIGNAL void spotClientSetLocalStation(QString, QString, QString);
508 Q_SIGNAL void spotClientEnqueueCmd(QString, QString, QString, QString,
509 QString, QString, QString, int, Frequency, int,
510 int);
511 Q_SIGNAL void spotClientEnqueueSpot(QString, QString, int, Frequency, int, int);
512
513 Q_SIGNAL void decodedLineReady(QByteArray t);
514 Q_SIGNAL void playNotification(const QString &name);
515 Q_SIGNAL void initializeNotificationAudioOutputStream(const QAudioDevice &,
516 unsigned) const;
517 Q_SIGNAL void initializeAudioOutputStream(QAudioDevice, unsigned channels,
518 unsigned msBuffered) const;
519 Q_SIGNAL void stopAudioOutputStream() const;
520 Q_SIGNAL void startAudioInputStream(QAudioDevice const &,
521 int framesPerBuffer, AudioDevice *sink,
523 Q_SIGNAL void suspendAudioInputStream() const;
524 Q_SIGNAL void resumeAudioInputStream() const;
525 Q_SIGNAL void startDetector(AudioDevice::Channel) const;
526 Q_SIGNAL void FFTSize(unsigned) const;
527 Q_SIGNAL void detectorClose() const;
528 Q_SIGNAL void finished() const;
529 Q_SIGNAL void transmitFrequency(double) const;
530 Q_SIGNAL void endTransmitMessage(bool quick = false) const;
531 Q_SIGNAL void tune(bool = true) const;
532 Q_SIGNAL void sendMessage(double frequency, int submode, double txDelay,
534 Q_SIGNAL void outAttenuationChanged(qreal) const;
535 Q_SIGNAL void toggleShorthand() const;
536 Q_SIGNAL void submodeChanged(Varicode::SubmodeType) const;
537
538 Q_SIGNAL void messageAdded(int) const;
539
540 private:
541 QByteArray wisdomFileName() const;
542
543 void writeAllTxt(QStringView message);
544 void writeMsgTxt(QStringView message, int snr, int offset);
545
546 void currentTextChanged();
547 void tableSelectionChanged(QItemSelection const &, QItemSelection const &);
548 void setupJS8();
549 void applyPillSettings();
550
551 int freq() const { return m_freq; }
552
554 void refuseToSendIn30mWSPRBand();
555
556 void prepareSending(qint64 nowMS);
557
559 void updateClockUI(const QDateTime &);
560
561 void setFreq(int);
562 void transmit();
563
564 bool canEnableHBReplies();
565 bool presentlyWantHBReplies();
566
567 QString m_nextFreeTextMsg;
568
569 NetworkAccessManager m_network_manager;
570 bool m_valid;
571 [[maybe_unused]] bool m_multiple; // Used only in Windows builds
572 MultiSettings *m_multi_settings;
573 QPushButton *m_configurations_button;
574 QSettings *m_settings;
575 bool m_settings_read;
576 QScopedPointer<Ui::UI_Constructor> ui;
577
578 // other windows
579 Configuration m_config;
580 JS8MessageBox m_rigErrorMessageBox;
581
582 QDockWidget* messageDock_ = nullptr;
583 MessagePanel* messagePanel_ = nullptr;
584 QDialog* messageFloatDialog_ = nullptr;
585 QLineEdit* m_inboxFilterEdit_ = nullptr;
586
587 enum class MessageHost { Dock, Dialog };
588 MessageHost messageHost_ = MessageHost::Dock;
589
590 QScopedPointer<WideGraph> m_wideGraph;
591 QScopedPointer<LogQSO> m_logDlg;
592 QScopedPointer<HelpTextWindow> m_shortcuts;
593 QScopedPointer<HelpTextWindow> m_prefixes;
594 QScopedPointer<HelpTextWindow> m_mouseCmnds;
595
597 Frequency m_lastDialFreq;
598 QString m_lastBand;
599
600 // Per-band persistent activity storage (activity.db3) - issue #267.
601 // Everything above ActivityDB lives in the controller; the window
602 // keeps only this pointer and thin delegating calls.
603 std::unique_ptr<ActivityStorageController> m_activityStorage;
604
605 Detector *m_detector;
606 unsigned m_FFTSize;
607 SoundInput *m_soundInput;
608 Modulator *m_modulator;
609 SoundOutput *m_soundOutput;
610 NotificationAudio *m_notification;
611
612 // Configuration might one day offer to send a txDelayChanged signal.
613 // As long as it doesn't, we poll and compare with the previous value.
614 double m_TxDelay; // in seconds.
615
616 TxLoop *m_cq_loop;
617 TxLoop *m_hb_loop;
618
619 QThread m_networkThread;
620 QThread m_audioThread;
621 QThread m_notificationAudioThread;
622 JS8::Decoder m_decoder;
623
624 qint64 m_secBandChanged;
625
626 Frequency m_freqNominal;
627 Frequency m_freqTxNominal;
628
629 int m_freq;
630
631 qint32 m_XIT;
632 qint32 m_sec0;
633 qint32 m_RxLog;
634 qint32 m_nutc0;
635 // The period of the current submode, in seconds. (15 for normal, 10 for
636 // fast, ...)
637 qint32 m_TRperiod;
638 qint32 m_inGain;
639 qint32 m_idleMinutes;
640 qint32 m_nSubMode;
641 FrequencyList_v3::const_iterator m_frequency_list_fcal_iter;
642 qint32 m_i3bit;
643
644 bool m_btxok; // True if OK to transmit
645 bool m_decoderBusy;
646 QString m_decoderBusyBand;
647 QMap<qint32, qint32>
648 m_lastDecodeStartMap; // submode, decode k start position
649 QMap<qint32, qint32>
650 m_lastDecodeCycleMap; // JS8 40 & JS8 60 submodes, last enqueued cycle start
651 Radio::Frequency m_decoderBusyFreq;
652 QDateTime m_decoderBusyStartTime;
653 bool m_auto;
654 bool m_restart;
655 bool m_bDecoded;
656 int m_currentMessageType;
657 QString m_currentMessage;
658 int m_currentMessageBits;
659 int m_lastMessageType;
660 QString m_lastMessageSent;
661 bool m_tuneup;
662 bool m_isTimeToSend;
663
664 int m_ihsym;
665 float m_px;
666 float m_pxmax;
667 float m_df3;
668 quint32 m_iptt = 0;
669 quint32 m_iptt0;
670 bool m_btxok0;
671 double m_onAirFreq0;
672 bool m_first_error;
673
674 char m_msg[100][80];
675
676 QMenu *modeSpeedMenu = nullptr;
677
678 Styles::OffsetSliderWidget *freqOffsetWidget = nullptr;
679 int m_sliderFreqBeforeHB = 0;
680
681 QTimer m_guiTimer;
682 // Timer to switch off PTT after end of transmission.
683 QTimer pttReleaseTimer;
684 QTimer logQSOTimer;
685 QTimer tuneButtonTimer;
686 QTimer tuneATU_Timer;
687 QTimer TxAgainTimer;
688 QTimer minuteTimer;
689 QTimer m_msgNotifyTimer;
690 QString m_baseCall;
691 QString m_hisCall;
692 QString m_hisGrid;
693 QString m_appDir;
694 QString m_palette;
695 QString m_rptSent;
696 QString m_rptRcvd;
697 QString m_msgSent0;
698 QString m_opCall;
699
700 struct CommandDetail {
701 bool isCompound;
702 bool isBuffered;
703 QString from;
704 QString to;
705 QString cmd;
706 Frequency dial;
707 int offset;
708 QDateTime utcTimestamp;
709 int snr;
710 int bits;
711 QString grid;
712 QString text;
713 QString extra;
714 float tdrift;
715 int submode;
716 QString relayPath;
717 };
718
719 struct ActivityDetail {
720 bool isLowConfidence;
721 bool isCompound;
722 bool isDirected;
723 bool isBuffered;
724 int bits;
725 Frequency dial;
726 int offset;
727 QString text;
728 QDateTime utcTimestamp;
729 int snr;
730 bool shouldDisplay;
731 float tdrift;
732 int submode;
733 };
734
735 struct MessageBuffer {
736 CommandDetail cmd;
737 QQueue<CallDetail> compound;
739 };
740
741 QString m_prevSelectedCallsign;
742 int m_bandActivityWidth;
743 int m_callActivityWidth;
744 int m_textActivityWidth;
745 int m_waterfallHeight;
746 bool m_bandActivityWasVisible;
747 bool m_rxDirty;
748 bool m_rxDisplayDirty;
749 int m_txFrameCountEstimate;
750 int m_txFrameCount;
751 int m_txFrameCountSent;
752 bool m_txEventStarted = false;
753 QTimer m_txTextDirtyDebounce;
754 bool m_txTextDirty;
755 QString m_txTextDirtyLastText;
756 QString m_txTextDirtyLastSelectedCall;
757 QString m_lastTxMessage;
758 QString m_totalTxMessage;
759
760 // moved from mainwindow.cpp, is used in multiple functions
761 QString since(QDateTime const &time) {
762 auto const delta = time.secsTo(DriftingDateTime::currentDateTimeUtc());
763
764 if (delta >= 60 * 60 * 24)
765 return QString("%1d").arg(delta / (60 * 60 * 24));
766 else if (delta >= 60 * 60)
767 return QString("%1h").arg(delta / (60 * 60));
768 else if (delta >= 60)
769 return QString("%1m").arg(delta / (60));
770 else if (delta >= 15)
771 return QString("%1s").arg(delta - (delta % 15));
772 else
773 return QString("now");
774 }
775
776 QDateTime m_lastTxStartTime;
777 QDateTime m_lastTxStopTime;
778 qint32 m_driftMsMMA;
779 qint32 m_driftMsMMA_N;
780
781 // moved from mainwindow.cpp, is used in multiple functions
782 auto replaceMacros(QString const &text,
783 QMap<QString, QString> const &values, bool const prune) {
784 QString output = text;
785
786 for (auto const [key, value] : values.asKeyValueRange()) {
787 output = output.replace(key, value.toUpper());
788 }
789
790 return prune ? output.replace(QRegularExpression("[<](?:[^>]+)[>]"), "")
791 : output;
792 }
793
794 QList<int> generateOffsets(int minOffset, int maxOffset) {
795 QList<int> offsets;
796
797 // TODO: these offsets aren't ordered correctly...
798
799 for (int i = minOffset; i <= maxOffset; i++) {
800 offsets.append(i);
801 }
802 return offsets;
803 }
804
805 enum Priority {
806 PriorityLow = 10,
807 PriorityNormal = 100,
808 PriorityHigh = 1000
809 };
810
811 struct PrioritizedMessage {
812 QDateTime date;
813 int priority;
814 QString message;
815 int offset;
816 Callback callback;
817
818 friend bool operator<(PrioritizedMessage const &a,
819 PrioritizedMessage const &b) {
820 if (a.priority < b.priority) {
821 return true;
822 }
823 return a.date < b.date;
824 }
825 };
826
827 struct CachedDirectedType {
828 bool isAllcall;
829 QDateTime date;
830 };
831
832 struct DecodeParams {
833 int submode;
834 int start;
835 int sz;
836 };
837
838 struct FrameCacheKey {
839 int submode;
840 QString frame;
841
842 FrameCacheKey(int submode, QString frame)
843 : submode(submode), frame(std::move(frame)) {}
844
845 bool operator==(FrameCacheKey const &) const noexcept = default;
846
847 struct Hash {
848 std::size_t operator()(FrameCacheKey const &key) const noexcept {
849 std::size_t const h1 = std::hash<int>{}(key.submode);
850 std::size_t const h2 = qHash(key.frame);
851 return h1 ^ (h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2));
852 }
853 };
854 };
855
856 using FrameCache =
857 std::unordered_map<FrameCacheKey, QDateTime, FrameCacheKey::Hash>;
858 using BandActivity = QMap<int, QList<ActivityDetail>>;
859
860 QQueue<DecodeParams> m_decoderQueue;
861 FrameCache m_messageDupeCache; // submode, frame -> date seen
862 QVariantMap m_showColumnsCache; // table column:key -> show boolean
863 QVariantMap m_sortCache; // table key -> sort by
864 QPriorityQueue<PrioritizedMessage> m_txMessageQueue; // messages to be sent
865 QQueue<QPair<QString, int>> m_txFrameQueue; // frames to be sent
866 QQueue<ActivityDetail> m_rxActivityQueue; // all rx activity queue
867 QQueue<CommandDetail>
868 m_rxCommandQueue; // command queue for processing commands
869 QQueue<CallDetail>
870 m_rxCallQueue; // call detail queue for spots to pskreporter
871 QMap<QString, QString>
872 m_compoundCallCache; // base callsign -> compound callsign
873 QCache<QString, QDateTime> m_txAllcallCommandCache; // callsign -> last tx
874 QCache<int, QDateTime> m_rxRecentCache; // freq -> last rx
875 QCache<int, CachedDirectedType>
876 m_rxDirectedCache; // freq -> last directed rx
877 QCache<QString, int> m_rxCallCache; // call -> last freq seen
878 QMap<int, int> m_rxFrameBlockNumbers; // freq -> block
879 BandActivity m_bandActivity; // freq -> [(text, last timestamp), ...]
880 QMap<int, MessageBuffer> m_messageBuffer; // freq -> (cmd, [frames, ...])
881 int m_lastClosedMessageBufferOffset;
882 QMap<QString, CallDetail>
883 m_callActivity; // call -> (last freq, last timestamp)
884
885 QMap<int, QString> m_origRxHeaderLabelMap; // colIndex, label
886 QMap<int, QString> m_origCallActivityHeaderLabelMap; // colIndex, label
887 QMap<QString, QString> m_columnLabelMap; // full, minimal
888
889 QMap<QString, QSet<QString>>
890 m_heardGraphOutgoing; // callsign -> [stations who've this callsign has
891 // heard]
892 QMap<QString, QSet<QString>>
893 m_heardGraphIncoming; // callsign -> [stations who've heard this
894 // callsign]
895
896 QMap<QString, int> m_rxInboxCountCache; // call -> count
897
898 // The RAM band caches remain the session's display layer, exactly as
899 // on master: band round-trips restore the panes verbatim, with or
900 // without a working store. activity.db3 sits underneath as a
901 // write-through store plus a once-per-session seed of each bucket's
902 // history (see seedActivityForBand).
903 QMap<QString, QMap<QString, CallDetail>>
904 m_callActivityBandCache; // bucket -> call activity
905 QMap<QString, QString> m_rxTextBandCache; // bucket -> rx text
906 QMap<QString, QMap<int, QList<ActivityDetail>>>
907 m_bandActivityBandCache; // band -> band activity
908 QMap<QString, QMap<QString, QSet<QString>>>
909 m_heardGraphOutgoingBandCache; // band -> heard in
910 QMap<QString, QMap<QString, QSet<QString>>>
911 m_heardGraphIncomingBandCache; // band -> heard out
912
913 // Pending autoreply confirmations (network API and local UI notification)
914 struct PendingConfirmation {
915 int id;
916 int priority;
917 QString message;
918 int offset;
919 Callback callback;
920 QTimer *timer;
922 };
923 int m_nextConfirmId = 0;
924 QMap<int, PendingConfirmation> m_pendingConfirmations;
925
926 QMap<QString, QDateTime>
927 m_callSelectedTime; // call -> timestamp when callsign was last selected
932 QHash<QString, QDateTime> m_aprsRelayDedupCache;
933 QSet<QString> m_callSeenHeartbeat; // call
934 bool m_bandHopped;
935 Frequency m_bandHoppedFreq;
936
938 int m_hbInterval;
940 int m_cqInterval;
941
943 bool m_hbPaused;
944
945 QDateTime m_dateTimeQSOOn;
946 QDateTime m_dateTimeLastTX;
947
948 QSet<int> m_rxBlockedOffsets; //callsign blocking
949
950 LogBook m_logBook;
951 unsigned m_msAudioOutputBuffered;
952 unsigned m_framesAudioInputBuffered;
953 QThread::Priority m_audioThreadPriority;
954 QThread::Priority m_notificationAudioThreadPriority;
955 QThread::Priority m_decoderThreadPriority;
956 QThread::Priority m_networkThreadPriority;
957 bool m_splitMode;
958 bool m_monitoring;
959 bool m_generateAudioWhenPttConfirmedByTX;
960 bool m_transmitting;
961 bool m_tune;
962 bool m_tx_watchdog; // true when watchdog triggered
963 bool m_block_pwr_tooltip;
964 bool m_PwrBandSetOK;
965 Frequency m_lastMonitoredFrequency;
966 MessageClient *m_messageClient;
967 MessageServer *m_messageServer;
968 WSJTXMessageClient *m_wsjtxMessageClient;
969 WSJTXMessageMapper *m_wsjtxMessageMapper;
970 TCPClient *m_n3fjpClient;
971 PSKReporter *m_pskReporter;
972 SpotClient *m_spotClient;
973 APRSISClient *m_aprsClient;
974 AprsInboundRelay *m_aprsInboundRelay;
975 QVariantHash m_pwrBandTxMemory; // Remembers power level by band
976 QVariantHash
977 m_pwrBandTuneMemory; // Remembers power level by band for tuning
978 QByteArray m_geometryNoControls;
979
980 //---------------------------------------------------- private functions
981 void readSettings();
982 void set_application_font(QFont const &);
983 void writeSettings();
984 void updateCallActivityHeaderLabel();
985 void createControlBar();
986 void bindStatusButtonToAction(QPushButton *button, QAction *action, QString const &label);
987 void statusChanged();
988 void rigFailure(QString const &reason);
989 void spotSetLocal();
990 void pskSetLocal();
991 void aprsSetLocal();
992 void spotReport(int submode, Frequency dial, int offset, int snr,
993 QString const &callsign, QString const &grid);
994 void spotCmd(CommandDetail const &cmd);
995 void spotAprsCmd(CommandDetail const &cmd);
996 void pskLogReport(QString const &mode, Frequency dial, int offset, int snr,
997 QString const &callsign, QString const &grid,
998 QDateTime const &utcTimestamp);
999 void spotAprsGrid(Frequency dial, int offset, int snr, QString callsign,
1000 QString grid);
1001 Radio::Frequency dialFrequency();
1002 void setSubmode(int submode);
1003 void updateCurrentBand();
1004 void displayDialFrequency();
1005 void transmitDisplay(bool);
1006 void postDecode(bool is_new, QString const &message);
1007 void displayTransmit();
1008 void updateModeButtonText();
1009 void updateButtonDisplay();
1010 void updateTextDisplay();
1011 void updateTextWordCheckerDisplay();
1012 void updateTxButtonDisplay();
1013 bool isMyCallIncluded(QString const &text);
1014 bool isAllCallIncluded(QString const &text);
1015 bool isGroupCallIncluded(const QString &text);
1016 QString callsignSelected(bool useInputText = false);
1017 void callsignSelectedChanged(QString old, QString current);
1018 bool isRecentOffset(int submode, int offset);
1019 void markOffsetRecent(int offset);
1020 bool isDirectedOffset(int offset, bool *pIsAllCall);
1021 void markOffsetDirected(int offset, bool isAllCall);
1022 void clearOffsetDirected(int offset);
1023 void processActivity(bool force = false);
1024 void resetTimeDeltaAverage();
1025 void processRxActivity(); // JS8_Mainwindow/processRxActivity.cpp
1026 void processIdleActivity();
1027 void processCompoundActivity();
1028 void processBufferedActivity(); // JS8_Mainwindow/processBufferedActivity.cpp
1029 void processCommandActivity(); // JS8_Mainwindow/processCommandActivity.cpp
1030 QString inboxPath();
1031 QString hbBlockingPath() const;
1032 void pushNotificationHandler(); // JS8_Mainwindow/pushNotificationHandler.cpp
1033 QString msgNotifyPath() const;
1034 void removeStoredMessageNotification(int msgId);
1035 void refreshInboxCounts();
1036 bool hasMessageHistory(QString call);
1037 int addCommandToMyInbox(CommandDetail d);
1038 int addCommandToStorage(QString type, CommandDetail d);
1039 int getNextMessageIdForCallsign(QString callsign);
1040 int getLookaheadMessageIdForCallsign(QString callsign, int afterMsgId);
1041 int getNextGroupMessageIdForCallsign(QString group_name, QString callsign);
1042 int getLookaheadGroupMessageIdForCallsign(QString group_name,
1043 QString callsign, int afterMsgId);
1044 int countUnreadForCallsign(const QString &callsign);
1045 int countGroupUnreadForCallsign(const QString &group_name,
1046 const QString &callsign);
1047 bool markGroupMsgDeliveredForCallsign(int msgId, QString callsign);
1048 bool markMsgDelivered(int mid, Message msg);
1049 QStringList parseRelayPathCallsigns(QString from, QString text);
1050 void processSpots();
1051 void processTxQueue();
1052 void displayActivity(bool force = false);
1053 void displayBandActivity(); // JS8_Mainwindow/displayBandActivity.cpp
1054 void displayCallActivity(); // JS8_Mainwindow/displayCallActivity.cpp
1055 void enable_DXCC_entity(bool on);
1056 void setRig(Frequency = 0); // zero frequency means no change
1057 QDateTime nextTransmitCycle();
1058 void statusUpdate();
1059 void on_the_minute();
1060 void tryBandHop();
1061 void add_child_to_event_filter(QObject *);
1062 void remove_child_from_event_filter(QObject *);
1063 QString columnLabel(QString defaultLabel);
1064 void ensureMessageDock();
1065
1066 void resetIdleTimer();
1067 void incrementIdleTimer();
1068 void tx_watchdog(bool triggered);
1069 void write_frequency_entry(QString const &file_name);
1070 void write_transmit_entry(QString const &file_name);
1071};
1072
1073#endif // MAINWINDOW_H
APRS-IS client interface for JS8Call.
Declares the orchestration layer above ActivityDB (issue #267).
Defines the inbound APRS-IS relay handler for JS8Call.
Audio Device declarations for JS8Call-improved.
Defines the Call Activity record shared by the UI and storage.
Parse and expose fields from a decoded JS8 frame.
Worker and Decoder QObject wrapper for an external decoder process.
Audio sink that collects, down-samples and provides buffered samples.
Custom event filters for Qt applications.
Submode parameter accessors for JS8 modes.
Core JS8 namespace types, Costas arrays and decoder event payloads.
std::variant< DecodeStarted, SyncStart, SyncState, Decoded, DecodeFinished > Variant
Definition JS8.h:121
Spelling and suggestion helper for the JS8Call compressed word list.
High-level logbook operations combining ADIF and CTY data.
Audio modulator device that generates PCM frames for transmission.
Subclass of QNetworkAccessManager that manages SSL-error exceptions.
High-level helper to play notification sounds with caching.
Helper to aggregate and send PSK Reporter spots.
Pill-shaped visual highlights for directed message tokens.
Capture audio from an input device and forward to an AudioDevice sink.
Send audio data to a configured soundcard/output device.
Client for sending spots and commands to upstream spot servers.
Lightweight TCP client utilities used throughout the network code.
UDP client for sending and receiving WSJT‑X protocol messages.
Translate JS8Call events into WSJT‑X UDP protocol messages.
Parser and in-memory store for ADIF QSO records.
Definition ADIF.h:41
APRS-IS client responsible for sending and receiving APRS frames.
Definition APRSISClient.h:21
Handles inbound APRS-IS messages and enqueues JS8 relays.
Definition AprsInboundRelay.h:20
Abstract base class for audio devices exposed as a QIODevice.
Definition AudioDevice.h:27
Channel
Audio channel selection used by the device.
Definition AudioDevice.h:35
Definition Configuration.h:59
Wraps a decoded frame and provides parsed accessors.
Definition DecodedText.h:30
Definition Detector.h:26
Definition FrequencyList.h:67
Definition HelpTextWindow.h:9
Definition JS8MessageBox.h:13
High-level QObject controller that owns the decoding worker thread.
Definition JS8.h:145
Helper for checking and suggesting compressed-codewords.
Definition JSC_checker.h:28
Integrates ADIF, CTY and worked-state utilities for logbook queries.
Definition LogBook.h:27
Definition LogQSO.h:22
Definition MessageClient.h:21
Definition MessagePanel.h:17
Definition MessageServer.h:14
Definition Message.h:16
Audio device which synthesizes JS8 waveform samples for TX.
Definition Modulator.h:26
Definition MultiSettings.h:62
QNetworkAccessManager subclass that remembers allowed SSL errors.
Definition NetworkAccessManager.h:38
Plays short notification sounds using an internal output stream.
Definition NotificationAudio.h:27
Aggregates station spots and posts them to PSK Reporter.
Definition PSKReporter.h:29
Definition qpriorityqueue.h:39
Definition qpriorityqueue.h:72
Definition SelfDestructMessageBox.h:10
Gets audio data from a QAudioSource and passes frames to a sink.
Definition SoundInput.h:27
Manages audio output format, buffering and the underlying sink.
Definition SoundOutput.h:24
Sends spots and spot-related commands to a remote host.
Definition SpotClient.h:22
A labeled "Offset:" slider used to select the RX/TX audio offset, in Hz, in the header bar (Linux/oth...
Definition styles.h:751
Simple TCP client wrapper.
Definition TCPClient.h:25
Definition Transceiver.h:82
Definition Transceiver.h:50
Definition TxLoop.h:10
void confirmThenEnqueueMessage(int timeout, int priority, QString message, int offset, Callback c)
Presents a local confirmation dialog and fires a network confirmation request.
Definition confirmThenEnqueueMessage.cpp:34
void dataSink(qint64 frames)
Definition dataSink.cpp:79
void guiUpdate()
Definition mainwindow.cpp:2496
void resetMessageTransmitQueue()
Resets the frame-level transmission state after a message completes.
Definition mainwindow.cpp:3266
UI_Constructor(QString const &program_info, QDir const &temp_directory, bool multiple, MultiSettings *settings, QWidget *parent=nullptr)
Definition UI_Constructor.cpp:21
void processDecodeEvent(JS8::Event::Variant const &)
Definition processDecodeEvent.cpp:10
Implements a WSJT‑X compatible UDP message client.
Definition WSJTXMessageClient.h:31
Maps JS8Call events to WSJT-X protocol messages.
Definition WSJTXMessageMapper.h:26
Definition WideGraph.h:29
Common definitions and constants used throughout the JS8Call-improved project.
#define JS8_NUM_SYMBOLS
Definition commons.h:28
Definition StationList.h:50
Definition mainwindow.h:847
Platform-specific label, button, widget, and dialog styles used by the UI_Constructor class to assemb...