-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 89 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 12 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/statwindow.cpp | 45 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/statwindow.h | 40 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 40 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 13 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.h | 2 |
9 files changed, 199 insertions, 54 deletions
diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 5970b01..08eb18a 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -12,2 +12,3 @@ HEADERS = wellenreiterbase.h \ hexwindow.h \ + statwindow.h \ configwindow.h \ @@ -22,2 +23,3 @@ SOURCES = main.cpp \ hexwindow.cpp \ + statwindow.cpp \ configwindow.cpp \ diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 69d2b3a..94e3f28 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -62,10 +62,4 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); - #ifdef QWS - searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); - cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); - #else - startStopIconSet = new QIconSet(); - startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); - startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); - #endif + startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); + stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); @@ -73,15 +67,17 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n - startStopButton = new QToolButton( 0 ); + startButton = new QToolButton( 0 ); #ifdef QWS - startStopButton->setAutoRaise( true ); + startButton->setAutoRaise( true ); #endif + startButton->setIconSet( *startIconSet ); + startButton->setEnabled( false ); + connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); + + stopButton = new QToolButton( 0 ); #ifdef QWS - startStopButton->setOnIconSet( *cancelIconSet ); - startStopButton->setOffIconSet( *searchIconSet ); - #else - startStopButton->setIconSet( *startStopIconSet ); + stopButton->setAutoRaise( true ); #endif - startStopButton->setToggleButton( true ); - connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); - startStopButton->setEnabled( false ); + stopButton->setIconSet( *stopIconSet ); + stopButton->setEnabled( false ); + connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); @@ -127,4 +123,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n QPopupMenu* sniffer = new QPopupMenu( mb ); - sniffer->insertItem( "&Configure..." ); + sniffer->insertItem( "&Configure...", this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); + startID = sniffer->insertItem( "&Start", mw, SLOT( startClicked() ) ); + sniffer->setItemEnabled( startID, false ); + stopID = sniffer->insertItem( "Sto&p", mw, SLOT( stopClicked() ) ); + sniffer->setItemEnabled( stopID, false ); @@ -137,3 +137,2 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n id = mb->insertItem( "&Sniffer", sniffer ); - mb->setItemEnabled( id, false ); id = mb->insertItem( "&Demo", demo ); @@ -142,3 +141,4 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n #ifdef QWS - mb->insertItem( startStopButton ); + mb->insertItem( startButton ); + mb->insertItem( stopButton ); mb->insertItem( c ); @@ -148,5 +148,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n mb->insertItem( c ); - mb->insertItem( startStopButton ); + mb->insertItem( stopButton ); + mb->insertItem( startButton ); #endif + updateToolButtonState(); + // setup status bar (for now only on X11) @@ -157,4 +160,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n + connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); + connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; + + void WellenreiterMainWindow::showConfigure() @@ -168,6 +175,9 @@ void WellenreiterMainWindow::showConfigure() - if ( result ) - { - // check configuration from config window + if ( result ) updateToolButtonState(); +} + + +void WellenreiterMainWindow::updateToolButtonState() +{ const QString& interface = cw->interfaceName->currentText(); @@ -177,7 +187,10 @@ void WellenreiterMainWindow::showConfigure() if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) - startStopButton->setEnabled( true ); - //TODO ... + { + startButton->setEnabled( true ); + menuBar()->setItemEnabled( startID, true ); + } else - startStopButton->setEnabled( false ); - //TODO ... + { + startButton->setEnabled( false ); + menuBar()->setItemEnabled( startID, false ); } @@ -185,14 +198,18 @@ void WellenreiterMainWindow::showConfigure() -WellenreiterMainWindow::~WellenreiterMainWindow() + +void WellenreiterMainWindow::changedSniffingState() { + startButton->setEnabled( !mw->sniffing ); + menuBar()->setItemEnabled( startID, !mw->sniffing ); + stopButton->setEnabled( mw->sniffing ); + menuBar()->setItemEnabled( stopID, mw->sniffing ); +} + +WellenreiterMainWindow::~WellenreiterMainWindow() +{ delete infoIconSet; delete settingsIconSet; - #ifdef QWS - delete searchIconSet; - delete cancelIconSet; - #else - delete startStopIconSet; - #endif - + delete startIconSet; + delete stopIconSet; }; diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 1b08c5b..1e191e5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h @@ -37,9 +37,11 @@ class WellenreiterMainWindow: public QMainWindow - QIconSet* startStopIconSet; - const QIconSet* searchIconSet; + const QIconSet* startIconSet; + const QIconSet* stopIconSet; const QIconSet* infoIconSet; const QIconSet* settingsIconSet; - const QIconSet* cancelIconSet; - QToolButton* startStopButton; + QToolButton* startButton; + QToolButton* stopButton; + int startID; + int stopID; @@ -47,2 +49,3 @@ class WellenreiterMainWindow: public QMainWindow virtual void closeEvent( QCloseEvent* ); + void updateToolButtonState(); @@ -59,2 +62,3 @@ class WellenreiterMainWindow: public QMainWindow void fileNew(); + void changedSniffingState(); }; diff --git a/noncore/net/wellenreiter/gui/statwindow.cpp b/noncore/net/wellenreiter/gui/statwindow.cpp new file mode 100644 index 0000000..07d34ef --- a/dev/null +++ b/noncore/net/wellenreiter/gui/statwindow.cpp @@ -0,0 +1,45 @@ +/********************************************************************** +** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. +** +** This file is part of Opie Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ + +#include "statwindow.h" +#include <qmultilineedit.h> + +MStatWindow::MStatWindow( QWidget * parent, const char * name, WFlags f ) + :QVBox( parent, name, f ) +{ + ledit = new QMultiLineEdit( this ); + ledit->setFont( QFont( "fixed", 10 ) ); + + // FIXME: Set properties( font, read-only, etc...) + +}; + +void MStatWindow::log( QString text ) +{ + + ledit->append( text ); + +}; + +const QString MStatWindow::getLog() const +{ + return ledit->text(); +} + +void MStatWindow::clear() +{ + ledit->clear(); +} + diff --git a/noncore/net/wellenreiter/gui/statwindow.h b/noncore/net/wellenreiter/gui/statwindow.h new file mode 100644 index 0000000..bbdf777 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/statwindow.h @@ -0,0 +1,40 @@ +/********************************************************************** +** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. +** +** This file is part of Opie Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +**********************************************************************/ + +#ifndef STATWINDOW_H +#define STATWINDOW_H + +#include <qvbox.h> + +class QString; +class QMultiLineEdit; + +class MStatWindow: public QVBox +{ + + public: + MStatWindow( QWidget * parent = 0, const char * name = "MStatWindow", WFlags f = 0 ); + + void log( QString text ); + const QString getLog() const; + void clear(); + + protected: + QMultiLineEdit* ledit; + +}; + +#endif + diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 0bfc8e9..3372883 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -36,2 +36,3 @@ using namespace Opie; #include <qspinbox.h> +#include <qtoolbutton.h> #include <qmainwindow.h> @@ -54,3 +55,3 @@ using namespace Opie; #include "configwindow.h" - +#include "statwindow.h" #include "manufacturers.h" @@ -219,5 +220,4 @@ void Wellenreiter::receivePacket(OPacket* p) -void Wellenreiter::startStopClicked() -{ - if ( sniffing ) + +void Wellenreiter::stopClicked() { @@ -251,5 +251,28 @@ void Wellenreiter::startStopClicked() QMessageBox::information( this, "Wellenreiter II", "Your wireless card\nshould now be usable again." ); + + sniffing = false; + emit( stoppedSniffing() ); + + // print out statistics + statwindow->log( "-----------------------------------------" ); + statwindow->log( "- Wellenreiter II Capturing Statistic -" ); + statwindow->log( "-----------------------------------------" ); + statwindow->log( "Packet Type | Receive Count" ); + + for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) + { + QString left; + left.sprintf( "%s", (const char*) it.key() ); + left = left.leftJustify( 20 ); + left.append( '|' ); + QString right; + right.sprintf( "%d", it.data() ); + right = right.rightJustify( 7 ); + statwindow->log( left + right ); } - else +} + + +void Wellenreiter::startClicked() { @@ -280,5 +303,7 @@ void Wellenreiter::startStopClicked() case 4: iface->setMonitoring( new OOrinocoMonitoringInterface( iface ) ); break; - default: assert( 0 ); // shouldn't happen + default: + QMessageBox::information( this, "Wellenreiter II", "Bring your device into\nmonitor mode now." ); } + if ( cardtype > 0 && cardtype < 5 ) iface->setMonitorMode( true ); @@ -312,4 +337,3 @@ void Wellenreiter::startStopClicked() sniffing = true; - - } + emit( startedSniffing() ); } diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 85f889b..839c77e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -49,2 +49,4 @@ class Wellenreiter : public WellenreiterBase { + bool sniffing; + public slots: @@ -52,3 +54,8 @@ class Wellenreiter : public WellenreiterBase { void receivePacket(OPacket*); - void startStopClicked(); + void startClicked(); + void stopClicked(); + + signals: + void startedSniffing(); + void stoppedSniffing(); @@ -59,3 +66,2 @@ class Wellenreiter : public WellenreiterBase { - bool sniffing; OWirelessNetworkInterface* iface; diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 3a703bc..245b9fc 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -32,2 +32,3 @@ #include "scanlist.h" +#include "statwindow.h" @@ -80,3 +81,2 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f - //--------- LOG TAB -------------- @@ -85,3 +85,2 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f - //--------- HEX TAB -------------- @@ -90,2 +89,6 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f + //--------- STAT TAB -------------- + + statwindow = new MStatWindow( TabWidget, "Stat" ); + //--------- ABOUT TAB -------------- @@ -127,5 +130,6 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f #ifdef QWS - TabWidget->addTab( ap, "wellenreiter/networks", tr( "Networks" ) ); + TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); + TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stats" ) ); TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); @@ -135,2 +139,3 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); + TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); @@ -140,3 +145,3 @@ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags f #ifdef QWS - TabWidget->setCurrentTab( tr( "Networks" ) ); + TabWidget->setCurrentTab( tr( "Nets" ) ); #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h index 1fa1ea3..ad2e96c 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.h +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h @@ -29,2 +29,3 @@ class MLogWindow; class MHexWindow; +class MStatWindow; @@ -53,2 +54,3 @@ public: MHexWindow* hexwindow; + MStatWindow* statwindow; QWidget* about; |