author | mickeyl <mickeyl> | 2003-03-30 03:06:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-30 03:06:07 (UTC) |
commit | 8e1504c3e8b8e5af509147f0b33f4e92a7c1c041 (patch) (unidiff) | |
tree | bb3b73b0d14c5f304405d473ed6a3ed381240652 | |
parent | e1c4cb3364f8f7ff68da88b5ec26053ee561c8a1 (diff) | |
download | opie-8e1504c3e8b8e5af509147f0b33f4e92a7c1c041.zip opie-8e1504c3e8b8e5af509147f0b33f4e92a7c1c041.tar.gz opie-8e1504c3e8b8e5af509147f0b33f4e92a7c1c041.tar.bz2 |
very interesting: gcc 2.9x does not handle operator? with mixed types, e.g. operator?(bool,QString,char*), while gcc 3.x does the necessary format conversion.
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 5bdc1b3..3bff7c4 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,228 +1,228 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ***********************************************************************/ | 14 | ***********************************************************************/ |
15 | 15 | ||
16 | // Qt | 16 | // Qt |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | #include <qsocketnotifier.h> | 22 | #include <qsocketnotifier.h> |
23 | 23 | ||
24 | // Opie | 24 | // Opie |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <opie/odevice.h> | 27 | #include <opie/odevice.h> |
28 | using namespace Opie; | 28 | using namespace Opie; |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include <opie2/oapplication.h> | 31 | #include <opie2/oapplication.h> |
32 | #include <opie2/onetwork.h> | 32 | #include <opie2/onetwork.h> |
33 | #include <opie2/opcap.h> | 33 | #include <opie2/opcap.h> |
34 | 34 | ||
35 | // Standard | 35 | // Standard |
36 | 36 | ||
37 | #include <assert.h> | 37 | #include <assert.h> |
38 | #include <errno.h> | 38 | #include <errno.h> |
39 | #include <unistd.h> | 39 | #include <unistd.h> |
40 | #include <string.h> | 40 | #include <string.h> |
41 | #include <sys/types.h> | 41 | #include <sys/types.h> |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | 43 | ||
44 | // Local | 44 | // Local |
45 | 45 | ||
46 | #include "wellenreiter.h" | 46 | #include "wellenreiter.h" |
47 | #include "scanlist.h" | 47 | #include "scanlist.h" |
48 | #include "logwindow.h" | 48 | #include "logwindow.h" |
49 | #include "hexwindow.h" | 49 | #include "hexwindow.h" |
50 | #include "configwindow.h" | 50 | #include "configwindow.h" |
51 | 51 | ||
52 | #include "manufacturers.h" | 52 | #include "manufacturers.h" |
53 | 53 | ||
54 | Wellenreiter::Wellenreiter( QWidget* parent ) | 54 | Wellenreiter::Wellenreiter( QWidget* parent ) |
55 | : WellenreiterBase( parent, 0, 0 ), | 55 | : WellenreiterBase( parent, 0, 0 ), |
56 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) | 56 | sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) |
57 | { | 57 | { |
58 | 58 | ||
59 | // | 59 | // |
60 | // construct manufacturer database | 60 | // construct manufacturer database |
61 | // | 61 | // |
62 | 62 | ||
63 | QString manufile; | 63 | QString manufile; |
64 | #ifdef QWS | 64 | #ifdef QWS |
65 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); | 65 | manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() ); |
66 | #else | 66 | #else |
67 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); | 67 | manufile.sprintf( "/usr/local/share/wellenreiter/manufacturers.dat" ); |
68 | #endif | 68 | #endif |
69 | manufacturerdb = new ManufacturerDB( manufile ); | 69 | manufacturerdb = new ManufacturerDB( manufile ); |
70 | 70 | ||
71 | logwindow->log( "(i) Wellenreiter has been started." ); | 71 | logwindow->log( "(i) Wellenreiter has been started." ); |
72 | 72 | ||
73 | // | 73 | // |
74 | // detect operating system | 74 | // detect operating system |
75 | // | 75 | // |
76 | 76 | ||
77 | #ifdef QWS | 77 | #ifdef QWS |
78 | QString sys; | 78 | QString sys; |
79 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 79 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
80 | _system = ODevice::inst()->system(); | 80 | _system = ODevice::inst()->system(); |
81 | logwindow->log( sys ); | 81 | logwindow->log( sys ); |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | // setup GUI | 84 | // setup GUI |
85 | netview->setColumnWidthMode( 1, QListView::Manual ); | 85 | netview->setColumnWidthMode( 1, QListView::Manual ); |
86 | 86 | ||
87 | if ( manufacturerdb ) | 87 | if ( manufacturerdb ) |
88 | netview->setManufacturerDB( manufacturerdb ); | 88 | netview->setManufacturerDB( manufacturerdb ); |
89 | 89 | ||
90 | pcap = new OPacketCapturer(); | 90 | pcap = new OPacketCapturer(); |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | Wellenreiter::~Wellenreiter() | 94 | Wellenreiter::~Wellenreiter() |
95 | { | 95 | { |
96 | // no need to delete child widgets, Qt does it all for us | 96 | // no need to delete child widgets, Qt does it all for us |
97 | 97 | ||
98 | delete manufacturerdb; | 98 | delete manufacturerdb; |
99 | delete pcap; | 99 | delete pcap; |
100 | } | 100 | } |
101 | 101 | ||
102 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 102 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
103 | { | 103 | { |
104 | configwindow = cw; | 104 | configwindow = cw; |
105 | } | 105 | } |
106 | 106 | ||
107 | void Wellenreiter::receivePacket(OPacket* p) | 107 | void Wellenreiter::receivePacket(OPacket* p) |
108 | { | 108 | { |
109 | logwindow->log( "(d) Received data from daemon" ); | 109 | logwindow->log( "(d) Received data from daemon" ); |
110 | //TODO | 110 | //TODO |
111 | 111 | ||
112 | // check if we received a beacon frame | 112 | // check if we received a beacon frame |
113 | // static_cast is justified here | 113 | // static_cast is justified here |
114 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); | 114 | OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); |
115 | if ( !beacon ) return; | 115 | if ( !beacon ) return; |
116 | QString type; | 116 | QString type; |
117 | 117 | ||
118 | //FIXME: Can stations in ESS mode can be distinguished from APs? | 118 | //FIXME: Can stations in ESS mode can be distinguished from APs? |
119 | //FIXME: Apparently yes, but not by listening to beacons, because | 119 | //FIXME: Apparently yes, but not by listening to beacons, because |
120 | //FIXME: they simply don't send beacons in infrastructure mode. | 120 | //FIXME: they simply don't send beacons in infrastructure mode. |
121 | //FIXME: so we also have to listen to data packets | 121 | //FIXME: so we also have to listen to data packets |
122 | 122 | ||
123 | if ( beacon->canIBSS() ) | 123 | if ( beacon->canIBSS() ) |
124 | type = "adhoc"; | 124 | type = "adhoc"; |
125 | else | 125 | else |
126 | type = "managed"; | 126 | type = "managed"; |
127 | 127 | ||
128 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 128 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
129 | QString essid = ssid ? ssid->ID() : "<unknown>"; | 129 | QString essid = ssid ? ssid->ID() : QString("<unknown>"); |
130 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 130 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
131 | int channel = ds ? ds->channel() : -1; | 131 | int channel = ds ? ds->channel() : -1; |
132 | 132 | ||
133 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 133 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
134 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); | 134 | netView()->addNewItem( type, essid, header->macAddress2().toString(), header->usesWep(), channel, 0 ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void Wellenreiter::startStopClicked() | 137 | void Wellenreiter::startStopClicked() |
138 | { | 138 | { |
139 | if ( sniffing ) | 139 | if ( sniffing ) |
140 | { | 140 | { |
141 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 141 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
142 | 142 | ||
143 | iface->setChannelHopping(); // stop hopping channels | 143 | iface->setChannelHopping(); // stop hopping channels |
144 | pcap->close(); | 144 | pcap->close(); |
145 | sniffing = false; | 145 | sniffing = false; |
146 | oApp->setTitle(); | 146 | oApp->setTitle(); |
147 | 147 | ||
148 | // get interface name from config window | 148 | // get interface name from config window |
149 | const QString& interface = configwindow->interfaceName->currentText(); | 149 | const QString& interface = configwindow->interfaceName->currentText(); |
150 | ONetwork* net = ONetwork::instance(); | 150 | ONetwork* net = ONetwork::instance(); |
151 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 151 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
152 | 152 | ||
153 | // switch off monitor mode | 153 | // switch off monitor mode |
154 | iface->setMonitorMode( false ); | 154 | iface->setMonitorMode( false ); |
155 | // switch off promisc flag | 155 | // switch off promisc flag |
156 | iface->setPromiscuousMode( false ); | 156 | iface->setPromiscuousMode( false ); |
157 | 157 | ||
158 | //TODO: Display "please wait..." (use owait?) | 158 | //TODO: Display "please wait..." (use owait?) |
159 | 159 | ||
160 | /* | 160 | /* |
161 | 161 | ||
162 | QString cmdline; | 162 | QString cmdline; |
163 | cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); | 163 | cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface ); |
164 | system( cmdline ); //FIXME: Use OProcess | 164 | system( cmdline ); //FIXME: Use OProcess |
165 | 165 | ||
166 | */ | 166 | */ |
167 | 167 | ||
168 | // message the user | 168 | // message the user |
169 | 169 | ||
170 | //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); | 170 | //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); |
171 | } | 171 | } |
172 | 172 | ||
173 | else | 173 | else |
174 | { | 174 | { |
175 | // get configuration from config window | 175 | // get configuration from config window |
176 | 176 | ||
177 | const QString& interface = configwindow->interfaceName->currentText(); | 177 | const QString& interface = configwindow->interfaceName->currentText(); |
178 | const int cardtype = configwindow->daemonDeviceType(); | 178 | const int cardtype = configwindow->daemonDeviceType(); |
179 | const int interval = configwindow->daemonHopInterval(); | 179 | const int interval = configwindow->daemonHopInterval(); |
180 | 180 | ||
181 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 181 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
182 | { | 182 | { |
183 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); | 183 | QMessageBox::information( this, "Wellenreiter II", "Your device is not\nproperly configured. Please reconfigure!" ); |
184 | return; | 184 | return; |
185 | } | 185 | } |
186 | 186 | ||
187 | // configure device | 187 | // configure device |
188 | 188 | ||
189 | ONetwork* net = ONetwork::instance(); | 189 | ONetwork* net = ONetwork::instance(); |
190 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); | 190 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); |
191 | 191 | ||
192 | // set monitor mode | 192 | // set monitor mode |
193 | 193 | ||
194 | switch ( cardtype ) | 194 | switch ( cardtype ) |
195 | { | 195 | { |
196 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; | 196 | case 1: iface->setMonitoring( new OCiscoMonitoringInterface( iface ) ); break; |
197 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; | 197 | case 2: iface->setMonitoring( new OWlanNGMonitoringInterface( iface ) ); break; |
198 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; | 198 | case 3: iface->setMonitoring( new OHostAPMonitoringInterface( iface ) ); break; |
199 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; | 199 | case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; |
200 | default: assert( 0 ); // shouldn't happen | 200 | default: assert( 0 ); // shouldn't happen |
201 | } | 201 | } |
202 | 202 | ||
203 | iface->setMonitorMode( true ); | 203 | iface->setMonitorMode( true ); |
204 | 204 | ||
205 | // open pcap and start sniffing | 205 | // open pcap and start sniffing |
206 | pcap->open( interface ); | 206 | pcap->open( interface ); |
207 | 207 | ||
208 | if ( !pcap->isOpen() ) | 208 | if ( !pcap->isOpen() ) |
209 | { | 209 | { |
210 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); | 210 | QMessageBox::warning( this, "Wellenreiter II", "Can't open packet capturer:\n" + QString(strerror( errno ) )); |
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | 213 | ||
214 | // set capturer to non-blocking mode | 214 | // set capturer to non-blocking mode |
215 | pcap->setBlocking( false ); | 215 | pcap->setBlocking( false ); |
216 | 216 | ||
217 | // start channel hopper | 217 | // start channel hopper |
218 | iface->setChannelHopping( 1000 ); //use interval from config window | 218 | iface->setChannelHopping( 1000 ); //use interval from config window |
219 | 219 | ||
220 | // connect | 220 | // connect |
221 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 221 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
222 | 222 | ||
223 | logwindow->log( "(i) Daemon has been started." ); | 223 | logwindow->log( "(i) Daemon has been started." ); |
224 | oApp->setTitle( "Scanning ..." ); | 224 | oApp->setTitle( "Scanning ..." ); |
225 | sniffing = true; | 225 | sniffing = true; |
226 | 226 | ||
227 | } | 227 | } |
228 | } | 228 | } |