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 @@ -193,56 +193,56 @@ void OListViewItem::init() const QColor &OListViewItem::backgroundColor() { return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : listView()->viewport()->colorGroup().base(); } 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; const QPixmap *pm = listView()->viewport()->backgroundPixmap(); if (pm && !pm->isNull()) { _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); 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 @@ -15,24 +15,25 @@ #include "configwindow.h" #include "logwindow.h" #include "mainwindow.h" #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 #include "resource.h" #endif WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) @@ -50,56 +51,67 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n #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 // 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..." ); sniffer->insertSeparator(); QPopupMenu* demo = new QPopupMenu( mb ); demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) ); @@ -163,36 +175,66 @@ WellenreiterMainWindow::~WellenreiterMainWindow() delete settingsIconSet; #ifdef QWS delete searchIconSet; delete cancelIconSet; #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 @@ -34,19 +34,23 @@ class WellenreiterMainWindow: public QMainWindow protected: Wellenreiter* mw; WellenreiterConfigWindow* cw; 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 @@ -11,31 +11,33 @@ ** 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 "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 ); addColumn( tr( "W" ) ); setColumnAlignment( 4, AlignCenter ); addColumn( tr( "T" ) ); setColumnAlignment( 5, AlignCenter ); @@ -116,38 +118,50 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo { // we have already seen this item, it's a dupe #ifdef DEBUG qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); #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 @@ -9,36 +9,38 @@ ** 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 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; }; #endif 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 @@ -74,29 +74,48 @@ void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, if ( signal != -1 ) setText( col_sig, QString::number( signal ) ); if ( channel != -1 ) 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 @@ -9,24 +9,26 @@ ** 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 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, QString essid, QString macaddr, bool wep, int channel, @@ -55,24 +57,26 @@ class MScanListItem: public OListViewItem const QString& essid() { return _essid; }; const QString& macaddr() { return _macaddr; }; bool wep() { return _wep; }; int channel() { return _channel; }; 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; }; #endif 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 @@ -114,24 +114,29 @@ Wellenreiter::Wellenreiter( QWidget* parent ) netview->setColumnWidthMode( 1, QListView::Manual ); if ( manufacturerdb ) netview->setManufacturerDB( manufacturerdb ); } 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() { // FIXME: receive message and handle it qDebug( "received message from daemon." ); 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 @@ -44,24 +44,25 @@ class ManufacturerDB; class WellenreiterConfigWindow; class Wellenreiter : public WellenreiterBase { Q_OBJECT 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(); private: int daemon_fd; // socket filedescriptor for udp communication socket #ifdef QWS OSystem _system; // Opie Operating System identifier |