author | skyhusker <skyhusker> | 2005-04-20 10:25:20 (UTC) |
---|---|---|
committer | skyhusker <skyhusker> | 2005-04-20 10:25:20 (UTC) |
commit | e439d0e6eaa6704a8b1b89ea32aa8a0520738a04 (patch) (unidiff) | |
tree | 18c8b1eba5e1836f757765e4204d638500aa79f2 /noncore/net/opiestumbler/stumbler.cpp | |
parent | f6b9c85c09692f298ffa5ee95e1f171a9e158502 (diff) | |
download | opie-e439d0e6eaa6704a8b1b89ea32aa8a0520738a04.zip opie-e439d0e6eaa6704a8b1b89ea32aa8a0520738a04.tar.gz opie-e439d0e6eaa6704a8b1b89ea32aa8a0520738a04.tar.bz2 |
First commit of OpieStumbler, an application which performs wireless networks scanning using Wireless Extensions
Diffstat (limited to 'noncore/net/opiestumbler/stumbler.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opiestumbler/stumbler.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/noncore/net/opiestumbler/stumbler.cpp b/noncore/net/opiestumbler/stumbler.cpp new file mode 100644 index 0000000..cda6b99 --- a/dev/null +++ b/noncore/net/opiestumbler/stumbler.cpp | |||
@@ -0,0 +1,80 @@ | |||
1 | #include <qstring.h> | ||
2 | #include <qtimer.h> | ||
3 | #include <qapplication.h> | ||
4 | |||
5 | //#include <opie2/onetutils.h> | ||
6 | #include <opie2/onetwork.h> | ||
7 | #include <opie2/odebug.h> | ||
8 | |||
9 | #include "stumbler.h" | ||
10 | |||
11 | using namespace Opie::Net; | ||
12 | |||
13 | Stumbler::Stumbler(const QString &iface, QObject *parent, const char *name) | ||
14 | :QObject(parent, name), m_interval(5000), | ||
15 | m_wifaceName(iface), | ||
16 | m_timer(new QTimer(this)) | ||
17 | { | ||
18 | m_wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_wifaceName)); | ||
19 | connect(m_timer, SIGNAL(timeout()), this, SLOT(slotRefresh())); | ||
20 | } | ||
21 | |||
22 | |||
23 | void Stumbler::start() | ||
24 | { | ||
25 | if (!m_wiface) { | ||
26 | odebug << "Error, interface " << m_wifaceName << " does not exist" << oendl; | ||
27 | return; | ||
28 | } | ||
29 | |||
30 | if (!ONetwork::instance()->isWirelessInterface(m_wifaceName.ascii())) { | ||
31 | odebug << "Error, " << m_wifaceName << " is not a wireless interface" << oendl; | ||
32 | //FIXME: Tell the user about this | ||
33 | return; | ||
34 | } | ||
35 | |||
36 | if (!m_timer->isActive()) { | ||
37 | odebug << "Starting stumbler" << oendl; | ||
38 | m_wiface->setUp(FALSE); | ||
39 | m_wiface->setSSID("any"); | ||
40 | m_wiface->setAssociatedAP( OMacAddress::broadcast ); | ||
41 | m_wiface->setUp(TRUE); | ||
42 | m_timer->start(m_interval); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | void Stumbler::stop() | ||
47 | { | ||
48 | if (m_timer->isActive()) { | ||
49 | odebug << "Stoping stumbler" << oendl; | ||
50 | m_timer->stop(); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void Stumbler::setInterval(int msec) | ||
55 | { | ||
56 | m_interval = msec; | ||
57 | if (m_timer->isActive()) { | ||
58 | m_timer->stop(); | ||
59 | m_timer->start(m_interval); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | void Stumbler::setIface(const QString &iface) | ||
64 | { | ||
65 | m_wifaceName = iface; | ||
66 | m_wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_wifaceName)); | ||
67 | } | ||
68 | |||
69 | void Stumbler::slotRefresh() | ||
70 | { | ||
71 | m_stationList = m_wiface->scanNetwork(); | ||
72 | if ( qApp ) | ||
73 | qApp->processEvents(); | ||
74 | emit (newdata()); | ||
75 | } | ||
76 | |||
77 | Opie::Net::OStationList * Stumbler::stations() | ||
78 | { | ||
79 | return m_stationList; | ||
80 | } | ||