summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-06-15 12:45:31 (UTC)
committer mickeyl <mickeyl>2003-06-15 12:45:31 (UTC)
commit6b682070b6d83f3537dd9fa5aee715ab142a04e6 (patch) (unidiff)
treeb152def34a4fe52ef6195af9c1c324b23a3d7981
parent7feda6ad0e05602d0a939f9867f296f62ae758cd (diff)
downloadopie-6b682070b6d83f3537dd9fa5aee715ab142a04e6.zip
opie-6b682070b6d83f3537dd9fa5aee715ab142a04e6.tar.gz
opie-6b682070b6d83f3537dd9fa5aee715ab142a04e6.tar.bz2
basic framework for context menu "join network" established
just need to send the proper qcop messages now
Diffstat (more/less context) (show 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
@@ -19,10 +19,12 @@
19 19
20#include <assert.h> 20#include <assert.h>
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qtextstream.h> 22#include <qtextstream.h>
23#include <qpopupmenu.h>
23 24
24#ifdef QWS 25#ifdef QWS
26#include <qpe/qpeapplication.h>
25#include <opie/odevice.h> 27#include <opie/odevice.h>
26using namespace Opie; 28using namespace Opie;
27#endif 29#endif
28 30
@@ -73,8 +75,16 @@ MScanListView::MScanListView( QWidget* parent, const char* name )
73 addColumn( tr( "Last Seen" ) ); 75 addColumn( tr( "Last Seen" ) );
74 setColumnAlignment( col_lastseen, AlignCenter ); 76 setColumnAlignment( col_lastseen, AlignCenter );
75 setRootIsDecorated( true ); 77 setRootIsDecorated( true );
76 setAllColumnsShowFocus( true ); 78 setAllColumnsShowFocus( true );
79
80 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
81 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
82
83 #ifdef QWS
84 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
85 #endif
86
77}; 87};
78 88
79 89
80MScanListView::~MScanListView() 90MScanListView::~MScanListView()
@@ -316,8 +326,29 @@ void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
316 (const char*) macaddr.toString(), (const char*) ip ) ); 326 (const char*) macaddr.toString(), (const char*) ip ) );
317} 327}
318 328
319 329
330void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col )
331{
332 if ( !item ) return;
333
334 MScanListItem* itm = static_cast<MScanListItem*>( item );
335
336 qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'",
337 (const char*) itm->text(0), (const char*) itm->type, col );
338
339 if ( itm->type == "adhoc" || itm->type == "managed" )
340 {
341 QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() );
342
343 QPopupMenu m( this );
344 m.insertItem( entry, 37773, 0 );
345 int result = m.exec( QCursor::pos() );
346 if ( result == 37773 )
347 emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() );
348 }
349}
350
320//============================================================ 351//============================================================
321// MScanListItem 352// MScanListItem
322//============================================================ 353//============================================================
323 354
@@ -344,8 +375,16 @@ MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid
344 #endif 375 #endif
345 decorateItem( type, essid, macaddr, wep, channel, signal ); 376 decorateItem( type, essid, macaddr, wep, channel, signal );
346} 377}
347 378
379const QString& MScanListItem::essid() const
380{
381 if ( type == "network" )
382 return _essid;
383 else
384 return ( (MScanListItem*) parent() )->essid();
385}
386
348OListViewItem* MScanListItem::childFactory() 387OListViewItem* MScanListItem::childFactory()
349{ 388{
350 return new MScanListItem( this ); 389 return new MScanListItem( this );
351} 390}
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
@@ -46,8 +46,14 @@ class MScanListView: public OListView
46 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 46 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
47 47
48 void identify( const OMacAddress&, const QString& ipaddr ); 48 void identify( const OMacAddress&, const QString& ipaddr );
49 49
50 void contextMenuRequested( QListViewItem* item, const QPoint&, int );
51
52 signals:
53 void rightButtonClicked(QListViewItem*,const QPoint&,int);
54 void joinNetwork( const QString&, const QString&, int, const QString& );
55
50 protected: 56 protected:
51 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 57 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" );
52 58
53}; 59};
@@ -81,9 +87,9 @@ class MScanListItem: public OListViewItem
81 QString type; 87 QString type;
82 88
83 public: 89 public:
84 //const QString& type() { return _type; }; 90 //const QString& type() { return _type; };
85 const QString& essid() { return _essid; }; 91 const QString& essid() const;
86 const QString& macaddr() { return _macaddr; }; 92 const QString& macaddr() { return _macaddr; };
87 bool wep() { return _wep; }; 93 bool wep() { return _wep; };
88 int channel() { return _channel; }; 94 int channel() { return _channel; };
89 int signal() { return _signal; }; 95 int signal() { return _signal; };
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
@@ -27,8 +27,9 @@
27// Opie 27// Opie
28 28
29#ifdef QWS 29#ifdef QWS
30#include <opie/odevice.h> 30#include <opie/odevice.h>
31#include <qpe/qcopenvelope_qws.h>
31using namespace Opie; 32using namespace Opie;
32#endif 33#endif
33 34
34#ifdef QWS 35#ifdef QWS
@@ -80,8 +81,10 @@ Wellenreiter::Wellenreiter( QWidget* parent )
80 logwindow->log( sys ); 81 logwindow->log( sys );
81 #endif 82 #endif
82 83
83 netview->setColumnWidthMode( 1, QListView::Manual ); 84 netview->setColumnWidthMode( 1, QListView::Manual );
85 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
86 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
84 pcap = new OPacketCapturer(); 87 pcap = new OPacketCapturer();
85} 88}
86 89
87 90
@@ -487,4 +490,19 @@ void Wellenreiter::doAction( const QString& action, const QString& protocol, OPa
487 QMessageBox::information ( this, "Notification!", 490 QMessageBox::information ( this, "Notification!",
488 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 491 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
489} 492}
490 493
494void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
495{
496 qDebug( "joinNetwork() - %s, %s, %d, %s",
497 (const char*) type,
498 (const char*) essid,
499 channel,
500 (const char*) macaddr );
501
502 // TODO: Stop scanning here
503
504 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
505 msg << "test" << "test" << "test";
506
507}
508
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
@@ -58,8 +58,10 @@ class Wellenreiter : public WellenreiterBase {
58 void receivePacket(OPacket*); 58 void receivePacket(OPacket*);
59 void startClicked(); 59 void startClicked();
60 void stopClicked(); 60 void stopClicked();
61 61
62 void joinNetwork(const QString&,const QString&,int,const QString&);
63
62 signals: 64 signals:
63 void startedSniffing(); 65 void startedSniffing();
64 void stoppedSniffing(); 66 void stoppedSniffing();
65 67