summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 5dc2e79..14f251a 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -302,96 +302,105 @@ void Wellenreiter::receivePacket( OPacket* p )
// check for a data frame
OWaveLanDataPacket* data = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
if ( data )
{
handleData( p, data );
}
handleNotification( p );
}
void Wellenreiter::stopClicked()
{
if ( iface )
{
disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
iface->setChannelHopping(); // stop hopping channels
}
else
killTimers();
pcap->close();
sniffing = false;
if ( iface )
{
// switch off monitor mode
iface->setMonitorMode( false );
// switch off promisc flag
iface->setPromiscuousMode( false );
system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
}
logwindow->log( "(i) Stopped Scanning." );
assert( parent() );
( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
// message the user
QMessageBox::information( this, "Wellenreiter II",
tr( "Your wireless card\nshould now be usable again." ) );
sniffing = false;
emit( stoppedSniffing() );
+ #ifdef QWS
+ if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
+ {
+ 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() );
}
void Wellenreiter::startClicked()
{
// get configuration from config window
const QString& interface = configwindow->interfaceName->currentText();
const int cardtype = configwindow->driverType();
const int interval = configwindow->hoppingInterval();
if ( ( interface == "" ) || ( cardtype == 0 ) )
{
QMessageBox::information( this, "Wellenreiter II",
tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
return;
}
// configure device
ONetwork* net = ONetwork::instance();
// TODO: check if interface is wireless and support sniffing for non-wireless interfaces
iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
// bring device UP
iface->setUp( true );
if ( !iface->isUp() )
{
QMessageBox::warning( this, "Wellenreiter II",
tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
return;
}
// set monitor mode
bool usePrism = configwindow->usePrismHeader();
switch ( cardtype )
{
case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
@@ -429,96 +438,106 @@ void Wellenreiter::startClicked()
QString dumpname( configwindow->captureFileName->text() );
if ( dumpname.isEmpty() ) dumpname = "captureFile";
dumpname.append( '-' );
dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
dumpname.append( ".wellenreiter" );
pcap->openDumpFile( dumpname );
}
else
{
pcap->open( interface );
}
}
else
{
pcap->open( QFile( interface ) );
}
if ( !pcap->isOpen() )
{
QMessageBox::warning( this, "Wellenreiter II",
tr( "Can't open packet capturer for '%1':\n" ).arg( iface->name() ) + QString(strerror( errno ) ));
return;
}
// set capturer to non-blocking mode
pcap->setBlocking( false );
// start channel hopper
if ( cardtype != DEVTYPE_FILE )
{
logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
}
if ( cardtype != DEVTYPE_FILE )
{
// connect socket notifier and start channel hopper
connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) );
connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
}
else
{
// start timer for reading packets
startTimer( 100 );
}
logwindow->log( "(i) Started Scanning." );
sniffing = true;
+
+ #ifdef QWS
+ if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
+ {
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
+ }
+ #else
+ #warning FIXME: setScreenSaverMode is not operational on the X11 build
+ #endif
+
emit( startedSniffing() );
if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
else
{
assert( parent() );
( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
}
}
void Wellenreiter::timerEvent( QTimerEvent* )
{
qDebug( "Wellenreiter::timerEvent()" );
OPacket* p = pcap->next();
if ( !p ) // no more packets available
{
stopClicked();
}
else
{
receivePacket( p );
delete p;
}
}
void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
{
#ifdef QWS
if ( action == "TouchSound" )
ODevice::inst()->touchSound();
else if ( action == "AlarmSound" )
ODevice::inst()->alarmSound();
else if ( action == "KeySound" )
ODevice::inst()->keySound();
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 ) );
else if ( action == "MessageBox" )
QMessageBox::information( this, "Notification!",
QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
#else
#warning Actions do not work with Qt/X11 yet
#endif
}