summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp6
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
@@ -130,345 +130,345 @@ void WellenreiterConfigWindow::performAutodetection()
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
140int WellenreiterConfigWindow::driverType() const 140int 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
154int WellenreiterConfigWindow::hoppingInterval() const 154int WellenreiterConfigWindow::hoppingInterval() const
155{ 155{
156 return hopInterval->cleanText().toInt(); 156 return hopInterval->cleanText().toInt();
157} 157}
158 158
159 159
160bool WellenreiterConfigWindow::usePrismHeader() const 160bool WellenreiterConfigWindow::usePrismHeader() const
161{ 161{
162 return prismHeader->isChecked(); 162 return prismHeader->isChecked();
163} 163}
164 164
165 165
166bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 166bool 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
188void WellenreiterConfigWindow::changedDeviceType(int t) 188void 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
205void WellenreiterConfigWindow::synchronizeActionsAndScripts() 205void 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
217void WellenreiterConfigWindow::changedNetworkAction(int t) 217void WellenreiterConfigWindow::changedNetworkAction(int t)
218{ 218{
219 synchronizeActionsAndScripts(); 219 synchronizeActionsAndScripts();
220} 220}
221 221
222 222
223void WellenreiterConfigWindow::changedClientAction(int t) 223void WellenreiterConfigWindow::changedClientAction(int t)
224{ 224{
225 synchronizeActionsAndScripts(); 225 synchronizeActionsAndScripts();
226} 226}
227 227
228 228
229void WellenreiterConfigWindow::changedStationAction(int t) 229void WellenreiterConfigWindow::changedStationAction(int t)
230{ 230{
231 synchronizeActionsAndScripts(); 231 synchronizeActionsAndScripts();
232} 232}
233 233
234 234
235void WellenreiterConfigWindow::getCaptureFileNameClicked() 235void 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
246void WellenreiterConfigWindow::channelAllClicked(int state) 246void 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
266bool WellenreiterConfigWindow::useGPS() const 266bool WellenreiterConfigWindow::useGPS() const
267{ 267{
268 return enableGPS->isChecked(); 268 return enableGPS->isChecked();
269} 269}
270 270
271 271
272const QString WellenreiterConfigWindow::gpsHost() const 272const 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
278int WellenreiterConfigWindow::gpsPort() const 278int 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
285void WellenreiterConfigWindow::performAction( const QString& type, 285void 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
352void WellenreiterConfigWindow::load() 352void 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
431void WellenreiterConfigWindow::save() 431void 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
@@ -465,251 +465,251 @@ void Wellenreiter::stopClicked()
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
495void Wellenreiter::startClicked() 495void 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
637void Wellenreiter::timerEvent( QTimerEvent* ) 637void 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
653void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 653void 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
676void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 676void 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