Rev 715 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 715 | Rev 750 | ||
---|---|---|---|
1 | /*************************************************************************** |
1 | /*************************************************************************** |
2 | * Copyright (C) 2009 by Manuel Schrape * |
2 | * Copyright (C) 2009 by Manuel Schrape * |
3 | * manuel.schrape@gmx.de * |
3 | * manuel.schrape@gmx.de * |
4 | * * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Con_Server; either version 2 of the License. * |
7 | * the Free Software Con_Server; either version 2 of the License. * |
8 | * * |
8 | * * |
9 | * This program is distributed in the hope that it will be useful, * |
9 | * This program is distributed in the hope that it will be useful, * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
12 | * GNU General Public License for more details. * |
12 | * GNU General Public License for more details. * |
13 | * * |
13 | * * |
14 | * You should have received a copy of the GNU General Public License * |
14 | * You should have received a copy of the GNU General Public License * |
15 | * along with this program; if not, write to the * |
15 | * along with this program; if not, write to the * |
16 | * Free Software Con_Server, Inc., * |
16 | * Free Software Con_Server, Inc., * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
18 | ***************************************************************************/ |
18 | ***************************************************************************/ |
19 | 19 | ||
20 | #include <QMessageBox> |
20 | #include <QMessageBox> |
21 | #include <QCryptographicHash> |
21 | #include <QCryptographicHash> |
22 | 22 | ||
23 | #include "dlg_Main.h" |
23 | #include "dlg_Main.h" |
24 | 24 | ||
25 | // Konstruktor Main-Form |
25 | // Konstruktor Main-Form |
26 | //////////////////////// |
26 | //////////////////////// |
27 | dlg_Main::dlg_Main() |
27 | dlg_Main::dlg_Main() |
28 | { |
28 | { |
29 | setupUi(this); |
29 | setupUi(this); |
30 | 30 | ||
31 | s_Buffer = ""; |
31 | s_Buffer = ""; |
32 | o_Settings = new cSettings(); |
32 | o_Settings = new cSettings(); |
33 | 33 | ||
34 | o_Input = new Input(); |
34 | o_Input = new Input(); |
35 | o_Output = new Input(); |
35 | o_Output = new Input(); |
36 | 36 | ||
37 | f_Terminal = new dlg_Terminal(this); |
37 | f_Terminal = new dlg_Terminal(this); |
38 | 38 | ||
39 | init_GUI(); |
39 | init_GUI(); |
40 | init_Connections(); |
40 | init_Connections(); |
41 | 41 | ||
42 | init_TCP(); |
42 | init_TCP(); |
43 | } |
43 | } |
44 | 44 | ||
45 | void dlg_Main::set_ARGV(char *Programm) |
45 | void dlg_Main::set_ARGV(char *Programm) |
46 | { |
46 | { |
47 | QString tmp = QString(Programm); |
47 | QString tmp = QString(Programm); |
48 | QMK_Dir = tmp.left(tmp.lastIndexOf("/")); |
48 | QMK_Dir = tmp.left(tmp.lastIndexOf("/")); |
49 | } |
49 | } |
50 | 50 | ||
51 | // Grafische Oberfläche initialisieren |
51 | // Grafische Oberfläche initialisieren |
52 | ////////////////////////////////////// |
52 | ////////////////////////////////////// |
53 | void dlg_Main::init_GUI() |
53 | void dlg_Main::init_GUI() |
54 | { |
54 | { |
55 | setWindowTitle(QA_NAME + " " + QA_VERSION); |
55 | setWindowTitle(QA_NAME + " " + QA_VERSION); |
56 | 56 | ||
57 | resize(o_Settings->GUI.Size); |
57 | resize(o_Settings->GUI.Size); |
58 | move(o_Settings->GUI.Point); |
58 | move(o_Settings->GUI.Point); |
- | 59 | ||
- | 60 | f_Terminal->resize(o_Settings->TERMINAL.Size); |
|
- | 61 | f_Terminal->move(o_Settings->TERMINAL.Point); |
|
- | 62 | ||
- | 63 | f_Terminal->cb_Data->setChecked(o_Settings->DATA.Data); |
|
- | 64 | f_Terminal->cb_Info->setChecked(o_Settings->DATA.Info); |
|
- | 65 | f_Terminal->cb_Send->setChecked(o_Settings->DATA.Send); |
|
- | 66 | f_Terminal->cb_TCP->setChecked(o_Settings->DATA.TCP); |
|
59 | 67 | ||
60 | if (o_Settings->GUI.isMax) |
68 | if (o_Settings->GUI.isMax) |
61 | { |
69 | { |
62 | showMaximized(); |
70 | showMaximized(); |
63 | } |
71 | } |
64 | 72 | ||
65 | // todo: In abhängigkeit von Settings |
73 | // todo: In abhängigkeit von Settings |
66 | wg_IP->setVisible(false); |
74 | wg_IP->setVisible(false); |
67 | rb_Device->setChecked(true); |
75 | rb_Device->setChecked(true); |
68 | 76 | ||
69 | for (int z = 0; z < DEV_IP_MAX; z++) |
77 | for (int z = 0; z < DEV_IP_MAX; z++) |
70 | { |
78 | { |
71 | Item[z] = new QListWidgetItem(); |
79 | Item[z] = new QListWidgetItem(); |
72 | } |
80 | } |
73 | 81 | ||
74 | // Liste der Devices |
82 | // Liste der Devices |
75 | for(int z = 0; z < o_Settings->CLIENT.TTY_MAX; z++) |
83 | for(int z = 0; z < o_Settings->CLIENT.TTY_MAX; z++) |
76 | { |
84 | { |
77 | if (cb_Device->findText(o_Settings->CLIENT.TTY_DEVICES[z]) == -1) |
85 | if (cb_Device->findText(o_Settings->CLIENT.TTY_DEVICES[z]) == -1) |
78 | { |
86 | { |
79 | cb_Device->addItem(o_Settings->CLIENT.TTY_DEVICES[z]); |
87 | cb_Device->addItem(o_Settings->CLIENT.TTY_DEVICES[z]); |
80 | } |
88 | } |
81 | } |
89 | } |
82 | 90 | ||
83 | cb_Device->setCurrentIndex(o_Settings->CLIENT.TTY_ID); |
91 | cb_Device->setCurrentIndex(o_Settings->CLIENT.TTY_ID); |
84 | 92 | ||
85 | // Liste der IP-Server |
93 | // Liste der IP-Server |
86 | for(int z = 0; z < o_Settings->CLIENT.TCP_MAX; z++) |
94 | for(int z = 0; z < o_Settings->CLIENT.TCP_MAX; z++) |
87 | { |
95 | { |
88 | if (cb_Server->findText(o_Settings->CLIENT.TCP_SERVER[z]) == -1) |
96 | if (cb_Server->findText(o_Settings->CLIENT.TCP_SERVER[z]) == -1) |
89 | { |
97 | { |
90 | cb_Server->addItem(o_Settings->CLIENT.TCP_SERVER[z]); |
98 | cb_Server->addItem(o_Settings->CLIENT.TCP_SERVER[z]); |
91 | } |
99 | } |
92 | } |
100 | } |
93 | 101 | ||
94 | cb_Server->setCurrentIndex(o_Settings->CLIENT.TCP_ID); |
102 | cb_Server->setCurrentIndex(o_Settings->CLIENT.TCP_ID); |
95 | 103 | ||
96 | // Password für IP-Verbindung. |
104 | // Password für IP-Verbindung. |
97 | le_Password->setText(o_Settings->CLIENT.TCP_Password); |
105 | le_Password->setText(o_Settings->CLIENT.TCP_Password); |
- | 106 | ||
- | 107 | btn_Debug->setVisible(false); |
|
98 | 108 | btn_ConnectServer->setVisible(false); |
|
99 | } |
109 | } |
100 | 110 | ||
101 | // Signale mit Slots verbinden |
111 | // Signale mit Slots verbinden |
102 | ////////////////////////////// |
112 | ////////////////////////////// |
103 | void dlg_Main::init_Connections() |
113 | void dlg_Main::init_Connections() |
104 | { |
114 | { |
105 | // Connect-Button |
115 | // Connect-Button |
106 | connect(btn_Connect, SIGNAL(clicked()), this, SLOT(slot_btn_Connect())); |
116 | connect(btn_Connect, SIGNAL(clicked()), this, SLOT(slot_btn_Connect())); |
107 | 117 | ||
108 | connect(btn_cScope, SIGNAL(clicked()), this, SLOT(slot_btn_cScope())); |
118 | connect(btn_cScope, SIGNAL(clicked()), this, SLOT(slot_btn_cScope())); |
109 | connect(btn_cSettings, SIGNAL(clicked()), this, SLOT(slot_btn_cSettings())); |
119 | connect(btn_cSettings, SIGNAL(clicked()), this, SLOT(slot_btn_cSettings())); |
110 | connect(btn_cMaps, SIGNAL(clicked()), this, SLOT(slot_btn_cMaps())); |
120 | connect(btn_cMaps, SIGNAL(clicked()), this, SLOT(slot_btn_cMaps())); |
111 | connect(btn_cVoice, SIGNAL(clicked()), this, SLOT(slot_btn_cVoice())); |
121 | connect(btn_cVoice, SIGNAL(clicked()), this, SLOT(slot_btn_cVoice())); |
112 | connect(btn_cLogger, SIGNAL(clicked()), this, SLOT(slot_btn_cLogger())); |
122 | connect(btn_cLogger, SIGNAL(clicked()), this, SLOT(slot_btn_cLogger())); |
113 | 123 | ||
114 | connect(btn_Terminal, SIGNAL(clicked()), this, SLOT(slot_btn_Terminal())); |
124 | connect(btn_Terminal, SIGNAL(clicked()), this, SLOT(slot_btn_Terminal())); |
115 | connect(btn_ConnectServer, SIGNAL(clicked()), this, SLOT(slot_btn_ConnectServer())); |
125 | connect(btn_ConnectServer, SIGNAL(clicked()), this, SLOT(slot_btn_ConnectServer())); |
- | 126 | ||
- | 127 | connect(btn_Debug, SIGNAL(clicked()), this, SLOT(slot_btn_Debug())); |
|
- | 128 | ||
- | 129 | connect(rb_NC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
|
- | 130 | connect(rb_FC, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
|
- | 131 | connect(rb_MK3MAG, SIGNAL(clicked()), this, SLOT(slot_rb_Hardware())); |
|
116 | 132 | ||
117 | // About QMK-Kernel & About-QT Dialog einfügen |
133 | // About QMK-Kernel & About-QT Dialog einfügen |
118 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
134 | connect(ac_About, SIGNAL(triggered()), this, SLOT(slot_ac_About())); |
119 | connect(ac_Server, SIGNAL(triggered()), this, SLOT(slot_ac_Server())); |
135 | connect(ac_Server, SIGNAL(triggered()), this, SLOT(slot_ac_Server())); |
120 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
136 | menu_Help->addAction(trUtf8("Über &Qt"), qApp, SLOT(aboutQt())); |
121 | } |
137 | } |
122 | 138 | ||
123 | // IP-Ports initialisiern |
139 | // IP-Ports initialisiern |
124 | ///////////////////////// |
140 | ///////////////////////// |
125 | // todo: Port und Anzahl aus Settings |
141 | // todo: Port und Anzahl aus Settings |
126 | bool dlg_Main::init_TCP() |
142 | bool dlg_Main::init_TCP() |
127 | { |
143 | { |
128 | Connect_Count = 0; |
144 | Connect_Count = 0; |
129 | 145 | ||
130 | Con_Server[0].Status = 0; |
146 | Con_Server[0].Status = 0; |
131 | 147 | ||
132 | Con_Server[0].TCP = false; |
148 | Con_Server[0].TCP = false; |
133 | Con_Server[0].UDP = false; |
149 | Con_Server[0].UDP = false; |
134 | 150 | ||
135 | for (int a = 0; a < DEV_IP_MAX; a++) |
151 | for (int a = 0; a < DEV_IP_MAX; a++) |
136 | { |
152 | { |
137 | Con_Server[a].Status = 0; |
153 | Con_Server[a].Status = 0; |
138 | } |
154 | } |
139 | 155 | ||
140 | TCP_Server = new QTcpServer(this); |
156 | TCP_Server = new QTcpServer(this); |
141 | 157 | ||
142 | if (TCP_Server->listen(QHostAddress::Any, qint16(o_Settings->SERVER.TCP_PORT))) |
158 | if (TCP_Server->listen(QHostAddress::Any, qint16(o_Settings->SERVER.TCP_PORT))) |
143 | { |
159 | { |
144 | connect(TCP_Server, SIGNAL(newConnection()), this, SLOT(slot_TCP_NewConnection())); |
160 | connect(TCP_Server, SIGNAL(newConnection()), this, SLOT(slot_TCP_NewConnection())); |
145 | } |
161 | } |
146 | 162 | ||
147 | return true; |
163 | return true; |
148 | } |
164 | } |
149 | 165 | ||
150 | // Eingangsdaten verarbeiten |
166 | // Eingangsdaten verarbeiten |
151 | //////////////////////////// |
167 | //////////////////////////// |
152 | void dlg_Main::parse_Input_Data(QString t_Data) |
168 | void dlg_Main::parse_Input_Data(QString t_Data) |
153 | { |
169 | { |
154 | unsigned char OutData[150]; |
170 | unsigned char OutData[180]; |
155 | char *InData = t_Data.toLatin1().data(); |
171 | char *InData = t_Data.toLatin1().data(); |
156 | 172 | ||
157 | if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0) |
173 | if (HandlerMK::Decode_64(InData, t_Data.length(), OutData) != 0) |
158 | { |
174 | { |
159 | switch(InData[2]) |
175 | switch(InData[2]) |
160 | { |
176 | { |
161 | case 'V' : // Versions-Info |
177 | case 'V' : // Versions-Info |
162 | { |
178 | { |
163 | o_Input->stop_Resend(DATA_VERSION); |
179 | o_Input->stop_Resend(DATA_VERSION); |
164 | VersionInfo = HandlerMK::parse_Version(OutData, InData[1] - 'a'); |
180 | VersionInfo = HandlerMK::parse_Version(OutData, InData[1] - 'a'); |
165 | lb_Info->setText(tr("Verbunden mit ") + VersionInfo.Hardware + " " + VersionInfo.Version + trUtf8(" über ") + s_Input.Main + "."); |
181 | lb_Info->setText(tr("Verbunden mit ") + VersionInfo.Hardware + " " + VersionInfo.Version + trUtf8(" über ") + s_Input.Main + "."); |
166 | 182 | ||
167 | if (VersionInfo.ID == ADDRESS_FC) |
183 | if (VersionInfo.ID == ADDRESS_FC) |
168 | { |
184 | { |
169 | rb_FC->setChecked(true); |
185 | rb_FC->setChecked(true); |
170 | } |
186 | } |
171 | if (VersionInfo.ID == ADDRESS_NC) |
187 | if (VersionInfo.ID == ADDRESS_NC) |
172 | { |
188 | { |
173 | rb_NC->setChecked(true); |
189 | rb_NC->setChecked(true); |
174 | } |
190 | } |
175 | if (VersionInfo.ID == ADDRESS_MK3MAG) |
191 | if (VersionInfo.ID == ADDRESS_MK3MAG) |
176 | { |
192 | { |
177 | rb_MK3MAG->setChecked(true); |
193 | rb_MK3MAG->setChecked(true); |
178 | } |
194 | } |
179 | } |
195 | } |
180 | break; |
196 | break; |
181 | } |
197 | } |
182 | } |
198 | } |
183 | } |
199 | } |
184 | 200 | ||
185 | void dlg_Main::route_Input_Data(QString t_Data) |
201 | void dlg_Main::route_Input_Data(QString t_Data) |
186 | { |
202 | { |
187 | // An alle offenen TCP-Sockets senden. |
203 | // An alle offenen TCP-Sockets senden. |
188 | for (int a = 1; a < DEV_IP_MAX; a++) |
204 | for (int a = 1; a < DEV_IP_MAX; a++) |
189 | { |
205 | { |
190 | if (Con_Server[a].Status > 0) |
206 | if (Con_Server[a].Status > 0) |
191 | { |
207 | { |
192 | if (Con_Server[a].TCP == true) |
208 | if (Con_Server[a].TCP == true) |
193 | { |
209 | { |
194 | if ((Con_Server[a].Fields == "") || (Con_Server[a].Fields.contains(t_Data.at(2)) == true)) |
210 | if ((Con_Server[a].Fields == "") || (Con_Server[a].Fields.contains(t_Data.at(2)) == true)) |
195 | { |
211 | { |
196 | if (o_Input->Mode() == TTY) |
212 | if (o_Input->Mode() == TTY) |
197 | { |
213 | { |
198 | send_TCP(o_TCP[a], t_Data + "\r"); |
214 | send_TCP(o_TCP[a], t_Data + "\r"); |
199 | } |
215 | } |
200 | else |
216 | else |
201 | { |
217 | { |
202 | send_TCP(o_TCP[a], t_Data); |
218 | send_TCP(o_TCP[a], t_Data); |
203 | } |
219 | } |
204 | } |
220 | } |
205 | else |
221 | else |
206 | { |
222 | { |
207 | // qDebug("Not Send Data"); |
223 | // qDebug("Not Send Data"); |
208 | // qDebug(t_Data.toLatin1().data()); |
224 | // qDebug(t_Data.toLatin1().data()); |
209 | } |
225 | } |
210 | } |
226 | } |
211 | } |
227 | } |
212 | } |
228 | } |
213 | if ((o_Output->IsOpen()) && ((Con_Output.Fields == "") || (Con_Output.Fields.contains(t_Data.at(2)) == true))) |
229 | if ((o_Output->IsOpen()) && ((Con_Output.Fields == "") || (Con_Output.Fields.contains(t_Data.at(2)) == true))) |
214 | { |
230 | { |
215 | o_Output->send_Data(t_Data); |
231 | o_Output->send_Data(t_Data); |
216 | } |
232 | } |
217 | } |
233 | } |
218 | 234 | ||
219 | void dlg_Main::parse_TCP_Server_Data(QString t_Data, int t_ID) |
235 | void dlg_Main::parse_TCP_Server_Data(QString t_Data, int t_ID) |
220 | { |
236 | { |
221 | QStringList Data; |
237 | QStringList Data; |
222 | Data = t_Data.split(":"); |
238 | Data = t_Data.split(":"); |
223 | 239 | ||
224 | if (Data.count() > 1) |
240 | if (Data.count() > 1) |
225 | { |
241 | { |
226 | int CMD = Data[2].toInt(); |
242 | int CMD = Data[2].toInt(); |
227 | QString A = Data[2]; |
243 | QString A = Data[2]; |
228 | // qDebug(A.toLatin1().data()); |
244 | // qDebug(A.toLatin1().data()); |
229 | 245 | ||
230 | switch(CMD) |
246 | switch(CMD) |
231 | { |
247 | { |
232 | case 101 : |
248 | case 101 : |
233 | { |
249 | { |
234 | Con_Server[t_ID].Version = Data[3]; |
250 | Con_Server[t_ID].Version = Data[3]; |
235 | Item[t_ID]->setText(" " + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
251 | Item[t_ID]->setText(" " + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
236 | 252 | ||
237 | if (Con_Server[t_ID].Status == 2) |
253 | if (Con_Server[t_ID].Status == 2) |
238 | { |
254 | { |
239 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
255 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
240 | } |
256 | } |
241 | else |
257 | else |
242 | { |
258 | { |
243 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "105")); |
259 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "105")); |
244 | } |
260 | } |
245 | 261 | ||
246 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "106")); |
262 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "106")); |
247 | } |
263 | } |
248 | break; |
264 | break; |
249 | case 105 : |
265 | case 105 : |
250 | { |
266 | { |
251 | if (Con_Server[t_ID].Status != 2) |
267 | if (Con_Server[t_ID].Status != 2) |
252 | { |
268 | { |
253 | // qDebug("Get 105"); |
269 | // qDebug("Get 105"); |
254 | QString s_MD5PW; |
270 | QString s_MD5PW; |
255 | QByteArray a_MD5PW; |
271 | QByteArray a_MD5PW; |
256 | 272 | ||
257 | a_MD5PW = QCryptographicHash::hash(o_Settings->SERVER.Password.toAscii(),QCryptographicHash::Md5); |
273 | a_MD5PW = QCryptographicHash::hash(o_Settings->SERVER.Password.toAscii(),QCryptographicHash::Md5); |
258 | 274 | ||
259 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
275 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
260 | 276 | ||
261 | if ((o_Settings->SERVER.Password != "") && (Data[3] == s_MD5PW)) |
277 | if ((o_Settings->SERVER.Password != "") && (Data[3] == s_MD5PW)) |
262 | { |
278 | { |
263 | // qDebug("Set 505 OK"); |
279 | // qDebug("Set 505 OK"); |
264 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "OK")); |
280 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "OK")); |
265 | 281 | ||
266 | Con_Server[t_ID].Status = 2; |
282 | Con_Server[t_ID].Status = 2; |
267 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
283 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version); |
268 | } |
284 | } |
269 | else |
285 | else |
270 | { |
286 | { |
271 | // qDebug("Set 505 NO"); |
287 | // qDebug("Set 505 NO"); |
272 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "NO")); |
288 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "NO")); |
273 | } |
289 | } |
274 | } |
290 | } |
275 | else |
291 | else |
276 | { |
292 | { |
277 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "OK")); |
293 | send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 505, "OK")); |
278 | } |
294 | } |
279 | } |
295 | } |
280 | break; |
296 | break; |
281 | case 106 : // Datenfelder anfordern. |
297 | case 106 : // Datenfelder anfordern. |
282 | { |
298 | { |
283 | if (Con_Server[t_ID].Status == 2) |
299 | if (Con_Server[t_ID].Status == 2) |
284 | { |
300 | { |
285 | Con_Server[t_ID].Fields = Data[3]; |
301 | Con_Server[t_ID].Fields = Data[3]; |
286 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version + " - " + Con_Server[t_ID].Fields); |
302 | Item[t_ID]->setText("*" + QString(o_TCP[t_ID]->peerAddress().toString()).leftJustified(15,' ') + " - " + Con_Server[t_ID].Version + " - " + Con_Server[t_ID].Fields); |
287 | // send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 506, Con_Server[t_ID].Fields)); |
303 | // send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 506, Con_Server[t_ID].Fields)); |
288 | } |
304 | } |
289 | } |
305 | } |
290 | } |
306 | } |
291 | } |
307 | } |
292 | } |
308 | } |
293 | 309 | ||
294 | // IP-Input-Daten verarbeiten. |
310 | // IP-Input-Daten verarbeiten. |
295 | void dlg_Main::parse_TCP_Input_Data(QString t_Data) |
311 | void dlg_Main::parse_TCP_Input_Data(QString t_Data) |
296 | { |
312 | { |
297 | QStringList Data; |
313 | QStringList Data; |
298 | Data = t_Data.split(":"); |
314 | Data = t_Data.split(":"); |
299 | 315 | ||
300 | if (Data.count() > 1) |
316 | if (Data.count() > 1) |
301 | { |
317 | { |
302 | int CMD = Data[2].toInt(); |
318 | int CMD = Data[2].toInt(); |
303 | 319 | ||
304 | switch(CMD) |
320 | switch(CMD) |
305 | { |
321 | { |
306 | case 502 : |
322 | case 502 : |
307 | { |
323 | { |
308 | // qDebug("Request Data"); |
324 | // qDebug("Request Data"); |
309 | switch (Data[3].toInt()) |
325 | switch (Data[3].toInt()) |
310 | { |
326 | { |
311 | case 105 : |
327 | case 105 : |
312 | { |
328 | { |
313 | QString s_MD5PW; |
329 | QString s_MD5PW; |
314 | QByteArray a_MD5PW; |
330 | QByteArray a_MD5PW; |
315 | 331 | ||
316 | a_MD5PW = QCryptographicHash::hash(le_Password->text().toAscii(),QCryptographicHash::Md5); |
332 | a_MD5PW = QCryptographicHash::hash(le_Password->text().toAscii(),QCryptographicHash::Md5); |
317 | 333 | ||
318 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
334 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
319 | 335 | ||
320 | o_Input->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 105, s_MD5PW)); |
336 | o_Input->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 105, s_MD5PW)); |
321 | } |
337 | } |
322 | break; |
338 | break; |
323 | } |
339 | } |
324 | } |
340 | } |
325 | break; |
341 | break; |
326 | case 505 : |
342 | case 505 : |
327 | { |
343 | { |
328 | if (Data[3] == "OK") |
344 | if (Data[3] == "OK") |
329 | { |
345 | { |
330 | } |
346 | } |
331 | else |
347 | else |
332 | { |
348 | { |
333 | QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen. <br />Daten senden zum Mikrokopter nicht möglich."), QMessageBox::Ok); |
349 | QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen. <br />Daten senden zum Mikrokopter nicht möglich."), QMessageBox::Ok); |
334 | } |
350 | } |
335 | } |
351 | } |
336 | break; |
352 | break; |
337 | } |
353 | } |
338 | } |
354 | } |
339 | } |
355 | } |
340 | 356 | ||
341 | // IP-Input-Daten verarbeiten. |
357 | // IP-Output-Daten verarbeiten. (Live-Data) |
342 | void dlg_Main::parse_TCP_Output_Data(QString t_Data) |
358 | void dlg_Main::parse_TCP_Output_Data(QString t_Data) |
343 | { |
359 | { |
344 | QStringList Data; |
360 | QStringList Data; |
345 | Data = t_Data.split(":"); |
361 | Data = t_Data.split(":"); |
346 | 362 | ||
347 | if (Data.count() > 1) |
363 | if (Data.count() > 1) |
348 | { |
364 | { |
349 | int CMD = Data[2].toInt(); |
365 | int CMD = Data[2].toInt(); |
350 | 366 | ||
351 | switch(CMD) |
367 | switch(CMD) |
352 | { |
368 | { |
353 | case 101 : |
369 | case 101 : |
354 | { |
370 | { |
355 | Con_Output.Version = Data[3]; |
371 | Con_Output.Version = Data[3]; |
356 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
372 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
357 | } |
373 | } |
358 | break; |
374 | break; |
359 | case 106 : // Datenfelder anfordern. |
375 | case 106 : // Datenfelder anfordern. |
360 | { |
376 | { |
361 | Con_Output.Fields = Data[3]; |
377 | Con_Output.Fields = Data[3]; |
362 | // send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 506, Con_Server[t_ID].Fields)); |
378 | // send_TCP(o_TCP[t_ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 506, Con_Server[t_ID].Fields)); |
363 | } |
379 | } |
364 | break; |
380 | break; |
365 | case 502 : |
381 | case 502 : |
366 | { |
382 | { |
367 | switch (Data[3].toInt()) |
383 | switch (Data[3].toInt()) |
368 | { |
384 | { |
369 | case 104 : |
385 | case 104 : |
370 | { |
386 | { |
371 | // qDebug("Request PW"); |
387 | // qDebug("Request PW"); |
372 | QString s_MD5PW; |
388 | QString s_MD5PW; |
373 | QByteArray a_MD5PW; |
389 | QByteArray a_MD5PW; |
374 | 390 | ||
375 | a_MD5PW = QCryptographicHash::hash(QString("madlen").toAscii(),QCryptographicHash::Md5); |
391 | a_MD5PW = QCryptographicHash::hash(QString(QByteArray::fromBase64(Base64Hash.toLatin1()) + o_Settings->LIVEDATA.Password).toAscii(),QCryptographicHash::Md5); |
376 | 392 | ||
377 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
393 | s_MD5PW = QString(a_MD5PW.toHex().data()); |
378 | 394 | ||
379 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 104, "keyoz@c64-power.net;" + s_MD5PW)); |
395 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 104, o_Settings->LIVEDATA.User + ";" + s_MD5PW)); |
380 | } |
396 | } |
381 | break; |
397 | break; |
382 | } |
398 | } |
383 | } |
399 | } |
384 | break; |
400 | break; |
385 | case 504 : |
401 | case 504 : |
386 | { |
402 | { |
387 | if (Data[3] == "OK") |
403 | if (Data[3] == "OK") |
388 | { |
404 | { |
389 | Con_Output.Status = 2; |
405 | Con_Output.Status = 2; |
390 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "106")); |
406 | o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 502, "106")); |
391 | } |
407 | } |
392 | else |
408 | else |
393 | { |
409 | { |
394 | QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen."), QMessageBox::Ok); |
410 | QMessageBox::warning(this, QA_NAME, trUtf8("Authentifizierung fehlgeschlagen."), QMessageBox::Ok); |
395 | } |
411 | } |
396 | } |
412 | } |
397 | break; |
413 | break; |
398 | } |
414 | } |
399 | } |
415 | } |
400 | } |
416 | } |
401 | 417 | ||
402 | // Freies IP-Socket ermitteln |
418 | // Freies IP-Socket ermitteln |
403 | int dlg_Main::get_FreeSocket() |
419 | int dlg_Main::get_FreeSocket() |
404 | { |
420 | { |
405 | for (int a = 1; a < DEV_IP_MAX; a++) |
421 | for (int a = 1; a < DEV_IP_MAX; a++) |
406 | { |
422 | { |
407 | if (Con_Server[a].Status == 0) |
423 | if (Con_Server[a].Status == 0) |
408 | return a; |
424 | return a; |
409 | } |
425 | } |
410 | return 0; |
426 | return 0; |
411 | } |
427 | } |
412 | 428 | ||
413 | // Daten auf TCP Senden |
429 | // Daten auf TCP Senden |
414 | void dlg_Main::send_TCP(QTcpSocket *Socket, QString Data) |
430 | void dlg_Main::send_TCP(QTcpSocket *Socket, QString Data) |
415 | { |
431 | { |
416 | QByteArray SendText = Data.toAscii(); |
432 | QByteArray SendText = Data.toAscii(); |
417 | 433 | ||
418 | Socket->write(SendText + "\n"); |
434 | Socket->write(SendText + "\n"); |
419 | Socket->flush(); |
435 | Socket->flush(); |
420 | 436 | ||
421 | // qDebug(SendText.data()); |
437 | // qDebug(SendText.data()); |
422 | } |
438 | } |
423 | 439 | ||
424 | /////////// |
440 | /////////// |
425 | // Slots // |
441 | // Slots // |
426 | /////////// |
442 | /////////// |
427 | 443 | ||
428 | void dlg_Main::slot_btn_cScope() |
444 | void dlg_Main::slot_btn_cScope() |
429 | { |
445 | { |
430 | QString Programm = QMK_Dir + "/QMK-Scope"; |
446 | QString Programm = QMK_Dir + "/QMK-Scope"; |
431 | 447 | ||
432 | QStringList Argumente; |
448 | QStringList Argumente; |
433 | 449 | ||
434 | o_cScope = new QProcess(); |
450 | o_cScope = new QProcess(); |
435 | 451 | ||
436 | Argumente << ""; |
452 | Argumente << ""; |
437 | 453 | ||
438 | o_cScope->start(Programm, Argumente); // Programmaufruf |
454 | o_cScope->start(Programm, Argumente); // Programmaufruf |
439 | } |
455 | } |
440 | 456 | ||
441 | void dlg_Main::slot_btn_cSettings() |
457 | void dlg_Main::slot_btn_cSettings() |
442 | { |
458 | { |
443 | QString Programm = QMK_Dir + "/QMK-Settings"; |
459 | QString Programm = QMK_Dir + "/QMK-Settings"; |
444 | 460 | ||
445 | QStringList Argumente; |
461 | QStringList Argumente; |
446 | 462 | ||
447 | o_cSettings = new QProcess(); |
463 | o_cSettings = new QProcess(); |
448 | 464 | ||
449 | Argumente << ""; |
465 | Argumente << ""; |
450 | 466 | ||
451 | o_cSettings->start(Programm, Argumente); // Programmaufruf |
467 | o_cSettings->start(Programm, Argumente); // Programmaufruf |
452 | } |
468 | } |
453 | 469 | ||
454 | void dlg_Main::slot_btn_cMaps() |
470 | void dlg_Main::slot_btn_cMaps() |
455 | { |
471 | { |
456 | QString Programm = QMK_Dir + "/QMK-Maps"; |
472 | QString Programm = QMK_Dir + "/QMK-Maps"; |
457 | 473 | ||
458 | QStringList Argumente; |
474 | QStringList Argumente; |
459 | 475 | ||
460 | o_cMaps = new QProcess(); |
476 | o_cMaps = new QProcess(); |
461 | 477 | ||
462 | Argumente << ""; |
478 | Argumente << ""; |
463 | 479 | ||
464 | o_cMaps->start(Programm, Argumente); // Programmaufruf |
480 | o_cMaps->start(Programm, Argumente); // Programmaufruf |
465 | } |
481 | } |
466 | 482 | ||
467 | void dlg_Main::slot_btn_cVoice() |
483 | void dlg_Main::slot_btn_cVoice() |
468 | { |
484 | { |
469 | QString Programm = QMK_Dir + "/QMK-Voice"; |
485 | QString Programm = QMK_Dir + "/QMK-Voice"; |
470 | 486 | ||
471 | QStringList Argumente; |
487 | QStringList Argumente; |
472 | 488 | ||
473 | o_cVoice = new QProcess(); |
489 | o_cVoice = new QProcess(); |
474 | 490 | ||
475 | Argumente << ""; |
491 | Argumente << ""; |
476 | 492 | ||
477 | o_cVoice->start(Programm, Argumente); // Programmaufruf |
493 | o_cVoice->start(Programm, Argumente); // Programmaufruf |
478 | } |
494 | } |
479 | 495 | ||
480 | void dlg_Main::slot_btn_cLogger() |
496 | void dlg_Main::slot_btn_cLogger() |
481 | { |
497 | { |
482 | QString Programm = QMK_Dir + "/QMK-Logger"; |
498 | QString Programm = QMK_Dir + "/QMK-Logger"; |
483 | 499 | ||
484 | QStringList Argumente; |
500 | QStringList Argumente; |
485 | 501 | ||
486 | o_cLogger = new QProcess(); |
502 | o_cLogger = new QProcess(); |
487 | 503 | ||
488 | Argumente << ""; |
504 | Argumente << ""; |
489 | 505 | ||
490 | o_cLogger->start(Programm, Argumente); // Programmaufruf |
506 | o_cLogger->start(Programm, Argumente); // Programmaufruf |
491 | } |
507 | } |
492 | 508 | ||
493 | void dlg_Main::slot_btn_Terminal() |
509 | void dlg_Main::slot_btn_Terminal() |
494 | { |
510 | { |
495 | if (!f_Terminal->isVisible()) |
511 | if (!f_Terminal->isVisible()) |
496 | { |
512 | { |
497 | f_Terminal->show(); |
513 | f_Terminal->show(); |
498 | } |
514 | } |
499 | } |
515 | } |
500 | 516 | ||
501 | // Verbindung herstellen zum Datenserver |
517 | // Verbindung herstellen zum Datenserver |
502 | void dlg_Main::slot_btn_ConnectServer() |
518 | void dlg_Main::slot_btn_ConnectServer() |
503 | { |
519 | { |
504 | if (!o_Output->IsOpen()) |
520 | if (!o_Output->IsOpen()) |
505 | { |
521 | { |
506 | Con_Output = Con_Server[0]; |
522 | Con_Output = Con_Server[0]; |
507 | 523 | ||
508 | s_Output.Main = "127.0.0.1";//Server[0]; |
524 | s_Output.Main = o_Settings->LIVEDATA.Server;//Server[0]; |
509 | s_Output.Sub = "64410";//Server[1]; |
525 | s_Output.Sub = o_Settings->LIVEDATA.Port;//Server[1]; |
510 | 526 | ||
511 | o_Output = new Input_TCP(); |
527 | o_Output = new Input_TCP(); |
512 | o_Output->Init(); |
528 | o_Output->Init(); |
513 | 529 | ||
514 | if (o_Output->Open(s_Output) == true) |
530 | if (o_Output->Open(s_Output) == true) |
515 | { |
531 | { |
516 | connect(o_Output, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Output_Disconnected(int))); |
532 | connect(o_Output, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Output_Disconnected(int))); |
517 | connect(o_Output, SIGNAL(sig_Connected()), this, SLOT(slot_Output_Connected())); |
533 | connect(o_Output, SIGNAL(sig_Connected()), this, SLOT(slot_Output_Connected())); |
518 | } |
534 | } |
519 | btn_ConnectServer->setText(tr("Trenne Server")); |
535 | btn_ConnectServer->setText(tr("Trenne Server")); |
520 | Con_Output.Status = 1; |
536 | Con_Output.Status = 1; |
521 | } |
537 | } |
522 | else |
538 | else |
523 | { |
539 | { |
524 | btn_ConnectServer->setText(tr("Verbinde Server")); |
540 | btn_ConnectServer->setText(tr("Verbinde Server")); |
525 | 541 | ||
526 | o_Output->Close(); |
542 | o_Output->Close(); |
527 | disconnect(o_Output, SIGNAL(sig_NewData(QString)), 0, 0); |
543 | disconnect(o_Output, SIGNAL(sig_NewData(QString)), 0, 0); |
528 | if (o_Output->Mode() == TCP) |
544 | if (o_Output->Mode() == TCP) |
529 | { |
545 | { |
530 | disconnect(o_Output, SIGNAL(sig_Disconnected(int)), 0, 0); |
546 | disconnect(o_Output, SIGNAL(sig_Disconnected(int)), 0, 0); |
531 | disconnect(o_Output, SIGNAL(sig_Connected()), 0, 0); |
547 | disconnect(o_Output, SIGNAL(sig_Connected()), 0, 0); |
532 | } |
548 | } |
533 | } |
549 | } |
534 | } |
550 | } |
535 | 551 | ||
- | 552 | void dlg_Main::slot_btn_Debug() |
|
- | 553 | { |
|
- | 554 | if (o_Output->IsOpen()) |
|
- | 555 | { |
|
- | 556 | o_Output->send_Data("#cO=M======wWMrSCuD==A===============================================A=GM======[M=====@==@|p==O=CM=========kN"); |
|
- | 557 | } |
|
- | 558 | } |
|
- | 559 | ||
536 | void dlg_Main::slot_Output_Disconnected(int Error) |
560 | void dlg_Main::slot_rb_Hardware() |
- | 561 | { |
|
- | 562 | // if ((rb_NC->isChecked() == false) && (VersionInfo.ID != ADDRESS_NC)) |
|
- | 563 | // { |
|
- | 564 | // o_Input->send_Data(HandlerMK::get_SelectNC()); |
|
- | 565 | // } |
|
- | 566 | ||
- | 567 | if (rb_FC->isChecked()) |
|
- | 568 | { |
|
- | 569 | o_Input->send_Data(HandlerMK::get_SelectFC()); |
|
- | 570 | } |
|
537 | { |
571 | else |
- | 572 | if (rb_MK3MAG->isChecked()) |
|
- | 573 | { |
|
- | 574 | o_Input->send_Data(HandlerMK::get_SelectMK3MAG()); |
|
- | 575 | } |
|
538 | // cb_Server->setEnabled(true); |
576 | else |
- | 577 | if (rb_NC->isChecked()) |
|
- | 578 | { |
|
- | 579 | o_Input->send_Data(HandlerMK::get_SelectNC()); |
|
- | 580 | } |
|
- | 581 | ||
- | 582 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
|
- | 583 | } |
|
- | 584 | ||
539 | // le_Password->setEnabled(true); |
585 | void dlg_Main::slot_Output_Disconnected(int Error) |
540 | 586 | { |
|
541 | disconnect(o_Output, SIGNAL(sig_NewData(QString)), 0, 0); |
587 | disconnect(o_Output, SIGNAL(sig_NewData(QString)), 0, 0); |
542 | if (o_Output->Mode() == TCP) |
588 | if (o_Output->Mode() == TCP) |
543 | { |
589 | { |
544 | disconnect(o_Output, SIGNAL(sig_Disconnected(int)), 0, 0); |
590 | disconnect(o_Output, SIGNAL(sig_Disconnected(int)), 0, 0); |
545 | disconnect(o_Output, SIGNAL(sig_Connected()), 0, 0); |
591 | disconnect(o_Output, SIGNAL(sig_Connected()), 0, 0); |
546 | } |
592 | } |
547 | 593 | ||
548 | btn_ConnectServer->setText(tr("Verbinde Server")); |
594 | btn_ConnectServer->setText(tr("Verbinde Server")); |
549 | 595 | ||
550 | /* switch (Error) |
596 | /* switch (Error) |
551 | { |
597 | { |
552 | case REMOTECLOSED : |
598 | case REMOTECLOSED : |
553 | { |
599 | { |
554 | // lb_Status->setText(tr("Verbindung vom Server beendet.")); |
600 | // lb_Status->setText(tr("Verbindung vom Server beendet.")); |
555 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
601 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
556 | } |
602 | } |
557 | break; |
603 | break; |
558 | case REFUSED : |
604 | case REFUSED : |
559 | { |
605 | { |
560 | // lb_Status->setText(tr("Server nicht gefunden.")); |
606 | // lb_Status->setText(tr("Server nicht gefunden.")); |
561 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
607 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
562 | } |
608 | } |
563 | break; |
609 | break; |
564 | case 3 : |
610 | case 3 : |
565 | { |
611 | { |
566 | // lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
612 | // lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
567 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
613 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
568 | } |
614 | } |
569 | break; |
615 | break; |
570 | default : |
616 | default : |
571 | { |
617 | { |
572 | // lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
618 | // lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
573 | } |
619 | } |
574 | break; |
620 | break; |
575 | } |
621 | } |
576 | */ |
622 | */ |
577 | 623 | ||
578 | } |
624 | } |
579 | 625 | ||
580 | void dlg_Main::slot_Output_Connected() |
626 | void dlg_Main::slot_Output_Connected() |
581 | { |
627 | { |
582 | connect(o_Output, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Output_Data(QString))); |
628 | connect(o_Output, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Output_Data(QString))); |
583 | - | ||
584 | // o_Output->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
- | |
585 | // o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
- | |
586 | // btn_Connect->setText(tr("Trennen")); |
- | |
587 | } |
629 | } |
588 | 630 | ||
589 | void dlg_Main::slot_Output_Data(QString t_Data) |
631 | void dlg_Main::slot_Output_Data(QString t_Data) |
590 | { |
632 | { |
591 | if ((t_Data[0] == '#')) |
633 | if ((t_Data[0] == '#')) |
592 | { |
634 | { |
593 | } |
635 | } |
594 | else if (o_Output->Mode() == TCP) |
636 | else if (o_Output->Mode() == TCP) |
595 | { |
637 | { |
596 | show_Terminal(6, t_Data); |
638 | show_Terminal(6, "IP:" + t_Data); |
597 | parse_TCP_Output_Data(t_Data); |
639 | parse_TCP_Output_Data(t_Data); |
598 | } |
640 | } |
599 | } |
641 | } |
600 | 642 | ||
601 | // Verbindung herstellen zum Kopter |
643 | // Verbindung herstellen zum Kopter |
602 | void dlg_Main::slot_btn_Connect() |
644 | void dlg_Main::slot_btn_Connect() |
603 | { |
645 | { |
604 | if (!o_Input->IsOpen()) |
646 | if (!o_Input->IsOpen()) |
605 | { |
647 | { |
606 | if (rb_Device->isChecked()) |
648 | if (rb_Device->isChecked()) |
607 | { |
649 | { |
608 | if (cb_Device->findText(cb_Device->currentText()) == -1) |
650 | if (cb_Device->findText(cb_Device->currentText()) == -1) |
609 | { |
651 | { |
610 | cb_Device->addItem(cb_Device->currentText()); |
652 | cb_Device->addItem(cb_Device->currentText()); |
611 | cb_Device->setCurrentIndex(cb_Device->findText(cb_Device->currentText())); |
653 | cb_Device->setCurrentIndex(cb_Device->findText(cb_Device->currentText())); |
612 | } |
654 | } |
613 | 655 | ||
614 | s_Input.Main = cb_Device->currentText(); |
656 | s_Input.Main = cb_Device->currentText(); |
615 | 657 | ||
616 | o_Input = new Input_TTY(); |
658 | o_Input = new Input_TTY(); |
617 | o_Input->Init(); |
659 | o_Input->Init(); |
618 | 660 | ||
619 | if (o_Input->Open(s_Input) == true) |
661 | if (o_Input->Open(s_Input) == true) |
620 | { |
662 | { |
621 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
663 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
622 | 664 | ||
623 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
665 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
624 | 666 | ||
625 | btn_Connect->setText(tr("Trennen")); |
667 | btn_Connect->setText(tr("Trennen")); |
626 | cb_Device->setEnabled(false); |
668 | cb_Device->setEnabled(false); |
627 | } |
669 | } |
628 | } |
670 | } |
629 | else if (rb_TCP->isChecked()) |
671 | else if (rb_TCP->isChecked()) |
630 | { |
672 | { |
631 | if (cb_Server->findText(cb_Device->currentText()) == -1) |
673 | if (cb_Server->findText(cb_Device->currentText()) == -1) |
632 | { |
674 | { |
633 | cb_Server->addItem(cb_Server->currentText()); |
675 | cb_Server->addItem(cb_Server->currentText()); |
634 | cb_Server->setCurrentIndex(cb_Server->findText(cb_Server->currentText())); |
676 | cb_Server->setCurrentIndex(cb_Server->findText(cb_Server->currentText())); |
635 | } |
677 | } |
636 | 678 | ||
637 | cb_Server->setEnabled(false); |
679 | cb_Server->setEnabled(false); |
638 | le_Password->setEnabled(false); |
680 | le_Password->setEnabled(false); |
639 | 681 | ||
640 | o_Input = new Input_TCP(); |
682 | o_Input = new Input_TCP(); |
641 | o_Input->Init(); |
683 | o_Input->Init(); |
642 | 684 | ||
643 | set_Input s_Input; |
685 | set_Input s_Input; |
644 | 686 | ||
645 | QStringList Server = cb_Server->currentText().split(":"); |
687 | QStringList Server = cb_Server->currentText().split(":"); |
646 | 688 | ||
647 | s_Input.Main = Server[0]; |
689 | s_Input.Main = Server[0]; |
648 | s_Input.Sub = Server[1]; |
690 | s_Input.Sub = Server[1]; |
649 | 691 | ||
650 | if (o_Input->Open(s_Input) == true) |
692 | if (o_Input->Open(s_Input) == true) |
651 | { |
693 | { |
652 | connect(o_Input, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Input_Disconnected(int))); |
694 | connect(o_Input, SIGNAL(sig_Disconnected(int)), this, SLOT(slot_Input_Disconnected(int))); |
653 | connect(o_Input, SIGNAL(sig_Connected()), this, SLOT(slot_Input_Connected())); |
695 | connect(o_Input, SIGNAL(sig_Connected()), this, SLOT(slot_Input_Connected())); |
654 | } |
696 | } |
655 | } |
697 | } |
656 | 698 | ||
657 | } |
699 | } |
658 | else |
700 | else |
659 | { |
701 | { |
660 | { |
702 | { |
661 | cb_Device->setEnabled(true); |
703 | cb_Device->setEnabled(true); |
662 | cb_Server->setEnabled(true); |
704 | cb_Server->setEnabled(true); |
663 | le_Password->setEnabled(true); |
705 | le_Password->setEnabled(true); |
664 | 706 | ||
665 | o_Input->Close(); |
707 | o_Input->Close(); |
666 | btn_Connect->setText(tr("Verbinden")); |
708 | btn_Connect->setText(tr("Verbinden")); |
667 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
709 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
668 | if (o_Input->Mode() == TCP) |
710 | if (o_Input->Mode() == TCP) |
669 | { |
711 | { |
670 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
712 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
671 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
713 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
672 | } |
714 | } |
673 | } |
715 | } |
674 | } |
716 | } |
675 | } |
717 | } |
676 | 718 | ||
677 | // Neue Daten empfangen. |
719 | // Neue Daten empfangen. |
678 | void dlg_Main::slot_Input_Data(QString t_Data) |
720 | void dlg_Main::slot_Input_Data(QString t_Data) |
679 | { |
721 | { |
680 | if ((t_Data[0] == '#')) |
722 | if ((t_Data[0] == '#')) |
681 | { |
723 | { |
682 | 724 | ||
683 | if ((HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length() - 1)) || ((o_Input->Mode() == TTY) && (HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length())))) |
725 | if ((HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length() - 1)) || ((o_Input->Mode() == TTY) && (HandlerMK::Check_CRC(t_Data.toLatin1().data(), t_Data.length())))) |
684 | { |
726 | { |
685 | show_Terminal(1, "MK: " + t_Data); |
727 | show_Terminal(1, "MK: " + t_Data); |
686 | parse_Input_Data(t_Data); |
728 | parse_Input_Data(t_Data); |
687 | route_Input_Data(t_Data); |
729 | route_Input_Data(t_Data); |
688 | } |
730 | } |
689 | else |
731 | else |
690 | { |
732 | { |
691 | show_Terminal(2, t_Data); |
733 | show_Terminal(2, t_Data); |
692 | } |
734 | } |
693 | } |
735 | } |
694 | else if ((o_Input->Mode() == TCP) && (t_Data[0] == '$')) |
736 | else if ((o_Input->Mode() == TCP) && (t_Data[0] == '$')) |
695 | { |
737 | { |
696 | show_Terminal(4, t_Data); |
738 | show_Terminal(4, t_Data); |
697 | parse_TCP_Input_Data(t_Data); |
739 | parse_TCP_Input_Data(t_Data); |
698 | } |
740 | } |
699 | else |
741 | else |
700 | { |
742 | { |
701 | show_Terminal(2, t_Data); |
743 | show_Terminal(2, t_Data); |
702 | } |
744 | } |
703 | 745 | ||
704 | 746 | ||
705 | } |
747 | } |
706 | 748 | ||
707 | void dlg_Main::slot_Input_Disconnected(int Error) |
749 | void dlg_Main::slot_Input_Disconnected(int Error) |
708 | { |
750 | { |
709 | cb_Server->setEnabled(true); |
751 | cb_Server->setEnabled(true); |
710 | le_Password->setEnabled(true); |
752 | le_Password->setEnabled(true); |
711 | 753 | ||
712 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
754 | disconnect(o_Input, SIGNAL(sig_NewData(QString)), 0, 0); |
713 | if (o_Input->Mode() == TCP) |
755 | if (o_Input->Mode() == TCP) |
714 | { |
756 | { |
715 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
757 | disconnect(o_Input, SIGNAL(sig_Disconnected(int)), 0, 0); |
716 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
758 | disconnect(o_Input, SIGNAL(sig_Connected()), 0, 0); |
717 | } |
759 | } |
718 | 760 | ||
719 | btn_Connect->setText(tr("Verbinden")); |
761 | btn_Connect->setText(tr("Verbinden")); |
720 | 762 | ||
721 | /* switch (Error) |
763 | /* switch (Error) |
722 | { |
764 | { |
723 | case REMOTECLOSED : |
765 | case REMOTECLOSED : |
724 | { |
766 | { |
725 | // lb_Status->setText(tr("Verbindung vom Server beendet.")); |
767 | // lb_Status->setText(tr("Verbindung vom Server beendet.")); |
726 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
768 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Verbindung wurde vom Server beendet."), QMessageBox::Ok); |
727 | } |
769 | } |
728 | break; |
770 | break; |
729 | case REFUSED : |
771 | case REFUSED : |
730 | { |
772 | { |
731 | // lb_Status->setText(tr("Server nicht gefunden.")); |
773 | // lb_Status->setText(tr("Server nicht gefunden.")); |
732 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
774 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Kann nicht zum Server verbinden."), QMessageBox::Ok); |
733 | } |
775 | } |
734 | break; |
776 | break; |
735 | case 3 : |
777 | case 3 : |
736 | { |
778 | { |
737 | // lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
779 | // lb_Status->setText(tr("Serververbindung getrennt. Logindaten falsch.")); |
738 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
780 | QMessageBox::warning(this, QA_NAME,tr("QMK-Datenserver: Loginname oder Password falsch."), QMessageBox::Ok); |
739 | } |
781 | } |
740 | break; |
782 | break; |
741 | default : |
783 | default : |
742 | { |
784 | { |
743 | // lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
785 | // lb_Status->setText(tr("Getrennt vom QMK-Datenserver.")); |
744 | } |
786 | } |
745 | break; |
787 | break; |
746 | } |
788 | } |
747 | */ |
789 | */ |
748 | 790 | ||
749 | } |
791 | } |
750 | 792 | ||
751 | void dlg_Main::slot_Input_Connected() |
793 | void dlg_Main::slot_Input_Connected() |
752 | { |
794 | { |
753 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
795 | connect(o_Input, SIGNAL(sig_NewData(QString)), this, SLOT(slot_Input_Data(QString))); |
754 | 796 | ||
755 | o_Input->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
797 | o_Input->send_Data(HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
756 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
798 | o_Input->send_Data(HandlerMK::make_Frame('v', 0, c_Data, 0).toLatin1().data(), DATA_VERSION); |
757 | btn_Connect->setText(tr("Trennen")); |
799 | btn_Connect->setText(tr("Trennen")); |
758 | } |
800 | } |
759 | 801 | ||
760 | // About-Dialog |
802 | // About-Dialog |
761 | void dlg_Main::slot_ac_About() |
803 | void dlg_Main::slot_ac_About() |
762 | { |
804 | { |
763 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
805 | QMessageBox::about(this, trUtf8(("Über ")) + QA_NAME, QA_ABOUT); |
764 | } |
806 | } |
765 | 807 | ||
766 | void dlg_Main::slot_ac_Server() |
808 | void dlg_Main::slot_ac_Server() |
767 | { |
809 | { |
768 | dlg_Preferences *f_Preferences = new dlg_Preferences(this); |
810 | dlg_Preferences *f_Preferences = new dlg_Preferences(this); |
769 | 811 | ||
770 | f_Preferences->set_Settings(o_Settings); |
812 | f_Preferences->set_Settings(o_Settings); |
771 | 813 | ||
772 | if (f_Preferences->exec()==QDialog::Accepted) |
814 | if (f_Preferences->exec()==QDialog::Accepted) |
773 | { |
815 | { |
774 | o_Settings = f_Preferences->get_Settings(); |
816 | o_Settings = f_Preferences->get_Settings(); |
775 | o_Settings->write_Settings(); |
817 | o_Settings->write_Settings(); |
776 | } |
818 | } |
777 | } |
819 | } |
778 | 820 | ||
779 | void dlg_Main::show_Terminal(int t_Typ, QString t_Data) |
821 | void dlg_Main::show_Terminal(int t_Typ, QString t_Data) |
780 | { |
822 | { |
781 | if (f_Terminal->isVisible()) |
823 | if (f_Terminal->isVisible()) |
782 | { |
824 | { |
783 | f_Terminal->show_Data(t_Typ, t_Data); |
825 | f_Terminal->show_Data(t_Typ, t_Data); |
784 | } |
826 | } |
785 | } |
827 | } |
786 | 828 | ||
787 | ///////////////////// |
829 | ///////////////////// |
788 | // IP-Slots Server // |
830 | // IP-Slots Server // |
789 | ///////////////////// |
831 | ///////////////////// |
790 | 832 | ||
791 | void dlg_Main::slot_TCP_NewConnection() |
833 | void dlg_Main::slot_TCP_NewConnection() |
792 | { |
834 | { |
793 | if (!o_Input->IsOpen()) |
835 | if (!o_Input->IsOpen()) |
794 | { |
836 | { |
795 | slot_btn_Connect(); |
837 | slot_btn_Connect(); |
796 | } |
838 | } |
797 | 839 | ||
798 | int ID = get_FreeSocket(); |
840 | int ID = get_FreeSocket(); |
799 | 841 | ||
800 | if (ID != 0) |
842 | if (ID != 0) |
801 | { |
843 | { |
802 | Connect_Count++; |
844 | Connect_Count++; |
803 | 845 | ||
804 | // Leeres Con_Server erzeugen |
846 | // Leeres Con_Server erzeugen |
805 | Con_Server[ID] = Con_Server[0]; |
847 | Con_Server[ID] = Con_Server[0]; |
806 | 848 | ||
807 | Con_Server[ID].Status = 1; |
849 | Con_Server[ID].Status = 1; |
808 | Con_Server[ID].TCP = true; |
850 | Con_Server[ID].TCP = true; |
809 | 851 | ||
810 | Con_Server[ID].Fields = ""; |
852 | Con_Server[ID].Fields = ""; |
811 | Con_Server[ID].Version = "n/a"; |
853 | Con_Server[ID].Version = "n/a"; |
812 | 854 | ||
813 | o_TCP[ID] = TCP_Server->nextPendingConnection(); |
855 | o_TCP[ID] = TCP_Server->nextPendingConnection(); |
814 | o_TCP[ID]->setProperty("ID", ID); |
856 | o_TCP[ID]->setProperty("ID", ID); |
815 | 857 | ||
816 | send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
858 | send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 101, QA_NAME + " " + QA_VERSION)); |
817 | 859 | ||
818 | connect(o_TCP[ID], SIGNAL(disconnected()),o_TCP[ID], SLOT(deleteLater())); |
860 | connect(o_TCP[ID], SIGNAL(disconnected()),o_TCP[ID], SLOT(deleteLater())); |
819 | connect(o_TCP[ID], SIGNAL(disconnected()),this, SLOT(slot_TCP_Disconnect())); |
861 | connect(o_TCP[ID], SIGNAL(disconnected()),this, SLOT(slot_TCP_Disconnect())); |
820 | connect(o_TCP[ID], SIGNAL(readyRead()),this, SLOT(slot_TCP_Read())); |
862 | connect(o_TCP[ID], SIGNAL(readyRead()),this, SLOT(slot_TCP_Read())); |
821 | 863 | ||
822 | Item[ID]->setText(" " + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - n/a"); |
864 | Item[ID]->setText(" " + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - n/a"); |
823 | lw_Clients->addItem(Item[ID]); |
865 | lw_Clients->addItem(Item[ID]); |
824 | 866 | ||
825 | if (o_TCP[ID]->peerAddress().toString() == "127.0.0.1") |
867 | if (o_TCP[ID]->peerAddress().toString() == "127.0.0.1") |
826 | { |
868 | { |
827 | Con_Server[ID].Status = 2; |
869 | Con_Server[ID].Status = 2; |
828 | Item[ID]->setText("*" + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - n/a"); |
870 | Item[ID]->setText("*" + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - n/a"); |
829 | } |
871 | } |
830 | 872 | ||
831 | if (o_Input->IsOpen()) |
873 | if (o_Input->IsOpen()) |
832 | { |
874 | { |
833 | // send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 520, cb_Device->currentText())); |
875 | // send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 520, cb_Device->currentText())); |
834 | } |
876 | } |
835 | 877 | ||
836 | } |
878 | } |
837 | else // Server voll |
879 | else // Server voll |
838 | { |
880 | { |
839 | o_TCP[ID] = TCP_Server->nextPendingConnection(); |
881 | o_TCP[ID] = TCP_Server->nextPendingConnection(); |
840 | o_TCP[ID]->setProperty("ID", ID); |
882 | o_TCP[ID]->setProperty("ID", ID); |
841 | 883 | ||
842 | send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 521, "Sorry, Server full.")); |
884 | send_TCP(o_TCP[ID],HandlerIP::make_Frame(ID_COMMUNICATOR, 521, "Sorry, Server full.")); |
843 | o_TCP[ID]->disconnectFromHost(); |
885 | o_TCP[ID]->disconnectFromHost(); |
844 | } |
886 | } |
845 | } |
887 | } |
846 | 888 | ||
847 | void dlg_Main::slot_TCP_Read() |
889 | void dlg_Main::slot_TCP_Read() |
848 | { |
890 | { |
849 | QTcpSocket *Socket = (QTcpSocket*)sender(); |
891 | QTcpSocket *Socket = (QTcpSocket*)sender(); |
850 | 892 | ||
851 | // if (Socket->canReadLine()) |
893 | // if (Socket->canReadLine()) |
852 | { |
894 | { |
853 | int ID = Socket->property("ID").toUInt(); |
895 | int ID = Socket->property("ID").toUInt(); |
854 | ID = ID; |
896 | ID = ID; |
855 | 897 | ||
856 | // QString t_Data = QString(TCP_Socket->readLine(TCP_Socket->bytesAvailable())).remove(QChar('\n')); |
898 | // QString t_Data = QString(TCP_Socket->readLine(TCP_Socket->bytesAvailable())).remove(QChar('\n')); |
857 | QString t_Data = s_Buffer + QString(Socket->readAll()); |
899 | QString t_Data = s_Buffer + QString(Socket->readAll()).remove(QChar('\n')); |
858 | s_Buffer = ""; |
900 | s_Buffer = ""; |
- | 901 | ||
- | 902 | t_Data = t_Data.replace('\r', "\r\n"); |
|
859 | 903 | ||
860 | QStringList l_Data = t_Data.split('\n'); |
904 | QStringList l_Data = t_Data.split('\n'); |
861 | 905 | ||
862 | for (int z = 0; z < l_Data.count(); z++) |
906 | for (int z = 0; z < l_Data.count(); z++) |
863 | { |
907 | { |
864 | if ((l_Data[z][l_Data[z].length() - 1] == '\r')) |
908 | if ((l_Data[z][l_Data[z].length() - 1] == '\r')) |
865 | { |
909 | { |
866 | l_Data[z].remove(QChar('\r')); |
910 | l_Data[z].remove(QChar('\r')); |
867 | if (l_Data[z][0] == '$') |
911 | if (l_Data[z][0] == '$') |
868 | { |
912 | { |
869 | parse_TCP_Server_Data(l_Data[z], ID); |
913 | parse_TCP_Server_Data(l_Data[z], ID); |
870 | show_Terminal(5, "IP: " + l_Data[z]); |
914 | show_Terminal(5, "IP: " + l_Data[z]); |
871 | } |
915 | } |
872 | else |
916 | else |
873 | { |
917 | { |
874 | if ((Con_Server[ID].Status >= 2)) |
918 | if ((Con_Server[ID].Status >= 2)) |
875 | { |
919 | { |
876 | show_Terminal(3, "MK> " + l_Data[z]); |
920 | show_Terminal(3, "MK> " + l_Data[z]); |
877 | o_Input->send_Data(l_Data[z]); |
921 | o_Input->send_Data(l_Data[z]); |
878 | } |
922 | } |
879 | } |
923 | } |
880 | } |
924 | } |
881 | else |
925 | else |
- | 926 | { if (l_Data[z].length() > 1) |
|
882 | { |
927 | { |
883 | qDebug("Ohne Ende"); |
928 | qDebug(QString("Ohne Ende: " + l_Data[z]).toLatin1().data()); |
884 | s_Buffer = s_Buffer + l_Data[z]; |
929 | s_Buffer = s_Buffer + l_Data[z]; |
- | 930 | } |
|
885 | } |
931 | } |
886 | 932 | ||
887 | } |
933 | } |
888 | 934 | ||
889 | /* |
935 | /* |
890 | QString t_Data = QString(Socket->readLine((Socket->bytesAvailable()))); |
936 | QString t_Data = QString(Socket->readLine((Socket->bytesAvailable()))); |
891 | 937 | ||
892 | QStringList s_Data = t_Data.split('\r'); |
938 | QStringList s_Data = t_Data.split('\r'); |
893 | 939 | ||
894 | for (int z = 0; z < s_Data.count() - 1; z++) |
940 | for (int z = 0; z < s_Data.count() - 1; z++) |
895 | { |
941 | { |
896 | if (s_Data[z][0] == '$') |
942 | if (s_Data[z][0] == '$') |
897 | { |
943 | { |
898 | parse_TCP_Server_Data(s_Data[z], ID); |
944 | parse_TCP_Server_Data(s_Data[z], ID); |
899 | show_Terminal(5, "IP: " + s_Data[z]); |
945 | show_Terminal(5, "IP: " + s_Data[z]); |
900 | 946 | ||
901 | } |
947 | } |
902 | else |
948 | else |
903 | { |
949 | { |
904 | if ((Con_Server[ID].Status >= 2)) |
950 | if ((Con_Server[ID].Status >= 2)) |
905 | { |
951 | { |
906 | show_Terminal(3, s_Data[z]); |
952 | show_Terminal(3, s_Data[z]); |
907 | o_Input->send_Data(s_Data[z]); |
953 | o_Input->send_Data(s_Data[z]); |
908 | } |
954 | } |
909 | } |
955 | } |
910 | } |
956 | } |
911 | } |
957 | } |
912 | */ |
958 | */ |
913 | } |
959 | } |
914 | } |
960 | } |
915 | 961 | ||
916 | void dlg_Main::slot_TCP_Disconnect() |
962 | void dlg_Main::slot_TCP_Disconnect() |
917 | { |
963 | { |
918 | QTcpSocket *Socket = (QTcpSocket*)sender(); |
964 | QTcpSocket *Socket = (QTcpSocket*)sender(); |
919 | 965 | ||
920 | int ID = Socket->property("ID").toUInt(); |
966 | int ID = Socket->property("ID").toUInt(); |
921 | 967 | ||
922 | Item[ID]->setText(" " + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - Disconected"); |
968 | Item[ID]->setText(" " + QString(o_TCP[ID]->peerAddress().toString()).leftJustified(15,' ') + " - Disconected"); |
923 | 969 | ||
924 | Con_Server[ID] = Con_Server[0]; |
970 | Con_Server[ID] = Con_Server[0]; |
925 | Con_Server[ID].Status = 0; |
971 | Con_Server[ID].Status = 0; |
926 | 972 | ||
927 | Connect_Count--; |
973 | Connect_Count--; |
928 | 974 | ||
929 | Socket->setProperty("ID", 0); |
975 | Socket->setProperty("ID", 0); |
930 | 976 | ||
931 | if ((Connect_Count == 0) && (o_Input->IsOpen())) |
977 | if ((Connect_Count == 0) && (o_Input->IsOpen())) |
932 | slot_btn_Connect(); |
978 | slot_btn_Connect(); |
933 | } |
979 | } |
934 | 980 | ||
935 | 981 | ||
936 | // Programm Ende |
982 | // Programm Ende |
937 | //////////////// |
983 | //////////////// |
938 | dlg_Main::~dlg_Main() |
984 | dlg_Main::~dlg_Main() |
939 | { |
985 | { |
940 | o_Settings->GUI.isMax = isMaximized(); |
986 | o_Settings->GUI.isMax = isMaximized(); |
941 | o_Settings->GUI.Size = size(); |
987 | o_Settings->GUI.Size = size(); |
942 | o_Settings->GUI.Point = pos(); |
988 | o_Settings->GUI.Point = pos(); |
- | 989 | ||
- | 990 | // o_Settings->GUI.isMax = isMaximized(); |
|
- | 991 | o_Settings->TERMINAL.Size = f_Terminal->size(); |
|
- | 992 | o_Settings->TERMINAL.Point = f_Terminal->pos(); |
|
943 | 993 | ||
944 | o_Settings->CLIENT.TTY_MAX = cb_Device->count(); |
994 | o_Settings->CLIENT.TTY_MAX = cb_Device->count(); |
945 | o_Settings->CLIENT.TTY_ID = cb_Device->currentIndex(); |
995 | o_Settings->CLIENT.TTY_ID = cb_Device->currentIndex(); |
946 | 996 | ||
947 | for (int z = 0; z < cb_Device->count(); z++) |
997 | for (int z = 0; z < cb_Device->count(); z++) |
948 | { |
998 | { |
949 | if (z < 10) |
999 | if (z < 10) |
950 | { |
1000 | { |
951 | o_Settings->CLIENT.TTY_DEVICES[z] = cb_Device->itemText(z); |
1001 | o_Settings->CLIENT.TTY_DEVICES[z] = cb_Device->itemText(z); |
952 | } |
1002 | } |
953 | } |
1003 | } |
954 | 1004 | ||
955 | o_Settings->CLIENT.TCP_MAX = cb_Server->count(); |
1005 | o_Settings->CLIENT.TCP_MAX = cb_Server->count(); |
956 | o_Settings->CLIENT.TCP_ID = cb_Server->currentIndex(); |
1006 | o_Settings->CLIENT.TCP_ID = cb_Server->currentIndex(); |
957 | 1007 | ||
958 | for (int z = 0; z < cb_Server->count(); z++) |
1008 | for (int z = 0; z < cb_Server->count(); z++) |
959 | { |
1009 | { |
960 | if (z < 10) |
1010 | if (z < 10) |
961 | { |
1011 | { |
962 | o_Settings->CLIENT.TCP_SERVER[z] = cb_Server->itemText(z); |
1012 | o_Settings->CLIENT.TCP_SERVER[z] = cb_Server->itemText(z); |
963 | } |
1013 | } |
964 | } |
1014 | } |
- | 1015 | ||
- | 1016 | o_Settings->DATA.Data = f_Terminal->cb_Data->isChecked(); |
|
- | 1017 | o_Settings->DATA.Info = f_Terminal->cb_Info->isChecked(); |
|
- | 1018 | o_Settings->DATA.Send = f_Terminal->cb_Send->isChecked(); |
|
- | 1019 | o_Settings->DATA.TCP = f_Terminal->cb_TCP->isChecked(); |
|
965 | 1020 | ||
966 | o_Settings->write_Settings(); |
1021 | o_Settings->write_Settings(); |
967 | 1022 | ||
968 | // qDebug("Ende."); |
1023 | // qDebug("Ende."); |
969 | } |
1024 | } |
970 | 1025 |