~ubuntu-branches/ubuntu/vivid/wpasupplicant/vivid

« back to all changes in this revision

Viewing changes to wpa_supplicant/wpa_gui/networkconfig.ui.h

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2008-03-12 20:03:04 UTC
  • mfrom: (1.1.10 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080312200304-4331y9wj46pdd34z
Tags: 0.6.3-1
* New upstream release.
* Drop patches applied upstream:
  - debian/patches/30_wpa_gui_qt4_eventhistoryui_rework.patch
  - debian/patches/31_wpa_gui_qt4_eventhistory_always_scrollbar.patch
  - debian/patches/32_wpa_gui_qt4_eventhistory_scroll_with_events.patch
  - debian/patches/40_dbus_ssid_data.patch
* Tidy up the clean target of debian/rules. Now that the madwifi headers are
  handled differently we no longer need to do any cleanup.
* Fix formatting error in debian/ifupdown/wpa_action.8 to make lintian
  quieter.
* Add patch to fix formatting errors in manpages build from sgml source. Use
  <emphasis> tags to hightlight keywords instead of surrounding them in
  strong quotes.
  - debian/patches/41_manpage_format_fixes.patch
* wpasupplicant binary package no longer suggests pcscd, guessnet, iproute
  or wireless-tools, nor does it recommend dhcp3-client. These are not
  needed.
* Add debian/patches/10_silence_siocsiwauth_icotl_failure.patch to disable
  ioctl failure messages that occur under normal conditions.
* Cherry pick two upstream git commits concerning the dbus interface:
  - debian/patches/11_avoid_dbus_version_namespace.patch
  - debian/patches/12_fix_potential_use_after_free.patch
* Add debian/patches/42_manpage_explain_available_drivers.patch to explain
  that not all of the driver backends are available in the provided
  wpa_supplicant binary, and that the canonical list of supported driver
  backends can be retrieved from the wpa_supplicant -h (help) output.
  (Closes: #466910)
* Add debian/patches/20_wpa_gui_qt4_disable_link_prl.patch to remove
  link_prl CONFIG compile flag added by qmake-qt4 >= 4.3.4-2 to avoid excess
  linking.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
** ui.h extension file, included from the uic-generated form implementation.
 
3
**
 
4
** If you want to add, delete, or rename functions or slots, use
 
5
** Qt Designer to update this file, preserving your code.
 
6
**
 
7
** You should not define a constructor or destructor in this file.
 
8
** Instead, write your code in functions called init() and destroy().
 
9
** These will automatically be called by the form's constructor and
 
10
** destructor.
 
11
*****************************************************************************/
 
12
 
 
13
 
 
14
enum {
 
15
    AUTH_NONE = 0,
 
16
    AUTH_IEEE8021X = 1,
 
17
    AUTH_WPA_PSK = 2,
 
18
    AUTH_WPA_EAP = 3,
 
19
    AUTH_WPA2_PSK = 4,
 
20
    AUTH_WPA2_EAP = 5
 
21
};
 
22
 
 
23
#define WPA_GUI_KEY_DATA "[key is configured]"
 
24
 
 
25
void NetworkConfig::init()
 
26
{
 
27
    wpagui = NULL;
 
28
    new_network = false;
 
29
}
 
30
 
 
31
void NetworkConfig::paramsFromScanResults(Q3ListViewItem *sel)
 
32
{
 
33
    new_network = true;
 
34
 
 
35
    /* SSID BSSID frequency signal flags */
 
36
    setCaption(sel->text(0));
 
37
    ssidEdit->setText(sel->text(0));
 
38
    
 
39
    QString flags = sel->text(4);
 
40
    int auth, encr = 0;
 
41
    if (flags.find("[WPA2-EAP") >= 0)
 
42
        auth = AUTH_WPA2_EAP;
 
43
    else if (flags.find("[WPA-EAP") >= 0)
 
44
        auth = AUTH_WPA_EAP;
 
45
    else if (flags.find("[WPA2-PSK") >= 0)
 
46
        auth = AUTH_WPA2_PSK;
 
47
    else if (flags.find("[WPA-PSK") >= 0)
 
48
        auth = AUTH_WPA_PSK;
 
49
    else
 
50
        auth = AUTH_NONE;
 
51
    
 
52
    if (flags.find("-CCMP") >= 0)
 
53
        encr = 1;
 
54
    else if (flags.find("-TKIP") >= 0)
 
55
        encr = 0;
 
56
    else if (flags.find("WEP") >= 0)
 
57
        encr = 1;
 
58
    else
 
59
        encr = 0;
 
60
 
 
61
    authSelect->setCurrentItem(auth);
 
62
    authChanged(auth);
 
63
    encrSelect->setCurrentItem(encr);
 
64
 
 
65
    getEapCapa();
 
66
}
 
67
 
 
68
 
 
69
void NetworkConfig::authChanged(int sel)
 
70
{
 
71
    pskEdit->setEnabled(sel == AUTH_WPA_PSK || sel == AUTH_WPA2_PSK);
 
72
    bool eap = sel == AUTH_IEEE8021X || sel == AUTH_WPA_EAP ||
 
73
               sel == AUTH_WPA2_EAP;
 
74
    eapSelect->setEnabled(eap);
 
75
    identityEdit->setEnabled(eap);
 
76
    passwordEdit->setEnabled(eap);
 
77
    cacertEdit->setEnabled(eap);
 
78
   
 
79
    while (encrSelect->count())
 
80
        encrSelect->removeItem(0);
 
81
    
 
82
    if (sel == AUTH_NONE || sel == AUTH_IEEE8021X) {
 
83
        encrSelect->insertItem("None");
 
84
        encrSelect->insertItem("WEP");
 
85
        encrSelect->setCurrentItem(sel == AUTH_NONE ? 0 : 1);
 
86
    } else {
 
87
        encrSelect->insertItem("TKIP");
 
88
        encrSelect->insertItem("CCMP");
 
89
        encrSelect->setCurrentItem((sel == AUTH_WPA2_PSK ||
 
90
                                    sel == AUTH_WPA2_EAP) ? 1 : 0);
 
91
    }
 
92
    
 
93
    wepEnabled(sel == AUTH_IEEE8021X);
 
94
}
 
95
 
 
96
 
 
97
void NetworkConfig::addNetwork()
 
98
{
 
99
    char reply[10], cmd[256];
 
100
    size_t reply_len;
 
101
    int id;
 
102
    int psklen = pskEdit->text().length();
 
103
    int auth = authSelect->currentItem();
 
104
 
 
105
    if (auth == AUTH_WPA_PSK || auth == AUTH_WPA2_PSK) {
 
106
        if (psklen < 8 || psklen > 64) {
 
107
            QMessageBox::warning(this, "wpa_gui", "WPA-PSK requires a passphrase "
 
108
                                 "of 8 to 63 characters\n"
 
109
                                 "or 64 hex digit PSK");
 
110
            return;
 
111
        }
 
112
    }
 
113
        
 
114
    if (wpagui == NULL)
 
115
        return;
 
116
    
 
117
    memset(reply, 0, sizeof(reply));
 
118
    reply_len = sizeof(reply) - 1;
 
119
    
 
120
    if (new_network) {
 
121
        wpagui->ctrlRequest("ADD_NETWORK", reply, &reply_len);
 
122
        if (reply[0] == 'F') {
 
123
            QMessageBox::warning(this, "wpa_gui", "Failed to add network to wpa_supplicant\n"
 
124
                                 "configuration.");
 
125
            return;
 
126
        }
 
127
        id = atoi(reply);
 
128
    } else {
 
129
        id = edit_network_id;
 
130
    }
 
131
 
 
132
    setNetworkParam(id, "ssid", ssidEdit->text().ascii(), true);
 
133
    
 
134
    if (idstrEdit->isEnabled())
 
135
        setNetworkParam(id, "id_str", idstrEdit->text().ascii(), true);
 
136
 
 
137
    const char *key_mgmt = NULL, *proto = NULL, *pairwise = NULL;
 
138
    switch (auth) {
 
139
    case AUTH_NONE:
 
140
        key_mgmt = "NONE";
 
141
        break;
 
142
    case AUTH_IEEE8021X:
 
143
        key_mgmt = "IEEE8021X";
 
144
        break;
 
145
    case AUTH_WPA_PSK:
 
146
        key_mgmt = "WPA-PSK";
 
147
        proto = "WPA";
 
148
        break;
 
149
    case AUTH_WPA_EAP:
 
150
        key_mgmt = "WPA-EAP";
 
151
        proto = "WPA";
 
152
        break;
 
153
    case AUTH_WPA2_PSK:
 
154
        key_mgmt = "WPA-PSK";
 
155
        proto = "WPA2";
 
156
        break;
 
157
    case AUTH_WPA2_EAP:
 
158
        key_mgmt = "WPA-EAP";
 
159
        proto = "WPA2";
 
160
        break;
 
161
    }
 
162
    
 
163
    if (auth == AUTH_WPA_PSK || auth == AUTH_WPA_EAP ||
 
164
        auth == AUTH_WPA2_PSK || auth == AUTH_WPA2_EAP) {
 
165
        int encr = encrSelect->currentItem();
 
166
        if (encr == 0)
 
167
            pairwise = "TKIP";
 
168
        else
 
169
            pairwise = "CCMP";
 
170
    }
 
171
    
 
172
    if (proto)
 
173
        setNetworkParam(id, "proto", proto, false);
 
174
    if (key_mgmt)
 
175
        setNetworkParam(id, "key_mgmt", key_mgmt, false);
 
176
    if (pairwise) {
 
177
        setNetworkParam(id, "pairwise", pairwise, false);
 
178
        setNetworkParam(id, "group", "TKIP CCMP WEP104 WEP40", false);
 
179
    }
 
180
    if (pskEdit->isEnabled() &&
 
181
        strcmp(passwordEdit->text().ascii(), WPA_GUI_KEY_DATA) != 0)
 
182
        setNetworkParam(id, "psk", pskEdit->text().ascii(), psklen != 64);
 
183
    if (eapSelect->isEnabled())
 
184
        setNetworkParam(id, "eap", eapSelect->currentText().ascii(), false);
 
185
    if (identityEdit->isEnabled())
 
186
        setNetworkParam(id, "identity", identityEdit->text().ascii(), true);
 
187
    if (passwordEdit->isEnabled() &&
 
188
        strcmp(passwordEdit->text().ascii(), WPA_GUI_KEY_DATA) != 0)
 
189
        setNetworkParam(id, "password", passwordEdit->text().ascii(), true);
 
190
    if (cacertEdit->isEnabled())
 
191
        setNetworkParam(id, "ca_cert", cacertEdit->text().ascii(), true);
 
192
    writeWepKey(id, wep0Edit, 0);
 
193
    writeWepKey(id, wep1Edit, 1);
 
194
    writeWepKey(id, wep2Edit, 2);
 
195
    writeWepKey(id, wep3Edit, 3);
 
196
  
 
197
    if (wep0Radio->isEnabled() && wep0Radio->isChecked())
 
198
        setNetworkParam(id, "wep_tx_keyidx", "0", false);
 
199
    else if (wep1Radio->isEnabled() && wep1Radio->isChecked())
 
200
        setNetworkParam(id, "wep_tx_keyidx", "1", false);
 
201
    else if (wep2Radio->isEnabled() && wep2Radio->isChecked())
 
202
        setNetworkParam(id, "wep_tx_keyidx", "2", false);
 
203
    else if (wep3Radio->isEnabled() && wep3Radio->isChecked())
 
204
        setNetworkParam(id, "wep_tx_keyidx", "3", false);
 
205
 
 
206
    snprintf(cmd, sizeof(cmd), "ENABLE_NETWORK %d", id);
 
207
    reply_len = sizeof(reply);
 
208
    wpagui->ctrlRequest(cmd, reply, &reply_len);
 
209
    if (strncmp(reply, "OK", 2) != 0) {
 
210
        QMessageBox::warning(this, "wpa_gui", "Failed to enable network in wpa_supplicant\n"
 
211
                             "configuration.");
 
212
        /* Network was added, so continue anyway */
 
213
    }
 
214
    wpagui->triggerUpdate();
 
215
    wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
 
216
 
 
217
    close();
 
218
}
 
219
 
 
220
 
 
221
void NetworkConfig::setWpaGui( WpaGui *_wpagui )
 
222
{
 
223
    wpagui = _wpagui;
 
224
}
 
225
 
 
226
 
 
227
int NetworkConfig::setNetworkParam(int id, const char *field, const char *value, bool quote)
 
228
{
 
229
    char reply[10], cmd[256];
 
230
    size_t reply_len;
 
231
    snprintf(cmd, sizeof(cmd), "SET_NETWORK %d %s %s%s%s",
 
232
             id, field, quote ? "\"" : "", value, quote ? "\"" : "");
 
233
    reply_len = sizeof(reply);
 
234
    wpagui->ctrlRequest(cmd, reply, &reply_len);
 
235
    return strncmp(reply, "OK", 2) == 0 ? 0 : -1;
 
236
}
 
237
 
 
238
 
 
239
void NetworkConfig::encrChanged( const QString &sel )
 
240
{
 
241
    wepEnabled(sel.find("WEP") == 0);
 
242
}
 
243
 
 
244
 
 
245
void NetworkConfig::wepEnabled( bool enabled )
 
246
{
 
247
    wep0Edit->setEnabled(enabled);
 
248
    wep1Edit->setEnabled(enabled);
 
249
    wep2Edit->setEnabled(enabled);
 
250
    wep3Edit->setEnabled(enabled);
 
251
    wep0Radio->setEnabled(enabled);
 
252
    wep1Radio->setEnabled(enabled);
 
253
    wep2Radio->setEnabled(enabled);
 
254
    wep3Radio->setEnabled(enabled);
 
255
}
 
256
 
 
257
 
 
258
void NetworkConfig::writeWepKey( int network_id, QLineEdit *edit, int id )
 
259
{
 
260
    char buf[10];
 
261
    bool hex;
 
262
    const char *txt, *pos;
 
263
    size_t len;
 
264
  
 
265
    if (!edit->isEnabled() || edit->text().isEmpty())
 
266
        return;
 
267
    
 
268
    /*
 
269
        * Assume hex key if only hex characters are present and length matches
 
270
       * with 40, 104, or 128-bit key
 
271
       */
 
272
    txt = edit->text().ascii();
 
273
    if (strcmp(txt, WPA_GUI_KEY_DATA) == 0)
 
274
        return;
 
275
    len = strlen(txt);
 
276
    if (len == 0)
 
277
        return;
 
278
    pos = txt;
 
279
    hex = true;
 
280
    while (*pos) {
 
281
        if (!((*pos >= '0' && *pos <= '9') || (*pos >= 'a' && *pos <= 'f') ||
 
282
              (*pos >= 'A' && *pos <= 'F'))) {
 
283
            hex = false;
 
284
            break;
 
285
        }
 
286
        pos++;
 
287
    }
 
288
    if (hex && len != 10 && len != 26 && len != 32)
 
289
        hex = false;
 
290
    snprintf(buf, sizeof(buf), "wep_key%d", id);
 
291
    setNetworkParam(network_id, buf, txt, !hex);
 
292
}
 
293
 
 
294
 
 
295
static int key_value_isset(const char *reply, size_t reply_len)
 
296
{
 
297
    return reply_len > 0 && (reply_len < 4 || memcmp(reply, "FAIL", 4) != 0);
 
298
}
 
299
 
 
300
 
 
301
void NetworkConfig::paramsFromConfig( int network_id )
 
302
{
 
303
    int i, res;
 
304
 
 
305
    edit_network_id = network_id;
 
306
    getEapCapa();
 
307
    
 
308
    char reply[1024], cmd[256], *pos;
 
309
    size_t reply_len;
 
310
    
 
311
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ssid", network_id);
 
312
    reply_len = sizeof(reply) - 1;
 
313
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 2 &&
 
314
        reply[0] == '"') {
 
315
        reply[reply_len] = '\0';
 
316
        pos = strchr(reply + 1, '"');
 
317
        if (pos)
 
318
            *pos = '\0';
 
319
        ssidEdit->setText(reply + 1);
 
320
    }
 
321
 
 
322
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d id_str", network_id);
 
323
    reply_len = sizeof(reply) - 1;
 
324
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 2 &&
 
325
        reply[0] == '"') {
 
326
        reply[reply_len] = '\0';
 
327
        pos = strchr(reply + 1, '"');
 
328
        if (pos)
 
329
            *pos = '\0';
 
330
        idstrEdit->setText(reply + 1);
 
331
    }
 
332
    
 
333
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d proto", network_id);
 
334
    reply_len = sizeof(reply) - 1;
 
335
    int wpa = 0;
 
336
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
 
337
        reply[reply_len] = '\0';
 
338
        if (strstr(reply, "RSN") || strstr(reply, "WPA2"))
 
339
            wpa = 2;
 
340
        else if (strstr(reply, "WPA"))
 
341
            wpa = 1;
 
342
    }
 
