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) (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
@@ -1,455 +1,494 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h" 17#include "configwindow.h"
18#include "logwindow.h" 18#include "logwindow.h"
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
29 31
30#ifdef QWS 32#ifdef QWS
31#include <qpe/resource.h> 33#include <qpe/resource.h>
32#else 34#else
33#include "resource.h" 35#include "resource.h"
34#endif 36#endif
35 37
36const int col_type = 0; 38const int col_type = 0;
37const int col_essid = 0; 39const int col_essid = 0;
38const int col_sig = 1; 40const int col_sig = 1;
39const int col_ap = 2; 41const int col_ap = 2;
40const int col_channel = 3; 42const int col_channel = 3;
41const int col_wep = 4; 43const int col_wep = 4;
42const int col_traffic = 5; 44const int col_traffic = 5;
43const int col_ip = 6; 45const int col_ip = 6;
44const int col_manuf = 7; 46const int col_manuf = 7;
45const int col_firstseen = 8; 47const int col_firstseen = 8;
46const int col_lastseen = 9; 48const int col_lastseen = 9;
47 49
48MScanListView::MScanListView( QWidget* parent, const char* name ) 50MScanListView::MScanListView( QWidget* parent, const char* name )
49 :OListView( parent, name ) 51 :OListView( parent, name )
50{ 52{
51 53
52 setFrameShape( QListView::StyledPanel ); 54 setFrameShape( QListView::StyledPanel );
53 setFrameShadow( QListView::Sunken ); 55 setFrameShadow( QListView::Sunken );
54 56
55 addColumn( tr( "Net/Station" ) ); 57 addColumn( tr( "Net/Station" ) );
56 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 58 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
57 addColumn( tr( "#" ) ); 59 addColumn( tr( "#" ) );
58 setColumnAlignment( col_sig, AlignCenter ); 60 setColumnAlignment( col_sig, AlignCenter );
59 addColumn( tr( "MAC" ) ); 61 addColumn( tr( "MAC" ) );
60 setColumnAlignment( col_ap, AlignCenter ); 62 setColumnAlignment( col_ap, AlignCenter );
61 addColumn( tr( "Chn" ) ); 63 addColumn( tr( "Chn" ) );
62 setColumnAlignment( col_channel, AlignCenter ); 64 setColumnAlignment( col_channel, AlignCenter );
63 addColumn( tr( "W" ) ); 65 addColumn( tr( "W" ) );
64 setColumnAlignment( col_wep, AlignCenter ); 66 setColumnAlignment( col_wep, AlignCenter );
65 addColumn( tr( "T" ) ); 67 addColumn( tr( "T" ) );
66 setColumnAlignment( col_traffic, AlignCenter ); 68 setColumnAlignment( col_traffic, AlignCenter );
67 addColumn( tr( "IP" ) ); 69 addColumn( tr( "IP" ) );
68 setColumnAlignment( col_ip, AlignCenter ); 70 setColumnAlignment( col_ip, AlignCenter );
69 addColumn( tr( "Manufacturer" ) ); 71 addColumn( tr( "Manufacturer" ) );
70 setColumnAlignment( col_manuf, AlignCenter ); 72 setColumnAlignment( col_manuf, AlignCenter );
71 addColumn( tr( "First Seen" ) ); 73 addColumn( tr( "First Seen" ) );
72 setColumnAlignment( col_firstseen, AlignCenter ); 74 setColumnAlignment( col_firstseen, AlignCenter );
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()
81{ 91{
82}; 92};
83 93
84 94
85OListViewItem* MScanListView::childFactory() 95OListViewItem* MScanListView::childFactory()
86{ 96{
87 return new MScanListItem( this ); 97 return new MScanListItem( this );
88} 98}
89 99
90 100
91void MScanListView::serializeTo( QDataStream& s) const 101void MScanListView::serializeTo( QDataStream& s) const
92{ 102{
93 qDebug( "serializing MScanListView" ); 103 qDebug( "serializing MScanListView" );
94 OListView::serializeTo( s ); 104 OListView::serializeTo( s );
95} 105}
96 106
97 107
98void MScanListView::serializeFrom( QDataStream& s) 108void MScanListView::serializeFrom( QDataStream& s)
99{ 109{
100 qDebug( "serializing MScanListView" ); 110 qDebug( "serializing MScanListView" );
101 OListView::serializeFrom( s ); 111 OListView::serializeFrom( s );
102} 112}
103 113
104 114
105void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal ) 115void MScanListView::addNewItem( const QString& type, const QString& essid, const OMacAddress& mac, bool wep, int channel, int signal )
106{ 116{
107 QString macaddr = mac.toString(true); 117 QString macaddr = mac.toString(true);
108 118
109 #ifdef DEBUG 119 #ifdef DEBUG
110 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 120 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
111 (const char*) essid, (const char*) macaddr, channel ); 121 (const char*) essid, (const char*) macaddr, channel );
112 #endif 122 #endif
113 123
114 // search, if we already have seen this net 124 // search, if we already have seen this net
115 125
116 QString s; 126 QString s;
117 MScanListItem* network; 127 MScanListItem* network;
118 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 128 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
119 129
120 while ( item && ( item->text( col_essid ) != essid ) ) 130 while ( item && ( item->text( col_essid ) != essid ) )
121 { 131 {
122 #ifdef DEBUG 132 #ifdef DEBUG
123 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 133 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
124 #endif 134 #endif
125 item = static_cast<MScanListItem*> ( item->nextSibling() ); 135 item = static_cast<MScanListItem*> ( item->nextSibling() );
126 } 136 }
127 if ( item ) 137 if ( item )
128 { 138 {
129 // we have already seen this net, check all childs if MAC exists 139 // we have already seen this net, check all childs if MAC exists
130 140
131 network = item; 141 network = item;
132 142
133 item = static_cast<MScanListItem*> ( item->firstChild() ); 143 item = static_cast<MScanListItem*> ( item->firstChild() );
134 assert( item ); // this shouldn't fail 144 assert( item ); // this shouldn't fail
135 145
136 while ( item && ( item->text( col_ap ) != macaddr ) ) 146 while ( item && ( item->text( col_ap ) != macaddr ) )
137 { 147 {
138 #ifdef DEBUG 148 #ifdef DEBUG
139 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); 149 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
140 #endif 150 #endif
141 item = static_cast<MScanListItem*> ( item->nextSibling() ); 151 item = static_cast<MScanListItem*> ( item->nextSibling() );
142 } 152 }
143 153
144 if ( item ) 154 if ( item )
145 { 155 {
146 // we have already seen this item, it's a dupe 156 // we have already seen this item, it's a dupe
147 #ifdef DEBUG 157 #ifdef DEBUG
148 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 158 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
149 #endif 159 #endif
150 item->receivedBeacon(); 160 item->receivedBeacon();
151 return; 161 return;
152 } 162 }
153 } 163 }
154 else 164 else
155 { 165 {
156 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 166 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
157 MLogWindow::logwindow()->log( s ); 167 MLogWindow::logwindow()->log( s );
158 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 ); 168 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0 );
159 } 169 }
160 170
161 171
162 // insert new station as child from network 172 // insert new station as child from network
163 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 173 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
164 174
165 #ifdef DEBUG 175 #ifdef DEBUG
166 qDebug( "inserting new station %s", (const char*) macaddr ); 176 qDebug( "inserting new station %s", (const char*) macaddr );
167 #endif 177 #endif
168 178
169 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 179 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
170 station->setManufacturer( mac.manufacturer() ); 180 station->setManufacturer( mac.manufacturer() );
171 181
172 if ( type == "managed" ) 182 if ( type == "managed" )
173 { 183 {
174 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 184 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
175 } 185 }
176 else 186 else
177 { 187 {
178 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 188 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
179 } 189 }
180 MLogWindow::logwindow()->log( s ); 190 MLogWindow::logwindow()->log( s );
181 191
182} 192}
183 193
184 194
185void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 195void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
186{ 196{
187 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 197 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
188 198
189 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 199 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
190 { 200 {
191 #ifdef DEBUG 201 #ifdef DEBUG
192 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 202 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
193 #endif 203 #endif
194 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 204 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
195 } 205 }
196 206
197 if ( subitem ) 207 if ( subitem )
198 { 208 {
199 // we have already seen this item, it's a dupe 209 // we have already seen this item, it's a dupe
200 #ifdef DEBUG 210 #ifdef DEBUG
201 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); 211 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
202 #endif 212 #endif
203 subitem->receivedBeacon(); //FIXME: sent data bit 213 subitem->receivedBeacon(); //FIXME: sent data bit
204 return; 214 return;
205 } 215 }
206 216
207 // Hey, it seems to be a new item :-D 217 // Hey, it seems to be a new item :-D
208 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 218 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
209 station->setManufacturer( addr.manufacturer() ); 219 station->setManufacturer( addr.manufacturer() );
210 220
211 QString s; 221 QString s;
212 if ( type == "station" ) 222 if ( type == "station" )
213 { 223 {
214 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 224 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
215 } 225 }
216 else 226 else
217 { 227 {
218 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 228 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
219 } 229 }
220 MLogWindow::logwindow()->log( s ); 230 MLogWindow::logwindow()->log( s );
221} 231}
222 232
223 233
224void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) 234void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo )
225{ 235{
226 QString s; 236 QString s;
227 MScanListItem* network; 237 MScanListItem* network;
228 238
229 QListViewItemIterator it( this ); 239 QListViewItemIterator it( this );
230 while ( it.current() && 240 while ( it.current() &&
231 it.current()->text( col_ap ) != viaFrom.toString(true) && 241 it.current()->text( col_ap ) != viaFrom.toString(true) &&
232 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; 242 it.current()->text( col_ap ) != viaTo.toString(true) ) ++it;
233 243
234 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 244 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
235 245
236 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations 246 if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations
237 { 247 {
238 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); 248 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from );
239 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); 249 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to );
240 } 250 }
241 else 251 else
242 { 252 {
243 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); 253 qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" );
244 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); 254 MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" );
245 } 255 }
246} 256}
247 257
248 258
249void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 259void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
250{ 260{
251 QString s; 261 QString s;
252 MScanListItem* network; 262 MScanListItem* network;
253 263
254 QListViewItemIterator it( this ); 264 QListViewItemIterator it( this );
255 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 265 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
256 266
257 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 267 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
258 268
259 if ( item ) // AP has shown up yet, so just add our new "from" - station 269 if ( item ) // AP has shown up yet, so just add our new "from" - station
260 { 270 {
261 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); 271 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" );
262 } 272 }
263 else 273 else
264 { 274 {
265 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 275 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
266 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); 276 MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" );
267 277
268 } 278 }
269} 279}
270 280
271 281
272void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 282void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
273{ 283{
274 QString s; 284 QString s;
275 MScanListItem* network; 285 MScanListItem* network;
276 286
277 QListViewItemIterator it( this ); 287 QListViewItemIterator it( this );
278 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; 288 while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it;
279 289
280 MScanListItem* item = static_cast<MScanListItem*>( it.current() ); 290 MScanListItem* item = static_cast<MScanListItem*>( it.current() );
281 291
282 if ( item ) // AP has shown up yet, so just add our new "from" - station 292 if ( item ) // AP has shown up yet, so just add our new "from" - station
283 { 293 {
284 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); 294 addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" );
285 } 295 }
286 else 296 else
287 { 297 {
288 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); 298 qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" );
289 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); 299 MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" );
290 } 300 }
291} 301}
292 302
293 303
294void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) 304void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via )
295{ 305{
296 qWarning( "D'oh! Not yet implemented..." ); 306 qWarning( "D'oh! Not yet implemented..." );
297 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); 307 MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" );
298} 308}
299 309
300 310
301void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) 311void MScanListView::identify( const OMacAddress& macaddr, const QString& ip )
302{ 312{
303 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); 313 qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip );
304 314
305 QListViewItemIterator it( this ); 315 QListViewItemIterator it( this );
306 for ( ; it.current(); ++it ) 316 for ( ; it.current(); ++it )
307 { 317 {
308 if ( it.current()->text( col_ap ) == macaddr.toString(true) ) 318 if ( it.current()->text( col_ap ) == macaddr.toString(true) )
309 { 319 {
310 it.current()->setText( col_ip, ip ); 320 it.current()->setText( col_ip, ip );
311 return; 321 return;
312 } 322 }
313 } 323 }
314 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); 324 qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" );
315 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", 325 MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!",
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
324MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr, 355MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
325 bool wep, int channel, int signal ) 356 bool wep, int channel, int signal )
326 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), 357 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
327 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), 358 _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
328 _channel( channel ), _signal( signal ), _beacons( 1 ) 359 _channel( channel ), _signal( signal ), _beacons( 1 )
329{ 360{
330 #ifdef DEBUG 361 #ifdef DEBUG
331 qDebug( "creating scanlist item" ); 362 qDebug( "creating scanlist item" );
332 #endif 363 #endif
333 if ( WellenreiterConfigWindow::instance() && type == "network" ) 364 if ( WellenreiterConfigWindow::instance() && type == "network" )
334 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() ); 365 playSound( WellenreiterConfigWindow::instance()->soundOnNetwork() );
335 decorateItem( type, essid, macaddr, wep, channel, signal ); 366 decorateItem( type, essid, macaddr, wep, channel, signal );
336} 367}
337 368
338MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr, 369MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
339 bool wep, int channel, int signal ) 370 bool wep, int channel, int signal )
340 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) 371 :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
341{ 372{
342 #ifdef DEBUG 373 #ifdef DEBUG
343 qDebug( "creating scanlist item" ); 374 qDebug( "creating scanlist item" );
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}
352 391
353void MScanListItem::serializeTo( QDataStream& s ) const 392void MScanListItem::serializeTo( QDataStream& s ) const
354{ 393{
355 #ifdef DEBUG 394 #ifdef DEBUG
356 qDebug( "serializing MScanListItem" ); 395 qDebug( "serializing MScanListItem" );
357 #endif 396 #endif
358 OListViewItem::serializeTo( s ); 397 OListViewItem::serializeTo( s );
359 398
360 s << _type; 399 s << _type;
361 s << (Q_UINT8) ( _wep ? 'y' : 'n' ); 400 s << (Q_UINT8) ( _wep ? 'y' : 'n' );
362} 401}
363 402
364void MScanListItem::serializeFrom( QDataStream& s ) 403void MScanListItem::serializeFrom( QDataStream& s )
365{ 404{
366 #ifdef DEBUG 405 #ifdef DEBUG
367 qDebug( "serializing MScanListItem" ); 406 qDebug( "serializing MScanListItem" );
368 #endif 407 #endif
369 OListViewItem::serializeFrom( s ); 408 OListViewItem::serializeFrom( s );
370 409
371 char wep; 410 char wep;
372 s >> _type; 411 s >> _type;
373 s >> (Q_UINT8) wep; 412 s >> (Q_UINT8) wep;
374 _wep = (wep == 'y'); 413 _wep = (wep == 'y');
375 414
376 QString name; 415 QString name;
377 name.sprintf( "wellenreiter/%s", (const char*) _type ); 416 name.sprintf( "wellenreiter/%s", (const char*) _type );
378 setPixmap( col_type, Resource::loadPixmap( name ) ); 417 setPixmap( col_type, Resource::loadPixmap( name ) );
379 if ( _wep ) 418 if ( _wep )
380 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 419 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
381 listView()->triggerUpdate(); 420 listView()->triggerUpdate();
382} 421}
383 422
384void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ) 423void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
385{ 424{
386 #ifdef DEBUG 425 #ifdef DEBUG
387 qDebug( "decorating scanlist item %s / %s / %s [%d]", 426 qDebug( "decorating scanlist item %s / %s / %s [%d]",
388 (const char*) type, 427 (const char*) type,
389 (const char*) essid, 428 (const char*) essid,
390 (const char*) macaddr, 429 (const char*) macaddr,
391 channel ); 430 channel );
392 #endif 431 #endif
393 432
394 // set icon for managed or adhoc mode 433 // set icon for managed or adhoc mode
395 QString name; 434 QString name;
396 name.sprintf( "wellenreiter/%s", (const char*) type ); 435 name.sprintf( "wellenreiter/%s", (const char*) type );
397 setPixmap( col_type, Resource::loadPixmap( name ) ); 436 setPixmap( col_type, Resource::loadPixmap( name ) );
398 437
399 // set icon for wep (wireless encryption protocol) 438 // set icon for wep (wireless encryption protocol)
400 if ( wep ) 439 if ( wep )
401 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! 440 setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
402 441
403 // set channel and signal text 442 // set channel and signal text
404 443
405 if ( signal != -1 ) 444 if ( signal != -1 )
406 setText( col_sig, QString::number( signal ) ); 445 setText( col_sig, QString::number( signal ) );
407 if ( channel != -1 ) 446 if ( channel != -1 )
408 setText( col_channel, QString::number( channel ) ); 447 setText( col_channel, QString::number( channel ) );
409 448
410 setText( col_firstseen, QTime::currentTime().toString() ); 449 setText( col_firstseen, QTime::currentTime().toString() );
411 //setText( col_lastseen, QTime::currentTime().toString() ); 450 //setText( col_lastseen, QTime::currentTime().toString() );
412 451
413 listView()->triggerUpdate(); 452 listView()->triggerUpdate();
414 453
415 this->type = type; 454 this->type = type;
416 _type = type; 455 _type = type;
417 _essid = essid; 456 _essid = essid;
418 _macaddr = macaddr; 457 _macaddr = macaddr;
419 _channel = channel; 458 _channel = channel;
420 _beacons = 1; 459 _beacons = 1;
421 _signal = 0; 460 _signal = 0;
422} 461}
423 462
424 463
425void MScanListItem::setManufacturer( const QString& manufacturer ) 464void MScanListItem::setManufacturer( const QString& manufacturer )
426{ 465{
427 setText( col_manuf, manufacturer ); 466 setText( col_manuf, manufacturer );
428} 467}
429 468
430 469
431void MScanListItem::playSound( const QString& sound ) const 470void MScanListItem::playSound( const QString& sound ) const
432{ 471{
433 #ifdef QWS 472 #ifdef QWS
434 if ( sound == "Ignore" ) return; 473 if ( sound == "Ignore" ) return;
435 else if ( sound == "Touch" ) ODevice::inst()->touchSound(); 474 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
436 else if ( sound == "Key" ) ODevice::inst()->keySound(); 475 else if ( sound == "Key" ) ODevice::inst()->keySound();
437 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound(); 476 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
438 #endif 477 #endif
439} 478}
440 479
441 480
442void MScanListItem::receivedBeacon() 481void MScanListItem::receivedBeacon()
443{ 482{
444 _beacons++; 483 _beacons++;
445 #ifdef DEBUG 484 #ifdef DEBUG
446 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); 485 qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
447 #endif 486 #endif
448 setText( col_sig, QString::number( _beacons ) ); 487 setText( col_sig, QString::number( _beacons ) );
449 setText( col_lastseen, QTime::currentTime().toString() ); 488 setText( col_lastseen, QTime::currentTime().toString() );
450 489
451 MScanListItem* p = (MScanListItem*) parent(); 490 MScanListItem* p = (MScanListItem*) parent();
452 if ( p ) p->receivedBeacon(); 491 if ( p ) p->receivedBeacon();
453 492
454} 493}
455 494
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
@@ -1,131 +1,137 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19/* OPIE */ 19/* OPIE */
20#include <opie2/olistview.h> 20#include <opie2/olistview.h>
21#include <opie2/onetutils.h> 21#include <opie2/onetutils.h>
22 22
23/* QT */ 23/* QT */
24#include <qtextstream.h> 24#include <qtextstream.h>
25 25
26class QString; 26class QString;
27class MScanListItem; 27class MScanListItem;
28 28
29class MScanListView: public OListView 29class MScanListView: public OListView
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33 public: 33 public:
34 MScanListView( QWidget* parent = 0, const char* name = 0 ); 34 MScanListView( QWidget* parent = 0, const char* name = 0 );
35 virtual ~MScanListView(); 35 virtual ~MScanListView();
36 36
37 virtual OListViewItem* childFactory(); 37 virtual OListViewItem* childFactory();
38 virtual void serializeTo( QDataStream& s ) const; 38 virtual void serializeTo( QDataStream& s ) const;
39 virtual void serializeFrom( QDataStream& s ); 39 virtual void serializeFrom( QDataStream& s );
40 40
41 public slots: 41 public slots:
42 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal ); 42 void addNewItem( const QString& type, const QString& essid, const OMacAddress& macaddr, bool wep, int channel, int signal );
43 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 43 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
44 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 44 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via );
45 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); 45 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo );
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};
54 60
55//****************************** MScanListItem **************************************************************** 61//****************************** MScanListItem ****************************************************************
56 62
57class MScanListItem: public OListViewItem 63class MScanListItem: public OListViewItem
58{ 64{
59 public: 65 public:
60 MScanListItem::MScanListItem( QListView* parent, 66 MScanListItem::MScanListItem( QListView* parent,
61 QString type = "unknown", 67 QString type = "unknown",
62 QString essid = "unknown", 68 QString essid = "unknown",
63 QString macaddr = "unknown", 69 QString macaddr = "unknown",
64 bool wep = false, 70 bool wep = false,
65 int channel = 0, 71 int channel = 0,
66 int signal = 0 ); 72 int signal = 0 );
67 73
68 MScanListItem::MScanListItem( QListViewItem* parent, 74 MScanListItem::MScanListItem( QListViewItem* parent,
69 QString type = "unknown", 75 QString type = "unknown",
70 QString essid = "unknown", 76 QString essid = "unknown",
71 QString macaddr = "unknown", 77 QString macaddr = "unknown",
72 bool wep = false, 78 bool wep = false,
73 int channel = 0, 79 int channel = 0,
74 int signal = 0 ); 80 int signal = 0 );
75 81
76 82
77 protected: 83 protected:
78 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); 84 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal );
79 85
80 public: 86 public:
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; };
90 int beacons() { return _beacons; }; 96 int beacons() { return _beacons; };
91 97
92 void setSignal( int signal ) { /* TODO */ }; 98 void setSignal( int signal ) { /* TODO */ };
93 void receivedBeacon(); 99 void receivedBeacon();
94 100
95 void setManufacturer( const QString& manufacturer ); 101 void setManufacturer( const QString& manufacturer );
96 102
97 virtual OListViewItem* childFactory(); 103 virtual OListViewItem* childFactory();
98 virtual void serializeTo( QDataStream& s ) const; 104 virtual void serializeTo( QDataStream& s ) const;
99 virtual void serializeFrom( QDataStream& s ); 105 virtual void serializeFrom( QDataStream& s );
100 106
101 protected: 107 protected:
102 void playSound( const QString& ) const; 108 void playSound( const QString& ) const;
103 109
104 private: 110 private:
105 QString _type; 111 QString _type;
106 QString _essid; 112 QString _essid;
107 QString _macaddr; 113 QString _macaddr;
108 bool _wep; 114 bool _wep;
109 int _channel; 115 int _channel;
110 int _signal; 116 int _signal;
111 int _beacons; 117 int _beacons;
112 118
113}; 119};
114 120
115//****************************** MScanListViewFactory **************************************************************** 121//****************************** MScanListViewFactory ****************************************************************
116 122
117/* 123/*
118 124
119class MScanListViewFactory : public OListViewFactory 125class MScanListViewFactory : public OListViewFactory
120{ 126{
121public: 127public:
122 virtual QListView* listViewFactory(); 128 virtual QListView* listViewFactory();
123 virtual QListViewItem* listViewItemFactory( QListView* lv ); 129 virtual QListViewItem* listViewItemFactory( QListView* lv );
124 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 130 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
125 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 131 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
126 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 132 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
127} 133}
128*/ 134*/
129 135
130#endif 136#endif
131 137
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
@@ -1,490 +1,508 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Local 16// Local
17 17
18#include "wellenreiter.h" 18#include "wellenreiter.h"
19#include "scanlist.h" 19#include "scanlist.h"
20#include "logwindow.h" 20#include "logwindow.h"
21#include "hexwindow.h" 21#include "hexwindow.h"
22#include "configwindow.h" 22#include "configwindow.h"
23#include "statwindow.h" 23#include "statwindow.h"
24#include "graphwindow.h" 24#include "graphwindow.h"
25#include "protolistview.h" 25#include "protolistview.h"
26 26
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
35#include <opie2/oapplication.h> 36#include <opie2/oapplication.h>
36#else 37#else
37#include <qapplication.h> 38#include <qapplication.h>
38#endif 39#endif
39#include <opie2/onetwork.h> 40#include <opie2/onetwork.h>
40#include <opie2/opcap.h> 41#include <opie2/opcap.h>
41 42
42// Qt 43// Qt
43 44
44#include <qcheckbox.h> 45#include <qcheckbox.h>
45#include <qcombobox.h> 46#include <qcombobox.h>
46#include <qdatetime.h> 47#include <qdatetime.h>
47#include <qpushbutton.h> 48#include <qpushbutton.h>
48#include <qlineedit.h> 49#include <qlineedit.h>
49#include <qmessagebox.h> 50#include <qmessagebox.h>
50#include <qobjectlist.h> 51#include <qobjectlist.h>
51#include <qregexp.h> 52#include <qregexp.h>
52#include <qspinbox.h> 53#include <qspinbox.h>
53#include <qtoolbutton.h> 54#include <qtoolbutton.h>
54#include <qmainwindow.h> 55#include <qmainwindow.h>
55 56
56// Standard 57// Standard
57 58
58#include <assert.h> 59#include <assert.h>
59#include <errno.h> 60#include <errno.h>
60#include <unistd.h> 61#include <unistd.h>
61#include <string.h> 62#include <string.h>
62#include <sys/types.h> 63#include <sys/types.h>
63#include <stdlib.h> 64#include <stdlib.h>
64 65
65Wellenreiter::Wellenreiter( QWidget* parent ) 66Wellenreiter::Wellenreiter( QWidget* parent )
66 : WellenreiterBase( parent, 0, 0 ), 67 : WellenreiterBase( parent, 0, 0 ),
67 sniffing( false ), iface( 0 ), configwindow( 0 ) 68 sniffing( false ), iface( 0 ), configwindow( 0 )
68{ 69{
69 70
70 logwindow->log( "(i) Wellenreiter has been started." ); 71 logwindow->log( "(i) Wellenreiter has been started." );
71 72
72 // 73 //
73 // detect operating system 74 // detect operating system
74 // 75 //
75 76
76 #ifdef QWS 77 #ifdef QWS
77 QString sys; 78 QString sys;
78 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 79 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
79 _system = ODevice::inst()->system(); 80 _system = ODevice::inst()->system();
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
88Wellenreiter::~Wellenreiter() 91Wellenreiter::~Wellenreiter()
89{ 92{
90 delete pcap; 93 delete pcap;
91} 94}
92 95
93 96
94void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 97void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
95{ 98{
96 configwindow = cw; 99 configwindow = cw;
97} 100}
98 101
99 102
100void Wellenreiter::channelHopped(int c) 103void Wellenreiter::channelHopped(int c)
101{ 104{
102 QString title = "Wellenreiter II -scan- ["; 105 QString title = "Wellenreiter II -scan- [";
103 QString left; 106 QString left;
104 if ( c > 1 ) left.fill( '.', c-1 ); 107 if ( c > 1 ) left.fill( '.', c-1 );
105 title.append( left ); 108 title.append( left );
106 title.append( '|' ); 109 title.append( '|' );
107 if ( c < iface->channels() ) 110 if ( c < iface->channels() )
108 { 111 {
109 QString right; 112 QString right;
110 right.fill( '.', iface->channels()-c ); 113 right.fill( '.', iface->channels()-c );
111 title.append( right ); 114 title.append( right );
112 } 115 }
113 title.append( "]" ); 116 title.append( "]" );
114 //title.append( QString().sprintf( " %02d", c ) ); 117 //title.append( QString().sprintf( " %02d", c ) );
115 assert( parent() ); 118 assert( parent() );
116 ( (QMainWindow*) parent() )->setCaption( title ); 119 ( (QMainWindow*) parent() )->setCaption( title );
117} 120}
118 121
119 122
120void Wellenreiter::handleNotification( OPacket* p ) 123void Wellenreiter::handleNotification( OPacket* p )
121{ 124{
122 QObjectList* l = p->queryList(); 125 QObjectList* l = p->queryList();
123 QObjectListIt it( *l ); 126 QObjectListIt it( *l );
124 QObject* o; 127 QObject* o;
125 128
126 while ( (o = it.current()) != 0 ) 129 while ( (o = it.current()) != 0 )
127 { 130 {
128 QString name = it.current()->name(); 131 QString name = it.current()->name();
129 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 132 if ( configwindow->parsePackets->isProtocolChecked( name ) )
130 { 133 {
131 QString action = configwindow->parsePackets->protocolAction( name ); 134 QString action = configwindow->parsePackets->protocolAction( name );
132 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 135 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
133 doAction( action, name, p ); 136 doAction( action, name, p );
134 } 137 }
135 else 138 else
136 { 139 {
137 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 140 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
138 } 141 }
139 ++it; 142 ++it;
140 } 143 }
141} 144}
142 145
143 146
144void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 147void Wellenreiter::handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
145{ 148{
146 QString type; 149 QString type;
147 if ( beacon->canIBSS() ) 150 if ( beacon->canIBSS() )
148 { 151 {
149 type = "adhoc"; 152 type = "adhoc";
150 } 153 }
151 else if ( beacon->canESS() ) 154 else if ( beacon->canESS() )
152 { 155 {
153 type = "managed"; 156 type = "managed";
154 } 157 }
155 else 158 else
156 { 159 {
157 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 160 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
158 return; 161 return;
159 } 162 }
160 163
161 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 164 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
162 QString essid = ssid ? ssid->ID() : QString("<unknown>"); 165 QString essid = ssid ? ssid->ID() : QString("<unknown>");
163 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 166 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
164 int channel = ds ? ds->channel() : -1; 167 int channel = ds ? ds->channel() : -1;
165 168
166 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 169 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
167 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 ); 170 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0 );
168 171
169 // update graph window 172 // update graph window
170 if ( ds ) 173 if ( ds )
171 { 174 {
172 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 175 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
173 if ( prism ) 176 if ( prism )
174 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 177 graphwindow->traffic( ds->channel(), prism->signalStrength() );
175 else 178 else
176 graphwindow->traffic( ds->channel(), 95 ); 179 graphwindow->traffic( ds->channel(), 95 );
177 } 180 }
178} 181}
179 182
180 183
181void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data ) 184void Wellenreiter::handleData( OPacket* p, OWaveLanDataPacket* data )
182{ 185{
183 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 186 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
184 if ( wlan->fromDS() && !wlan->toDS() ) 187 if ( wlan->fromDS() && !wlan->toDS() )
185 { 188 {
186 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 189 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
187 } 190 }
188 else if ( !wlan->fromDS() && wlan->toDS() ) 191 else if ( !wlan->fromDS() && wlan->toDS() )
189 { 192 {
190 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 193 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
191 } 194 }
192 else if ( wlan->fromDS() && wlan->toDS() ) 195 else if ( wlan->fromDS() && wlan->toDS() )
193 { 196 {
194 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 197 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
195 } 198 }
196 else 199 else
197 { 200 {
198 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 201 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
199 } 202 }
200 203
201 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 204 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
202 if ( arp ) 205 if ( arp )
203 { 206 {
204 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 207 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
205 if ( arp->type() == "REQUEST" ) 208 if ( arp->type() == "REQUEST" )
206 { 209 {
207 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 210 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
208 } 211 }
209 else if ( arp->type() == "REPLY" ) 212 else if ( arp->type() == "REPLY" )
210 { 213 {
211 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 214 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
212 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 215 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
213 } 216 }
214 } 217 }
215 218
216 OIPPacket* ip = (OIPPacket*) p->child( "IP" ); 219 OIPPacket* ip = (OIPPacket*) p->child( "IP" );
217 if ( ip ) 220 if ( ip )
218 { 221 {
219 qDebug( "Received IP packet." ); 222 qDebug( "Received IP packet." );
220 } 223 }
221} 224}
222 225
223 226
224QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 227QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
225{ 228{
226 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 229 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
227 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 230 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
228 return 0; 231 return 0;
229 232
230 return p->child( protocol ); 233 return p->child( protocol );
231} 234}
232 235
233 236
234bool Wellenreiter::checkDumpPacket( OPacket* p ) 237bool Wellenreiter::checkDumpPacket( OPacket* p )
235{ 238{
236 // go through all child packets and see if one is inside the child hierarchy for p 239 // go through all child packets and see if one is inside the child hierarchy for p
237 // if so, do what the user requested (protocolAction), e.g. pass or discard 240 // if so, do what the user requested (protocolAction), e.g. pass or discard
238 if ( !configwindow->writeCaptureFile->isOn() ) 241 if ( !configwindow->writeCaptureFile->isOn() )
239 return false; 242 return false;
240 243
241 QObjectList* l = p->queryList(); 244 QObjectList* l = p->queryList();
242 QObjectListIt it( *l ); 245 QObjectListIt it( *l );
243 QObject* o; 246 QObject* o;
244 247
245 while ( (o = it.current()) != 0 ) 248 while ( (o = it.current()) != 0 )
246 { 249 {
247 QString name = it.current()->name(); 250 QString name = it.current()->name();
248 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 251 if ( configwindow->capturePackets->isProtocolChecked( name ) )
249 { 252 {
250 QString action = configwindow->capturePackets->protocolAction( name ); 253 QString action = configwindow->capturePackets->protocolAction( name );
251 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 254 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
252 if ( action == "Discard" ) 255 if ( action == "Discard" )
253 { 256 {
254 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 257 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
255 return false; 258 return false;
256 } 259 }
257 } 260 }
258 else 261 else
259 { 262 {
260 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 263 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
261 } 264 }
262 ++it; 265 ++it;
263 } 266 }
264 return true; 267 return true;
265} 268}
266 269
267 270
268void Wellenreiter::receivePacket( OPacket* p ) 271void Wellenreiter::receivePacket( OPacket* p )
269{ 272{
270 hexWindow()->log( p->dump( 8 ) ); 273 hexWindow()->log( p->dump( 8 ) );
271 274
272 if ( checkDumpPacket( p ) ) 275 if ( checkDumpPacket( p ) )
273 { 276 {
274 pcap->dump( p ); 277 pcap->dump( p );
275 } 278 }
276 279
277 // check if we received a beacon frame 280 // check if we received a beacon frame
278 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 281 OWaveLanManagementPacket* beacon = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
279 if ( beacon && beacon->managementType() == "Beacon" ) 282 if ( beacon && beacon->managementType() == "Beacon" )
280 { 283 {
281 handleBeacon( p, beacon ); 284 handleBeacon( p, beacon );
282 return; 285 return;
283 } 286 }
284 287
285 //TODO: WEP check here 288 //TODO: WEP check here
286 289
287 // check for a data frame 290 // check for a data frame
288 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 291 OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
289 if ( data ) 292 if ( data )
290 { 293 {
291 handleData( p, data ); 294 handleData( p, data );
292 } 295 }
293 296
294 handleNotification( p ); 297 handleNotification( p );
295 298
296} 299}
297 300
298 301
299void Wellenreiter::stopClicked() 302void Wellenreiter::stopClicked()
300{ 303{
301 if ( iface ) 304 if ( iface )
302 { 305 {
303 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 306 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
304 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 307 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
305 iface->setChannelHopping(); // stop hopping channels 308 iface->setChannelHopping(); // stop hopping channels
306 } 309 }
307 else 310 else
308 killTimers(); 311 killTimers();
309 312
310 pcap->close(); 313 pcap->close();
311 sniffing = false; 314 sniffing = false;
312 315
313 if ( iface ) 316 if ( iface )
314 { 317 {
315 // switch off monitor mode 318 // switch off monitor mode
316 iface->setMonitorMode( false ); 319 iface->setMonitorMode( false );
317 // switch off promisc flag 320 // switch off promisc flag
318 iface->setPromiscuousMode( false ); 321 iface->setPromiscuousMode( false );
319 322
320 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 323 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
321 } 324 }
322 325
323 logwindow->log( "(i) Stopped Scanning." ); 326 logwindow->log( "(i) Stopped Scanning." );
324 assert( parent() ); 327 assert( parent() );
325 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 328 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
326 329
327 // message the user 330 // message the user
328 QMessageBox::information( this, "Wellenreiter II", 331 QMessageBox::information( this, "Wellenreiter II",
329 tr( "Your wireless card\nshould now be usable again." ) ); 332 tr( "Your wireless card\nshould now be usable again." ) );
330 333
331 sniffing = false; 334 sniffing = false;
332 emit( stoppedSniffing() ); 335 emit( stoppedSniffing() );
333 336
334 // print out statistics 337 // print out statistics
335 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 338 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
336 statwindow->updateCounter( it.key(), it.data() ); 339 statwindow->updateCounter( it.key(), it.data() );
337} 340}
338 341
339 342
340void Wellenreiter::startClicked() 343void Wellenreiter::startClicked()
341{ 344{
342 // get configuration from config window 345 // get configuration from config window
343 346
344 const QString& interface = configwindow->interfaceName->currentText(); 347 const QString& interface = configwindow->interfaceName->currentText();
345 const int cardtype = configwindow->driverType(); 348 const int cardtype = configwindow->driverType();
346 const int interval = configwindow->hoppingInterval(); 349 const int interval = configwindow->hoppingInterval();
347 350
348 if ( ( interface == "" ) || ( cardtype == 0 ) ) 351 if ( ( interface == "" ) || ( cardtype == 0 ) )
349 { 352 {
350 QMessageBox::information( this, "Wellenreiter II", 353 QMessageBox::information( this, "Wellenreiter II",
351 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 354 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
352 return; 355 return;
353 } 356 }
354 357
355 // configure device 358 // configure device
356 ONetwork* net = ONetwork::instance(); 359 ONetwork* net = ONetwork::instance();
357 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); 360 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface ));
358 361
359 // bring device UP 362 // bring device UP
360 iface->setUp( true ); 363 iface->setUp( true );
361 if ( !iface->isUp() ) 364 if ( !iface->isUp() )
362 { 365 {
363 QMessageBox::warning( this, "Wellenreiter II", 366 QMessageBox::warning( this, "Wellenreiter II",
364 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 367 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
365 return; 368 return;
366 } 369 }
367 370
368 // set monitor mode 371 // set monitor mode
369 bool usePrism = configwindow->usePrismHeader(); 372 bool usePrism = configwindow->usePrismHeader();
370 373
371 switch ( cardtype ) 374 switch ( cardtype )
372 { 375 {
373 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 376 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
374 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 377 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
375 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 378 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
376 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 379 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
377 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 380 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
378 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 381 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
379 default: assert( 0 ); // shouldn't reach this 382 default: assert( 0 ); // shouldn't reach this
380 } 383 }
381 384
382 // switch device into monitor mode 385 // switch device into monitor mode
383 if ( cardtype < DEVTYPE_FILE ) 386 if ( cardtype < DEVTYPE_FILE )
384 { 387 {
385 if ( cardtype != DEVTYPE_MANUAL ) 388 if ( cardtype != DEVTYPE_MANUAL )
386 iface->setMonitorMode( true ); 389 iface->setMonitorMode( true );
387 if ( !iface->monitorMode() ) 390 if ( !iface->monitorMode() )
388 { 391 {
389 QMessageBox::warning( this, "Wellenreiter II", 392 QMessageBox::warning( this, "Wellenreiter II",
390 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) ); 393 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) );
391 return; 394 return;
392 } 395 }
393 } 396 }
394 397
395 // open pcap and start sniffing 398 // open pcap and start sniffing
396 if ( cardtype != DEVTYPE_FILE ) 399 if ( cardtype != DEVTYPE_FILE )
397 { 400 {
398 pcap->open( interface ); 401 pcap->open( interface );
399 402
400 if ( configwindow->writeCaptureFile->isOn() ) 403 if ( configwindow->writeCaptureFile->isOn() )
401 { 404 {
402 QString dumpname( configwindow->captureFileName->text() ); 405 QString dumpname( configwindow->captureFileName->text() );
403 dumpname.append( '-' ); 406 dumpname.append( '-' );
404 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 407 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
405 dumpname.append( ".wellenreiter" ); 408 dumpname.append( ".wellenreiter" );
406 pcap->openDumpFile( dumpname ); 409 pcap->openDumpFile( dumpname );
407 } 410 }
408 else 411 else
409 { 412 {
410 pcap->open( interface ); 413 pcap->open( interface );
411 } 414 }
412 } 415 }
413 else 416 else
414 { 417 {
415 pcap->open( QFile( interface ) ); 418 pcap->open( QFile( interface ) );
416 } 419 }
417 420
418 if ( !pcap->isOpen() ) 421 if ( !pcap->isOpen() )
419 { 422 {
420 QMessageBox::warning( this, "Wellenreiter II", 423 QMessageBox::warning( this, "Wellenreiter II",
421 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) )); 424 tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
422 return; 425 return;
423 } 426 }
424 427
425 // set capturer to non-blocking mode 428 // set capturer to non-blocking mode
426 pcap->setBlocking( false ); 429 pcap->setBlocking( false );
427 430
428 // start channel hopper 431 // start channel hopper
429 if ( cardtype != DEVTYPE_FILE ) 432 if ( cardtype != DEVTYPE_FILE )
430 iface->setChannelHopping( 1000 ); //use interval from config window 433 iface->setChannelHopping( 1000 ); //use interval from config window
431 434
432 if ( cardtype != DEVTYPE_FILE ) 435 if ( cardtype != DEVTYPE_FILE )
433 { 436 {
434 // connect socket notifier and start channel hopper 437 // connect socket notifier and start channel hopper
435 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 438 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
436 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 439 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
437 } 440 }
438 else 441 else
439 { 442 {
440 // start timer for reading packets 443 // start timer for reading packets
441 startTimer( 100 ); 444 startTimer( 100 );
442 } 445 }
443 446
444 logwindow->log( "(i) Started Scanning." ); 447 logwindow->log( "(i) Started Scanning." );
445 sniffing = true; 448 sniffing = true;
446 emit( startedSniffing() ); 449 emit( startedSniffing() );
447 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 450 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
448 else 451 else
449 { 452 {
450 assert( parent() ); 453 assert( parent() );
451 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 454 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
452 } 455 }
453} 456}
454 457
455 458
456void Wellenreiter::timerEvent( QTimerEvent* ) 459void Wellenreiter::timerEvent( QTimerEvent* )
457{ 460{
458 qDebug( "Wellenreiter::timerEvent()" ); 461 qDebug( "Wellenreiter::timerEvent()" );
459 OPacket* p = pcap->next(); 462 OPacket* p = pcap->next();
460 if ( !p ) // no more packets available 463 if ( !p ) // no more packets available
461 { 464 {
462 stopClicked(); 465 stopClicked();
463 } 466 }
464 else 467 else
465 { 468 {
466 receivePacket( p ); 469 receivePacket( p );
467 delete p; 470 delete p;
468 } 471 }
469} 472}
470 473
471 474
472void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 475void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
473{ 476{
474 if ( action == "TouchSound" ) 477 if ( action == "TouchSound" )
475 ODevice::inst()->touchSound(); 478 ODevice::inst()->touchSound();
476 else if ( action == "AlarmSound" ) 479 else if ( action == "AlarmSound" )
477 ODevice::inst()->alarmSound(); 480 ODevice::inst()->alarmSound();
478 else if ( action == "KeySound" ) 481 else if ( action == "KeySound" )
479 ODevice::inst()->keySound(); 482 ODevice::inst()->keySound();
480 else if ( action == "LedOn" ) 483 else if ( action == "LedOn" )
481 ODevice::inst()->setLedState( Led_Mail, Led_On ); 484 ODevice::inst()->setLedState( Led_Mail, Led_On );
482 else if ( action == "LedOff" ) 485 else if ( action == "LedOff" )
483 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 486 ODevice::inst()->setLedState( Led_Mail, Led_Off );
484 else if ( action == "LogMessage" ) 487 else if ( action == "LogMessage" )
485 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 488 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
486 else if ( action == "MessageBox" ) 489 else if ( action == "MessageBox" )
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
@@ -1,89 +1,91 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21#ifdef QWS 21#ifdef QWS
22#include <opie/odevice.h> 22#include <opie/odevice.h>
23using namespace Opie; 23using namespace Opie;
24#endif 24#endif
25 25
26class QTimerEvent; 26class QTimerEvent;
27class QPixmap; 27class QPixmap;
28class OPacket; 28class OPacket;
29class OWaveLanManagementPacket; 29class OWaveLanManagementPacket;
30class OWaveLanDataPacket; 30class OWaveLanDataPacket;
31class OPacketCapturer; 31class OPacketCapturer;
32class OWirelessNetworkInterface; 32class OWirelessNetworkInterface;
33class WellenreiterConfigWindow; 33class WellenreiterConfigWindow;
34class MLogWindow; 34class MLogWindow;
35class MHexWindow; 35class MHexWindow;
36 36
37class Wellenreiter : public WellenreiterBase { 37class Wellenreiter : public WellenreiterBase {
38 Q_OBJECT 38 Q_OBJECT
39 39
40 public: 40 public:
41 Wellenreiter( QWidget* parent = 0 ); 41 Wellenreiter( QWidget* parent = 0 );
42 ~Wellenreiter(); 42 ~Wellenreiter();
43 43
44 void setConfigWindow( WellenreiterConfigWindow* cw ); 44 void setConfigWindow( WellenreiterConfigWindow* cw );
45 MScanListView* netView() const { return netview; }; 45 MScanListView* netView() const { return netview; };
46 MLogWindow* logWindow() const { return logwindow; }; 46 MLogWindow* logWindow() const { return logwindow; };
47 MHexWindow* hexWindow() const { return hexwindow; }; 47 MHexWindow* hexWindow() const { return hexwindow; };
48 bool isDaemonRunning() const { return sniffing; }; 48 bool isDaemonRunning() const { return sniffing; };
49 49
50 public: 50 public:
51 bool sniffing; 51 bool sniffing;
52 52
53 protected: 53 protected:
54 virtual void timerEvent( QTimerEvent* ); 54 virtual void timerEvent( QTimerEvent* );
55 55
56 public slots: 56 public slots:
57 void channelHopped(int); 57 void channelHopped(int);
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
66 private: 68 private:
67 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon ); 69 void handleBeacon( OPacket* p, OWaveLanManagementPacket* beacon );
68 void handleData( OPacket* p, OWaveLanDataPacket* data ); 70 void handleData( OPacket* p, OWaveLanDataPacket* data );
69 void handleNotification( OPacket* p ); 71 void handleNotification( OPacket* p );
70 void doAction( const QString& action, const QString& protocol, OPacket* p ); 72 void doAction( const QString& action, const QString& protocol, OPacket* p );
71 QObject* childIfToParse( OPacket* p, const QString& protocol ); 73 QObject* childIfToParse( OPacket* p, const QString& protocol );
72 bool checkDumpPacket( OPacket* p ); 74 bool checkDumpPacket( OPacket* p );
73 75
74 private: 76 private:
75 #ifdef QWS 77 #ifdef QWS
76 OSystem _system; // Opie Operating System identifier 78 OSystem _system; // Opie Operating System identifier
77 #endif 79 #endif
78 80
79 OWirelessNetworkInterface* iface; 81 OWirelessNetworkInterface* iface;
80 OPacketCapturer* pcap; 82 OPacketCapturer* pcap;
81 WellenreiterConfigWindow* configwindow; 83 WellenreiterConfigWindow* configwindow;
82 84
83 //void readConfig(); 85 //void readConfig();
84 //void writeConfig(); 86 //void writeConfig();
85}; 87};
86 88
87 89
88 90
89#endif 91#endif