summaryrefslogtreecommitdiff
path: root/libopie2
Side-by-side diff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp4
-rw-r--r--libopie2/examples/opieui/opieui.pro4
-rw-r--r--libopie2/opiecore/oapplication.cpp12
-rw-r--r--libopie2/opiecore/oapplication.h2
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp24
-rw-r--r--libopie2/opienet/omanufacturerdb.h18
-rw-r--r--libopie2/opienet/onetutils.cpp5
7 files changed, 60 insertions, 9 deletions
diff --git a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
index fd68772..6326ad0 100644
--- a/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
+++ b/libopie2/examples/opienet/onetworkdemo/onetworkdemo.cpp
@@ -1,39 +1,43 @@
#include <opie2/onetwork.h>
+#include <opie2/omanufacturerdb.h>
int main( int argc, char** argv )
{
qDebug( "OPIE Network Demo" );
ONetwork* net = ONetwork::instance();
ONetwork::InterfaceIterator it = net->iterator();
while ( it.current() )
{
qDebug( "DEMO: ONetwork contains Interface '%s'", (const char*) it.current()->name() );
qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString() );
qDebug( "DEMO: MAC Address is '%s'", (const char*) it.current()->macAddress().toString(true) );
+ qDebug( "DEMO: MAC Manufacturer seems to be '%s'", (const char*) it.current()->macAddress().manufacturer() );
+ qDebug( "DEMO: Manufacturertest1 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "08:00:87" ) );
+ qDebug( "DEMO: Manufacturertest2 = '%s'", (const char*) OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) );
qDebug( "Demo: IPv4 Address is '%s'", (const char*) it.current()->ipV4Address() );
if ( it.current()->isWireless() )
{
OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() );
qDebug( "DEMO: '%s' seems to feature the wireless extensions.", (const char*) iface->name() );
qDebug( "DEMO: Current SSID is '%s'", (const char*) iface->SSID() );
qDebug( "DEMO: Antenna is tuned to '%f', that is channel %d", iface->frequency(), iface->channel() );
//if ( iface->mode() == OWirelessNetworkInterface::adhoc )
//{
qDebug( "DEMO: Associated AP has MAC Address '%s'", (const char*) iface->associatedAP() );
//}
// nickname
qDebug( "DEMO: Current NickName is '%s'", (const char*) iface->nickName() );
iface->setNickName( "MyNickName" );
if ( iface->nickName() != "MyNickName" )
qDebug( "DEMO: Warning! Can't change nickname" );
else
qDebug( "DEMO: Nickname change successful." );
// operation mode
qDebug( "DEMO: Current OperationMode is '%s'", (const char*) iface->mode() );
iface->setMode( "adhoc" );
diff --git a/libopie2/examples/opieui/opieui.pro b/libopie2/examples/opieui/opieui.pro
index b52f013..ad66f47 100644
--- a/libopie2/examples/opieui/opieui.pro
+++ b/libopie2/examples/opieui/opieui.pro
@@ -1,3 +1,3 @@
-TEMPLATE = subdirs
-SUBDIRS = olistviewdemo oversatileviewdemo
+TEMPLATE = subdirs
+SUBDIRS = olistviewdemo
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index 7a6c174..06d8ba2 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -10,48 +10,51 @@
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
+#include <signal.h>
+#include <stdio.h>
+
OApplication* OApplication::_instance = 0;
/**************************************************************************************************/
/* OApplicationPrivate
/**************************************************************************************************/
class OApplicationPrivate
{
public:
OApplicationPrivate() {};
~OApplicationPrivate() {};
};
/**************************************************************************************************/
/* OApplication
/**************************************************************************************************/
OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
:QPEApplication( argc, argv ),
_appname( rAppName ),
_config( 0 )
{
init();
@@ -64,48 +67,57 @@ OApplication::~OApplication()
if ( _config )
delete _config;
OApplication::_instance = 0;
// after deconstruction of the one-and-only application object,
// the construction of another object is allowed
}
OConfig* OApplication::config()
{
if ( !_config )
{
_config = new OConfig( _appname );
}
return _config;
}
void OApplication::init()
{
d = new OApplicationPrivate();
if ( !OApplication::_instance )
{
OApplication::_instance = this;
+
+ /* register SIGSEGV handler to give programs an option
+ * to exit gracefully, e.g. save or close devices or files.
+ struct sigaction sa;
+ sa.sa_handler = ( void (*)(int) ) &segv_handler;
+ sa.sa_flags = SA_SIGINFO | SA_RESTART;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGSEGV, &sa, NULL);
+ */
}
else
{
qFatal( "OApplication: Can't create more than one OApplication object. Aborting." );
}
}
void OApplication::showMainWidget( QWidget* widget, bool nomax )
{
QPEApplication::showMainWidget( widget, nomax );
widget->setCaption( _appname );
}
void OApplication::setTitle( const QString& title ) const
{
if ( mainWidget() )
{
if ( !title.isNull() )
mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
else
mainWidget()->setCaption( _appname );
}
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index 94ac488..1bd34e2 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -20,49 +20,49 @@
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef OAPPLICATION_H
#define OAPPLICATION_H
#define oApp OApplication::oApplication()
#include <qpe/qpeapplication.h>
class OApplicationPrivate;
class OConfig;
class OApplication: public QPEApplication
{
Q_OBJECT
-
+
public:
/**
* Constructor. Parses command-line arguments and sets the window caption.
*
* @param rAppName application name. Will be used for finding the
* associated message, icon and configuration files
*
*/
OApplication( int& argc, char** argv, const QCString& rAppName );
/**
* Destructor. Destroys the application object and its children.
*/
virtual ~OApplication();
/**
* @returns the process-wide application object
*
* This is similar to the global @ref QApplication pointer qApp. It
* allows access to the single global OApplication object, since
* more than one cannot be created in the same application. It
* saves you the trouble of having to pass the pointer explicitly
* to every function that may require it.
*/
static const OApplication* oApplication() { return _instance; };
/**
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index ea15125..c185fc5 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -39,58 +39,76 @@ OManufacturerDB::OManufacturerDB()
qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
if ( !QFile::exists( filename ) )
{
filename = "/opt/QtPalmtop/etc/manufacturers";
qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
if ( !QFile::exists( filename ) )
{
filename = "/usr/share/wellenreiter/manufacturers";
qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
}
}
QFile file( filename );
bool hasFile = file.open( IO_ReadOnly );
if (!hasFile)
{
qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename );
}
else
{
qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename );
QTextStream s( &file );
QString addr;
QString manu;
+ QString extManu;
while (!s.atEnd())
{
s >> addr;
if ( !addr ) // read nothing!?
{
continue;
}
else
if ( addr[0] == '#' )
{
- s.readLine();
continue;
}
s.skipWhiteSpace();
s >> manu;
- s.readLine();
- //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu );
+ s.skipWhiteSpace();
+ s >> extManu;
+ if ( extManu[0] == '#' ) // we have an extended manufacturer
+ {
+ s.skipWhiteSpace();
+ extManu = s.readLine();
+ qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
+ manufacturersExt.insert( addr, extManu );
+ }
+ else
+ s.readLine();
+ qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
manufacturers.insert( addr, manu );
}
}
}
OManufacturerDB::~OManufacturerDB()
{
}
const QString& OManufacturerDB::lookup( const QString& macaddr ) const
{
return manufacturers[macaddr.upper().left(8)];
}
+
+
+const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
+{
+ QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
+ return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
+}
+
diff --git a/libopie2/opienet/omanufacturerdb.h b/libopie2/opienet/omanufacturerdb.h
index cb0b6c8..651f624 100644
--- a/libopie2/opienet/omanufacturerdb.h
+++ b/libopie2/opienet/omanufacturerdb.h
@@ -1,38 +1,54 @@
/**********************************************************************
** 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 OMANUFACTURERDB_H
#define OMANUFACTURERDB_H
#include <qmap.h>
+/**
+ * @brief A Ethernet card vendor database.
+ *
+ * This class encapsulates the lookup of Ethernet vendor given a
+ * certain Mac Address. Only the first three bytes define the vendor.
+ */
class OManufacturerDB
{
public:
- //FIXME make us consistent -zecke I use self(), sandman inst() you use instance() so we need to chose one!
+ /**
+ * @returns the one-and-only @ref OManufacturerDB instance.
+ */
static OManufacturerDB* instance();
+ /**
+ * @returns the short manufacturer string given a @a macaddr.
+ */
const QString& lookup( const QString& macaddr ) const;
+ /**
+ * @returns the enhanced manufacturer string given a @a macaddr.
+ */
+ const QString& lookupExt( const QString& macaddr ) const;
protected:
OManufacturerDB();
virtual ~OManufacturerDB();
private:
QMap<QString, QString> manufacturers;
+ QMap<QString, QString> manufacturersExt;
static OManufacturerDB* _instance;
};
#endif
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index e05efc2..08c40b4 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -98,57 +98,58 @@ OMacAddress OMacAddress::fromString( const QString& str )
QString addr( str );
unsigned char buf[6];
bool ok = true;
int index = 14;
for ( int i = 5; i >= 0; --i )
{
buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
if ( !ok ) return OMacAddress::unknown;
addr.truncate( index );
index -= 3;
}
return (const unsigned char*) &buf;
}
QString OMacAddress::toString( bool substitute ) const
{
QString manu;
manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
QString serial;
serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
if ( !substitute ) return manu+serial;
// fallback - if no vendor is found, just use the number
QString textmanu = OManufacturerDB::instance()->lookup( manu );
- return textmanu.isNull() ? manu+serial : textmanu + serial;
+ return textmanu.isNull() ? manu+serial : textmanu+serial;
}
QString OMacAddress::manufacturer() const
{
- return OManufacturerDB::instance()->lookup( toString() );
+ return OManufacturerDB::instance()->lookupExt( toString() );
}
+
bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
{
return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
}
/*======================================================================================
* OHostAddress
*======================================================================================*/
/*======================================================================================
* OPrivateIOCTL
*======================================================================================*/
OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
:QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
{
}
OPrivateIOCTL::~OPrivateIOCTL()
{
}