summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/wellenreiter.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/wellenreiter/gui/wellenreiter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp37
1 files changed, 14 insertions, 23 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 4c53028..db7063b 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -52,46 +52,47 @@ using namespace Opie;
#include "scanlist.h"
#include "logwindow.h"
#include "hexwindow.h"
#include "configwindow.h"
#include "manufacturers.h"
#include <daemon/source/config.hh>
#include <libwellenreiter/source/wl_types.hh>
#include <libwellenreiter/source/wl_sock.hh>
#include <libwellenreiter/source/wl_proto.hh>
-Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
- : WellenreiterBase( parent, name, fl ), daemonRunning( false ), manufacturerdb( 0 )
+Wellenreiter::Wellenreiter( QWidget* parent )
+ : WellenreiterBase( parent, 0, 0 ),
+ daemonRunning( false ), manufacturerdb( 0 ), configwindow( 0 )
{
//
// construct manufacturer database
//
QString manufile;
#ifdef QWS
manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) QPEApplication::qpeDir() );
#else
manufile.sprintf( "/home/mickey/work/opie/share/wellenreiter/manufacturers.dat" );
#endif
manufacturerdb = new ManufacturerDB( manufile );
logwindow->log( "(i) Wellenreiter has been started." );
-
+
//
// detect operating system
//
-
+
#ifdef QWS
QString sys;
sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
_system = ODevice::inst()->system();
logwindow->log( sys );
#endif
//
// setup socket for daemon communication, register socket notifier
//
// struct sockaddr_in sockaddr;
@@ -101,41 +102,43 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
logwindow->log( "(E) Couldn't get file descriptor for commsocket." );
}
else
{
int flags;
flags = fcntl( daemon_fd, F_GETFL, 0 );
fcntl( daemon_fd, F_SETFL, flags | O_NONBLOCK );
QSocketNotifier *sn = new QSocketNotifier( daemon_fd, QSocketNotifier::Read, parent );
connect( sn, SIGNAL( activated( int ) ), this, SLOT( dataReceived() ) );
}
// setup GUI
-
- connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
- // button->setEnabled( false );
netview->setColumnWidthMode( 1, QListView::Manual );
if ( manufacturerdb )
netview->setManufacturerDB( manufacturerdb );
-
+
}
Wellenreiter::~Wellenreiter()
{
// no need to delete child widgets, Qt does it all for us
-
+
delete manufacturerdb;
}
+void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
+{
+ configwindow = cw;
+}
+
void Wellenreiter::handleMessage()
{
// FIXME: receive message and handle it
qDebug( "received message from daemon." );
/*char buffer[10000];
memset( &buffer, 0, sizeof( buffer ) );*/
char buffer[WL_SOCKBUF];
// int result = #wl_recv( &daemon_fd, (char*) &buffer, sizeof(buffer) );
@@ -202,42 +205,31 @@ typedef struct {
{
qDebug( "unknown sniffer command." );
}
}
void Wellenreiter::dataReceived()
{
logwindow->log( "(d) Received data from daemon" );
handleMessage();
}
-void Wellenreiter::buttonClicked()
+void Wellenreiter::startStopClicked()
{
- /*
- // add some test stations, so that we can see if the GUI part works
- addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 );
- addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 );
- addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 );
- addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 );
- addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 );
- */
-
-
if ( daemonRunning )
{
daemonRunning = false;
logwindow->log( "(i) Daemon has been stopped." );
- button->setText( tr( "Start Scanning" ) );
setCaption( tr( "Wellenreiter/Opie" ) );
// Stop daemon - ugly for now... later better
system( "killall wellenreiterd" );
// get configuration from config window
const QString& interface = configwindow->interfaceName->currentText();
// reset the interface trying to get it into a usable state again
@@ -252,32 +244,31 @@ void Wellenreiter::buttonClicked()
else
{
// get configuration from config window
const QString& interface = configwindow->interfaceName->currentText();
const int cardtype = configwindow->daemonDeviceType();
const int interval = configwindow->daemonHopInterval();
if ( ( interface == "<select>" ) || ( cardtype == 0 ) )
{
- QMessageBox::information( this, "Wellenreiter/Opie", "You must configure your\ndevice before scanning." );
+ QMessageBox::information( this, "Wellenreiter/Opie", "Your device is not\nptoperly configured. Please reconfigure!" );
return;
}
// start wellenreiterd
QString cmdline;
cmdline.sprintf( "wellenreiterd %s %d &", (const char*) interface, cardtype );
qDebug( "about to execute '%s' ...", (const char*) cmdline );
system( cmdline );
qDebug( "done!" );
logwindow->log( "(i) Daemon has been started." );
daemonRunning = true;
- button->setText( tr( "Stop Scanning" ) );
setCaption( tr( "Scanning ..." ) );
}
}