summaryrefslogtreecommitdiff
path: root/noncore
authormickeyl <mickeyl>2004-01-08 10:37:42 (UTC)
committer mickeyl <mickeyl>2004-01-08 10:37:42 (UTC)
commitc1fe58cfdfdb42f75a040442c29defa15c81f626 (patch) (unidiff)
tree69c3e3c441af1ef933b73984e0c1a6778f8dc672 /noncore
parent05d47b2603adfab0e16f7395e34b7aa56ce6d8de (diff)
downloadopie-c1fe58cfdfdb42f75a040442c29defa15c81f626.zip
opie-c1fe58cfdfdb42f75a040442c29defa15c81f626.tar.gz
opie-c1fe58cfdfdb42f75a040442c29defa15c81f626.tar.bz2
Calling scripts on new {Network, Client, Station} works now. Possible substitution
values are $SSID, $MAC, $WEP, $CHAN.
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp52
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.h5
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp2
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp6
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h12
5 files changed, 56 insertions, 21 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 1341d03..7f39230 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -13,40 +13,44 @@
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/onetwork.h> 21#include <opie2/onetwork.h>
22#ifdef QWS 22#ifdef QWS
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h> 24#include <opie2/oconfig.h>
25#include <opie/odevice.h>
26using namespace Opie;
25#endif 27#endif
26 28
27/* QT */ 29/* QT */
28#include <qapplication.h> 30#include <qapplication.h>
29#include <qcheckbox.h> 31#include <qcheckbox.h>
30#include <qcombobox.h> 32#include <qcombobox.h>
31#include <qfile.h> 33#include <qfile.h>
32#include <qlineedit.h> 34#include <qlineedit.h>
33#include <qlayout.h> 35#include <qlayout.h>
34#include <qmap.h> 36#include <qmap.h>
35#include <qpushbutton.h> 37#include <qpushbutton.h>
36#include <qtabwidget.h> 38#include <qtabwidget.h>
37#include <qtoolbutton.h> 39#include <qtoolbutton.h>
38#include <qspinbox.h> 40#include <qspinbox.h>
39#include <qtextstream.h> 41#include <qtextstream.h>
40 42
43/* POSIX */
44#include <assert.h>
41 45
42WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 46WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
43 47
44WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 48WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
45 :WellenreiterConfigBase( parent, name, true, f ) 49 :WellenreiterConfigBase( parent, name, true, f )
46{ 50{
47 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 51 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
48 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 52 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
49 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 53 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
50 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 54 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
51 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 55 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
52 _devicetype[ "<file>" ] = DEVTYPE_FILE; 56 _devicetype[ "<file>" ] = DEVTYPE_FILE;
@@ -263,60 +267,88 @@ const QString WellenreiterConfigWindow::gpsHost() const
263{ 267{
264 return useGPS() ? gpsdHost->currentText() : QString::null; 268 return useGPS() ? gpsdHost->currentText() : QString::null;
265} 269}
266 270
267 271
268int WellenreiterConfigWindow::gpsPort() const 272int WellenreiterConfigWindow::gpsPort() const
269{ 273{
270 bool ok; 274 bool ok;
271 return useGPS() ? gpsdPort->value() : -1; 275 return useGPS() ? gpsdPort->value() : -1;
272} 276}
273 277
274 278
275void WellenreiterConfigWindow::performAction( const QString& type ) 279void WellenreiterConfigWindow::performAction( const QString& type,
280 const QString& essid,
281 const QString& mac,
282 bool wep,
283 int channel,
284 int signal
285 /* , const GpsLocation& loc */ )
276{ 286{
277 int action; 287 int action;
278 QString script; 288 QString script;
279 289
280 if ( type == "network" ) 290 if ( type == "network" )
281 { 291 {
282 action = newNetworkAction->currentItem(); 292 action = newNetworkAction->currentItem();
283 script = newNetworkScript->text(); 293 script = newNetworkScript->text();
284 } 294 }
285 else if ( type == "managed" || type == "adhoc" ) 295 else if ( type == "managed" || type == "adhoc" )
286 { 296 {
287 action = newClientAction->currentItem(); 297 action = newClientAction->currentItem();
288 script = newClientScript->text(); 298 script = newClientScript->text();
289 } 299 }
290 else if ( type == "station" ) 300 else if ( type == "station" )
291 { 301 {
292 action = newStationAction->currentItem(); 302 action = newStationAction->currentItem();
293 script = newStationScript->text(); 303 script = newStationScript->text();
294 } 304 }
295 else 305 else
296 { 306 {
297 qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); 307 qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type );
298 return; 308 return;
299 } 309 }
300 310
301 qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); 311 qDebug( "going to perform action %d (script='%s')", action, (const char*) script );
302 312
303 /* 313 switch( action )
304 314 {
305 if ( sound == "Ignore" ) return; 315 case 0: /* Ignore */ return;
306 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 316 case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return;
307 else if ( sound == "Key" ) ODevice::inst()->keySound(); 317 case 2: /* Play Click */ ODevice::inst()->touchSound(); return;
308 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 318 case 3: /* Blink LED */ break; //FIXME: Implement this
309 319 case 4: /* Run Script */
310 */ 320 {
321 /**
322 *
323 * Script Substitution Information:
324 *
325 * $SSID = SSID
326 * $MAC = MAC
327 * $WEP = Wep
328 * $CHAN = Channel
329 *
330 **/
331 script = script.replace( QRegExp( "$SSID" ), essid );
332 script = script.replace( QRegExp( "$MAC" ), mac );
333 script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) );
334 script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) );
335
336 qDebug( "going to call script '%s'", (const char*) script );
337 ::system( script );
338 qDebug( "script returned." );
339 return;
340 }
341 default: assert( false );
342 }
311} 343}
312 344
313 345
314void WellenreiterConfigWindow::load() 346void WellenreiterConfigWindow::load()
315{ 347{
316#ifdef Q_WS_X11 348#ifdef Q_WS_X11
317 #warning Persistent Configuration not yet implemented for standalone X11 build 349 #warning Persistent Configuration not yet implemented for standalone X11 build
318 performAutodetection(); 350 performAutodetection();
319#else 351#else
320 qDebug( "loading configuration settings..." ); 352 qDebug( "loading configuration settings..." );
321 353
322 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */ 354 /* This is dumb monkey typing stuff... We _need_ to do this automatically! */
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h
index b082331..5c998cb 100644
--- a/noncore/net/wellenreiter/gui/configwindow.h
+++ b/noncore/net/wellenreiter/gui/configwindow.h
@@ -8,24 +8,27 @@
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#ifndef WELLENREITERCONFIGWINDOW_H 16#ifndef WELLENREITERCONFIGWINDOW_H
17#define WELLENREITERCONFIGWINDOW_H 17#define WELLENREITERCONFIGWINDOW_H
18 18
19#include "configbase.h" 19#include "configbase.h"
20#include "gps.h"
21
22/* QT */
20#include <qmap.h> 23#include <qmap.h>
21#include <qcombobox.h> 24#include <qcombobox.h>
22#include <qstring.h> 25#include <qstring.h>
23 26
24const int DEVTYPE_SELECT = 0; 27const int DEVTYPE_SELECT = 0;
25const int DEVTYPE_CISCO = 1; 28const int DEVTYPE_CISCO = 1;
26const int DEVTYPE_WLAN_NG = 2; 29const int DEVTYPE_WLAN_NG = 2;
27const int DEVTYPE_HOSTAP = 3; 30const int DEVTYPE_HOSTAP = 3;
28const int DEVTYPE_ORINOCO = 4; 31const int DEVTYPE_ORINOCO = 4;
29const int DEVTYPE_MANUAL = 5; 32const int DEVTYPE_MANUAL = 5;
30const int DEVTYPE_FILE = 6; 33const int DEVTYPE_FILE = 6;
31 34
@@ -54,25 +57,25 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase
54 57
55 void save(); 58 void save();
56 void load(); 59 void load();
57 60
58 public slots: 61 public slots:
59 void changedDeviceType(int); 62 void changedDeviceType(int);
60 void changedNetworkAction(int t); 63 void changedNetworkAction(int t);
61 void changedClientAction(int t); 64 void changedClientAction(int t);
62 void changedStationAction(int t); 65 void changedStationAction(int t);
63 void getCaptureFileNameClicked(); 66 void getCaptureFileNameClicked();
64 void performAutodetection(); 67 void performAutodetection();
65 void channelAllClicked(int); 68 void channelAllClicked(int);
66 void performAction( const QString& ); 69 void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ );
67 70
68 protected: 71 protected:
69 void synchronizeActionsAndScripts(); 72 void synchronizeActionsAndScripts();
70 73
71 protected: 74 protected:
72 QMap<QString, int> _devicetype; 75 QMap<QString, int> _devicetype;
73 static WellenreiterConfigWindow* _instance; 76 static WellenreiterConfigWindow* _instance;
74 int _guess; 77 int _guess;
75 78
76}; 79};
77 80
78#endif 81#endif
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index dd757b5..702a7cc 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -112,20 +112,20 @@ int main( int argc, char **argv )
112 } 112 }
113 113
114 a.exec(); 114 a.exec();
115 115
116 if ( check ) 116 if ( check )
117 { 117 {
118 118
119 if ( killed ) 119 if ( killed )
120 { 120 {
121 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); 121 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No );
122 if ( result == QMessageBox::Yes ) 122 if ( result == QMessageBox::Yes )
123 { 123 {
124 system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); 124 ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) );
125 } 125 }
126 } 126 }
127 127
128 delete w; 128 delete w;
129 } 129 }
130 return 0; 130 return 0;
131} 131}
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 470646d..aea7eb6 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -400,41 +400,41 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in
400 QPopupMenu m( this ); 400 QPopupMenu m( this );
401 m.insertItem( entry, 37773, 0 ); 401 m.insertItem( entry, 37773, 0 );
402 int result = m.exec( QCursor::pos() ); 402 int result = m.exec( QCursor::pos() );
403 if ( result == 37773 ) 403 if ( result == 37773 )
404 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); 404 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
405 } 405 }
406} 406}
407 407
408//============================================================ 408//============================================================
409// MScanListItem 409// MScanListItem
410//============================================================ 410//============================================================
411 411
412MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 412MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr,
413 bool wep, int channel, int signal ) 413 bool wep, int channel, int signal )
414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 414 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 415 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
416 _channel( channel ), _signal( signal ), _beacons( 1 ) 416 _channel( channel ), _signal( signal ), _beacons( 1 )
417{ 417{
418 #ifdef DEBUG 418 #ifdef DEBUG
419 qDebug( "creating scanlist item" ); 419 qDebug( "creating scanlist item" );
420 #endif 420 #endif
421 421
422 if ( WellenreiterConfigWindow::instance() ) 422 if ( WellenreiterConfigWindow::instance() )
423 WellenreiterConfigWindow::instance()->performAction( type ); // better use signal/slot combination here 423 WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here
424 424
425 decorateItem( type, essid, macaddr, wep, channel, signal ); 425 decorateItem( type, essid, macaddr, wep, channel, signal );
426} 426}
427 427
428MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 428MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr,
429 bool wep, int channel, int signal ) 429 bool wep, int channel, int signal )
430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 430 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
431{ 431{
432 #ifdef DEBUG 432 #ifdef DEBUG
433 qDebug( "creating scanlist item" ); 433 qDebug( "creating scanlist item" );
434 #endif 434 #endif
435 decorateItem( type, essid, macaddr, wep, channel, signal ); 435 decorateItem( type, essid, macaddr, wep, channel, signal );
436} 436}
437 437
438const QString& MScanListItem::essid() const 438const QString& MScanListItem::essid() const
439{ 439{
440 if ( type == "network" ) 440 if ( type == "network" )
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index 42f35c2..e8d48c3 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -59,35 +59,35 @@ class MScanListView: public OListView
59 59
60 protected: 60 protected:
61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" );
62 62
63}; 63};
64 64
65//****************************** MScanListItem **************************************************************** 65//****************************** MScanListItem ****************************************************************
66 66
67class MScanListItem: public OListViewItem 67class MScanListItem: public OListViewItem
68{ 68{
69 public: 69 public:
70 MScanListItem::MScanListItem( QListView* parent, 70 MScanListItem::MScanListItem( QListView* parent,
71 QString type = "unknown", 71 const QString& type = "unknown",
72 QString essid = "unknown", 72 const QString& essid = "unknown",
73 QString macaddr = "unknown", 73 const QString& macaddr = "unknown",
74 bool wep = false, 74 bool wep = false,
75 int channel = 0, 75 int channel = 0,
76 int signal = 0 ); 76 int signal = 0 );
77 77
78 MScanListItem::MScanListItem( QListViewItem* parent, 78 MScanListItem::MScanListItem( QListViewItem* parent,
79 QString type = "unknown", 79 const QString& type = "unknown",
80 QString essid = "unknown", 80 const QString& essid = "unknown",
81 QString macaddr = "unknown", 81 const QString& macaddr = "unknown",
82 bool wep = false, 82 bool wep = false,
83 int channel = 0, 83 int channel = 0,
84 int signal = 0 ); 84 int signal = 0 );
85 85
86 86
87 protected: 87 protected:
88 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 88 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
89 89
90 public: 90 public:
91 QString type; 91 QString type;
92 92
93 public: 93 public: