-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 60 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 32 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 10 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 21 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 5 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 1 |
9 files changed, 118 insertions, 27 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp index bca17b2..8bc59de 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp @@ -197,48 +197,48 @@ const QColor &OListViewItem::backgroundColor() } bool OListViewItem::isAlternate() { OListView *lv = static_cast<OListView*>( listView() ); // check if the item above is an OListViewItem OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); - /*if (not itemAbove()->inherits( "OListViewItem" )) return false;*/ + /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ // check if we have a valid alternate background color - if (not (lv && lv->alternateBackground().isValid())) return false; + if (!(lv && lv->alternateBackground().isValid())) return false; m_known = above ? above->m_known : true; if (m_known) { m_odd = above ? !above->m_odd : false; } else { OListViewItem *item; bool previous = true; if (parent()) { item = static_cast<OListViewItem *>(parent()); if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; item = static_cast<OListViewItem *>(parent()->firstChild()); - /* if !( item.inherits( "OListViewItem" ) item = 0; */ + /* if ( !item.inherits( "OListViewItem" ) item = 0; */ } else { item = static_cast<OListViewItem *>(lv->firstChild()); } while(item) { item->m_odd = previous = !previous; item->m_known = true; item = static_cast<OListViewItem *>(item->nextSibling()); - /* if !(item.inherits( "OListViewItem" ) ) break; */ + /* if (!item.inherits( "OListViewItem" ) ) break; */ } } return m_odd; } void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) { QColorGroup _cg = cg; diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index cb003dd..e388fc5 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -19,16 +19,17 @@ #include "wellenreiter.h" #include "scanlist.h" #include <qcombobox.h> #include <qfile.h> #include <qiconset.h> #include <qmenubar.h> +#include <qmessagebox.h> #include <qpopupmenu.h> #include <qstatusbar.h> #include <qtextstream.h> #include <qtoolbutton.h> #ifdef QWS #include <qpe/resource.h> #else @@ -54,48 +55,59 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n 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 // setup tool buttons startStopButton = new QToolButton( 0 ); + #ifdef QWS startStopButton->setAutoRaise( true ); + #endif #ifdef QWS startStopButton->setOnIconSet( *cancelIconSet ); startStopButton->setOffIconSet( *searchIconSet ); #else startStopButton->setIconSet( *startStopIconSet ); #endif startStopButton->setToggleButton( true ); connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); startStopButton->setEnabled( false ); 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 ); connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); // setup menu bar int id; QMenuBar* mb = menuBar(); QPopupMenu* fileSave = new QPopupMenu( mb ); + fileSave->insertItem( "&Session", this, SLOT( fileSaveSession() ) ); fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) ); + QPopupMenu* fileLoad = new QPopupMenu( mb ); + fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); + fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); + QPopupMenu* file = new QPopupMenu( mb ); - id = file->insertItem( "&Load" ); + id = file->insertItem( "&Load", fileLoad ); file->setItemEnabled( id, false ); file->insertItem( "&Save", fileSave ); QPopupMenu* view = new QPopupMenu( mb ); view->insertItem( "&Configure..." ); QPopupMenu* sniffer = new QPopupMenu( mb ); sniffer->insertItem( "&Configure..." ); @@ -167,32 +179,62 @@ WellenreiterMainWindow::~WellenreiterMainWindow() #else delete startStopIconSet; #endif }; void WellenreiterMainWindow::demoAddStations() { - mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); - mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); - mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); - mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); + mw->netView()->addNewItem( "managed", "Vanille", "00:00:20:EF:A6:43", true, 6, 80 ); + mw->netView()->addNewItem( "managed", "Vanille", "00:00:1c:EF:A6:23", true, 11, 10 ); + mw->netView()->addNewItem( "adhoc", "ELAN", "00:A0:F8:E7:16:22", false, 3, 10 ); + mw->netView()->addNewItem( "adhoc", "ELAN", "00:AA:01:E7:56:62", false, 3, 15 ); + mw->netView()->addNewItem( "adhoc", "ELAN", "00:B0:8E:E7:56:E2", false, 3, 20 ); } void WellenreiterMainWindow::fileSaveLog() { const QString fname( "/tmp/log.txt" ); QFile f( fname ); if ( f.open(IO_WriteOnly) ) { QTextStream t( &f ); t << mw->logWindow()->getLog(); f.close(); - qDebug( "saved log in file '%s'", (const char*) fname ); + qDebug( "Saved log to file '%s'", (const char*) fname ); + } + else + { + qDebug( "Problem saving log to file '%s'", (const char*) fname ); + } + +} + +void WellenreiterMainWindow::fileSaveSession() +{ + const QString fname( "/tmp/session.xml" ); + QFile f( fname ); + if ( f.open(IO_WriteOnly) ) + { + QTextStream t( &f ); + mw->netView()->dump( t ); + f.close(); + qDebug( "Saved session to file '%s'", (const char*) fname ); } else { - qDebug( "Problem saving log in file '%s'", (const char*) fname ); + qDebug( "Problem saving session to file '%s'", (const char*) fname ); } +} -}
\ No newline at end of file +void WellenreiterMainWindow::closeEvent( QCloseEvent* e ) +{ + if ( mw->isDaemonRunning() ) + { + QMessageBox::warning( this, "Wellenreiter/Opie", "Sniffing in progress!\nPlease stop sniffing before closing." ); + e->ignore(); + } + else + { + QMainWindow::closeEvent( e ); + } +} diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 03aa08a..8bfccf3 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h @@ -38,15 +38,19 @@ class WellenreiterMainWindow: public QMainWindow QIconSet* startStopIconSet; const QIconSet* searchIconSet; const QIconSet* infoIconSet; const QIconSet* settingsIconSet; const QIconSet* cancelIconSet; QToolButton* startStopButton; + protected: + virtual void closeEvent( QCloseEvent* ); + public slots: void showConfigure(); void demoAddStations(); void fileSaveLog(); + void fileSaveSession(); }; #endif diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 6d3469c..cdc2c48 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -15,23 +15,25 @@ #include "scanlist.h" #include "scanlistitem.h" #include <assert.h> #include "manufacturers.h" +#include <qtextstream.h> + MScanListView::MScanListView( QWidget* parent, const char* name ) :OListView( parent, name ), _manufacturerdb( 0 ) { setFrameShape( QListView::StyledPanel ); setFrameShadow( QListView::Sunken ); - + addColumn( tr( "Net/Station" ) ); setColumnAlignment( 0, AlignLeft || AlignVCenter ); addColumn( tr( "B" ) ); setColumnAlignment( 1, AlignCenter ); addColumn( tr( "AP" ) ); setColumnAlignment( 2, AlignCenter ); addColumn( tr( "Chn" ) ); setColumnAlignment( 3, AlignCenter ); @@ -120,34 +122,46 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo #endif item->receivedBeacon(); return; } } else { s.sprintf( "(i) new network: '%s'", (const char*) essid ); - + network = new MScanListItem( this, "networks", essid, QString::null, 0, 0, 0 ); - } - - + } + + // insert new station as child from network - + // no essid to reduce clutter, maybe later we have a nick or stationname to display!? - + qDebug( "inserting new station %s", (const char*) macaddr ); - + MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); if ( _manufacturerdb ) station->setManufacturer( _manufacturerdb->lookup( macaddr ) ); if ( type == "managed" ) { s.sprintf( "(i) new AP in '%s' [%d]", (const char*) essid, channel ); } else { s.sprintf( "(i) new adhoc station in '%s' [%d]", (const char*) essid, channel ); } - + } +void MScanListView::dump( QTextStream& t ) const +{ + qDebug( "dumping scanlist..." ); + + QListViewItemIterator it( const_cast<MScanListView*>( this ) ); + for ( ; it.current(); ++it ) + { + static_cast<MScanListItem*>( it.current() )->dump( t ); + } + + qDebug( "dump finished." ); +} diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 475f7b6..f06f251 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -13,30 +13,32 @@ ** **********************************************************************/ #ifndef SCANLIST_H #define SCANLIST_H #include <cornucopia/olistview.h> -class QString; +#include <qtextstream.h> +class QString; class ManufacturerDB; class MScanListView: public OListView { Q_OBJECT - + public: MScanListView( QWidget* parent = 0, const char* name = 0 ); virtual ~MScanListView(); - + void setManufacturerDB( ManufacturerDB* manufacturerdb ); - + void dump( QTextStream& t ) const; + public slots: void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); private: ManufacturerDB* _manufacturerdb; }; diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index bfa7aa9..4aecd2b 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp @@ -78,25 +78,44 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, setText( col_channel, QString::number( channel ) ); setText( col_firstseen, QTime::currentTime().toString() ); //setText( col_lastseen, QTime::currentTime().toString() ); listView()->triggerUpdate(); this->type = type; - + _type = type; + _essid = essid; + _macaddr = macaddr; + _channel = channel; + _beacons = 0; + _signal = 0; } void MScanListItem::setManufacturer( const QString& manufacturer ) { setText( col_manuf, manufacturer ); } void MScanListItem::receivedBeacon() { _beacons++; #ifdef DEBUG qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); #endif setText( col_sig, QString::number( _beacons ) ); setText( col_lastseen, QTime::currentTime().toString() ); } + +void MScanListItem::dump( QTextStream& t ) const +{ + qDebug( "dumping scanlistitem at <%d>", this ); + t << "<ITEM type=" << _type; + t << " ESSID='" << _essid; + t << "' MAC=" << _macaddr; + t << " WEP=" << _wep; + t << " CHANNEL=" << _channel; + t << " SIGNAL=" << _signal; + t << " BEACONS=" << _beacons; + t << ">\n"; +} + diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index 89b3bc4..5f6ae40 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h @@ -13,16 +13,18 @@ ** **********************************************************************/ #ifndef SCANLISTITEM_H #define SCANLISTITEM_H #include <cornucopia/olistview.h> +#include <qtextstream.h> + class QString; class MScanListItem: public OListViewItem { public: MScanListItem::MScanListItem( QListView* parent, QString type, @@ -59,16 +61,18 @@ class MScanListItem: public OListViewItem int signal() { return _signal; }; int beacons() { return _beacons; }; void setSignal( int signal ) { /* TODO */ }; void receivedBeacon(); void setManufacturer( const QString& manufacturer ); + void dump( QTextStream& t ) const; + private: QString _type; QString _essid; QString _macaddr; bool _wep; int _channel; int _signal; int _beacons; diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index c599bb4..1ccf971 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -118,16 +118,21 @@ Wellenreiter::Wellenreiter( QWidget* parent ) } Wellenreiter::~Wellenreiter() { // no need to delete child widgets, Qt does it all for us delete manufacturerdb; + if ( daemon_fd != -1 ) + { + qDebug( "closing comm socket" ); + close( daemon_fd ); + } } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::handleMessage() diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index ff523d4..ee9dca9 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -48,16 +48,17 @@ class Wellenreiter : public WellenreiterBase { public: Wellenreiter( QWidget* parent = 0 ); ~Wellenreiter(); void setConfigWindow( WellenreiterConfigWindow* cw ); MScanListView* netView() const { return netview; }; MLogWindow* logWindow() const { return logwindow; }; + bool isDaemonRunning() const { return daemonRunning; }; protected: bool daemonRunning; public slots: void dataReceived(); void startStopClicked(); |