Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 70 |
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 @@ #include <qapplication.h> #endif #include <opie2/omanufacturerdb.h> #include <opie2/onetwork.h> #include <opie2/opcap.h> #include <qpe/qcopenvelope_qws.h> -using namespace Opie::Core; -using namespace Opie::Net; -using namespace Opie::Ui; /* QT */ #include <qcheckbox.h> #include <qcombobox.h> #include <qdatetime.h> #include <qpushbutton.h> @@ -57,12 +54,17 @@ using namespace Opie::Ui; #include <unistd.h> #include <string.h> #include <sys/types.h> #include <stdlib.h> #include <signal.h> + +using namespace Opie::Core; +using namespace Opie::Net; +using namespace Opie::Ui; + Wellenreiter* Wellenreiter::instance = 0; Wellenreiter::Wellenreiter( QWidget* parent ) : WellenreiterBase( parent, 0, 0 ), sniffing( false ), iface( 0 ), configwindow( 0 ) { @@ -71,14 +73,13 @@ Wellenreiter::Wellenreiter( QWidget* parent ) // // detect operating system // #ifdef QWS - QString sys; - sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); + QString sys = QString( "(i) Running on '%1'.").arg( ODevice::inst()->systemString() ); _system = ODevice::inst()->system(); logwindow->log( sys ); #endif netview->setColumnWidthMode( 1, QListView::Manual ); connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), @@ -107,12 +108,13 @@ void Wellenreiter::initialTimer() OManufacturerDB::instance(); } void Wellenreiter::signalHandler( int sig ) { + Q_UNUSED( sig ) oerr << "Aye! Received SIGSEGV or SIGBUS! Trying to exit gracefully..." << oendl; if ( Wellenreiter::instance->sniffing ) { Wellenreiter::instance->pcap->closeDumpFile(); Wellenreiter::instance->pcap->close(); Wellenreiter::instance->stopClicked(); @@ -173,13 +175,13 @@ void Wellenreiter::handleNotification( OPacket* p ) while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->parsePackets->isProtocolChecked( name ) ) { QString action = configwindow->parsePackets->protocolAction( name ); - odebug << "parsePacket-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; + odebug << "parsePacket-action for '" << name << "' seems to be '" << action << "'" << oendl; doAction( action, name, p ); } else { odebug << "protocol '" << name << "' not checked in parsePackets." << oendl; } @@ -194,18 +196,18 @@ void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); else owarn << "Wellenreiter::handleManagementFrame(): '" << manage->managementType() << "' - please handle me!" << oendl; } -void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) +void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* /* request */ ) { OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); - OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); - int channel = ds ? ds->channel() : -1; +// OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); +// int channel = ds ? ds->channel() : -1; OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); GpsLocation loc( -111, -111 ); if ( configwindow->enableGPS->isChecked() ) { // TODO: add check if GPS is working!? @@ -217,18 +219,18 @@ void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManage if ( essid.length() ) netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); odebug << "Wellenreiter::invalid frame [possibly noise] detected!" << oendl; } -void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) +void Wellenreiter::handleManagementFrameProbeResponse( OPacket* /* p */, OWaveLanManagementPacket* /* response */ ) { } -void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) +void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) { QString type; if ( beacon->canIBSS() ) { type = "adhoc"; } @@ -284,13 +286,13 @@ void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* contro { odebug << "Wellenreiter::handleControlFrame - please handle " << control->controlType() << " in a future version! :D" << oendl; } } -void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ) +void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* /* data */ , OMacAddress& from, OMacAddress& to ) { OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); if ( wlan->fromDS() && !wlan->toDS() ) { netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); from = wlan->macAddress3(); @@ -314,22 +316,22 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd from = wlan->macAddress2(); to = wlan->macAddress1(); } } -void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) +void Wellenreiter::handleEthernetData( OPacket* /* p */, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) { from = data->sourceAddress(); to = data->destinationAddress(); netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); } -void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) +void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& /* source */, OMacAddress& /* dest */ ) { OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); if ( arp ) { odebug << "Received ARP traffic (type '" << arp->type() << "'): " << oendl; if ( arp->type() == "REQUEST" ) @@ -342,29 +344,29 @@ void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); } } } -void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) +void Wellenreiter::handleIPData( OPacket* p, OIPPacket* /* ip */, OMacAddress& source, OMacAddress& /* dest */ ) { //TODO: Implement more IP based protocols ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); if ( dhcp ) { odebug << "Received DHCP '" << dhcp->type() << "' packet" << oendl; if ( dhcp->type() == "OFFER" ) { - odebug << "DHCP: '" << (const char*) source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; + odebug << "DHCP: '" << source.toString() << "' ('" << dhcp->serverAddress().toString() << "') seems to be a DHCP server." << oendl; netView()->identify( source, dhcp->serverAddress().toString() ); netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); } else if ( dhcp->type() == "ACK" ) { - odebug << "DHCP: '" << (const char*) dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; + odebug << "DHCP: '" << dhcp->clientMacAddress().toString() << "' ('" << dhcp->yourAddress().toString() << "') accepted the offered DHCP address." << oendl; netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); } } } @@ -392,16 +394,16 @@ bool Wellenreiter::checkDumpPacket( OPacket* p ) while ( (o = it.current()) != 0 ) { QString name = it.current()->name(); if ( configwindow->capturePackets->isProtocolChecked( name ) ) { QString action = configwindow->capturePackets->protocolAction( name ); - odebug << "capturePackets-action for '" << (const char*) name << "' seems to be '" << action << "'" << oendl; + odebug << "capturePackets-action for '" << name << "' seems to be '" << action << "'" << oendl; if ( action == "Discard" ) { - logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); + logwindow->log( QString("(i) dump-discarding of '%1' packet requested." ).arg( name ) ); return false; } } else { odebug << "protocol '" << name << "' not checked in capturePackets." << oendl; @@ -517,25 +519,23 @@ void Wellenreiter::stopClicked() QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #else #warning FIXME: setScreenSaverMode is not operational on the X11 build #endif - // print out statistics - for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) - statwindow->updateCounter( it.key(), it.data() ); + updateStatistics(); } void Wellenreiter::startClicked() { // get configuration from config window const QString& interface = configwindow->interfaceName->currentText(); const int cardtype = configwindow->driverType(); - const int interval = configwindow->hoppingInterval(); +// const int interval = configwindow->hoppingInterval(); if ( ( interface == "" ) || ( cardtype == 0 ) ) { QMessageBox::information( this, "Wellenreiter II", tr( "No device configured.\nPlease reconfigure!" ) ); return; @@ -701,13 +701,13 @@ void Wellenreiter::timerEvent( QTimerEvent* ) // transferred to the PacketView. //delete p; } } -void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) +void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* /* p */ ) { #ifdef QWS if ( action == "TouchSound" ) ODevice::inst()->playTouchSound(); else if ( action == "AlarmSound" ) ODevice::inst()->playAlarmSound(); @@ -715,16 +715,16 @@ void Wellenreiter::doAction( const QString& action, const QString& protocol, OPa ODevice::inst()->playKeySound(); else if ( action == "LedOn" ) ODevice::inst()->setLedState( Led_Mail, Led_On ); else if ( action == "LedOff" ) ODevice::inst()->setLedState( Led_Mail, Led_Off ); else if ( action == "LogMessage" ) - logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); + logwindow->log( QString(tr("Got packet with protocol '%1'","Protocol Name" ) ).arg( protocol ) ); else if ( action == "MessageBox" ) QMessageBox::information( this, "Notification!", - QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); + QString(tr( "Got packet with protocol '%1'", "Protocol Name" ) ).arg( protocol ) ); #else #warning Actions do not work with Qt/X11 yet #endif } void 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 if ( sniffing ) { QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); return; } - odebug << "joinNetwork() with Interface " << (const char*) iface->name() - << ": " << (const char*) type << ", " << (const char*) essid - << ", " << channel << ", " << (const char*) macaddr << oendl; + odebug << "joinNetwork() with Interface " << iface->name() + << ": " << type << ", " << essid + << ", " << channel << ", " << macaddr << oendl; QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); int count = 3; odebug << "sending " << count << " messages" << oendl; msg << QString("count") << QString::number(count); odebug << "msg >" << iface->name() << "< Mode >" << type.latin1() << "<" << oendl; @@ -761,6 +761,18 @@ void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int ch #else QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); #endif } +void Wellenreiter::updateStatistics() +{ + // print out statistics + for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) + statwindow->updateCounter( it.key(), it.data() ); +} + +void Wellenreiter::slotTabChanged( QWidget* wid ) +{ + if ( wid == statwindow ) + updateStatistics(); +} |