-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 56 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 38 |
3 files changed, 54 insertions, 48 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 868b0b0..ab7e0c7 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -48,115 +48,112 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n cw = new WellenreiterConfigWindow( this ); mw = new Wellenreiter( this ); mw->setConfigWindow( cw ); setCentralWidget( mw ); // setup application icon #ifndef QWS setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); setIconText( "Wellenreiter/X11" ); #endif - // setup icon sets - - infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); - settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); - startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); - stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); - // setup tool buttons startButton = new QToolButton( 0 ); #ifdef QWS startButton->setAutoRaise( true ); #endif - startButton->setIconSet( *startIconSet ); + startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); startButton->setEnabled( false ); connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); stopButton = new QToolButton( 0 ); #ifdef QWS stopButton->setAutoRaise( true ); #endif - stopButton->setIconSet( *stopIconSet ); + stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); stopButton->setEnabled( false ); connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); - QToolButton* c = new QToolButton( 0 ); - #ifdef QWS - c->setAutoRaise( true ); - #endif - c->setIconSet( *infoIconSet ); - c->setEnabled( false ); - QToolButton* d = new QToolButton( 0 ); #ifdef QWS d->setAutoRaise( true ); #endif - d->setIconSet( *settingsIconSet ); + d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); + uploadButton = new QToolButton( 0 ); + #ifdef QWS + uploadButton->setAutoRaise( true ); + #endif + uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); + uploadButton->setEnabled( false ); + connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); + // setup menu bar int id; QMenuBar* mb = menuBar(); QPopupMenu* fileSave = new QPopupMenu( mb ); fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); QPopupMenu* fileLoad = new QPopupMenu( mb ); fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); QPopupMenu* file = new QPopupMenu( mb ); file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); id = file->insertItem( tr( "&Load" ), fileLoad ); file->insertItem( tr( "&Save" ), fileSave ); file->insertSeparator(); + uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); + file->insertSeparator(); file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( tr( "&Configure..." ) ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); sniffer->setItemEnabled( startID, false ); stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); sniffer->setItemEnabled( stopID, false ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); id = mb->insertItem( tr( "&File" ), file ); //id = mb->insertItem( tr( "&View" ), view ); //mb->setItemEnabled( id, false ); id = mb->insertItem( tr( "&Sniffer" ), sniffer ); id = mb->insertItem( tr( "&Demo" ), demo ); mb->setItemEnabled( id, true ); + mb->setItemEnabled( uploadID, false ); #ifdef QWS mb->insertItem( startButton ); mb->insertItem( stopButton ); - mb->insertItem( c ); + mb->insertItem( uploadButton ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); - mb->insertItem( c ); + mb->insertItem( uploadButton ); mb->insertItem( stopButton ); mb->insertItem( startButton ); #endif updateToolButtonState(); // setup status bar (for now only on X11) #ifndef QWS statusBar()->message( tr( "Ready." ) ); #endif @@ -170,60 +167,63 @@ void WellenreiterMainWindow::showConfigure() { qDebug( "show configure..." ); cw->setCaption( tr( "Configure" ) ); #ifdef QWS cw->showMaximized(); #endif int result = cw->exec(); if ( result ) updateToolButtonState(); } - void WellenreiterMainWindow::updateToolButtonState() { const QString& interface = cw->interfaceName->currentText(); const int cardtype = cw->driverType(); if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) { startButton->setEnabled( true ); menuBar()->setItemEnabled( startID, true ); } else { startButton->setEnabled( false ); menuBar()->setItemEnabled( startID, false ); } } void WellenreiterMainWindow::changedSniffingState() { startButton->setEnabled( !mw->sniffing ); menuBar()->setItemEnabled( startID, !mw->sniffing ); stopButton->setEnabled( mw->sniffing ); menuBar()->setItemEnabled( stopID, mw->sniffing ); + + if ( !mw->sniffing ) + { + menuBar()->setItemEnabled( uploadID, true ); + uploadButton->setEnabled( true ); + } } WellenreiterMainWindow::~WellenreiterMainWindow() { - delete infoIconSet; - delete settingsIconSet; - delete startIconSet; - delete stopIconSet; + qDebug( "Wellenreiter:: bye." ); }; + void WellenreiterMainWindow::demoAddStations() { //mw = 0; // test SIGSGV handling mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 10.10, 20.20 ) ); mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:A0:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:AA:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:B0:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); } @@ -334,34 +334,42 @@ void WellenreiterMainWindow::fileLoadSession() QDataStream t( &f ); t >> *mw->netView(); f.close(); qDebug( "Loaded session from file '%s'", (const char*) fname ); } else { qDebug( "Problem loading session from file '%s'", (const char*) fname ); } } } + void WellenreiterMainWindow::fileNew() { mw->netView()->clear(); mw->logWindow()->clear(); mw->hexWindow()->clear(); } + void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) { if ( mw->isDaemonRunning() ) { QMessageBox::warning( this, "Wellenreiter/Opie", tr( "Sniffing in progress!\nPlease stop sniffing before closing." ) ); e->ignore(); } else { QMainWindow::closeEvent( e ); } } +void WellenreiterMainWindow::uploadSession() +{ + QMessageBox::warning( this, "Wellenreiter/Opie", + tr( "This feature is\nunder construction... ;-)" ) ); +} + diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 926bb0a..8d4e768 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h @@ -27,38 +27,36 @@ class WellenreiterMainWindow: public QMainWindow { Q_OBJECT public: WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); ~WellenreiterMainWindow(); QString getFileName( bool save ); protected: Wellenreiter* mw; WellenreiterConfigWindow* cw; - const QIconSet* startIconSet; - const QIconSet* stopIconSet; - const QIconSet* infoIconSet; - const QIconSet* settingsIconSet; - QToolButton* startButton; QToolButton* stopButton; + QToolButton* uploadButton; int startID; int stopID; + int uploadID; protected: virtual void closeEvent( QCloseEvent* ); void updateToolButtonState(); public slots: void showConfigure(); void demoAddStations(); void fileSaveLog(); void fileSaveHex(); void fileSaveSession(); void fileLoadSession(); void fileNew(); + void uploadSession(); void changedSniffingState(); }; #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 1d4a98b..ec89f1e 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -293,25 +293,25 @@ QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) return 0; return p->child( protocol ); } bool Wellenreiter::checkDumpPacket( OPacket* p ) { // go through all child packets and see if one is inside the child hierarchy for p // if so, do what the user requested (protocolAction), e.g. pass or discard if ( !configwindow->writeCaptureFile->isChecked() ) - return false; + return true; // semantic change - we're logging anyway now to /tmp/wellenreiter QObjectList* l = p->queryList(); QObjectListIt it( *l ); QObject* o; while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->capturePackets->isProtocolChecked( name ) ) { QString action = configwindow->capturePackets->protocolAction( name ); qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); @@ -497,47 +497,47 @@ void Wellenreiter::startClicked() return; } } // open GPS device if ( configwindow->enableGPS->isChecked() ) { qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); } // open pcap and start sniffing - if ( cardtype != DEVTYPE_FILE ) - { - pcap->open( interface ); - if ( configwindow->writeCaptureFile->isChecked() ) - { - QString dumpname( configwindow->captureFileName->text() ); - if ( dumpname.isEmpty() ) dumpname = "captureFile"; - dumpname.append( '-' ); - dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); - dumpname.append( ".wellenreiter" ); - pcap->openDumpFile( dumpname ); - } - else - { - pcap->open( interface ); - } + QString dumpname; + if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? + { + dumpname = configwindow->captureFileName->text(); + if ( dumpname.isEmpty() ) dumpname = "captureFile"; + dumpname.append( '-' ); + dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); + dumpname.append( ".wellenreiter" ); } - else + else // write it anyway ;) { - pcap->open( QFile( interface ) ); + dumpname = "/var/log/dump.wellenreiter"; } + if ( cardtype != DEVTYPE_FILE ) + pcap->open( interface ); + else + pcap->open( QFile( interface ) ); + + qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); + pcap->openDumpFile( dumpname ); + if ( !pcap->isOpen() ) { QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); return; } // set capturer to non-blocking mode pcap->setBlocking( false ); // start channel hopper if ( cardtype != DEVTYPE_FILE ) |