author | mickeyl <mickeyl> | 2004-01-08 10:37:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-08 10:37:42 (UTC) |
commit | c1fe58cfdfdb42f75a040442c29defa15c81f626 (patch) (side-by-side diff) | |
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 @@ -21,8 +21,10 @@ #include <opie2/onetwork.h> #ifdef QWS #include <opie2/oapplication.h> #include <opie2/oconfig.h> +#include <opie/odevice.h> +using namespace Opie; #endif /* QT */ #include <qapplication.h> @@ -37,8 +39,10 @@ #include <qtoolbutton.h> #include <qspinbox.h> #include <qtextstream.h> +/* POSIX */ +#include <assert.h> WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) @@ -271,9 +275,15 @@ int WellenreiterConfigWindow::gpsPort() const return useGPS() ? gpsdPort->value() : -1; } -void WellenreiterConfigWindow::performAction( const QString& type ) +void WellenreiterConfigWindow::performAction( const QString& type, + const QString& essid, + const QString& mac, + bool wep, + int channel, + int signal + /* , const GpsLocation& loc */ ) { int action; QString script; @@ -293,22 +303,44 @@ void WellenreiterConfigWindow::performAction( const QString& type ) script = newStationScript->text(); } else { - qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); + qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); return; } qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); - /* - - if ( sound == "Ignore" ) return; - else if ( sound == "Touch" ) ODevice::inst()->touchSound(); - else if ( sound == "Key" ) ODevice::inst()->keySound(); - else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); - - */ + switch( action ) + { + case 0: /* Ignore */ return; + case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; + case 2: /* Play Click */ ODevice::inst()->touchSound(); return; + case 3: /* Blink LED */ break; //FIXME: Implement this + case 4: /* Run Script */ + { + /** + * + * Script Substitution Information: + * + * $SSID = SSID + * $MAC = MAC + * $WEP = Wep + * $CHAN = Channel + * + **/ + script = script.replace( QRegExp( "$SSID" ), essid ); + script = script.replace( QRegExp( "$MAC" ), mac ); + script = script.replace( QRegExp( "$WEP" ), wep ? QString( "true" ) : QString( "false" ) ); + script = script.replace( QRegExp( "$CHAN" ), QString::number( channel ) ); + + qDebug( "going to call script '%s'", (const char*) script ); + ::system( script ); + qDebug( "script returned." ); + return; + } + default: assert( false ); + } } void WellenreiterConfigWindow::load() 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 @@ -16,8 +16,11 @@ #ifndef WELLENREITERCONFIGWINDOW_H #define WELLENREITERCONFIGWINDOW_H #include "configbase.h" +#include "gps.h" + +/* QT */ #include <qmap.h> #include <qcombobox.h> #include <qstring.h> @@ -62,9 +65,9 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase void changedStationAction(int t); void getCaptureFileNameClicked(); void performAutodetection(); void channelAllClicked(int); - void performAction( const QString& ); + void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); protected: void synchronizeActionsAndScripts(); 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 @@ -120,9 +120,9 @@ int main( int argc, char **argv ) { result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); if ( result == QMessageBox::Yes ) { - system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); + ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); } } delete w; 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 @@ -408,9 +408,9 @@ void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, in //============================================================ // MScanListItem //============================================================ -MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, +MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), _channel( channel ), _signal( signal ), _beacons( 1 ) @@ -419,14 +419,14 @@ MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QS qDebug( "creating scanlist item" ); #endif if ( WellenreiterConfigWindow::instance() ) - WellenreiterConfigWindow::instance()->performAction( type ); // better use signal/slot combination here + WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here decorateItem( type, essid, macaddr, wep, channel, signal ); } -MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, +MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, bool wep, int channel, int signal ) :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) { #ifdef DEBUG 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 @@ -67,19 +67,19 @@ class MScanListView: public OListView class MScanListItem: public OListViewItem { public: MScanListItem::MScanListItem( QListView* parent, - QString type = "unknown", - QString essid = "unknown", - QString macaddr = "unknown", + const QString& type = "unknown", + const QString& essid = "unknown", + const QString& macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); MScanListItem::MScanListItem( QListViewItem* parent, - QString type = "unknown", - QString essid = "unknown", - QString macaddr = "unknown", + const QString& type = "unknown", + const QString& essid = "unknown", + const QString& macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); |