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()));
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);
598 scanres = new ScanResults();
601 scanres->setWpaGui(this);
607 void WpaGui::eventHistory()
614 eh = new EventHistory();
628 #ifdef CONFIG_CTRL_IFACE_NAMED_PIPE
630 * QSocketNotifier cannot be used with Windows named pipes, so use a
631 * timer to check for received messages for now. This could be
632 * optimized be doing something specific to named pipes or Windows
633 * events, but it is not clear what would be the best way of doing that
637 #endif /* CONFIG_CTRL_IFACE_NAMED_PIPE */
639 if (scanres && !scanres->isVisible()) {
644 if (eh && !eh->isVisible()) {
649 if (udr && !udr->isVisible()) {
654 len = sizeof(buf) - 1;
655 if (ctrlRequest("PING", buf, &len) < 0) {
656 printf("PING failed - trying to reconnect\n");
657 if (openCtrlConnection(ctrl_iface) >= 0) {
658 printf("Reconnected successfully\n");
659 pingsToStatusUpdate = 0;
663 pingsToStatusUpdate--;
664 if (pingsToStatusUpdate <= 0) {
671 static int str_match(const char *a, const char *b)
673 return strncmp(a, b, strlen(b)) == 0;
677 void WpaGui::processMsg(char *msg)
679 char *pos = msg, *pos2;
685 priority = atoi(pos);
686 pos = strchr(pos, '>');
693 WpaMsg wm(pos, priority);
697 while (msgs.count() > 100)
700 /* Update last message with truncated version of the event */
701 if (strncmp(pos, "CTRL-", 5) == 0) {
702 pos2 = strchr(pos, str_match(pos, WPA_CTRL_REQ) ? ':' : ' ');
709 QString lastmsg = pos2;
710 lastmsg.truncate(40);
711 textLastMessage->setText(lastmsg);
713 pingsToStatusUpdate = 0;
714 networkMayHaveChanged = true;
716 if (str_match(pos, WPA_CTRL_REQ))
717 processCtrlReq(pos + strlen(WPA_CTRL_REQ));
718 else if (str_match(pos, WPA_EVENT_SCAN_RESULTS) && scanres)
719 scanres->updateResults();
720 else if (str_match(pos, WPA_EVENT_DISCONNECTED))
721 showTrayMessage(QSystemTrayIcon::Information, 3,
722 "Disconnected from network.");
723 else if (str_match(pos, WPA_EVENT_CONNECTED)) {
724 showTrayMessage(QSystemTrayIcon::Information, 3,
725 "Connection to network established.");
726 QTimer::singleShot(5 * 1000, this, SLOT(showTrayStatus()));
731 void WpaGui::processCtrlReq(const char *req)
737 udr = new UserDataRequest();
740 if (udr->setParams(this, req) < 0) {
750 void WpaGui::receiveMsgs()
755 while (monitor_conn && wpa_ctrl_pending(monitor_conn) > 0) {
756 len = sizeof(buf) - 1;
757 if (wpa_ctrl_recv(monitor_conn, buf, &len) == 0) {
765 void WpaGui::connectB()
768 size_t reply_len = sizeof(reply);
769 ctrlRequest("REASSOCIATE", reply, &reply_len);
773 void WpaGui::selectNetwork( const QString &sel )
777 size_t reply_len = sizeof(reply);
779 if (cmd.startsWith("Select any")) {
782 int pos = cmd.indexOf(':');
784 printf("Invalid selectNetwork '%s'\n",
785 cmd.toAscii().constData());
790 cmd.prepend("SELECT_NETWORK ");
791 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
796 void WpaGui::enableNetwork(const QString &sel)
800 size_t reply_len = sizeof(reply);
802 if (!cmd.startsWith("all")) {
803 int pos = cmd.indexOf(':');
805 printf("Invalid enableNetwork '%s'\n",
806 cmd.toAscii().constData());
811 cmd.prepend("ENABLE_NETWORK ");
812 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
817 void WpaGui::disableNetwork(const QString &sel)
821 size_t reply_len = sizeof(reply);
823 if (!cmd.startsWith("all")) {
824 int pos = cmd.indexOf(':');
826 printf("Invalid disableNetwork '%s'\n",
827 cmd.toAscii().constData());
832 cmd.prepend("DISABLE_NETWORK ");
833 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
838 void WpaGui::editNetwork(const QString &sel)
843 if (!cmd.startsWith("Select any")) {
844 int pos = sel.indexOf(':');
846 printf("Invalid editNetwork '%s'\n",
847 cmd.toAscii().constData());
854 NetworkConfig *nc = new NetworkConfig();
860 nc->paramsFromConfig(id);
869 void WpaGui::editSelectedNetwork()
871 if (networkSelect->count() < 1) {
872 QMessageBox::information(this, "No Networks",
873 "There are no networks to edit.\n");
876 QString sel(networkSelect->currentText());
881 void WpaGui::editListedNetwork()
883 if (networkList->currentRow() < 0) {
884 QMessageBox::information(this, "Select A Network",
885 "Select a network from the list to"
889 QString sel(networkList->currentItem()->text());
894 void WpaGui::triggerUpdate()
897 networkMayHaveChanged = true;
902 void WpaGui::addNetwork()
904 NetworkConfig *nc = new NetworkConfig();
914 void WpaGui::removeNetwork(const QString &sel)
918 size_t reply_len = sizeof(reply);
920 if (cmd.startsWith("Select any"))
923 if (!cmd.startsWith("all")) {
924 int pos = cmd.indexOf(':');
926 printf("Invalid removeNetwork '%s'\n",
927 cmd.toAscii().constData());
932 cmd.prepend("REMOVE_NETWORK ");
933 ctrlRequest(cmd.toAscii().constData(), reply, &reply_len);
938 void WpaGui::removeSelectedNetwork()
940 if (networkSelect->count() < 1) {
941 QMessageBox::information(this, "No Networks",
942 "There are no networks to remove.\n");
945 QString sel(networkSelect->currentText());
950 void WpaGui::removeListedNetwork()
952 if (networkList->currentRow() < 0) {
953 QMessageBox::information(this, "Select A Network",
954 "Select a network from the list to"
958 QString sel(networkList->currentItem()->text());
963 void WpaGui::enableAllNetworks()
970 void WpaGui::disableAllNetworks()
977 void WpaGui::removeAllNetworks()
984 int WpaGui::getNetworkDisabled(const QString &sel)
988 size_t reply_len = sizeof(reply) - 1;
989 int pos = cmd.indexOf(':');
991 printf("Invalid getNetworkDisabled '%s'\n",
992 cmd.toAscii().constData());
996 cmd.prepend("GET_NETWORK ");
997 cmd.append(" disabled");
999 if (ctrlRequest(cmd.toAscii().constData(), reply, &reply_len) >= 0
1000 && reply_len >= 1) {
1001 reply[reply_len] = '\0';
1002 if (!str_match(reply, "FAIL"))
1010 void WpaGui::updateNetworkDisabledStatus()
1012 if (networkList->currentRow() < 0)
1015 QString sel(networkList->currentItem()->text());
1017 switch (getNetworkDisabled(sel)) {
1019 if (!enableRadioButton->isChecked())
1020 enableRadioButton->setChecked(true);
1023 if (!disableRadioButton->isChecked())
1024 disableRadioButton->setChecked(true);
1030 void WpaGui::enableListedNetwork(bool enabled)
1032 if (networkList->currentRow() < 0 || !enabled)
1035 QString sel(networkList->currentItem()->text());
1037 if (getNetworkDisabled(sel) == 1)
1042 void WpaGui::disableListedNetwork(bool disabled)
1044 if (networkList->currentRow() < 0 || !disabled)
1047 QString sel(networkList->currentItem()->text());
1049 if (getNetworkDisabled(sel) == 0)
1050 disableNetwork(sel);
1054 void WpaGui::saveConfig()
1059 len = sizeof(buf) - 1;
1060 ctrlRequest("SAVE_CONFIG", buf, &len);
1064 if (str_match(buf, "FAIL"))
1065 QMessageBox::warning(this, "Failed to save configuration",
1066 "The configuration could not be saved.\n"
1068 "The update_config=1 configuration option\n"
1069 "must be used for configuration saving to\n"
1072 QMessageBox::information(this, "Saved configuration",
1073 "The current configuration was saved."
1078 void WpaGui::selectAdapter( const QString & sel )
1080 if (openCtrlConnection(sel.toAscii().constData()) < 0)
1081 printf("Failed to open control connection to "
1082 "wpa_supplicant.\n");
1088 void WpaGui::createTrayIcon()
1090 QApplication::setQuitOnLastWindowClosed(false);
1092 tray_icon = new QSystemTrayIcon(this);
1093 tray_icon->setToolTip(qAppName() + " - wpa_supplicant user interface");
1094 tray_icon->setIcon(QIcon(":/icons/wpa_gui.svg"));
1097 SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
1098 this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
1100 ackTrayIcon = false;
1102 tray_menu = new QMenu(this);
1104 disconnectAction = new QAction("&Disconnect", this);
1105 reconnectAction = new QAction("Re&connect", this);
1106 connect(disconnectAction, SIGNAL(triggered()), this,
1107 SLOT(disconnect()));
1108 connect(reconnectAction, SIGNAL(triggered()), this,
1110 tray_menu->addAction(disconnectAction);
1111 tray_menu->addAction(reconnectAction);
1112 tray_menu->addSeparator();
1114 eventAction = new QAction("&Event History", this);
1115 scanAction = new QAction("Scan &Results", this);
1116 statAction = new QAction("S&tatus", this);
1117 connect(eventAction, SIGNAL(triggered()), this, SLOT(eventHistory()));
1118 connect(scanAction, SIGNAL(triggered()), this, SLOT(scan()));
1119 connect(statAction, SIGNAL(triggered()), this, SLOT(showTrayStatus()));
1120 tray_menu->addAction(eventAction);
1121 tray_menu->addAction(scanAction);
1122 tray_menu->addAction(statAction);
1123 tray_menu->addSeparator();
1125 showAction = new QAction("&Show Window", this);
1126 hideAction = new QAction("&Hide Window", this);
1127 quitAction = new QAction("&Quit", this);
1128 connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
1129 connect(hideAction, SIGNAL(triggered()), this, SLOT(hide()));
1130 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
1131 tray_menu->addAction(showAction);
1132 tray_menu->addAction(hideAction);
1133 tray_menu->addSeparator();
1134 tray_menu->addAction(quitAction);
1136 tray_icon->setContextMenu(tray_menu);
1140 void WpaGui::showTrayMessage(QSystemTrayIcon::MessageIcon type, int sec,
1141 const QString & msg)
1143 if (!QSystemTrayIcon::supportsMessages())
1146 if (isVisible() || !tray_icon || !tray_icon->isVisible())
1149 tray_icon->showMessage(qAppName(), msg, type, sec * 1000);
1153 void WpaGui::trayActivated(QSystemTrayIcon::ActivationReason how)
1156 /* use close() here instead of hide() and allow the
1157 * custom closeEvent handler take care of children */
1158 case QSystemTrayIcon::Trigger:
1165 case QSystemTrayIcon::MiddleClick:
1174 void WpaGui::showTrayStatus()
1179 len = sizeof(buf) - 1;
1180 if (ctrlRequest("STATUS", buf, &len) < 0)
1184 QString msg, status(buf);
1186 QStringList lines = status.split(QRegExp("\\n"));
1187 for (QStringList::Iterator it = lines.begin();
1188 it != lines.end(); it++) {
1189 int pos = (*it).indexOf('=') + 1;
1193 if ((*it).startsWith("bssid="))
1194 msg.append("BSSID:\t" + (*it).mid(pos) + "\n");
1195 else if ((*it).startsWith("ssid="))
1196 msg.append("SSID: \t" + (*it).mid(pos) + "\n");
1197 else if ((*it).startsWith("pairwise_cipher="))
1198 msg.append("PAIR: \t" + (*it).mid(pos) + "\n");
1199 else if ((*it).startsWith("group_cipher="))
1200 msg.append("GROUP:\t" + (*it).mid(pos) + "\n");
1201 else if ((*it).startsWith("key_mgmt="))
1202 msg.append("AUTH: \t" + (*it).mid(pos) + "\n");
1203 else if ((*it).startsWith("wpa_state="))
1204 msg.append("STATE:\t" + (*it).mid(pos) + "\n");
1205 else if ((*it).startsWith("ip_address="))
1206 msg.append("IP: \t" + (*it).mid(pos) + "\n");
1207 else if ((*it).startsWith("Supplicant PAE state="))
1208 msg.append("PAE: \t" + (*it).mid(pos) + "\n");
1209 else if ((*it).startsWith("EAP state="))
1210 msg.append("EAP: \t" + (*it).mid(pos) + "\n");
1214 showTrayMessage(QSystemTrayIcon::Information, 10, msg);
1218 void WpaGui::closeEvent(QCloseEvent *event)
1238 if (tray_icon && !ackTrayIcon) {
1239 /* give user a visual hint that the tray icon exists */
1240 if (QSystemTrayIcon::supportsMessages()) {
1242 showTrayMessage(QSystemTrayIcon::Information, 3,
1243 qAppName() + " will keep running in "
1244 "the system tray.");
1246 QMessageBox::information(this, qAppName() + " systray",
1247 "The program will keep "
1248 "running in the system "