author | mickeyl <mickeyl> | 2003-09-26 12:24:21 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-09-26 12:24:21 (UTC) |
commit | d1a11b45e805fe7771ea05944757d767c3c4c8ea (patch) (side-by-side diff) | |
tree | f270fea2d1d05c9fc8db1d57542ef7a01870750c /noncore/net/wellenreiter/gui/configwindow.cpp | |
parent | a88328daa117bdb3bd72cef6ca6e5e2b9d619a13 (diff) | |
download | opie-d1a11b45e805fe7771ea05944757d767c3c4c8ea.zip opie-d1a11b45e805fe7771ea05944757d767c3c4c8ea.tar.gz opie-d1a11b45e805fe7771ea05944757d767c3c4c8ea.tar.bz2 |
more work on persistent configuration
version bump to 1.0.1-snap
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index d255c6a..84d4c63 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -11,48 +11,50 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ /* LOCAL */ #include "configwindow.h" #include "mainwindow.h" /* QT */ #include <qapplication.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qfile.h> #include <qlineedit.h> #include <qlayout.h> #include <qmap.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qspinbox.h> #include <qtextstream.h> /* OPIE */ #include <opie2/onetwork.h> +#include <opie2/oapplication.h> +#include <opie2/oconfig.h> WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { _devicetype[ "cisco" ] = DEVTYPE_CISCO; _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; _devicetype[ "<file>" ] = DEVTYPE_FILE; // gather possible interface names from ONetwork ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { if ( it.current()->isWireless() ) interfaceName->insertItem( it.current()->name() ); ++it; } if ( !load() ) // no configuration present @@ -105,49 +107,49 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow() int WellenreiterConfigWindow::driverType() const { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; } else { return 0; } }; int WellenreiterConfigWindow::hoppingInterval() const { return hopInterval->cleanText().toInt(); } bool WellenreiterConfigWindow::usePrismHeader() const { - return prismHeader->isOn(); + return prismHeader->isChecked(); } bool WellenreiterConfigWindow::isChannelChecked( int channel ) const { switch ( channel ) { case 1: return channel1->isOn(); case 2: return channel2->isOn(); case 3: return channel3->isOn(); case 4: return channel4->isOn(); case 5: return channel5->isOn(); case 6: return channel6->isOn(); case 7: return channel7->isOn(); case 8: return channel8->isOn(); case 9: return channel9->isOn(); case 10: return channel10->isOn(); case 11: return channel11->isOn(); case 12: return channel12->isOn(); case 13: return channel13->isOn(); case 14: return channel14->isOn(); } } @@ -205,37 +207,98 @@ bool WellenreiterConfigWindow::useGPS() const return enableGPS->isChecked(); } const QString WellenreiterConfigWindow::gpsHost() const { return useGPS() ? gpsdHost->currentText() : QString::null; } int WellenreiterConfigWindow::gpsPort() const { bool ok; return useGPS() ? gpsdPort->value() : -1; } bool WellenreiterConfigWindow::load() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build return false; #else qDebug( "loading configuration settings..." ); - return true; + + /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ + + OConfig* c = oApp->config(); + + c->setGroup( "Interface" ); + //interfaceName->setCurrentText( c->readEntry( "name" ) ); + //deviceType->setCurrentText( c->readEntry( "type", "<select>" ) ); + prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); + hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); + hopInterval->setValue( c->readNumEntry( "interval", 100 ) ); + adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); + + c->setGroup( "Capture" ); + captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); + + c->setGroup( "UI" ); + lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); + openTree->setChecked( c->readBoolEntry( "openTree", true ) ); + disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); + + c->setGroup( "GPS" ); + enableGPS->setChecked( c->readBoolEntry( "use", false ) ); +#if QT_VERSION < 300 + gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); + gpsdHost->setCurrentItem( 0 ); +#else + gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); +#endif + gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); + startGPS->setChecked( c->readBoolEntry( "start", false ) ); + commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); + + return false; // false = perform autodetection; true = use config settings #endif } void WellenreiterConfigWindow::save() { #ifdef Q_WS_X11 #warning Persistent Configuration not yet implemented for standalone X11 build #else qDebug( "saving configuration settings..." ); + + /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ + + OConfig* c = oApp->config(); + + c->setGroup( "Interface" ); + c->writeEntry( "name", interfaceName->currentText() ); + c->writeEntry( "type", deviceType->currentText() ); + c->writeEntry( "prism", prismHeader->isChecked() ); + c->writeEntry( "hop", hopChannels->isChecked() ); + c->writeEntry( "interval", hopInterval->value() ); + c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); + + c->setGroup( "Capture" ); + c->writeEntry( "filename", captureFileName->text() ); + + c->setGroup( "UI" ); + c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); + c->writeEntry( "openTree", openTree->isChecked() ); + c->writeEntry( "disablePM", disablePM->isChecked() ); + + c->setGroup( "GPS" ); + c->writeEntry( "use", enableGPS->isChecked() ); + c->writeEntry( "host", gpsdHost->currentText() ); + c->writeEntry( "port", gpsdPort->value() ); + c->writeEntry( "start", startGPS->isChecked() ); + c->writeEntry( "command", commandGPS->text() ); + #endif } |