Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 78 |
1 files changed, 73 insertions, 5 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 | |||
@@ -16,6 +16,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 | ||
@@ -24,6 +33,7 @@ | |||
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 | ||
@@ -31,13 +41,14 @@ | |||
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." ); |
@@ -149,15 +160,15 @@ bool Wellenreiter::hasMessage() | |||
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 | ||
@@ -237,11 +248,66 @@ void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, boo | |||
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 | ||
240 | 266 | ||
241 | // FIXME: communicate with daemon and set button text according to state | 267 | const QString& interface = configwindow->interfaceName->currentText(); |
268 | const QString& cardtype = configwindow->deviceType->currentText(); | ||
269 | const QString& interval = configwindow->hopInterval->cleanText(); | ||
242 | 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." ); | ||
243 | button->setText( "Stop Scanning" ); | 278 | button->setText( "Stop Scanning" ); |
244 | 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 | ||
308 | |||
309 | /* | ||
310 | |||
245 | // add some test stations, so that we can see if the GUI part works | 311 | // add some test stations, so that we can see if the GUI part works |
246 | 312 | ||
247 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); | 313 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); |
@@ -254,4 +320,6 @@ void Wellenreiter::buttonClicked() | |||
254 | 320 | ||
255 | //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); | 321 | //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); |
256 | 322 | ||
323 | */ | ||
324 | } | ||
257 | } | 325 | } |