-
Notifications
You must be signed in to change notification settings - Fork 14
/
MainWindow.h
144 lines (129 loc) · 3.96 KB
/
MainWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
* Copyright (c) 2019-2022 by Thomas A. Early N7TAE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <regex>
#include <future>
#include <atomic>
#include <mutex>
#ifndef NO_DHT
#include <opendht.h>
#endif
#include "FLTK-GUI.h"
#include "Configure.h"
#include "M17Gateway.h"
#include "M17RouteMap.h"
#include "SettingsDlg.h"
#include "AboutDlg.h"
#include "AudioManager.h"
#include "TransmitButton.h"
class CMainWindow
{
public:
CMainWindow();
~CMainWindow();
CConfigure cfg;
CAudioManager AudioManager;
bool Init();
void Run(int argc, char *argv[]);
void Receive(bool is_rx);
void NewSettings(CFGDATA *newdata);
void UpdateGUI();
// helpers
bool ToUpper(std::string &s);
// regular expression for testing stuff
std::regex IPv4RegEx, IPv6RegEx, M17CallRegEx, M17RefRegEx;
private:
// classes
CSettingsDlg SettingsDlg;
CAboutDlg AboutDlg;
CM17Gateway gateM17;
#ifndef NO_DHT
// Distributed Hash Table
dht::DhtRunner node;
dht::Value nodevalue;
const std::string exportNodeFilename;
#endif
// widgets
Fl_Double_Window *pWin;
CTransmitButton *pPTTButton, *pEchoTestButton;
Fl_Button *pQuickKeyButton, *pActionButton, *pConnectButton, *pDisconnectButton, *pDashboardButton;
Fl_Input *pDestCallsignInput, *pDestIPInput;
Fl_Int_Input *pDestPortInput;
Fl_Group *pModuleGroup;
Fl_Radio_Round_Button *pModuleRadioButton[26];
Fl_Menu_Bar *pMenuBar;
Fl_Text_Display *pTextDisplay;
Fl_Text_Buffer *pTextBuffer;
Fl_RGB_Image *pIcon;
// state data
CFGDATA cfgdata;
std::mutex logmux;
// helpers
void BuildDestMenuButton();
void FixDestActionButton();
void SetDestActionButton(const bool sensitive, const char *label);
void TransmitterButtonControl();
std::future<void> futM17;
std::future<void> futReadThread;
void SetState();
void RunM17();
void StopM17();
void ReadThread();
CUnixDgramReader M172AM, LogInput;
void CloseAll();
void insertLogText(const char *line);
void AudioSummary(const char *title);
char GetDestinationModule();
void SetDestinationAddress(std::string &cs);
#ifndef NO_DHT
void Get(const std::string &cs);
#endif
void ActivateModules(const std::string &modules = "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
// Actual Callbacks
void Quit();
void ShowSettingsDialog();
void ShowAboutDialog();
void EchoButton();
void PTTButton();
void QuickKeyButton();
void DestCallsignInput();
void DestIPInput();
void DestPortInput();
void DestMenuButton();
void ActionButton();
void LinkButton();
void UnlinkButton();
void DashboardButton();
// Static wrapper for callbacks
static void QuitCB(Fl_Widget *p, void *v);
static void ShowSettingsDialogCB(Fl_Widget *p, void *v);
static void ShowAboutDialogCB(Fl_Widget *p, void *v);
static void EchoButtonCB(Fl_Widget *p, void *v);
static void PTTButtonCB(Fl_Widget *p, void *v);
static void QuickKeyButttonCB(Fl_Widget *, void *);
static void DestCallsignInputCB(Fl_Widget *p, void *v);
static void DestIPInputCB(Fl_Widget *p, void *v);
static void DestPortInputCB(Fl_Widget *p, void *v);
static void DestMenuButtonCB(Fl_Widget *p, void *v);
static void ActionButtonCB(Fl_Widget *p, void *v);
static void LinkButtonCB(Fl_Widget *p, void *v);
static void UnlinkButtonCB(Fl_Widget *p, void *v);
static void DashboardButtonCB(Fl_Widget *p, void *v);
bool bDestCS, bDestIP, bDestPort, bTransOK;
std::atomic<bool> keep_running;
};