343
 
 
344
    int auth = AUTH_NONE, encr = 0;
 
345
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d key_mgmt", network_id);
 
346
    reply_len = sizeof(reply) - 1;
 
347
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
 
348
        reply[reply_len] = '\0';
 
349
        if (strstr(reply, "WPA-EAP"))
 
350
            auth = wpa & 2 ? AUTH_WPA2_EAP : AUTH_WPA_EAP;
 
351
        else if (strstr(reply, "WPA-PSK"))
 
352
            auth = wpa & 2 ? AUTH_WPA2_PSK : AUTH_WPA_PSK;
 
353
        else if (strstr(reply, "IEEE8021X")) {
 
354
            auth = AUTH_IEEE8021X;
 
355
            encr = 1;
 
356
        }
 
357
    }
 
358
 
 
359
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d pairwise", network_id);
 
360
    reply_len = sizeof(reply) - 1;
 
361
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0) {
 
362
        reply[reply_len] = '\0';
 
363
        if (strstr(reply, "CCMP") && auth != AUTH_NONE)
 
364
            encr = 1;
 
365
        else if (strstr(reply, "TKIP"))
 
366
            encr = 0;
 
367
        else if (strstr(reply, "WEP"))
 
368
            encr = 1;
 
369
        else
 
370
            encr = 0;
 
371
    }
 
