/********************************************************************** ** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. ** ** This file is part of Wellenreiter II. ** ** 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 "configwindow.h" #include "gps.h" #include "logwindow.h" #include "packetview.h" #include "mainwindow.h" #include "wellenreiter.h" #include "scanlist.h" /* OPIE */ #ifdef QWS #include #include #include #else #include "resource.h" #include #include #endif /* QT */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* STD */ #include using namespace Opie::Core; using namespace Opie::Net; using namespace Opie::Ui; WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { cw = new WellenreiterConfigWindow( this ); mw = new Wellenreiter( this ); mw->setConfigWindow( cw ); setCentralWidget( mw ); // setup application icon setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); #ifndef QWS setIconText( "Wellenreiter/X11" ); #endif // setup tool buttons startButton = new QToolButton( 0 ); QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); #ifdef QWS startButton->setAutoRaise( true ); #endif startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); startButton->setEnabled( false ); connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); stopButton = new QToolButton( 0 ); QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); #ifdef QWS stopButton->setAutoRaise( true ); #endif stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); stopButton->setEnabled( false ); connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); QToolButton* d = new QToolButton( 0 ); QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), #ifdef QWS d->setAutoRaise( true ); #endif d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); uploadButton = new QToolButton( 0 ); QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); #ifdef QWS uploadButton->setAutoRaise( true ); #endif uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); uploadButton->setEnabled( false ); //uploadButton->setEnabled( true ); // DEBUGGING 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* 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* view = new QPopupMenu( mb ); view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); 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( uploadButton ); mb->insertItem( d ); #else // Qt3 changed the insertion order. It's now totally random :( mb->insertItem( d ); 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 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; void WellenreiterMainWindow::showConfigure() { odebug << "show configure..." << oendl; cw->setCaption( tr( "Configure" ) ); int result = QPEApplication::execDialog( cw ); if ( result ) updateToolButtonState(); } void WellenreiterMainWindow::updateToolButtonState() { const QString& interface = cw->interfaceName->currentText(); const int cardtype = cw->driverType(); if ( ( interface != "