~ubuntu-branches/ubuntu/saucy/wpasupplicant/saucy

« back to all changes in this revision

Viewing changes to wpa_supplicant/wpa_gui-qt4/wpagui.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2010-11-22 09:43:43 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20101122094343-qgsxaojvmswfri77
Tags: 0.7.3-0ubuntu1
* Get wpasupplicant 0.7.3 from Debian's SVN. Leaving 0.7.3-1 as unreleased
  for now.
* Build-Depend on debhelper 8, since the packaging from Debian uses compat 8.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * wpa_gui - WpaGui class
3
 
 * Copyright (c) 2005-2008, Jouni Malinen <j@w1.fi>
 
3
 * Copyright (c) 2005-2010, Jouni Malinen <j@w1.fi>
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License version 2 as
29
29
 
30
30
#include "wpagui.h"
31
31
#include "dirent.h"
32
 
#include "wpa_ctrl.h"
 
32
#include "common/wpa_ctrl.h"
33
33
#include "userdatarequest.h"
34
34
#include "networkconfig.h"
35
35
 
50
50
#ifdef CONFIG_NATIVE_WINDOWS
51
51
        fileStopServiceAction = new QAction(this);
52
52
        fileStopServiceAction->setObjectName("Stop Service");
53
 
        fileStopServiceAction->setIconText("Stop Service");
 
53
        fileStopServiceAction->setIconText(tr("Stop Service"));
54
54
        fileMenu->insertAction(actionWPS, fileStopServiceAction);
55
55
 
56
56
        fileStartServiceAction = new QAction(this);
57
57
        fileStartServiceAction->setObjectName("Start Service");
58
 
        fileStartServiceAction->setIconText("Start Service");
 
58
        fileStartServiceAction->setIconText(tr("Start Service"));
59
59
        fileMenu->insertAction(fileStopServiceAction, fileStartServiceAction);
60
60
 
61
61
        connect(fileStartServiceAction, SIGNAL(triggered()), this,
64
64
                SLOT(stopService()));
65
65
 
66
66
        addInterfaceAction = new QAction(this);
67
 
        addInterfaceAction->setIconText("Add Interface");
 
67
        addInterfaceAction->setIconText(tr("Add Interface"));
68
68
        fileMenu->insertAction(fileStartServiceAction, addInterfaceAction);
69
69
 
