author | mickeyl <mickeyl> | 2003-05-07 21:53:35 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-07 21:53:35 (UTC) |
commit | 3d150d3dceb6f66930d487958af95a169462ea84 (patch) (side-by-side diff) | |
tree | f93c5754689afebb5be8e2affa57517a4bb4a825 /noncore/net/wellenreiter/gui/wellenreiter.cpp | |
parent | 8344bbd32ca4ebfef275746de29cb3109b013cb6 (diff) | |
download | opie-3d150d3dceb6f66930d487958af95a169462ea84.zip opie-3d150d3dceb6f66930d487958af95a169462ea84.tar.gz opie-3d150d3dceb6f66930d487958af95a169462ea84.tar.bz2 |
first half of event system completed
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 75 |
1 files changed, 64 insertions, 11 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 2f3d093..edf7dcf 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -10,12 +10,24 @@ ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ***********************************************************************/ +// Local + +#include "wellenreiter.h" +#include "scanlist.h" +#include "logwindow.h" +#include "hexwindow.h" +#include "configwindow.h" +#include "statwindow.h" +#include "graphwindow.h" +#include "manufacturers.h" +#include "protolistview.h" + // Opie #ifdef QWS #include <opie/odevice.h> using namespace Opie; #endif @@ -33,12 +45,13 @@ using namespace Opie; #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmessagebox.h> +#include <qobjectlist.h> #include <qregexp.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qmainwindow.h> // Standard @@ -47,23 +60,12 @@ using namespace Opie; #include <errno.h> #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> -// Local - -#include "wellenreiter.h" -#include "scanlist.h" -#include "logwindow.h" -#include "hexwindow.h" -#include "configwindow.h" -#include "statwindow.h" -#include "graphwindow.h" -#include "manufacturers.h" - Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), manufacturerdb( 0 ), configwindow( 0 ) { // @@ -134,12 +136,36 @@ void Wellenreiter::channelHopped(int c) //title.append( QString().sprintf( " %02d", c ) ); assert( parent() ); ( (QMainWindow*) parent() )->setCaption( title ); } +void Wellenreiter::handleNotification( OPacket* p ) +{ + QObjectList* l = p->queryList(); + QObjectListIt it( *l ); + QObject* o; + + while ( (o = it.current()) != 0 ) + { + QString name = it.current()->name(); + if ( configwindow->parsePackets->isProtocolChecked( name ) ) + { + QString action = configwindow->parsePackets->protocolAction( name ); + qDebug( "action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); + doAction( action, name, p ); + } + else + { + qDebug( "protocol '%s' not checked.", (const char*) name ); + } + ++it; + } +} + + void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) { QString type; if ( beacon->canIBSS() ) { type = "adhoc"; @@ -242,16 +268,24 @@ void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) { qDebug( "Received IP packet." ); } } +QObject* childIfToParse( OPacket* p, const QString& protocol ) +{ + //FIXME: Implement +} + + void Wellenreiter::receivePacket( OPacket* p ) { hexWindow()->log( p->dump( 8 ) ); + handleNotification( p ); + // check if we received a beacon frame OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( p->child( "802.11 Management" ) ); if ( beacon && beacon->managementType() == "Beacon" ) { handleBeacon( p, beacon ); return; @@ -428,6 +462,25 @@ void Wellenreiter::timerEvent( QTimerEvent* ) { receivePacket( p ); delete p; } } + +void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) +{ + if ( action == "TouchSound" ) + ODevice::inst()->touchSound(); + else if ( action == "AlarmSound" ) + ODevice::inst()->alarmSound(); + else if ( action == "KeySound" ) + ODevice::inst()->keySound(); + else if ( action == "LedOn" ) + ODevice::inst()->setLedState( Led_Mail, Led_On ); + else if ( action == "LedOff" ) + ODevice::inst()->setLedState( Led_Mail, Led_Off ); + else if ( action == "LogMessage" ) + logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); + else if ( action == "MessageBox" ) + QMessageBox::information ( this, "Notification!", + QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); +} |