author | mickeyl <mickeyl> | 2003-02-24 21:37:49 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-02-24 21:37:49 (UTC) |
commit | d14b92ef8984ae654ff187bf6c8f5946d3ba218d (patch) (side-by-side diff) | |
tree | fd209280150b48eb137315d9bfe693892525697e | |
parent | 93151a1467b45759d320ce6673160190d6ab8872 (diff) | |
download | opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.zip opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.tar.gz opie-d14b92ef8984ae654ff187bf6c8f5946d3ba218d.tar.bz2 |
- work around yet another g++ 2.x bug
- started work on saving session to xml
[ any classes from libopie I can reuse without too much effort? ]
-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 @@ -199,16 +199,16 @@ 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; } @@ -218,25 +218,25 @@ bool OListViewItem::isAlternate() 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) 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 @@ -21,12 +21,13 @@ #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 @@ -56,44 +57,55 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n 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..." ); @@ -169,30 +181,60 @@ WellenreiterMainWindow::~WellenreiterMainWindow() #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 @@ -40,13 +40,17 @@ class WellenreiterMainWindow: public QMainWindow 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 @@ -17,19 +17,21 @@ #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 ); @@ -122,32 +124,44 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo 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 @@ -15,26 +15,28 @@ #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 @@ -80,13 +80,18 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, 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 ); } @@ -97,6 +102,20 @@ void MScanListItem::receivedBeacon() #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 @@ -15,12 +15,14 @@ #ifndef SCANLISTITEM_H #define SCANLISTITEM_H #include <cornucopia/olistview.h> +#include <qtextstream.h> + class QString; class MScanListItem: public OListViewItem { public: @@ -61,12 +63,14 @@ class MScanListItem: public OListViewItem 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; 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 @@ -120,12 +120,17 @@ 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; } 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 @@ -50,12 +50,13 @@ class Wellenreiter : public WellenreiterBase { 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(); |