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()), qApp, SLOT(quit()));
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()));
88 ctrl_iface_dir = strdup("/var/run/wpa_supplicant");
92 if (QSystemTrayIcon::isSystemTrayAvailable())
93 createTrayIcon(startInTray);
97 textStatus->setText("connecting to wpa_supplicant");
98 timer = new QTimer(this);
99 connect(timer, SIGNAL(timeout()), SLOT(ping()));
100 timer->setSingleShot(FALSE);
103 if (openCtrlConnection(ctrl_iface) < 0) {
104 printf("Failed to open control connection to "
105 "wpa_supplicant.\n");
109 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:t");
170 ctrl_iface = strdup(optarg);
173 free(ctrl_iface_dir);
174 ctrl_iface_dir = strdup(optarg);
184 int WpaGui::openCtrlConnection(const char *ifname)
188 char buf[2048], *pos, *pos2;
192 if (ifname != ctrl_iface) {
194 ctrl_iface = strdup(ifname);
197 #ifdef CONFIG_CTRL_IFACE_UDP
199 ctrl_iface = strdup("udp");
200 #endif /* CONFIG_CTRL_IFACE_UDP */
201 #ifdef CONFIG_CTRL_IFACE_UNIX
203 DIR *dir = opendir(ctrl_iface_dir);
207 while ((dent = readdir(dir))) {
208 #ifdef _DIRENT_HAVE_D_TYPE
209 /* Skip the file if it is not a socket.
210 * Also accept DT_UNKNOWN (0) in case
211 * the C library or underlying file
212 * system does not support d_type. */
213 if (dent->d_type != DT_SOCK &&
214 dent->d_type != DT_UNKNOWN)
216 #endif /* _DIRENT_HAVE_D_TYPE */
218 if (strcmp(dent->d_name, ".") == 0 ||
219 strcmp(dent->d_name, "..") == 0)
221 printf("Selected interface '%s'\n",
223 ctrl_iface = strdup(dent->d_name);
228 #endif /* CONFIG_CTRL_IFACE_UNIX */
229 #ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
230 struct wpa_ctrl *ctrl;
236 ctrl = wpa_ctrl_open(NULL);
238 len = sizeof(buf) - 1;
239 ret = wpa_ctrl_request(ctrl, "INTERFACES", 10, buf,
243 pos = strchr(buf, '\n');
246 ctrl_iface = strdup(buf);
248 wpa_ctrl_close(ctrl);
250 #endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
253 if (ctrl_iface == NULL)
256 #ifdef CONFIG_CTRL_IFACE_UNIX
257 flen = strlen(ctrl_iface_dir) + strlen(ctrl_iface) + 2;
258 cfile = (char *) malloc(flen);
261 snprintf(cfile, flen, "%s/%s", ctrl_iface_dir, ctrl_iface);
262 #else /* CONFIG_CTRL_IFACE_UNIX */
263 flen = strlen(ctrl_iface) + 1;
264 cfile = (char *) malloc(flen);
267 snprintf(cfile, flen, "%s", ctrl_iface);
268 #endif /* CONFIG_CTRL_IFACE_UNIX */
271 wpa_ctrl_close(ctrl_conn);
278 wpa_ctrl_detach(monitor_conn);
279 wpa_ctrl_close(monitor_conn);
283 printf("Trying to connect to '%s'\n", cfile);
284 ctrl_conn = wpa_ctrl_open(cfile);
285 if (ctrl_conn == NULL) {
289 monitor_conn = wpa_ctrl_open(cfile);
291 if (monitor_conn == NULL) {
292 wpa_ctrl_close(ctrl_conn);
295 if (wpa_ctrl_attach(monitor_conn)) {
296 printf("Failed to attach to wpa_supplicant\n");
297 wpa_ctrl_close(monitor_conn);
299 wpa_ctrl_close(ctrl_conn);
304 #if defined(CONFIG_CTRL_IFACE_UNIX) || defined(CONFIG_CTRL_IFACE_UDP)
305 msgNotifier = new QSocketNotifier(wpa_ctrl_get_fd(monitor_conn),
306 QSocketNotifier::Read, this);
307 connect(msgNotifier, SIGNAL(activated(int)), SLOT(receiveMsgs()));
310 adapterSelect->clear();
311 adapterSelect->addItem(ctrl_iface);
312 adapterSelect->setCurrentIndex(0);
314 len = sizeof(buf) - 1;
315 if (wpa_ctrl_request(ctrl_conn, "INTERFACES", 10, buf, &len, NULL) >=
320 pos2 = strchr(pos, '\n');
323 if (strcmp(pos, ctrl_iface) != 0)
324 adapterSelect->addItem(pos);
336 static void wpa_gui_msg_cb(char *msg, size_t)
338 /* This should not happen anymore since two control connections are
340 printf("missed message: %s\n", msg);
344 int WpaGui::ctrlRequest(const char *cmd, char *buf, size_t *buflen)
348 if (ctrl_conn == NULL)
350 ret = wpa_ctrl_request(ctrl_conn, cmd, strlen(cmd), buf, buflen,
353 printf("'%s' command timed out.\n", cmd);
355 printf("'%s' command failed.\n", cmd);
361 void WpaGui::updateStatus()
363 char buf[2048], *start, *end, *pos;
366 pingsToStatusUpdate = 10;
368 len = sizeof(buf) - 1;
369 if (ctrl_conn == NULL || ctrlRequest("STATUS", buf, &len) < 0) {
370 textStatus->setText("Could not get status from "
372 textAuthentication->clear();
373 textEncryption->clear();
376 textIpAddress->clear();
382 bool auth_updated = false, ssid_updated = false;
383 bool bssid_updated = false, ipaddr_updated = false;
384 bool status_updated = false;
385 char *pairwise_cipher = NULL, *group_cipher = NULL;
390 end = strchr(start, '\n');
394 while (end[0] && end[1])
399 pos = strchr(start, '=');
402 if (strcmp(start, "bssid") == 0) {
403 bssid_updated = true;
404 textBssid->setText(pos);
405 } else if (strcmp(start, "ssid") == 0) {
407 textSsid->setText(pos);
408 } else if (strcmp(start, "ip_address") == 0) {
409 ipaddr_updated = true;
410 textIpAddress->setText(pos);
411 } else if (strcmp(start, "wpa_state") == 0) {
412 status_updated = true;
413 textStatus->setText(pos);
414 } else if (strcmp(start, "key_mgmt") == 0) {
416 textAuthentication->setText(pos);
417 /* TODO: could add EAP status to this */
418 } else if (strcmp(start, "pairwise_cipher") == 0) {
419 pairwise_cipher = pos;
420 } else if (strcmp(start, "group_cipher") == 0) {
430 if (pairwise_cipher || group_cipher) {
432 if (pairwise_cipher && group_cipher &&
433 strcmp(pairwise_cipher, group_cipher) != 0) {
434 encr.append(pairwise_cipher);
436 encr.append(group_cipher);
437 } else if (pairwise_cipher) {
438 encr.append(pairwise_cipher);
440 encr.append(group_cipher);
441 encr.append(" [group key only]");
443 textEncryption->setText(encr);
445 textEncryption->clear();
450 textAuthentication->clear();
456 textIpAddress->clear();
460 void WpaGui::updateNetworks()
462 char buf[2048], *start, *end, *id, *ssid, *bssid, *flags;
464 int first_active = -1;
465 int was_selected = -1;
466 bool current = false;
468 if (!networkMayHaveChanged)
471 if (networkList->currentRow() >= 0)
472 was_selected = networkList->currentRow();
474 networkSelect->clear();
475 networkList->clear();
477 if (ctrl_conn == NULL)
480 len = sizeof(buf) - 1;
481 if (ctrlRequest("LIST_NETWORKS", buf, &len) < 0)
485 start = strchr(buf, '\n');
492 end = strchr(start, '\n');
496 while (end[0] && end[1])
502 ssid = strchr(id, '\t');
506 bssid = strchr(ssid, '\t');
510 flags = strchr(bssid, '\t');
516 network.append(": ");
517 network.append(ssid);
518 networkSelect->addItem(network);
519 networkList->addItem(network);
521 if (strstr(flags, "[CURRENT]")) {
522 networkSelect->setCurrentIndex(networkSelect->count() -
525 } else if (first_active < 0 &&
526 strstr(flags, "[DISABLED]") == NULL)
527 first_active = networkSelect->count() - 1;
534 if (networkSelect->count() > 1)
535 networkSelect->addItem("Select any network");
537 if (!current && first_active >= 0)
538 networkSelect->setCurrentIndex(first_active);
540 if (was_selected >= 0 && networkList->count() > 0) {
541 if (was_selected < networkList->count())
542 networkList->setCurrentRow(was_selected);
544 networkList->setCurrentRow(networkList->count() - 1);
547 networkList->setCurrentRow(networkSelect->currentIndex());
549 networkMayHaveChanged = false;
553 void WpaGui::helpIndex()
555 printf("helpIndex\n");
559 void WpaGui::helpContents()
561 printf("helpContents\n");
565 void WpaGui::helpAbout()
567 QMessageBox::about(this, "wpa_gui for wpa_supplicant",
568 "Copyright (c) 2003-2008,\n"
569 "Jouni Malinen <j@w1.fi>\n"
570 "and contributors.\n"
572 "This program is free software. You can\n"
573 "distribute it and/or modify it under the terms "
575 "the GNU General Public License version 2.\n"
577 "Alternatively, this software may be distributed\n"
578 "under the terms of the BSD license.\n"
580 "This product includes software developed\n"
581 "by the OpenSSL Project for use in the\n"
582 "OpenSSL Toolkit (http://www.openssl.org/)\n");
586 void WpaGui::disconnect()
589 size_t reply_len = sizeof(reply);
590 ctrlRequest("DISCONNECT", reply, &reply_len);
601 scanres = new ScanResults();
604 scanres->setWpaGui(this);
610 void WpaGui::eventHistory()
617 eh = new EventHistory();
631 #ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
633 * QSocketNotifier cannot be used with Windows named pipes, so use a
634 * timer to check for received messages for now. This could be
635 * optimized be doing something specific to named pipes or Windows
636 * events, but it is not clear what would be the best way of doing that
640 #endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
642 if (scanres && !scanres->isVisible()) {
647 if (eh && !eh->isVisible()) {
652 if (udr && !udr->isVisible()) {
657 len = sizeof(buf) - 1;
658 if (ctrlRequest("PING", buf, &len) < 0) {
659 printf("PING failed - trying to reconnect\n");
660 if (openCtrlConnection(ctrl_iface) >= 0) {
661 printf("Reconnected successfully\n");
662 pingsToStatusUpdate = 0;
666 pingsToStatusUpdate--;
667 if (pingsToStatusUpdate <= 0) {
674 static int str_match(const char *a, const char *b)
676 return strncmp(a, b, strlen(b)) == 0;
680 void WpaGui::processMsg(char *msg)
682 char *pos = msg, *pos2;
688 priority = atoi(pos);
689 pos = strchr(pos, '>');
696 WpaMsg wm(pos, priority);
700 while (msgs.count() > 100)
703 /* Update last message with truncated version of the event */
704 if (strncmp(pos, "CTRL-", 5) == 0) {
705 pos2 = strchr(pos, str_match(pos, WPA_CTRL_REQ) ? ':' : ' ');
712 QString lastmsg = pos2;
713 lastmsg.truncate(40);
714 textLastMessage->setText(lastmsg);
716 pingsToStatusUpdate = 0;
717 networkMayHaveChanged = true;
719 if (str_match(pos, WPA_CTRL_REQ))
720 processCtrlReq(pos + strlen(WPA_CTRL_REQ));
721 else if (str_match(pos, WPA_EVENT_SCAN_RESULTS) && scanres)
722 scanres->updateResults();
723 else if (str_match(pos, WPA_EVENT_DISCONNECTED))
724 showTrayMessage(QSystemTrayIcon::Information, 3,
725 "Disconnected from network.");
726 else if (str_match(pos, WPA_EVENT_CONNECTED)) {
727 showTrayMessage(QSystemTrayIcon::Information, 3,
728 "Connection to network established.");
729 QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
734 void WpaGui::processCtrlReq(const char *req)
740 udr = new UserDataRequest();
743 if (udr->setParams(this, req) < 0) {
753 void WpaGui::receiveMsgs()
758 while (monitor_conn && wpa_ctrl_pending(monitor_conn) > 0) {
759 len = sizeof(buf) - 1;
760 if (wpa_ctrl_recv(monitor_conn, buf, &len) == 0) {
768 void WpaGui::connectB()
771 size_t reply_len = sizeof(reply);
772 ctrlRequest("REASSOCIATE", reply, &reply_len);
776 void WpaGui::selectNetwork( const QString &sel )
780 size_t reply_len = sizeof(reply);
782 if (cmd.startsWith("Select any")) {
785 int pos = cmd.indexOf(':');
787 printf("Invalid selectNetwork '%s'\n",
788 cmd.toAscii().constData());
793 cmd.prepend("SELECT_NETWORK ");
794 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
799 void WpaGui::enableNetwork(const QString &sel)
803 size_t reply_len = sizeof(reply);
805 if (!cmd.startsWith("all")) {
806 int pos = cmd.indexOf(':');
808 printf("Invalid enableNetwork '%s'\n",
809 cmd.toAscii().constData());
814 cmd.prepend("ENABLE_NETWORK ");
815 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
820 void WpaGui::disableNetwork(const QString &sel)
824 size_t reply_len = sizeof(reply);
826 if (!cmd.startsWith("all")) {
827 int pos = cmd.indexOf(':');
829 printf("Invalid disableNetwork '%s'\n",
830 cmd.toAscii().constData());
835 cmd.prepend("DISABLE_NETWORK ");
836 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
841 void WpaGui::editNetwork(const QString &sel)
846 if (!cmd.startsWith("Select any")) {
847 int pos = sel.indexOf(':');
849 printf("Invalid editNetwork '%s'\n",
850 cmd.toAscii().constData());
857 NetworkConfig *nc = new NetworkConfig();
863 nc->paramsFromConfig(id);
872 void WpaGui::editSelectedNetwork()
874 if (networkSelect->count() < 1) {
875 QMessageBox::information(this, "No Networks",
876 "There are no networks to edit.\n");
879 QString sel(networkSelect->currentText());
884 void WpaGui::editListedNetwork()
886 if (networkList->currentRow() < 0) {
887 QMessageBox::information(this, "Select A Network",
888 "Select a network from the list to"
892 QString sel(networkList->currentItem()->text());
897 void WpaGui::triggerUpdate()
900 networkMayHaveChanged = true;
905 void WpaGui::addNetwork()
907 NetworkConfig *nc = new NetworkConfig();
917 void WpaGui::removeNetwork(const QString &sel)
921 size_t reply_len = sizeof(reply);
923 if (cmd.startsWith("Select any"))
926 if (!cmd.startsWith("all")) {
927 int pos = cmd.indexOf(':');
929 printf("Invalid removeNetwork '%s'\n",
930 cmd.toAscii().constData());
935 cmd.prepend("REMOVE_NETWORK ");
936 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
941 void WpaGui::removeSelectedNetwork()
943 if (networkSelect->count() < 1) {
944 QMessageBox::information(this, "No Networks",
945 "There are no networks to remove.\n");
948 QString sel(networkSelect->currentText());
953 void WpaGui::removeListedNetwork()
955 if (networkList->currentRow() < 0) {
956 QMessageBox::information(this, "Select A Network",
957 "Select a network from the list to"
961 QString sel(networkList->currentItem()->text());
966 void WpaGui::enableAllNetworks()
973 void WpaGui::disableAllNetworks()
980 void WpaGui::removeAllNetworks()
987 int WpaGui::getNetworkDisabled(const QString &sel)
991 size_t reply_len = sizeof(reply) - 1;
992 int pos = cmd.indexOf(':');
994 printf("Invalid getNetworkDisabled '%s'\n",
995 cmd.toAscii().constData());
999 cmd.prepend("GET_NETWORK ");
1000 cmd.append(" disabled");
1002 if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) >= 0
1003 && reply_len >= 1) {
1004 reply[reply_len] = '\0';
1005 if (!str_match(reply, "FAIL"))
1013 void WpaGui::updateNetworkDisabledStatus()
1015 if (networkList->currentRow() < 0)
1018 QString sel(networkList->currentItem()->text());
1020 switch (getNetworkDisabled(sel)) {
1022 if (!enableRadioButton->isChecked())
1023 enableRadioButton->setChecked(true);
1026 if (!disableRadioButton->isChecked())
1027 disableRadioButton->setChecked(true);
1033 void WpaGui::enableListedNetwork(bool enabled)
1035 if (networkList->currentRow() < 0 || !enabled)
1038 QString sel(networkList->currentItem()->text());
1040 if (getNetworkDisabled(sel) == 1)
1045 void WpaGui::disableListedNetwork(bool disabled)
1047 if (networkList->currentRow() < 0 || !disabled)
1050 QString sel(networkList->currentItem()->text());
1052 if (getNetworkDisabled(sel) == 0)
1053 disableNetwork(sel);
1057 void WpaGui::saveConfig()
1062 len = sizeof(buf) - 1;
1063 ctrlRequest("SAVE_CONFIG", buf, &len);
1067 if (str_match(buf, "FAIL"))
1068 QMessageBox::warning(this, "Failed to save configuration",
1069 "The configuration could not be saved.\n"
1071 "The update_config=1 configuration option\n"
1072 "must be used for configuration saving to\n"
1075 QMessageBox::information(this, "Saved configuration",
1076 "The current configuration was saved."
1081 void WpaGui::selectAdapter( const QString & sel )
1083 if (openCtrlConnection(sel.toAscii().constData()) < 0)
1084 printf("Failed to open control connection to "
1085 "wpa_supplicant.\n");
1091 void WpaGui::createTrayIcon(bool trayOnly)
1093 QApplication::setQuitOnLastWindowClosed(false);
1095 tray_icon = new QSystemTrayIcon(this);
1096 tray_icon->setToolTip(qAppName() + " - wpa_supplicant user interface");
1097 tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
1100 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1101 this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
1103 ackTrayIcon = false;
1105 tray_menu = new QMenu(this);
1107 disconnectAction = new QAction("&Disconnect", this);
1108 reconnectAction = new QAction("Re&connect", this);
1109 connect(disconnectAction, SIGNAL(triggered()), this,
1110 SLOT(disconnect()));
1111 connect(reconnectAction, SIGNAL(triggered()), this,
1113 tray_menu->addAction(disconnectAction);
1114 tray_menu->addAction(reconnectAction);
1115 tray_menu->addSeparator();
1117 eventAction = new QAction("&Event History", this);
1118 scanAction = new QAction("Scan &Results", this);
1119 statAction = new QAction("S&tatus", this);
1120 connect(eventAction, SIGNAL(triggered()), this, SLOT(eventHistory()));
1121 connect(scanAction, SIGNAL(triggered()), this, SLOT(scan()));
1122 connect(statAction, SIGNAL(triggered()), this, SLOT(showTrayStatus()));
1123 tray_menu->addAction(eventAction);
1124 tray_menu->addAction(scanAction);
1125 tray_menu->addAction(statAction);
1126 tray_menu->addSeparator();
1128 showAction = new QAction("&Show Window", this);
1129 hideAction = new QAction("&Hide Window", this);
1130 quitAction = new QAction("&Quit", this);
1131 connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
1132 connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));
1133 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
1134 tray_menu->addAction(showAction);
1135 tray_menu->addAction(hideAction);
1136 tray_menu->addSeparator();
1137 tray_menu->addAction(quitAction);
1139 tray_icon->setContextMenu(tray_menu);
1148 void WpaGui::showTrayMessage(QSystemTrayIcon::MessageIcon type, int sec,
1149 const QString & msg)
1151 if (!QSystemTrayIcon::supportsMessages())
1154 if (isVisible() || !tray_icon || !tray_icon->isVisible())
1157 tray_icon->showMessage(qAppName(), msg, type, sec * 1000);
1161 void WpaGui::trayActivated(QSystemTrayIcon::ActivationReason how)
1164 /* use close() here instead of hide() and allow the
1165 * custom closeEvent handler take care of children */
1166 case QSystemTrayIcon::Trigger:
1173 case QSystemTrayIcon::MiddleClick:
1182 void WpaGui::showTrayStatus()
1187 len = sizeof(buf) - 1;
1188 if (ctrlRequest("STATUS", buf, &len) < 0)
1192 QString msg, status(buf);
1194 QStringList lines = status.split(QRegExp("\\n"));
1195 for (QStringList::Iterator it = lines.begin();
1196 it != lines.end(); it++) {
1197 int pos = (*it).indexOf('=') + 1;
1201 if ((*it).startsWith("bssid="))
1202 msg.append("BSSID:\t" + (*it).mid(pos) + "\n");
1203 else if ((*it).startsWith("ssid="))
1204 msg.append("SSID: \t" + (*it).mid(pos) + "\n");
1205 else if ((*it).startsWith("pairwise_cipher="))
1206 msg.append("PAIR: \t" + (*it).mid(pos) + "\n");
1207 else if ((*it).startsWith("group_cipher="))
1208 msg.append("GROUP:\t" + (*it).mid(pos) + "\n");
1209 else if ((*it).startsWith("key_mgmt="))
1210 msg.append("AUTH: \t" + (*it).mid(pos) + "\n");
1211 else if ((*it).startsWith("wpa_state="))
1212 msg.append("STATE:\t" + (*it).mid(pos) + "\n");
1213 else if ((*it).startsWith("ip_address="))
1214 msg.append("IP: \t" + (*it).mid(pos) + "\n");
1215 else if ((*it).startsWith("Supplicant PAE state="))
1216 msg.append("PAE: \t" + (*it).mid(pos) + "\n");
1217 else if ((*it).startsWith("EAP state="))
1218 msg.append("EAP: \t" + (*it).mid(pos) + "\n");
1222 showTrayMessage(QSystemTrayIcon::Information, 10, msg);
1226 void WpaGui::closeEvent(QCloseEvent *event)
1246 if (tray_icon && !ackTrayIcon) {
1247 /* give user a visual hint that the tray icon exists */
1248 if (QSystemTrayIcon::supportsMessages()) {
1250 showTrayMessage(QSystemTrayIcon::Information, 3,
1251 qAppName() + " will keep running in "
1252 "the system tray.");
1254 QMessageBox::information(this, qAppName() + " systray",
1255 "The program will keep "
1256 "running in the system "