-rw-r--r-- | noncore/net/wellenreiter/cornucopia/README | 127 | ||||
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 151 | ||||
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.h | 87 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 2 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 36 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.h | 1 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 130 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 77 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 121 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 83 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 8 |
11 files changed, 578 insertions, 245 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/README b/noncore/net/wellenreiter/cornucopia/README index 36a6954..486dc67 100644 --- a/noncore/net/wellenreiter/cornucopia/README +++ b/noncore/net/wellenreiter/cornucopia/README @@ -1,3 +1,124 @@ ---------------------------------------------------------------- -Dies ist ein Testballon für opielibs1.2 - Codename: Cornucopia ---------------------------------------------------------------- +/******************************************************************** +/* This is an overview of the opielibs 1.2 project +/********************************************************************/ + + Origin: opielibs is about creating classes to + * optimize Qt classes for the embedded environment + * provide sophisticated abstractions for developers + * provide complete documentation and working examples + * provide end users with a common look and feel + * reduce memory footprint through sharing code + * reduce possible bugs through reusing tested code + +-------------------------------------------------------- +1. General Overview +-------------------------------------------------------- + +Separation into the following libraries: + - libopiecore + - libopieui + - libopiepim + - libopienet + +1.1 Contents of libopiecore [ opiecore ] +-------------------------------------------------------- + + - oprocctrl + - oprocess + - odevice + - odevicebutton + + - oconfig + - oconfiggroupsaver + - ocompletionbase + - ocompletion + - ocomptreenodelist + - ocomptreenode + - ocompletionwrapper + - oglobal + - oglobalsettings + - osortableitem + - osortablevaluelist + +1.2 Contents of libopieui [ opieui ] +-------------------------------------------------------- + + - oapplication + + - ofiledialog + - colordialog + - oclickablelabel + - ocolorbutton + - colorpopupmenu + - otabinfo + - otabbar + - otabwidget + - ofontmenu + - ofontselector + - ofileview + - oticker + + - olistview + - olistviewitem + - oversatileview + - oversatileviewitem + - ocompletionbox + - olineedit + - ocombobox + - ohistorycombo + + - omessagebox + - odialogbase + + - todayconfigwidget (rather into opiepim?) + - orecurrancewidget (rather into opiepim?) + - otimepicker (rather into opiepim?) + +1.3 Contents of libopiepim [ opiepim ] +-------------------------------------------------------- + + - ocheckitem + - todoevent + - todoresource + - todayplugininterface + - todovcalresource + +1.4 Contents of libopiedb [ opiedb ] +-------------------------------------------------------- + + - tododb + - xmltree + +1.5 Contents of libopienet [ opienet ] +-------------------------------------------------------- + + <libmail stuff> + <libbend stuff> + <libftp stuff> + +-------------------------------------------------------- +2.0 Feature Description +-------------------------------------------------------- + +2.1 libopiecore + +... + +2.2 libopieui + +... + +2.2.x OListView, OListViewItem, OListViewFactory + +... + +2.3 libopiepim + +... + +2.4 libopiedb + +... + +2.5 libopienet + diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp index 8bc59de..f2d3730 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp @@ -124,4 +124,80 @@ void OListView::setColumnSeparator( const QPen& p ) } +#ifndef QT_NO_DATASTREAM +void OListView::serializeTo( QDataStream& s ) const +{ + #warning Caution... the binary format is still under construction... + qDebug( "storing OListView..." ); + + // store number of columns and the labels + s << columns(); + for ( int i = 0; i < columns(); ++i ) + s << columnText( i ); + + // calculate the number of top-level items to serialize + int items = 0; + QListViewItem* item = firstChild(); + while ( item ) + { + item = item->nextSibling(); + items++; + } + + // store number of items and the items itself + s << items; + item = firstChild(); + for ( int i = 0; i < items; ++i ) + { + s << *static_cast<OListViewItem*>( item ); + item = item->nextSibling(); + } + + qDebug( "OListview stored." ); +} + +void OListView::serializeFrom( QDataStream& s ) +{ + #warning Caution... the binary format is still under construction... + qDebug( "loading OListView..." ); + + int cols; + s >> cols; + qDebug( "read number of columns = %d", cols ); + + while ( columns() < cols ) addColumn( QString::null ); + + for ( int i = 0; i < cols; ++i ) + { + QString coltext; + s >> coltext; + qDebug( "read text '%s' for column %d", (const char*) coltext, i ); + setColumnText( i, coltext ); + } + + int items; + s >> items; + qDebug( "read number of items = %d", items ); + + for ( int i = 0; i < items; ++i ) + { + OListViewItem* item = new OListViewItem( this ); + s >> *item; + } + + qDebug( "OListView loaded." ); + +} + +QDataStream& operator<<( QDataStream& s, const OListView& lv ) +{ + lv.serializeTo( s ); +} + +QDataStream& operator>>( QDataStream& s, OListView& lv ) +{ + lv.serializeFrom( s ); +} +#endif // QT_NO_DATASTREAM + //****************************** OListViewItem *********************************************************************** @@ -246,5 +322,5 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in if (pm && !pm->isNull()) { - _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); + _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); } @@ -253,7 +329,7 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); } - QListViewItem::paintCell(p, _cg, column, width, alignment); + QListViewItem::paintCell( p, _cg, column, width, alignment ); - //FIXME: Use styling here? + //FIXME: Use styling here! const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); @@ -261,2 +337,71 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in p->drawLine( width-1, 0, width-1, height() ); } + +#ifndef QT_NO_DATASTREAM +void OListViewItem::serializeTo( QDataStream& s ) const +{ + #warning Caution... the binary format is still under construction... + qDebug( "storing OListViewItem..." ); + + // store item text + for ( int i = 0; i < listView()->columns(); ++i ) + { + s << text( i ); + } + + // calculate the number of children to serialize + int items = 0; + QListViewItem* item = firstChild(); + while ( item ) + { + item = item->nextSibling(); + items++; + } + + // store number of items and the items itself + s << items; + item = firstChild(); + for ( int i = 0; i < items; ++i ) + { + s << *static_cast<OListViewItem*>( item ); + item = item->nextSibling(); + } + + qDebug( "OListviewItem stored." ); +} +void OListViewItem::serializeFrom( QDataStream& s ) +{ + #warning Caution... the binary format is still under construction... + qDebug( "loading OListViewItem..." ); + + for ( int i = 0; i < listView()->columns(); ++i ) + { + QString coltext; + s >> coltext; + qDebug( "read text '%s' for column %d", (const char*) coltext, i ); + setText( i, coltext ); + } + + int items; + s >> items; + qDebug( "read number of items = %d", items ); + + for ( int i = 0; i < items; ++i ) + { + OListViewItem* item = new OListViewItem( this ); + s >> (*item); + } + + qDebug( "OListViewItem loaded." ); +} + +QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) +{ + lvi.serializeTo( s ); +} + +QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) +{ + lvi.serializeFrom( s ); +} +#endif // QT_NO_DATASTREAM diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h index 4b9e4b0..9df5500 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.h +++ b/noncore/net/wellenreiter/cornucopia/olistview.h @@ -34,12 +34,15 @@ #define OLISTVIEW_H -#include <qlistview.h> #include <qcolor.h> +#include <qlistview.h> #include <qpen.h> +#include <qdatastream.h> + +class OListViewFactory; /** - * A @ref QListView variant featuring visual enhancements - * like an alternate background for odd rows and an autostretch - * mode for the width of the widget. + * A @ref QListView variant featuring visual and functional enhancements + * like an alternate background for odd rows, an autostretch mode + * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. * * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> @@ -113,11 +116,49 @@ const QPen& columnSeparator() const; + #ifndef QT_NO_DATASTREAM + /** + * serialize this object to a @ref QDataStream + * @param s the stream used to serialize this object. + */ + virtual void serializeTo( QDataStream& s ) const; + + /** + * serialize this object from a @ref QDataStream + * @param s the stream used to serialize this object. + */ + virtual void serializeFrom( QDataStream& s ); + #endif + + /** + * returns a factory for OListView classes + * creates one on the fly if it doesn't exist + * @return the XML Factory + */ + #ifndef QT_NO_XML + //OListViewFactory* Factory(); + #endif + private: QColor m_alternateBackground; bool m_fullWidth; QPen m_columnSeparator; - + #ifndef QT_NO_XML + //OListViewFactory* m_Factory; + #endif }; +#ifndef QT_NO_DATASTREAM +/** + * \relates QListView + * Writes a listview to the stream and returns a reference to the stream. + */ +QDataStream& operator<<( QDataStream& s, const OListView& lv ); +/** + * \relates QListView + * Reads a listview from the stream and returns a reference to the stream. + */ +QDataStream& operator>>( QDataStream& s, OListView& lv ); +#endif // QT_NO_DATASTREAM + //****************************** OListViewItem ****************************************************************** @@ -147,5 +188,5 @@ class OListViewItem: public QListViewItem QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); - + OListViewItem( QListViewItem * parent, QListViewItem * after, QString, QString = QString::null, @@ -153,7 +194,7 @@ class OListViewItem: public QListViewItem QString = QString::null, QString = QString::null, QString = QString::null, QString = QString::null ); - + virtual ~OListViewItem(); - + const QColor& backgroundColor(); bool isAlternate(); @@ -161,4 +202,18 @@ class OListViewItem: public QListViewItem void init(); + #ifndef QT_NO_DATASTREAM + /** + * serialize this object to or from a @ref QDataStream + * @param s the stream used to serialize this object. + */ + virtual void serializeTo( QDataStream& s ) const; + + /** + * serialize this object to or from a @ref QDataStream + * @param s the stream used to serialize this object. + */ + virtual void serializeFrom( QDataStream& s ); + #endif + private: bool m_known; @@ -166,3 +221,17 @@ class OListViewItem: public QListViewItem }; -#endif +#ifndef QT_NO_DATASTREAM +/** + * \relates QListViewItem + * Writes a listview item and all subitems recursively to the stream + * and returns a reference to the stream. + */ +QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); +/** + * \relates QListViewItem + * Reads a listview item from the stream and returns a reference to the stream. + */ +QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); +#endif // QT_NO_DATASTREAM + +#endif // OLISTVIEW_H diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index 6037661..8861a50 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -8,5 +8,4 @@ HEADERS = wellenreiterbase.h \ mainwindow.h \ wellenreiter.h \ - scanlistitem.h \ scanlist.h \ logwindow.h \ @@ -21,5 +20,4 @@ SOURCES = main.cpp \ wellenreiterbase.cpp \ wellenreiter.cpp \ - scanlistitem.cpp \ scanlist.cpp \ logwindow.cpp \ diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index e388fc5..0ef89d4 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -22,4 +22,5 @@ #include <qcombobox.h> +#include <qdatastream.h> #include <qfile.h> #include <qiconset.h> @@ -45,4 +46,11 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n setCentralWidget( mw ); + // setup application icon + + #ifndef QWS + setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); + setIconText( "Wellenreiter/X11" ); + #endif + // setup icon sets @@ -100,9 +108,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n QPopupMenu* fileLoad = new QPopupMenu( mb ); fileLoad->insertItem( "&Session", this, SLOT( fileLoadSession() ) ); - fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); + //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); QPopupMenu* file = new QPopupMenu( mb ); id = file->insertItem( "&Load", fileLoad ); - file->setItemEnabled( id, false ); file->insertItem( "&Save", fileSave ); @@ -186,5 +193,5 @@ void WellenreiterMainWindow::demoAddStations() { 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( "managed", "Vanille", "00:30:6D: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 ); @@ -216,6 +223,6 @@ void WellenreiterMainWindow::fileSaveSession() if ( f.open(IO_WriteOnly) ) { - QTextStream t( &f ); - mw->netView()->dump( t ); + QDataStream t( &f ); + t << *mw->netView(); f.close(); qDebug( "Saved session to file '%s'", (const char*) fname ); @@ -227,4 +234,23 @@ void WellenreiterMainWindow::fileSaveSession() } +void WellenreiterMainWindow::fileLoadSession() +{ + const QString fname( "/tmp/session.xml" ); + QFile f( fname ); + + if ( f.open(IO_ReadOnly) ) + { + 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::closeEvent( QCloseEvent* e ) { diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h index 8bfccf3..59f259d 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.h +++ b/noncore/net/wellenreiter/gui/mainwindow.h @@ -52,4 +52,5 @@ class WellenreiterMainWindow: public QMainWindow void fileSaveLog(); void fileSaveSession(); + void fileLoadSession(); }; diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index cdc2c48..58a04fb 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -15,10 +15,8 @@ #include "scanlist.h" -#include "scanlistitem.h" #include <assert.h> - #include "manufacturers.h" - +#include <qdatetime.h> #include <qtextstream.h> @@ -51,9 +49,21 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) setAllColumnsShowFocus( true ); }; - + MScanListView::~MScanListView() { }; +void MScanListView::serializeTo( QDataStream& s) const +{ + qDebug( "serializing MScanListView" ); + OListView::serializeTo( s ); +} + +void MScanListView::serializeFrom( QDataStream& s) +{ + qDebug( "serializing MScanListView" ); + OListView::serializeFrom( s ); +} + void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb ) { @@ -70,7 +80,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo (const char*) macaddr, channel ); - + // search, if we already have seen this net - + QString s; MScanListItem* network; @@ -99,7 +109,7 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo nextpixmap = ani1; item->setPixmap( 0, *nextpixmap ); */ - + //qDebug( "current pixmap %d, next %d", pixmap, nextpixmap ); - + // we have already seen this net, check all childs if MAC exists @@ -114,5 +124,5 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo item = static_cast<MScanListItem*> ( item->itemBelow() ); } - + if ( item ) { @@ -154,14 +164,100 @@ void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bo } -void MScanListView::dump( QTextStream& t ) const +#ifdef QWS +#include <qpe/resource.h> +#else +#include "resource.h" +#endif + +const int col_type = 0; +const int col_essid = 0; +const int col_sig = 1; +const int col_ap = 2; +const int col_channel = 3; +const int col_wep = 4; +const int col_traffic = 5; +const int col_manuf = 6; +const int col_firstseen = 7; +const int col_lastseen = 8; + +MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, + bool wep, int channel, int signal ) + :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), + _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), + _channel( channel ), _signal( signal ), _beacons( 0 ) { - qDebug( "dumping scanlist..." ); + qDebug( "creating scanlist item" ); + decorateItem( type, essid, macaddr, wep, channel, signal ); +} - QListViewItemIterator it( const_cast<MScanListView*>( this ) ); - for ( ; it.current(); ++it ) - { - static_cast<MScanListItem*>( it.current() )->dump( t ); - } +MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, + bool wep, int channel, int signal ) + :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) +{ + qDebug( "creating scanlist item" ); + decorateItem( type, essid, macaddr, wep, channel, signal ); +} - qDebug( "dump finished." ); +void MScanListItem::serializeTo( QDataStream& s ) const +{ + OListViewItem::serializeTo( s ); +} + +void MScanListItem::serializeFrom( QDataStream& s ) +{ + OListViewItem::serializeFrom( s ); } + +void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) +{ + qDebug( "decorating scanlist item %s / %s / %s [%d]", + (const char*) type, + (const char*) essid, + (const char*) macaddr, + channel ); + + // set icon for managed or adhoc mode + QString name; + name.sprintf( "wellenreiter/%s", (const char*) type ); + setPixmap( col_type, Resource::loadPixmap( name ) ); + + // set icon for wep (wireless encryption protocol) + if ( wep ) + setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! + + // set channel and signal text + + 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() ); +} + diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index f06f251..66c701b 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -33,9 +33,11 @@ class MScanListView: public OListView void setManufacturerDB( ManufacturerDB* manufacturerdb ); - void dump( QTextStream& t ) const; + + virtual void serializeTo( QDataStream& s ) const; + virtual void serializeFrom( QDataStream& s ); public slots: void addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); - + private: ManufacturerDB* _manufacturerdb; @@ -43,4 +45,75 @@ class MScanListView: public OListView }; +//****************************** MScanListItem **************************************************************** + +class MScanListItem: public OListViewItem +{ + public: + MScanListItem::MScanListItem( QListView* parent, + QString type, + QString essid, + QString macaddr, + bool wep, + int channel, + int signal ); + + MScanListItem::MScanListItem( QListViewItem* parent, + QString type, + QString essid, + QString macaddr, + bool wep, + int channel, + int signal ); + + + protected: + virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); + + public: + QString type; + + public: + //const QString& type() { return _type; }; + 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 ); + + virtual void serializeTo( QDataStream& s ) const; + virtual void serializeFrom( QDataStream& s ); + + private: + QString _type; + QString _essid; + QString _macaddr; + bool _wep; + int _channel; + int _signal; + int _beacons; + +}; + +//****************************** MScanListViewFactory **************************************************************** + +/* + +class MScanListViewFactory : public OListViewFactory +{ +public: + virtual QListView* listViewFactory(); + virtual QListViewItem* listViewItemFactory( QListView* lv ); + virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); + virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); + virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); +} +*/ + #endif diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp deleted file mode 100644 index 4aecd2b..0000000 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/dev/null @@ -1,121 +0,0 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** 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 "scanlistitem.h" -#include <assert.h> -#include <qdatetime.h> -#include <qpixmap.h> - -#ifdef QWS -#include <qpe/resource.h> -#else -#include "resource.h" -#endif - -const int col_type = 0; -const int col_essid = 0; -const int col_sig = 1; -const int col_ap = 2; -const int col_channel = 3; -const int col_wep = 4; -const int col_traffic = 5; -const int col_manuf = 6; -const int col_firstseen = 7; -const int col_lastseen = 8; - -MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, - bool wep, int channel, int signal ) - :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), - _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), - _channel( channel ), _signal( signal ), _beacons( 0 ) -{ - qDebug( "creating scanlist item" ); - decorateItem( type, essid, macaddr, wep, channel, signal ); -} - -MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, - bool wep, int channel, int signal ) - :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) -{ - qDebug( "creating scanlist item" ); - decorateItem( type, essid, macaddr, wep, channel, signal ); -} - -void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) -{ - qDebug( "decorating scanlist item %s / %s / %s [%d]", - (const char*) type, - (const char*) essid, - (const char*) macaddr, - channel ); - - // set icon for managed or adhoc mode - QString name; - name.sprintf( "wellenreiter/%s", (const char*) type ); - setPixmap( col_type, Resource::loadPixmap( name ) ); - - // set icon for wep (wireless encryption protocol) - if ( wep ) - setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! - - // set channel and signal text - - 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 deleted file mode 100644 index 5f6ae40..0000000 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/dev/null @@ -1,83 +0,0 @@ -/********************************************************************** -** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. -** -** This file is part of Opie Environment. -** -** 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. -** -**********************************************************************/ - -#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, - int signal ); - - MScanListItem::MScanListItem( QListViewItem* parent, - QString type, - QString essid, - QString macaddr, - bool wep, - int channel, - int signal ); - - - protected: - - virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); - - public: - - QString type; - - public: - - //const QString& type() { return _type; }; - 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 1ccf971..dd8a365 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -124,4 +124,10 @@ Wellenreiter::~Wellenreiter() delete manufacturerdb; + + // X11-only - Hmm... Closing the socket here segfaults on exit, + // Maybe because the notifier still has a handle to it!? Seems not to + // occur on Qt/Embedded + + #ifdef QWS if ( daemon_fd != -1 ) { @@ -129,4 +135,6 @@ Wellenreiter::~Wellenreiter() close( daemon_fd ); } + #endif + } |