summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp39
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h8
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp18
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
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
@@ -17,14 +17,16 @@
#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
@@ -71,12 +73,20 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
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()
{
};
@@ -314,12 +324,33 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
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 )
@@ -342,12 +373,20 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid
#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
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
@@ -44,12 +44,18 @@ class MScanListView: public OListView
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 ****************************************************************
@@ -79,13 +85,13 @@ class MScanListItem: public OListViewItem
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; };
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
@@ -25,12 +25,13 @@
#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
@@ -78,12 +79,14 @@ Wellenreiter::Wellenreiter( QWidget* parent )
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()
{
@@ -485,6 +488,21 @@ void Wellenreiter::doAction( const QString& action, const QString& protocol, OPa
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
@@ -56,12 +56,14 @@ class Wellenreiter : public WellenreiterBase {
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 );