-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 39 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.h | 8 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 18 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 2 |
4 files changed, 66 insertions, 1 deletions
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index 809d0bd..085eec4 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp @@ -1,48 +1,50 @@ /********************************************************************** ** 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 "scanlist.h" #include "configwindow.h" #include "logwindow.h" #include <assert.h> #include <qdatetime.h> #include <qtextstream.h> +#include <qpopupmenu.h> #ifdef QWS +#include <qpe/qpeapplication.h> #include <opie/odevice.h> using namespace Opie; #endif #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_ip = 6; const int col_manuf = 7; const int col_firstseen = 8; const int col_lastseen = 9; MScanListView::MScanListView( QWidget* parent, const char* name ) @@ -53,48 +55,56 @@ MScanListView::MScanListView( QWidget* parent, const char* name ) setFrameShadow( QListView::Sunken ); addColumn( tr( "Net/Station" ) ); setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); addColumn( tr( "#" ) ); setColumnAlignment( col_sig, AlignCenter ); addColumn( tr( "MAC" ) ); setColumnAlignment( col_ap, AlignCenter ); addColumn( tr( "Chn" ) ); setColumnAlignment( col_channel, AlignCenter ); addColumn( tr( "W" ) ); setColumnAlignment( col_wep, AlignCenter ); addColumn( tr( "T" ) ); setColumnAlignment( col_traffic, AlignCenter ); addColumn( tr( "IP" ) ); setColumnAlignment( col_ip, AlignCenter ); addColumn( tr( "Manufacturer" ) ); setColumnAlignment( col_manuf, AlignCenter ); addColumn( tr( "First Seen" ) ); setColumnAlignment( col_firstseen, AlignCenter ); addColumn( tr( "Last Seen" ) ); setColumnAlignment( col_lastseen, AlignCenter ); setRootIsDecorated( true ); setAllColumnsShowFocus( true ); + + connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), + this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); + + #ifdef QWS + QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); + #endif + }; MScanListView::~MScanListView() { }; OListViewItem* MScanListView::childFactory() { return new MScanListItem( this ); } void MScanListView::serializeTo( QDataStream& s) const { qDebug( "serializing MScanListView" ); OListView::serializeTo( s ); } void MScanListView::serializeFrom( QDataStream& s) { qDebug( "serializing MScanListView" ); @@ -296,76 +306,105 @@ void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, qWarning( "D'oh! Not yet implemented..." ); MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); } void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) { qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); QListViewItemIterator it( this ); for ( ; it.current(); ++it ) { if ( it.current()->text( col_ap ) == macaddr.toString(true) ) { it.current()->setText( col_ip, ip ); return; } } qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", (const char*) macaddr.toString(), (const char*) ip ) ); } +void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) +{ + if ( !item ) return; + + MScanListItem* itm = static_cast<MScanListItem*>( item ); + + qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", + (const char*) itm->text(0), (const char*) itm->type, col ); + + if ( itm->type == "adhoc" || itm->type == "managed" ) + { + QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); + + QPopupMenu m( this ); + m.insertItem( entry, 37773, 0 ); + int result = m.exec( QCursor::pos() ); + if ( result == 37773 ) + emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); + } +} + //============================================================ // MScanListItem //============================================================ 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( 1 ) { #ifdef DEBUG qDebug( "creating scanlist item" ); #endif if ( WellenreiterConfigWindow::instance() && type == "network" ) playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 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 ) { #ifdef DEBUG qDebug( "creating scanlist item" ); #endif decorateItem( type, essid, macaddr, wep, channel, signal ); } +const QString& MScanListItem::essid() const +{ + if ( type == "network" ) + return _essid; + else + return ( (MScanListItem*) parent() )->essid(); +} + OListViewItem* MScanListItem::childFactory() { return new MScanListItem( this ); } void MScanListItem::serializeTo( QDataStream& s ) const { #ifdef DEBUG qDebug( "serializing MScanListItem" ); #endif OListViewItem::serializeTo( s ); s << _type; s << (Q_UINT8) ( _wep ? 'y' : 'n' ); } void MScanListItem::serializeFrom( QDataStream& s ) { #ifdef DEBUG qDebug( "serializing MScanListItem" ); #endif OListViewItem::serializeFrom( s ); char wep; diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h index 253c166..5aba0d2 100644 --- a/noncore/net/wellenreiter/gui/scanlist.h +++ b/noncore/net/wellenreiter/gui/scanlist.h @@ -26,84 +26,90 @@ class QString; class MScanListItem; class MScanListView: public OListView { Q_OBJECT public: MScanListView( QWidget* parent = 0, const char* name = 0 ); virtual ~MScanListView(); virtual OListViewItem* childFactory(); virtual void serializeTo( QDataStream& s ) const; virtual void serializeFrom( QDataStream& s ); public slots: void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); void identify( const OMacAddress&, const QString& ipaddr ); + void contextMenuRequested( QListViewItem* item, const QPoint&, int ); + + signals: + void rightButtonClicked(QListViewItem*,const QPoint&,int); + void joinNetwork( const QString&, const QString&, int, const QString& ); + protected: void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); }; //****************************** MScanListItem **************************************************************** class MScanListItem: public OListViewItem { public: MScanListItem::MScanListItem( QListView* parent, QString type = "unknown", QString essid = "unknown", QString macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); MScanListItem::MScanListItem( QListViewItem* parent, QString type = "unknown", QString essid = "unknown", QString macaddr = "unknown", bool wep = false, int channel = 0, int signal = 0 ); 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& essid() const; 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 OListViewItem* childFactory(); virtual void serializeTo( QDataStream& s ) const; virtual void serializeFrom( QDataStream& s ); protected: void playSound( const QString& ) 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 2f26702..8a9e55d 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -7,48 +7,49 @@ ** 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. ** ***********************************************************************/ // Local #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "hexwindow.h" #include "configwindow.h" #include "statwindow.h" #include "graphwindow.h" #include "protolistview.h" // Opie #ifdef QWS #include <opie/odevice.h> +#include <qpe/qcopenvelope_qws.h> using namespace Opie; #endif #ifdef QWS #include <opie2/oapplication.h> #else #include <qapplication.h> #endif #include <opie2/onetwork.h> #include <opie2/opcap.h> // Qt #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qmessagebox.h> #include <qobjectlist.h> #include <qregexp.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qmainwindow.h> @@ -60,48 +61,50 @@ using namespace Opie; #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), configwindow( 0 ) { logwindow->log( "(i) Wellenreiter has been started." ); // // detect operating system // #ifdef QWS QString sys; sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif netview->setColumnWidthMode( 1, QListView::Manual ); + connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), + this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); pcap = new OPacketCapturer(); } Wellenreiter::~Wellenreiter() { delete pcap; } void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) { configwindow = cw; } void Wellenreiter::channelHopped(int c) { QString title = "Wellenreiter II -scan- ["; QString left; if ( c > 1 ) left.fill( '.', c-1 ); title.append( left ); title.append( '|' ); if ( c < iface->channels() ) @@ -467,24 +470,39 @@ void Wellenreiter::timerEvent( QTimerEvent* ) delete p; } } void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) { if ( action == "TouchSound" ) ODevice::inst()->touchSound(); else if ( action == "AlarmSound" ) ODevice::inst()->alarmSound(); else if ( action == "KeySound" ) ODevice::inst()->keySound(); else if ( action == "LedOn" ) ODevice::inst()->setLedState( Led_Mail, Led_On ); else if ( action == "LedOff" ) ODevice::inst()->setLedState( Led_Mail, Led_Off ); else if ( action == "LogMessage" ) logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); else if ( action == "MessageBox" ) QMessageBox::information ( this, "Notification!", QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); } +void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) +{ + qDebug( "joinNetwork() - %s, %s, %d, %s", + (const char*) type, + (const char*) essid, + channel, + (const char*) macaddr ); + + // TODO: Stop scanning here + + QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); + msg << "test" << "test" << "test"; + +} + diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index f23ca4d..e1062df 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -38,48 +38,50 @@ 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; }; MHexWindow* hexWindow() const { return hexwindow; }; bool isDaemonRunning() const { return sniffing; }; public: bool sniffing; protected: virtual void timerEvent( QTimerEvent* ); public slots: void channelHopped(int); void receivePacket(OPacket*); void startClicked(); void stopClicked(); + void joinNetwork(const QString&,const QString&,int,const QString&); + signals: void startedSniffing(); void stoppedSniffing(); private: void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); void handleData( OPacket* p, OWaveLanDataPacket* data ); void handleNotification( OPacket* p ); void doAction( const QString& action, const QString& protocol, OPacket* p ); QObject* childIfToParse( OPacket* p, const QString& protocol ); bool checkDumpPacket( OPacket* p ); private: #ifdef QWS OSystem _system; // Opie Operating System identifier #endif OWirelessNetworkInterface* iface; OPacketCapturer* pcap; WellenreiterConfigWindow* configwindow; //void readConfig(); //void writeConfig(); }; |