372
 
 
373
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d psk", network_id);
 
374
    reply_len = sizeof(reply) - 1;
 
375
    res = wpagui->ctrlRequest(cmd, reply, &reply_len);
 
376
    if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
 
377
        reply[reply_len] = '\0';
 
378
        pos = strchr(reply + 1, '"');
 
379
        if (pos)
 
380
            *pos = '\0';
 
381
        pskEdit->setText(reply + 1);
 
382
    } else if (res >= 0 && key_value_isset(reply, reply_len)) {
 
383
        pskEdit->setText(WPA_GUI_KEY_DATA);
 
384
    }
 
385
 
 
386
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d identity", network_id);
 
387
    reply_len = sizeof(reply) - 1;
 
388
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 2 &&
 
389
        reply[0] == '"') {
 
390
        reply[reply_len] = '\0';
 
391
        pos = strchr(reply + 1, '"');
 
392
        if (pos)
 
393
            *pos = '\0';
 
394
        identityEdit->setText(reply + 1);
 
395
    }
 
396
 
 
397
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d password", network_id);
 
398
    reply_len = sizeof(reply) - 1;
 
399
    res = wpagui->ctrlRequest(cmd, reply, &reply_len);
 
400
    if (res >= 0 && reply_len >= 2 &&
 
401
        reply[0] == '"') {
 
402
        reply[reply_len] = '\0';
 
403
        pos = strchr(reply + 1, '"');
 
404
        if (pos)
 
405
            *pos = '\0';
 
406
        passwordEdit->setText(reply + 1);
 
407
    } else if (res >= 0 && key_value_isset(reply, reply_len)) {
 
408
        passwordEdit->setText(WPA_GUI_KEY_DATA);
 
409
    }
 
