-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index ca53471..48fe89c 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -1,474 +1,474 @@ | |||
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 | /* LOCAL */ | 16 | /* LOCAL */ |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "mainwindow.h" | 18 | #include "mainwindow.h" |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #include <opie2/onetwork.h> | 21 | #include <opie2/onetwork.h> |
22 | #ifdef QWS | 22 | #ifdef QWS |
23 | #include <opie2/oapplication.h> | 23 | #include <opie2/oapplication.h> |
24 | #include <opie2/oconfig.h> | 24 | #include <opie2/oconfig.h> |
25 | #include <opie2/odevice.h> | 25 | #include <opie2/odevice.h> |
26 | using namespace Opie; | 26 | using namespace Opie; |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | /* QT */ | 29 | /* QT */ |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qcheckbox.h> | 31 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qlineedit.h> | 34 | #include <qlineedit.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
39 | #include <qtoolbutton.h> | 39 | #include <qtoolbutton.h> |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | 42 | ||
43 | /* POSIX */ | 43 | /* POSIX */ |
44 | #include <assert.h> | 44 | #include <assert.h> |
45 | 45 | ||
46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
47 | 47 | ||
48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) | 48 | WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) |
49 | :WellenreiterConfigBase( parent, name, true, f ) | 49 | :WellenreiterConfigBase( parent, name, true, f ) |
50 | { | 50 | { |
51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; | 51 | _devicetype[ "cisco" ] = DEVTYPE_CISCO; |
52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; | 52 | _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; |
53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; | 53 | _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; |
54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; | 54 | _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; |
55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; | 55 | _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; |
56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; | 56 | _devicetype[ "<file>" ] = DEVTYPE_FILE; |
57 | 57 | ||
58 | // gather possible interface names from ONetwork | 58 | // gather possible interface names from ONetwork |
59 | ONetwork* net = ONetwork::instance(); | 59 | ONetwork* net = ONetwork::instance(); |
60 | ONetwork::InterfaceIterator it = net->iterator(); | 60 | ONetwork::InterfaceIterator it = net->iterator(); |
61 | while ( it.current() ) | 61 | while ( it.current() ) |
62 | { | 62 | { |
63 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
64 | interfaceName->insertItem( it.current()->name() ); | 64 | interfaceName->insertItem( it.current()->name() ); |
65 | ++it; | 65 | ++it; |
66 | } | 66 | } |
67 | 67 | ||
68 | load(); | 68 | load(); |
69 | 69 | ||
70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here | 70 | #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here |
71 | QPushButton* okButton = new QPushButton( "ok", this ); | 71 | QPushButton* okButton = new QPushButton( "ok", this ); |
72 | okButton->show(); | 72 | okButton->show(); |
73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui | 73 | WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui |
74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 74 | connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | WellenreiterConfigWindow::_instance = this; | 77 | WellenreiterConfigWindow::_instance = this; |
78 | 78 | ||
79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); | 80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); |
81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); | 81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); |
82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); | 82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); |
83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
84 | 84 | ||
85 | // make the checkbox 'channelAll' control all other channels | 85 | // make the checkbox 'channelAll' control all other channels |
86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
87 | 87 | ||
88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | 88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); |
89 | 89 | ||
90 | // hide tab4 (parse) until Wellenreiter 1.2 | 90 | // hide tab4 (parse) until Wellenreiter 1.2 |
91 | tab->removePage( tab_4 ); | 91 | tab->removePage( tab_4 ); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | void WellenreiterConfigWindow::accept() | 95 | void WellenreiterConfigWindow::accept() |
96 | { | 96 | { |
97 | save(); | 97 | save(); |
98 | QDialog::accept(); | 98 | QDialog::accept(); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() |
103 | { | 103 | { |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void WellenreiterConfigWindow::performAutodetection() | 107 | void WellenreiterConfigWindow::performAutodetection() |
108 | { | 108 | { |
109 | //TODO: insert modal splash screen here | 109 | //TODO: insert modal splash screen here |
110 | // and sleep a second, so that it looks | 110 | // and sleep a second, so that it looks |
111 | // like we're actually doing something fancy... ;-) | 111 | // like we're actually doing something fancy... ;-) |
112 | 112 | ||
113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); |
114 | 114 | ||
115 | // try to guess device type | 115 | // try to guess device type |
116 | QFile m( "/proc/modules" ); | 116 | QFile m( "/proc/modules" ); |
117 | if ( m.open( IO_ReadOnly ) ) | 117 | if ( m.open( IO_ReadOnly ) ) |
118 | { | 118 | { |
119 | int devicetype(0); | 119 | int devicetype(0); |
120 | QString line; | 120 | QString line; |
121 | QTextStream modules( &m ); | 121 | QTextStream modules( &m ); |
122 | while( !modules.atEnd() && !devicetype ) | 122 | while( !modules.atEnd() && !devicetype ) |
123 | { | 123 | { |
124 | modules >> line; | 124 | modules >> line; |
125 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; | 125 | if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; |
126 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; | 126 | else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; |
127 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; | 127 | else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; |
128 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; | 128 | else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; |
129 | } | 129 | } |
130 | if ( devicetype ) | 130 | if ( devicetype ) |
131 | { | 131 | { |
132 | deviceType->setCurrentItem( devicetype ); | 132 | deviceType->setCurrentItem( devicetype ); |
133 | _guess = devicetype; | 133 | _guess = devicetype; |
134 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); | 134 | qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | int WellenreiterConfigWindow::driverType() const | 140 | int WellenreiterConfigWindow::driverType() const |
141 | { | 141 | { |
142 | QString name = deviceType->currentText(); | 142 | QString name = deviceType->currentText(); |
143 | if ( _devicetype.contains( name ) ) | 143 | if ( _devicetype.contains( name ) ) |
144 | { | 144 | { |
145 | return _devicetype[name]; | 145 | return _devicetype[name]; |
146 | } | 146 | } |
147 | else | 147 | else |
148 | { | 148 | { |
149 | return 0; | 149 | return 0; |
150 | } | 150 | } |
151 | }; | 151 | }; |
152 | 152 | ||
153 | 153 | ||
154 | int WellenreiterConfigWindow::hoppingInterval() const | 154 | int WellenreiterConfigWindow::hoppingInterval() const |
155 | { | 155 | { |
156 | return hopInterval->cleanText().toInt(); | 156 | return hopInterval->cleanText().toInt(); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
160 | bool WellenreiterConfigWindow::usePrismHeader() const | 160 | bool WellenreiterConfigWindow::usePrismHeader() const |
161 | { | 161 | { |
162 | return prismHeader->isChecked(); | 162 | return prismHeader->isChecked(); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const | 166 | bool WellenreiterConfigWindow::isChannelChecked( int channel ) const |
167 | { | 167 | { |
168 | switch ( channel ) | 168 | switch ( channel ) |
169 | { | 169 | { |
170 | case 1: return channel1->isOn(); | 170 | case 1: return channel1->isOn(); |
171 | case 2: return channel2->isOn(); | 171 | case 2: return channel2->isOn(); |
172 | case 3: return channel3->isOn(); | 172 | case 3: return channel3->isOn(); |
173 | case 4: return channel4->isOn(); | 173 | case 4: return channel4->isOn(); |
174 | case 5: return channel5->isOn(); | 174 | case 5: return channel5->isOn(); |
175 | case 6: return channel6->isOn(); | 175 | case 6: return channel6->isOn(); |
176 | case 7: return channel7->isOn(); | 176 | case 7: return channel7->isOn(); |
177 | case 8: return channel8->isOn(); | 177 | case 8: return channel8->isOn(); |
178 | case 9: return channel9->isOn(); | 178 | case 9: return channel9->isOn(); |
179 | case 10: return channel10->isOn(); | 179 | case 10: return channel10->isOn(); |
180 | case 11: return channel11->isOn(); | 180 | case 11: return channel11->isOn(); |
181 | case 12: return channel12->isOn(); | 181 | case 12: return channel12->isOn(); |
182 | case 13: return channel13->isOn(); | 182 | case 13: return channel13->isOn(); |
183 | case 14: return channel14->isOn(); | 183 | case 14: return channel14->isOn(); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | 187 | ||
188 | void WellenreiterConfigWindow::changedDeviceType(int t) | 188 | void WellenreiterConfigWindow::changedDeviceType(int t) |
189 | { | 189 | { |
190 | if ( t != DEVTYPE_FILE ) return; | 190 | if ( t != DEVTYPE_FILE ) return; |
191 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); | 191 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); |
192 | if ( !name.isEmpty() && QFile::exists( name ) ) | 192 | if ( !name.isEmpty() && QFile::exists( name ) ) |
193 | { | 193 | { |
194 | interfaceName->insertItem( name ); | 194 | interfaceName->insertItem( name ); |
195 | interfaceName->setCurrentItem( interfaceName->count()-1 ); | 195 | interfaceName->setCurrentItem( interfaceName->count()-1 ); |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | deviceType->setCurrentItem( _guess ); | 199 | deviceType->setCurrentItem( _guess ); |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() | 205 | void WellenreiterConfigWindow::synchronizeActionsAndScripts() |
206 | { | 206 | { |
207 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); | 207 | if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); |
208 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); | 208 | if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); |
209 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); | 209 | if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); |
210 | 210 | ||
211 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); | 211 | //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); |
212 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); | 212 | //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); |
213 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); | 213 | //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void WellenreiterConfigWindow::changedNetworkAction(int t) | 217 | void WellenreiterConfigWindow::changedNetworkAction(int t) |
218 | { | 218 | { |
219 | synchronizeActionsAndScripts(); | 219 | synchronizeActionsAndScripts(); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void WellenreiterConfigWindow::changedClientAction(int t) | 223 | void WellenreiterConfigWindow::changedClientAction(int t) |
224 | { | 224 | { |
225 | synchronizeActionsAndScripts(); | 225 | synchronizeActionsAndScripts(); |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void WellenreiterConfigWindow::changedStationAction(int t) | 229 | void WellenreiterConfigWindow::changedStationAction(int t) |
230 | { | 230 | { |
231 | synchronizeActionsAndScripts(); | 231 | synchronizeActionsAndScripts(); |
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | void WellenreiterConfigWindow::getCaptureFileNameClicked() | 235 | void WellenreiterConfigWindow::getCaptureFileNameClicked() |
236 | { | 236 | { |
237 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); | 237 | QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); |
238 | qDebug( "name = %s", (const char*) name ); | 238 | qDebug( "name = %s", (const char*) name ); |
239 | if ( !name.isEmpty() ) | 239 | if ( !name.isEmpty() ) |
240 | { | 240 | { |
241 | captureFileName->setText( name ); | 241 | captureFileName->setText( name ); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | void WellenreiterConfigWindow::channelAllClicked(int state) | 246 | void WellenreiterConfigWindow::channelAllClicked(int state) |
247 | { | 247 | { |
248 | bool b = state; | 248 | bool b = state; |
249 | channel1->setChecked( b ); | 249 | channel1->setChecked( b ); |
250 | channel2->setChecked( b ); | 250 | channel2->setChecked( b ); |
251 | channel3->setChecked( b ); | 251 | channel3->setChecked( b ); |
252 | channel4->setChecked( b ); | 252 | channel4->setChecked( b ); |
253 | channel5->setChecked( b ); | 253 | channel5->setChecked( b ); |
254 | channel6->setChecked( b ); | 254 | channel6->setChecked( b ); |
255 | channel7->setChecked( b ); | 255 | channel7->setChecked( b ); |
256 | channel8->setChecked( b ); | 256 | channel8->setChecked( b ); |
257 | channel9->setChecked( b ); | 257 | channel9->setChecked( b ); |
258 | channel10->setChecked( b ); | 258 | channel10->setChecked( b ); |
259 | channel11->setChecked( b ); | 259 | channel11->setChecked( b ); |
260 | channel12->setChecked( b ); | 260 | channel12->setChecked( b ); |
261 | channel13->setChecked( b ); | 261 | channel13->setChecked( b ); |
262 | channel14->setChecked( b ); | 262 | channel14->setChecked( b ); |
263 | } | 263 | } |
264 | 264 | ||
265 | 265 | ||
266 | bool WellenreiterConfigWindow::useGPS() const | 266 | bool WellenreiterConfigWindow::useGPS() const |
267 | { | 267 | { |
268 | return enableGPS->isChecked(); | 268 | return enableGPS->isChecked(); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | const QString WellenreiterConfigWindow::gpsHost() const | 272 | const QString WellenreiterConfigWindow::gpsHost() const |
273 | { | 273 | { |
274 | return useGPS() ? gpsdHost->currentText() : QString::null; | 274 | return useGPS() ? gpsdHost->currentText() : QString::null; |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | int WellenreiterConfigWindow::gpsPort() const | 278 | int WellenreiterConfigWindow::gpsPort() const |
279 | { | 279 | { |
280 | bool ok; | 280 | bool ok; |
281 | return useGPS() ? gpsdPort->value() : -1; | 281 | return useGPS() ? gpsdPort->value() : -1; |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | void WellenreiterConfigWindow::performAction( const QString& type, | 285 | void WellenreiterConfigWindow::performAction( const QString& type, |
286 | const QString& essid, | 286 | const QString& essid, |
287 | const QString& mac, | 287 | const QString& mac, |
288 | bool wep, | 288 | bool wep, |
289 | int channel, | 289 | int channel, |
290 | int signal | 290 | int signal |
291 | /* , const GpsLocation& loc */ ) | 291 | /* , const GpsLocation& loc */ ) |
292 | { | 292 | { |
293 | int action; | 293 | int action; |
294 | QString script; | 294 | QString script; |
295 | 295 | ||
296 | if ( type == "network" ) | 296 | if ( type == "network" ) |
297 | { | 297 | { |
298 | action = newNetworkAction->currentItem(); | 298 | action = newNetworkAction->currentItem(); |
299 | script = newNetworkScript->text(); | 299 | script = newNetworkScript->text(); |
300 | } | 300 | } |
301 | else if ( type == "managed" || type == "adhoc" ) | 301 | else if ( type == "managed" || type == "adhoc" ) |
302 | { | 302 | { |
303 | action = newClientAction->currentItem(); | 303 | action = newClientAction->currentItem(); |
304 | script = newClientScript->text(); | 304 | script = newClientScript->text(); |
305 | } | 305 | } |
306 | else if ( type == "station" ) | 306 | else if ( type == "station" ) |
307 | { | 307 | { |
308 | action = newStationAction->currentItem(); | 308 | action = newStationAction->currentItem(); |
309 | script = newStationScript->text(); | 309 | script = newStationScript->text(); |
310 | } | 310 | } |
311 | else | 311 | else |
312 | { | 312 | { |
313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
314 | return; | 314 | return; |
315 | } | 315 | } |
316 | 316 | ||
317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); | 317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); |
318 | 318 | ||
319 | switch( action ) | 319 | switch( action ) |
320 | { | 320 | { |
321 | case 0: /* Ignore */ return; | 321 | case 0: /* Ignore */ return; |
322 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; | 322 | case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; |
323 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; | 323 | case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; |
324 | case 3: /* Blink LED */ break; //FIXME: Implement this | 324 | case 3: /* Blink LED */ break; //FIXME: Implement this |
325 | case 4: /* Run Script */ | 325 | case 4: /* Run Script */ |
326 | { | 326 | { |
327 | /** | 327 | /** |
328 | * | 328 | * |
329 | * Script Substitution Information: | 329 | * Script Substitution Information: |
330 | * | 330 | * |
331 | * $SSID = SSID | 331 | * $SSID = SSID |
332 | * $MAC = MAC | 332 | * $MAC = MAC |
333 | * $WEP = Wep | 333 | * $WEP = Wep |
334 | * $CHAN = Channel | 334 | * $CHAN = Channel |
335 | * | 335 | * |
336 | **/ | 336 | **/ |
337 | script = script.replace( QRegExp( "$SSID" ), essid ); | 337 | script = script.replace( QRegExp( "$SSID" ), essid ); |
338 | script = script.replace( QRegExp( "$MAC" ), mac ); | 338 | script = script.replace( QRegExp( "$MAC" ), mac ); |
339 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); | 339 | script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); |
340 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); | 340 | script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); |
341 | 341 | ||
342 | qDebug( "going to call script '%s'", (const char*) script ); | 342 | qDebug( "going to call script '%s'", (const char*) script ); |
343 | ::system( script ); | 343 | ::system( script ); |
344 | qDebug( "script returned." ); | 344 | qDebug( "script returned." ); |
345 | return; | 345 | return; |
346 | } | 346 | } |
347 | default: assert( false ); | 347 | default: assert( false ); |
348 | } | 348 | } |
349 | } | 349 | } |
350 | 350 | ||
351 | 351 | ||
352 | void WellenreiterConfigWindow::load() | 352 | void WellenreiterConfigWindow::load() |
353 | { | 353 | { |
354 | #ifdef Q_WS_X11 | 354 | #ifdef Q_WS_X11 |
355 | #warning Persistent Configuration not yet implemented for standalone X11 build | 355 | #warning Persistent Configuration not yet implemented for standalone X11 build |
356 | performAutodetection(); | 356 | performAutodetection(); |
357 | #else | 357 | #else |
358 | qDebug( "loading configuration settings..." ); | 358 | qDebug( "loading configuration settings..." ); |
359 | 359 | ||
360 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 360 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
361 | 361 | ||
362 | OConfig* c = oApp->config(); | 362 | OConfig* c = oApp->config(); |
363 | 363 | ||
364 | c->setGroup( "Interface" ); | 364 | c->setGroup( "Interface" ); |
365 | 365 | ||
366 | QString interface = c->readEntry( "name", "<none>" ); | 366 | QString interface = c->readEntry( "name", "<none>" ); |
367 | if ( interface != "<none>" ) | 367 | if ( interface != "<none>" ) |
368 | { | 368 | { |
369 | #if QT_VERSION < 300 | 369 | #if QT_VERSION < 300 |
370 | interfaceName->insertItem( interface, 0 ); | 370 | interfaceName->insertItem( interface, 0 ); |
371 | interfaceName->setCurrentItem( 0 ); | 371 | interfaceName->setCurrentItem( 0 ); |
372 | #else | 372 | #else |
373 | interfaceName->setCurrentText( interface ); | 373 | interfaceName->setCurrentText( interface ); |
374 | #endif | 374 | #endif |
375 | 375 | ||
376 | QString device = c->readEntry( "type", "<select>" ); | 376 | QString device = c->readEntry( "type", "<select>" ); |
377 | #if QT_VERSION < 300 | 377 | #if QT_VERSION < 300 |
378 | for ( int i = 0; i < deviceType->count(); ++i ) | 378 | for ( int i = 0; i < deviceType->count(); ++i ) |
379 | { | 379 | { |
380 | if ( deviceType->text( i ) == device ) | 380 | if ( deviceType->text( i ) == device ) |
381 | { | 381 | { |
382 | deviceType->setCurrentItem( i ); | 382 | deviceType->setCurrentItem( i ); |
383 | break; | 383 | break; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | #else | 386 | #else |
387 | deviceType->setCurrentText( device ); | 387 | deviceType->setCurrentText( device ); |
388 | #endif | 388 | #endif |
389 | } | 389 | } |
390 | else | 390 | else |
391 | { | 391 | { |
392 | performAutodetection(); | 392 | performAutodetection(); |
393 | } | 393 | } |
394 | 394 | ||
395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
399 | 399 | ||
400 | c->setGroup( "Capture" ); | 400 | c->setGroup( "Capture" ); |
401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
402 | 402 | ||
403 | c->setGroup( "UI" ); | 403 | c->setGroup( "UI" ); |
404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm | 407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm |
408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click | 409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click |
410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click | 411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click |
412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
414 | 414 | ||
415 | c->setGroup( "GPS" ); | 415 | c->setGroup( "GPS" ); |
416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
417 | #if QT_VERSION < 300 | 417 | #if QT_VERSION < 300 |
418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
419 | gpsdHost->setCurrentItem( 0 ); | 419 | gpsdHost->setCurrentItem( 0 ); |
420 | #else | 420 | #else |
421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
422 | #endif | 422 | #endif |
423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
426 | 426 | ||
427 | #endif | 427 | #endif |
428 | } | 428 | } |
429 | 429 | ||
430 | 430 | ||
431 | void WellenreiterConfigWindow::save() | 431 | void WellenreiterConfigWindow::save() |
432 | { | 432 | { |
433 | #ifdef Q_WS_X11 | 433 | #ifdef Q_WS_X11 |
434 | #warning Persistent Configuration not yet implemented for standalone X11 build | 434 | #warning Persistent Configuration not yet implemented for standalone X11 build |
435 | #else | 435 | #else |
436 | qDebug( "saving configuration settings..." ); | 436 | qDebug( "saving configuration settings..." ); |
437 | 437 | ||
438 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ | 438 | /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ |
439 | 439 | ||
440 | OConfig* c = oApp->config(); | 440 | OConfig* c = oApp->config(); |
441 | 441 | ||
442 | c->setGroup( "Interface" ); | 442 | c->setGroup( "Interface" ); |
443 | c->writeEntry( "name", interfaceName->currentText() ); | 443 | c->writeEntry( "name", interfaceName->currentText() ); |
444 | c->writeEntry( "type", deviceType->currentText() ); | 444 | c->writeEntry( "type", deviceType->currentText() ); |
445 | c->writeEntry( "prism", prismHeader->isChecked() ); | 445 | c->writeEntry( "prism", prismHeader->isChecked() ); |
446 | c->writeEntry( "hop", hopChannels->isChecked() ); | 446 | c->writeEntry( "hop", hopChannels->isChecked() ); |
447 | c->writeEntry( "interval", hopInterval->value() ); | 447 | c->writeEntry( "interval", hopInterval->value() ); |
448 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); | 448 | c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); |
449 | 449 | ||
450 | c->setGroup( "Capture" ); | 450 | c->setGroup( "Capture" ); |
451 | c->writeEntry( "filename", captureFileName->text() ); | 451 | c->writeEntry( "filename", captureFileName->text() ); |
452 | 452 | ||
453 | c->setGroup( "UI" ); | 453 | c->setGroup( "UI" ); |
454 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); | 454 | c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); |
455 | c->writeEntry( "openTree", openTree->isChecked() ); | 455 | c->writeEntry( "openTree", openTree->isChecked() ); |
456 | c->writeEntry( "disablePM", disablePM->isChecked() ); | 456 | c->writeEntry( "disablePM", disablePM->isChecked() ); |
457 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); | 457 | c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); |
458 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); | 458 | c->writeEntry( "newNetworkScript", newNetworkScript->text() ); |
459 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); | 459 | c->writeEntry( "newClientAction", newClientAction->currentItem() ); |
460 | c->writeEntry( "newClientScript", newClientScript->text() ); | 460 | c->writeEntry( "newClientScript", newClientScript->text() ); |
461 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); | 461 | c->writeEntry( "newStationAction", newStationAction->currentItem() ); |
462 | c->writeEntry( "newStationScript", newStationScript->text() ); | 462 | c->writeEntry( "newStationScript", newStationScript->text() ); |
463 | 463 | ||
464 | c->setGroup( "GPS" ); | 464 | c->setGroup( "GPS" ); |
465 | c->writeEntry( "use", enableGPS->isChecked() ); | 465 | c->writeEntry( "use", enableGPS->isChecked() ); |
466 | c->writeEntry( "host", gpsdHost->currentText() ); | 466 | c->writeEntry( "host", gpsdHost->currentText() ); |
467 | c->writeEntry( "port", gpsdPort->value() ); | 467 | c->writeEntry( "port", gpsdPort->value() ); |
468 | c->writeEntry( "start", startGPS->isChecked() ); | 468 | c->writeEntry( "start", startGPS->isChecked() ); |
469 | c->writeEntry( "command", commandGPS->text() ); | 469 | c->writeEntry( "command", commandGPS->text() ); |
470 | 470 | ||
471 | c->write(); | 471 | c->write(); |
472 | 472 | ||
473 | #endif | 473 | #endif |
474 | } | 474 | } |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 43a04e3..db68e5b 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -1,715 +1,715 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file may be distributed and/or modified under the terms of the | 4 | ** This file may be distributed and/or modified under the terms of the |
5 | ** GNU General Public License version 2 as published by the Free Software | 5 | ** GNU General Public License version 2 as published by the Free Software |
6 | ** Foundation and appearing in the file LICENSE.GPL included in the | 6 | ** Foundation and appearing in the file LICENSE.GPL included in the |
7 | ** packaging of this file. | 7 | ** packaging of this file. |
8 | ** | 8 | ** |
9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 9 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 10 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
11 | ** | 11 | ** |
12 | ***********************************************************************/ | 12 | ***********************************************************************/ |
13 | 13 | ||
14 | // Local | 14 | // Local |
15 | 15 | ||
16 | #include "gps.h" | 16 | #include "gps.h" |
17 | #include "wellenreiter.h" | 17 | #include "wellenreiter.h" |
18 | #include "scanlist.h" | 18 | #include "scanlist.h" |
19 | #include "logwindow.h" | 19 | #include "logwindow.h" |
20 | #include "hexwindow.h" | 20 | #include "hexwindow.h" |
21 | #include "configwindow.h" | 21 | #include "configwindow.h" |
22 | #include "statwindow.h" | 22 | #include "statwindow.h" |
23 | #include "graphwindow.h" | 23 | #include "graphwindow.h" |
24 | #include "protolistview.h" | 24 | #include "protolistview.h" |
25 | 25 | ||
26 | // Opie | 26 | // Opie |
27 | 27 | ||
28 | #ifdef QWS | 28 | #ifdef QWS |
29 | #include <opie2/oapplication.h> | 29 | #include <opie2/oapplication.h> |
30 | #include <opie2/odevice.h> | 30 | #include <opie2/odevice.h> |
31 | #else | 31 | #else |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #endif | 33 | #endif |
34 | #include <opie2/omanufacturerdb.h> | 34 | #include <opie2/omanufacturerdb.h> |
35 | #include <opie2/onetwork.h> | 35 | #include <opie2/onetwork.h> |
36 | #include <opie2/opcap.h> | 36 | #include <opie2/opcap.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | using namespace Opie; | 38 | using namespace Opie; |
39 | 39 | ||
40 | // Qt | 40 | // Qt |
41 | 41 | ||
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qdatetime.h> | 44 | #include <qdatetime.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qobjectlist.h> | 48 | #include <qobjectlist.h> |
49 | #include <qregexp.h> | 49 | #include <qregexp.h> |
50 | #include <qspinbox.h> | 50 | #include <qspinbox.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qtoolbutton.h> | 52 | #include <qtoolbutton.h> |
53 | #include <qmainwindow.h> | 53 | #include <qmainwindow.h> |
54 | 54 | ||
55 | // Standard | 55 | // Standard |
56 | 56 | ||
57 | #include <assert.h> | 57 | #include <assert.h> |
58 | #include <errno.h> | 58 | #include <errno.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | #include <string.h> | 60 | #include <string.h> |
61 | #include <sys/types.h> | 61 | #include <sys/types.h> |
62 | #include <stdlib.h> | 62 | #include <stdlib.h> |
63 | 63 | ||
64 | Wellenreiter::Wellenreiter( QWidget* parent ) | 64 | Wellenreiter::Wellenreiter( QWidget* parent ) |
65 | : WellenreiterBase( parent, 0, 0 ), | 65 | : WellenreiterBase( parent, 0, 0 ), |
66 | sniffing( false ), iface( 0 ), configwindow( 0 ) | 66 | sniffing( false ), iface( 0 ), configwindow( 0 ) |
67 | { | 67 | { |
68 | 68 | ||
69 | logwindow->log( "(i) Wellenreiter has been started." ); | 69 | logwindow->log( "(i) Wellenreiter has been started." ); |
70 | 70 | ||
71 | // | 71 | // |
72 | // detect operating system | 72 | // detect operating system |
73 | // | 73 | // |
74 | 74 | ||
75 | #ifdef QWS | 75 | #ifdef QWS |
76 | QString sys; | 76 | QString sys; |
77 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | 77 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); |
78 | _system = ODevice::inst()->system(); | 78 | _system = ODevice::inst()->system(); |
79 | logwindow->log( sys ); | 79 | logwindow->log( sys ); |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | netview->setColumnWidthMode( 1, QListView::Manual ); | 82 | netview->setColumnWidthMode( 1, QListView::Manual ); |
83 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), | 83 | connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), |
84 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); | 84 | this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); |
85 | pcap = new OPacketCapturer(); | 85 | pcap = new OPacketCapturer(); |
86 | 86 | ||
87 | gps = new GPS( this ); | 87 | gps = new GPS( this ); |
88 | 88 | ||
89 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); | 89 | QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | Wellenreiter::~Wellenreiter() | 94 | Wellenreiter::~Wellenreiter() |
95 | { | 95 | { |
96 | delete pcap; | 96 | delete pcap; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void Wellenreiter::initialTimer() | 100 | void Wellenreiter::initialTimer() |
101 | { | 101 | { |
102 | qDebug( "Wellenreiter::preloading manufacturer database..." ); | 102 | qDebug( "Wellenreiter::preloading manufacturer database..." ); |
103 | OManufacturerDB::instance(); | 103 | OManufacturerDB::instance(); |
104 | } | 104 | } |
105 | 105 | ||
106 | 106 | ||
107 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) | 107 | void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) |
108 | { | 108 | { |
109 | configwindow = cw; | 109 | configwindow = cw; |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void Wellenreiter::channelHopped(int c) | 113 | void Wellenreiter::channelHopped(int c) |
114 | { | 114 | { |
115 | QString title = "Wellenreiter II -scan- ["; | 115 | QString title = "Wellenreiter II -scan- ["; |
116 | QString left; | 116 | QString left; |
117 | if ( c > 1 ) left.fill( '.', c-1 ); | 117 | if ( c > 1 ) left.fill( '.', c-1 ); |
118 | title.append( left ); | 118 | title.append( left ); |
119 | title.append( '|' ); | 119 | title.append( '|' ); |
120 | if ( c < iface->channels() ) | 120 | if ( c < iface->channels() ) |
121 | { | 121 | { |
122 | QString right; | 122 | QString right; |
123 | right.fill( '.', iface->channels()-c ); | 123 | right.fill( '.', iface->channels()-c ); |
124 | title.append( right ); | 124 | title.append( right ); |
125 | } | 125 | } |
126 | title.append( "]" ); | 126 | title.append( "]" ); |
127 | //title.append( QString().sprintf( " %02d", c ) ); | 127 | //title.append( QString().sprintf( " %02d", c ) ); |
128 | assert( parent() ); | 128 | assert( parent() ); |
129 | ( (QMainWindow*) parent() )->setCaption( title ); | 129 | ( (QMainWindow*) parent() )->setCaption( title ); |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void Wellenreiter::handleNotification( OPacket* p ) | 133 | void Wellenreiter::handleNotification( OPacket* p ) |
134 | { | 134 | { |
135 | QObjectList* l = p->queryList(); | 135 | QObjectList* l = p->queryList(); |
136 | QObjectListIt it( *l ); | 136 | QObjectListIt it( *l ); |
137 | QObject* o; | 137 | QObject* o; |
138 | 138 | ||
139 | while ( (o = it.current()) != 0 ) | 139 | while ( (o = it.current()) != 0 ) |
140 | { | 140 | { |
141 | QString name = it.current()->name(); | 141 | QString name = it.current()->name(); |
142 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) | 142 | if ( configwindow->parsePackets->isProtocolChecked( name ) ) |
143 | { | 143 | { |
144 | QString action = configwindow->parsePackets->protocolAction( name ); | 144 | QString action = configwindow->parsePackets->protocolAction( name ); |
145 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 145 | qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
146 | doAction( action, name, p ); | 146 | doAction( action, name, p ); |
147 | } | 147 | } |
148 | else | 148 | else |
149 | { | 149 | { |
150 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); | 150 | qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); |
151 | } | 151 | } |
152 | ++it; | 152 | ++it; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) | 157 | void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) |
158 | { | 158 | { |
159 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); | 159 | if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); |
160 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); | 160 | else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); |
161 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); | 161 | else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); |
162 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); | 162 | else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) | 166 | void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) |
167 | { | 167 | { |
168 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 168 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
169 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 169 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
170 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 170 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
171 | int channel = ds ? ds->channel() : -1; | 171 | int channel = ds ? ds->channel() : -1; |
172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 172 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
173 | 173 | ||
174 | GpsLocation loc( -111, -111 ); | 174 | GpsLocation loc( -111, -111 ); |
175 | if ( configwindow->enableGPS->isChecked() ) | 175 | if ( configwindow->enableGPS->isChecked() ) |
176 | { | 176 | { |
177 | // TODO: add check if GPS is working!? | 177 | // TODO: add check if GPS is working!? |
178 | qDebug( "Wellenreiter::gathering GPS data..." ); | 178 | qDebug( "Wellenreiter::gathering GPS data..." ); |
179 | loc = gps->position(); | 179 | loc = gps->position(); |
180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 180 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
181 | } | 181 | } |
182 | 182 | ||
183 | if ( essid.length() ) | 183 | if ( essid.length() ) |
184 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); | 184 | netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); |
185 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 185 | qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
189 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) | 189 | void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) |
190 | { | 190 | { |
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
194 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) | 194 | void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) |
195 | { | 195 | { |
196 | QString type; | 196 | QString type; |
197 | if ( beacon->canIBSS() ) | 197 | if ( beacon->canIBSS() ) |
198 | { | 198 | { |
199 | type = "adhoc"; | 199 | type = "adhoc"; |
200 | } | 200 | } |
201 | else if ( beacon->canESS() ) | 201 | else if ( beacon->canESS() ) |
202 | { | 202 | { |
203 | type = "managed"; | 203 | type = "managed"; |
204 | } | 204 | } |
205 | else | 205 | else |
206 | { | 206 | { |
207 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); | 207 | qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); |
208 | return; | 208 | return; |
209 | } | 209 | } |
210 | 210 | ||
211 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); | 211 | OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); |
212 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); | 212 | QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); |
213 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); | 213 | OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); |
214 | int channel = ds ? ds->channel() : -1; | 214 | int channel = ds ? ds->channel() : -1; |
215 | 215 | ||
216 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 216 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
217 | 217 | ||
218 | GpsLocation loc( -111, -111 ); | 218 | GpsLocation loc( -111, -111 ); |
219 | if ( configwindow->enableGPS->isChecked() ) | 219 | if ( configwindow->enableGPS->isChecked() ) |
220 | { | 220 | { |
221 | // TODO: add check if GPS is working!? | 221 | // TODO: add check if GPS is working!? |
222 | qDebug( "Wellenreiter::gathering GPS data..." ); | 222 | qDebug( "Wellenreiter::gathering GPS data..." ); |
223 | loc = gps->position(); | 223 | loc = gps->position(); |
224 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); | 224 | qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); |
225 | } | 225 | } |
226 | 226 | ||
227 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); | 227 | netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); |
228 | 228 | ||
229 | // update graph window | 229 | // update graph window |
230 | if ( ds ) | 230 | if ( ds ) |
231 | { | 231 | { |
232 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); | 232 | OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); |
233 | if ( prism ) | 233 | if ( prism ) |
234 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); | 234 | graphwindow->traffic( ds->channel(), prism->signalStrength() ); |
235 | else | 235 | else |
236 | graphwindow->traffic( ds->channel(), 95 ); | 236 | graphwindow->traffic( ds->channel(), 95 ); |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) | 241 | void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) |
242 | { | 242 | { |
243 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); | 243 | OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); |
244 | 244 | ||
245 | if ( control->controlType() == "Acknowledge" ) | 245 | if ( control->controlType() == "Acknowledge" ) |
246 | { | 246 | { |
247 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); | 247 | netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); |
248 | } | 248 | } |
249 | else | 249 | else |
250 | { | 250 | { |
251 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); | 251 | qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) | 256 | void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) |
257 | { | 257 | { |
258 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); | 258 | OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); |
259 | if ( wlan->fromDS() && !wlan->toDS() ) | 259 | if ( wlan->fromDS() && !wlan->toDS() ) |
260 | { | 260 | { |
261 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 261 | netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
262 | from = wlan->macAddress3(); | 262 | from = wlan->macAddress3(); |
263 | to = wlan->macAddress2(); | 263 | to = wlan->macAddress2(); |
264 | } | 264 | } |
265 | else if ( !wlan->fromDS() && wlan->toDS() ) | 265 | else if ( !wlan->fromDS() && wlan->toDS() ) |
266 | { | 266 | { |
267 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); | 267 | netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); |
268 | from = wlan->macAddress2(); | 268 | from = wlan->macAddress2(); |
269 | to = wlan->macAddress3(); | 269 | to = wlan->macAddress3(); |
270 | } | 270 | } |
271 | else if ( wlan->fromDS() && wlan->toDS() ) | 271 | else if ( wlan->fromDS() && wlan->toDS() ) |
272 | { | 272 | { |
273 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); | 273 | netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); |
274 | from = wlan->macAddress4(); | 274 | from = wlan->macAddress4(); |
275 | to = wlan->macAddress3(); | 275 | to = wlan->macAddress3(); |
276 | } | 276 | } |
277 | else | 277 | else |
278 | { | 278 | { |
279 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); | 279 | netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); |
280 | from = wlan->macAddress2(); | 280 | from = wlan->macAddress2(); |
281 | to = wlan->macAddress1(); | 281 | to = wlan->macAddress1(); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) | 286 | void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) |
287 | { | 287 | { |
288 | from = data->sourceAddress(); | 288 | from = data->sourceAddress(); |
289 | to = data->destinationAddress(); | 289 | to = data->destinationAddress(); |
290 | 290 | ||
291 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); | 291 | netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) | 295 | void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) |
296 | { | 296 | { |
297 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); | 297 | OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); |
298 | if ( arp ) | 298 | if ( arp ) |
299 | { | 299 | { |
300 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); | 300 | qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); |
301 | if ( arp->type() == "REQUEST" ) | 301 | if ( arp->type() == "REQUEST" ) |
302 | { | 302 | { |
303 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 303 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
304 | } | 304 | } |
305 | else if ( arp->type() == "REPLY" ) | 305 | else if ( arp->type() == "REPLY" ) |
306 | { | 306 | { |
307 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); | 307 | netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); |
308 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); | 308 | netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); |
309 | } | 309 | } |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) | 314 | void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) |
315 | { | 315 | { |
316 | //TODO: Implement more IP based protocols | 316 | //TODO: Implement more IP based protocols |
317 | 317 | ||
318 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); | 318 | ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); |
319 | if ( dhcp ) | 319 | if ( dhcp ) |
320 | { | 320 | { |
321 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); | 321 | qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); |
322 | if ( dhcp->type() == "OFFER" ) | 322 | if ( dhcp->type() == "OFFER" ) |
323 | { | 323 | { |
324 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); | 324 | qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); |
325 | netView()->identify( source, dhcp->serverAddress().toString() ); | 325 | netView()->identify( source, dhcp->serverAddress().toString() ); |
326 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); | 326 | netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); |
327 | } | 327 | } |
328 | else if ( dhcp->type() == "ACK" ) | 328 | else if ( dhcp->type() == "ACK" ) |
329 | { | 329 | { |
330 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); | 330 | qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); |
331 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); | 331 | netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | 336 | ||
337 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) | 337 | QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) |
338 | { | 338 | { |
339 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) | 339 | if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) |
340 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) | 340 | if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) |
341 | return 0; | 341 | return 0; |
342 | 342 | ||
343 | return p->child( protocol ); | 343 | return p->child( protocol ); |
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | bool Wellenreiter::checkDumpPacket( OPacket* p ) | 347 | bool Wellenreiter::checkDumpPacket( OPacket* p ) |
348 | { | 348 | { |
349 | // go through all child packets and see if one is inside the child hierarchy for p | 349 | // go through all child packets and see if one is inside the child hierarchy for p |
350 | // if so, do what the user requested (protocolAction), e.g. pass or discard | 350 | // if so, do what the user requested (protocolAction), e.g. pass or discard |
351 | if ( !configwindow->writeCaptureFile->isChecked() ) | 351 | if ( !configwindow->writeCaptureFile->isChecked() ) |
352 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter | 352 | return true; // semantic change - we're logging anyway now to /tmp/wellenreiter |
353 | 353 | ||
354 | QObjectList* l = p->queryList(); | 354 | QObjectList* l = p->queryList(); |
355 | QObjectListIt it( *l ); | 355 | QObjectListIt it( *l ); |
356 | QObject* o; | 356 | QObject* o; |
357 | 357 | ||
358 | while ( (o = it.current()) != 0 ) | 358 | while ( (o = it.current()) != 0 ) |
359 | { | 359 | { |
360 | QString name = it.current()->name(); | 360 | QString name = it.current()->name(); |
361 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) | 361 | if ( configwindow->capturePackets->isProtocolChecked( name ) ) |
362 | { | 362 | { |
363 | QString action = configwindow->capturePackets->protocolAction( name ); | 363 | QString action = configwindow->capturePackets->protocolAction( name ); |
364 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); | 364 | qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); |
365 | if ( action == "Discard" ) | 365 | if ( action == "Discard" ) |
366 | { | 366 | { |
367 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); | 367 | logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); |
368 | return false; | 368 | return false; |
369 | } | 369 | } |
370 | } | 370 | } |
371 | else | 371 | else |
372 | { | 372 | { |
373 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); | 373 | qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); |
374 | } | 374 | } |
375 | ++it; | 375 | ++it; |
376 | } | 376 | } |
377 | return true; | 377 | return true; |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void Wellenreiter::receivePacket( OPacket* p ) | 381 | void Wellenreiter::receivePacket( OPacket* p ) |
382 | { | 382 | { |
383 | hexWindow()->log( p->dump( 8 ) ); | 383 | hexWindow()->log( p->dump( 8 ) ); |
384 | 384 | ||
385 | if ( checkDumpPacket( p ) ) | 385 | if ( checkDumpPacket( p ) ) |
386 | { | 386 | { |
387 | pcap->dump( p ); | 387 | pcap->dump( p ); |
388 | } | 388 | } |
389 | 389 | ||
390 | // check for a management frame | 390 | // check for a management frame |
391 | OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); | 391 | OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); |
392 | if ( manage ) | 392 | if ( manage ) |
393 | { | 393 | { |
394 | handleManagementFrame( p, manage ); | 394 | handleManagementFrame( p, manage ); |
395 | return; | 395 | return; |
396 | } | 396 | } |
397 | 397 | ||
398 | // check for a control frame | 398 | // check for a control frame |
399 | OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); | 399 | OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); |
400 | if ( control ) | 400 | if ( control ) |
401 | { | 401 | { |
402 | handleControlFrame( p, control ); | 402 | handleControlFrame( p, control ); |
403 | return; | 403 | return; |
404 | } | 404 | } |
405 | 405 | ||
406 | OMacAddress source; | 406 | OMacAddress source; |
407 | OMacAddress dest; | 407 | OMacAddress dest; |
408 | 408 | ||
409 | //TODO: WEP check here | 409 | //TODO: WEP check here |
410 | 410 | ||
411 | // check for a wireless data frame | 411 | // check for a wireless data frame |
412 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); | 412 | OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); |
413 | if ( wlan ) | 413 | if ( wlan ) |
414 | { | 414 | { |
415 | handleWlanData( p, wlan, source, dest ); | 415 | handleWlanData( p, wlan, source, dest ); |
416 | } | 416 | } |
417 | 417 | ||
418 | // check for a wired data frame | 418 | // check for a wired data frame |
419 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); | 419 | OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); |
420 | if ( eth ) | 420 | if ( eth ) |
421 | { | 421 | { |
422 | handleEthernetData( p, eth, source, dest ); | 422 | handleEthernetData( p, eth, source, dest ); |
423 | } | 423 | } |
424 | 424 | ||
425 | // check for an arp frame since arp frames come in two flavours: | 425 | // check for an arp frame since arp frames come in two flavours: |
426 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. | 426 | // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. |
427 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); | 427 | OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); |
428 | if ( arp ) | 428 | if ( arp ) |
429 | { | 429 | { |
430 | handleARPData( p, arp, source, dest ); | 430 | handleARPData( p, arp, source, dest ); |
431 | } | 431 | } |
432 | 432 | ||
433 | // check for a ip frame | 433 | // check for a ip frame |
434 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); | 434 | OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); |
435 | if ( ip ) | 435 | if ( ip ) |
436 | { | 436 | { |
437 | handleIPData( p, ip, source, dest ); | 437 | handleIPData( p, ip, source, dest ); |
438 | } | 438 | } |
439 | 439 | ||
440 | //handleNotification( p ); | 440 | //handleNotification( p ); |
441 | 441 | ||
442 | } | 442 | } |
443 | 443 | ||
444 | 444 | ||
445 | void Wellenreiter::stopClicked() | 445 | void Wellenreiter::stopClicked() |
446 | { | 446 | { |
447 | if ( iface ) | 447 | if ( iface ) |
448 | { | 448 | { |
449 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 449 | disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
450 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 450 | disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
451 | iface->setChannelHopping(); // stop hopping channels | 451 | iface->setChannelHopping(); // stop hopping channels |
452 | } | 452 | } |
453 | else | 453 | else |
454 | killTimers(); | 454 | killTimers(); |
455 | 455 | ||
456 | pcap->close(); | 456 | pcap->close(); |
457 | sniffing = false; | 457 | sniffing = false; |
458 | 458 | ||
459 | if ( iface ) | 459 | if ( iface ) |
460 | { | 460 | { |
461 | // switch off monitor mode | 461 | // switch off monitor mode |
462 | iface->setMode( "managed" ); | 462 | iface->setMode( "managed" ); |
463 | // switch off promisc flag | 463 | // switch off promisc flag |
464 | iface->setPromiscuousMode( false ); | 464 | iface->setPromiscuousMode( false ); |
465 | 465 | ||
466 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess | 466 | system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess |
467 | } | 467 | } |
468 | 468 | ||
469 | logwindow->log( "(i) Stopped Scanning." ); | 469 | logwindow->log( "(i) Stopped Scanning." ); |
470 | assert( parent() ); | 470 | assert( parent() ); |
471 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); | 471 | ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); |
472 | 472 | ||
473 | // message the user | 473 | // message the user |
474 | QMessageBox::information( this, "Wellenreiter II", | 474 | QMessageBox::information( this, "Wellenreiter II", |
475 | tr( "Your wireless card\nshould now be usable again." ) ); | 475 | tr( "Your wireless card\nshould now be usable again." ) ); |
476 | 476 | ||
477 | sniffing = false; | 477 | sniffing = false; |
478 | emit( stoppedSniffing() ); | 478 | emit( stoppedSniffing() ); |
479 | 479 | ||
480 | #ifdef QWS | 480 | #ifdef QWS |
481 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 481 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
482 | { | 482 | { |
483 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 483 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
484 | } | 484 | } |
485 | #else | 485 | #else |
486 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 486 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
487 | #endif | 487 | #endif |
488 | 488 | ||
489 | // print out statistics | 489 | // print out statistics |
490 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) | 490 | for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) |
491 | statwindow->updateCounter( it.key(), it.data() ); | 491 | statwindow->updateCounter( it.key(), it.data() ); |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | void Wellenreiter::startClicked() | 495 | void Wellenreiter::startClicked() |
496 | { | 496 | { |
497 | // get configuration from config window | 497 | // get configuration from config window |
498 | 498 | ||
499 | const QString& interface = configwindow->interfaceName->currentText(); | 499 | const QString& interface = configwindow->interfaceName->currentText(); |
500 | const int cardtype = configwindow->driverType(); | 500 | const int cardtype = configwindow->driverType(); |
501 | const int interval = configwindow->hoppingInterval(); | 501 | const int interval = configwindow->hoppingInterval(); |
502 | 502 | ||
503 | if ( ( interface == "" ) || ( cardtype == 0 ) ) | 503 | if ( ( interface == "" ) || ( cardtype == 0 ) ) |
504 | { | 504 | { |
505 | QMessageBox::information( this, "Wellenreiter II", | 505 | QMessageBox::information( this, "Wellenreiter II", |
506 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); | 506 | tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); |
507 | return; | 507 | return; |
508 | } | 508 | } |
509 | 509 | ||
510 | // configure device | 510 | // configure device |
511 | ONetwork* net = ONetwork::instance(); | 511 | ONetwork* net = ONetwork::instance(); |
512 | 512 | ||
513 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces | 513 | // TODO: check if interface is wireless and support sniffing for non-wireless interfaces |
514 | 514 | ||
515 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! | 515 | iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! |
516 | 516 | ||
517 | // bring device UP | 517 | // bring device UP |
518 | if ( cardtype != DEVTYPE_FILE ) | 518 | if ( cardtype != DEVTYPE_FILE ) |
519 | { | 519 | { |
520 | iface->setUp( true ); | 520 | iface->setUp( true ); |
521 | if ( !iface->isUp() ) | 521 | if ( !iface->isUp() ) |
522 | { | 522 | { |
523 | QMessageBox::warning( this, "Wellenreiter II", | 523 | QMessageBox::warning( this, "Wellenreiter II", |
524 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); | 524 | tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); |
525 | return; | 525 | return; |
526 | } | 526 | } |
527 | } | 527 | } |
528 | // set monitor mode | 528 | // set monitor mode |
529 | bool usePrism = configwindow->usePrismHeader(); | 529 | bool usePrism = configwindow->usePrismHeader(); |
530 | 530 | ||
531 | switch ( cardtype ) | 531 | switch ( cardtype ) |
532 | { | 532 | { |
533 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; | 533 | case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; |
534 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; | 534 | case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; |
535 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; | 535 | case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; |
536 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; | 536 | case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; |
537 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; | 537 | case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; |
538 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; | 538 | case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; |
539 | default: assert( 0 ); // shouldn't reach this | 539 | default: assert( 0 ); // shouldn't reach this |
540 | } | 540 | } |
541 | 541 | ||
542 | // switch device into monitor mode | 542 | // switch device into monitor mode |
543 | if ( cardtype < DEVTYPE_FILE ) | 543 | if ( cardtype < DEVTYPE_FILE ) |
544 | { | 544 | { |
545 | if ( cardtype != DEVTYPE_MANUAL ) | 545 | if ( cardtype != DEVTYPE_MANUAL ) |
546 | iface->setMode( "monitor" ); | 546 | iface->setMode( "monitor" ); |
547 | if ( iface->mode() != "monitor" ) | 547 | if ( iface->mode() != "monitor" ) |
548 | { | 548 | { |
549 | if ( QMessageBox::warning( this, "Wellenreiter II", | 549 | if ( QMessageBox::warning( this, "Wellenreiter II", |
550 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + | 550 | tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + |
551 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | 551 | tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) |
552 | return; | 552 | return; |
553 | } | 553 | } |
554 | } | 554 | } |
555 | 555 | ||
556 | // open GPS device | 556 | // open GPS device |
557 | if ( configwindow->enableGPS->isChecked() ) | 557 | if ( configwindow->enableGPS->isChecked() ) |
558 | { | 558 | { |
559 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 559 | qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
560 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); | 560 | gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); |
561 | } | 561 | } |
562 | 562 | ||
563 | // open pcap and start sniffing | 563 | // open pcap and start sniffing |
564 | 564 | ||
565 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? | 565 | if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? |
566 | { | 566 | { |
567 | dumpname = configwindow->captureFileName->text(); | 567 | dumpname = configwindow->captureFileName->text(); |
568 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; | 568 | if ( dumpname.isEmpty() ) dumpname = "captureFile"; |
569 | dumpname.append( '-' ); | 569 | dumpname.append( '-' ); |
570 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); | 570 | dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); |
571 | dumpname.append( ".wellenreiter" ); | 571 | dumpname.append( ".wellenreiter" ); |
572 | } | 572 | } |
573 | else // write it anyway ;) | 573 | else // write it anyway ;) |
574 | { | 574 | { |
575 | dumpname = "/var/log/dump.wellenreiter"; | 575 | dumpname = "/var/log/dump.wellenreiter"; |
576 | } | 576 | } |
577 | 577 | ||
578 | if ( cardtype != DEVTYPE_FILE ) | 578 | if ( cardtype != DEVTYPE_FILE ) |
579 | pcap->open( interface ); | 579 | pcap->open( interface ); |
580 | else | 580 | else |
581 | pcap->open( QFile( interface ) ); | 581 | pcap->open( QFile( interface ) ); |
582 | 582 | ||
583 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); | 583 | qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); |
584 | pcap->openDumpFile( dumpname ); | 584 | pcap->openDumpFile( dumpname ); |
585 | 585 | ||
586 | if ( !pcap->isOpen() ) | 586 | if ( !pcap->isOpen() ) |
587 | { | 587 | { |
588 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( | 588 | QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( |
589 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); | 589 | cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); |
590 | return; | 590 | return; |
591 | } | 591 | } |
592 | 592 | ||
593 | // set capturer to non-blocking mode | 593 | // set capturer to non-blocking mode |
594 | pcap->setBlocking( false ); | 594 | pcap->setBlocking( false ); |
595 | 595 | ||
596 | // start channel hopper | 596 | // start channel hopper |
597 | if ( cardtype != DEVTYPE_FILE ) | 597 | if ( cardtype != DEVTYPE_FILE ) |
598 | { | 598 | { |
599 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); | 599 | logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); |
600 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window | 600 | iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window |
601 | } | 601 | } |
602 | 602 | ||
603 | if ( cardtype != DEVTYPE_FILE ) | 603 | if ( cardtype != DEVTYPE_FILE ) |
604 | { | 604 | { |
605 | // connect socket notifier and start channel hopper | 605 | // connect socket notifier and start channel hopper |
606 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); | 606 | connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); |
607 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); | 607 | connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); |
608 | } | 608 | } |
609 | else | 609 | else |
610 | { | 610 | { |
611 | // start timer for reading packets | 611 | // start timer for reading packets |
612 | startTimer( 100 ); | 612 | startTimer( 100 ); |
613 | } | 613 | } |
614 | 614 | ||
615 | logwindow->log( "(i) Started Scanning." ); | 615 | logwindow->log( "(i) Started Scanning." ); |
616 | sniffing = true; | 616 | sniffing = true; |
617 | 617 | ||
618 | #ifdef QWS | 618 | #ifdef QWS |
619 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) | 619 | if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) |
620 | { | 620 | { |
621 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | 621 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; |
622 | } | 622 | } |
623 | #else | 623 | #else |
624 | #warning FIXME: setScreenSaverMode is not operational on the X11 build | 624 | #warning FIXME: setScreenSaverMode is not operational on the X11 build |
625 | #endif | 625 | #endif |
626 | 626 | ||
627 | emit( startedSniffing() ); | 627 | emit( startedSniffing() ); |
628 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title | 628 | if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title |
629 | else | 629 | else |
630 | { | 630 | { |
631 | assert( parent() ); | 631 | assert( parent() ); |
632 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); | 632 | ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | 636 | ||
637 | void Wellenreiter::timerEvent( QTimerEvent* ) | 637 | void Wellenreiter::timerEvent( QTimerEvent* ) |
638 | { | 638 | { |
639 | qDebug( "Wellenreiter::timerEvent()" ); | 639 | qDebug( "Wellenreiter::timerEvent()" ); |
640 | OPacket* p = pcap->next(); | 640 | OPacket* p = pcap->next(); |
641 | if ( !p ) // no more packets available | 641 | if ( !p ) // no more packets available |
642 | { | 642 | { |
643 | stopClicked(); | 643 | stopClicked(); |
644 | } | 644 | } |
645 | else | 645 | else |
646 | { | 646 | { |
647 | receivePacket( p ); | 647 | receivePacket( p ); |
648 | delete p; | 648 | delete p; |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | 652 | ||
653 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) | 653 | void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) |
654 | { | 654 | { |
655 | #ifdef QWS | 655 | #ifdef QWS |
656 | if ( action == "TouchSound" ) | 656 | if ( action == "TouchSound" ) |
657 | ODevice::inst()->touchSound(); | 657 | ODevice::inst()->playTouchSound(); |
658 | else if ( action == "AlarmSound" ) | 658 | else if ( action == "AlarmSound" ) |
659 | ODevice::inst()->alarmSound(); | 659 | ODevice::inst()->playAlarmSound(); |
660 | else if ( action == "KeySound" ) | 660 | else if ( action == "KeySound" ) |
661 | ODevice::inst()->keySound(); | 661 | ODevice::inst()->playKeySound(); |
662 | else if ( action == "LedOn" ) | 662 | else if ( action == "LedOn" ) |
663 | ODevice::inst()->setLedState( Led_Mail, Led_On ); | 663 | ODevice::inst()->setLedState( Led_Mail, Led_On ); |
664 | else if ( action == "LedOff" ) | 664 | else if ( action == "LedOff" ) |
665 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 665 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
666 | else if ( action == "LogMessage" ) | 666 | else if ( action == "LogMessage" ) |
667 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 667 | logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
668 | else if ( action == "MessageBox" ) | 668 | else if ( action == "MessageBox" ) |
669 | QMessageBox::information( this, "Notification!", | 669 | QMessageBox::information( this, "Notification!", |
670 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); | 670 | QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); |
671 | #else | 671 | #else |
672 | #warning Actions do not work with Qt/X11 yet | 672 | #warning Actions do not work with Qt/X11 yet |
673 | #endif | 673 | #endif |
674 | } | 674 | } |
675 | 675 | ||
676 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) | 676 | void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) |
677 | { | 677 | { |
678 | #ifdef QWS | 678 | #ifdef QWS |
679 | if ( !iface ) | 679 | if ( !iface ) |
680 | { | 680 | { |
681 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); | 681 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); |
682 | return; | 682 | return; |
683 | } | 683 | } |
684 | 684 | ||
685 | if ( sniffing ) | 685 | if ( sniffing ) |
686 | { | 686 | { |
687 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); | 687 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); |
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | 690 | ||
691 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", | 691 | qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", |
692 | (const char*) iface->name(), | 692 | (const char*) iface->name(), |
693 | (const char*) type, | 693 | (const char*) type, |
694 | (const char*) essid, | 694 | (const char*) essid, |
695 | channel, | 695 | channel, |
696 | (const char*) macaddr ); | 696 | (const char*) macaddr ); |
697 | 697 | ||
698 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); | 698 | QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); |
699 | int count = 3; | 699 | int count = 3; |
700 | qDebug("sending %d messages",count); | 700 | qDebug("sending %d messages",count); |
701 | msg << QString("count") << QString::number(count); | 701 | msg << QString("count") << QString::number(count); |
702 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); | 702 | qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); |
703 | msg << QString(iface->name()) << QString("Mode") << type; | 703 | msg << QString(iface->name()) << QString("Mode") << type; |
704 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); | 704 | qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); |
705 | msg << QString(iface->name()) << QString("ESSID") << essid; | 705 | msg << QString(iface->name()) << QString("ESSID") << essid; |
706 | qDebug("msg >%s< channel >%d<", iface->name(),channel); | 706 | qDebug("msg >%s< channel >%d<", iface->name(),channel); |
707 | msg << QString(iface->name()) << QString("Channel") << channel; | 707 | msg << QString(iface->name()) << QString("Channel") << channel; |
708 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); | 708 | // qDebug("msg >%s< mac >%s<", iface->name(),macaddr); |
709 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; | 709 | // msg << QString(iface->name()) << QString("MacAddr") << macaddr; |
710 | #else | 710 | #else |
711 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); | 711 | QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); |
712 | #endif | 712 | #endif |
713 | 713 | ||
714 | } | 714 | } |
715 | 715 | ||