summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 5dc2e79..14f251a 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -158,408 +158,427 @@ void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
158 { 158 {
159 type = "managed"; 159 type = "managed";
160 } 160 }
161 else 161 else
162 { 162 {
163 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 163 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
164 return; 164 return;
165 } 165 }
166 166
167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 167 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
168 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 168 QString essid = ssid ? ssid->ID() : QString("<unknown>");
169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 169 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
170 int channel = ds ? ds->channel() : -1; 170 int channel = ds ? ds->channel() : -1;
171 171
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( 0, 0 ); 174 GpsLocation loc( 0, 0 );
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 )", loc.latitude, loc.longitude ); 180 qDebug( "Wellenreiter::GPS data received is ( %f , %f )", loc.latitude, loc.longitude );
181 } 181 }
182 182
183 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 183 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
184 184
185 // update graph window 185 // update graph window
186 if ( ds ) 186 if ( ds )
187 { 187 {
188 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 188 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
189 if ( prism ) 189 if ( prism )
190 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 190 graphwindow->traffic( ds->channel(), prism->signalStrength() );
191 else 191 else
192 graphwindow->traffic( ds->channel(), 95 ); 192 graphwindow->traffic( ds->channel(), 95 );
193 } 193 }
194} 194}
195 195
196 196
197void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 197void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
198{ 198{
199 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 199 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
200 if ( wlan->fromDS() && !wlan->toDS() ) 200 if ( wlan->fromDS() && !wlan->toDS() )
201 { 201 {
202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 202 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
203 } 203 }
204 else if ( !wlan->fromDS() && wlan->toDS() ) 204 else if ( !wlan->fromDS() && wlan->toDS() )
205 { 205 {
206 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 206 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
207 } 207 }
208 else if ( wlan->fromDS() && wlan->toDS() ) 208 else if ( wlan->fromDS() && wlan->toDS() )
209 { 209 {
210 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 210 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
211 } 211 }
212 else 212 else
213 { 213 {
214 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 214 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
215 } 215 }
216 216
217 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 217 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
218 if ( arp ) 218 if ( arp )
219 { 219 {
220 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 220 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
221 if ( arp->type() == "REQUEST" ) 221 if ( arp->type() == "REQUEST" )
222 { 222 {
223 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 223 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
224 } 224 }
225 else if ( arp->type() == "REPLY" ) 225 else if ( arp->type() == "REPLY" )
226 { 226 {
227 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 227 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
228 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 228 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
229 } 229 }
230 } 230 }
231 231
232 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 232 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
233 if ( ip ) 233 if ( ip )
234 { 234 {
235 qDebug( "Received IP packet." ); 235 qDebug( "Received IP packet." );
236 } 236 }
237} 237}
238 238
239 239
240QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 240QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
241{ 241{
242 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 242 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
243 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 243 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
244 return 0; 244 return 0;
245 245
246 return p->child( protocol ); 246 return p->child( protocol );
247} 247}
248 248
249 249
250bool Wellenreiter::checkDumpPacket( OPacket* p ) 250bool Wellenreiter::checkDumpPacket( OPacket* p )
251{ 251{
252 // go through all child packets and see if one is inside the child hierarchy for p 252 // go through all child packets and see if one is inside the child hierarchy for p
253 // if so, do what the user requested (protocolAction), e.g. pass or discard 253 // if so, do what the user requested (protocolAction), e.g. pass or discard
254 if ( !configwindow->writeCaptureFile->isChecked() ) 254 if ( !configwindow->writeCaptureFile->isChecked() )
255 return false; 255 return false;
256 256
257 QObjectList* l = p->queryList(); 257 QObjectList* l = p->queryList();
258 QObjectListIt it( *l ); 258 QObjectListIt it( *l );
259 QObject* o; 259 QObject* o;
260 260
261 while ( (o = it.current()) != 0 ) 261 while ( (o = it.current()) != 0 )
262 { 262 {
263 QString name = it.current()->name(); 263 QString name = it.current()->name();
264 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 264 if ( configwindow->capturePackets->isProtocolChecked( name ) )
265 { 265 {
266 QString action = configwindow->capturePackets->protocolAction( name ); 266 QString action = configwindow->capturePackets->protocolAction( name );
267 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 267 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
268 if ( action == "Discard" ) 268 if ( action == "Discard" )
269 { 269 {
270 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 270 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
271 return false; 271 return false;
272 } 272 }
273 } 273 }
274 else 274 else
275 { 275 {
276 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 276 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
277 } 277 }
278 ++it; 278 ++it;
279 } 279 }
280 return true; 280 return true;
281} 281}
282 282
283 283
284void Wellenreiter::receivePacket( OPacket* p ) 284void Wellenreiter::receivePacket( OPacket* p )
285{ 285{
286 hexWindow()->log( p->dump( 8 ) ); 286 hexWindow()->log( p->dump( 8 ) );
287 287
288 if ( checkDumpPacket( p ) ) 288 if ( checkDumpPacket( p ) )
289 { 289 {
290 pcap->dump( p ); 290 pcap->dump( p );
291 } 291 }
292 292
293 // check if we received a beacon frame 293 // check if we received a beacon frame
294 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 294 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
295 if ( beacon && beacon->managementType() == "Beacon" ) 295 if ( beacon && beacon->managementType() == "Beacon" )
296 { 296 {
297 handleBeacon( p, beacon ); 297 handleBeacon( p, beacon );
298 return; 298 return;
299 } 299 }
300 300
301 //TODO: WEP check here 301 //TODO: WEP check here
302 302
303 // check for a data frame 303 // check for a data frame
304 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 304 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
305 if ( data ) 305 if ( data )
306 { 306 {
307 handleData( p, data ); 307 handleData( p, data );
308 } 308 }
309 309
310 handleNotification( p ); 310 handleNotification( p );
311 311
312} 312}
313 313
314 314
315void Wellenreiter::stopClicked() 315void Wellenreiter::stopClicked()
316{ 316{
317 if ( iface ) 317 if ( iface )
318 { 318 {
319 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 319 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
320 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 320 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
321 iface->setChannelHopping(); // stop hopping channels 321 iface->setChannelHopping(); // stop hopping channels
322 } 322 }
323 else 323 else
324 killTimers(); 324 killTimers();
325 325
326 pcap->close(); 326 pcap->close();
327 sniffing = false; 327 sniffing = false;
328 328
329 if ( iface ) 329 if ( iface )
330 { 330 {
331 // switch off monitor mode 331 // switch off monitor mode
332 iface->setMonitorMode( false ); 332 iface->setMonitorMode( false );
333 // switch off promisc flag 333 // switch off promisc flag
334 iface->setPromiscuousMode( false ); 334 iface->setPromiscuousMode( false );
335 335
336 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 336 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
337 } 337 }
338 338
339 logwindow->log( "(i) Stopped Scanning." ); 339 logwindow->log( "(i) Stopped Scanning." );
340 assert( parent() ); 340 assert( parent() );
341 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 341 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
342 342
343 // message the user 343 // message the user
344 QMessageBox::information( this, "Wellenreiter II", 344 QMessageBox::information( this, "Wellenreiter II",
345 tr( "Your wireless card\nshould now be usable again." ) ); 345 tr( "Your wireless card\nshould now be usable again." ) );
346 346
347 sniffing = false; 347 sniffing = false;
348 emit( stoppedSniffing() ); 348 emit( stoppedSniffing() );
349 349
350 #ifdef QWS
351 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
352 {
353 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
354 }
355 #else
356 #warning FIXME: setScreenSaverMode is not operational on the X11 build
357 #endif
358
350 // print out statistics 359 // print out statistics
351 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 360 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
352 statwindow->updateCounter( it.key(), it.data() ); 361 statwindow->updateCounter( it.key(), it.data() );
353} 362}
354 363
355 364
356void Wellenreiter::startClicked() 365void Wellenreiter::startClicked()
357{ 366{
358 // get configuration from config window 367 // get configuration from config window
359 368
360 const QString& interface = configwindow->interfaceName->currentText(); 369 const QString& interface = configwindow->interfaceName->currentText();
361 const int cardtype = configwindow->driverType(); 370 const int cardtype = configwindow->driverType();
362 const int interval = configwindow->hoppingInterval(); 371 const int interval = configwindow->hoppingInterval();
363 372
364 if ( ( interface == "" ) || ( cardtype == 0 ) ) 373 if ( ( interface == "" ) || ( cardtype == 0 ) )
365 { 374 {
366 QMessageBox::information( this, "Wellenreiter II", 375 QMessageBox::information( this, "Wellenreiter II",
367 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 376 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
368 return; 377 return;
369 } 378 }
370 379
371 // configure device 380 // configure device
372 ONetwork* net = ONetwork::instance(); 381 ONetwork* net = ONetwork::instance();
373 382
374 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 383 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
375 384
376 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 385 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
377 386
378 // bring device UP 387 // bring device UP
379 iface->setUp( true ); 388 iface->setUp( true );
380 if ( !iface->isUp() ) 389 if ( !iface->isUp() )
381 { 390 {
382 QMessageBox::warning( this, "Wellenreiter II", 391 QMessageBox::warning( this, "Wellenreiter II",
383 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 392 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
384 return; 393 return;
385 } 394 }
386 395
387 // set monitor mode 396 // set monitor mode
388 bool usePrism = configwindow->usePrismHeader(); 397 bool usePrism = configwindow->usePrismHeader();
389 398
390 switch ( cardtype ) 399 switch ( cardtype )
391 { 400 {
392 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 401 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
393 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 402 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
394 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 403 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
395 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 404 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
396 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 405 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
397 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 406 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
398 default: assert( 0 ); // shouldn't reach this 407 default: assert( 0 ); // shouldn't reach this
399 } 408 }
400 409
401 // switch device into monitor mode 410 // switch device into monitor mode
402 if ( cardtype < DEVTYPE_FILE ) 411 if ( cardtype < DEVTYPE_FILE )
403 { 412 {
404 if ( cardtype != DEVTYPE_MANUAL ) 413 if ( cardtype != DEVTYPE_MANUAL )
405 iface->setMonitorMode( true ); 414 iface->setMonitorMode( true );
406 if ( !iface->monitorMode() ) 415 if ( !iface->monitorMode() )
407 { 416 {
408 if ( QMessageBox::warning( this, "Wellenreiter II", 417 if ( QMessageBox::warning( this, "Wellenreiter II",
409 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 418 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
410 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 419 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
411 return; 420 return;
412 } 421 }
413 } 422 }
414 423
415 // open GPS device 424 // open GPS device
416 if ( configwindow->enableGPS->isChecked() ) 425 if ( configwindow->enableGPS->isChecked() )
417 { 426 {
418 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 427 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
419 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 428 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
420 } 429 }
421 430
422 // open pcap and start sniffing 431 // open pcap and start sniffing
423 if ( cardtype != DEVTYPE_FILE ) 432 if ( cardtype != DEVTYPE_FILE )
424 { 433 {
425 pcap->open( interface ); 434 pcap->open( interface );
426 435
427 if ( configwindow->writeCaptureFile->isChecked() ) 436 if ( configwindow->writeCaptureFile->isChecked() )
428 { 437 {
429 QString dumpname( configwindow->captureFileName->text() ); 438 QString dumpname( configwindow->captureFileName->text() );
430 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 439 if ( dumpname.isEmpty() ) dumpname = "captureFile";
431 dumpname.append( '-' ); 440 dumpname.append( '-' );
432 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 441 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
433 dumpname.append( ".wellenreiter" ); 442 dumpname.append( ".wellenreiter" );
434 pcap->openDumpFile( dumpname ); 443 pcap->openDumpFile( dumpname );
435 } 444 }
436 else 445 else
437 { 446 {
438 pcap->open( interface ); 447 pcap->open( interface );
439 } 448 }
440 } 449 }
441 else 450 else
442 { 451 {
443 pcap->open( QFile( interface ) ); 452 pcap->open( QFile( interface ) );
444 } 453 }
445 454
446 if ( !pcap->isOpen() ) 455 if ( !pcap->isOpen() )
447 { 456 {
448 QMessageBox::warning( this, "Wellenreiter II", 457 QMessageBox::warning( this, "Wellenreiter II",
449 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); 458 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
450 return; 459 return;
451 } 460 }
452 461
453 // set capturer to non-blocking mode 462 // set capturer to non-blocking mode
454 pcap->setBlocking( false ); 463 pcap->setBlocking( false );
455 464
456 // start channel hopper 465 // start channel hopper
457 if ( cardtype != DEVTYPE_FILE ) 466 if ( cardtype != DEVTYPE_FILE )
458 { 467 {
459 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 468 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
460 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 469 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
461 } 470 }
462 471
463 if ( cardtype != DEVTYPE_FILE ) 472 if ( cardtype != DEVTYPE_FILE )
464 { 473 {
465 // connect socket notifier and start channel hopper 474 // connect socket notifier and start channel hopper
466 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 475 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
467 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 476 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
468 } 477 }
469 else 478 else
470 { 479 {
471 // start timer for reading packets 480 // start timer for reading packets
472 startTimer( 100 ); 481 startTimer( 100 );
473 } 482 }
474 483
475 logwindow->log( "(i) Started Scanning." ); 484 logwindow->log( "(i) Started Scanning." );
476 sniffing = true; 485 sniffing = true;
486
487 #ifdef QWS
488 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
489 {
490 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
491 }
492 #else
493 #warning FIXME: setScreenSaverMode is not operational on the X11 build
494 #endif
495
477 emit( startedSniffing() ); 496 emit( startedSniffing() );
478 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 497 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
479 else 498 else
480 { 499 {
481 assert( parent() ); 500 assert( parent() );
482 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 501 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
483 } 502 }
484} 503}
485 504
486 505
487void Wellenreiter::timerEvent( QTimerEvent* ) 506void Wellenreiter::timerEvent( QTimerEvent* )
488{ 507{
489 qDebug( "Wellenreiter::timerEvent()" ); 508 qDebug( "Wellenreiter::timerEvent()" );
490 OPacket* p = pcap->next(); 509 OPacket* p = pcap->next();
491 if ( !p ) // no more packets available 510 if ( !p ) // no more packets available
492 { 511 {
493 stopClicked(); 512 stopClicked();
494 } 513 }
495 else 514 else
496 { 515 {
497 receivePacket( p ); 516 receivePacket( p );
498 delete p; 517 delete p;
499 } 518 }
500} 519}
501 520
502 521
503void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 522void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
504{ 523{
505 #ifdef QWS 524 #ifdef QWS
506 if ( action == "TouchSound" ) 525 if ( action == "TouchSound" )
507 ODevice::inst()->touchSound(); 526 ODevice::inst()->touchSound();
508 else if ( action == "AlarmSound" ) 527 else if ( action == "AlarmSound" )
509 ODevice::inst()->alarmSound(); 528 ODevice::inst()->alarmSound();
510 else if ( action == "KeySound" ) 529 else if ( action == "KeySound" )
511 ODevice::inst()->keySound(); 530 ODevice::inst()->keySound();
512 else if ( action == "LedOn" ) 531 else if ( action == "LedOn" )
513 ODevice::inst()->setLedState( Led_Mail, Led_On ); 532 ODevice::inst()->setLedState( Led_Mail, Led_On );
514 else if ( action == "LedOff" ) 533 else if ( action == "LedOff" )
515 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 534 ODevice::inst()->setLedState( Led_Mail, Led_Off );
516 else if ( action == "LogMessage" ) 535 else if ( action == "LogMessage" )
517 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 536 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
518 else if ( action == "MessageBox" ) 537 else if ( action == "MessageBox" )
519 QMessageBox::information( this, "Notification!", 538 QMessageBox::information( this, "Notification!",
520 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 539 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
521 #else 540 #else
522 #warning Actions do not work with Qt/X11 yet 541 #warning Actions do not work with Qt/X11 yet
523 #endif 542 #endif
524} 543}
525 544
526void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 545void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
527{ 546{
528 #ifdef QWS 547 #ifdef QWS
529 if ( !iface ) 548 if ( !iface )
530 { 549 {
531 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 550 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
532 return; 551 return;
533 } 552 }
534 553
535 if ( sniffing ) 554 if ( sniffing )
536 { 555 {
537 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 556 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
538 return; 557 return;
539 } 558 }
540 559
541 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 560 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
542 (const char*) iface->name(), 561 (const char*) iface->name(),
543 (const char*) type, 562 (const char*) type,
544 (const char*) essid, 563 (const char*) essid,
545 channel, 564 channel,
546 (const char*) macaddr ); 565 (const char*) macaddr );
547 566
548 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 567 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
549 int count = 3; 568 int count = 3;
550 qDebug("sending %d messages",count); 569 qDebug("sending %d messages",count);
551 msg << QString("count") << QString::number(count); 570 msg << QString("count") << QString::number(count);
552 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 571 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
553 msg << QString(iface->name()) << QString("Mode") << type; 572 msg << QString(iface->name()) << QString("Mode") << type;
554 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 573 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
555 msg << QString(iface->name()) << QString("ESSID") << essid; 574 msg << QString(iface->name()) << QString("ESSID") << essid;
556 qDebug("msg >%s< channel >%d<", iface->name(),channel); 575 qDebug("msg >%s< channel >%d<", iface->name(),channel);
557 msg << QString(iface->name()) << QString("Channel") << channel; 576 msg << QString(iface->name()) << QString("Channel") << channel;
558// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 577// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
559// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 578// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
560 #else 579 #else
561 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 580 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
562 #endif 581 #endif
563 582
564} 583}
565 584