410
 
 
411
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d ca_cert", network_id);
 
412
    reply_len = sizeof(reply) - 1;
 
413
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 2 &&
 
414
        reply[0] == '"') {
 
415
        reply[reply_len] = '\0';
 
416
        pos = strchr(reply + 1, '"');
 
417
        if (pos)
 
418
            *pos = '\0';
 
419
        cacertEdit->setText(reply + 1);
 
420
    }
 
421
 
 
422
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d eap", network_id);
 
423
    reply_len = sizeof(reply) - 1;
 
424
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1) {
 
425
        reply[reply_len] = '\0';
 
426
        for (i = 0; i < eapSelect->count(); i++) {
 
427
            if (eapSelect->text(i).compare(reply) == 0) {
 
428
                eapSelect->setCurrentItem(i);
 
429
                break;
 
430
            }
 
431
        }
 
432
    }
 
433
 
 
434
    for (i = 0; i < 4; i++) {
 
435
        QLineEdit *wepEdit;
 
436
        switch (i) {
 
437
        default:
 
438
        case 0:
 
439
            wepEdit = wep0Edit;
 
440
            break;
 
441
        case 1:
 
442
            wepEdit = wep1Edit;
 
443
            break;
 
444
        case 2:
 
445
            wepEdit = wep2Edit;
 
446
            break;
 
447
        case 3:
 
448
            wepEdit = wep3Edit;
 
449
            break;
 
450
        }
 
451
        snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_key%d", network_id, i);
 
452
        reply_len = sizeof(reply) - 1;
 
453
        res = wpagui->ctrlRequest(cmd, reply, &reply_len);
 
454
        if (res >= 0 && reply_len >= 2 && reply[0] == '"') {
 
455
            reply[reply_len] = '\0';
 
456
            pos = strchr(reply + 1, '"');
 
457
            if (pos)
 
458
                *pos = '\0';
 
459
            if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
 
460
                encr = 1;
 
461
 
 
462
            wepEdit->setText(reply + 1);
 
463
        } else if (res >= 0 && key_value_isset(reply, reply_len)) {
 
464
            if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
 
465
                encr = 1;
 
466
            wepEdit->setText(WPA_GUI_KEY_DATA);
 
467
        }
 
468
    }
 