70
70
        connect(addInterfaceAction, SIGNAL(triggered()), this,
85
85
        connect(fileSaveConfigAction, SIGNAL(triggered()), this,
86
86
                SLOT(saveConfig()));
87
87
        connect(actionWPS, SIGNAL(triggered()), this, SLOT(wpsDialog()));
 
88
        connect(actionPeers, SIGNAL(triggered()), this, SLOT(peersDialog()));
88
89
        connect(fileExitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
89
90
        connect(networkAddAction, SIGNAL(triggered()), this,
90
91
                SLOT(addNetwork()));
133
134
 
134
135
        eh = NULL;
135
136
        scanres = NULL;
 
137
        peers = NULL;
136
138
        add_iface = NULL;
137
139
        udr = NULL;
138
140
        tray_icon = NULL;
162
164
                show();
163
165
 
164
166
        connectedToService = false;
165
 
        textStatus->setText("connecting to wpa_supplicant");
 
167
        textStatus->setText(tr("connecting to wpa_supplicant"));
166
168
        timer = new QTimer(this);
167
169
        connect(timer, SIGNAL(timeout()), SLOT(ping()));
168
170
        timer->setSingleShot(FALSE);
205
207
                scanres = NULL;
206
208
        }
207
209
 
 
210
        if (peers) {
 
211
                peers->close();
 
212
                delete peers;
 
213
                peers = NULL;
 
214
        }
 
215
 
208
216
        if (add_iface) {
209
217
                add_iface->close();
210
218
                delete add_iface;
332
340
                        first = false;
333
341
                        if (QMessageBox::warning(
334
342
                                    this, qAppName(),
335
 
                                    "wpa_supplicant service is not running.\n"
336
 
                                    "Do you want to start it?",
 
343
                                    tr("wpa_supplicant service is not "
 
344
                                       "running.\n"
 
345
                                       "Do you want to start it?"),
337
346
                                    QMessageBox::Yes | QMessageBox::No) ==
338
347
                            QMessageBox::Yes)
339
348
                                startService();
435
444
}
436
445
 
437
446
 
438
 
static void wpa_gui_msg_cb(char *msg, size_t)
439
 
{
440
 
        /* This should not happen anymore since two control connections are
441
 
         * used. */
442
 
        printf("missed message: %s\n", msg);
443
 
}
444
 
 
445
 
 
446
447
int WpaGui::ctrlRequest(const char *cmd, char *buf, size_t *buflen)
447
448
{
448
449
        int ret;
449
450
 
450
451
        if (ctrl_conn == NULL)
451
452
                return -3;
452
 
        ret = wpa_ctrl_request(ctrl_conn, cmd, strlen(cmd), buf, buflen,
453
 
                               wpa_gui_msg_cb);
 
453
        ret = wpa_ctrl_request(ctrl_conn, cmd, strlen(cmd), buf, buflen, NULL);
454
454
        if (ret == -2)
455
455
                printf("'%s' command timed out.\n", cmd);
456
456
        else if (ret < 0)
460
460
}
461
461
 
462
462
 
 
463
QString WpaGui::wpaStateTranslate(char *state)
 
464
{
 
465
        if (!strcmp(state, "DISCONNECTED"))
 
466
                return tr("Disconnected");
 
467
        else if (!strcmp(state, "INACTIVE"))
 
468
                return tr("Inactive");
 
469
        else if (!strcmp(state, "SCANNING"))
 
470
                return tr("Scanning");
 
471
        else if (!strcmp(state, "AUTHENTICATING"))
 
472
                return tr("Authenticating");
 
473
        else if (!strcmp(state, "ASSOCIATING"))
 
474
                return tr("Associating");
 
475
        else if (!strcmp(state, "ASSOCIATED"))
 
476
                return tr("Associated");
 
477
        else if (!strcmp(state, "4WAY_HANDSHAKE"))
 
478
                return tr("4-Way Handshake");
 
479
        else if (!strcmp(state, "GROUP_HANDSHAKE"))
 
480
                return tr("Group Handshake");
 
481
        else if (!strcmp(state, "COMPLETED"))
 
482
                return tr("Completed");
 
483
        else
 
484
                return tr("Unknown");
 
485
}
 
486
 
 
487
 
463
488
void WpaGui::updateStatus()
464
489
{
465
490
        char buf[2048], *start, *end, *pos;
469
494
 
470
495
        len = sizeof(buf) - 1;
471
496
        if (ctrl_conn == NULL || ctrlRequest("STATUS", buf, &len) < 0) {
472
 
                textStatus->setText("Could not get status from "
473
 
                                    "wpa_supplicant");
 
497
                textStatus->setText(tr("Could not get status from "
 
498
                                       "wpa_supplicant"));
474
499
                textAuthentication->clear();
475
500
                textEncryption->clear();
476
501
                textSsid->clear();
484
509
                        first = false;
485
510
                        if (QMessageBox::information(
486
511
                                    this, qAppName(),
487
 
                                    "No network interfaces in use.\n"
488
 
                                    "Would you like to add one?",
 
512
                                    tr("No network interfaces in use.\n"
 
513
                                       "Would you like to add one?"),
489
514
                                    QMessageBox::Yes | QMessageBox::No) ==
490
515
                            QMessageBox::Yes)
491
516
                                addInterface();
500
525
        bool bssid_updated = false, ipaddr_updated = false;
501
526
        bool status_updated = false;
502
527
        char *pairwise_cipher = NULL, *group_cipher = NULL;
 
528
        char *mode = NULL;
503
529
 
504
530
        start = buf;
505
531
        while (*start) {
527
553
                                textIpAddress->setText(pos);
528
554
                        } else if (strcmp(start, "wpa_state") == 0) {
529
555
                                status_updated = true;
530
 
                                textStatus->setText(pos);
 
556
                                textStatus->setText(wpaStateTranslate(pos));
531
557
                        } else if (strcmp(start, "key_mgmt") == 0) {
532
558
                                auth_updated = true;
533
559
                                textAuthentication->setText(pos);
536
562
                                pairwise_cipher = pos;
537
563
                        } else if (strcmp(start, "group_cipher") == 0) {
538
564
                                group_cipher = pos;
 
565
                        } else if (strcmp(start, "mode") == 0) {
 
566
                                mode = pos;
539
567
                        }
540
568
                }
541
569
 
543
571
                        break;
544
572
                start = end + 1;
545
573
        }
 
574
        if (status_updated && mode)
 
575
                textStatus->setText(textStatus->text() + " (" + mode + ")");
546
576
 
547
577
        if (pairwise_cipher || group_cipher) {
548
578
                QString encr;
649
679
        }
650
680
 
651
681
        if (networkSelect->count() > 1)
652
 
                networkSelect->addItem("Select any network");
 
682
                networkSelect->addItem(tr("Select any network"));
653
683
 
654
684
        if (!current && first_active >= 0)
655
685
                networkSelect->setCurrentIndex(first_active);
682
712
void WpaGui::helpAbout()
683
713
{
684
714
        QMessageBox::about(this, "wpa_gui for wpa_supplicant",
685
 
                           "Copyright (c) 2003-2008,\n"
 
715
                           "Copyright (c) 2003-2010,\n"
686
716
                           "Jouni Malinen <j@w1.fi>\n"
687
717
                           "and contributors.\n"
688
718
                           "\n"
822
852
        WpaMsg wm(pos, priority);
823
853
        if (eh)
824
854
                eh->addEvent(wm);
 
855
        if (peers)
 
856
                peers->event_notify(wm);
825
857
        msgs.append(wm);
826
858
        while (msgs.count() > 100)
827
859
                msgs.pop_front();
848
880
                scanres->updateResults();
849
881
        else if (str_match(pos, WPA_EVENT_DISCONNECTED))
850
882
                showTrayMessage(QSystemTrayIcon::Information, 3,
851
 
                                "Disconnected from network.");
 
883
                                tr("Disconnected from network."));
852
884
        else if (str_match(pos, WPA_EVENT_CONNECTED)) {
853
885
                showTrayMessage(QSystemTrayIcon::Information, 3,
854
 
                                "Connection to network established.");
 
886
                                tr("Connection to network established."));
855
887
                QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
856
888
                stopWpsRun(true);
857
889
        } else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PBC)) {
858
 
                wpsStatusText->setText("WPS AP in active PBC mode found");
 
890
                wpsStatusText->setText(tr("WPS AP in active PBC mode found"));
859
891
                if (textStatus->text() == "INACTIVE" ||
860
892
                    textStatus->text() == "DISCONNECTED")
861
893
                        wpaguiTab->setCurrentWidget(wpsTab);
862
 
                wpsInstructions->setText("Press the PBC button on the screen "
863
 
                                         "to start registration");
 
894
                wpsInstructions->setText(tr("Press the PBC button on the "
 
895
                                            "screen to start registration"));
864
896
        } else if (str_match(pos, WPS_EVENT_AP_AVAILABLE_PIN)) {
865
 
                wpsStatusText->setText("WPS AP with recently selected "
866
 
                                       "registrar");
 
897
                wpsStatusText->setText(tr("WPS AP with recently selected "
 
898
                                          "registrar"));
867
899
                if (textStatus->text() == "INACTIVE" ||
868
900
                    textStatus->text() == "DISCONNECTED")
869
901
                        wpaguiTab->setCurrentWidget(wpsTab);
870
902
        } else if (str_match(pos, WPS_EVENT_AP_AVAILABLE)) {
871
 
                wpsStatusText->setText("WPS AP detected");
 
903
                wpsStatusText->setText(tr("WPS AP detected"));
872
904
        } else if (str_match(pos, WPS_EVENT_OVERLAP)) {
873
 
                wpsStatusText->setText("PBC mode overlap detected");
874
 
                wpsInstructions->setText("More than one AP is currently in "
875
 
                                         "active WPS PBC mode. Wait couple of "
876
 
                                         "minutes and try again");
 
905
                wpsStatusText->setText(tr("PBC mode overlap detected"));
 
906
                wpsInstructions->setText(tr("More than one AP is currently in "
 
907
                                            "active WPS PBC mode. Wait couple "
 
908
                                            "of minutes and try again"));
877
909
                wpaguiTab->setCurrentWidget(wpsTab);
878
910
        } else if (str_match(pos, WPS_EVENT_CRED_RECEIVED)) {
879
 
                wpsStatusText->setText("Network configuration received");
 
911
                wpsStatusText->setText(tr("Network configuration received"));
880
912
                wpaguiTab->setCurrentWidget(wpsTab);
881
913
        } else if (str_match(pos, WPA_EVENT_EAP_METHOD)) {
882
914
                if (strstr(pos, "(WSC)"))
883
 
                        wpsStatusText->setText("Registration started");
 
915
                        wpsStatusText->setText(tr("Registration started"));
884
916
        } else if (str_match(pos, WPS_EVENT_M2D)) {
885
 
                wpsStatusText->setText("Registrar does not yet know PIN");
 
917
                wpsStatusText->setText(tr("Registrar does not yet know PIN"));
886
918
        } else if (str_match(pos, WPS_EVENT_FAIL)) {
887
 
                wpsStatusText->setText("Registration failed");
 
919
                wpsStatusText->setText(tr("Registration failed"));
888
920
        } else if (str_match(pos, WPS_EVENT_SUCCESS)) {
889
 
                wpsStatusText->setText("Registration succeeded");
 
921
                wpsStatusText->setText(tr("Registration succeeded"));
890
922
        }
