summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-10-04 00:30:57 (UTC)
committer mickeyl <mickeyl>2003-10-04 00:30:57 (UTC)
commite2716e3862915582d0ce48aaacc967f5b0cf6550 (patch) (unidiff)
treea27e94a9d813f843dcb26c22ee31f7ce21142109
parent120b0fe68c1352ba03ad6e73d26bcbe8452ef6ed (diff)
downloadopie-e2716e3862915582d0ce48aaacc967f5b0cf6550.zip
opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.gz
opie-e2716e3862915582d0ce48aaacc967f5b0cf6550.tar.bz2
perform autodetection only if no configuration exists or on demand
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui470
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp98
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h6
3 files changed, 344 insertions, 230 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index d7ab3bb..4fc8ea1 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -11,8 +11,8 @@
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>303</width> 14 <width>286</width>
15 <height>287</height> 15 <height>345</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
@@ -56,57 +56,306 @@
56 <name>title</name> 56 <name>title</name>
57 <string>Interface</string> 57 <string>Interface</string>
58 </attribute> 58 </attribute>
59 <grid> 59 <vbox>
60 <property stdset="1"> 60 <property stdset="1">
61 <name>margin</name> 61 <name>margin</name>
62 <number>5</number> 62 <number>11</number>
63 </property> 63 </property>
64 <property stdset="1"> 64 <property stdset="1">
65 <name>spacing</name> 65 <name>spacing</name>
66 <number>3</number> 66 <number>6</number>
67 </property> 67 </property>
68 <widget row="0" column="0" > 68 <widget>
69 <class>QLabel</class> 69 <class>QLayoutWidget</class>
70 <property stdset="1">
71 <name>name</name>
72 <cstring>Layout7</cstring>
73 </property>
74 <grid>
75 <property stdset="1">
76 <name>margin</name>
77 <number>0</number>
78 </property>
79 <property stdset="1">
80 <name>spacing</name>
81 <number>6</number>
82 </property>
83 <widget row="1" column="1" >
84 <class>QComboBox</class>
85 <item>
86 <property>
87 <name>text</name>
88 <string>&lt;select&gt;</string>
89 </property>
90 </item>
91 <item>
92 <property>
93 <name>text</name>
94 <string>cisco</string>
95 </property>
96 </item>
97 <item>
98 <property>
99 <name>text</name>
100 <string>wlan-ng</string>
101 </property>
102 </item>
103 <item>
104 <property>
105 <name>text</name>
106 <string>hostap</string>
107 </property>
108 </item>
109 <item>
110 <property>
111 <name>text</name>
112 <string>orinoco</string>
113 </property>
114 </item>
115 <item>
116 <property>
117 <name>text</name>
118 <string>&lt;manual&gt;</string>
119 </property>
120 </item>
121 <item>
122 <property>
123 <name>text</name>
124 <string>&lt;file&gt;</string>
125 </property>
126 </item>
127 <property stdset="1">
128 <name>name</name>
129 <cstring>deviceType</cstring>
130 </property>
131 <property stdset="1">
132 <name>enabled</name>
133 <bool>true</bool>
134 </property>
135 <property stdset="1">
136 <name>sizePolicy</name>
137 <sizepolicy>
138 <hsizetype>7</hsizetype>
139 <vsizetype>0</vsizetype>
140 </sizepolicy>
141 </property>
142 <property>
143 <name>whatsThis</name>
144 <string>Choose the type of driver used for sniffing.</string>
145 </property>
146 </widget>
147 <widget row="1" column="0" >
148 <class>QLabel</class>
149 <property stdset="1">
150 <name>name</name>
151 <cstring>TextLabel2_3</cstring>
152 </property>
153 <property stdset="1">
154 <name>enabled</name>
155 <bool>true</bool>
156 </property>
157 <property stdset="1">
158 <name>text</name>
159 <string>Driver:</string>
160 </property>
161 </widget>
162 <widget row="0" column="1" >
163 <class>QComboBox</class>
164 <property stdset="1">
165 <name>name</name>
166 <cstring>interfaceName</cstring>
167 </property>
168 <property stdset="1">
169 <name>enabled</name>
170 <bool>true</bool>
171 </property>
172 <property stdset="1">
173 <name>sizePolicy</name>
174 <sizepolicy>
175 <hsizetype>7</hsizetype>
176 <vsizetype>0</vsizetype>
177 </sizepolicy>
178 </property>
179 <property stdset="1">
180 <name>editable</name>
181 <bool>false</bool>
182 </property>
183 <property>
184 <name>whatsThis</name>
185 <string>Choose the interface used for sniffing.</string>
186 </property>
187 </widget>
188 <widget row="0" column="0" >
189 <class>QLabel</class>
190 <property stdset="1">
191 <name>name</name>
192 <cstring>TextLabel1_2</cstring>
193 </property>
194 <property stdset="1">
195 <name>enabled</name>
196 <bool>true</bool>
197 </property>
198 <property stdset="1">
199 <name>text</name>
200 <string>Name:</string>
201 </property>
202 </widget>
203 </grid>
204 </widget>
205 <widget>
206 <class>QLayoutWidget</class>
70 <property stdset="1"> 207 <property stdset="1">
71 <name>name</name> 208 <name>name</name>
72 <cstring>TextLabel1_2</cstring> 209 <cstring>Layout5</cstring>
73 </property> 210 </property>
211 <hbox>
212 <property stdset="1">
213 <name>margin</name>
214 <number>0</number>
215 </property>
216 <property stdset="1">
217 <name>spacing</name>
218 <number>6</number>
219 </property>
220 <widget>
221 <class>QPushButton</class>
222 <property stdset="1">
223 <name>name</name>
224 <cstring>autodetect</cstring>
225 </property>
226 <property stdset="1">
227 <name>text</name>
228 <string>Perform Autodetection</string>
229 </property>
230 </widget>
231 </hbox>
232 </widget>
233 <widget>
234 <class>QCheckBox</class>
74 <property stdset="1"> 235 <property stdset="1">
75 <name>enabled</name> 236 <name>name</name>
76 <bool>true</bool> 237 <cstring>prismHeader</cstring>
77 </property> 238 </property>
78 <property stdset="1"> 239 <property stdset="1">
79 <name>text</name> 240 <name>text</name>
80 <string>Name:</string> 241 <string>Use additional PRISM header</string>
81 </property> 242 </property>
82 </widget> 243 </widget>
83 <widget row="1" column="0" > 244 <spacer>
84 <class>QLabel</class> 245 <property>
85 <property stdset="1">
86 <name>name</name> 246 <name>name</name>
87 <cstring>TextLabel2_3</cstring> 247 <cstring>Spacer4</cstring>
88 </property> 248 </property>
89 <property stdset="1"> 249 <property stdset="1">
90 <name>enabled</name> 250 <name>orientation</name>
91 <bool>true</bool> 251 <enum>Vertical</enum>
92 </property> 252 </property>
93 <property stdset="1"> 253 <property stdset="1">
94 <name>text</name> 254 <name>sizeType</name>
95 <string>Driver:</string> 255 <enum>Expanding</enum>
256 </property>
257 <property>
258 <name>sizeHint</name>
259 <size>
260 <width>20</width>
261 <height>20</height>
262 </size>
263 </property>
264 </spacer>
265 <widget>
266 <class>QLayoutWidget</class>
267 <property stdset="1">
268 <name>name</name>
269 <cstring>Layout6</cstring>
96 </property> 270 </property>
271 <hbox>
272 <property stdset="1">
273 <name>margin</name>
274 <number>0</number>
275 </property>
276 <property stdset="1">
277 <name>spacing</name>
278 <number>6</number>
279 </property>
280 <widget>
281 <class>QCheckBox</class>
282 <property stdset="1">
283 <name>name</name>
284 <cstring>hopChannels</cstring>
285 </property>
286 <property stdset="1">
287 <name>text</name>
288 <string>Hop Channels</string>
289 </property>
290 <property stdset="1">
291 <name>checked</name>
292 <bool>true</bool>
293 </property>
294 </widget>
295 <widget>
296 <class>QLabel</class>
297 <property stdset="1">
298 <name>name</name>
299 <cstring>TextLabel1</cstring>
300 </property>
301 <property stdset="1">
302 <name>text</name>
303 <string>every</string>
304 </property>
305 </widget>
306 <widget>
307 <class>QSpinBox</class>
308 <property stdset="1">
309 <name>name</name>
310 <cstring>hopInterval</cstring>
311 </property>
312 <property stdset="1">
313 <name>enabled</name>
314 <bool>true</bool>
315 </property>
316 <property stdset="1">
317 <name>suffix</name>
318 <string> ms</string>
319 </property>
320 <property stdset="1">
321 <name>maxValue</name>
322 <number>2000</number>
323 </property>
324 <property stdset="1">
325 <name>minValue</name>
326 <number>100</number>
327 </property>
328 <property stdset="1">
329 <name>lineStep</name>
330 <number>100</number>
331 </property>
332 <property stdset="1">
333 <name>value</name>
334 <number>1000</number>
335 </property>
336 <property>
337 <name>whatsThis</name>
338 <string>Choose the channel hop interval.</string>
339 </property>
340 </widget>
341 </hbox>
97 </widget> 342 </widget>
98 <widget row="2" column="0" rowspan="1" colspan="4" > 343 <widget>
99 <class>QCheckBox</class> 344 <class>QCheckBox</class>
100 <property stdset="1"> 345 <property stdset="1">
101 <name>name</name> 346 <name>name</name>
102 <cstring>prismHeader</cstring> 347 <cstring>adaptiveHopping</cstring>
348 </property>
349 <property stdset="1">
350 <name>enabled</name>
351 <bool>false</bool>
103 </property> 352 </property>
104 <property stdset="1"> 353 <property stdset="1">
105 <name>text</name> 354 <name>text</name>
106 <string>Use additional PRISM header</string> 355 <string>Use Adaptive(TM) Hop Scheme</string>
107 </property> 356 </property>
108 </widget> 357 </widget>
109 <widget row="6" column="0" rowspan="1" colspan="4" > 358 <widget>
110 <class>QGroupBox</class> 359 <class>QGroupBox</class>
111 <property stdset="1"> 360 <property stdset="1">
112 <name>name</name> 361 <name>name</name>
@@ -302,180 +551,7 @@
302 </widget> 551 </widget>
303 </grid> 552 </grid>
304 </widget> 553 </widget>
305 <widget row="0" column="1" rowspan="1" colspan="3" > 554 </vbox>
306 <class>QComboBox</class>
307 <property stdset="1">
308 <name>name</name>
309 <cstring>interfaceName</cstring>
310 </property>
311 <property stdset="1">
312 <name>enabled</name>
313 <bool>true</bool>
314 </property>
315 <property stdset="1">
316 <name>editable</name>
317 <bool>false</bool>
318 </property>
319 <property>
320 <name>whatsThis</name>
321 <string>Choose the interface used for sniffing.</string>
322 </property>
323 </widget>
324 <widget row="1" column="1" rowspan="1" colspan="3" >
325 <class>QComboBox</class>
326 <item>
327 <property>
328 <name>text</name>
329 <string>&lt;select&gt;</string>
330 </property>
331 </item>
332 <item>
333 <property>
334 <name>text</name>
335 <string>cisco</string>
336 </property>
337 </item>
338 <item>
339 <property>
340 <name>text</name>
341 <string>wlan-ng</string>
342 </property>
343 </item>
344 <item>
345 <property>
346 <name>text</name>
347 <string>hostap</string>
348 </property>
349 </item>
350 <item>
351 <property>
352 <name>text</name>
353 <string>orinoco</string>
354 </property>
355 </item>
356 <item>
357 <property>
358 <name>text</name>
359 <string>&lt;manual&gt;</string>
360 </property>
361 </item>
362 <item>
363 <property>
364 <name>text</name>
365 <string>&lt;file&gt;</string>
366 </property>
367 </item>
368 <property stdset="1">
369 <name>name</name>
370 <cstring>deviceType</cstring>
371 </property>
372 <property stdset="1">
373 <name>enabled</name>
374 <bool>true</bool>
375 </property>
376 <property>
377 <name>whatsThis</name>
378 <string>Choose the type of driver used for sniffing.</string>
379 </property>
380 </widget>
381 <spacer row="3" column="0" >
382 <property>
383 <name>name</name>
384 <cstring>Spacer4</cstring>
385 </property>
386 <property stdset="1">
387 <name>orientation</name>
388 <enum>Vertical</enum>
389 </property>
390 <property stdset="1">
391 <name>sizeType</name>
392 <enum>Expanding</enum>
393 </property>
394 <property>
395 <name>sizeHint</name>
396 <size>
397 <width>20</width>
398 <height>20</height>
399 </size>
400 </property>
401 </spacer>
402 <widget row="4" column="2" >
403 <class>QLabel</class>
404 <property stdset="1">
405 <name>name</name>
406 <cstring>TextLabel1</cstring>
407 </property>
408 <property stdset="1">
409 <name>text</name>
410 <string>every</string>
411 </property>
412 </widget>
413 <widget row="4" column="0" rowspan="1" colspan="2" >
414 <class>QCheckBox</class>
415 <property stdset="1">
416 <name>name</name>
417 <cstring>hopChannels</cstring>
418 </property>
419 <property stdset="1">
420 <name>text</name>
421 <string>Hop Channels</string>
422 </property>
423 <property stdset="1">
424 <name>checked</name>
425 <bool>true</bool>
426 </property>
427 </widget>
428 <widget row="4" column="3" >
429 <class>QSpinBox</class>
430 <property stdset="1">
431 <name>name</name>
432 <cstring>hopInterval</cstring>
433 </property>
434 <property stdset="1">
435 <name>enabled</name>
436 <bool>true</bool>
437 </property>
438 <property stdset="1">
439 <name>suffix</name>
440 <string> ms</string>
441 </property>
442 <property stdset="1">
443 <name>maxValue</name>
444 <number>2000</number>
445 </property>
446 <property stdset="1">
447 <name>minValue</name>
448 <number>100</number>
449 </property>
450 <property stdset="1">
451 <name>lineStep</name>
452 <number>100</number>
453 </property>
454 <property stdset="1">
455 <name>value</name>
456 <number>1000</number>
457 </property>
458 <property>
459 <name>whatsThis</name>
460 <string>Choose the channel hop interval.</string>
461 </property>
462 </widget>
463 <widget row="5" column="0" rowspan="1" colspan="4" >
464 <class>QCheckBox</class>
465 <property stdset="1">
466 <name>name</name>
467 <cstring>adaptiveHopping</cstring>
468 </property>
469 <property stdset="1">
470 <name>enabled</name>
471 <bool>false</bool>
472 </property>
473 <property stdset="1">
474 <name>text</name>
475 <string>Use Adaptive(TM) Hop Scheme</string>
476 </property>
477 </widget>
478 </grid>
479 </widget> 555 </widget>
480 <widget> 556 <widget>
481 <class>QWidget</class> 557 <class>QWidget</class>
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 84d4c63..3ec190b 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -57,31 +57,7 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
57 ++it; 57 ++it;
58 } 58 }
59 59
60 if ( !load() ) // no configuration present 60 load();
61 {
62 // try to guess device type
63 QFile m( "/proc/modules" );
64 if ( m.open( IO_ReadOnly ) )
65 {
66 int devicetype(0);
67 QString line;
68 QTextStream modules( &m );
69 while( !modules.atEnd() && !devicetype )
70 {
71 modules >> line;
72 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
73 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
74 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
75 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
76 }
77 if ( devicetype )
78 {
79 deviceType->setCurrentItem( devicetype );
80 _guess = devicetype;
81 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
82 }
83 }
84 }
85 61
86 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 62 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
87 QPushButton* okButton = new QPushButton( "ok", this ); 63 QPushButton* okButton = new QPushButton( "ok", this );
@@ -97,6 +73,8 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
97 73
98 // make the checkbox 'channelAll' control all other channels 74 // make the checkbox 'channelAll' control all other channels
99 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 75 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
76
77 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
100}; 78};
101 79
102 80
@@ -106,6 +84,39 @@ WellenreiterConfigWindow::~WellenreiterConfigWindow()
106} 84}
107 85
108 86
87void WellenreiterConfigWindow::performAutodetection()
88{
89 //TODO: insert modal splash screen here
90 // and sleep a second, so that it looks
91 // like we're actually doing something fancy... ;-)
92
93 qDebug( "WellenreiterConfigWindow::performAutodetection()" );
94
95 // try to guess device type
96 QFile m( "/proc/modules" );
97 if ( m.open( IO_ReadOnly ) )
98 {
99 int devicetype(0);
100 QString line;
101 QTextStream modules( &m );
102 while( !modules.atEnd() && !devicetype )
103 {
104 modules >> line;
105 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
106 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
107 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
108 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
109 }
110 if ( devicetype )
111 {
112 deviceType->setCurrentItem( devicetype );
113 _guess = devicetype;
114 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
115 }
116 }
117}
118
119
109int WellenreiterConfigWindow::driverType() const 120int WellenreiterConfigWindow::driverType() const
110{ 121{
111 QString name = deviceType->currentText(); 122 QString name = deviceType->currentText();
@@ -221,11 +232,11 @@ int WellenreiterConfigWindow::gpsPort() const
221} 232}
222 233
223 234
224bool WellenreiterConfigWindow::load() 235void WellenreiterConfigWindow::load()
225{ 236{
226#ifdef Q_WS_X11 237#ifdef Q_WS_X11
227 #warning Persistent Configuration not yet implemented for standalone X11 build 238 #warning Persistent Configuration not yet implemented for standalone X11 build
228 return false; 239 performAutodetection();
229#else 240#else
230 qDebug( "loading configuration settings..." ); 241 qDebug( "loading configuration settings..." );
231 242
@@ -234,8 +245,36 @@ bool WellenreiterConfigWindow::load()
234 OConfig* c = oApp->config(); 245 OConfig* c = oApp->config();
235 246
236 c->setGroup( "Interface" ); 247 c->setGroup( "Interface" );
237 //interfaceName->setCurrentText( c->readEntry( "name" ) ); 248
238 //deviceType->setCurrentText( c->readEntry( "type", "<select>" ) ); 249 QString interface = c->readEntry( "name", "<none>" );
250 if ( interface != "<none>" )
251 {
252#if QT_VERSION < 300
253 interfaceName->insertItem( interface, 0 );
254 interfaceName->setCurrentItem( 0 );
255#else
256 interfaceName->setCurrentText( interface );
257#endif
258
259 QString device = c->readEntry( "type", "<select>" );
260#if QT_VERSION < 300
261 for ( int i = 0; i < deviceType->count(); ++i )
262 {
263 if ( deviceType->text( i ) == device )
264 {
265 deviceType->setCurrentItem( i );
266 break;
267 }
268 }
269#else
270 deviceType->setCurrentText( device );
271#endif
272 }
273 else
274 {
275 performAutodetection();
276 }
277
239 prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); 278 prismHeader->setChecked( c->readBoolEntry( "prism", false ) );
240 hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); 279 hopChannels->setChecked( c->readBoolEntry( "hop", true ) );
241 hopInterval->setValue( c->readNumEntry( "interval", 100 ) ); 280 hopInterval->setValue( c->readNumEntry( "interval", 100 ) );
@@ -261,7 +300,6 @@ bool WellenreiterConfigWindow::load()
261 startGPS->setChecked( c->readBoolEntry( "start", false ) ); 300 startGPS->setChecked( c->readBoolEntry( "start", false ) );
262 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); 301 commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) );
263 302
264 return false; // false = perform autodetection; true = use config settings
265#endif 303#endif
266} 304}
267 305
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index 2986320..80b4d2b 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -38,7 +38,7 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
38 public: 38 public:
39 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); 39 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
40 ~WellenreiterConfigWindow(); 40 ~WellenreiterConfigWindow();
41 41
42 int driverType() const; 42 int driverType() const;
43 const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ }; 43 const QString soundOnNetwork() const { return "";/*netSound->currentText();*/ };
44 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ }; 44 const QString soundOnBeacon() const { return "";/*beaconSound->currentText();*/ };
@@ -53,12 +53,12 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
53 int gpsPort() const; 53 int gpsPort() const;
54 54
55 void save(); 55 void save();
56 bool load(); 56 void load();
57 57
58 public slots: 58 public slots:
59 void changedDeviceType(int); 59 void changedDeviceType(int);
60 void getCaptureFileNameClicked(); 60 void getCaptureFileNameClicked();
61 61 void performAutodetection();
62 void channelAllClicked(int); 62 void channelAllClicked(int);
63 63
64 protected: 64 protected: