author | mickeyl <mickeyl> | 2002-12-29 17:28:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2002-12-29 17:28:26 (UTC) |
commit | e829097195e5c4b07c79ba22e168d3ae3ded4489 (patch) (side-by-side diff) | |
tree | 166cf184a01806be74f9b3c61c94d9109daf2afc | |
parent | 8f6559d4be4e0b1857c4ae5cdbf1ad8b485b638b (diff) | |
download | opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.zip opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.tar.gz opie-e829097195e5c4b07c79ba22e168d3ae3ded4489.tar.bz2 |
added a manufacturer database class
-rw-r--r-- | noncore/net/wellenreiter/gui/gui-x11.pro | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/gui.pro | 4 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.cpp | 58 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/manufacturers.h | 37 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlistitem.h | 22 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/wellenreiter.h | 3 |
7 files changed, 140 insertions, 4 deletions
diff --git a/noncore/net/wellenreiter/gui/gui-x11.pro b/noncore/net/wellenreiter/gui/gui-x11.pro index 523bf15..c2a4394 100644 --- a/noncore/net/wellenreiter/gui/gui-x11.pro +++ b/noncore/net/wellenreiter/gui/gui-x11.pro @@ -1,11 +1,11 @@ DESTDIR = . TEMPLATE = app CONFIG = qt warn_on debug #CONFIG = qt warn_on release -HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h wlan.h cardconfig.h -SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp wlan.cpp cardconfig.cpp +HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h resource.h wlan.h cardconfig.h manufacturers.h +SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp resource.cpp wlan.cpp cardconfig.cpp manufacturers.cpp INCLUDEPATH += ../ DEPENDPATH += ../ LIBS += -L. -lwellenreiter INTERFACES = configbase.ui TARGET = wellenreiter diff --git a/noncore/net/wellenreiter/gui/gui.pro b/noncore/net/wellenreiter/gui/gui.pro index ce1c387..52ed8c6 100644 --- a/noncore/net/wellenreiter/gui/gui.pro +++ b/noncore/net/wellenreiter/gui/gui.pro @@ -1,11 +1,11 @@ DESTDIR = $(OPIEDIR)/bin TEMPLATE = app CONFIG = qt warn_on debug #CONFIG = qt warn_on release -HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h wlan.h cardconfig.h -SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp wlan.cpp cardconfig.cpp +HEADERS = wellenreiterbase.h wellenreiter.h scanlistitem.h scanlist.h logwindow.h hexwindow.h configwindow.h wlan.h cardconfig.h manufacturers.h +SOURCES = main.cpp wellenreiterbase.cpp wellenreiter.cpp scanlistitem.cpp scanlist.cpp logwindow.cpp hexwindow.cpp configwindow.cpp wlan.cpp cardconfig.cpp manufacturers.h INCLUDEPATH += $(OPIEDIR)/include ../ DEPENDPATH += $(OPIEDIR)/include ../ LIBS += -lqpe -lopie -L. -lwellenreiter INTERFACES = configbase.ui TARGET = wellenreiter diff --git a/noncore/net/wellenreiter/gui/manufacturers.cpp b/noncore/net/wellenreiter/gui/manufacturers.cpp new file mode 100644 index 0000000..d235989 --- a/dev/null +++ b/noncore/net/wellenreiter/gui/manufacturers.cpp @@ -0,0 +1,58 @@ +/********************************************************************** +** 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 "manufacturers.h" + +// Qt +#include <qstring.h> +#include <qfile.h> +#include <qtextstream.h> + +ManufacturerDB::ManufacturerDB( const QString& filename ) +{ + QFile file( filename ); + bool hasFile = file.open( IO_ReadOnly ); + if (!hasFile) + { + qDebug( "ManufacturerDB: D'oh! Manufacturer list '%s' not found!", (const char*) filename ); + } + else + { + qDebug( "ManufacturerDB: reading manufacturer list from '%s'...", (const char*) filename ); + QTextStream s( &file ); + QString addr; + QString manu; + + while (!s.atEnd()) + { + s >> addr; + s.skipWhiteSpace(); + manu = s.readLine(); + qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); + manufacturers.insert( addr, manu ); + + } + } + +} + +ManufacturerDB::~ManufacturerDB() +{ +} + +QString ManufacturerDB::lookup( const QString& macaddr ) +{ + return manufacturers[macaddr.upper().left(8)]; +} diff --git a/noncore/net/wellenreiter/gui/manufacturers.h b/noncore/net/wellenreiter/gui/manufacturers.h new file mode 100644 index 0000000..d69977a --- a/dev/null +++ b/noncore/net/wellenreiter/gui/manufacturers.h @@ -0,0 +1,37 @@ +/********************************************************************** +** 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 MANUFACTURERS_H +#define MANUFACTURERS_H + +#include <qmap.h> +#include <string.h> + +class ManufacturerDB +{ + public: + + ManufacturerDB( const QString& filename ); + virtual ~ManufacturerDB(); + QString lookup( const QString& macaddr ); + + private: + + QMap<QString, QString> manufacturers; + +}; + +#endif + diff --git a/noncore/net/wellenreiter/gui/scanlistitem.h b/noncore/net/wellenreiter/gui/scanlistitem.h index cd9d883..47a5a4e 100644 --- a/noncore/net/wellenreiter/gui/scanlistitem.h +++ b/noncore/net/wellenreiter/gui/scanlistitem.h @@ -46,10 +46,32 @@ class MScanListItem: public QListViewItem virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal ); public: QString type; + public: + + //const QString& type() { return _type; }; + const QString& essid() { return _essid; }; + const QString& macaddr() { return _macaddr; }; + bool wep() { return _wep; }; + int channel() { return _channel; }; + int signal() { return _signal; }; + int received() { return _received; }; + + void setSignal( int signal ) { /* TODO */ }; + void incReceived() { _received++; }; + + private: + QString _type; + QString _essid; + QString _macaddr; + bool _wep; + int _channel; + int _signal; + int _received; + }; #endif diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp index 2d9bbee..9068e3a 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp @@ -50,20 +50,34 @@ using namespace Opie; #include "wellenreiter.h" #include "scanlist.h" #include "logwindow.h" #include "hexwindow.h" #include "configwindow.h" +#include "manufacturers.h" + #include <libwellenreiter/source/wl_sock.hh> #include <libwellenreiter/source/wl_proto.hh> #include <daemon/source/config.hh> Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) : WellenreiterBase( parent, name, fl ), daemonRunning( false ) { + // + // construct manufacturer database + // + + QString manufile; + #ifdef QWS + manufile.sprintf( "%s/share/wellenreiter/manufacturers.dat", (const char*) qApp.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 // @@ -100,12 +114,14 @@ Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) } Wellenreiter::~Wellenreiter() { // no need to delete child widgets, Qt does it all for us + + delete manufacturerdb; } void Wellenreiter::handleMessage() { // FIXME: receive message and handle it diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h index 2296892..9715983 100644 --- a/noncore/net/wellenreiter/gui/wellenreiter.h +++ b/noncore/net/wellenreiter/gui/wellenreiter.h @@ -22,12 +22,13 @@ #include <opie/odevice.h> using namespace Opie; #endif class QTimerEvent; class QPixmap; +class ManufacturerDB; class Wellenreiter : public WellenreiterBase { Q_OBJECT public: @@ -46,11 +47,13 @@ private: int daemon_fd; // socket filedescriptor for udp communication socket #ifdef QWS OSystem _system; // Opie Operating System identifier #endif void handleMessage(); + ManufacturerDB* manufacturerdb; + //void readConfig(); //void writeConfig(); }; #endif |