2 * wpa_gui - WpaGui class
3 * Copyright (c) 2005-2008, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
16 /* Need to get getopt() */
20 #include <QMessageBox>
21 #include <QCloseEvent>
26 #include "userdatarequest.h"
27 #include "networkconfig.h"
29 WpaGui::WpaGui(QWidget *parent, const char *, Qt::WFlags)
36 connect(fileEventHistoryAction, SIGNAL(triggered()), this,
37 SLOT(eventHistory()));
38 connect(fileSaveConfigAction, SIGNAL(triggered()), this,
40 connect(fileExitAction, SIGNAL(triggered()), this, SLOT(fileExit()));
41 connect(networkAddAction, SIGNAL(triggered()), this,
43 connect(networkEditAction, SIGNAL(triggered()), this,
44 SLOT(editSelectedNetwork()));
45 connect(networkRemoveAction, SIGNAL(triggered()), this,
46 SLOT(removeSelectedNetwork()));
47 connect(networkEnableAllAction, SIGNAL(triggered()), this,
48 SLOT(enableAllNetworks()));
49 connect(networkDisableAllAction, SIGNAL(triggered()), this,
50 SLOT(disableAllNetworks()));
51 connect(networkRemoveAllAction, SIGNAL(triggered()), this,
52 SLOT(removeAllNetworks()));
53 connect(helpIndexAction, SIGNAL(triggered()), this, SLOT(helpIndex()));
54 connect(helpContentsAction, SIGNAL(triggered()), this,
55 SLOT(helpContents()));
56 connect(helpAboutAction, SIGNAL(triggered()), this, SLOT(helpAbout()));
57 connect(disconnectButton, SIGNAL(clicked()), this, SLOT(disconnect()));
58 connect(scanButton, SIGNAL(clicked()), this, SLOT(scan()));
59 connect(connectButton, SIGNAL(clicked()), this, SLOT(connectB()));
60 connect(adapterSelect, SIGNAL(activated(const QString&)), this,
61 SLOT(selectAdapter(const QString&)));
62 connect(networkSelect, SIGNAL(activated(const QString&)), this,
63 SLOT(selectNetwork(const QString&)));
64 connect(addNetworkButton, SIGNAL(clicked()), this, SLOT(addNetwork()));
65 connect(editNetworkButton, SIGNAL(clicked()), this,
66 SLOT(editListedNetwork()));
67 connect(removeNetworkButton, SIGNAL(clicked()), this,
68 SLOT(removeListedNetwork()));
69 connect(networkList, SIGNAL(itemSelectionChanged()), this,
70 SLOT(updateNetworkDisabledStatus()));
71 connect(enableRadioButton, SIGNAL(toggled(bool)), this,
72 SLOT(enableListedNetwork(bool)));
73 connect(disableRadioButton, SIGNAL(toggled(bool)), this,
74 SLOT(disableListedNetwork(bool)));
75 connect(scanNetworkButton, SIGNAL(clicked()), this, SLOT(scan()));
76 connect(networkList, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
77 this, SLOT(editListedNetwork()));
87 ctrl_iface_dir = strdup("/var/run/wpa_supplicant");
89 if (QSystemTrayIcon::isSystemTrayAvailable())
94 textStatus->setText("connecting to wpa_supplicant");
95 timer = new QTimer(this);
96 connect(timer, SIGNAL(timeout()), SLOT(ping()));
97 timer->setSingleShot(FALSE);
100 if (openCtrlConnection(ctrl_iface) < 0) {
101 printf("Failed to open control connection to "
102 "wpa_supplicant.\n");
106 networkMayHaveChanged = true;
119 wpa_ctrl_detach(monitor_conn);
120 wpa_ctrl_close(monitor_conn);
124 wpa_ctrl_close(ctrl_conn);
149 free(ctrl_iface_dir);
150 ctrl_iface_dir = NULL;
154 void WpaGui::languageChange()
160 void WpaGui::parse_argv()
164 c = getopt(qApp->argc(), qApp->argv(), "i:p:");
170 ctrl_iface = strdup(optarg);
173 free(ctrl_iface_dir);
174 ctrl_iface_dir = strdup(optarg);
181 int WpaGui::openCtrlConnection(const char *ifname)
185 char buf[2048], *pos, *pos2;
189 if (ifname != ctrl_iface) {
191 ctrl_iface = strdup(ifname);
194 #ifdef CONFIG_CTRL_IFACE_UDP
196 ctrl_iface = strdup("udp");
197 #endif /* CONFIG_CTRL_IFACE_UDP */
198 #ifdef CONFIG_CTRL_IFACE_UNIX
200 DIR *dir = opendir(ctrl_iface_dir);
204 while ((dent = readdir(dir))) {
205 #ifdef _DIRENT_HAVE_D_TYPE
206 /* Skip the file if it is not a socket.
207 * Also accept DT_UNKNOWN (0) in case
208 * the C library or underlying file
209 * system does not support d_type. */
210 if (dent->d_type != DT_SOCK &&
211 dent->d_type != DT_UNKNOWN)
213 #endif /* _DIRENT_HAVE_D_TYPE */
215 if (strcmp(dent->d_name, ".") == 0 ||
216 strcmp(dent->d_name, "..") == 0)
218 printf("Selected interface '%s'\n",
220 ctrl_iface = strdup(dent->d_name);
225 #endif /* CONFIG_CTRL_IFACE_UNIX */
226 #ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
227 struct wpa_ctrl *ctrl;
233 ctrl = wpa_ctrl_open(NULL);
235 len = sizeof(buf) - 1;
236 ret = wpa_ctrl_request(ctrl, "INTERFACES", 10, buf,
240 pos = strchr(buf, '\n');
243 ctrl_iface = strdup(buf);
245 wpa_ctrl_close(ctrl);
247 #endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
250 if (ctrl_iface == NULL)
253 #ifdef CONFIG_CTRL_IFACE_UNIX
254 flen = strlen(ctrl_iface_dir) + strlen(ctrl_iface) + 2;
255 cfile = (char *) malloc(flen);
258 snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ctrl_iface);
259 #else /* CONFIG_CTRL_IFACE_UNIX */
260 flen = strlen(ctrl_iface) + 1;
261 cfile = (char *) malloc(flen);
264 snprintf(cfile, flen, "%s", ctrl_iface);
265 #endif /* CONFIG_CTRL_IFACE_UNIX */
268 wpa_ctrl_close(ctrl_conn);
275 wpa_ctrl_detach(monitor_conn);
276 wpa_ctrl_close(monitor_conn);
280 printf("Trying to connect to '%s'\n", cfile);
281 ctrl_conn = wpa_ctrl_open(cfile);
282 if (ctrl_conn == NULL) {
286 monitor_conn = wpa_ctrl_open(cfile);
288 if (monitor_conn == NULL) {
289 wpa_ctrl_close(ctrl_conn);
292 if (wpa_ctrl_attach(monitor_conn)) {
293 printf("Failed to attach to wpa_supplicant\n");
294 wpa_ctrl_close(monitor_conn);
296 wpa_ctrl_close(ctrl_conn);
301 #if defined(CONFIG_CTRL_IFACE_UNIX) || defined(CONFIG_CTRL_IFACE_UDP)
302 msgNotifier = new QSocketNotifier(wpa_ctrl_get_fd(monitor_conn),
303 QSocketNotifier::Read, this);
304 connect(msgNotifier, SIGNAL(activated(int)), SLOT(receiveMsgs()));
307 adapterSelect->clear();
308 adapterSelect->addItem(ctrl_iface);
309 adapterSelect->setCurrentIndex(0);
311 len = sizeof(buf) - 1;
312 if (wpa_ctrl_request(ctrl_conn, "INTERFACES", 10, buf, &len, NULL) >=
317 pos2 = strchr(pos, '\n');
320 if (strcmp(pos, ctrl_iface) != 0)
321 adapterSelect->addItem(pos);
333 static void wpa_gui_msg_cb(char *msg, size_t)
335 /* This should not happen anymore since two control connections are
337 printf("missed message: %s\n", msg);
341 int WpaGui::ctrlRequest(const char *cmd, char *buf, size_t *buflen)
345 if (ctrl_conn == NULL)
347 ret = wpa_ctrl_request(ctrl_conn, cmd, strlen(cmd), buf, buflen,
350 printf("'%s' command timed out.\n", cmd);
352 printf("'%s' command failed.\n", cmd);
358 void WpaGui::updateStatus()
360 char buf[2048], *start, *end, *pos;
363 pingsToStatusUpdate = 10;
365 len = sizeof(buf) - 1;
366 if (ctrl_conn == NULL || ctrlRequest("STATUS", buf, &len) < 0) {
367 textStatus->setText("Could not get status from "
369 textAuthentication->clear();
370 textEncryption->clear();
373 textIpAddress->clear();
379 bool auth_updated = false, ssid_updated = false;
380 bool bssid_updated = false, ipaddr_updated = false;
381 bool status_updated = false;
382 char *pairwise_cipher = NULL, *group_cipher = NULL;
387 end = strchr(start, '\n');
391 while (end[0] && end[1])
396 pos = strchr(start, '=');
399 if (strcmp(start, "bssid") == 0) {
400 bssid_updated = true;
401 textBssid->setText(pos);
402 } else if (strcmp(start, "ssid") == 0) {
404 textSsid->setText(pos);
405 } else if (strcmp(start, "ip_address") == 0) {
406 ipaddr_updated = true;
407 textIpAddress->setText(pos);
408 } else if (strcmp(start, "wpa_state") == 0) {
409 status_updated = true;
410 textStatus->setText(pos);
411 } else if (strcmp(start, "key_mgmt") == 0) {
413 textAuthentication->setText(pos);
414 /* TODO: could add EAP status to this */
415 } else if (strcmp(start, "pairwise_cipher") == 0) {
416 pairwise_cipher = pos;
417 } else if (strcmp(start, "group_cipher") == 0) {
427 if (pairwise_cipher || group_cipher) {
429 if (pairwise_cipher && group_cipher &&
430 strcmp(pairwise_cipher, group_cipher) != 0) {
431 encr.append(pairwise_cipher);
433 encr.append(group_cipher);
434 } else if (pairwise_cipher) {
435 encr.append(pairwise_cipher);
437 encr.append(group_cipher);
438 encr.append(" [group key only]");
440 textEncryption->setText(encr);
442 textEncryption->clear();
447 textAuthentication->clear();
453 textIpAddress->clear();
457 void WpaGui::updateNetworks()
459 char buf[2048], *start, *end, *id, *ssid, *bssid, *flags;
461 int first_active = -1;
462 int was_selected = -1;
463 bool current = false;
465 if (!networkMayHaveChanged)
468 if (networkList->currentRow() >= 0)
469 was_selected = networkList->currentRow();
471 networkSelect->clear();
472 networkList->clear();
474 if (ctrl_conn == NULL)
477 len = sizeof(buf) - 1;
478 if (ctrlRequest("LIST_NETWORKS", buf, &len) < 0)
482 start = strchr(buf, '\n');
489 end = strchr(start, '\n');
493 while (end[0] && end[1])
499 ssid = strchr(id, '\t');
503 bssid = strchr(ssid, '\t');
507 flags = strchr(bssid, '\t');
513 network.append(": ");
514 network.append(ssid);
515 networkSelect->addItem(network);
516 networkList->addItem(network);
518 if (strstr(flags, "[CURRENT]")) {
519 networkSelect->setCurrentIndex(networkSelect->count() -
522 } else if (first_active < 0 &&
523 strstr(flags, "[DISABLED]") == NULL)
524 first_active = networkSelect->count() - 1;
531 if (networkSelect->count() > 1)
532 networkSelect->addItem("Select any network");
534 if (!current && first_active >= 0)
535 networkSelect->setCurrentIndex(first_active);
537 if (was_selected >= 0 && networkList->count() > 0) {
538 if (was_selected < networkList->count())
539 networkList->setCurrentRow(was_selected);
541 networkList->setCurrentRow(networkList->count() - 1);
544 networkList->setCurrentRow(networkSelect->currentIndex());
546 networkMayHaveChanged = false;
550 void WpaGui::helpIndex()
552 printf("helpIndex\n");
556 void WpaGui::helpContents()
558 printf("helpContents\n");
562 void WpaGui::helpAbout()
564 QMessageBox::about(this, "wpa_gui for wpa_supplicant",
565 "Copyright (c) 2003-2008,\n"
566 "Jouni Malinen <j@w1.fi>\n"
567 "and contributors.\n"
569 "This program is free software. You can\n"
570 "distribute it and/or modify it under the terms "
572 "the GNU General Public License version 2.\n"
574 "Alternatively, this software may be distributed\n"
575 "under the terms of the BSD license.\n"
577 "This product includes software developed\n"
578 "by the OpenSSL Project for use in the\n"
579 "OpenSSL Toolkit (http://www.openssl.org/)\n");
583 void WpaGui::disconnect()
586 size_t reply_len = sizeof(reply);
587 ctrlRequest("DISCONNECT", reply, &reply_len);
601 scanres = new ScanResults();
604 scanres->setWpaGui(this);
610 void WpaGui::eventHistory()
620 eh = new EventHistory();
634 #ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
636 * QSocketNotifier cannot be used with Windows named pipes, so use a
637 * timer to check for received messages for now. This could be
638 * optimized be doing something specific to named pipes or Windows
639 * events, but it is not clear what would be the best way of doing that
643 #endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
645 if (scanres && !scanres->isVisible()) {
650 if (eh && !eh->isVisible()) {
655 if (udr && !udr->isVisible()) {
660 len = sizeof(buf) - 1;
661 if (ctrlRequest("PING", buf, &len) < 0) {
662 printf("PING failed - trying to reconnect\n");
663 if (openCtrlConnection(ctrl_iface) >= 0) {
664 printf("Reconnected successfully\n");
665 pingsToStatusUpdate = 0;
669 pingsToStatusUpdate--;
670 if (pingsToStatusUpdate <= 0) {
677 static int str_match(const char *a, const char *b)
679 return strncmp(a, b, strlen(b)) == 0;
683 void WpaGui::processMsg(char *msg)
685 char *pos = msg, *pos2;
691 priority = atoi(pos);
692 pos = strchr(pos, '>');
699 WpaMsg wm(pos, priority);
703 while (msgs.count() > 100)
706 /* Update last message with truncated version of the event */
707 if (strncmp(pos, "CTRL-", 5) == 0) {
708 pos2 = strchr(pos, str_match(pos, WPA_CTRL_REQ) ? ':' : ' ');
715 QString lastmsg = pos2;
716 lastmsg.truncate(40);
717 textLastMessage->setText(lastmsg);
719 pingsToStatusUpdate = 0;
720 networkMayHaveChanged = true;
722 if (str_match(pos, WPA_CTRL_REQ))
723 processCtrlReq(pos + strlen(WPA_CTRL_REQ));
724 else if (str_match(pos, WPA_EVENT_SCAN_RESULTS) && scanres)
725 scanres->updateResults();
726 else if (str_match(pos, WPA_EVENT_DISCONNECTED))
727 showTrayMessage(QSystemTrayIcon::Information, 3,
728 "Disconnected from network.");
729 else if (str_match(pos, WPA_EVENT_CONNECTED)) {
730 showTrayMessage(QSystemTrayIcon::Information, 3,
731 "Connection to network established.");
732 QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
737 void WpaGui::processCtrlReq(const char *req)
743 udr = new UserDataRequest();
746 if (udr->setParams(this, req) < 0) {
756 void WpaGui::receiveMsgs()
761 while (monitor_conn && wpa_ctrl_pending(monitor_conn) > 0) {
762 len = sizeof(buf) - 1;
763 if (wpa_ctrl_recv(monitor_conn, buf, &len) == 0) {
771 void WpaGui::connectB()
774 size_t reply_len = sizeof(reply);
775 ctrlRequest("REASSOCIATE", reply, &reply_len);
779 void WpaGui::selectNetwork( const QString &sel )
783 size_t reply_len = sizeof(reply);
785 if (cmd.startsWith("Select any")) {
788 int pos = cmd.indexOf(':');
790 printf("Invalid selectNetwork '%s'\n",
791 cmd.toAscii().constData());
796 cmd.prepend("SELECT_NETWORK ");
797 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
802 void WpaGui::enableNetwork(const QString &sel)
806 size_t reply_len = sizeof(reply);
808 if (!cmd.startsWith("all")) {
809 int pos = cmd.indexOf(':');
811 printf("Invalid enableNetwork '%s'\n",
812 cmd.toAscii().constData());
817 cmd.prepend("ENABLE_NETWORK ");
818 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
823 void WpaGui::disableNetwork(const QString &sel)
827 size_t reply_len = sizeof(reply);
829 if (!cmd.startsWith("all")) {
830 int pos = cmd.indexOf(':');
832 printf("Invalid disableNetwork '%s'\n",
833 cmd.toAscii().constData());
838 cmd.prepend("DISABLE_NETWORK ");
839 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
844 void WpaGui::editNetwork(const QString &sel)
849 if (!cmd.startsWith("Select any")) {
850 int pos = sel.indexOf(':');
852 printf("Invalid editNetwork '%s'\n",
853 cmd.toAscii().constData());
860 NetworkConfig *nc = new NetworkConfig();
866 nc->paramsFromConfig(id);
875 void WpaGui::editSelectedNetwork()
877 if (networkSelect->count() < 1) {
878 QMessageBox::information(this, "No Networks",
879 "There are no networks to edit.\n");
882 QString sel(networkSelect->currentText());
887 void WpaGui::editListedNetwork()
889 if (networkList->currentRow() < 0) {
890 QMessageBox::information(this, "Select A Network",
891 "Select a network from the list to"
895 QString sel(networkList->currentItem()->text());
900 void WpaGui::triggerUpdate()
903 networkMayHaveChanged = true;
908 void WpaGui::addNetwork()
910 NetworkConfig *nc = new NetworkConfig();
920 void WpaGui::removeNetwork(const QString &sel)
924 size_t reply_len = sizeof(reply);
926 if (cmd.startsWith("Select any"))
929 if (!cmd.startsWith("all")) {
930 int pos = cmd.indexOf(':');
932 printf("Invalid removeNetwork '%s'\n",
933 cmd.toAscii().constData());
938 cmd.prepend("REMOVE_NETWORK ");
939 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
944 void WpaGui::removeSelectedNetwork()
946 if (networkSelect->count() < 1) {
947 QMessageBox::information(this, "No Networks",
948 "There are no networks to remove.\n");
951 QString sel(networkSelect->currentText());
956 void WpaGui::removeListedNetwork()
958 if (networkList->currentRow() < 0) {
959 QMessageBox::information(this, "Select A Network",
960 "Select a network from the list to"
964 QString sel(networkList->currentItem()->text());
969 void WpaGui::enableAllNetworks()
976 void WpaGui::disableAllNetworks()
983 void WpaGui::removeAllNetworks()
990 int WpaGui::getNetworkDisabled(const QString &sel)
994 size_t reply_len = sizeof(reply) - 1;
995 int pos = cmd.indexOf(':');
997 printf("Invalid getNetworkDisabled '%s'\n",
998 cmd.toAscii().constData());
1002 cmd.prepend("GET_NETWORK ");
1003 cmd.append(" disabled");
1005 if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) >= 0
1006 && reply_len >= 1) {
1007 reply[reply_len] = '\0';
1008 if (!str_match(reply, "FAIL"))
1016 void WpaGui::updateNetworkDisabledStatus()
1018 if (networkList->currentRow() < 0)
1021 QString sel(networkList->currentItem()->text());
1023 switch (getNetworkDisabled(sel)) {
1025 if (!enableRadioButton->isChecked())
1026 enableRadioButton->setChecked(true);
1029 if (!disableRadioButton->isChecked())
1030 disableRadioButton->setChecked(true);
1036 void WpaGui::enableListedNetwork(bool enabled)
1038 if (networkList->currentRow() < 0 || !enabled)
1041 QString sel(networkList->currentItem()->text());
1043 if (getNetworkDisabled(sel) == 1)
1048 void WpaGui::disableListedNetwork(bool disabled)
1050 if (networkList->currentRow() < 0 || !disabled)
1053 QString sel(networkList->currentItem()->text());
1055 if (getNetworkDisabled(sel) == 0)
1056 disableNetwork(sel);
1060 void WpaGui::saveConfig()
1065 len = sizeof(buf) - 1;
1066 ctrlRequest("SAVE_CONFIG", buf, &len);
1070 if (str_match(buf, "FAIL"))
1071 QMessageBox::warning(this, "Failed to save configuration",
1072 "The configuration could not be saved.\n"
1074 "The update_config=1 configuration option\n"
1075 "must be used for configuration saving to\n"
1078 QMessageBox::information(this, "Saved configuration",
1079 "The current configuration was saved."
1084 void WpaGui::selectAdapter( const QString & sel )
1086 if (openCtrlConnection(sel.toAscii().constData()) < 0)
1087 printf("Failed to open control connection to "
1088 "wpa_supplicant.\n");
1094 void WpaGui::createTrayIcon()
1096 tray_icon = new QSystemTrayIcon(this);
1097 tray_icon->setToolTip(qAppName() + " - wpa_supplicant user interface");
1098 tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
1101 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1102 this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
1104 ackTrayIcon = false;
1106 tray_menu = new QMenu(this);
1108 disconnectAction = new QAction("&Disconnect", this);
1109 reconnectAction = new QAction("Re&connect", this);
1110 connect(disconnectAction, SIGNAL(triggered()), this,
1111 SLOT(disconnect()));
1112 connect(reconnectAction, SIGNAL(triggered()), this,
1114 tray_menu->addAction(disconnectAction);
1115 tray_menu->addAction(reconnectAction);
1116 tray_menu->addSeparator();
1118 eventAction = new QAction("&Event History", this);
1119 scanAction = new QAction("Scan &Results", this);
1120 statAction = new QAction("S&tatus", this);
1121 connect(eventAction, SIGNAL(triggered()), this, SLOT(eventHistory()));
1122 connect(scanAction, SIGNAL(triggered()), this, SLOT(scan()));
1123 connect(statAction, SIGNAL(triggered()), this, SLOT(showTrayStatus()));
1124 tray_menu->addAction(eventAction);
1125 tray_menu->addAction(scanAction);
1126 tray_menu->addAction(statAction);
1127 tray_menu->addSeparator();
1129 showAction = new QAction("&Show Window", this);
1130 hideAction = new QAction("&Hide Window", this);
1131 quitAction = new QAction("&Quit", this);
1132 connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
1133 connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));
1134 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
1135 tray_menu->addAction(showAction);
1136 tray_menu->addAction(hideAction);
1137 tray_menu->addSeparator();
1138 tray_menu->addAction(quitAction);
1140 tray_icon->setContextMenu(tray_menu);
1144 void WpaGui::showTrayMessage(QSystemTrayIcon::MessageIcon type, int sec,
1145 const QString & msg)
1147 if (!QSystemTrayIcon::supportsMessages())
1150 if (isVisible() || !tray_icon || !tray_icon->isVisible())
1153 tray_icon->showMessage(qAppName(), msg, type, sec * 1000);
1157 void WpaGui::trayActivated(QSystemTrayIcon::ActivationReason how)
1160 /* use close() here instead of hide() and allow the
1161 * custom closeEvent handler take care of children */
1162 case QSystemTrayIcon::Trigger:
1168 case QSystemTrayIcon::MiddleClick:
1177 void WpaGui::showTrayStatus()
1182 len = sizeof(buf) - 1;
1183 if (ctrlRequest("STATUS", buf, &len) < 0)
1187 QString msg, status(buf);
1189 QStringList lines = status.split(QRegExp("\\n"));
1190 for (QStringList::Iterator it = lines.begin();
1191 it != lines.end(); it++) {
1192 int pos = (*it).indexOf('=') + 1;
1196 if ((*it).startsWith("bssid="))
1197 msg.append("BSSID:\t" + (*it).mid(pos) + "\n");
1198 else if ((*it).startsWith("ssid="))
1199 msg.append("SSID: \t" + (*it).mid(pos) + "\n");
1200 else if ((*it).startsWith("pairwise_cipher="))
1201 msg.append("PAIR: \t" + (*it).mid(pos) + "\n");
1202 else if ((*it).startsWith("group_cipher="))
1203 msg.append("GROUP:\t" + (*it).mid(pos) + "\n");
1204 else if ((*it).startsWith("key_mgmt="))
1205 msg.append("AUTH: \t" + (*it).mid(pos) + "\n");
1206 else if ((*it).startsWith("ip_address="))
1207 msg.append("IP: \t" + (*it).mid(pos) + "\n");
1210 showTrayMessage(QSystemTrayIcon::Information, 10, msg);
1213 void WpaGui::fileExit()
1222 void WpaGui::closeEvent(QCloseEvent *event)
1242 if (tray_icon && tray_icon->isVisible()) {
1243 /* give user a visual hint that the tray icon exists */
1244 if (QSystemTrayIcon::supportsMessages()) {
1246 QTimer::singleShot(1 * 1000, this,
1247 SLOT(showTrayStatus()));
1248 } else if (!ackTrayIcon) {
1249 QMessageBox::information(this, qAppName() + " systray",
1250 "The program will keep "
1251 "running in the system tray."
1252 " To terminate the program, "
1253 "choose <b>Quit</b> in the "
1254 "context menu of the system "