891
923
}
892
924
 
939
971
        char reply[10];
940
972
        size_t reply_len = sizeof(reply);
941
973
 
942
 
        if (cmd.startsWith("Select any")) {
 
974
        if (cmd.contains(QRegExp("^\\d+:")))
 
975
                cmd.truncate(cmd.indexOf(':'));
 
976
        else
943
977
                cmd = "any";
944
 
        } else {
945
 
                int pos = cmd.indexOf(':');
946
 
                if (pos < 0) {
947
 
                        printf("Invalid selectNetwork '%s'\n",
948
 
                               cmd.toAscii().constData());
949
 
                        return;
950
 
                }
951
 
                cmd.truncate(pos);
952
 
        }
953
978
        cmd.prepend("SELECT_NETWORK ");
954
979
        ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
955
980
        triggerUpdate();
963
988
        char reply[10];
964
989
        size_t reply_len = sizeof(reply);
965
990
 
966
 
        if (!cmd.startsWith("all")) {
967
 
                int pos = cmd.indexOf(':');
968
 
                if (pos < 0) {
969
 
                        printf("Invalid enableNetwork '%s'\n",
970
 
                               cmd.toAscii().constData());
971
 
                        return;
972
 
                }
973
 
                cmd.truncate(pos);
 
991
        if (cmd.contains(QRegExp("^\\d+:")))
 
992
                cmd.truncate(cmd.indexOf(':'));
 
993
        else if (!cmd.startsWith("all")) {
 
994
                printf("Invalid editNetwork '%s'\n",
 
995
                       cmd.toAscii().constData());
 
996
                return;
974
997
        }
975
998
        cmd.prepend("ENABLE_NETWORK ");
976
999
        ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
984
1007
        char reply[10];
985
1008
        size_t reply_len = sizeof(reply);
986
1009
 
987
 
        if (!cmd.startsWith("all")) {
988
 
                int pos = cmd.indexOf(':');
989
 
                if (pos < 0) {
990
 
                        printf("Invalid disableNetwork '%s'\n",
991
 
                               cmd.toAscii().constData());
992
 
                        return;
993
 
                }
994
 
                cmd.truncate(pos);
 
1010
        if (cmd.contains(QRegExp("^\\d+:")))
 
1011
                cmd.truncate(cmd.indexOf(':'));
 
1012
        else if (!cmd.startsWith("all")) {
 
1013
                printf("Invalid editNetwork '%s'\n",
 
1014
                       cmd.toAscii().constData());
 
1015
                return;
995
1016
        }
996
1017
        cmd.prepend("DISABLE_NETWORK ");
997
1018
        ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
1004
1025
        QString cmd(sel);
1005
1026
        int id = -1;
1006
1027
 
1007
 
        if (!cmd.startsWith("Select any")) {
1008
 
                int pos = sel.indexOf(':');
1009
 
                if (pos < 0) {
1010
 
                        printf("Invalid editNetwork '%s'\n",
1011
 
                               cmd.toAscii().constData());
1012
 
                        return;
1013
 
                }
1014
 
                cmd.truncate(pos);
 
1028
        if (cmd.contains(QRegExp("^\\d+:"))) {
 
1029
                cmd.truncate(cmd.indexOf(':'));
1015
1030
                id = cmd.toInt();
1016
1031
        }
1017
1032
 
1033
1048
void WpaGui::editSelectedNetwork()
1034
1049
{
1035
1050
        if (networkSelect->count() < 1) {
1036
 
                QMessageBox::information(this, "No Networks",
1037
 
                                         "There are no networks to edit.\n");
 
1051
                QMessageBox::information(
 
1052
                        this, tr("No Networks"),
 
1053
                        tr("There are no networks to edit.\n"));
1038
1054
                return;
1039
1055
        }
1040
1056
        QString sel(networkSelect->currentText());
1045
1061
void WpaGui::editListedNetwork()
1046
1062
{
1047
1063
        if (networkList->currentRow() < 0) {
1048
 
                QMessageBox::information(this, "Select A Network",
1049
 
                                         "Select a network from the list to"
1050
 
                                         " edit it.\n");
 
1064
                QMessageBox::information(this, tr("Select A Network"),
 
1065
                                         tr("Select a network from the list to"
 
1066
                                            " edit it.\n"));
1051
1067
                return;
1052
1068
        }
1053
1069
        QString sel(networkList->currentItem()->text());
1081
1097
        char reply[10];
1082
1098
        size_t reply_len = sizeof(reply);
1083
1099
 
1084
 
        if (cmd.startsWith("Select any"))
 
1100
        if (cmd.contains(QRegExp("^\\d+:")))
 
1101
                cmd.truncate(cmd.indexOf(':'));
 
1102
        else if (!cmd.startsWith("all")) {
 
1103
                printf("Invalid editNetwork '%s'\n",
 
1104
                       cmd.toAscii().constData());
1085
1105
                return;
1086
 
 
1087
 
        if (!cmd.startsWith("all")) {
1088
 
                int pos = cmd.indexOf(':');
1089
 
                if (pos < 0) {
1090
 
                        printf("Invalid removeNetwork '%s'\n",
1091
 
                               cmd.toAscii().constData());
1092
 
                        return;
1093
 
                }
1094
 
                cmd.truncate(pos);
1095
1106
        }
1096
1107
        cmd.prepend("REMOVE_NETWORK ");
1097
1108
        ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
1102
1113
void WpaGui::removeSelectedNetwork()
1103
1114
{
1104
1115
        if (networkSelect->count() < 1) {
1105
 
                QMessageBox::information(this, "No Networks",
1106
 
                                         "There are no networks to remove.\n");
 
1116
                QMessageBox::information(this, tr("No Networks"),
 
1117
                                         tr("There are no networks to remove."
 
1118
                                            "\n"));
1107
1119
                return;
1108
1120
        }
1109
1121
        QString sel(networkSelect->currentText());
1114
1126
void WpaGui::removeListedNetwork()
1115
1127
{
1116
1128
        if (networkList->currentRow() < 0) {
1117
 
                QMessageBox::information(this, "Select A Network",
1118
 
                                         "Select a network from the list to"
1119
 
                                         " remove it.\n");
 
1129
                QMessageBox::information(this, tr("Select A Network"),
 
1130
                                         tr("Select a network from the list "
 
1131
                                            "to remove it.\n"));
1120
1132
                return;
1121
1133
        }
1122
1134
        QString sel(networkList->currentItem()->text());
1226
1238
        buf[len] = '\0';
1227
1239
 
1228
1240
        if (str_match(buf, "FAIL"))
1229
 
                QMessageBox::warning(this, "Failed to save configuration",
1230
 
                                     "The configuration could not be saved.\n"
1231
 
                                     "\n"
1232
 
                                     "The update_config=1 configuration option\n"
1233
 
                                     "must be used for configuration saving to\n"
1234
 
                                     "be permitted.\n");
 
1241
                QMessageBox::warning(
 
1242
                        this, tr("Failed to save configuration"),
 
1243
                        tr("The configuration could not be saved.\n"
 
1244
                           "\n"
 
1245
                           "The update_config=1 configuration option\n"
 
1246
                           "must be used for configuration saving to\n"
 
1247
                           "be permitted.\n"));
1235
1248
        else
1236
 
                QMessageBox::information(this, "Saved configuration",
1237
 
                                         "The current configuration was saved."
1238
 
                                         "\n");
 
1249
                QMessageBox::information(
 
1250
                        this, tr("Saved configuration"),
 
1251
                        tr("The current configuration was saved."
 
1252
                           "\n"));
1239
1253
}
1240
1254
 
1241
1255
 
1254
1268
        QApplication::setQuitOnLastWindowClosed(false);
1255
1269
 
1256
1270
        tray_icon = new QSystemTrayIcon(this);
1257
 
        tray_icon->setToolTip(qAppName() + " - wpa_supplicant user interface");
 
1271
        tray_icon->setToolTip(qAppName() + tr(" - wpa_supplicant user interface"));
1258
1272
        if (QImageReader::supportedImageFormats().contains(QByteArray("svg")))
1259
1273
                tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
1260
1274
        else
1268
1282
 
1269
1283
        tray_menu = new QMenu(this);
1270
1284
 
1271
 
        disconnectAction = new QAction("&Disconnect", this);
1272
 
        reconnectAction = new QAction("Re&connect", this);
 
1285
        disconnectAction = new QAction(tr("&Disconnect"), this);
 
1286
        reconnectAction = new QAction(tr("Re&connect"), this);
1273
1287
        connect(disconnectAction, SIGNAL(triggered()), this,
1274
1288
                SLOT(disconnect()));
1275
1289
        connect(reconnectAction, SIGNAL(triggered()), this,
1278
1292
        tray_menu->addAction(reconnectAction);
1279
1293
        tray_menu->addSeparator();
1280
1294
 
1281
 
        eventAction = new QAction("&Event History", this);
1282
 
        scanAction = new QAction("Scan &Results", this);
1283
 
        statAction = new QAction("S&tatus", this);
 
1295
        eventAction = new QAction(tr("&Event History"), this);
 
1296
        scanAction = new QAction(tr("Scan &Results"), this);
 
1297
        statAction = new QAction(tr("S&tatus"), this);
1284
1298
        connect(eventAction, SIGNAL(triggered()), this, SLOT(eventHistory()));
1285
1299
        connect(scanAction, SIGNAL(triggered()), this, SLOT(scan()));
1286
1300
        connect(statAction, SIGNAL(triggered()), this, SLOT(showTrayStatus()));
1289
1303
        tray_menu->addAction(statAction);
1290
1304
        tray_menu->addSeparator();
1291
1305
 
1292
 
        showAction = new QAction("&Show Window", this);
1293
 
        hideAction = new QAction("&Hide Window", this);
1294
 
        quitAction = new QAction("&Quit", this);
 
1306
        showAction = new QAction(tr("&Show Window"), this);
 
1307
        hideAction = new QAction(tr("&Hide Window"), this);
 
1308
        quitAction = new QAction(tr("&Quit"), this);
1295
1309
        connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
1296
1310
        connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));
1297
1311
        connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
1405
1419
                scanres = NULL;
1406
1420
        }
1407
1421
 
 
1422
        if (peers) {
 
1423
                peers->close();
 
1424
                delete peers;
 
1425
                peers = NULL;
 
1426
        }
 
1427
 
1408
1428
        if (udr) {
1409
1429
                udr->close();
1410
1430
                delete udr;
1416
1436
                if (QSystemTrayIcon::supportsMessages()) {
1417
1437
                        hide();
1418
1438
                        showTrayMessage(QSystemTrayIcon::Information, 3,
1419
 
                                        qAppName() + " will keep running in "
1420
 
                                        "the system tray.");
 
1439
                                        qAppName() +
 
1440
                                        tr(" will keep running in "
 
1441
                                           "the system tray."));
1421
1442
                } else {
1422
 
                        QMessageBox::information(this, qAppName() + " systray",
1423
 
                                                 "The program will keep "
1424
 
                                                 "running in the system "
1425
 
                                                 "tray.");
 
1443
                        QMessageBox::information(this, qAppName() +
 
1444
                                                 tr(" systray"),
 
1445
                                                 tr("The program will keep "
 
1446
                                                    "running in the system "
 
1447
                                                    "tray."));
1426
1448
                }
1427
1449
                ackTrayIcon = true;
1428
1450
        }
1437
1459
}
1438
1460
 
1439
1461
 
 
1462
void WpaGui::peersDialog()
 
1463
{
 
1464
        if (peers) {
 
1465
                peers->close();
 
1466
                delete peers;
 
1467
        }
 
1468
 
 
1469
        peers = new Peers();
 
1470
        if (peers == NULL)
 
1471
                return;
 
1472
        peers->setWpaGui(this);
 
1473
        peers->show();
 
1474
        peers->exec();
 
1475
}
 
1476
 
 
1477
 
1440
1478
void WpaGui::tabChanged(int index)
1441
1479
{
1442
1480
        if (index != 2)
1460
1498
                return;
1461
1499
 
1462
1500
        wpsPinEdit->setEnabled(false);
1463
 
        if (wpsStatusText->text().compare("WPS AP in active PBC mode found")) {
1464
 
                wpsInstructions->setText("Press the push button on the AP to "
1465
 
                                         "start the PBC mode.");
 
1501
        if (wpsStatusText->text().compare(tr("WPS AP in active PBC mode found"))) {
 
1502
                wpsInstructions->setText(tr("Press the push button on the AP to "
 
1503
                                         "start the PBC mode."));
1466
1504
        } else {
1467
 
                wpsInstructions->setText("If you have not yet done so, press "
 
1505
                wpsInstructions->setText(tr("If you have not yet done so, press "
1468
1506
                                         "the push button on the AP to start "
1469
 
                                         "the PBC mode.");
 
1507
                                         "the PBC mode."));
1470
1508
        }
1471
 
        wpsStatusText->setText("Waiting for Registrar");
 
1509
        wpsStatusText->setText(tr("Waiting for Registrar"));
1472
1510
        wpsRunning = true;
1473
1511
}
1474
1512
 
1485
1523
 
1486
1524
        wpsPinEdit->setText(reply);
1487
1525
        wpsPinEdit->setEnabled(true);
1488
 
        wpsInstructions->setText("Enter the generated PIN into the Registrar "
 
1526
        wpsInstructions->setText(tr("Enter the generated PIN into the Registrar "
1489
1527
                                 "(either the internal one in the AP or an "
1490
 
                                 "external one).");
1491
 
        wpsStatusText->setText("Waiting for Registrar");
 
1528
                                 "external one)."));
 
1529
        wpsStatusText->setText(tr("Waiting for Registrar"));
1492
1530
        wpsRunning = true;
1493
1531
}
1494
1532
 
1498
1536
        bssFromScan = bssid;
1499
1537
        wpsApPinEdit->setEnabled(!bssFromScan.isEmpty());
1500
1538
        wpsApPinButton->setEnabled(wpsApPinEdit->text().length() == 8);
1501
 
        wpsStatusText->setText("WPS AP selected from scan results");
1502
 
        wpsInstructions->setText("If you want to use an AP device PIN, e.g., "
 
1539
        wpsStatusText->setText(tr("WPS AP selected from scan results"));
 
1540
        wpsInstructions->setText(tr("If you want to use an AP device PIN, e.g., "
1503
1541
                                 "from a label in the device, enter the eight "
1504
 
                                 "digit AP PIN and click Use AP PIN button.");
 
1542
                                 "digit AP PIN and click Use AP PIN button."));
1505
1543
}
1506
1544
 
1507
1545
 
1520
1558
        if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) < 0)
