summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/configwindow.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp50
1 files changed, 41 insertions, 9 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 @@
**
**********************************************************************/
/* LOCAL */
#include "configwindow.h"
#include "mainwindow.h"
/* OPIE */
#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>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qfile.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qmap.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#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 )
:WellenreiterConfigBase( parent, name, true, f )
{
_devicetype[ "cisco" ] = DEVTYPE_CISCO;
_devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
_devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
_devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
_devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
_devicetype[ "<file>" ] = DEVTYPE_FILE;
@@ -263,25 +267,31 @@ const QString WellenreiterConfigWindow::gpsHost() const
{
return useGPS() ? gpsdHost->currentText() : QString::null;
}
int WellenreiterConfigWindow::gpsPort() const
{
bool ok;
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;
if ( type == "network" )
{
action = newNetworkAction->currentItem();
script = newNetworkScript->text();
}
else if ( type == "managed" || type == "adhoc" )
{
action = newClientAction->currentItem();
@@ -291,32 +301,54 @@ void WellenreiterConfigWindow::performAction( const QString& type )
{
action = newStationAction->currentItem();
script = newStationScript->text();
}
else
{
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()
{
#ifdef Q_WS_X11
#warning Persistent Configuration not yet implemented for standalone X11 build
performAutodetection();
#else
qDebug( "loading configuration settings..." );
/* This is dumb monkey typing stuff... We _need_ to do this automatically! */