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.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 6d62fa8..3453d18 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,47 +1,49 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
***********************************************************************/
// Qt
#include <qpushbutton.h>
// Standard
#include <assert.h>
+#include <errno.h>
#include <unistd.h>
+#include <string.h>
#include <sys/types.h>
// Local
#include "wellenreiter.h"
#include "scanlistitem.h"
#include "logwindow.h"
#include "hexwindow.h"
#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS!
#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
: WellenreiterBase( parent, name, fl )
{
logwindow->log( "(i) Wellenreiter has been started." );
connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
netview->setColumnWidthMode( 1, QListView::Manual );
//
// setup socket for daemon communication and start poller
@@ -110,65 +112,73 @@ typedef struct {
}
else
{
qDebug( "unknown sniffer command." );
}
}
bool Wellenreiter::hasMessage()
{
// FIXME: do this in libwellenreiter, not here!!!
fd_set rfds;
FD_ZERO( &rfds );
FD_SET( daemon_fd, &rfds );
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 10;
int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
- return FD_ISSET( daemon_fd, &rfds );
+
+ if ( result == 0 )
+ {
+ return false;
+ }
+ else if ( result == -1 )
+ {
+ qDebug( "selected returned: %s", strerror( errno ) );
+ return false;
+ }
+ else
+ return true; //FD_ISSET( daemon_fd, &rfds ); gibbet 'eh nur einen Deskriptor
}
void Wellenreiter::timerEvent( QTimerEvent* e )
{
qDebug( "checking for message..." );
-
- int result = hasMessage();
- qDebug( "hasMessage() returned %d", result );
-
- if ( result )
+ if ( hasMessage() )
{
+ qDebug( "got message" );
handleMessage();
}
else
{
- qDebug( "no message :(" );
+ qDebug( "no message..." );
}
}
void Wellenreiter::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
{
// FIXME: this code belongs in customized QListView, not into this class
// FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
qDebug( "Wellenreiter::addNewItem( %s / %s / %s [%d]",
(const char*) type,
(const char*) essid,
(const char*) macaddr,
channel );
// search, if we already have seen this net
QString s;
MScanListItem* network;
MScanListItem* item = (MScanListItem*) netview->firstChild();
while ( item && ( item->text( 0 ) != essid ) )
{
qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
item = item->itemBelow();