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 | |||
@@ -13,34 +13,45 @@ | |||
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 ); |
@@ -146,21 +157,21 @@ bool Wellenreiter::hasMessage() | |||
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 |
@@ -234,24 +245,81 @@ void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, boo | |||
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 | ||
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 ); |
248 | addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); | 314 | 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 ); | 315 | 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 ); | 316 | 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 ); | 317 | addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); |
252 | 318 | ||
253 | QString command ("98"); | 319 | 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 | } |