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