author | mickeyl <mickeyl> | 2004-01-08 10:37:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-08 10:37:42 (UTC) |
commit | c1fe58cfdfdb42f75a040442c29defa15c81f626 (patch) (unidiff) | |
tree | 69c3e3c441af1ef933b73984e0c1a6778f8dc672 | |
parent | 05d47b2603adfab0e16f7395e34b7aa56ce6d8de (diff) | |
download | opie-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.
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 52 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 12 |
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 | |||
@@ -23,4 +23,6 @@ | |||
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> | ||
26 | using namespace Opie; | ||
25 | #endif | 27 | #endif |
26 | 28 | ||
@@ -39,4 +41,6 @@ | |||
39 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
40 | 42 | ||
43 | /* POSIX */ | ||
44 | #include <assert.h> | ||
41 | 45 | ||
42 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; | 46 | WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; |
@@ -273,5 +277,11 @@ int WellenreiterConfigWindow::gpsPort() const | |||
273 | 277 | ||
274 | 278 | ||
275 | void WellenreiterConfigWindow::performAction( const QString& type ) | 279 | void 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; |
@@ -295,5 +305,5 @@ void WellenreiterConfigWindow::performAction( const QString& type ) | |||
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 | } |
@@ -301,12 +311,34 @@ void WellenreiterConfigWindow::performAction( const QString& type ) | |||
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 | ||
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 | |||
@@ -18,4 +18,7 @@ | |||
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> |
@@ -64,5 +67,5 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase | |||
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: |
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 | |||
@@ -122,5 +122,5 @@ int main( int argc, char **argv ) | |||
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 | } |
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 | |||
@@ -410,5 +410,5 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in | |||
410 | //============================================================ | 410 | //============================================================ |
411 | 411 | ||
412 | MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, | 412 | MScanListItem::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 ), |
@@ -421,10 +421,10 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS | |||
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 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, | 428 | MScanListItem::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 ) |
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 | |||
@@ -69,7 +69,7 @@ class MScanListItem: public OListViewItem | |||
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, |
@@ -77,7 +77,7 @@ class MScanListItem: public OListViewItem | |||
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, |