From e829097195e5c4b07c79ba22e168d3ae3ded4489 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sun, 29 Dec 2002 17:28:26 +0000 Subject: added a manufacturer database class --- (limited to 'noncore') 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 @@ -2,8 +2,8 @@ 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 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 @@ -2,8 +2,8 @@ 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 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 +#include +#include + +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 +#include + +class ManufacturerDB +{ + public: + + ManufacturerDB( const QString& filename ); + virtual ~ManufacturerDB(); + QString lookup( const QString& macaddr ); + + private: + + QMap 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 @@ -49,6 +49,28 @@ class MScanListItem: public QListViewItem 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 @@ -53,6 +53,8 @@ using namespace Opie; #include "hexwindow.h" #include "configwindow.h" +#include "manufacturers.h" + #include #include #include @@ -61,6 +63,18 @@ 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." ); // @@ -103,6 +117,8 @@ 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() 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 @@ -25,6 +25,7 @@ using namespace Opie; class QTimerEvent; class QPixmap; +class ManufacturerDB; class Wellenreiter : public WellenreiterBase { Q_OBJECT @@ -48,7 +49,9 @@ private: OSystem _system; // Opie Operating System identifier #endif void handleMessage(); - + + ManufacturerDB* manufacturerdb; + //void readConfig(); //void writeConfig(); }; -- cgit v0.9.0.2