summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp58
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
2 files changed, 53 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index afb010c..02a6f76 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -19,24 +19,25 @@
19 19
20// Standard 20// Standard
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <sys/types.h> 23#include <sys/types.h>
24 24
25// Local 25// Local
26 26
27#include "wellenreiter.h" 27#include "wellenreiter.h"
28#include "scanlistitem.h" 28#include "scanlistitem.h"
29 29
30#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! 30#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS!
31#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
31#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! 32#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
32 33
33Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 34Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
34 : WellenreiterBase( parent, name, fl ) 35 : WellenreiterBase( parent, name, fl )
35{ 36{
36 37
37 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 38 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
38 netview->setColumnWidthMode( 1, QListView::Manual ); 39 netview->setColumnWidthMode( 1, QListView::Manual );
39 40
40 // 41 //
41 // setup socket for daemon communication and start poller 42 // setup socket for daemon communication and start poller
42 // 43 //
@@ -50,53 +51,98 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
50} 51}
51 52
52Wellenreiter::~Wellenreiter() 53Wellenreiter::~Wellenreiter()
53{ 54{
54 // no need to delete child widgets, Qt does it all for us 55 // no need to delete child widgets, Qt does it all for us
55} 56}
56 57
57void Wellenreiter::handleMessage() 58void Wellenreiter::handleMessage()
58{ 59{
59 // FIXME: receive message and handle it 60 // FIXME: receive message and handle it
60 61
61 qDebug( "received message from daemon." ); 62 qDebug( "received message from daemon." );
63
64 char buffer[128];
65
66 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) );
67 qDebug( "received %d from recvcomm", result );
68
69/*
70typedef struct {
71 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
72 int ssid_len; Length of SSID
73 int channel; Channel
74 int wep; 1 = WEP enabled ; 0 = disabled
75 char mac[64]; MAC address of Accesspoint
76 char bssid[128]; BSSID of Accesspoint
77} wl_network_t;
78*/
79
80 if ( result == 1 ) /* new network found */
81 {
82 qDebug( "Sniffer said: new network found." );
83 wl_network_t n;
84 get_network_found( &n, (const char*) &buffer );
85 n.bssid[n.ssid_len] = "\0";
86
87 QString type;
88
89 if ( n.net_type == 1 )
90 type == "managed";
91 else
92 type == "adhoc";
93
94 addNewItem( type, n.bssid, n.mac, n.wep, n.channel, 0 );
95
96 }
97
98 else
99
100 {
101 qDebug( "unknown sniffer command." );
102 }
103
62} 104}
63 105
64 106
65bool Wellenreiter::hasMessage() 107bool Wellenreiter::hasMessage()
66{ 108{
109
110 // FIXME: do this in libwellenreiter, not here!!!
111
67 fd_set rfds; 112 fd_set rfds;
68 FD_ZERO( &rfds ); 113 FD_ZERO( &rfds );
69 FD_SET( daemon_fd, &rfds ); 114 FD_SET( daemon_fd, &rfds );
70 struct timeval tv; 115 struct timeval tv;
71 tv.tv_sec = 0; 116 tv.tv_sec = 0;
72 tv.tv_usec = 0; 117 tv.tv_usec = 0;
73 return select( 1, &rfds, NULL, NULL, &tv ); 118 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
119 return FD_ISSET( daemon_fd, &rfds );
74} 120}
75 121
76void Wellenreiter::timerEvent( QTimerEvent* e ) 122void Wellenreiter::timerEvent( QTimerEvent* e )
77{ 123{
78 // qDebug( "checking for message..." ); 124 qDebug( "checking for message..." );
79 125
80 if ( hasMessage() ) 126 if ( hasMessage() )
81 { 127 {
82 handleMessage(); 128 handleMessage();
83 } 129 }
84 else 130 else
85 { 131 {
86 // qDebug( "no message :(" ); 132 qDebug( "no message :(" );
87 } 133 }
88} 134}
89 135
90void Wellenreiter::addNewStation( QString type, QString essid, QString ap, bool wep, int channel, int signal ) 136void Wellenreiter::addNewItem( QString type, QString essid, QString ap, bool wep, int channel, int signal )
91{ 137{
92 // FIXME: this code belongs in customized QListView, not into this class 138 // FIXME: this code belongs in customized QListView, not into this class
93 139
94 // search, if we had an item with this essid once before 140 // search, if we had an item with this essid once before
95 141
96 QListViewItem* item = netview->firstChild(); 142 QListViewItem* item = netview->firstChild();
97 143
98 while ( item && ( item->text( 0 ) != essid ) ) 144 while ( item && ( item->text( 0 ) != essid ) )
99 { 145 {
100 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 146 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
101 item = item->itemBelow(); 147 item = item->itemBelow();
102 } 148 }
@@ -111,16 +157,16 @@ void Wellenreiter::addNewStation( QString type, QString essid, QString ap, bool
111 } 157 }
112} 158}
113 159
114void Wellenreiter::buttonClicked() 160void Wellenreiter::buttonClicked()
115{ 161{
116 162
117 // FIXME: communicate with daemon and set button text according to state 163 // FIXME: communicate with daemon and set button text according to state
118 164
119 button->setText( "Stop Scanning" ); 165 button->setText( "Stop Scanning" );
120 166
121 // add some icons, so that we can see if this works 167 // add some icons, so that we can see if this works
122 168
123 addNewStation( "managed", "MyNet", "04:00:20:EF:A6:43", true, 6, 80 ); 169 addNewItem( "managed", "MyNet", "04:00:20:EF:A6:43", true, 6, 80 );
124 addNewStation( "adhoc", "YourNet", "40:03:A3:E7:56:22", false, 11, 30 ); 170 addNewItem( "adhoc", "YourNet", "40:03:A3:E7:56:22", false, 11, 30 );
125 171
126} 172}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index b0f41e3..61f7503 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -24,25 +24,25 @@ class Wellenreiter : public WellenreiterBase {
24 Q_OBJECT 24 Q_OBJECT
25 25
26public: 26public:
27 27
28 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 28 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
29 ~Wellenreiter(); 29 ~Wellenreiter();
30 30
31protected: 31protected:
32 virtual void timerEvent( QTimerEvent* ); 32 virtual void timerEvent( QTimerEvent* );
33 33
34public slots: 34public slots:
35 void buttonClicked(); 35 void buttonClicked();
36 void addNewStation( QString type, QString essid, QString ap, bool wep, int channel, int signal ); 36 void addNewItem( QString type, QString essid, QString ap, bool wep, int channel, int signal );
37 37
38private: 38private:
39 int daemon_fd; // socket filedescriptor for udp communication socket 39 int daemon_fd; // socket filedescriptor for udp communication socket
40 40
41 bool hasMessage(); 41 bool hasMessage();
42 void handleMessage(); 42 void handleMessage();
43 43
44 //void readConfig(); 44 //void readConfig();
45 //void writeConfig(); 45 //void writeConfig();
46}; 46};
47 47
48#endif 48#endif