469
 
 
470
    snprintf(cmd, sizeof(cmd), "GET_NETWORK %d wep_tx_keyidx", network_id);
 
471
    reply_len = sizeof(reply) - 1;
 
472
    if (wpagui->ctrlRequest(cmd, reply, &reply_len) >= 0 && reply_len >= 1) {
 
473
        reply[reply_len] = '\0';
 
474
        switch (atoi(reply)) {
 
475
        case 0:
 
476
            wep0Radio->setChecked(true);
 
477
            break;
 
478
        case 1:
 
479
            wep1Radio->setChecked(true);
 
480
            break;
 
481
        case 2:
 
482
            wep2Radio->setChecked(true);
 
483
            break;
 
484
        case 3:
 
485
            wep3Radio->setChecked(true);
 
486
            break;
 
487
        }
 
488
    }
 
489
 
 
490
    authSelect->setCurrentItem(auth);
 
491
    authChanged(auth);
 
492
    encrSelect->setCurrentItem(encr);
 
493
    if (auth == AUTH_NONE || auth == AUTH_IEEE8021X)
 
494
        wepEnabled(encr == 1);
 
495
 
 
496
    removeButton->setEnabled(true);
 
497
    addButton->setText("Save");
 
498
}
 
499
 
 
500
 
 
501
void NetworkConfig::removeNetwork()
 
