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.
15 #include "scanresults.h"
17 #include "networkconfig.h"
20 ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
25 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
26 connect(scanButton, SIGNAL(clicked()), this, SLOT(scanRequest()));
27 connect(scanResultsWidget,
28 SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
29 SLOT(bssSelected(QTreeWidgetItem *)));
32 scanResultsWidget->setItemsExpandable(FALSE);
33 scanResultsWidget->setRootIsDecorated(FALSE);
37 ScanResults::~ScanResults()
42 void ScanResults::languageChange()
48 void ScanResults::setWpaGui(WpaGui *_wpagui)
55 void ScanResults::updateResults()
62 scanResultsWidget->clear();
66 snprintf(cmd, sizeof(cmd), "BSS %d", index++);
70 reply_len = sizeof(reply) - 1;
71 if (wpagui->ctrlRequest(cmd, reply, &reply_len) < 0)
73 reply[reply_len] = '\0';
76 if (bss.isEmpty() || bss.startsWith("FAIL"))
79 QString ssid, bssid, freq, signal, flags;
81 QStringList lines = bss.split(QRegExp("\\n"));
82 for (QStringList::Iterator it = lines.begin();
83 it != lines.end(); it++) {
84 int pos = (*it).indexOf('=') + 1;
88 if ((*it).startsWith("bssid="))
89 bssid = (*it).mid(pos);
90 else if ((*it).startsWith("freq="))
91 freq = (*it).mid(pos);
92 else if ((*it).startsWith("qual="))
93 signal = (*it).mid(pos);
94 else if ((*it).startsWith("flags="))
95 flags = (*it).mid(pos);
96 else if ((*it).startsWith("ssid="))
97 ssid = (*it).mid(pos);
100 QTreeWidgetItem *item = new QTreeWidgetItem(scanResultsWidget);
102 item->setText(0, ssid);
103 item->setText(1, bssid);
104 item->setText(2, freq);
105 item->setText(3, signal);
106 item->setText(4, flags);
115 void ScanResults::scanRequest()
118 size_t reply_len = sizeof(reply);
123 wpagui->ctrlRequest("SCAN", reply, &reply_len);
127 void ScanResults::getResults()
133 void ScanResults::bssSelected(QTreeWidgetItem *sel)
135 NetworkConfig *nc = new NetworkConfig();
138 nc->setWpaGui(wpagui);
139 nc->paramsFromScanResults(sel);