1/**************************************************************************** 2** ui.h extension file, included from the uic-generated form implementation. 3** 4** If you want to add, delete, or rename functions or slots, use 5** Qt Designer to update this file, preserving your code. 6** 7** You should not define a constructor or destructor in this file. 8** Instead, write your code in functions called init() and destroy(). 9** These will automatically be called by the form's constructor and 10** destructor. 11*****************************************************************************/ 12 13void ScanResults::init() 14{ 15 wpagui = NULL; 16} 17 18 19void ScanResults::destroy() 20{ 21 delete timer; 22} 23 24 25void ScanResults::setWpaGui(WpaGui *_wpagui) 26{ 27 wpagui = _wpagui; 28 updateResults(); 29 30 timer = new QTimer(this); 31 connect(timer, SIGNAL(timeout()), SLOT(getResults())); 32 timer->start(10000, FALSE); 33} 34 35 36void ScanResults::updateResults() 37{ 38 char reply[8192]; 39 size_t reply_len; 40 41 if (wpagui == NULL) 42 return; 43 44 reply_len = sizeof(reply) - 1; 45 if (wpagui->ctrlRequest("SCAN_RESULTS", reply, &reply_len) < 0) 46 return; 47 reply[reply_len] = '\0'; 48 49 scanResultsView->clear(); 50 51 QString res(reply); 52 QStringList lines = QStringList::split(QChar('\n'), res); 53 bool first = true; 54 for (QStringList::Iterator it = lines.begin(); it != lines.end(); it++) { 55 if (first) { 56 first = false; 57 continue; 58 } 59 60 QStringList cols = QStringList::split(QChar('\t'), *it, true); 61 QString ssid, bssid, freq, signal, flags; 62 bssid = cols.count() > 0 ? cols[0] : ""; 63 freq = cols.count() > 1 ? cols[1] : ""; 64 signal = cols.count() > 2 ? cols[2] : ""; 65 flags = cols.count() > 3 ? cols[3] : ""; 66 ssid = cols.count() > 4 ? cols[4] : ""; 67 new Q3ListViewItem(scanResultsView, ssid, bssid, freq, signal, flags); 68 } 69} 70 71 72void ScanResults::scanRequest() 73{ 74 char reply[10]; 75 size_t reply_len = sizeof(reply); 76 77 if (wpagui == NULL) 78 return; 79 80 wpagui->ctrlRequest("SCAN", reply, &reply_len); 81} 82 83 84void ScanResults::getResults() 85{ 86 updateResults(); 87} 88 89 90 91 92void ScanResults::bssSelected( Q3ListViewItem * sel ) 93{ 94 NetworkConfig *nc = new NetworkConfig(); 95 if (nc == NULL) 96 return; 97 nc->setWpaGui(wpagui); 98 nc->paramsFromScanResults(sel); 99 nc->show(); 100 nc->exec(); 101} 102