summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-05-03 12:47:50 (UTC)
committer mickeyl <mickeyl>2004-05-03 12:47:50 (UTC)
commit0490226f4ed54fdeef5578255594830659a8d3bd (patch) (unidiff)
treee960e0d3d8f916927a9c7c911b1b496475b21e07
parentfb6f93892d4d0e0471d62f5b5ab6d9bdef0a5e76 (diff)
downloadopie-0490226f4ed54fdeef5578255594830659a8d3bd.zip
opie-0490226f4ed54fdeef5578255594830659a8d3bd.tar.gz
opie-0490226f4ed54fdeef5578255594830659a8d3bd.tar.bz2
write more settings into the .config file and read it
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 89ed24c..ae149e2 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -20,464 +20,473 @@
20/* OPIE */ 20/* OPIE */
21#include <opie2/onetwork.h> 21#include <opie2/onetwork.h>
22#ifdef QWS 22#ifdef QWS
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h> 24#include <opie2/oconfig.h>
25#include <opie2/odevice.h> 25#include <opie2/odevice.h>
26#include <opie2/odebug.h> 26#include <opie2/odebug.h>
27using namespace Opie::Core; 27using namespace Opie::Core;
28using namespace Opie::Net; 28using namespace Opie::Net;
29#endif 29#endif
30 30
31/* QT */ 31/* QT */
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qcheckbox.h> 33#include <qcheckbox.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qmap.h> 38#include <qmap.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qspinbox.h> 41#include <qspinbox.h>
42#include <qtabwidget.h> 42#include <qtabwidget.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46/* STD */ 46/* STD */
47#include <assert.h> 47#include <assert.h>
48 48
49WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 49WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
50 50
51WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 51WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
52 :WellenreiterConfigBase( parent, name, true, f ) 52 :WellenreiterConfigBase( parent, name, true, f )
53{ 53{
54 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 54 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
55 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 55 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
56 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 56 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
57 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 57 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
58 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 58 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
59 _devicetype[ "<file>" ] = DEVTYPE_FILE; 59 _devicetype[ "<file>" ] = DEVTYPE_FILE;
60 60
61 // gather possible interface names from ONetwork 61 // gather possible interface names from ONetwork
62 ONetwork* net = ONetwork::instance(); 62 ONetwork* net = ONetwork::instance();
63 ONetwork::InterfaceIterator it = net->iterator(); 63 ONetwork::InterfaceIterator it = net->iterator();
64 while ( it.current() ) 64 while ( it.current() )
65 { 65 {
66 if ( it.current()->isWireless() ) 66 if ( it.current()->isWireless() )
67 interfaceName->insertItem( it.current()->name() ); 67 interfaceName->insertItem( it.current()->name() );
68 ++it; 68 ++it;
69 } 69 }
70 70
71 load(); 71 load();
72 72
73 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 73 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
74 QPushButton* okButton = new QPushButton( "ok", this ); 74 QPushButton* okButton = new QPushButton( "ok", this );
75 okButton->show(); 75 okButton->show();
76 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 76 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
77 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 77 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
78 #endif 78 #endif
79 79
80 WellenreiterConfigWindow::_instance = this; 80 WellenreiterConfigWindow::_instance = this;
81 81
82 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); 82 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
83 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); 83 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) );
84 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); 84 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) );
85 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); 85 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) );
86 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); 86 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) );
87 87
88 // make the checkbox 'channelAll' control all other channels 88 // make the checkbox 'channelAll' control all other channels
89 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 89 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
90 90
91 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); 91 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
92 92
93 // hide tab4 (parse) until Wellenreiter 1.2 93 // hide tab4 (parse) until Wellenreiter 1.2
94 tab->removePage( tab_4 ); 94 tab->removePage( tab_4 );
95}; 95};
96 96
97 97
98void WellenreiterConfigWindow::accept() 98void WellenreiterConfigWindow::accept()
99{ 99{
100 save(); 100 save();
101 QDialog::accept(); 101 QDialog::accept();
102} 102}
103 103
104 104
105WellenreiterConfigWindow::~WellenreiterConfigWindow() 105WellenreiterConfigWindow::~WellenreiterConfigWindow()
106{ 106{
107} 107}
108 108
109 109
110void WellenreiterConfigWindow::performAutodetection() 110void WellenreiterConfigWindow::performAutodetection()
111{ 111{
112 //TODO: insert modal splash screen here 112 //TODO: insert modal splash screen here
113 // and sleep a second, so that it looks 113 // and sleep a second, so that it looks
114 // like we're actually doing something fancy... ;-) 114 // like we're actually doing something fancy... ;-)
115 115
116 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl; 116 odebug << "WellenreiterConfigWindow::performAutodetection()" << oendl;
117 117
118 // try to guess device type 118 // try to guess device type
119 QFile m( "/proc/modules" ); 119 QFile m( "/proc/modules" );
120 if ( m.open( IO_ReadOnly ) ) 120 if ( m.open( IO_ReadOnly ) )
121 { 121 {
122 int devicetype(0); 122 int devicetype(0);
123 QString line; 123 QString line;
124 QTextStream modules( &m ); 124 QTextStream modules( &m );
125 while( !modules.atEnd() && !devicetype ) 125 while( !modules.atEnd() && !devicetype )
126 { 126 {
127 modules >> line; 127 modules >> line;
128 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 128 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
129 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 129 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
130 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 130 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
131 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; 131 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
132 } 132 }
133 if ( devicetype ) 133 if ( devicetype )
134 { 134 {
135 deviceType->setCurrentItem( devicetype ); 135 deviceType->setCurrentItem( devicetype );
136 _guess = devicetype; 136 _guess = devicetype;
137 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl; 137 odebug << "Wellenreiter: guessed device type to be #" << devicetype << "" << oendl;
138 } 138 }
139 } 139 }
140} 140}
141 141
142 142
143int WellenreiterConfigWindow::driverType() const 143int WellenreiterConfigWindow::driverType() const
144{ 144{
145 QString name = deviceType->currentText(); 145 QString name = deviceType->currentText();
146 if ( _devicetype.contains( name ) ) 146 if ( _devicetype.contains( name ) )
147 { 147 {
148 return _devicetype[name]; 148 return _devicetype[name];
149 } 149 }
150 else 150 else
151 { 151 {
152 return 0; 152 return 0;
153 } 153 }
154}; 154};
155 155
156 156
157int WellenreiterConfigWindow::hoppingInterval() const 157int WellenreiterConfigWindow::hoppingInterval() const
158{ 158{
159 return hopInterval->cleanText().toInt(); 159 return hopInterval->cleanText().toInt();
160} 160}
161 161
162 162
163bool WellenreiterConfigWindow::usePrismHeader() const 163bool WellenreiterConfigWindow::usePrismHeader() const
164{ 164{
165 return prismHeader->isChecked(); 165 return prismHeader->isChecked();
166} 166}
167 167
168 168
169bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 169bool WellenreiterConfigWindow::isChannelChecked( int channel ) const
170{ 170{
171 switch ( channel ) 171 switch ( channel )
172 { 172 {
173 case 1: return channel1->isOn(); 173 case 1: return channel1->isOn();
174 case 2: return channel2->isOn(); 174 case 2: return channel2->isOn();
175 case 3: return channel3->isOn(); 175 case 3: return channel3->isOn();
176 case 4: return channel4->isOn(); 176 case 4: return channel4->isOn();
177 case 5: return channel5->isOn(); 177 case 5: return channel5->isOn();
178 case 6: return channel6->isOn(); 178 case 6: return channel6->isOn();
179 case 7: return channel7->isOn(); 179 case 7: return channel7->isOn();
180 case 8: return channel8->isOn(); 180 case 8: return channel8->isOn();
181 case 9: return channel9->isOn(); 181 case 9: return channel9->isOn();
182 case 10: return channel10->isOn(); 182 case 10: return channel10->isOn();
183 case 11: return channel11->isOn(); 183 case 11: return channel11->isOn();
184 case 12: return channel12->isOn(); 184 case 12: return channel12->isOn();
185 case 13: return channel13->isOn(); 185 case 13: return channel13->isOn();
186 case 14: return channel14->isOn(); 186 case 14: return channel14->isOn();
187 } 187 }
188} 188}
189 189
190 190
191void WellenreiterConfigWindow::changedDeviceType(int t) 191void WellenreiterConfigWindow::changedDeviceType(int t)
192{ 192{
193 if ( t != DEVTYPE_FILE ) return; 193 if ( t != DEVTYPE_FILE ) return;
194 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); 194 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
195 if ( !name.isEmpty() && QFile::exists( name ) ) 195 if ( !name.isEmpty() && QFile::exists( name ) )
196 { 196 {
197 interfaceName->insertItem( name ); 197 interfaceName->insertItem( name );
198 interfaceName->setCurrentItem( interfaceName->count()-1 ); 198 interfaceName->setCurrentItem( interfaceName->count()-1 );
199 } 199 }
200 else 200 else
201 { 201 {
202 deviceType->setCurrentItem( _guess ); 202 deviceType->setCurrentItem( _guess );
203 } 203 }
204 204
205} 205}
206 206
207 207
208void WellenreiterConfigWindow::synchronizeActionsAndScripts() 208void WellenreiterConfigWindow::synchronizeActionsAndScripts()
209{ 209{
210 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); 210 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide();
211 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); 211 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide();
212 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); 212 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide();
213 213
214 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); 214 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 );
215 //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); 215 //newClientScript->setEnabled( newClientAction->currentItem() == 4 );
216 //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); 216 //newStationScript->setEnabled( newStationAction->currentItem() == 4 );
217} 217}
218 218
219 219
220void WellenreiterConfigWindow::changedNetworkAction(int t) 220void WellenreiterConfigWindow::changedNetworkAction(int t)
221{ 221{
222 synchronizeActionsAndScripts(); 222 synchronizeActionsAndScripts();
223} 223}
224 224
225 225
226void WellenreiterConfigWindow::changedClientAction(int t) 226void WellenreiterConfigWindow::changedClientAction(int t)
227{ 227{
228 synchronizeActionsAndScripts(); 228 synchronizeActionsAndScripts();
229} 229}
230 230
231 231
232void WellenreiterConfigWindow::changedStationAction(int t) 232void WellenreiterConfigWindow::changedStationAction(int t)
233{ 233{
234 synchronizeActionsAndScripts(); 234 synchronizeActionsAndScripts();
235} 235}
236 236
237 237
238void WellenreiterConfigWindow::getCaptureFileNameClicked() 238void WellenreiterConfigWindow::getCaptureFileNameClicked()
239{ 239{
240 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 240 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
241 odebug << "name = " << name << "" << oendl; 241 odebug << "name = " << name << "" << oendl;
242 if ( !name.isEmpty() ) 242 if ( !name.isEmpty() )
243 { 243 {
244 captureFileName->setText( name ); 244 captureFileName->setText( name );
245 } 245 }
246} 246}
247 247
248 248
249void WellenreiterConfigWindow::channelAllClicked(int state) 249void WellenreiterConfigWindow::channelAllClicked(int state)
250{ 250{
251 bool b = state; 251 bool b = state;
252 channel1->setChecked( b ); 252 channel1->setChecked( b );
253 channel2->setChecked( b ); 253 channel2->setChecked( b );
254 channel3->setChecked( b ); 254 channel3->setChecked( b );
255 channel4->setChecked( b ); 255 channel4->setChecked( b );
256 channel5->setChecked( b ); 256 channel5->setChecked( b );
257 channel6->setChecked( b ); 257 channel6->setChecked( b );
258 channel7->setChecked( b ); 258 channel7->setChecked( b );
259 channel8->setChecked( b ); 259 channel8->setChecked( b );
260 channel9->setChecked( b ); 260 channel9->setChecked( b );
261 channel10->setChecked( b ); 261 channel10->setChecked( b );
262 channel11->setChecked( b ); 262 channel11->setChecked( b );
263 channel12->setChecked( b ); 263 channel12->setChecked( b );
264 channel13->setChecked( b ); 264 channel13->setChecked( b );
265 channel14->setChecked( b ); 265 channel14->setChecked( b );
266} 266}
267 267
268 268
269bool WellenreiterConfigWindow::useGPS() const 269bool WellenreiterConfigWindow::useGPS() const
270{ 270{
271 return enableGPS->isChecked(); 271 return enableGPS->isChecked();
272} 272}
273 273
274 274
275const QString WellenreiterConfigWindow::gpsHost() const 275const QString WellenreiterConfigWindow::gpsHost() const
276{ 276{
277 return useGPS() ? gpsdHost->currentText() : QString::null; 277 return useGPS() ? gpsdHost->currentText() : QString::null;
278} 278}
279 279
280 280
281int WellenreiterConfigWindow::gpsPort() const 281int WellenreiterConfigWindow::gpsPort() const
282{ 282{
283 bool ok; 283 bool ok;
284 return useGPS() ? gpsdPort->value() : -1; 284 return useGPS() ? gpsdPort->value() : -1;
285} 285}
286 286
287 287
288void WellenreiterConfigWindow::performAction( const QString& type, 288void WellenreiterConfigWindow::performAction( const QString& type,
289 const QString& essid, 289 const QString& essid,
290 const QString& mac, 290 const QString& mac,
291 bool wep, 291 bool wep,
292 int channel, 292 int channel,
293 int signal 293 int signal
294 /* , const GpsLocation& loc */ ) 294 /* , const GpsLocation& loc */ )
295{ 295{
296 int action; 296 int action;
297 QString script; 297 QString script;
298 298
299 if ( type == "network" ) 299 if ( type == "network" )
300 { 300 {
301 action = newNetworkAction->currentItem(); 301 action = newNetworkAction->currentItem();
302 script = newNetworkScript->text(); 302 script = newNetworkScript->text();
303 } 303 }
304 else if ( type == "managed" || type == "adhoc" ) 304 else if ( type == "managed" || type == "adhoc" )
305 { 305 {
306 action = newClientAction->currentItem(); 306 action = newClientAction->currentItem();
307 script = newClientScript->text(); 307 script = newClientScript->text();
308 } 308 }
309 else if ( type == "station" ) 309 else if ( type == "station" )
310 { 310 {
311 action = newStationAction->currentItem(); 311 action = newStationAction->currentItem();
312 script = newStationScript->text(); 312 script = newStationScript->text();
313 } 313 }
314 else 314 else
315 { 315 {
316 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl; 316 owarn << "WellenreiterConfigWindow::performAction(): unknown type '" << type << "'" << oendl;
317 return; 317 return;
318 } 318 }
319 319
320 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl; 320 odebug << "for event '" << (const char*) type << "' I'm going to perform action " << action << " (script='" << script << "')" << oendl;
321 321
322 switch( action ) 322 switch( action )
323 { 323 {
324 case 0: /* Ignore */ return; 324 case 0: /* Ignore */ return;
325 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return; 325 case 1: /* Play Alarm */ ODevice::inst()->playAlarmSound(); return;
326 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return; 326 case 2: /* Play Click */ ODevice::inst()->playTouchSound(); return;
327 case 3: /* Blink LED */ break; //FIXME: Implement this 327 case 3: /* Blink LED */ break; //FIXME: Implement this
328 case 4: /* Run Script */ 328 case 4: /* Run Script */
329 { 329 {
330 /** 330 /**
331 * 331 *
332 * Script Substitution Information: 332 * Script Substitution Information:
333 * 333 *
334 * $SSID = SSID 334 * $SSID = SSID
335 * $MAC = MAC 335 * $MAC = MAC
336 * $WEP = Wep 336 * $WEP = Wep
337 * $CHAN = Channel 337 * $CHAN = Channel
338 * 338 *
339 **/ 339 **/
340 script = script.replace( QRegExp( "$SSID" ), essid ); 340 script = script.replace( QRegExp( "$SSID" ), essid );
341 script = script.replace( QRegExp( "$MAC" ), mac ); 341 script = script.replace( QRegExp( "$MAC" ), mac );
342 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); 342 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) );
343 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); 343 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) );
344 344
345 odebug << "going to call script '" << script << "'" << oendl; 345 odebug << "going to call script '" << script << "'" << oendl;
346 ::system( script ); 346 ::system( script );
347 odebug << "script returned." << oendl; 347 odebug << "script returned." << oendl;
348 return; 348 return;
349 } 349 }
350 default: assert( false ); 350 default: assert( false );
351 } 351 }
352} 352}
353 353
354 354
355void WellenreiterConfigWindow::load() 355void WellenreiterConfigWindow::load()
356{ 356{
357#ifdef Q_WS_X11 357#ifdef Q_WS_X11
358 #warning Persistent Configuration not yet implemented for standalone X11 build 358 #warning Persistent Configuration not yet implemented for standalone X11 build
359 performAutodetection(); 359 performAutodetection();
360#else 360#else
361 odebug << "loading configuration settings..." << oendl; 361 odebug << "loading configuration settings..." << oendl;
362 362
363 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 363 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
364 364
365 OConfig* c = oApp->config(); 365 OConfig* c = oApp->config();
366 366
367 c->setGroup( "Interface" ); 367 c->setGroup( "Interface" );
368 368
369 QString interface = c->readEntry( "name", "<none>" ); 369 QString interface = c->readEntry( "name", "<none>" );
370 if ( interface != "<none>" ) 370 if ( interface != "<none>" )
371 { 371 {
372#if QT_VERSION < 300 372#if QT_VERSION < 300
373 interfaceName->insertItem( interface, 0 ); 373 interfaceName->insertItem( interface, 0 );
374 interfaceName->setCurrentItem( 0 ); 374 interfaceName->setCurrentItem( 0 );
375#else 375#else
376 interfaceName->setCurrentText( interface ); 376 interfaceName->setCurrentText( interface );
377#endif 377#endif
378 378
379 QString device = c->readEntry( "type", "<select>" ); 379 QString device = c->readEntry( "type", "<select>" );
380#if QT_VERSION < 300 380#if QT_VERSION < 300
381 for ( int i = 0; i < deviceType->count(); ++i ) 381 for ( int i = 0; i < deviceType->count(); ++i )
382 { 382 {
383 if ( deviceType->text( i ) == device ) 383 if ( deviceType->text( i ) == device )
384 { 384 {
385 deviceType->setCurrentItem( i ); 385 deviceType->setCurrentItem( i );
386 break; 386 break;
387 } 387 }
388 } 388 }
389#else 389#else
390 deviceType->setCurrentText( device ); 390 deviceType->setCurrentText( device );
391#endif 391#endif
392 } 392 }
393 else 393 else
394 { 394 {
395 performAutodetection(); 395 performAutodetection();
396 } 396 }
397 397
398 prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); 398 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
399 hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); 399 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
400 hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); 400 hopInterval->setValue( c->readNumEntry( "interval", 250 ) );
401 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); 401 adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) );
402 402
403 c->setGroup( "Capture" ); 403 c->setGroup( "Capture" );
404 writeCaptureFile->setChecked( c->readBoolEntry( "writeCaptureFile", true ) );
405 captureFileName->setEnabled( writeCaptureFile->isChecked() );
406 getCaptureFileName->setEnabled( writeCaptureFile->isChecked() );
404 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); 407 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
408 hexViewBufferUnlimited->setChecked( c->readBoolEntry( "hexViewBufferUnlimited", true ) );
409 hexViewBufferLimited->setChecked( !c->readBoolEntry( "hexViewBufferUnlimited", true ) );
410 hexViewBufferSize->setValue( c->readNumEntry( "hexViewBufferSize", 2000 ) );
405 411
406 c->setGroup( "UI" ); 412 c->setGroup( "UI" );
407 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); 413 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
408 openTree->setChecked( c->readBoolEntry( "openTree", true ) ); 414 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
409 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); 415 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
410 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm 416 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm
411 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); 417 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) );
412 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click 418 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click
413 newClientScript->setText( c->readEntry( "newClientScript", "" ) ); 419 newClientScript->setText( c->readEntry( "newClientScript", "" ) );
414 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click 420 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click
415 newStationScript->setText( c->readEntry( "newStationScript", "" ) ); 421 newStationScript->setText( c->readEntry( "newStationScript", "" ) );
416 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand 422 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand
417 423
418 c->setGroup( "GPS" ); 424 c->setGroup( "GPS" );
419 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 425 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
420#if QT_VERSION < 300 426#if QT_VERSION < 300
421 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 427 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
422 gpsdHost->setCurrentItem( 0 ); 428 gpsdHost->setCurrentItem( 0 );
423#else 429#else
424 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); 430 gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) );
425#endif 431#endif
426 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); 432 gpsdPort->setValue( c->readNumEntry( "port", 2947 ) );
427 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 433 startGPS->setChecked( c->readBoolEntry( "start", false ) );
428 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 434 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
429 435
430#endif 436#endif
431} 437}
432 438
433 439
434void WellenreiterConfigWindow::save() 440void WellenreiterConfigWindow::save()
435{ 441{
436#ifdef Q_WS_X11 442#ifdef Q_WS_X11
437 #warning Persistent Configuration not yet implemented for standalone X11 build 443 #warning Persistent Configuration not yet implemented for standalone X11 build
438#else 444#else
439 odebug << "saving configuration settings..." << oendl; 445 odebug << "saving configuration settings..." << oendl;
440 446
441 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 447 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
442 448
443 OConfig* c = oApp->config(); 449 OConfig* c = oApp->config();
444 450
445 c->setGroup( "Interface" ); 451 c->setGroup( "Interface" );
446 c->writeEntry( "name", interfaceName->currentText() ); 452 c->writeEntry( "name", interfaceName->currentText() );
447 c->writeEntry( "type", deviceType->currentText() ); 453 c->writeEntry( "type", deviceType->currentText() );
448 c->writeEntry( "prism", prismHeader->isChecked() ); 454 c->writeEntry( "prism", prismHeader->isChecked() );
449 c->writeEntry( "hop", hopChannels->isChecked() ); 455 c->writeEntry( "hop", hopChannels->isChecked() );
450 c->writeEntry( "interval", hopInterval->value() ); 456 c->writeEntry( "interval", hopInterval->value() );
451 c->writeEntry( "adaptive", adaptiveHopping->isChecked() ); 457 c->writeEntry( "adaptive", adaptiveHopping->isChecked() );
452 458
453 c->setGroup( "Capture" ); 459 c->setGroup( "Capture" );
460 c->writeEntry( "writeCaptureFile", writeCaptureFile->isChecked() );
454 c->writeEntry( "filename", captureFileName->text() ); 461 c->writeEntry( "filename", captureFileName->text() );
462 c->writeEntry( "hexViewBufferUnlimited", hexViewBufferUnlimited->isChecked() );
463 c->writeEntry( "hexViewBufferSize", hexViewBufferSize->value() );
455 464
456 c->setGroup( "UI" ); 465 c->setGroup( "UI" );
457 c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); 466 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
458 c->writeEntry( "openTree", openTree->isChecked() ); 467 c->writeEntry( "openTree", openTree->isChecked() );
459 c->writeEntry( "disablePM", disablePM->isChecked() ); 468 c->writeEntry( "disablePM", disablePM->isChecked() );
460 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() ); 469 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() );
461 c->writeEntry( "newNetworkScript", newNetworkScript->text() ); 470 c->writeEntry( "newNetworkScript", newNetworkScript->text() );
462 c->writeEntry( "newClientAction", newClientAction->currentItem() ); 471 c->writeEntry( "newClientAction", newClientAction->currentItem() );
463 c->writeEntry( "newClientScript", newClientScript->text() ); 472 c->writeEntry( "newClientScript", newClientScript->text() );
464 c->writeEntry( "newStationAction", newStationAction->currentItem() ); 473 c->writeEntry( "newStationAction", newStationAction->currentItem() );
465 c->writeEntry( "newStationScript", newStationScript->text() ); 474 c->writeEntry( "newStationScript", newStationScript->text() );
466 475
467 c->setGroup( "GPS" ); 476 c->setGroup( "GPS" );
468 c->writeEntry( "use", enableGPS->isChecked() ); 477 c->writeEntry( "use", enableGPS->isChecked() );
469 c->writeEntry( "host", gpsdHost->currentText() ); 478 c->writeEntry( "host", gpsdHost->currentText() );
470 c->writeEntry( "port", gpsdPort->value() ); 479 c->writeEntry( "port", gpsdPort->value() );
471 c->writeEntry( "start", startGPS->isChecked() ); 480 c->writeEntry( "start", startGPS->isChecked() );
472 c->writeEntry( "command", commandGPS->text() ); 481 c->writeEntry( "command", commandGPS->text() );
473 482
474 c->write(); 483 c->write();
475 484
476#endif 485#endif
477} 486}
478 487
479 488
480int WellenreiterConfigWindow::hexViewBuffer() const 489int WellenreiterConfigWindow::hexViewBuffer() const
481{ 490{
482 return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value(); 491 return hexViewBufferUnlimited->isChecked() ? -1 : hexViewBufferSize->value();
483} 492}