1521
1559
                return;
1522
1560
 
1523
 
        wpsStatusText->setText("Waiting for AP/Enrollee");
 
1561
        wpsStatusText->setText(tr("Waiting for AP/Enrollee"));
1524
1562
        wpsRunning = true;
1525
1563
}
1526
1564
 
1528
1566
void WpaGui::stopWpsRun(bool success)
1529
1567
{
1530
1568
        if (wpsRunning)
1531
 
                wpsStatusText->setText(success ? "Connected to the network" :
1532
 
                                       "Stopped");
 
1569
                wpsStatusText->setText(success ? tr("Connected to the network") :
 
1570
                                       tr("Stopped"));
1533
1571
        else
1534
1572
                wpsStatusText->setText("");
1535
1573
        wpsPinEdit->setEnabled(false);
1558
1596
ErrorMsg::ErrorMsg(QWidget *parent, DWORD last_err) :
1559
1597
        QMessageBox(parent), err(last_err)
1560
1598
{
1561
 
        setWindowTitle("wpa_gui error");
 
1599
        setWindowTitle(tr("wpa_gui error"));
1562
1600
        setIcon(QMessageBox::Warning);
1563
1601
}
1564
1602
 
1588
1626
 
1589
1627
        scm = OpenSCManager(0, 0, SC_MANAGER_CONNECT);
1590
1628
        if (!scm) {
1591
 
                ErrorMsg(this).showMsg("OpenSCManager failed");
 
1629
                ErrorMsg(this).showMsg(tr("OpenSCManager failed"));
1592
1630
                return;
1593
1631
        }
1594
1632
 
1595
1633
        svc = OpenService(scm, WPASVC_NAME, SERVICE_START);
1596
1634
        if (!svc) {
1597
 
                ErrorMsg(this).showMsg("OpenService failed");
 
1635
                ErrorMsg(this).showMsg(tr("OpenService failed"));
1598
1636
                CloseServiceHandle(scm);
1599
1637
                return;
1600
1638
        }
1601
1639
 
1602
1640
        if (!StartService(svc, 0, NULL)) {
1603
 
                ErrorMsg(this).showMsg("Failed to start wpa_supplicant "
1604
 
                                       "service");
 
1641
                ErrorMsg(this).showMsg(tr("Failed to start wpa_supplicant "
 
1642
                                       "service"));
1605
1643
        }
1606
1644
 
1607
1645
        CloseServiceHandle(svc);
1616
1654
 
1617
1655
        scm = OpenSCManager(0, 0, SC_MANAGER_CONNECT);
1618
1656
        if (!scm) {
1619
 
                ErrorMsg(this).showMsg("OpenSCManager failed");
 
1657
                ErrorMsg(this).showMsg(tr("OpenSCManager failed"));
1620
1658
                return;
1621
1659
        }
1622
1660
 
1623
1661
        svc = OpenService(scm, WPASVC_NAME, SERVICE_STOP);
1624
1662
        if (!svc) {
1625
 
                ErrorMsg(this).showMsg("OpenService failed");
 
1663
                ErrorMsg(this).showMsg(tr("OpenService failed"));
1626
1664
                CloseServiceHandle(scm);
1627
1665
                return;
1628
1666
        }
1629
1667
 
1630
1668
        if (!ControlService(svc, SERVICE_CONTROL_STOP, &status)) {
1631
 
                ErrorMsg(this).showMsg("Failed to stop wpa_supplicant "
1632
 
                                       "service");
 
1669
                ErrorMsg(this).showMsg(tr("Failed to stop wpa_supplicant "
 
1670
                                       "service"));
1633
1671
        }
1634
1672
 
1635
1673
        CloseServiceHandle(svc);