summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/logwindow.cpp9
-rw-r--r--noncore/net/wellenreiter/gui/logwindow.h5
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp32
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.h1
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp4
-rw-r--r--noncore/net/wellenreiter/gui/scanlistitem.cpp14
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h1
7 files changed, 53 insertions, 13 deletions
diff --git a/noncore/net/wellenreiter/gui/logwindow.cpp b/noncore/net/wellenreiter/gui/logwindow.cpp
index c355f09..f132f56 100644
--- a/noncore/net/wellenreiter/gui/logwindow.cpp
+++ b/noncore/net/wellenreiter/gui/logwindow.cpp
@@ -1,39 +1,42 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#include "logwindow.h"
#include <qmultilineedit.h>
#include <qdatetime.h>
MLogWindow::MLogWindow( QWidget * parent, const char * name, WFlags f )
:QVBox( parent, name, f )
{
ledit = new QMultiLineEdit( this );
// FIXME: Set properties( font, read-only, etc...)
-};
+}
void MLogWindow::log( QString text )
{
QTime time = QTime::currentTime();
QString line;
line.sprintf( "[%s] %s", (const char*) time.toString(), (const char*) text );
ledit->append( line );
qDebug( line );
-};
-
+}
+const QString MLogWindow::getLog() const
+{
+ return ledit->text();
+}
diff --git a/noncore/net/wellenreiter/gui/logwindow.h b/noncore/net/wellenreiter/gui/logwindow.h
index 325f8d0..253defa 100644
--- a/noncore/net/wellenreiter/gui/logwindow.h
+++ b/noncore/net/wellenreiter/gui/logwindow.h
@@ -1,38 +1,39 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef LOGWINDOW_H
#define LOGWINDOW_H
#include <qvbox.h>
class QString;
class QMultiLineEdit;
class MLogWindow: public QVBox
{
public:
MLogWindow( QWidget * parent = 0, const char * name = "MLogWindow", WFlags f = 0 );
-
+
void log( QString text );
-
+ const QString getLog() const;
+
protected:
QMultiLineEdit* ledit;
};
#endif
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 2d5ecd2..cb003dd 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,174 +1,198 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#include "configwindow.h"
+#include "logwindow.h"
#include "mainwindow.h"
#include "wellenreiter.h"
#include "scanlist.h"
#include <qcombobox.h>
+#include <qfile.h>
#include <qiconset.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qstatusbar.h>
+#include <qtextstream.h>
#include <qtoolbutton.h>
#ifdef QWS
#include <qpe/resource.h>
#else
#include "resource.h"
#endif
WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
:QMainWindow( parent, name, f )
{
cw = new WellenreiterConfigWindow( this );
mw = new Wellenreiter( this );
mw->setConfigWindow( cw );
setCentralWidget( mw );
// setup icon sets
infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) );
settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) );
#ifdef QWS
searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) );
cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) );
#else
startStopIconSet = new QIconSet();
startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off );
startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On );
#endif
// setup tool buttons
startStopButton = new QToolButton( 0 );
startStopButton->setAutoRaise( true );
#ifdef QWS
startStopButton->setOnIconSet( *cancelIconSet );
startStopButton->setOffIconSet( *searchIconSet );
#else
startStopButton->setIconSet( *startStopIconSet );
#endif
startStopButton->setToggleButton( true );
connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) );
startStopButton->setEnabled( false );
QToolButton* c = new QToolButton( 0 );
c->setAutoRaise( true );
c->setIconSet( *infoIconSet );
c->setEnabled( false );
QToolButton* d = new QToolButton( 0 );
d->setAutoRaise( true );
d->setIconSet( *settingsIconSet );
connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
// setup menu bar
+ int id;
+
QMenuBar* mb = menuBar();
+ QPopupMenu* fileSave = new QPopupMenu( mb );
+ fileSave->insertItem( "&Log", this, SLOT( fileSaveLog() ) );
+
QPopupMenu* file = new QPopupMenu( mb );
- file->insertItem( "&Load..." );
- file->insertItem( "&Save..." );
+ id = file->insertItem( "&Load" );
+ file->setItemEnabled( id, false );
+ file->insertItem( "&Save", fileSave );
QPopupMenu* view = new QPopupMenu( mb );
view->insertItem( "&Configure..." );
QPopupMenu* sniffer = new QPopupMenu( mb );
sniffer->insertItem( "&Configure..." );
sniffer->insertSeparator();
QPopupMenu* demo = new QPopupMenu( mb );
demo->insertItem( "&Add something", this, SLOT( demoAddStations() ) );
- int id;
id = mb->insertItem( "&File", file );
- mb->setItemEnabled( id, false );
id = mb->insertItem( "&View", view );
mb->setItemEnabled( id, false );
id = mb->insertItem( "&Sniffer", sniffer );
mb->setItemEnabled( id, false );
id = mb->insertItem( "&Demo", demo );
mb->setItemEnabled( id, true );
#ifdef QWS
mb->insertItem( startStopButton );
mb->insertItem( c );
mb->insertItem( d );
#else // Qt3 changed the insertion order. It's now totally random :(
mb->insertItem( d );
mb->insertItem( c );
mb->insertItem( startStopButton );
#endif
// setup status bar (for now only on X11)
#ifndef QWS
statusBar()->message( "Ready." );
#endif
};
void WellenreiterMainWindow::showConfigure()
{
qDebug( "show configure..." );
cw->setCaption( tr( "Configure" ) );
#ifdef QWS
cw->showMaximized();
#endif
int result = cw->exec();
if ( result )
{
// check configuration from config window
const QString& interface = cw->interfaceName->currentText();
const int cardtype = cw->daemonDeviceType();
const int interval = cw->daemonHopInterval();
if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
startStopButton->setEnabled( true );
//TODO ...
else
startStopButton->setEnabled( false );
//TODO ...
}
}
WellenreiterMainWindow::~WellenreiterMainWindow()
{
delete infoIconSet;
delete settingsIconSet;
#ifdef QWS
delete searchIconSet;
delete cancelIconSet;
#else
delete startStopIconSet;
#endif
};
void WellenreiterMainWindow::demoAddStations()
{
mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:43", true, 6, 80 );
mw->netView()->addNewItem( "managed", "Vanille", "04:00:20:EF:A6:23", true, 11, 10 );
mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:43:E7:16:22", false, 3, 10 );
mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:53:E7:56:62", false, 3, 15 );
mw->netView()->addNewItem( "adhoc", "ELAN", "40:03:63:E7:56:E2", false, 3, 20 );
}
+void WellenreiterMainWindow::fileSaveLog()
+{
+ const QString fname( "/tmp/log.txt" );
+ QFile f( fname );
+ if ( f.open(IO_WriteOnly) )
+ {
+ QTextStream t( &f );
+ t << mw->logWindow()->getLog();
+ f.close();
+ qDebug( "saved log in file '%s'", (const char*) fname );
+ }
+ else
+ {
+ qDebug( "Problem saving log in file '%s'", (const char*) fname );
+ }
+
+} \ No newline at end of file
diff --git a/noncore/net/wellenreiter/gui/mainwindow.h b/noncore/net/wellenreiter/gui/mainwindow.h
index 22c21e8..03aa08a 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.h
+++ b/noncore/net/wellenreiter/gui/mainwindow.h
@@ -1,51 +1,52 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
class Wellenreiter;
class WellenreiterConfigWindow;
class QIconSet;
class QToolButton;
class WellenreiterMainWindow: public QMainWindow
{
Q_OBJECT
public:
WellenreiterMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
~WellenreiterMainWindow();
protected:
Wellenreiter* mw;
WellenreiterConfigWindow* cw;
QIconSet* startStopIconSet;
const QIconSet* searchIconSet;
const QIconSet* infoIconSet;
const QIconSet* settingsIconSet;
const QIconSet* cancelIconSet;
QToolButton* startStopButton;
public slots:
void showConfigure();
void demoAddStations();
+ void fileSaveLog();
};
#endif
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index ab19701..a689cca 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,91 +1,95 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#include "scanlist.h"
#include "scanlistitem.h"
#include <assert.h>
#include "manufacturers.h"
MScanListView::MScanListView( QWidget* parent, const char* name )
:QListView( parent, name ), _manufacturerdb( 0 )
{
setFrameShape( QListView::StyledPanel );
setFrameShadow( QListView::Sunken );
addColumn( tr( "Net/Station" ) );
setColumnAlignment( 0, AlignLeft || AlignVCenter );
addColumn( tr( "B" ) );
setColumnAlignment( 1, AlignCenter );
addColumn( tr( "AP" ) );
setColumnAlignment( 2, AlignCenter );
addColumn( tr( "Chn" ) );
setColumnAlignment( 3, AlignCenter );
addColumn( tr( "W" ) );
setColumnAlignment( 4, AlignCenter );
addColumn( tr( "T" ) );
setColumnAlignment( 5, AlignCenter );
addColumn( tr( "Manufacturer" ) );
setColumnAlignment( 6, AlignCenter );
+ addColumn( tr( "First Seen" ) );
+ setColumnAlignment( 7, AlignCenter );
+ addColumn( tr( "Last Seen" ) );
+ setColumnAlignment( 8, AlignCenter );
setRootIsDecorated( true );
setAllColumnsShowFocus( true );
};
MScanListView::~MScanListView()
{
};
void MScanListView::setManufacturerDB( ManufacturerDB* manufacturerdb )
{
_manufacturerdb = manufacturerdb;
}
void MScanListView::addNewItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
{
// FIXME: scanlistitem needs a proper encapsulation and not such a damn dealing with text(...)
qDebug( "MScanList::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 = static_cast<MScanListItem*> ( firstChild() );
while ( item && ( item->text( 0 ) != essid ) )
{
qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
item = static_cast<MScanListItem*> ( item->itemBelow() );
}
if ( item )
{
// animate the item
/*
const QPixmap* pixmap = item->pixmap( 0 );
const QPixmap* nextpixmap = ani2;
if ( pixmap == ani1 )
nextpixmap = ani2;
else if ( pixmap == ani2 )
nextpixmap = ani3;
else if ( pixmap == ani3 )
nextpixmap = ani4;
diff --git a/noncore/net/wellenreiter/gui/scanlistitem.cpp b/noncore/net/wellenreiter/gui/scanlistitem.cpp
index 15aef0c..dd33f5f 100644
--- a/noncore/net/wellenreiter/gui/scanlistitem.cpp
+++ b/noncore/net/wellenreiter/gui/scanlistitem.cpp
@@ -1,96 +1,102 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#include "scanlistitem.h"
#include <assert.h>
+#include <qdatetime.h>
#include <qpixmap.h>
#ifdef QWS
#include <qpe/resource.h>
#else
#include "resource.h"
#endif
const int col_type = 0;
const int col_essid = 0;
const int col_sig = 1;
const int col_ap = 2;
const int col_channel = 3;
const int col_wep = 4;
const int col_traffic = 5;
const int col_manuf = 6;
+const int col_firstseen = 7;
+const int col_lastseen = 8;
MScanListItem::MScanListItem( QListView* parent, QString type, QString essid, QString macaddr,
bool wep, int channel, int signal )
:QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ),
_type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ),
_channel( channel ), _signal( signal ), _beacons( 0 )
{
qDebug( "creating scanlist item" );
decorateItem( type, essid, macaddr, wep, channel, signal );
}
MScanListItem::MScanListItem( QListViewItem* parent, QString type, QString essid, QString macaddr,
bool wep, int channel, int signal )
:QListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null )
{
qDebug( "creating scanlist item" );
decorateItem( type, essid, macaddr, wep, channel, signal );
}
void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal )
{
qDebug( "decorating scanlist item %s / %s / %s [%d]",
(const char*) type,
(const char*) essid,
(const char*) macaddr,
channel );
// set icon for managed or adhoc mode
QString name;
name.sprintf( "wellenreiter/%s", (const char*) type );
setPixmap( col_type, Resource::loadPixmap( name ) );
// set icon for wep (wireless encryption protocol)
if ( wep )
- setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); // rename the pixmap!
+ setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap!
// set channel and signal text
-
+
if ( signal != -1 )
setText( col_sig, QString::number( signal ) );
if ( channel != -1 )
setText( col_channel, QString::number( channel ) );
+ setText( col_firstseen, QTime::currentTime().toString() );
+ //setText( col_lastseen, QTime::currentTime().toString() );
+
listView()->triggerUpdate();
-
+
this->type = type;
}
void MScanListItem::setManufacturer( const QString& manufacturer )
{
setText( col_manuf, manufacturer );
}
void MScanListItem::receivedBeacon()
{
_beacons++;
#ifdef DEBUG
qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons );
#endif
setText( col_sig, QString::number( _beacons ) );
+ setText( col_lastseen, QTime::currentTime().toString() );
}
-
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index 61960d2..ff523d4 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -7,74 +7,75 @@
** 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.
**
**********************************************************************/
#ifndef WELLENREITER_H
#define WELLENREITER_H
#include "wellenreiterbase.h"
#ifdef QWS
#include <opie/odevice.h>
using namespace Opie;
#endif
// ugly... not here!
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <fcntl.h>
#include <daemon/source/config.hh>
#include <libwellenreiter/source/wl_types.hh>
#include <libwellenreiter/source/wl_sock.hh>
#include <libwellenreiter/source/wl_proto.hh>
class QTimerEvent;
class QPixmap;
class ManufacturerDB;
class WellenreiterConfigWindow;
class Wellenreiter : public WellenreiterBase {
Q_OBJECT
public:
Wellenreiter( QWidget* parent = 0 );
~Wellenreiter();
void setConfigWindow( WellenreiterConfigWindow* cw );
MScanListView* netView() const { return netview; };
+ MLogWindow* logWindow() const { return logwindow; };
protected:
bool daemonRunning;
public slots:
void dataReceived();
void startStopClicked();
private:
int daemon_fd; // socket filedescriptor for udp communication socket
#ifdef QWS
OSystem _system; // Opie Operating System identifier
#endif
void handleMessage();
ManufacturerDB* manufacturerdb;
WellenreiterConfigWindow* configwindow;
struct sockaddr_in sockaddr;
//void readConfig();
//void writeConfig();
};
#endif