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) (show 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.cpp16
-rw-r--r--noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro2
10 files changed, 108 insertions, 32 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
@@ -40,7 +40,9 @@ ManufacturerDB::ManufacturerDB( const QString& filename )
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 }
@@ -52,7 +54,7 @@ ManufacturerDB::~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
@@ -25,7 +25,7 @@ class ManufacturerDB
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
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
@@ -18,15 +18,42 @@
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(...)
@@ -84,7 +111,10 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
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 }
@@ -102,7 +132,9 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo
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 {
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
@@ -20,6 +20,8 @@
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
@@ -28,9 +30,14 @@ class MScanListView: public QListView
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 );
33 37
38 private:
39 ManufacturerDB* _manufacturerdb;
40
34}; 41};
35 42
36#endif 43#endif
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
@@ -30,10 +30,13 @@ const 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 );
@@ -77,3 +80,17 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr,
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
@@ -57,10 +57,12 @@ class MScanListItem: public QListViewItem
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;
@@ -69,7 +71,7 @@ class MScanListItem: public QListViewItem
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
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
@@ -24,6 +24,7 @@
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
@@ -55,12 +56,13 @@ using namespace Opie;
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 //
@@ -69,7 +71,7 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
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
@@ -92,7 +94,8 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
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." );
@@ -112,6 +115,9 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
112 button->setEnabled( false ); 115 button->setEnabled( false );
113 netview->setColumnWidthMode( 1, QListView::Manual ); 116 netview->setColumnWidthMode( 1, QListView::Manual );
114 117
118 if ( manufacturerdb )
119 netview->setManufacturerDB( manufacturerdb );
120
115} 121}
116 122
117Wellenreiter::~Wellenreiter() 123Wellenreiter::~Wellenreiter()
@@ -127,18 +133,25 @@ void Wellenreiter::handleMessage()
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 );
141 150
151 */
152
153 int result = wl_recv( &daemon_fd, sockaddr, (char*) &buffer, WL_SOCKBUF );
154
142 if ( result == -1 ) 155 if ( result == -1 )
143 { 156 {
144 qDebug( "Warning: %s", strerror( errno ) ); 157 qDebug( "Warning: %s", strerror( errno ) );
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
@@ -23,6 +23,22 @@
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;
@@ -51,9 +67,12 @@ private:
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
@@ -73,22 +73,6 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f
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
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,7 +1,7 @@
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 =