summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-09 20:01:42 (UTC)
committer mickeyl <mickeyl>2004-01-09 20:01:42 (UTC)
commit88af644c534f19e391ebbe8ea0babf3ccf459eb1 (patch) (unidiff)
treef49e88a6dfc58d3f196e6918bb402a14ee9f0ad0
parent56bb9961db1158250bbfe971f4556b56c0bd6581 (diff)
downloadopie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.zip
opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.gz
opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.bz2
save configuration settings in accept(), not in the ~
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp16
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h3
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp3
3 files changed, 16 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 7f39230..9358866 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -71,51 +71,57 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
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
95WellenreiterConfigWindow::~WellenreiterConfigWindow() 95void WellenreiterConfigWindow::accept()
96{ 96{
97 save(); 97 save();
98 QDialog::accept();
99}
100
101
102WellenreiterConfigWindow::~WellenreiterConfigWindow()
103{
98} 104}
99 105
100 106
101void WellenreiterConfigWindow::performAutodetection() 107void WellenreiterConfigWindow::performAutodetection()
102{ 108{
103 //TODO: insert modal splash screen here 109 //TODO: insert modal splash screen here
104 // and sleep a second, so that it looks 110 // and sleep a second, so that it looks
105 // like we're actually doing something fancy... ;-) 111 // like we're actually doing something fancy... ;-)
106 112
107 qDebug( "WellenreiterConfigWindow::performAutodetection()" ); 113 qDebug( "WellenreiterConfigWindow::performAutodetection()" );
108 114
109 // try to guess device type 115 // try to guess device type
110 QFile m( "/proc/modules" ); 116 QFile m( "/proc/modules" );
111 if ( m.open( IO_ReadOnly ) ) 117 if ( m.open( IO_ReadOnly ) )
112 { 118 {
113 int devicetype(0); 119 int devicetype(0);
114 QString line; 120 QString line;
115 QTextStream modules( &m ); 121 QTextStream modules( &m );
116 while( !modules.atEnd() && !devicetype ) 122 while( !modules.atEnd() && !devicetype )
117 { 123 {
118 modules >> line; 124 modules >> line;
119 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 125 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
120 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 126 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
121 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 127 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
@@ -287,49 +293,49 @@ void WellenreiterConfigWindow::performAction( const QString& type,
287 int action; 293 int action;
288 QString script; 294 QString script;
289 295
290 if ( type == "network" ) 296 if ( type == "network" )
291 { 297 {
292 action = newNetworkAction->currentItem(); 298 action = newNetworkAction->currentItem();
293 script = newNetworkScript->text(); 299 script = newNetworkScript->text();
294 } 300 }
295 else if ( type == "managed" || type == "adhoc" ) 301 else if ( type == "managed" || type == "adhoc" )
296 { 302 {
297 action = newClientAction->currentItem(); 303 action = newClientAction->currentItem();
298 script = newClientScript->text(); 304 script = newClientScript->text();
299 } 305 }
300 else if ( type == "station" ) 306 else if ( type == "station" )
301 { 307 {
302 action = newStationAction->currentItem(); 308 action = newStationAction->currentItem();
303 script = newStationScript->text(); 309 script = newStationScript->text();
304 } 310 }
305 else 311 else
306 { 312 {
307 qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); 313 qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type );
308 return; 314 return;
309 } 315 }
310 316
311 qDebug( "going to perform action %d (script='%s')", 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 );
312 318
313 switch( action ) 319 switch( action )
314 { 320 {
315 case 0: /* Ignore */ return; 321 case 0: /* Ignore */ return;
316 case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; 322 case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return;
317 case 2: /* Play Click */ ODevice::inst()->touchSound(); return; 323 case 2: /* Play Click */ ODevice::inst()->touchSound(); return;
318 case 3: /* Blink LED */ break; //FIXME: Implement this 324 case 3: /* Blink LED */ break; //FIXME: Implement this
319 case 4: /* Run Script */ 325 case 4: /* Run Script */
320 { 326 {
321 /** 327 /**
322 * 328 *
323 * Script Substitution Information: 329 * Script Substitution Information:
324 * 330 *
325 * $SSID = SSID 331 * $SSID = SSID
326 * $MAC = MAC 332 * $MAC = MAC
327 * $WEP = Wep 333 * $WEP = Wep
328 * $CHAN = Channel 334 * $CHAN = Channel
329 * 335 *
330 **/ 336 **/
331 script = script.replace( QRegExp( "$SSID" ), essid ); 337 script = script.replace( QRegExp( "$SSID" ), essid );
332 script = script.replace( QRegExp( "$MAC" ), mac ); 338 script = script.replace( QRegExp( "$MAC" ), mac );
333 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); 339 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) );
334 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); 340 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) );
335 341
@@ -377,53 +383,53 @@ void WellenreiterConfigWindow::load()
377 break; 383 break;
378 } 384 }
379 } 385 }
380#else 386#else
381 deviceType->setCurrentText( device ); 387 deviceType->setCurrentText( device );
382#endif 388#endif
383 } 389 }
384 else 390 else
385 { 391 {
386 performAutodetection(); 392 performAutodetection();
387 } 393 }
388 394
389 prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); 395 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
390 hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); 396 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
391 hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); 397 hopInterval->setValue( c->readNumEntry( "interval", 250 ) );
392 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); 398 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) );
393 399
394 c->setGroup( "Capture" ); 400 c->setGroup( "Capture" );
395 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); 401 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
396 402
397 c->setGroup( "UI" ); 403 c->setGroup( "UI" );
398 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); 404 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
399 openTree->setChecked( c->readBoolEntry( "openTree", true ) ); 405 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
400 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); 406 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
401 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) ); 407 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm
402 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); 408 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) );
403 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) ); 409 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click
404 newClientScript->setText( c->readEntry( "newClientScript", "" ) ); 410 newClientScript->setText( c->readEntry( "newClientScript", "" ) );
405 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) ); 411 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click
406 newStationScript->setText( c->readEntry( "newStationScript", "" ) ); 412 newStationScript->setText( c->readEntry( "newStationScript", "" ) );
407 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand 413 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand
408 414
409 c->setGroup( "GPS" ); 415 c->setGroup( "GPS" );
410 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 416 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
411#if QT_VERSION < 300 417#if QT_VERSION < 300
412 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 418 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
413 gpsdHost->setCurrentItem( 0 ); 419 gpsdHost->setCurrentItem( 0 );
414#else 420#else
415 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); 421 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
416#endif 422#endif
417 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); 423 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
418 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 424 startGPS->setChecked( c->readBoolEntry( "start", false ) );
419 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 425 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
420 426
421#endif 427#endif
422} 428}
423 429
424 430
425void WellenreiterConfigWindow::save() 431void WellenreiterConfigWindow::save()
426{ 432{
427#ifdef Q_WS_X11 433#ifdef Q_WS_X11
428 #warning Persistent Configuration not yet implemented for standalone X11 build 434 #warning Persistent Configuration not yet implemented for standalone X11 build
429#else 435#else
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index 5c998cb..d31d1e8 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -47,35 +47,36 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
47 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; 47 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ };
48 static WellenreiterConfigWindow* instance() { return _instance; }; 48 static WellenreiterConfigWindow* instance() { return _instance; };
49 49
50 int hoppingInterval() const; 50 int hoppingInterval() const;
51 bool usePrismHeader() const; 51 bool usePrismHeader() const;
52 bool isChannelChecked( int ) const; 52 bool isChannelChecked( int ) const;
53 53
54 bool useGPS() const; 54 bool useGPS() const;
55 const QString gpsHost() const; 55 const QString gpsHost() const;
56 int gpsPort() const; 56 int gpsPort() const;
57 57
58 void save(); 58 void save();
59 void load(); 59 void load();
60 60
61 public slots: 61 public slots:
62 void changedDeviceType(int); 62 void changedDeviceType(int);
63 void changedNetworkAction(int t); 63 void changedNetworkAction(int t);
64 void changedClientAction(int t); 64 void changedClientAction(int t);
65 void changedStationAction(int t); 65 void changedStationAction(int t);
66 void getCaptureFileNameClicked(); 66 void getCaptureFileNameClicked();
67 void performAutodetection(); 67 void performAutodetection();
68 void channelAllClicked(int); 68 void channelAllClicked(int);
69 void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); 69 void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ );
70 70
71 protected: 71 protected slots:
72 void synchronizeActionsAndScripts(); 72 void synchronizeActionsAndScripts();
73 virtual void accept();
73 74
74 protected: 75 protected:
75 QMap<QString, int> _devicetype; 76 QMap<QString, int> _devicetype;
76 static WellenreiterConfigWindow* _instance; 77 static WellenreiterConfigWindow* _instance;
77 int _guess; 78 int _guess;
78 79
79}; 80};
80 81
81#endif 82#endif
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index fd88b63..10ead53 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -411,48 +411,51 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in
411 411
412MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, 412MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
413 bool wep, int channel, int signal, bool probed ) 413 bool wep, int channel, int signal, bool probed )
414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
416 _channel( channel ), _signal( signal ), _beacons( 1 ) 416 _channel( channel ), _signal( signal ), _beacons( 1 )
417{ 417{
418 #ifdef DEBUG 418 #ifdef DEBUG
419 qDebug( "creating scanlist item" ); 419 qDebug( "creating scanlist item" );
420 #endif 420 #endif
421 421
422 if ( WellenreiterConfigWindow::instance() ) 422 if ( WellenreiterConfigWindow::instance() )
423 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here 423 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
424 424
425 decorateItem( type, essid, macaddr, wep, channel, signal, probed ); 425 decorateItem( type, essid, macaddr, wep, channel, signal, probed );
426} 426}
427 427
428MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, 428MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
429 bool wep, int channel, int signal ) 429 bool wep, int channel, int signal )
430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
431{ 431{
432 #ifdef DEBUG 432 #ifdef DEBUG
433 qDebug( "creating scanlist item" ); 433 qDebug( "creating scanlist item" );
434 #endif 434 #endif
435 if ( WellenreiterConfigWindow::instance() )
436 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
437
435 decorateItem( type, essid, macaddr, wep, channel, signal, false ); 438 decorateItem( type, essid, macaddr, wep, channel, signal, false );
436} 439}
437 440
438const QString& MScanListItem::essid() const 441const QString& MScanListItem::essid() const
439{ 442{
440 if ( type == "network" ) 443 if ( type == "network" )
441 return _essid; 444 return _essid;
442 else 445 else
443 return ( (MScanListItem*) parent() )->essid(); 446 return ( (MScanListItem*) parent() )->essid();
444} 447}
445 448
446OListViewItem* MScanListItem::childFactory() 449OListViewItem* MScanListItem::childFactory()
447{ 450{
448 return new MScanListItem( this ); 451 return new MScanListItem( this );
449} 452}
450 453
451void MScanListItem::serializeTo( QDataStream& s ) const 454void MScanListItem::serializeTo( QDataStream& s ) const
452{ 455{
453 #ifdef DEBUG 456 #ifdef DEBUG
454 qDebug( "serializing MScanListItem" ); 457 qDebug( "serializing MScanListItem" );
455 #endif 458 #endif
456 OListViewItem::serializeTo( s ); 459 OListViewItem::serializeTo( s );
457 460
458 s << _type; 461 s << _type;