~ubuntu-branches/ubuntu/gutsy/wpasupplicant/gutsy

« back to all changes in this revision

Viewing changes to wpa_supplicant/wpa_gui-qt4/scanresults.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler, Alexander Sack
  • Date: 2007-08-26 16:06:57 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070826160657-2m8pxoweuxe8f93t
Tags: 0.6.0+0.5.8-0ubuntu1
* New upstream release
* remove patch 11_erroneous_manpage_ref, applied upstream
* remove patch 25_wpas_dbus_unregister_iface_fix, applied upstream

[ Alexander Sack ]
* bumping upstream version to replace development version 0.6.0 with
  this package from stable release branch.
* attempt to fix wierd timeout and high latency issues by going
  back to stable upstream version (0.5.9) (LP: #140763,
  LP: #141233).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * wpa_gui - ScanResults class
3
 
 * Copyright (c) 2005-2006, Jouni Malinen <j@w1.fi>
4
 
 *
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.
8
 
 *
9
 
 * Alternatively, this software may be distributed under the terms of BSD
10
 
 * license.
11
 
 *
12
 
 * See README and COPYING for more details.
13
 
 */
14
 
 
15
 
#include <QTimer>
16
 
 
17
 
#include "scanresults.h"
18
 
#include "wpagui.h"
19
 
#include "networkconfig.h"
20
 
 
21
 
 
22
 
ScanResults::ScanResults(QWidget *parent, const char *, bool, Qt::WFlags)
23
 
        : QDialog(parent)
24
 
{
25
 
        setupUi(this);
26
 
 
27
 
        connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
28
 
        connect(scanButton, SIGNAL(clicked()), this, SLOT(scanRequest()));
29
 
        connect(scanResultsView, SIGNAL(doubleClicked(Q3ListViewItem *)), this,
30
 
                SLOT(bssSelected(Q3ListViewItem *)));
31
 
 
32
 
        wpagui = NULL;
33
 
}
34
 
 
35
 
 
36
 
ScanResults::~ScanResults()
37
 
{
38
 
        delete timer;
39
 
}
40
 
 
41
 
 
42
 
void ScanResults::languageChange()
43
 
{
44
 
        retranslateUi(this);
45
 
}
46
 
 
47
 
 
48
 
void ScanResults::setWpaGui(WpaGui *_wpagui)
49
 
{
50
 
        wpagui = _wpagui;
51
 
        updateResults();
52
 
    
53
 
        timer = new QTimer(this);
54
 
        connect(timer, SIGNAL(timeout()), SLOT(getResults()));
55
 
        timer->start(10000, FALSE);
56
 
}
57
 
 
58
 
 
59
 
void ScanResults::updateResults()
60
 
{
61
 
        char reply[8192];
62
 
        size_t reply_len;
63
 
    
64
 
        if (wpagui == NULL)
65
 
                return;
66
 
 
67
 
        reply_len = sizeof(reply) - 1;
68
 
        if (wpagui->ctrlRequest("SCAN_RESULTS", reply, &reply_len) < 0)
69
 
                return;
70
 
        reply[reply_len] = '\0';
71
 
 
72
 
        scanResultsView->clear();
73
 
    
74
 
        QString res(reply);
75
 
        QStringList lines = QStringList::split(QChar('\n'), res);
76
 
        bool first = true;
77
 
        for (QStringList::Iterator it = lines.begin(); it != lines.end(); it++)
78
 
        {
79
 
                if (first) {
80
 
                        first = false;
81
 
                        continue;
82
 
                }
83
 
        
84
 
                QStringList cols = QStringList::split(QChar('\t'), *it, true);
85
 
                QString ssid, bssid, freq, signal, flags;
86
 
                bssid = cols.count() > 0 ? cols[0] : "";
87
 
                freq = cols.count() > 1 ? cols[1] : "";
88
 
                signal = cols.count() > 2 ? cols[2] : "";
89
 
                flags = cols.count() > 3 ? cols[3] : "";
90
 
                ssid = cols.count() > 4 ? cols[4] : "";
91
 
                new Q3ListViewItem(scanResultsView, ssid, bssid, freq, signal,
92
 
                                   flags);
93
 
        }
94
 
}
95
 
 
96
 
 
97
 
void ScanResults::scanRequest()
98
 
{
99
 
        char reply[10];
100
 
        size_t reply_len = sizeof(reply);
101
 
    
102
 
        if (wpagui == NULL)
103
 
                return;
104
 
    
105
 
        wpagui->ctrlRequest("SCAN", reply, &reply_len);
106
 
}
107
 
 
108
 
 
109
 
void ScanResults::getResults()
110
 
{
111
 
        updateResults();
112
 
}
113
 
 
114
 
 
115
 
void ScanResults::bssSelected( Q3ListViewItem * sel )
116
 
{
117
 
        NetworkConfig *nc = new NetworkConfig();
118
 
        if (nc == NULL)
119
 
                return;
120
 
        nc->setWpaGui(wpagui);
121
 
        nc->paramsFromScanResults(sel);
122
 
        nc->show();
123
 
        nc->exec();
124
 
}