Subversion Repositories Projects

Rev

Rev 750 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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