summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/configwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp67
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 @@
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/* QT */ 20/* QT */
21#include <qapplication.h> 21#include <qapplication.h>
22#include <qcheckbox.h> 22#include <qcheckbox.h>
23#include <qcombobox.h> 23#include <qcombobox.h>
24#include <qfile.h> 24#include <qfile.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qmap.h> 27#include <qmap.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtoolbutton.h> 29#include <qtoolbutton.h>
30#include <qspinbox.h> 30#include <qspinbox.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/onetwork.h> 34#include <opie2/onetwork.h>
35#include <opie2/oapplication.h>
36#include <opie2/oconfig.h>
35 37
36WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 38WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
37 39
38WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 40WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
39 :WellenreiterConfigBase( parent, name, true, f ) 41 :WellenreiterConfigBase( parent, name, true, f )
40{ 42{
41 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 43 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
42 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 44 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
43 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 45 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
44 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 46 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
45 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 47 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
46 _devicetype[ "<file>" ] = DEVTYPE_FILE; 48 _devicetype[ "<file>" ] = DEVTYPE_FILE;
47 49
48 // gather possible interface names from ONetwork 50 // gather possible interface names from ONetwork
49 ONetwork* net = ONetwork::instance(); 51 ONetwork* net = ONetwork::instance();
50 ONetwork::InterfaceIterator it = net->iterator(); 52 ONetwork::InterfaceIterator it = net->iterator();
51 while ( it.current() ) 53 while ( it.current() )
52 { 54 {
53 if ( it.current()->isWireless() ) 55 if ( it.current()->isWireless() )
54 interfaceName->insertItem( it.current()->name() ); 56 interfaceName->insertItem( it.current()->name() );
55 ++it; 57 ++it;
56 } 58 }
57 59
58 if ( !load() ) // no configuration present 60 if ( !load() ) // no configuration present
@@ -105,49 +107,49 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow()
105 107
106 108
107int WellenreiterConfigWindow::driverType() const 109int WellenreiterConfigWindow::driverType() const
108{ 110{
109 QString name = deviceType->currentText(); 111 QString name = deviceType->currentText();
110 if ( _devicetype.contains( name ) ) 112 if ( _devicetype.contains( name ) )
111 { 113 {
112 return _devicetype[name]; 114 return _devicetype[name];
113 } 115 }
114 else 116 else
115 { 117 {
116 return 0; 118 return 0;
117 } 119 }
118}; 120};
119 121
120 122
121int WellenreiterConfigWindow::hoppingInterval() const 123int WellenreiterConfigWindow::hoppingInterval() const
122{ 124{
123 return hopInterval->cleanText().toInt(); 125 return hopInterval->cleanText().toInt();
124} 126}
125 127
126 128
127bool WellenreiterConfigWindow::usePrismHeader() const 129bool WellenreiterConfigWindow::usePrismHeader() const
128{ 130{
129 return prismHeader->isOn(); 131 return prismHeader->isChecked();
130} 132}
131 133
132 134
133bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 135bool WellenreiterConfigWindow::isChannelChecked( int channel ) const
134{ 136{
135 switch ( channel ) 137 switch ( channel )
136 { 138 {
137 case 1: return channel1->isOn(); 139 case 1: return channel1->isOn();
138 case 2: return channel2->isOn(); 140 case 2: return channel2->isOn();
139 case 3: return channel3->isOn(); 141 case 3: return channel3->isOn();
140 case 4: return channel4->isOn(); 142 case 4: return channel4->isOn();
141 case 5: return channel5->isOn(); 143 case 5: return channel5->isOn();
142 case 6: return channel6->isOn(); 144 case 6: return channel6->isOn();
143 case 7: return channel7->isOn(); 145 case 7: return channel7->isOn();
144 case 8: return channel8->isOn(); 146 case 8: return channel8->isOn();
145 case 9: return channel9->isOn(); 147 case 9: return channel9->isOn();
146 case 10: return channel10->isOn(); 148 case 10: return channel10->isOn();
147 case 11: return channel11->isOn(); 149 case 11: return channel11->isOn();
148 case 12: return channel12->isOn(); 150 case 12: return channel12->isOn();
149 case 13: return channel13->isOn(); 151 case 13: return channel13->isOn();
150 case 14: return channel14->isOn(); 152 case 14: return channel14->isOn();
151 } 153 }
152} 154}
153 155
@@ -205,37 +207,98 @@ bool WellenreiterConfigWindow::useGPS() const
205 return enableGPS->isChecked(); 207 return enableGPS->isChecked();
206} 208}
207 209
208 210
209const QString WellenreiterConfigWindow::gpsHost() const 211const QString WellenreiterConfigWindow::gpsHost() const
210{ 212{
211 return useGPS() ? gpsdHost->currentText() : QString::null; 213 return useGPS() ? gpsdHost->currentText() : QString::null;
212} 214}
213 215
214 216
215int WellenreiterConfigWindow::gpsPort() const 217int WellenreiterConfigWindow::gpsPort() const
216{ 218{
217 bool ok; 219 bool ok;
218 return useGPS() ? gpsdPort->value() : -1; 220 return useGPS() ? gpsdPort->value() : -1;
219} 221}
220 222
221 223
222bool WellenreiterConfigWindow::load() 224bool WellenreiterConfigWindow::load()
223{ 225{
224#ifdef Q_WS_X11 226#ifdef Q_WS_X11
225 #warning Persistent Configuration not yet implemented for standalone X11 build 227 #warning Persistent Configuration not yet implemented for standalone X11 build
226 return false; 228 return false;
227#else 229#else
228 qDebug( "loading configuration settings..." ); 230 qDebug( "loading configuration settings..." );
229 return true; 231
232 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
233
234 OConfig* c = oApp->config();
235
236 c->setGroup( "Interface" );
237 //interfaceName->setCurrentText( c->readEntry( "name" ) );
238 //deviceType->setCurrentText( c->readEntry( "type", "<select>" ) );
239 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
240 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
241 hopInterval->setValue( c->readNumEntry( "interval", 100 ) );
242 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) );
243
244 c->setGroup( "Capture" );
245 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
246
247 c->setGroup( "UI" );
248 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
249 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
250 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
251
252 c->setGroup( "GPS" );
253 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
254#if QT_VERSION < 300
255 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
256 gpsdHost->setCurrentItem( 0 );
257#else
258 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
259#endif
260 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
261 startGPS->setChecked( c->readBoolEntry( "start", false ) );
262 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
263
264 return false; // false = perform autodetection; true = use config settings
230#endif 265#endif
231} 266}
232 267
233 268
234void WellenreiterConfigWindow::save() 269void WellenreiterConfigWindow::save()
235{ 270{
236#ifdef Q_WS_X11 271#ifdef Q_WS_X11
237 #warning Persistent Configuration not yet implemented for standalone X11 build 272 #warning Persistent Configuration not yet implemented for standalone X11 build
238#else 273#else
239 qDebug( "saving configuration settings..." ); 274 qDebug( "saving configuration settings..." );
275
276 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
277
278 OConfig* c = oApp->config();
279
280 c->setGroup( "Interface" );
281 c->writeEntry( "name", interfaceName->currentText() );
282 c->writeEntry( "type", deviceType->currentText() );
283 c->writeEntry( "prism", prismHeader->isChecked() );
284 c->writeEntry( "hop", hopChannels->isChecked() );
285 c->writeEntry( "interval", hopInterval->value() );
286 c->writeEntry( "adaptive", adaptiveHopping->isChecked() );
287
288 c->setGroup( "Capture" );
289 c->writeEntry( "filename", captureFileName->text() );
290
291 c->setGroup( "UI" );
292 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
293 c->writeEntry( "openTree", openTree->isChecked() );
294 c->writeEntry( "disablePM", disablePM->isChecked() );
295
296 c->setGroup( "GPS" );
297 c->writeEntry( "use", enableGPS->isChecked() );
298 c->writeEntry( "host", gpsdHost->currentText() );
299 c->writeEntry( "port", gpsdPort->value() );
300 c->writeEntry( "start", startGPS->isChecked() );
301 c->writeEntry( "command", commandGPS->text() );
302
240#endif 303#endif
241} 304}