summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-03-31 14:30:17 (UTC)
committer mickeyl <mickeyl>2003-03-31 14:30:17 (UTC)
commit13e8e8cbaede72948d3901a1a903eba43854d770 (patch) (unidiff)
tree672679ac87efdfecd4755f712cfd11c2d2abad43
parente609b9726786efe7cd5be0cd6d8d9f4d91703da5 (diff)
downloadopie-13e8e8cbaede72948d3901a1a903eba43854d770.zip
opie-13e8e8cbaede72948d3901a1a903eba43854d770.tar.gz
opie-13e8e8cbaede72948d3901a1a903eba43854d770.tar.bz2
- initial attempt to autodetect driver
- add possibility to play sounds when receiving beacon and/or found a new network
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configbase.ui155
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp32
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h8
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp24
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h3
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp16
6 files changed, 166 insertions, 72 deletions
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui
index fa727f9..dda7ba0 100644
--- a/noncore/net/wellenreiter/gui/configbase.ui
+++ b/noncore/net/wellenreiter/gui/configbase.ui
@@ -8,14 +8,14 @@
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>212</width> 14 <width>220</width>
15 <height>267</height> 15 <height>306</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>Form1</string> 20 <string>Form1</string>
21 </property> 21 </property>
@@ -25,13 +25,13 @@
25 <property> 25 <property>
26 <name>layoutSpacing</name> 26 <name>layoutSpacing</name>
27 </property> 27 </property>
28 <vbox> 28 <vbox>
29 <property stdset="1"> 29 <property stdset="1">
30 <name>margin</name> 30 <name>margin</name>
31 <number>4</number> 31 <number>3</number>
32 </property> 32 </property>
33 <property stdset="1"> 33 <property stdset="1">
34 <name>spacing</name> 34 <name>spacing</name>
35 <number>1</number> 35 <number>1</number>
36 </property> 36 </property>
37 <widget> 37 <widget>
@@ -322,94 +322,139 @@
322 <enum>Horizontal</enum> 322 <enum>Horizontal</enum>
323 </property> 323 </property>
324 </widget> 324 </widget>
325 </hbox> 325 </hbox>
326 </widget> 326 </widget>
327 <widget> 327 <widget>
328 <class>QCheckBox</class>
329 <property stdset="1">
330 <name>name</name>
331 <cstring>groupNetworks</cstring>
332 </property>
333 <property stdset="1">
334 <name>enabled</name>
335 <bool>false</bool>
336 </property>
337 <property stdset="1">
338 <name>text</name>
339 <string>Group Detected Networks</string>
340 </property>
341 </widget>
342 <widget>
343 <class>QCheckBox</class>
344 <property stdset="1">
345 <name>name</name>
346 <cstring>enableActivity</cstring>
347 </property>
348 <property stdset="1">
349 <name>enabled</name>
350 <bool>false</bool>
351 </property>
352 <property stdset="1">
353 <name>text</name>
354 <string>Enable Activity Display</string>
355 </property>
356 </widget>
357 <widget>
328 <class>QLayoutWidget</class> 358 <class>QLayoutWidget</class>
329 <property stdset="1"> 359 <property stdset="1">
330 <name>name</name> 360 <name>name</name>
331 <cstring>Layout5</cstring> 361 <cstring>Layout5</cstring>
332 </property> 362 </property>
333 <property> 363 <grid>
334 <name>layoutSpacing</name>
335 </property>
336 <vbox>
337 <property stdset="1"> 364 <property stdset="1">
338 <name>margin</name> 365 <name>margin</name>
339 <number>0</number> 366 <number>0</number>
340 </property> 367 </property>
341 <property stdset="1"> 368 <property stdset="1">
342 <name>spacing</name> 369 <name>spacing</name>
343 <number>-1</number> 370 <number>6</number>
344 </property> 371 </property>
345 <widget> 372 <widget row="0" column="1" >
346 <class>QCheckBox</class> 373 <class>QLabel</class>
347 <property stdset="1"> 374 <property stdset="1">
348 <name>name</name> 375 <name>name</name>
349 <cstring>groupNetworks</cstring> 376 <cstring>TextLabel1</cstring>
350 </property>
351 <property stdset="1">
352 <name>enabled</name>
353 <bool>false</bool>
354 </property> 377 </property>
355 <property stdset="1"> 378 <property stdset="1">
356 <name>text</name> 379 <name>text</name>
357 <string>Group Detected Networks</string> 380 <string>sound on new net</string>
358 </property> 381 </property>
359 </widget> 382 </widget>
360 <widget> 383 <widget row="1" column="0" >
361 <class>QCheckBox</class> 384 <class>QComboBox</class>
385 <item>
386 <property>
387 <name>text</name>
388 <string>Ignore</string>
389 </property>
390 </item>
391 <item>
392 <property>
393 <name>text</name>
394 <string>Touch</string>
395 </property>
396 </item>
397 <item>
398 <property>
399 <name>text</name>
400 <string>Key</string>
401 </property>
402 </item>
403 <item>
404 <property>
405 <name>text</name>
406 <string>Alarm</string>
407 </property>
408 </item>
362 <property stdset="1"> 409 <property stdset="1">
363 <name>name</name> 410 <name>name</name>
364 <cstring>enableActivity</cstring> 411 <cstring>beaconSound</cstring>
365 </property>
366 <property stdset="1">
367 <name>enabled</name>
368 <bool>false</bool>
369 </property>
370 <property stdset="1">
371 <name>text</name>
372 <string>Enable Activity Display</string>
373 </property> 412 </property>
374 </widget> 413 </widget>
375 <widget> 414 <widget row="0" column="0" >
376 <class>QCheckBox</class> 415 <class>QComboBox</class>
416 <item>
417 <property>
418 <name>text</name>
419 <string>Ignore</string>
420 </property>
421 </item>
422 <item>
423 <property>
424 <name>text</name>
425 <string>Touch</string>
426 </property>
427 </item>
428 <item>
429 <property>
430 <name>text</name>
431 <string>Key</string>
432 </property>
433 </item>
434 <item>
435 <property>
436 <name>text</name>
437 <string>Alarm</string>
438 </property>
439 </item>
377 <property stdset="1"> 440 <property stdset="1">
378 <name>name</name> 441 <name>name</name>
379 <cstring>beepOnFound</cstring> 442 <cstring>netSound</cstring>
380 </property> 443 </property>
444 </widget>
445 <widget row="1" column="1" >
446 <class>QLabel</class>
381 <property stdset="1"> 447 <property stdset="1">
382 <name>enabled</name> 448 <name>name</name>
383 <bool>false</bool> 449 <cstring>TextLabel1_3</cstring>
384 </property> 450 </property>
385 <property stdset="1"> 451 <property stdset="1">
386 <name>text</name> 452 <name>text</name>
387 <string>Beep on new network</string> 453 <string>sound on beacon</string>
388 </property> 454 </property>
389 </widget> 455 </widget>
390 </vbox> 456 </grid>
391 </widget> 457 </widget>
392 <spacer>
393 <property>
394 <name>name</name>
395 <cstring>Spacer2</cstring>
396 </property>
397 <property stdset="1">
398 <name>orientation</name>
399 <enum>Vertical</enum>
400 </property>
401 <property stdset="1">
402 <name>sizeType</name>
403 <enum>Expanding</enum>
404 </property>
405 <property>
406 <name>sizeHint</name>
407 <size>
408 <width>20</width>
409 <height>20</height>
410 </size>
411 </property>
412 </spacer>
413 </vbox> 458 </vbox>
414</widget> 459</widget>
415</UI> 460</UI>
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 6dd862f..e287b47 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -14,21 +14,25 @@
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18 18
19/* QT */ 19/* QT */
20#include <qmap.h>
21#include <qcombobox.h> 20#include <qcombobox.h>
21#include <qfile.h>
22#include <qlayout.h>
23#include <qmap.h>
22#include <qpushbutton.h> 24#include <qpushbutton.h>
23#include <qspinbox.h> 25#include <qspinbox.h>
24#include <qlayout.h> 26#include <qtextstream.h>
25 27
26/* OPIE */ 28/* OPIE */
27#include <opie2/onetwork.h> 29#include <opie2/onetwork.h>
28 30
31WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
32
29WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 33WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
30 :WellenreiterConfigBase( parent, name, true, f ) 34 :WellenreiterConfigBase( parent, name, true, f )
31{ 35{
32 _devicetype[ "cisco" ] = 1; 36 _devicetype[ "cisco" ] = 1;
33 _devicetype[ "wlan-ng" ] = 2; 37 _devicetype[ "wlan-ng" ] = 2;
34 _devicetype[ "hostap" ] = 3; 38 _devicetype[ "hostap" ] = 3;
@@ -42,18 +46,42 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
42 { 46 {
43 if ( it.current()->isWireless() ) 47 if ( it.current()->isWireless() )
44 interfaceName->insertItem( it.current()->name() ); 48 interfaceName->insertItem( it.current()->name() );
45 ++it; 49 ++it;
46 } 50 }
47 51
52 // try to guess device type
53 QFile m( "/proc/modules" );
54 if ( m.open( IO_ReadOnly ) )
55 {
56 int devicetype(0);
57 QString line;
58 QTextStream modules( &m );
59 while( !modules.atEnd() && !devicetype )
60 {
61 modules >> line;
62 if ( line.contains( "cisco" ) ) devicetype = 1;
63 else if ( line.contains( "wlan" ) ) devicetype = 2;
64 else if ( line.contains( "hostap" ) ) devicetype = 3;
65 else if ( line.contains( "orinoco" ) ) devicetype = 4;
66 }
67 if ( devicetype )
68 {
69 deviceType->setCurrentItem( devicetype );
70 qDebug( "Wellenreiter: guessed device type to be %d", devicetype );
71 }
72 }
73
48 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 74 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
49 QPushButton* okButton = new QPushButton( "ok", this ); 75 QPushButton* okButton = new QPushButton( "ok", this );
50 okButton->show(); 76 okButton->show();
51 Layout5_2->addWidget( okButton ); //FIXME: rename this in configbase.ui 77 Layout5_2->addWidget( okButton ); //FIXME: rename this in configbase.ui
52 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 78 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
53 #endif 79 #endif
80
81 WellenreiterConfigWindow::_instance = this;
54}; 82};
55 83
56int WellenreiterConfigWindow::daemonDeviceType() 84int WellenreiterConfigWindow::daemonDeviceType()
57{ 85{
58 QString name = deviceType->currentText(); 86 QString name = deviceType->currentText();
59 if ( _devicetype.contains( name ) ) 87 if ( _devicetype.contains( name ) )
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index c627901..5fd0327 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -15,22 +15,30 @@
15 15
16#ifndef WELLENREITERCONFIGWINDOW_H 16#ifndef WELLENREITERCONFIGWINDOW_H
17#define WELLENREITERCONFIGWINDOW_H 17#define WELLENREITERCONFIGWINDOW_H
18 18
19#include "configbase.h" 19#include "configbase.h"
20#include <qmap.h> 20#include <qmap.h>
21#include <qcombobox.h>
22#include <qstring.h>
23
24class WellenreiterConfigWindow;
21 25
22class WellenreiterConfigWindow : public WellenreiterConfigBase 26class WellenreiterConfigWindow : public WellenreiterConfigBase
23{ 27{
24 28
25 public: 29 public:
26 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 ); 30 WellenreiterConfigWindow( QWidget * parent = 0, const char * name = "WellenreiterConfigWindow", WFlags f = 0 );
27 int daemonDeviceType(); 31 int daemonDeviceType();
28 int daemonHopInterval(); 32 int daemonHopInterval();
33 const QString soundOnNetwork() const { return netSound->currentText(); };
34 const QString soundOnBeacon() const { return beaconSound->currentText(); };
35 static WellenreiterConfigWindow* instance() { return _instance; };
29 36
30 protected: 37 protected:
31 QMap<QString, int> _devicetype; 38 QMap<QString, int> _devicetype;
39 static WellenreiterConfigWindow* _instance;
32 40
33}; 41};
34 42
35#endif 43#endif
36 44
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index be1245e..a006a3c 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -11,18 +11,24 @@
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#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h"
17 18
18#include <assert.h> 19#include <assert.h>
19#include "manufacturers.h" 20#include "manufacturers.h"
20#include <qdatetime.h> 21#include <qdatetime.h>
21#include <qtextstream.h> 22#include <qtextstream.h>
22 23
24#ifdef QWS
25#include <opie/odevice.h>
26using namespace Opie;
27#endif
28
23MScanListView::MScanListView( QWidget* parent, const char* name ) 29MScanListView::MScanListView( QWidget* parent, const char* name )
24 :OListView( parent, name ), _manufacturerdb( 0 ) 30 :OListView( parent, name ), _manufacturerdb( 0 )
25{ 31{
26 32
27 setFrameShape( QListView::StyledPanel ); 33 setFrameShape( QListView::StyledPanel );
28 setFrameShadow( QListView::Sunken ); 34 setFrameShadow( QListView::Sunken );
@@ -139,13 +145,12 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
139 return; 145 return;
140 } 146 }
141 } 147 }
142 else 148 else
143 { 149 {
144 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 150 s.sprintf( "(i) new network: '%s'", (const char*) essid );
145
146 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); 151 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
147 } 152 }
148 153
149 154
150 // insert new station as child from network 155 // insert new station as child from network
151 156
@@ -189,12 +194,14 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS
189 bool wep, int channel, int signal ) 194 bool wep, int channel, int signal )
190 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 195 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
191 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 196 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
192 _channel( channel ), _signal( signal ), _beacons( 0 ) 197 _channel( channel ), _signal( signal ), _beacons( 0 )
193{ 198{
194 qDebug( "creating scanlist item" ); 199 qDebug( "creating scanlist item" );
200 if ( WellenreiterConfigWindow::instance() && type == "networks" )
201 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
195 decorateItem( type, essid, macaddr, wep, channel, signal ); 202 decorateItem( type, essid, macaddr, wep, channel, signal );
196} 203}
197 204
198MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 205MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
199 bool wep, int channel, int signal ) 206 bool wep, int channel, int signal )
200 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 207 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
@@ -268,21 +275,36 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
268 _macaddr = macaddr; 275 _macaddr = macaddr;
269 _channel = channel; 276 _channel = channel;
270 _beacons = 0; 277 _beacons = 0;
271 _signal = 0; 278 _signal = 0;
272} 279}
273 280
281
274void MScanListItem::setManufacturer( const QString& manufacturer ) 282void MScanListItem::setManufacturer( const QString& manufacturer )
275{ 283{
276 setText( col_manuf, manufacturer ); 284 setText( col_manuf, manufacturer );
277} 285}
278 286
287
288void MScanListItem::playSound( const QString& sound ) const
289{
290 #ifdef QWS
291 if ( sound == "Ignore" ) return;
292 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
293 else if ( sound == "Key" ) ODevice::inst()->keySound();
294 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
295 #endif
296}
297
298
279void MScanListItem::receivedBeacon() 299void MScanListItem::receivedBeacon()
280{ 300{
281 _beacons++; 301 _beacons++;
282 #ifdef DEBUG 302 #ifdef DEBUG
283 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 303 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
284 #endif 304 #endif
285 setText( col_sig, QString::number( _beacons ) ); 305 setText( col_sig, QString::number( _beacons ) );
286 setText( col_lastseen, QTime::currentTime().toString() ); 306 setText( col_lastseen, QTime::currentTime().toString() );
307 if ( WellenreiterConfigWindow::instance() )
308 playSound( WellenreiterConfigWindow::instance()->soundOnBeacon() );
287} 309}
288 310
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index da9369f..01db172 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -88,12 +88,15 @@ class MScanListItem: public OListViewItem
88 void setManufacturer( const QString& manufacturer ); 88 void setManufacturer( const QString& manufacturer );
89 89
90 virtual OListViewItem* childFactory(); 90 virtual OListViewItem* childFactory();
91 virtual void serializeTo( QDataStream& s ) const; 91 virtual void serializeTo( QDataStream& s ) const;
92 virtual void serializeFrom( QDataStream& s ); 92 virtual void serializeFrom( QDataStream& s );
93 93
94 protected:
95 void playSound( const QString& ) const;
96
94 private: 97 private:
95 QString _type; 98 QString _type;
96 QString _essid; 99 QString _essid;
97 QString _macaddr; 100 QString _macaddr;
98 bool _wep; 101 bool _wep;
99 int _channel; 102 int _channel;
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 41ffdcc..d1dd73a 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -107,15 +107,12 @@ void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
107{ 107{
108 configwindow = cw; 108 configwindow = cw;
109} 109}
110 110
111void Wellenreiter::receivePacket(OPacket* p) 111void Wellenreiter::receivePacket(OPacket* p)
112{ 112{
113 logwindow->log( "(d) Received data from daemon" );
114 //TODO
115
116 // check if we received a beacon frame 113 // check if we received a beacon frame
117 // static_cast is justified here 114 // static_cast is justified here
118 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); 115 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) );
119 if ( !beacon ) return; 116 if ( !beacon ) return;
120 QString type; 117 QString type;
121 118
@@ -160,25 +157,16 @@ void Wellenreiter::startStopClicked()
160 157
161 // switch off monitor mode 158 // switch off monitor mode
162 iface->setMonitorMode( false ); 159 iface->setMonitorMode( false );
163 // switch off promisc flag 160 // switch off promisc flag
164 iface->setPromiscuousMode( false ); 161 iface->setPromiscuousMode( false );
165 162
166 //TODO: Display "please wait..." (use owait?) 163 system( "cardctl reset; sleep 1; dhclient; udhcpc" ); //FIXME: Use OProcess
167
168 /*
169
170 QString cmdline;
171 cmdline.sprintf( "ifdown %s; sleep 1; ifup %s", (const char*) interface, (const char*) interface, (const char*) interface );
172 system( cmdline ); //FIXME: Use OProcess
173
174 */
175 164
176 // message the user 165 // message the user
177 166 QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
178 //QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." );
179 } 167 }
180 168
181 else 169 else
182 { 170 {
183 // get configuration from config window 171 // get configuration from config window
184 172