Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 98 |
1 files changed, 83 insertions, 15 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 5808e9c..764ef34 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp | |||
@@ -7,46 +7,57 @@ | |||
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 | // Qt | 16 | // Qt |
17 | 17 | ||
18 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
19 | #include <qmessagebox.h> | ||
20 | #include <qcombobox.h> | ||
21 | #include <qspinbox.h> | ||
22 | |||
23 | // Qtopia | ||
24 | |||
25 | #ifdef QWS | ||
26 | #include <qpe/global.h> | ||
27 | #endif | ||
19 | 28 | ||
20 | // Standard | 29 | // Standard |
21 | 30 | ||
22 | #include <assert.h> | 31 | #include <assert.h> |
23 | #include <errno.h> | 32 | #include <errno.h> |
24 | #include <unistd.h> | 33 | #include <unistd.h> |
25 | #include <string.h> | 34 | #include <string.h> |
26 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | #include <stdlib.h> | ||
27 | 37 | ||
28 | // Local | 38 | // Local |
29 | 39 | ||
30 | #include "wellenreiter.h" | 40 | #include "wellenreiter.h" |
31 | #include "scanlistitem.h" | 41 | #include "scanlistitem.h" |
32 | #include "logwindow.h" | 42 | #include "logwindow.h" |
33 | #include "hexwindow.h" | 43 | #include "hexwindow.h" |
44 | #include "configwindow.h" | ||
34 | 45 | ||
35 | #include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! | 46 | #include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! |
36 | #include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! | 47 | #include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! |
37 | #include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! | 48 | #include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! |
38 | 49 | ||
39 | Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) | 50 | Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) |
40 | : WellenreiterBase( parent, name, fl ) | 51 | : WellenreiterBase( parent, name, fl ), daemonRunning( false ) |
41 | { | 52 | { |
42 | 53 | ||
43 | logwindow->log( "(i) Wellenreiter has been started." ); | 54 | logwindow->log( "(i) Wellenreiter has been started." ); |
44 | 55 | ||
45 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); | 56 | connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); |
46 | netview->setColumnWidthMode( 1, QListView::Manual ); | 57 | netview->setColumnWidthMode( 1, QListView::Manual ); |
47 | 58 | ||
48 | // | 59 | // |
49 | // setup socket for daemon communication and start poller | 60 | // setup socket for daemon communication and start poller |
50 | // | 61 | // |
51 | 62 | ||
52 | daemon_fd = commsock( GUIADDR, GUIPORT ); | 63 | daemon_fd = commsock( GUIADDR, GUIPORT ); |
@@ -140,33 +151,33 @@ bool Wellenreiter::hasMessage() | |||
140 | } | 151 | } |
141 | else if ( result == -1 ) | 152 | else if ( result == -1 ) |
142 | { | 153 | { |
143 | qDebug( "selected returned: %s", strerror( errno ) ); | 154 | qDebug( "selected returned: %s", strerror( errno ) ); |
144 | return false; | 155 | return false; |
145 | } | 156 | } |
146 | else | 157 | else |
147 | return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor | 158 | return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor |
148 | } | 159 | } |
149 | 160 | ||
150 | void Wellenreiter::timerEvent( QTimerEvent* e ) | 161 | void Wellenreiter::timerEvent( QTimerEvent* e ) |
151 | { | 162 | { |
152 | qDebug( "checking for message..." ); | 163 | //qDebug( "checking for message..." ); |
153 | if ( hasMessage() ) | 164 | if ( hasMessage() ) |
154 | { | 165 | { |
155 | qDebug( "got message" ); | 166 | //qDebug( "got message from daemon" ); |
156 | handleMessage(); | 167 | handleMessage(); |
157 | } | 168 | } |
158 | else | 169 | else |
159 | { | 170 | { |
160 | qDebug( "no message..." ); | 171 | //qDebug( "no message..." ); |
161 | } | 172 | } |
162 | } | 173 | } |
163 | 174 | ||
164 | void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) | 175 | void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) |
165 | { | 176 | { |
166 | // FIXME: this code belongs in customized QListView, not into this class | 177 | // FIXME: this code belongs in customized QListView, not into this class |
167 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) | 178 | // FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...) |
168 | 179 | ||
169 | qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", | 180 | qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]", |
170 | (const char*) type, | 181 | (const char*) type, |
171 | (const char*) essid, | 182 | (const char*) essid, |
172 | (const char*) macaddr, | 183 | (const char*) macaddr, |
@@ -228,30 +239,87 @@ void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, boo | |||
228 | } | 239 | } |
229 | else | 240 | else |
230 | { | 241 | { |
231 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); | 242 | s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); |
232 | } | 243 | } |
233 | 244 | ||
234 | logwindow->log( s ); | 245 | logwindow->log( s ); |
235 | 246 | ||
236 | } | 247 | } |
237 | 248 | ||
238 | void Wellenreiter::buttonClicked() | 249 | void Wellenreiter::buttonClicked() |
239 | { | 250 | { |
251 | if ( daemonRunning ) | ||
252 | { | ||
253 | logwindow->log( "(i) Daemon has been stopped." ); | ||
254 | button->setText( "Start Scanning" ); | ||
255 | |||
256 | // Stop daemon | ||
257 | |||
258 | // find out pids of wellenreiterd and orinoco_hopper | ||
259 | |||
260 | } | ||
261 | |||
262 | else | ||
263 | { | ||
264 | |||
265 | // get configuration from config window | ||
266 | |||
267 | const QString& interface = configwindow->interfaceName->currentText(); | ||
268 | const QString& cardtype = configwindow->deviceType->currentText(); | ||
269 | const QString& interval = configwindow->hopInterval->cleanText(); | ||
270 | |||
271 | if ( ( interface == "<select>" ) || ( cardtype == "<select>" ) ) | ||
272 | { | ||
273 | QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." ); | ||
274 | return; | ||
275 | } | ||
276 | |||
277 | logwindow->log( "(i) Daemon has been started." ); | ||
278 | button->setText( "Stop Scanning" ); | ||
279 | |||
280 | #ifdef QWS | ||
281 | |||
282 | // set interface into monitor mode | ||
283 | |||
284 | QString cmdline; | ||
285 | |||
286 | cmdline.sprintf( "iwpriv %s monitor 2", (const char*) interface ); | ||
287 | system( cmdline ); | ||
288 | cmdline.sprintf( "iwpriv %s monitor 2 1", (const char*) interface ); | ||
289 | system( cmdline ); | ||
290 | |||
291 | // start channel hopper | ||
292 | |||
293 | cmdline = "orinoco_hopper "; | ||
294 | cmdline += interface; | ||
295 | cmdline += " -i "; | ||
296 | cmdline += interval; | ||
297 | //qDebug( "execute: %s", (const char*) cmdline ); | ||
298 | Global::execute( cmdline ); | ||
299 | |||
300 | // start daemon | ||
301 | |||
302 | cmdline = "wellenreiterd "; | ||
303 | cmdline += interface; | ||
304 | cmdline += " 3"; | ||
305 | //qDebug( "execute: %s", (const char*) cmdline ); | ||
306 | Global::execute( cmdline ); | ||
307 | #endif | ||
240 | 308 | ||
241 | // FIXME: communicate with daemon and set button text according to state | 309 | /* |
242 | 310 | ||
243 | button->setText( "Stop Scanning" ); | 311 | // add some test stations, so that we can see if the GUI part works |
244 | 312 | ||
245 | // add some test stations, so that we can see if the GUI part works | 313 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); |
314 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | ||
315 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); | ||
316 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); | ||
317 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); | ||
246 | 318 | ||
247 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | 319 | QString command ("98"); |
248 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | ||
249 | addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); | ||
250 | addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); | ||
251 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); | ||
252 | |||
253 | QString command ("98"); | ||
254 | 320 | ||
255 | //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); | 321 | //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); |
256 | 322 | ||
323 | */ | ||
324 | } | ||
257 | } | 325 | } |