-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.cpp | 6 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 35 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiterbase.cpp | 7 |
4 files changed, 41 insertions, 11 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp index 9532a01..189a12d 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.cpp +++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp @@ -1,65 +1,69 @@ /********************************************************************** ** 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 <qpe/resource.h> #include <assert.h> #include <qpixmap.h> 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; MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) :QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) { 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 ) :QListViewItem( 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" ); // 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" ) ); // 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 listView()->triggerUpdate(); + this->type = type; + } diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index dd8219a..cd9d883 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h @@ -1,51 +1,55 @@ /********************************************************************** ** 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 <qlistview.h> class QString; class MScanListItem: public QListViewItem { 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; + }; #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index d1ace46..9c8630f 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -1,195 +1,210 @@ /********************************************************************** ** 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. ** ***********************************************************************/ // Qt #include <qpushbutton.h> // Standard #include <unistd.h> #include <sys/types.h> // Local #include "wellenreiter.h" #include "scanlistitem.h" #include "logwindow.h" #include "hexwindow.h" #include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! #include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS! #include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) : WellenreiterBase( parent, name, fl ) { logwindow->log( "(i) Wellenreiter has been started." ); connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); netview->setColumnWidthMode( 1, QListView::Manual ); // // setup socket for daemon communication and start poller // daemon_fd = commsock( GUIADDR, GUIPORT ); if ( daemon_fd == -1 ) { logwindow->log( "(E) Couldn't get file descriptor for commsocket." ); qDebug( "D'oh! Could not get file descriptor for daemon-->gui communication socket." ); } else startTimer( 700 ); } Wellenreiter::~Wellenreiter() { // no need to delete child widgets, Qt does it all for us } void Wellenreiter::handleMessage() { // FIXME: receive message and handle it qDebug( "received message from daemon." ); char buffer[128]; int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) ); qDebug( "received %d from recvcomm", result ); /* typedef struct { int net_type; 1 = Accesspoint ; 2 = Ad-Hoc int ssid_len; Length of SSID int channel; Channel int wep; 1 = WEP enabled ; 0 = disabled char mac[64]; MAC address of Accesspoint char bssid[128]; BSSID of Accesspoint } wl_network_t; */ qDebug( "Sniffer sent: '%s'", (const char*) &buffer ); hexwindow->log( (const char*) &buffer ); if ( result == NETFOUND ) /* new network found */ { logwindow->log( "(i) found new network" ); qDebug( "Sniffer said: new network found." ); wl_network_t n; get_network_found( &n, (char*) &buffer ); qDebug( "Sniffer said: net_type is %d.", n.net_type ); qDebug( "Sniffer said: MAC is %s", (const char*) &n.mac ); //n.bssid[n.ssid_len] = "\0"; QString type; if ( n.net_type == 1 ) type = "managed"; else type = "adhoc"; addNewItem( type, n.bssid, QString( (const char*) &n.mac ), n.wep, n.channel, 0 ); } else { qDebug( "unknown sniffer command." ); } } bool Wellenreiter::hasMessage() { // FIXME: do this in libwellenreiter, not here!!! fd_set rfds; FD_ZERO( &rfds ); FD_SET( daemon_fd, &rfds ); struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 10; int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); return FD_ISSET( daemon_fd, &rfds ); } void Wellenreiter::timerEvent( QTimerEvent* e ) { qDebug( "checking for message..." ); if ( hasMessage() ) { handleMessage(); } else { qDebug( "no message :(" ); } } void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) { // FIXME: this code belongs in customized QListView, not into this class // search, if we had an item with this essid once before - QListViewItem* item = netview->firstChild(); + //MScanListItem* item = dynamic_cast<MScanListItem*>( netview->firstChild() ); + MScanListItem* item = static_cast<MScanListItem*>( netview->firstChild() ); while ( item && ( item->text( 0 ) != essid ) ) { qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); - item = item->itemBelow(); + item = dynamic_cast<MScanListItem*>( item->itemBelow() ); } if ( item ) { qDebug( "found!" ); - if ( macaddr != item->text( 2 ) ) + // check, if it is the same item (based on MACaddr) + + if ( macaddr == item->text( 2 ) ) + { + qDebug( "already had item with mac %s", (const char*) item->text( 2 ) ); + return; + } + + // another item belonging to the same net, so: insert the new item as child + new MScanListItem( item, type, essid, macaddr, wep, channel, signal ); - else - qDebug( "already there. ignoring..." ); } + else { - new MScanListItem( netview, type, essid, macaddr, wep, channel, signal ); + qDebug( "inserting new network" ); + MScanListItem* network = new MScanListItem( netview, "networks", essid, QString::null, 0, 0, 0 ); + + new MScanListItem( network, type, essid, macaddr, wep, channel, signal ); } } void Wellenreiter::buttonClicked() { // FIXME: communicate with daemon and set button text according to state button->setText( "Stop Scanning" ); - // add some icons, so that we can see if this works + // add some test stations, so that we can see if the GUI part works - addNewItem( "managed", "DummyNet", "04:00:20:EF:A6:43", true, 6, 80 ); - addNewItem( "adhoc", "DummyNet", "40:03:A3:E7:56:22", false, 11, 30 ); + addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 ); + addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 ); + addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 ); + addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 ); + addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 ); QString command ("98"); - sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); + //sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command ); } diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index 9b6424d..b1845b9 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp @@ -1,163 +1,170 @@ /********************************************************************** ** 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 "wellenreiterbase.h" #include <qheader.h> #include <qlabel.h> #include <qlistview.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <opie/otabwidget.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include "logwindow.h" #include "hexwindow.h" #include <qpe/resource.h> /* * Constructs a WellenreiterBase which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { if ( !name ) setName( "WellenreiterBase" ); resize( 191, 294 ); setCaption( tr( "Wellenreiter" ) ); WellenreiterBaseLayout = new QVBoxLayout( this ); WellenreiterBaseLayout->setSpacing( 2 ); WellenreiterBaseLayout->setMargin( 0 ); TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); ap = new QWidget( TabWidget, "ap" ); apLayout = new QVBoxLayout( ap ); apLayout->setSpacing( 2 ); apLayout->setMargin( 2 ); //--------- NETVIEW TAB -------------- netview = new QListView( ap, "netview" ); netview->addColumn( tr( "SSID" ) ); + netview->setColumnAlignment( 0, AlignLeft || AlignVCenter ); netview->addColumn( tr( "Sig" ) ); + netview->setColumnAlignment( 1, AlignCenter ); netview->addColumn( tr( "AP" ) ); + netview->setColumnAlignment( 2, AlignCenter ); netview->addColumn( tr( "Chn" ) ); + netview->setColumnAlignment( 3, AlignCenter ); netview->addColumn( tr( "W" ) ); + netview->setColumnAlignment( 4, AlignCenter ); netview->addColumn( tr( "T" ) ); + netview->setColumnAlignment( 5, AlignCenter ); + netview->setFrameShape( QListView::StyledPanel ); netview->setFrameShadow( QListView::Sunken ); netview->setRootIsDecorated( TRUE ); apLayout->addWidget( netview ); TabWidget->addTab( ap, "wellenreiter/networks", tr( "Networks" ) ); //--------- LOG TAB -------------- logwindow = new MLogWindow( TabWidget, "Log" ); TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); //--------- HEX TAB -------------- hexwindow = new MHexWindow( TabWidget, "Hex" ); TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); //--------- CONFIG TAB -------------- QPushButton* dummy = new QPushButton( "under construction", TabWidget ); TabWidget->addTab( dummy, "wellenreiter/config", tr( "Config" ) ); //--------- ABOUT TAB -------------- about = new QWidget( TabWidget, "about" ); aboutLayout = new QGridLayout( about ); aboutLayout->setSpacing( 6 ); aboutLayout->setMargin( 11 ); PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); PixmapLabel1_3_2->setLineWidth( 2 ); PixmapLabel1_3_2->setMargin( 0 ); PixmapLabel1_3_2->setMidLineWidth( 0 ); PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); PixmapLabel1_3_2->setScaledContents( TRUE ); PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); TextLabel1_4_2_font.setPointSize( 10 ); TextLabel1_4_2->setFont( TextLabel1_4_2_font ); TextLabel1_4_2->setText( tr( "<p align=center>\n" "<hr>\n" "Max Moser<br>\n" "Martin J. Muench<br>\n" "Michael Lauer<br><hr>\n" "<b>www.remote-exploit.org</b>\n" "</p>" ) ); TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); WellenreiterBaseLayout->addWidget( TabWidget ); button = new QPushButton( this, "button" ); button->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, button->sizePolicy().hasHeightForWidth() ) ); button->setText( tr( "Start Scanning" ) ); WellenreiterBaseLayout->addWidget( button ); TabWidget->setCurrentTab( tr( "Networks" ) ); } /* * Destroys the object and frees any allocated resources */ WellenreiterBase::~WellenreiterBase() { // no need to delete child widgets, Qt does it all for us } /* * Main event handler. Reimplemented to handle application * font changes */ bool WellenreiterBase::event( QEvent* ev ) { bool ret = QWidget::event( ev ); if ( ev->type() == QEvent::ApplicationFontChange ) { //QFont Log_2_font( Log_2->font() ); //Log_2_font.setFamily( "adobe-courier" ); //Log_2_font.setPointSize( 8 ); //Log_2->setFont( Log_2_font ); QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); TextLabel1_4_2_font.setPointSize( 10 ); TextLabel1_4_2->setFont( TextLabel1_4_2_font ); } return ret; } |