scanresults.ui.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. void ScanResults::init()
  13. {
  14. wpagui = NULL;
  15. }
  16. void ScanResults::destroy()
  17. {
  18. delete timer;
  19. }
  20. void ScanResults::setWpaGui(WpaGui *_wpagui)
  21. {
  22. wpagui = _wpagui;
  23. updateResults();
  24. timer = new QTimer(this);
  25. connect(timer, SIGNAL(timeout()), SLOT(getResults()));
  26. timer->start(10000, FALSE);
  27. }
  28. void ScanResults::updateResults()
  29. {
  30. char reply[8192];
  31. size_t reply_len;
  32. if (wpagui == NULL)
  33. return;
  34. reply_len = sizeof(reply) - 1;
  35. if (wpagui->ctrlRequest("SCAN_RESULTS", reply, &reply_len) < 0)
  36. return;
  37. reply[reply_len] = '\0';
  38. scanResultsView->clear();
  39. QString res(reply);
  40. QStringList lines = QStringList::split(QChar('\n'), res);
  41. bool first = true;
  42. for (QStringList::Iterator it = lines.begin(); it != lines.end(); it++) {
  43. if (first) {
  44. first = false;
  45. continue;
  46. }
  47. QStringList cols = QStringList::split(QChar('\t'), *it, true);
  48. QString ssid, bssid, freq, signal, flags;
  49. bssid = cols.count() > 0 ? cols[0] : "";
  50. freq = cols.count() > 1 ? cols[1] : "";
  51. signal = cols.count() > 2 ? cols[2] : "";
  52. flags = cols.count() > 3 ? cols[3] : "";
  53. ssid = cols.count() > 4 ? cols[4] : "";
  54. new Q3ListViewItem(scanResultsView, ssid, bssid, freq, signal, flags);
  55. }
  56. }
  57. void ScanResults::scanRequest()
  58. {
  59. char reply[10];
  60. size_t reply_len = sizeof(reply);
  61. if (wpagui == NULL)
  62. return;
  63. wpagui->ctrlRequest("SCAN", reply, &reply_len);
  64. }
  65. void ScanResults::getResults()
  66. {
  67. updateResults();
  68. }
  69. void ScanResults::bssSelected( Q3ListViewItem * sel )
  70. {
  71. NetworkConfig *nc = new NetworkConfig();
  72. if (nc == NULL)
  73. return;
  74. nc->setWpaGui(wpagui);
  75. nc->paramsFromScanResults(sel);
  76. nc->show();
  77. nc->exec();
  78. }