summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-12-31 14:59:35 (UTC)
committer mickeyl <mickeyl>2002-12-31 14:59:35 (UTC)
commit76ec681931f01609969b92e75908418d9e8e92d5 (patch) (unidiff)
tree8230634998f17c66ebb4eb1acd82112cdb77c944
parent3f35e5918b5f508139e189d2428d01d6c2933a50 (diff)
downloadopie-76ec681931f01609969b92e75908418d9e8e92d5.zip
opie-76ec681931f01609969b92e75908418d9e8e92d5.tar.gz
opie-76ec681931f01609969b92e75908418d9e8e92d5.tar.bz2
- catch with latest changes in libwellenreiter
- GUI now identifies and displays device manufacturers - GUI now displays the number of received beacons for each device
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/manufacturers.cpp4
-rw-r--r--noncore/net/wellenreiter/gui/manufacturers.h2
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp36
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h7
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.cpp19
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.h8
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp27
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h19
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.cpp18
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro2
10 files changed, 109 insertions, 33 deletions
diff --git a/noncore/net/wellenreiter/gui/manufacturers.cpp b/noncore/net/wellenreiter/gui/manufacturers.cpp
index d235989..dad2753 100644
--- a/noncore/net/wellenreiter/gui/manufacturers.cpp
+++ b/noncore/net/wellenreiter/gui/manufacturers.cpp
@@ -27,32 +27,34 @@ ManufacturerDB::ManufacturerDB( const QString& filename )
27 if (!hasFile) 27 if (!hasFile)
28 { 28 {
29 qDebug( "ManufacturerDB: D'oh! Manufacturer list '%s' not found!", (const char*) filename ); 29 qDebug( "ManufacturerDB: D'oh! Manufacturer list '%s' not found!", (const char*) filename );
30 } 30 }
31 else 31 else
32 { 32 {
33 qDebug( "ManufacturerDB: reading manufacturer list from '%s'...", (const char*) filename ); 33 qDebug( "ManufacturerDB: reading manufacturer list from '%s'...", (const char*) filename );
34 QTextStream s( &file ); 34 QTextStream s( &file );
35 QString addr; 35 QString addr;
36 QString manu; 36 QString manu;
37 37
38 while (!s.atEnd()) 38 while (!s.atEnd())
39 { 39 {
40 s >> addr; 40 s >> addr;
41 s.skipWhiteSpace(); 41 s.skipWhiteSpace();
42 manu = s.readLine(); 42 manu = s.readLine();
43 #ifdef DEBUG
43 qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); 44 qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu );
45 #endif
44 manufacturers.insert( addr, manu ); 46 manufacturers.insert( addr, manu );
45 47
46 } 48 }
47 } 49 }
48 50
49} 51}
50 52
51ManufacturerDB::~ManufacturerDB() 53ManufacturerDB::~ManufacturerDB()
52{ 54{
53} 55}
54 56
55QString ManufacturerDB::lookup( const QString& macaddr ) 57const QString& ManufacturerDB::lookup( const QString& macaddr ) const
56{ 58{
57 return manufacturers[macaddr.upper().left(8)]; 59 return manufacturers[macaddr.upper().left(8)];
58} 60}
diff --git a/noncore/net/wellenreiter/gui/manufacturers.h b/noncore/net/wellenreiter/gui/manufacturers.h
index d69977a..67afe21 100644
--- a/noncore/net/wellenreiter/gui/manufacturers.h
+++ b/noncore/net/wellenreiter/gui/manufacturers.h
@@ -12,26 +12,26 @@
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#ifndef MANUFACTURERS_H 16#ifndef MANUFACTURERS_H
17#define MANUFACTURERS_H 17#define MANUFACTURERS_H
18 18
19#include <qmap.h> 19#include <qmap.h>
20#include <string.h> 20#include <string.h>
21 21
22class ManufacturerDB 22class ManufacturerDB
23{ 23{
24 public: 24 public:
25 25
26 ManufacturerDB( const QString& filename ); 26 ManufacturerDB( const QString& filename );
27 virtual ~ManufacturerDB(); 27 virtual ~ManufacturerDB();
28 QString lookup( const QString& macaddr ); 28 const QString& lookup( const QString& macaddr ) const;
29 29
30 private: 30 private:
31 31
32 QMap<QString, QString> manufacturers; 32 QMap<QString, QString> manufacturers;
33 33
34}; 34};
35 35
36#endif 36#endif
37 37
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 6d032aa..ab19701 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -5,41 +5,68 @@
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
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 "scanlistitem.h" 17#include "scanlistitem.h"
18 18
19#include <assert.h> 19#include <assert.h>
20 20
21#include "manufacturers.h"
22
21MScanListView::MScanListView( QWidget* parent, const char* name ) 23MScanListView::MScanListView( QWidget* parent, const char* name )
22 :QListView( parent, name ) 24 :QListView( parent, name ), _manufacturerdb( 0 )
23{ 25{
26
27 setFrameShape( QListView::StyledPanel );
28 setFrameShadow( QListView::Sunken );
29
30 addColumn( tr( "Net/Station" ) );
31 setColumnAlignment( 0, AlignLeft || AlignVCenter );
32 addColumn( tr( "B" ) );
33 setColumnAlignment( 1, AlignCenter );
34 addColumn( tr( "AP" ) );
35 setColumnAlignment( 2, AlignCenter );
36 addColumn( tr( "Chn" ) );
37 setColumnAlignment( 3, AlignCenter );
38 addColumn( tr( "W" ) );
39 setColumnAlignment( 4, AlignCenter );
40 addColumn( tr( "T" ) );
41 setColumnAlignment( 5, AlignCenter );
42 addColumn( tr( "Manufacturer" ) );
43 setColumnAlignment( 6, AlignCenter );
44 setRootIsDecorated( true );
45 setAllColumnsShowFocus( true );
24}; 46};
25 47
26MScanListView::~MScanListView() 48MScanListView::~MScanListView()
27{ 49{
28}; 50};
29 51
52void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
53{
54 _manufacturerdb = manufacturerdb;
55}
56
30void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 57void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
31{ 58{
32 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) 59 // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
33 60
34 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", 61 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]",
35 (const char*) type, 62 (const char*) type,
36 (const char*) essid, 63 (const char*) essid,
37 (const char*) macaddr, 64 (const char*) macaddr,
38 channel ); 65 channel );
39 66
40 // search, if we already have seen this net 67 // search, if we already have seen this net
41 68
42 QString s; 69 QString s;
43 MScanListItem* network; 70 MScanListItem* network;
44 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 71 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
45 72
@@ -71,47 +98,52 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
71 // we have already seen this net, check all childs if MAC exists 98 // we have already seen this net, check all childs if MAC exists
72 99
73 network = item; 100 network = item;
74 101
75 item = static_cast<MScanListItem*> ( item->firstChild() ); 102 item = static_cast<MScanListItem*> ( item->firstChild() );
76 assert( item ); // this shouldn't fail 103 assert( item ); // this shouldn't fail
77 104
78 while ( item && ( item->text( 2 ) != macaddr ) ) 105 while ( item && ( item->text( 2 ) != macaddr ) )
79 { 106 {
80 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); 107 qDebug( "subitemtext: %s", (const char*) item->text( 2 ) );
81 item = static_cast<MScanListItem*> ( item->itemBelow() ); 108 item = static_cast<MScanListItem*> ( item->itemBelow() );
82 } 109 }
83 110
84 if ( item ) 111 if ( item )
85 { 112 {
86 // we have already seen this item, it's a dupe 113 // we have already seen this item, it's a dupe
114 #ifdef DEBUG
87 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 115 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
116 #endif
117 item->receivedBeacon();
88 return; 118 return;
89 } 119 }
90 } 120 }
91 else 121 else
92 { 122 {
93 s.sprintf( "(i) new network: '%s'", (const char*) essid ); 123 s.sprintf( "(i) new network: '%s'", (const char*) essid );
94 124
95 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); 125 network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 );
96 } 126 }
97 127
98 128
99 // insert new station as child from network 129 // insert new station as child from network
100 130
101 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 131 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
102 132
103 qDebug( "inserting new station %s", (const char*) macaddr ); 133 qDebug( "inserting new station %s", (const char*) macaddr );
104 134
105 new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 135 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
136 if ( _manufacturerdb )
137 station->setManufacturer( _manufacturerdb->lookup( macaddr ) );
106 138
107 if ( type == "managed" ) 139 if ( type == "managed" )
108 { 140 {
109 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); 141 s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel );
110 } 142 }
111 else 143 else
112 { 144 {
113 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); 145 s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel );
114 } 146 }
115 147
116} 148}
117 149
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 6fe6930..9a35a82 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -7,31 +7,38 @@
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
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#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include <qlistview.h> 19#include <qlistview.h>
20 20
21class QString; 21class QString;
22 22
23class ManufacturerDB;
24
23class MScanListView: public QListView 25class MScanListView: public QListView
24{ 26{
25 Q_OBJECT 27 Q_OBJECT
26 28
27 public: 29 public:
28 MScanListView( QWidget* parent = 0, const char* name = 0 ); 30 MScanListView( QWidget* parent = 0, const char* name = 0 );
29 virtual ~MScanListView(); 31 virtual ~MScanListView();
30 32
33 void setManufacturerDB( ManufacturerDB* manufacturerdb );
34
31 public slots: 35 public slots:
32 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 36 void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
37
38 private:
39 ManufacturerDB* _manufacturerdb;
33 40
34}; 41};
35 42
36#endif 43#endif
37 44
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp
index f4b43a6..15aef0c 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.cpp
+++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp
@@ -17,36 +17,39 @@
17#include <assert.h> 17#include <assert.h>
18#include <qpixmap.h> 18#include <qpixmap.h>
19 19
20#ifdef QWS 20#ifdef QWS
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#else 22#else
23#include "resource.h" 23#include "resource.h"
24#endif 24#endif
25 25
26const int col_type = 0; 26const int col_type = 0;
27const int col_essid = 0; 27const int col_essid = 0;
28const int col_sig = 1; 28const int col_sig = 1;
29const int col_ap = 2; 29const int col_ap = 2;
30const int col_channel = 3; 30const int col_channel = 3;
31const int col_wep = 4; 31const int col_wep = 4;
32const int col_traffic = 5; 32const int col_traffic = 5;
33const int col_manuf = 6;
33 34
34MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 35MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
35 bool wep, int channel, int signal ) 36 bool wep, int channel, int signal )
36 :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 37 :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
38 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
39 _channel( channel ), _signal( signal ), _beacons( 0 )
37{ 40{
38 qDebug( "creating scanlist item" ); 41 qDebug( "creating scanlist item" );
39 decorateItem( type, essid, macaddr, wep, channel, signal ); 42 decorateItem( type, essid, macaddr, wep, channel, signal );
40} 43}
41 44
42MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 45MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
43 bool wep, int channel, int signal ) 46 bool wep, int channel, int signal )
44 :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 47 :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
45{ 48{
46 qDebug( "creating scanlist item" ); 49 qDebug( "creating scanlist item" );
47 decorateItem( type, essid, macaddr, wep, channel, signal ); 50 decorateItem( type, essid, macaddr, wep, channel, signal );
48} 51}
49 52
50void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 53void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
51{ 54{
52 qDebug( "decorating scanlist item %s / %s / %s [%d]", 55 qDebug( "decorating scanlist item %s / %s / %s [%d]",
@@ -64,16 +67,30 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
64 if ( wep ) 67 if ( wep )
65 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); // rename the pixmap! 68 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); // rename the pixmap!
66 69
67 // set channel and signal text 70 // set channel and signal text
68 71
69 if ( signal != -1 ) 72 if ( signal != -1 )
70 setText( col_sig, QString::number( signal ) ); 73 setText( col_sig, QString::number( signal ) );
71 if ( channel != -1 ) 74 if ( channel != -1 )
72 setText( col_channel, QString::number( channel ) ); 75 setText( col_channel, QString::number( channel ) );
73 76
74 listView()->triggerUpdate(); 77 listView()->triggerUpdate();
75 78
76 this->type = type; 79 this->type = type;
77 80
78} 81}
79 82
83void MScanListItem::setManufacturer( const QString& manufacturer )
84{
85 setText( col_manuf, manufacturer );
86}
87
88void MScanListItem::receivedBeacon()
89{
90 _beacons++;
91 #ifdef DEBUG
92 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
93 #endif
94 setText( col_sig, QString::number( _beacons ) );
95}
96
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h
index 47a5a4e..c3c6255 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.h
+++ b/noncore/net/wellenreiter/gui/scanlistitem.h
@@ -44,34 +44,36 @@ class MScanListItem: public QListViewItem
44 protected: 44 protected:
45 45
46 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 46 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
47 47
48 public: 48 public:
49 49
50 QString type; 50 QString type;
51 51
52 public: 52 public:
53 53
54 //const QString& type() { return _type; }; 54 //const QString& type() { return _type; };
55 const QString& essid() { return _essid; }; 55 const QString& essid() { return _essid; };
56 const QString& macaddr() { return _macaddr; }; 56 const QString& macaddr() { return _macaddr; };
57 bool wep() { return _wep; }; 57 bool wep() { return _wep; };
58 int channel() { return _channel; }; 58 int channel() { return _channel; };
59 int signal() { return _signal; }; 59 int signal() { return _signal; };
60 int received() { return _received; }; 60 int beacons() { return _beacons; };
61 61
62 void setSignal( int signal ) { /* TODO */ }; 62 void setSignal( int signal ) { /* TODO */ };
63 void incReceived() { _received++; }; 63 void receivedBeacon();
64
65 void setManufacturer( const QString& manufacturer );
64 66
65 private: 67 private:
66 QString _type; 68 QString _type;
67 QString _essid; 69 QString _essid;
68 QString _macaddr; 70 QString _macaddr;
69 bool _wep; 71 bool _wep;
70 int _channel; 72 int _channel;
71 int _signal; 73 int _signal;
72 int _received; 74 int _beacons;
73 75
74}; 76};
75 77
76#endif 78#endif
77 79
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 9068e3a..b22c5cc 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -11,146 +11,159 @@
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// Qt 16// Qt
17 17
18#include <qpushbutton.h> 18#include <qpushbutton.h>
19#include <qmessagebox.h> 19#include <qmessagebox.h>
20#include <qcombobox.h> 20#include <qcombobox.h>
21#include <qspinbox.h> 21#include <qspinbox.h>
22#include <qsocketnotifier.h> 22#include <qsocketnotifier.h>
23 23
24// Qtopia 24// Qtopia
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h>
27#include <qpe/global.h> 28#include <qpe/global.h>
28#endif 29#endif
29 30
30// Opie 31// Opie
31 32
32#ifdef QWS 33#ifdef QWS
33#include <opie/odevice.h> 34#include <opie/odevice.h>
34using namespace Opie; 35using namespace Opie;
35#endif 36#endif
36 37
37// Standard 38// Standard
38 39
39#include <assert.h> 40#include <assert.h>
40#include <errno.h> 41#include <errno.h>
41#include <unistd.h> 42#include <unistd.h>
42#include <string.h> 43#include <string.h>
43#include <sys/types.h> 44#include <sys/types.h>
44#include <sys/socket.h> 45#include <sys/socket.h>
45#include <stdlib.h> 46#include <stdlib.h>
46#include <fcntl.h> 47#include <fcntl.h>
47 48
48// Local 49// Local
49 50
50#include "wellenreiter.h" 51#include "wellenreiter.h"
51#include "scanlist.h" 52#include "scanlist.h"
52#include "logwindow.h" 53#include "logwindow.h"
53#include "hexwindow.h" 54#include "hexwindow.h"
54#include "configwindow.h" 55#include "configwindow.h"
55 56
56#include "manufacturers.h" 57#include "manufacturers.h"
57 58
59#include <daemon/source/config.hh>
60#include <libwellenreiter/source/wl_types.hh>
58#include <libwellenreiter/source/wl_sock.hh> 61#include <libwellenreiter/source/wl_sock.hh>
59#include <libwellenreiter/source/wl_proto.hh> 62#include <libwellenreiter/source/wl_proto.hh>
60#include <daemon/source/config.hh>
61 63
62Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 64Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
63 : WellenreiterBase( parent, name, fl ), daemonRunning( false ) 65 : WellenreiterBase( parent, name, fl ), daemonRunning( false ), manufacturerdb( 0 )
64{ 66{
65 67
66 // 68 //
67 // construct manufacturer database 69 // construct manufacturer database
68 // 70 //
69 71
70 QString manufile; 72 QString manufile;
71 #ifdef QWS 73 #ifdef QWS
72 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) qApp.qpeDir() ); 74 manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
73 #else 75 #else
74 manufile.sprintf( "/home/mickey/work/opie/share/wellenreiter/manufacturers.dat" ); 76 manufile.sprintf( "/home/mickey/work/opie/share/wellenreiter/manufacturers.dat" );
75 #endif 77 #endif
76 manufacturerdb = new ManufacturerDB( manufile ); 78 manufacturerdb = new ManufacturerDB( manufile );
77 79
78 logwindow->log( "(i) Wellenreiter has been started." ); 80 logwindow->log( "(i) Wellenreiter has been started." );
79 81
80 // 82 //
81 // detect operating system 83 // detect operating system
82 // 84 //
83 85
84 #ifdef QWS 86 #ifdef QWS
85 QString sys; 87 QString sys;
86 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 88 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
87 _system = ODevice::inst()->system(); 89 _system = ODevice::inst()->system();
88 logwindow->log( sys ); 90 logwindow->log( sys );
89 #endif 91 #endif
90 92
91 // 93 //
92 // setup socket for daemon communication, register socket notifier 94 // setup socket for daemon communication, register socket notifier
93 // 95 //
94 96
95 daemon_fd = wl_setupsock( GUIADDR, GUIPORT ); 97 // struct sockaddr_in sockaddr;
98 daemon_fd = wl_setupsock( GUIADDR, GUIPORT, sockaddr );
96 if ( daemon_fd == -1 ) 99 if ( daemon_fd == -1 )
97 { 100 {
98 logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); 101 logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
99 } 102 }
100 else 103 else
101 { 104 {
102 int flags; 105 int flags;
103 flags = fcntl( daemon_fd, F_GETFL, 0 ); 106 flags = fcntl( daemon_fd, F_GETFL, 0 );
104 fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); 107 fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK );
105 QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); 108 QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent );
106 connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); 109 connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) );
107 } 110 }
108 111
109 // setup GUI 112 // setup GUI
110 113
111 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 114 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
112 button->setEnabled( false ); 115 button->setEnabled( false );
113 netview->setColumnWidthMode( 1, QListView::Manual ); 116 netview->setColumnWidthMode( 1, QListView::Manual );
117
118 if ( manufacturerdb )
119 netview->setManufacturerDB( manufacturerdb );
114 120
115} 121}
116 122
117Wellenreiter::~Wellenreiter() 123Wellenreiter::~Wellenreiter()
118{ 124{
119 // no need to delete child widgets, Qt does it all for us 125 // no need to delete child widgets, Qt does it all for us
120 126
121 delete manufacturerdb; 127 delete manufacturerdb;
122} 128}
123 129
124void Wellenreiter::handleMessage() 130void Wellenreiter::handleMessage()
125{ 131{
126 // FIXME: receive message and handle it 132 // FIXME: receive message and handle it
127 133
128 qDebug( "received message from daemon." ); 134 qDebug( "received message from daemon." );
129 135
130 char buffer[10000]; 136 /*char buffer[10000];
131 memset( &buffer, 0, sizeof( buffer ) ); 137 memset( &buffer, 0, sizeof( buffer ) );*/
138
139 char buffer[WL_SOCKBUF];
132 140
133 // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); 141 // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) );
134 142
143 /*
144
135 struct sockaddr from; 145 struct sockaddr from;
136 socklen_t len; 146 socklen_t len;
137 147
138 int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); 148 int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len );
139
140 qDebug( "received %d from recv [%d bytes]", result, len ); 149 qDebug( "received %d from recv [%d bytes]", result, len );
150
151 */
152
153 int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF );
141 154
142 if ( result == -1 ) 155 if ( result == -1 )
143 { 156 {
144 qDebug( "Warning: %s", strerror( errno ) ); 157 qDebug( "Warning: %s", strerror( errno ) );
145 return; 158 return;
146 } 159 }
147 160
148 int command = buffer[1] - 48; 161 int command = buffer[1] - 48;
149 162
150/* 163/*
151typedef struct { 164typedef struct {
152 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc 165 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
153 int ssid_len; Length of SSID 166 int ssid_len; Length of SSID
154 int channel; Channel 167 int channel; Channel
155 int wep; 1 = WEP enabled ; 0 = disabled 168 int wep; 1 = WEP enabled ; 0 = disabled
156 char mac[64]; MAC address of Accesspoint 169 char mac[64]; MAC address of Accesspoint
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 9715983..0ddc72c 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -10,50 +10,69 @@
10** 10**
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#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26// ugly... not here!
27
28#include <assert.h>
29#include <errno.h>
30#include <unistd.h>
31#include <string.h>
32#include <sys/types.h>
33#include <sys/socket.h>
34#include <stdlib.h>
35#include <fcntl.h>
36#include <daemon/source/config.hh>
37#include <libwellenreiter/source/wl_types.hh>
38#include <libwellenreiter/source/wl_sock.hh>
39#include <libwellenreiter/source/wl_proto.hh>
40
41
26class QTimerEvent; 42class QTimerEvent;
27class QPixmap; 43class QPixmap;
28class ManufacturerDB; 44class ManufacturerDB;
29 45
30class Wellenreiter : public WellenreiterBase { 46class Wellenreiter : public WellenreiterBase {
31 Q_OBJECT 47 Q_OBJECT
32 48
33public: 49public:
34 50
35 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 51 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
36 ~Wellenreiter(); 52 ~Wellenreiter();
37 53
38protected: 54protected:
39 55
40 bool daemonRunning; 56 bool daemonRunning;
41 57
42public slots: 58public slots:
43 void buttonClicked(); 59 void buttonClicked();
44 void dataReceived(); 60 void dataReceived();
45 61
46private: 62private:
47 int daemon_fd; // socket filedescriptor for udp communication socket 63 int daemon_fd; // socket filedescriptor for udp communication socket
48 #ifdef QWS 64 #ifdef QWS
49 OSystem _system; // Opie Operating System identifier 65 OSystem _system; // Opie Operating System identifier
50 #endif 66 #endif
51 void handleMessage(); 67 void handleMessage();
52 68
53 ManufacturerDB* manufacturerdb; 69 ManufacturerDB* manufacturerdb;
70 struct sockaddr_in sockaddr;
54 71
55 //void readConfig(); 72 //void readConfig();
56 //void writeConfig(); 73 //void writeConfig();
57}; 74};
58 75
76
77
59#endif 78#endif
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
index d6b9891..a93c684 100644
--- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
@@ -59,49 +59,33 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f
59 setCaption( tr( "Wellenreiter" ) ); 59 setCaption( tr( "Wellenreiter" ) );
60 WellenreiterBaseLayout = new QVBoxLayout( this ); 60 WellenreiterBaseLayout = new QVBoxLayout( this );
61 WellenreiterBaseLayout->setSpacing( 2 ); 61 WellenreiterBaseLayout->setSpacing( 2 );
62 WellenreiterBaseLayout->setMargin( 0 ); 62 WellenreiterBaseLayout->setMargin( 0 );
63#ifdef QWS 63#ifdef QWS
64 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); 64 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global );
65#else 65#else
66 TabWidget = new QTabWidget( this, "TabWidget" ); 66 TabWidget = new QTabWidget( this, "TabWidget" );
67#endif 67#endif
68 ap = new QWidget( TabWidget, "ap" ); 68 ap = new QWidget( TabWidget, "ap" );
69 apLayout = new QVBoxLayout( ap ); 69 apLayout = new QVBoxLayout( ap );
70 apLayout->setSpacing( 2 ); 70 apLayout->setSpacing( 2 );
71 apLayout->setMargin( 2 ); 71 apLayout->setMargin( 2 );
72 72
73 //--------- NETVIEW TAB -------------- 73 //--------- NETVIEW TAB --------------
74 74
75 netview = new MScanListView( ap ); 75 netview = new MScanListView( ap );
76 netview->addColumn( tr( "SSID" ) );
77 netview->setColumnAlignment( 0, AlignLeft || AlignVCenter );
78 netview->addColumn( tr( "Sig" ) );
79 netview->setColumnAlignment( 1, AlignCenter );
80 netview->addColumn( tr( "AP" ) );
81 netview->setColumnAlignment( 2, AlignCenter );
82 netview->addColumn( tr( "Chn" ) );
83 netview->setColumnAlignment( 3, AlignCenter );
84 netview->addColumn( tr( "W" ) );
85 netview->setColumnAlignment( 4, AlignCenter );
86 netview->addColumn( tr( "T" ) );
87 netview->setColumnAlignment( 5, AlignCenter );
88
89 netview->setFrameShape( QListView::StyledPanel );
90 netview->setFrameShadow( QListView::Sunken );
91 netview->setRootIsDecorated( TRUE );
92 apLayout->addWidget( netview ); 76 apLayout->addWidget( netview );
93 77
94 78
95 //--------- LOG TAB -------------- 79 //--------- LOG TAB --------------
96 80
97 logwindow = new MLogWindow( TabWidget, "Log" ); 81 logwindow = new MLogWindow( TabWidget, "Log" );
98 82
99 83
100 //--------- HEX TAB -------------- 84 //--------- HEX TAB --------------
101 85
102 hexwindow = new MHexWindow( TabWidget, "Hex" ); 86 hexwindow = new MHexWindow( TabWidget, "Hex" );
103 87
104 //--------- CONFIG TAB -------------- 88 //--------- CONFIG TAB --------------
105 89
106 configwindow = new WellenreiterConfigWindow( TabWidget, "Config" ); 90 configwindow = new WellenreiterConfigWindow( TabWidget, "Config" );
107 91
diff --git a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro
index 9cf717e..8a6ed36 100644
--- a/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro
+++ b/noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro
@@ -1,11 +1,11 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG = warn_on debug 2CONFIG = warn_on debug
3VERSION = 0.2 3VERSION = 0.2
4HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh 4HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh
5SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc 5SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc
6 6
7LIBS = 7LIBS =
8TMAKE_CFLAGS += -D__UNIX__ 8TMAKE_CFLAGS += -D__UNIX__
9 9
10DESTDIR = $(QTDIR)/lib 10DESTDIR = $(QTDIR)/lib
11TARGET = wellenreiter 11TARGET = wellenreiter