502
{
 
503
    char reply[10], cmd[256];
 
504
    size_t reply_len;
 
505
    
 
506
    if (QMessageBox::information(this, "wpa_gui",
 
507
                                 "This will permanently remove the network\n"
 
508
                                 "from the configuration. Do you really want\n"
 
509
                                 "to remove this network?", "Yes", "No") != 0)
 
510
        return;
 
511
    
 
512
    snprintf(cmd, sizeof(cmd), "REMOVE_NETWORK %d", edit_network_id);
 
513
    reply_len = sizeof(reply);
 
514
    wpagui->ctrlRequest(cmd, reply, &reply_len);
 
515
    if (strncmp(reply, "OK", 2) != 0) {
 
516
        QMessageBox::warning(this, "wpa_gui",
 
517
                             "Failed to remove network from wpa_supplicant\n"
 
518
                             "configuration.");
 
519
    } else {
 
520
        wpagui->triggerUpdate();
 
521
        wpagui->ctrlRequest("SAVE_CONFIG", reply, &reply_len);
 
522
    }
 
523
 
 
524
    close();
 
525
}
 
526
 
 
527
 
 
528
void NetworkConfig::newNetwork()
 
529
{
 
530
    new_network = true;
 
531
    getEapCapa();
 
532
}
 
533
 
 
534
 
 
535
void NetworkConfig::getEapCapa()
 
536
{
 
537
    char reply[256];
 
538
    size_t reply_len;
 
539
    
 
540
    if (wpagui == NULL)
 
541
        return;
 
542
 
 
543
    reply_len = sizeof(reply) - 1;
 
544
    if (wpagui->ctrlRequest("GET_CAPABILITY eap", reply, &reply_len) < 0)
 
545
        return;
 
546
    reply[reply_len] = '\0';
 
547
    
 
548
    QString res(reply);
 
549
    QStringList types = QStringList::split(QChar(' '), res);
 
550
    eapSelect->insertStringList(types);
 
551
}