Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 58 |
1 files changed, 52 insertions, 6 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 | |||
@@ -29,4 +29,5 @@ | |||
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 | ||
@@ -60,4 +61,45 @@ void Wellenreiter::handleMessage() | |||
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 | /* | ||
70 | typedef 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 | ||
@@ -65,4 +107,7 @@ void Wellenreiter::handleMessage() | |||
65 | bool Wellenreiter::hasMessage() | 107 | bool 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 ); |
@@ -71,10 +116,11 @@ bool Wellenreiter::hasMessage() | |||
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 | ||
76 | void Wellenreiter::timerEvent( QTimerEvent* e ) | 122 | void Wellenreiter::timerEvent( QTimerEvent* e ) |
77 | { | 123 | { |
78 | // qDebug( "checking for message..." ); | 124 | qDebug( "checking for message..." ); |
79 | 125 | ||
80 | if ( hasMessage() ) | 126 | if ( hasMessage() ) |
@@ -84,9 +130,9 @@ void Wellenreiter::timerEvent( QTimerEvent* e ) | |||
84 | else | 130 | else |
85 | { | 131 | { |
86 | // qDebug( "no message :(" ); | 132 | qDebug( "no message :(" ); |
87 | } | 133 | } |
88 | } | 134 | } |
89 | 135 | ||
90 | void Wellenreiter::addNewStation( QString type, QString essid, QString ap, bool wep, int channel, int signal ) | 136 | void 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 |
@@ -121,6 +167,6 @@ void Wellenreiter::buttonClicked() | |||
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 | } |