2 * wpa_gui - ScanResults class
3 * Copyright (c) 2005-2006, 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.
17 #include "scanresults.h"
19 #include "networkconfig.h"
22 ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
27 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
28 connect(scanButton, SIGNAL(clicked()), this, SLOT(scanRequest()));
29 connect(scanResultsWidget,
30 SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
31 SLOT(bssSelected(QTreeWidgetItem *)));
34 scanResultsWidget->setItemsExpandable(FALSE);
35 scanResultsWidget->setRootIsDecorated(FALSE);
39 ScanResults::~ScanResults()
44 void ScanResults::languageChange()
50 void ScanResults::setWpaGui(WpaGui *_wpagui)
57 void ScanResults::updateResults()
64 scanResultsWidget->clear();
68 snprintf(cmd, sizeof(cmd), "BSS %d", index++);
72 reply_len = sizeof(reply) - 1;
73 if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0)
75 reply[reply_len] = '\0';
78 if (bss.isEmpty() || bss.startsWith("FAIL"))
81 QString ssid, bssid, freq, signal, flags;
83 QStringList lines = bss.split(QRegExp("\\n"));
84 for (QStringList::Iterator it = lines.begin();
85 it != lines.end(); it++) {
86 int pos = (*it).indexOf('=') + 1;
90 if ((*it).startsWith("bssid="))
91 bssid = (*it).mid(pos);
92 else if ((*it).startsWith("freq="))
93 freq = (*it).mid(pos);
94 else if ((*it).startsWith("qual="))
95 signal = (*it).mid(pos);
96 else if ((*it).startsWith("flags="))
97 flags = (*it).mid(pos);
98 else if ((*it).startsWith("ssid="))
99 ssid = (*it).mid(pos);
102 QTreeWidgetItem *item = new QTreeWidgetItem(scanResultsWidget);
104 item->setText(0, ssid);
105 item->setText(1, bssid);
106 item->setText(2, freq);
107 item->setText(3, signal);
108 item->setText(4, flags);
117 void ScanResults::scanRequest()
120 size_t reply_len = sizeof(reply);
125 wpagui->ctrlRequest("SCAN", reply, &reply_len);
129 void ScanResults::getResults()
135 void ScanResults::bssSelected(QTreeWidgetItem *sel)
137 NetworkConfig *nc = new NetworkConfig();
140 nc->setWpaGui(wpagui);
141 nc->paramsFromScanResults(sel);