Diffstat (limited to 'noncore/net/wellenreiter/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/logwindow.cpp | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 81 |
3 files changed, 65 insertions, 23 deletions
diff --git a/noncore/net/wellenreiter/gui/logwindow.cpp b/noncore/net/wellenreiter/gui/logwindow.cpp index dafb429..c355f09 100644 --- a/noncore/net/wellenreiter/gui/logwindow.cpp +++ b/noncore/net/wellenreiter/gui/logwindow.cpp | |||
@@ -23,16 +23,17 @@ MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f ) | |||
23 | ledit = new QMultiLineEdit( this ); | 23 | ledit = new QMultiLineEdit( this ); |
24 | 24 | ||
25 | // FIXME: Set properties( font, read-only, etc...) | 25 | // FIXME: Set properties( font, read-only, etc...) |
26 | 26 | ||
27 | }; | 27 | }; |
28 | 28 | ||
29 | void MLogWindow::log( QString text ) | 29 | void MLogWindow::log( QString text ) |
30 | { | 30 | { |
31 | QTime time = QTime::currentTime(); | 31 | QTime time = QTime::currentTime(); |
32 | QString line; | 32 | QString line; |
33 | line.sprintf( "[%s] %s", (const char*) time.toString(), (const char*) text ); | 33 | line.sprintf( "[%s] %s", (const char*) time.toString(), (const char*) text ); |
34 | ledit->append( line ); | 34 | ledit->append( line ); |
35 | qDebug( line ); | ||
35 | 36 | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | 39 | ||
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index 189a12d..398b42d 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp | |||
@@ -35,25 +35,29 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS | |||
35 | } | 35 | } |
36 | 36 | ||
37 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 37 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, |
38 | bool wep, int channel, int signal ) | 38 | bool wep, int channel, int signal ) |
39 | :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 39 | :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
40 | { | 40 | { |
41 | qDebug( "creating scanlist item" ); | 41 | qDebug( "creating scanlist item" ); |
42 | decorateItem( type, essid, macaddr, wep, channel, signal ); | 42 | decorateItem( type, essid, macaddr, wep, channel, signal ); |
43 | } | 43 | } |
44 | 44 | ||
45 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 45 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
46 | { | 46 | { |
47 | qDebug( "decorating scanlist item" ); | 47 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
48 | (const char*) type, | ||
49 | (const char*) essid, | ||
50 | (const char*) macaddr, | ||
51 | channel ); | ||
48 | 52 | ||
49 | // set icon for managed or adhoc mode | 53 | // set icon for managed or adhoc mode |
50 | QString name; | 54 | QString name; |
51 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 55 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
52 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 56 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
53 | 57 | ||
54 | // set icon for wep (wireless encryption protocol) | 58 | // set icon for wep (wireless encryption protocol) |
55 | if ( wep ) | 59 | if ( wep ) |
56 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); // rename the pixmap! | 60 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); // rename the pixmap! |
57 | 61 | ||
58 | // set channel and signal text | 62 | // set channel and signal text |
59 | 63 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 9c8630f..6d62fa8 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -10,24 +10,25 @@ | |||
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 | // Qt | 16 | // Qt |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | 19 | ||
20 | // Standard | 20 | // Standard |
21 | 21 | ||
22 | #include <assert.h> | ||
22 | #include <unistd.h> | 23 | #include <unistd.h> |
23 | #include <sys/types.h> | 24 | #include <sys/types.h> |
24 | 25 | ||
25 | // Local | 26 | // Local |
26 | 27 | ||
27 | #include "wellenreiter.h" | 28 | #include "wellenreiter.h" |
28 | #include "scanlistitem.h" | 29 | #include "scanlistitem.h" |
29 | #include "logwindow.h" | 30 | #include "logwindow.h" |
30 | #include "hexwindow.h" | 31 | #include "hexwindow.h" |
31 | 32 | ||
32 | #include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! | 33 | #include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! |
33 | #include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! | 34 | #include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! |
@@ -75,46 +76,45 @@ void Wellenreiter::handleMessage() | |||
75 | 76 | ||
76 | /* | 77 | /* |
77 | typedef struct { | 78 | typedef struct { |
78 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc | 79 | int net_type; 1 = Accesspoint ; 2 = Ad-Hoc |
79 | int ssid_len; Length of SSID | 80 | int ssid_len; Length of SSID |
80 | int channel; Channel | 81 | int channel; Channel |
81 | int wep; 1 = WEP enabled ; 0 = disabled | 82 | int wep; 1 = WEP enabled ; 0 = disabled |
82 | char mac[64]; MAC address of Accesspoint | 83 | char mac[64]; MAC address of Accesspoint |
83 | char bssid[128]; BSSID of Accesspoint | 84 | char bssid[128]; BSSID of Accesspoint |
84 | } wl_network_t; | 85 | } wl_network_t; |
85 | */ | 86 | */ |
86 | 87 | ||
87 | qDebug( "Sniffer sent: '%s'", (const char*) &buffer ); | 88 | // qDebug( "Sniffer sent: '%s'", (const char*) buffer ); |
88 | hexwindow->log( (const char*) &buffer ); | 89 | hexwindow->log( (const char*) &buffer ); |
89 | 90 | ||
90 | if ( result == NETFOUND ) /* new network found */ | 91 | if ( result == NETFOUND ) /* new network found */ |
91 | { | 92 | { |
92 | logwindow->log( "(i) found new network" ); | ||
93 | qDebug( "Sniffer said: new network found." ); | 93 | qDebug( "Sniffer said: new network found." ); |
94 | wl_network_t n; | 94 | wl_network_t n; |
95 | get_network_found( &n, (char*) &buffer ); | 95 | get_network_found( &n, (char*) &buffer ); |
96 | 96 | ||
97 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); | 97 | qDebug( "Sniffer said: net_type is %d.", n.net_type ); |
98 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); | 98 | qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); |
99 | 99 | ||
100 | //n.bssid[n.ssid_len] = "\0"; | 100 | //n.bssid[n.ssid_len] = "\0"; |
101 | 101 | ||
102 | QString type; | 102 | QString type; |
103 | 103 | ||
104 | if ( n.net_type == 1 ) | 104 | if ( n.net_type == 1 ) |
105 | type = "managed"; | 105 | type = "managed"; |
106 | else | 106 | else |
107 | type = "adhoc"; | 107 | type = "adhoc"; |
108 | 108 | ||
109 | addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); | 109 | addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | else | 113 | else |
114 | 114 | ||
115 | { | 115 | { |
116 | qDebug( "unknown sniffer command." ); | 116 | qDebug( "unknown sniffer command." ); |
117 | } | 117 | } |
118 | 118 | ||
119 | } | 119 | } |
120 | 120 | ||
@@ -129,72 +129,109 @@ bool Wellenreiter::hasMessage() | |||
129 | FD_SET( daemon_fd, &rfds ); | 129 | FD_SET( daemon_fd, &rfds ); |
130 | struct timeval tv; | 130 | struct timeval tv; |
131 | tv.tv_sec = 0; | 131 | tv.tv_sec = 0; |
132 | tv.tv_usec = 10; | 132 | tv.tv_usec = 10; |
133 | int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); | 133 | int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); |
134 | return FD_ISSET( daemon_fd, &rfds ); | 134 | return FD_ISSET( daemon_fd, &rfds ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void Wellenreiter::timerEvent( QTimerEvent* e ) | 137 | void Wellenreiter::timerEvent( QTimerEvent* e ) |
138 | { | 138 | { |
139 | qDebug( "checking for message..." ); | 139 | qDebug( "checking for message..." ); |
140 | 140 | ||
141 | if ( hasMessage() ) | 141 | int result = hasMessage(); |
142 | qDebug( "hasMessage() returned %d", result ); | ||
143 | |||
144 | if ( result ) | ||
142 | { | 145 | { |
143 | handleMessage(); | 146 | handleMessage(); |
144 | } | 147 | } |
145 | else | 148 | else |
146 | { | 149 | { |
147 | qDebug( "no message :(" ); | 150 | qDebug( "no message :(" ); |
148 | } | 151 | } |
149 | } | 152 | } |
150 | 153 | ||
151 | void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 154 | void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
152 | { | 155 | { |
153 | // FIXME: this code belongs in customized QListView, not into this class | 156 | // FIXME: this code belongs in customized QListView, not into this class |
157 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | ||
154 | 158 | ||
155 | // search, if we had an item with this essid once before | 159 | qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", |
156 | 160 | (const char*) type, | |
157 | //MScanListItem* item = dynamic_cast<MScanListItem*>( netview->firstChild() ); | 161 | (const char*) essid, |
158 | MScanListItem* item = static_cast<MScanListItem*>( netview->firstChild() ); | 162 | (const char*) macaddr, |
163 | channel ); | ||
164 | |||
165 | // search, if we already have seen this net | ||
166 | |||
167 | QString s; | ||
168 | MScanListItem* network; | ||
169 | MScanListItem* item = (MScanListItem*) netview->firstChild(); | ||
159 | 170 | ||
160 | while ( item && ( item->text( 0 ) != essid ) ) | 171 | while ( item && ( item->text( 0 ) != essid ) ) |
161 | { | 172 | { |
162 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); | 173 | qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); |
163 | item = dynamic_cast<MScanListItem*>( item->itemBelow() ); | 174 | item = item->itemBelow(); |
164 | } | 175 | } |
165 | if ( item ) | 176 | if ( item ) |
166 | { | 177 | { |
167 | qDebug( "found!" ); | 178 | // we have already seen this net, check all childs if MAC exists |
168 | 179 | ||
169 | // check, if it is the same item (based on MACaddr) | 180 | network = item; |
170 | 181 | ||
171 | if ( macaddr == item->text( 2 ) ) | 182 | item = item->firstChild(); |
183 | assert( item ); // this shouldn't fail | ||
184 | |||
185 | while ( item && ( item->text( 2 ) != macaddr ) ) | ||
172 | { | 186 | { |
173 | qDebug( "already had item with mac %s", (const char*) item->text( 2 ) ); | 187 | qDebug( "subitemtext: %s", (const char*) item->text( 2 ) ); |
174 | return; | 188 | item = item->itemBelow(); |
175 | } | 189 | } |
176 | |||
177 | // another item belonging to the same net, so: insert the new item as child | ||
178 | 190 | ||
179 | new MScanListItem( item, type, essid, macaddr, wep, channel, signal ); | 191 | if ( item ) |
192 | { | ||
193 | // we have already seen this item, it's a dupe | ||
194 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | ||
195 | return; | ||
196 | } | ||
180 | } | 197 | } |
181 | |||
182 | else | 198 | else |
183 | { | 199 | { |
184 | qDebug( "inserting new network" ); | 200 | s.sprintf( "(i) new network: '%s'", (const char*) essid ); |
185 | MScanListItem* network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); | 201 | logwindow->log( s ); |
202 | |||
203 | network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); | ||
204 | } | ||
205 | |||
206 | |||
207 | // insert new station as child from network | ||
208 | |||
209 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | ||
210 | |||
211 | qDebug( "inserting new station %s", (const char*) macaddr ); | ||
186 | 212 | ||
187 | new MScanListItem( network, type, essid, macaddr, wep, channel, signal ); | 213 | new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
214 | |||
215 | if ( type == "managed" ) | ||
216 | { | ||
217 | s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | ||
188 | } | 222 | } |
223 | |||
224 | logwindow->log( s ); | ||
225 | |||
189 | } | 226 | } |
190 | 227 | ||
191 | void Wellenreiter::buttonClicked() | 228 | void Wellenreiter::buttonClicked() |
192 | { | 229 | { |
193 | 230 | ||
194 | // FIXME: communicate with daemon and set button text according to state | 231 | // FIXME: communicate with daemon and set button text according to state |
195 | 232 | ||
196 | button->setText( "Stop Scanning" ); | 233 | button->setText( "Stop Scanning" ); |
197 | 234 | ||
198 | // add some test stations, so that we can see if the GUI part works | 235 | // add some test stations, so that we can see if the GUI part works |
199 | 236 | ||
200 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | 237 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); |