author | mickeyl <mickeyl> | 2002-12-28 18:57:11 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2002-12-28 18:57:11 (UTC) |
commit | f70916f3ab05917a3d0dda64beb8db5ac16448ab (patch) (unidiff) | |
tree | bd138c1a901de7ea49b012b32e48d3f4b8b073f8 | |
parent | 1362726346f1ab497ad5822db1a9b284f5bdaa1a (diff) | |
download | opie-f70916f3ab05917a3d0dda64beb8db5ac16448ab.zip opie-f70916f3ab05917a3d0dda64beb8db5ac16448ab.tar.gz opie-f70916f3ab05917a3d0dda64beb8db5ac16448ab.tar.bz2 |
- refactored a number of classes
- removed dumb polling ==> QSocketNotifier rocks
- switched to parsing the daemon stuff in the gui,
since libwellenreiter still has problems.
-rw-r--r-- | noncore/net/wellenreiter/gui/cardconfig.cpp | 29 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/cardconfig.h | 58 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configbase.ui | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui-x11.pro | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 100 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 11 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 213 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 13 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wlan.cpp | 57 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wlan.h | 38 |
14 files changed, 403 insertions, 165 deletions
diff --git a/noncore/net/wellenreiter/gui/cardconfig.cpp b/noncore/net/wellenreiter/gui/cardconfig.cpp new file mode 100644 index 0000000..1ca1d27 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/cardconfig.cpp | |||
@@ -0,0 +1,29 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "cardconfig.h" | ||
17 | |||
18 | #include <qstring.h> | ||
19 | |||
20 | CardConfig::CardConfig( const QString& interface, Type type, int hopinterval ) | ||
21 | :_interface( interface ), _type( type ), _hopinterval( hopinterval ) | ||
22 | { | ||
23 | |||
24 | } | ||
25 | |||
26 | CardConfig::~CardConfig() | ||
27 | { | ||
28 | } | ||
29 | |||
diff --git a/noncore/net/wellenreiter/gui/cardconfig.h b/noncore/net/wellenreiter/gui/cardconfig.h new file mode 100644 index 0000000..f54ebac --- a/dev/null +++ b/noncore/net/wellenreiter/gui/cardconfig.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef CARDCONFIG_H | ||
17 | #define CARDCONFIG_H | ||
18 | |||
19 | #include <qstring.h> | ||
20 | |||
21 | #ifdef QWS | ||
22 | #include <opie/odevice.h> | ||
23 | using namespace Opie; | ||
24 | #endif | ||
25 | |||
26 | class CardConfig | ||
27 | { | ||
28 | public: | ||
29 | |||
30 | typedef enum { Prism, Orinoco, HostAP, Manual } Type; | ||
31 | |||
32 | public: | ||
33 | |||
34 | CardConfig( const QString& interface, Type type = Manual, int hopinterval = 100 ); | ||
35 | virtual ~CardConfig(); | ||
36 | |||
37 | const QString& interface() { return _interface; }; | ||
38 | int hopinterval() { return _hopinterval; }; | ||
39 | Type type() { return _type; }; | ||
40 | |||
41 | #ifdef QWS | ||
42 | OSystem system() { return _system; }; | ||
43 | #endif | ||
44 | |||
45 | private: | ||
46 | |||
47 | QString _interface; | ||
48 | Type _type; | ||
49 | int _hopinterval; | ||
50 | |||
51 | #ifdef QWS | ||
52 | OSystem _system; | ||
53 | #endif | ||
54 | |||
55 | }; | ||
56 | |||
57 | #endif | ||
58 | |||
diff --git a/noncore/net/wellenreiter/gui/configbase.ui b/noncore/net/wellenreiter/gui/configbase.ui index e2f734a..8dcf513 100644 --- a/noncore/net/wellenreiter/gui/configbase.ui +++ b/noncore/net/wellenreiter/gui/configbase.ui | |||
@@ -12,5 +12,5 @@ | |||
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>232</width> | 14 | <width>228</width> |
15 | <height>267</height> | 15 | <height>267</height> |
16 | </rect> | 16 | </rect> |
@@ -33,5 +33,5 @@ | |||
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>spacing</name> | 34 | <name>spacing</name> |
35 | <number>0</number> | 35 | <number>1</number> |
36 | </property> | 36 | </property> |
37 | <widget> | 37 | <widget> |
@@ -181,10 +181,4 @@ | |||
181 | <property> | 181 | <property> |
182 | <name>text</name> | 182 | <name>text</name> |
183 | <string>cisco</string> | ||
184 | </property> | ||
185 | </item> | ||
186 | <item> | ||
187 | <property> | ||
188 | <name>text</name> | ||
189 | <string>orinoco</string> | 183 | <string>orinoco</string> |
190 | </property> | 184 | </property> |
diff --git a/noncore/net/wellenreiter/gui/gui-x11.pro b/noncore/net/wellenreiter/gui/gui-x11.pro index 6b4a7bf..523bf15 100644 --- a/noncore/net/wellenreiter/gui/gui-x11.pro +++ b/noncore/net/wellenreiter/gui/gui-x11.pro | |||
@@ -3,9 +3,9 @@ TEMPLATE = app | |||
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | #CONFIG = qt warn_on release | 4 | #CONFIG = qt warn_on release |
5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h | 5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h wlan.h cardconfig.h |
6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp | 6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp wlan.cpp cardconfig.cpp |
7 | INCLUDEPATH += ../ | 7 | INCLUDEPATH += ../ |
8 | DEPENDPATH += ../ | 8 | DEPENDPATH += ../ |
9 | LIBS += -lwellenreiter | 9 | LIBS += -L. -lwellenreiter |
10 | INTERFACES = configbase.ui | 10 | INTERFACES = configbase.ui |
11 | TARGET = wellenreiter | 11 | TARGET = wellenreiter |
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index b6e884d..ce1c387 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro | |||
@@ -3,9 +3,9 @@ TEMPLATE = app | |||
3 | CONFIG = qt warn_on debug | 3 | CONFIG = qt warn_on debug |
4 | #CONFIG = qt warn_on release | 4 | #CONFIG = qt warn_on release |
5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h | 5 | HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h wlan.h cardconfig.h |
6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp | 6 | SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp wlan.cpp cardconfig.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include ../ | 7 | INCLUDEPATH += $(OPIEDIR)/include ../ |
8 | DEPENDPATH += $(OPIEDIR)/include ../ | 8 | DEPENDPATH += $(OPIEDIR)/include ../ |
9 | LIBS += -lqpe -lopie -lwellenreiter | 9 | LIBS += -lqpe -lopie -L. -lwellenreiter |
10 | INTERFACES = configbase.ui | 10 | INTERFACES = configbase.ui |
11 | TARGET = wellenreiter | 11 | TARGET = wellenreiter |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index f907afc..6d032aa 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -15,3 +15,103 @@ | |||
15 | 15 | ||
16 | #include "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "scanlistitem.h" | ||
18 | |||
19 | #include <assert.h> | ||
20 | |||
21 | MScanListView::MScanListView( QWidget* parent, const char* name ) | ||
22 | :QListView( parent, name ) | ||
23 | { | ||
24 | }; | ||
25 | |||
26 | MScanListView::~MScanListView() | ||
27 | { | ||
28 | }; | ||
29 | |||
30 | void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | ||
31 | { | ||
32 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | ||
33 | |||
34 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", | ||
35 | (const char*) type, | ||
36 | (const char*) essid, | ||
37 | (const char*) macaddr, | ||
38 | channel ); | ||
39 | |||
40 | // search, if we already have seen this net | ||
41 | |||
42 | QString s; | ||
43 | MScanListItem* network; | ||
44 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | ||
45 | |||
46 | while ( item && ( item->text( 0 ) != essid ) ) | ||
47 | { | ||
48 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | ||
49 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
50 | } | ||
51 | if ( item ) | ||
52 | { | ||
53 | // animate the item | ||
54 | |||
55 | /* | ||
56 | |||
57 | const QPixmap* pixmap = item->pixmap( 0 ); | ||
58 | const QPixmap* nextpixmap = ani2; | ||
59 | if ( pixmap == ani1 ) | ||
60 | nextpixmap = ani2; | ||
61 | else if ( pixmap == ani2 ) | ||
62 | nextpixmap = ani3; | ||
63 | else if ( pixmap == ani3 ) | ||
64 | nextpixmap = ani4; | ||
65 | else if ( pixmap == ani4 ) | ||
66 | nextpixmap = ani1; | ||
67 | item->setPixmap( 0, *nextpixmap ); */ | ||
68 | |||
69 | //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); | ||
70 | |||
71 | // we have already seen this net, check all childs if MAC exists | ||
72 | |||
73 | network = item; | ||
74 | |||
75 | item = static_cast<MScanListItem*> ( item->firstChild() ); | ||
76 | assert( item ); // this shouldn't fail | ||
77 | |||
78 | while ( item && ( item->text( 2 ) != macaddr ) ) | ||
79 | { | ||
80 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | ||
81 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
82 | } | ||
83 | |||
84 | if ( item ) | ||
85 | { | ||
86 | // we have already seen this item, it's a dupe | ||
87 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | ||
88 | return; | ||
89 | } | ||
90 | } | ||
91 | else | ||
92 | { | ||
93 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | ||
94 | |||
95 | network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); | ||
96 | } | ||
97 | |||
98 | |||
99 | // insert new station as child from network | ||
100 | |||
101 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | ||
102 | |||
103 | qDebug( "inserting new station %s", (const char*) macaddr ); | ||
104 | |||
105 | new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | ||
106 | |||
107 | if ( type == "managed" ) | ||
108 | { | ||
109 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | ||
114 | } | ||
115 | |||
116 | } | ||
17 | 117 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 5cf3053..6fe6930 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h | |||
@@ -21,6 +21,15 @@ | |||
21 | class QString; | 21 | class QString; |
22 | 22 | ||
23 | class MScanList: public QListView | 23 | class MScanListView: public QListView |
24 | { | 24 | { |
25 | Q_OBJECT | ||
26 | |||
27 | public: | ||
28 | MScanListView( QWidget* parent = 0, const char* name = 0 ); | ||
29 | virtual ~MScanListView(); | ||
30 | |||
31 | public slots: | ||
32 | void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); | ||
33 | |||
25 | }; | 34 | }; |
26 | 35 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index 1e2a52e..f4b43a6 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp | |||
@@ -77,2 +77,3 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, | |||
77 | 77 | ||
78 | } | 78 | } |
79 | |||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 0fd929f..2d9bbee 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -20,4 +20,5 @@ | |||
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qspinbox.h> | 21 | #include <qspinbox.h> |
22 | #include <qsocketnotifier.h> | ||
22 | 23 | ||
23 | // Qtopia | 24 | // Qtopia |
@@ -27,4 +28,11 @@ | |||
27 | #endif | 28 | #endif |
28 | 29 | ||
30 | // Opie | ||
31 | |||
32 | #ifdef QWS | ||
33 | #include <opie/odevice.h> | ||
34 | using namespace Opie; | ||
35 | #endif | ||
36 | |||
29 | // Standard | 37 | // Standard |
30 | 38 | ||
@@ -34,10 +42,12 @@ | |||
34 | #include <string.h> | 42 | #include <string.h> |
35 | #include <sys/types.h> | 43 | #include <sys/types.h> |
44 | #include <sys/socket.h> | ||
36 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <fcntl.h> | ||
37 | 47 | ||
38 | // Local | 48 | // Local |
39 | 49 | ||
40 | #include "wellenreiter.h" | 50 | #include "wellenreiter.h" |
41 | #include "scanlistitem.h" | 51 | #include "scanlist.h" |
42 | #include "logwindow.h" | 52 | #include "logwindow.h" |
43 | #include "hexwindow.h" | 53 | #include "hexwindow.h" |
@@ -54,9 +64,17 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | |||
54 | logwindow->log( "(i) Wellenreiter has been started." ); | 64 | logwindow->log( "(i) Wellenreiter has been started." ); |
55 | 65 | ||
56 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); | ||
57 | netview->setColumnWidthMode( 1, QListView::Manual ); | ||
58 | |||
59 | // | 66 | // |
60 | // setup socket for daemon communication and start poller | 67 | // detect operating system |
68 | // | ||
69 | |||
70 | #ifdef QWS | ||
71 | QString sys; | ||
72 | sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); | ||
73 | _system = ODevice::inst()->system(); | ||
74 | logwindow->log( sys ); | ||
75 | #endif | ||
76 | |||
77 | // | ||
78 | // setup socket for daemon communication, register socket notifier | ||
61 | // | 79 | // |
62 | 80 | ||
@@ -65,9 +83,20 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | |||
65 | { | 83 | { |
66 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); | 84 | logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); |
67 | qDebug( "D'oh! Could not get file descriptor for daemon-->gui communication socket." ); | ||
68 | } | 85 | } |
69 | else | 86 | else |
70 | startTimer( 700 ); | 87 | { |
88 | int flags; | ||
89 | flags = fcntl( daemon_fd, F_GETFL, 0 ); | ||
90 | fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK ); | ||
91 | QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent ); | ||
92 | connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) ); | ||
93 | } | ||
71 | 94 | ||
95 | // setup GUI | ||
96 | |||
97 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); | ||
98 | button->setEnabled( false ); | ||
99 | netview->setColumnWidthMode( 1, QListView::Manual ); | ||
100 | |||
72 | } | 101 | } |
73 | 102 | ||
@@ -83,9 +112,24 @@ void Wellenreiter::handleMessage() | |||
83 | qDebug( "received message from daemon." ); | 112 | qDebug( "received message from daemon." ); |
84 | 113 | ||
85 | char buffer[128]; | 114 | char buffer[10000]; |
86 | 115 | memset( &buffer, 0, sizeof( buffer ) ); | |
87 | int result = wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | ||
88 | qDebug( "received %d from recvcomm", result ); | ||
89 | 116 | ||
117 | // int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) ); | ||
118 | |||
119 | struct sockaddr from; | ||
120 | socklen_t len; | ||
121 | |||
122 | int result = recvfrom( daemon_fd, &buffer, 8192, MSG_WAITALL, &from, &len ); | ||
123 | |||
124 | qDebug( "received %d from recv [%d bytes]", result, len ); | ||
125 | |||
126 | if ( result == -1 ) | ||
127 | { | ||
128 | qDebug( "Warning: %s", strerror( errno ) ); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | int command = buffer[1] - 48; | ||
133 | |||
90 | /* | 134 | /* |
91 | typedef struct { | 135 | typedef struct { |
@@ -99,8 +143,9 @@ typedef struct { | |||
99 | */ | 143 | */ |
100 | 144 | ||
101 | // qDebug( "Sniffer sent: '%s'", (const char*) buffer ); | 145 | qDebug( "Recv result: %d", ( result ) ); |
146 | qDebug( "Sniffer sent: '%s'", (const char*) buffer ); | ||
102 | hexwindow->log( (const char*) &buffer ); | 147 | hexwindow->log( (const char*) &buffer ); |
103 | 148 | ||
104 | if ( result == NETFOUND ) /* new network found */ | 149 | if ( command == NETFOUND ) /* new network found */ |
105 | { | 150 | { |
106 | qDebug( "Sniffer said: new network found." ); | 151 | qDebug( "Sniffer said: new network found." ); |
@@ -120,5 +165,5 @@ typedef struct { | |||
120 | type = "adhoc"; | 165 | type = "adhoc"; |
121 | 166 | ||
122 | addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); | 167 | netview->addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); |
123 | 168 | ||
124 | } | 169 | } |
@@ -132,123 +177,26 @@ typedef struct { | |||
132 | } | 177 | } |
133 | 178 | ||
134 | 179 | void Wellenreiter::dataReceived() | |
135 | bool Wellenreiter::hasMessage() | ||
136 | { | 180 | { |
137 | 181 | logwindow->log( "(d) Received data from daemon" ); | |
138 | // FIXME: do this in libwellenreiter, not here!!! | 182 | handleMessage(); |
139 | |||
140 | fd_set rfds; | ||
141 | FD_ZERO( &rfds ); | ||
142 | FD_SET( daemon_fd, &rfds ); | ||
143 | struct timeval tv; | ||
144 | tv.tv_sec = 0; | ||
145 | tv.tv_usec = 10; | ||
146 | int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); | ||
147 | |||
148 | if ( result == 0 ) | ||
149 | { | ||
150 | return false; | ||
151 | } | ||
152 | else if ( result == -1 ) | ||
153 | { | ||
154 | qDebug( "selected returned: %s", strerror( errno ) ); | ||
155 | return false; | ||
156 | } | ||
157 | else | ||
158 | return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor | ||
159 | } | 183 | } |
160 | 184 | ||
161 | void Wellenreiter::timerEvent( QTimerEvent* e ) | 185 | void Wellenreiter::buttonClicked() |
162 | { | ||
163 | //qDebug( "checking for message..." ); | ||
164 | if ( hasMessage() ) | ||
165 | { | ||
166 | //qDebug( "got message from daemon" ); | ||
167 | handleMessage(); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | //qDebug( "no message..." ); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | ||
176 | { | 186 | { |
177 | // FIXME: this code belongs in customized QListView, not into this class | 187 | /* |
178 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | 188 | // add some test stations, so that we can see if the GUI part works |
179 | 189 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | |
180 | qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", | 190 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); |
181 | (const char*) type, | 191 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); |
182 | (const char*) essid, | 192 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); |
183 | (const char*) macaddr, | 193 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); |
184 | channel ); | 194 | */ |
185 | |||
186 | // search, if we already have seen this net | ||
187 | |||
188 | QString s; | ||
189 | MScanListItem* network; | ||
190 | MScanListItem* item = static_cast<MScanListItem*> ( netview->firstChild() ); | ||
191 | |||
192 | while ( item && ( item->text( 0 ) != essid ) ) | ||
193 | { | ||
194 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | ||
195 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
196 | } | ||
197 | if ( item ) | ||
198 | { | ||
199 | // we have already seen this net, check all childs if MAC exists | ||
200 | |||
201 | network = item; | ||
202 | |||
203 | item = static_cast<MScanListItem*> ( item->firstChild() ); | ||
204 | assert( item ); // this shouldn't fail | ||
205 | |||
206 | while ( item && ( item->text( 2 ) != macaddr ) ) | ||
207 | { | ||
208 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); | ||
209 | item = static_cast<MScanListItem*> ( item->itemBelow() ); | ||
210 | } | ||
211 | |||
212 | if ( item ) | ||
213 | { | ||
214 | // we have already seen this item, it's a dupe | ||
215 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | ||
216 | return; | ||
217 | } | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); | ||
222 | logwindow->log( s ); | ||
223 | |||
224 | network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); | ||
225 | } | ||
226 | |||
227 | |||
228 | // insert new station as child from network | ||
229 | |||
230 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | ||
231 | |||
232 | qDebug( "inserting new station %s", (const char*) macaddr ); | ||
233 | |||
234 | new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | ||
235 | |||
236 | if ( type == "managed" ) | ||
237 | { | ||
238 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | ||
243 | } | ||
244 | |||
245 | logwindow->log( s ); | ||
246 | 195 | ||
247 | } | ||
248 | 196 | ||
249 | void Wellenreiter::buttonClicked() | ||
250 | { | ||
251 | if ( daemonRunning ) | 197 | if ( daemonRunning ) |
252 | { | 198 | { |
199 | daemonRunning = false; | ||
200 | |||
253 | logwindow->log( "(i) Daemon has been stopped." ); | 201 | logwindow->log( "(i) Daemon has been stopped." ); |
254 | button->setText( "Start Scanning" ); | 202 | button->setText( "Start Scanning" ); |
@@ -317,19 +265,4 @@ void Wellenreiter::buttonClicked() | |||
317 | qDebug( "done" ); | 265 | qDebug( "done" ); |
318 | 266 | ||
319 | /* | ||
320 | |||
321 | // add some test stations, so that we can see if the GUI part works | ||
322 | |||
323 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | ||
324 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | ||
325 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); | ||
326 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); | ||
327 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); | ||
328 | |||
329 | QString command ("98"); | ||
330 | |||
331 | //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); | ||
332 | |||
333 | */ | ||
334 | } | 267 | } |
335 | } | 268 | } |
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 052a242..2296892 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h | |||
@@ -19,5 +19,11 @@ | |||
19 | #include "wellenreiterbase.h" | 19 | #include "wellenreiterbase.h" |
20 | 20 | ||
21 | #ifdef QWS | ||
22 | #include <opie/odevice.h> | ||
23 | using namespace Opie; | ||
24 | #endif | ||
25 | |||
21 | class QTimerEvent; | 26 | class QTimerEvent; |
27 | class QPixmap; | ||
22 | 28 | ||
23 | class Wellenreiter : public WellenreiterBase { | 29 | class Wellenreiter : public WellenreiterBase { |
@@ -30,5 +36,4 @@ public: | |||
30 | 36 | ||
31 | protected: | 37 | protected: |
32 | virtual void timerEvent( QTimerEvent* ); | ||
33 | 38 | ||
34 | bool daemonRunning; | 39 | bool daemonRunning; |
@@ -36,12 +41,13 @@ protected: | |||
36 | public slots: | 41 | public slots: |
37 | void buttonClicked(); | 42 | void buttonClicked(); |
38 | void addNewItem( QString type, QString essid, QString ap, bool wep, int channel, int signal ); | 43 | void dataReceived(); |
39 | 44 | ||
40 | private: | 45 | private: |
41 | int daemon_fd; // socket filedescriptor for udp communication socket | 46 | int daemon_fd; // socket filedescriptor for udp communication socket |
42 | 47 | #ifdef QWS | |
43 | bool hasMessage(); | 48 | OSystem _system; // Opie Operating System identifier |
49 | #endif | ||
44 | void handleMessage(); | 50 | void handleMessage(); |
45 | 51 | ||
46 | //void readConfig(); | 52 | //void readConfig(); |
47 | //void writeConfig(); | 53 | //void writeConfig(); |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 5017b08..d6b9891 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -31,4 +31,5 @@ | |||
31 | #include "hexwindow.h" | 31 | #include "hexwindow.h" |
32 | #include "configwindow.h" | 32 | #include "configwindow.h" |
33 | #include "scanlist.h" | ||
33 | 34 | ||
34 | #ifdef QWS | 35 | #ifdef QWS |
@@ -48,4 +49,9 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
48 | : QWidget( parent, name, fl ) | 49 | : QWidget( parent, name, fl ) |
49 | { | 50 | { |
51 | ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); | ||
52 | ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); | ||
53 | ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); | ||
54 | ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); | ||
55 | |||
50 | if ( !name ) | 56 | if ( !name ) |
51 | setName( "WellenreiterBase" ); | 57 | setName( "WellenreiterBase" ); |
@@ -67,5 +73,5 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f | |||
67 | //--------- NETVIEW TAB -------------- | 73 | //--------- NETVIEW TAB -------------- |
68 | 74 | ||
69 | netview = new QListView( ap, "netview" ); | 75 | netview = new MScanListView( ap ); |
70 | netview->addColumn( tr( "SSID" ) ); | 76 | netview->addColumn( tr( "SSID" ) ); |
71 | netview->setColumnAlignment( 0, AlignLeft || AlignVCenter ); | 77 | netview->setColumnAlignment( 0, AlignLeft || AlignVCenter ); |
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index fce25d1..edb2930 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h | |||
@@ -23,6 +23,6 @@ class QHBoxLayout; | |||
23 | class QGridLayout; | 23 | class QGridLayout; |
24 | class QLabel; | 24 | class QLabel; |
25 | class QListView; | 25 | class MScanListView; |
26 | class QListViewItem; | 26 | class MScanListItem; |
27 | class QPushButton; | 27 | class QPushButton; |
28 | class MLogWindow; | 28 | class MLogWindow; |
@@ -50,5 +50,5 @@ public: | |||
50 | #endif | 50 | #endif |
51 | QWidget* ap; | 51 | QWidget* ap; |
52 | QListView* netview; | 52 | MScanListView* netview; |
53 | MLogWindow* logwindow; | 53 | MLogWindow* logwindow; |
54 | MHexWindow* hexwindow; | 54 | MHexWindow* hexwindow; |
@@ -64,4 +64,11 @@ protected: | |||
64 | QGridLayout* aboutLayout; | 64 | QGridLayout* aboutLayout; |
65 | bool event( QEvent* ); | 65 | bool event( QEvent* ); |
66 | |||
67 | QPixmap* ani1; | ||
68 | QPixmap* ani2; | ||
69 | QPixmap* ani3; | ||
70 | QPixmap* ani4; | ||
71 | |||
72 | |||
66 | }; | 73 | }; |
67 | 74 | ||
diff --git a/noncore/net/wellenreiter/gui/wlan.cpp b/noncore/net/wellenreiter/gui/wlan.cpp new file mode 100644 index 0000000..b046cc8 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/wlan.cpp | |||
@@ -0,0 +1,57 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "wlan.h" | ||
17 | #include "cardconfig.h" | ||
18 | |||
19 | // Qt | ||
20 | #include <qstring.h> | ||
21 | |||
22 | // Qtopia | ||
23 | #ifdef QWS | ||
24 | #include <opie/odevice.h> | ||
25 | using namespace Opie; | ||
26 | #endif | ||
27 | |||
28 | WLAN::WLAN( const QString& interface ) | ||
29 | { | ||
30 | _configuration = new CardConfig( interface ); | ||
31 | } | ||
32 | |||
33 | WLAN::WLAN( const CardConfig* configuration ) | ||
34 | { | ||
35 | _configuration = configuration; | ||
36 | |||
37 | } | ||
38 | |||
39 | WLAN::~WLAN() | ||
40 | { | ||
41 | delete _configuration; | ||
42 | |||
43 | } | ||
44 | |||
45 | void WLAN::setMonitorMode( bool enabled ) | ||
46 | { | ||
47 | |||
48 | /* | ||
49 | |||
50 | if ( _configuration->system() == System_OpenZaurus && _configuration->type() == CardConfig::Prism ) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | */ | ||
55 | |||
56 | } | ||
57 | |||
diff --git a/noncore/net/wellenreiter/gui/wlan.h b/noncore/net/wellenreiter/gui/wlan.h new file mode 100644 index 0000000..139e218 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/wlan.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #ifndef WLAN_H | ||
17 | #define WLAN_H | ||
18 | |||
19 | class QString; | ||
20 | class CardConfig; | ||
21 | |||
22 | class WLAN | ||
23 | { | ||
24 | public: | ||
25 | |||
26 | WLAN( const QString& interface ); | ||
27 | WLAN( const CardConfig* ); | ||
28 | virtual ~WLAN(); | ||
29 | void setMonitorMode( bool enabled ); | ||
30 | |||
31 | private: | ||
32 | |||
33 | const CardConfig* _configuration; | ||
34 | |||
35 | }; | ||
36 | |||
37 | #endif | ||
38 | |||