-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.cpp | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.h | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 36 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 7 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 27 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 19 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/libwellenreiter/libwellenreiter.pro | 2 |
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 | |||
@@ -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 | ||
55 | QString ManufacturerDB::lookup( const QString& macaddr ) | 57 | const 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 | |||
21 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 23 | MScanListView::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 | ||
26 | MScanListView::~MScanListView() | 48 | MScanListView::~MScanListView() |
27 | { | 49 | { |
28 | }; | 50 | }; |
29 | 51 | ||
52 | void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) | ||
53 | { | ||
54 | _manufacturerdb = manufacturerdb; | ||
55 | } | ||
56 | |||
30 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 57 | void 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 | ||
21 | class QString; | 21 | class QString; |
22 | 22 | ||
23 | class ManufacturerDB; | ||
24 | |||
23 | class MScanListView: public QListView | 25 | class MScanListView: public QListView |
24 | { | 26 | { |
25 | Q_OBJECT | 27 | Q_OBJECT |
@@ -28,8 +30,13 @@ 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 ); |
37 | |||
38 | private: | ||
39 | ManufacturerDB* _manufacturerdb; | ||
33 | 40 | ||
34 | }; | 41 | }; |
35 | 42 | ||
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; | |||
30 | const int col_channel = 3; | 30 | const int col_channel = 3; |
31 | const int col_wep = 4; | 31 | const int col_wep = 4; |
32 | const int col_traffic = 5; | 32 | const int col_traffic = 5; |
33 | const int col_manuf = 6; | ||
33 | 34 | ||
34 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 35 | MScanListItem::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 | ||
83 | void MScanListItem::setManufacturer( const QString& manufacturer ) | ||
84 | { | ||
85 | setText( col_manuf, manufacturer ); | ||
86 | } | ||
87 | |||
88 | void 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 | ||
62 | Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | 64 | Wellenreiter::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." ); |
@@ -111,6 +114,9 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | |||
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 | ||
@@ -127,17 +133,24 @@ 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 ); |
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 | { |
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 @@ | |||
23 | using namespace Opie; | 23 | using 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 | |||
26 | class QTimerEvent; | 42 | class QTimerEvent; |
27 | class QPixmap; | 43 | class QPixmap; |
28 | class ManufacturerDB; | 44 | class 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 | |||
@@ -72,23 +72,7 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
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 | ||
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 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG = warn_on debug | 2 | CONFIG = warn_on debug |
3 | VERSION = 0.2 | 3 | VERSION = 0.2 |
4 | HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh | 4 | HEADERS = source/cardmode.hh source/wl_log.hh source/wl_proto.hh source/sniff.hh source/wl_sock.hh source/wl_types.hh |
5 | SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc | 5 | SOURCES = source/cardmode.cc source/wl_log.cc source/wl_proto.cc source/sniff.cc source/wl_sock.cc |
6 | 6 | ||
7 | LIBS = | 7 | LIBS = |