summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
authormickeyl <mickeyl>2004-08-24 11:53:43 (UTC)
committer mickeyl <mickeyl>2004-08-24 11:53:43 (UTC)
commitb06390cb17114692a9fd5233d77620b385252480 (patch) (unidiff)
tree91de2ed5b0eb6ed739eb6bd0126e2ad004d6a9bd /noncore/net/wellenreiter/gui/wellenreiter.cpp
parent94611edc1942717faa15861adef25418e40ea626 (diff)
downloadopie-b06390cb17114692a9fd5233d77620b385252480.zip
opie-b06390cb17114692a9fd5233d77620b385252480.tar.gz
opie-b06390cb17114692a9fd5233d77620b385252480.tar.bz2
apply megapatch courtesy Holger 'Zecke' Freyther:
- bump version to 1.0.3-cvs - fix compile warnings - fix PacketViewer not to scroll, when watching in "real time" - fix appending text to log view - update statistics when tab is getting activated
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp70
1 files changed, 41 insertions, 29 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index e801ce7..df8e9c3 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -24,67 +24,68 @@
24/* OPIE */ 24/* OPIE */
25#ifdef QWS 25#ifdef QWS
26#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <opie2/odevice.h> 28#include <opie2/odevice.h>
29#else 29#else
30#include <qapplication.h> 30#include <qapplication.h>
31#endif 31#endif
32#include <opie2/omanufacturerdb.h> 32#include <opie2/omanufacturerdb.h>
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/opcap.h> 34#include <opie2/opcap.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36using namespace Opie::Core;
37using namespace Opie::Net;
38using namespace Opie::Ui;
39 36
40/* QT */ 37/* QT */
41#include <qcheckbox.h> 38#include <qcheckbox.h>
42#include <qcombobox.h> 39#include <qcombobox.h>
43#include <qdatetime.h> 40#include <qdatetime.h>
44#include <qpushbutton.h> 41#include <qpushbutton.h>
45#include <qlineedit.h> 42#include <qlineedit.h>
46#include <qmessagebox.h> 43#include <qmessagebox.h>
47#include <qobjectlist.h> 44#include <qobjectlist.h>
48#include <qregexp.h> 45#include <qregexp.h>
49#include <qspinbox.h> 46#include <qspinbox.h>
50#include <qtimer.h> 47#include <qtimer.h>
51#include <qtoolbutton.h> 48#include <qtoolbutton.h>
52#include <qmainwindow.h> 49#include <qmainwindow.h>
53 50
54/* STD */ 51/* STD */
55#include <assert.h> 52#include <assert.h>
56#include <errno.h> 53#include <errno.h>
57#include <unistd.h> 54#include <unistd.h>
58#include <string.h> 55#include <string.h>
59#include <sys/types.h> 56#include <sys/types.h>
60#include <stdlib.h> 57#include <stdlib.h>
61#include <signal.h> 58#include <signal.h>
62 59
60
61using namespace Opie::Core;
62using namespace Opie::Net;
63using namespace Opie::Ui;
64
63Wellenreiter* Wellenreiter::instance = 0; 65Wellenreiter* Wellenreiter::instance = 0;
64 66
65Wellenreiter::Wellenreiter( QWidget* parent ) 67Wellenreiter::Wellenreiter( QWidget* parent )
66 : WellenreiterBase( parent, 0, 0 ), 68 : WellenreiterBase( parent, 0, 0 ),
67 sniffing( false ), iface( 0 ), configwindow( 0 ) 69 sniffing( false ), iface( 0 ), configwindow( 0 )
68{ 70{
69 71
70 logwindow->log( "(i) Wellenreiter has been started." ); 72 logwindow->log( "(i) Wellenreiter has been started." );
71 73
72 // 74 //
73 // detect operating system 75 // detect operating system
74 // 76 //
75 77
76 #ifdef QWS 78 #ifdef QWS
77 QString sys; 79 QString sys = QString( "(i) Running on '%1'.").arg( ODevice::inst()->systemString() );
78 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 );
84 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 85 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
85 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 86 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
86 pcap = new OPacketCapturer(); 87 pcap = new OPacketCapturer();
87 pcap->setAutoDelete( false ); 88 pcap->setAutoDelete( false );
88 89
89 gps = new GPS( this ); 90 gps = new GPS( this );
90 91
@@ -101,24 +102,25 @@ Wellenreiter::~Wellenreiter()
101} 102}
102 103
103 104
104void Wellenreiter::initialTimer() 105void Wellenreiter::initialTimer()
105{ 106{
106 odebug << "preloading manufacturer database..." << oendl; 107 odebug << "preloading manufacturer database..." << oendl;
107 OManufacturerDB::instance(); 108 OManufacturerDB::instance();
108} 109}
109 110
110 111
111void Wellenreiter::signalHandler( int sig ) 112void Wellenreiter::signalHandler( int sig )
112{ 113{
114 Q_UNUSED( sig )
113 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; 115 oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl;
114 if ( Wellenreiter::instance->sniffing ) 116 if ( Wellenreiter::instance->sniffing )
115 { 117 {
116 Wellenreiter::instance->pcap->closeDumpFile(); 118 Wellenreiter::instance->pcap->closeDumpFile();
117 Wellenreiter::instance->pcap->close(); 119 Wellenreiter::instance->pcap->close();
118 Wellenreiter::instance->stopClicked(); 120 Wellenreiter::instance->stopClicked();
119 } 121 }
120 oerr << "Phew. Seemed to work." << oendl; 122 oerr << "Phew. Seemed to work." << oendl;
121 ::exit( -1 ); 123 ::exit( -1 );
122} 124}
123 125
124 126
@@ -167,74 +169,74 @@ void Wellenreiter::channelHopped(int c)
167void Wellenreiter::handleNotification( OPacket* p ) 169void Wellenreiter::handleNotification( OPacket* p )
168{ 170{
169 QObjectList* l = p->queryList(); 171 QObjectList* l = p->queryList();
170 QObjectListIt it( *l ); 172 QObjectListIt it( *l );
171 QObject* o; 173 QObject* o;
172 174
173 while ( (o = it.current()) != 0 ) 175 while ( (o = it.current()) != 0 )
174 { 176 {
175 QString name = it.current()->name(); 177 QString name = it.current()->name();
176 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 178 if ( configwindow->parsePackets->isProtocolChecked( name ) )
177 { 179 {
178 QString action = configwindow->parsePackets->protocolAction( name ); 180 QString action = configwindow->parsePackets->protocolAction( name );
179 odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 181 odebug << "parsePacket-action for '" << name << "' seems to be '" << action << "'" << oendl;
180 doAction( action, name, p ); 182 doAction( action, name, p );
181 } 183 }
182 else 184 else
183 { 185 {
184 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; 186 odebug << "protocol '" << name << "' not checked in parsePackets." << oendl;
185 } 187 }
186 ++it; 188 ++it;
187 } 189 }
188} 190}
189 191
190 192
191void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 193void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
192{ 194{
193 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 195 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
194 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 196 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
195 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 197 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
196 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; 198 else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl;
197} 199}
198 200
199 201
200void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) 202void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* /* request */ )
201{ 203{
202 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 204 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
203 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 205 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
204 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 206// OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
205 int channel = ds ? ds->channel() : -1; 207// int channel = ds ? ds->channel() : -1;
206 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 208 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
207 209
208 GpsLocation loc( -111, -111 ); 210 GpsLocation loc( -111, -111 );
209 if ( configwindow->enableGPS->isChecked() ) 211 if ( configwindow->enableGPS->isChecked() )
210 { 212 {
211 // TODO: add check if GPS is working!? 213 // TODO: add check if GPS is working!?
212 odebug << "Wellenreiter::gathering GPS data..." << oendl; 214 odebug << "Wellenreiter::gathering GPS data..." << oendl;
213 loc = gps->position(); 215 loc = gps->position();
214 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl; 216 odebug << "Wellenreiter::GPS data received is ( " << loc.latitude() << " , " << loc.longitude() << " ) - dms string = '" << loc.dmsPosition().latin1() << "'" << oendl;
215 } 217 }
216 218
217 if ( essid.length() ) 219 if ( essid.length() )
218 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 220 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
219 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; 221 odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl;
220} 222}
221 223
222 224
223void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) 225void Wellenreiter::handleManagementFrameProbeResponse( OPacket* /* p */, OWaveLanManagementPacket* /* response */ )
224{ 226{
225} 227}
226 228
227 229
228void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 230void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
229{ 231{
230 QString type; 232 QString type;
231 if ( beacon->canIBSS() ) 233 if ( beacon->canIBSS() )
232 { 234 {
233 type = "adhoc"; 235 type = "adhoc";
234 } 236 }
235 else if ( beacon->canESS() ) 237 else if ( beacon->canESS() )
236 { 238 {
237 type = "managed"; 239 type = "managed";
238 } 240 }
239 else 241 else
240 { 242 {
@@ -278,25 +280,25 @@ void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* contro
278 280
279 if ( control->controlType() == "Acknowledge" ) 281 if ( control->controlType() == "Acknowledge" )
280 { 282 {
281 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 283 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
282 } 284 }
283 else 285 else
284 { 286 {
285 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; 287 odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl;
286 } 288 }
287} 289}
288 290
289 291
290void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) 292void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* /* data */ , OMacAddress& from, OMacAddress& to )
291{ 293{
292 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 294 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
293 if ( wlan->fromDS() && !wlan->toDS() ) 295 if ( wlan->fromDS() && !wlan->toDS() )
294 { 296 {
295 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 297 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
296 from = wlan->macAddress3(); 298 from = wlan->macAddress3();
297 to = wlan->macAddress2(); 299 to = wlan->macAddress2();
298 } 300 }
299 else if ( !wlan->fromDS() && wlan->toDS() ) 301 else if ( !wlan->fromDS() && wlan->toDS() )
300 { 302 {
301 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 303 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
302 from = wlan->macAddress2(); 304 from = wlan->macAddress2();
@@ -308,69 +310,69 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
308 from = wlan->macAddress4(); 310 from = wlan->macAddress4();
309 to = wlan->macAddress3(); 311 to = wlan->macAddress3();
310 } 312 }
311 else 313 else
312 { 314 {
313 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 315 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
314 from = wlan->macAddress2(); 316 from = wlan->macAddress2();
315 to = wlan->macAddress1(); 317 to = wlan->macAddress1();
316 } 318 }
317} 319}
318 320
319 321
320void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 322void Wellenreiter::handleEthernetData( OPacket* /* p */, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
321{ 323{
322 from = data->sourceAddress(); 324 from = data->sourceAddress();
323 to = data->destinationAddress(); 325 to = data->destinationAddress();
324 326
325 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 327 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
326} 328}
327 329
328 330
329void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 331void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& /* source */, OMacAddress& /* dest */ )
330{ 332{
331 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 333 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
332 if ( arp ) 334 if ( arp )
333 { 335 {
334 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; 336 odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl;
335 if ( arp->type() == "REQUEST" ) 337 if ( arp->type() == "REQUEST" )
336 { 338 {
337 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 339 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
338 } 340 }
339 else if ( arp->type() == "REPLY" ) 341 else if ( arp->type() == "REPLY" )
340 { 342 {
341 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 343 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
342 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 344 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
343 } 345 }
344 } 346 }
345} 347}
346 348
347 349
348void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 350void Wellenreiter::handleIPData( OPacket* p, OIPPacket* /* ip */, OMacAddress& source, OMacAddress& /* dest */ )
349{ 351{
350 //TODO: Implement more IP based protocols 352 //TODO: Implement more IP based protocols
351 353
352 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 354 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
353 if ( dhcp ) 355 if ( dhcp )
354 { 356 {
355 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; 357 odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl;
356 if ( dhcp->type() == "OFFER" ) 358 if ( dhcp->type() == "OFFER" )
357 { 359 {
358 odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; 360 odebug << "DHCP: '" << source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl;
359 netView()->identify( source, dhcp->serverAddress().toString() ); 361 netView()->identify( source, dhcp->serverAddress().toString() );
360 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 362 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
361 } 363 }
362 else if ( dhcp->type() == "ACK" ) 364 else if ( dhcp->type() == "ACK" )
363 { 365 {
364 odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; 366 odebug << "DHCP: '" << dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl;
365 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 367 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
366 } 368 }
367 } 369 }
368} 370}
369 371
370 372
371QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 373QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
372{ 374{
373 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 375 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
374 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 376 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
375 return 0; 377 return 0;
376 378
@@ -386,28 +388,28 @@ bool Wellenreiter::checkDumpPacket( OPacket* p )
386 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 388 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
387 389
388 QObjectList* l = p->queryList(); 390 QObjectList* l = p->queryList();
389 QObjectListIt it( *l ); 391 QObjectListIt it( *l );
390 QObject* o; 392 QObject* o;
391 393
392 while ( (o = it.current()) != 0 ) 394 while ( (o = it.current()) != 0 )
393 { 395 {
394 QString name = it.current()->name(); 396 QString name = it.current()->name();
395 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 397 if ( configwindow->capturePackets->isProtocolChecked( name ) )
396 { 398 {
397 QString action = configwindow->capturePackets->protocolAction( name ); 399 QString action = configwindow->capturePackets->protocolAction( name );
398 odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; 400 odebug << "capturePackets-action for '" << name << "' seems to be '" << action << "'" << oendl;
399 if ( action == "Discard" ) 401 if ( action == "Discard" )
400 { 402 {
401 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 403 logwindow->log( QString("(i) dump-discarding of '%1' packet requested." ).arg( name ) );
402 return false; 404 return false;
403 } 405 }
404 } 406 }
405 else 407 else
406 { 408 {
407 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; 409 odebug << "protocol '" << name << "' not checked in capturePackets." << oendl;
408 } 410 }
409 ++it; 411 ++it;
410 } 412 }
411 return true; 413 return true;
412} 414}
413 415
@@ -511,37 +513,35 @@ void Wellenreiter::stopClicked()
511 sniffing = false; 513 sniffing = false;
512 emit( stoppedSniffing() ); 514 emit( stoppedSniffing() );
513 515
514 #ifdef QWS 516 #ifdef QWS
515 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 517 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
516 { 518 {
517 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 519 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
518 } 520 }
519 #else 521 #else
520 #warning FIXME: setScreenSaverMode is not operational on the X11 build 522 #warning FIXME: setScreenSaverMode is not operational on the X11 build
521 #endif 523 #endif
522 524
523 // print out statistics 525 updateStatistics();
524 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
525 statwindow->updateCounter( it.key(), it.data() );
526} 526}
527 527
528 528
529void Wellenreiter::startClicked() 529void Wellenreiter::startClicked()
530{ 530{
531 // get configuration from config window 531 // get configuration from config window
532 532
533 const QString& interface = configwindow->interfaceName->currentText(); 533 const QString& interface = configwindow->interfaceName->currentText();
534 const int cardtype = configwindow->driverType(); 534 const int cardtype = configwindow->driverType();
535 const int interval = configwindow->hoppingInterval(); 535// const int interval = configwindow->hoppingInterval();
536 536
537 if ( ( interface == "" ) || ( cardtype == 0 ) ) 537 if ( ( interface == "" ) || ( cardtype == 0 ) )
538 { 538 {
539 QMessageBox::information( this, "Wellenreiter II", 539 QMessageBox::information( this, "Wellenreiter II",
540 tr( "No device configured.\nPlease reconfigure!" ) ); 540 tr( "No device configured.\nPlease reconfigure!" ) );
541 return; 541 return;
542 } 542 }
543 543
544 // configure device 544 // configure device
545 ONetwork* net = ONetwork::instance(); 545 ONetwork* net = ONetwork::instance();
546 546
547 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 547 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
@@ -695,72 +695,84 @@ void Wellenreiter::timerEvent( QTimerEvent* )
695 stopClicked(); 695 stopClicked();
696 } 696 }
697 else 697 else
698 { 698 {
699 receivePacket( p ); 699 receivePacket( p );
700 // We no longer delete packets here. Ownership of the packets is 700 // We no longer delete packets here. Ownership of the packets is
701 // transferred to the PacketView. 701 // transferred to the PacketView.
702 //delete p; 702 //delete p;
703 } 703 }
704} 704}
705 705
706 706
707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 707void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* /* p */ )
708{ 708{
709 #ifdef QWS 709 #ifdef QWS
710 if ( action == "TouchSound" ) 710 if ( action == "TouchSound" )
711 ODevice::inst()->playTouchSound(); 711 ODevice::inst()->playTouchSound();
712 else if ( action == "AlarmSound" ) 712 else if ( action == "AlarmSound" )
713 ODevice::inst()->playAlarmSound(); 713 ODevice::inst()->playAlarmSound();
714 else if ( action == "KeySound" ) 714 else if ( action == "KeySound" )
715 ODevice::inst()->playKeySound(); 715 ODevice::inst()->playKeySound();
716 else if ( action == "LedOn" ) 716 else if ( action == "LedOn" )
717 ODevice::inst()->setLedState( Led_Mail, Led_On ); 717 ODevice::inst()->setLedState( Led_Mail, Led_On );
718 else if ( action == "LedOff" ) 718 else if ( action == "LedOff" )
719 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 719 ODevice::inst()->setLedState( Led_Mail, Led_Off );
720 else if ( action == "LogMessage" ) 720 else if ( action == "LogMessage" )
721 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 721 logwindow->log( QString(tr("Got packet with protocol '%1'","Protocol Name" ) ).arg( protocol ) );
722 else if ( action == "MessageBox" ) 722 else if ( action == "MessageBox" )
723 QMessageBox::information( this, "Notification!", 723 QMessageBox::information( this, "Notification!",
724 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 724 QString(tr( "Got packet with protocol '%1'", "Protocol Name" ) ).arg( protocol ) );
725 #else 725 #else
726 #warning Actions do not work with Qt/X11 yet 726 #warning Actions do not work with Qt/X11 yet
727 #endif 727 #endif
728} 728}
729 729
730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 730void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
731{ 731{
732 #ifdef QWS 732 #ifdef QWS
733 if ( !iface ) 733 if ( !iface )
734 { 734 {
735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 735 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
736 return; 736 return;
737 } 737 }
738 738
739 if ( sniffing ) 739 if ( sniffing )
740 { 740 {
741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 741 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
742 return; 742 return;
743 } 743 }
744 744
745 odebug << "joinNetwork() with Interface " << (const char*) iface->name() 745 odebug << "joinNetwork() with Interface " << iface->name()
746 << ": " << (const char*) type << ", " << (const char*) essid 746 << ": " << type << ", " << essid
747 << ", " << channel << ", " << (const char*) macaddr << oendl; 747 << ", " << channel << ", " << macaddr << oendl;
748 748
749 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 749 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
750 int count = 3; 750 int count = 3;
751 odebug << "sending " << count << " messages" << oendl; 751 odebug << "sending " << count << " messages" << oendl;
752 msg << QString("count") << QString::number(count); 752 msg << QString("count") << QString::number(count);
753 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; 753 odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl;
754 msg << QString(iface->name()) << QString("Mode") << type; 754 msg << QString(iface->name()) << QString("Mode") << type;
755 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl; 755 odebug << "msg >" << iface->name() << "< essid >" << essid.latin1() << "<" << oendl;
756 msg << QString(iface->name()) << QString("ESSID") << essid; 756 msg << QString(iface->name()) << QString("ESSID") << essid;
757 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl; 757 odebug << "msg >" << iface->name() << "< channel >" << channel << "<" << oendl;
758 msg << QString(iface->name()) << QString("Channel") << channel; 758 msg << QString(iface->name()) << QString("Channel") << channel;
759// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl; 759// odebug << "msg >" << iface->name() << "< mac >" << macaddr << "<" << oendl;
760// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 760// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
761 #else 761 #else
762 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 762 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
763 #endif 763 #endif
764 764
765} 765}
766 766
767void Wellenreiter::updateStatistics()
768{
769 // print out statistics
770 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
771 statwindow->updateCounter( it.key(), it.data() );
772}
773
774void Wellenreiter::slotTabChanged( QWidget* wid )
775{
776 if ( wid == statwindow )
777 updateStatistics();
778}