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
@@ -30,15 +30,12 @@
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>
@@ -57,12 +54,17 @@ using namespace Opie::Ui;
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{
@@ -71,14 +73,13 @@ Wellenreiter::Wellenreiter( QWidget* parent )
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&) ),
@@ -107,12 +108,13 @@ void Wellenreiter::initialTimer()
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();
@@ -173,13 +175,13 @@ void Wellenreiter::handleNotification( OPacket* p )
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 }
@@ -194,18 +196,18 @@ void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket*
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!?
@@ -217,18 +219,18 @@ void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManage
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 }
@@ -284,13 +286,13 @@ void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* contro
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();
@@ -314,22 +316,22 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
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" )
@@ -342,29 +344,29 @@ void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source,
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
@@ -392,16 +394,16 @@ bool Wellenreiter::checkDumpPacket( OPacket* p )
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;
@@ -517,25 +519,23 @@ void Wellenreiter::stopClicked()
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;
@@ -701,13 +701,13 @@ void Wellenreiter::timerEvent( QTimerEvent* )
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();
@@ -715,16 +715,16 @@ void Wellenreiter::doAction( const QString& action, const QString& protocol, OPa
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)
@@ -739,15 +739,15 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch
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;
@@ -761,6 +761,18 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch
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}