summaryrefslogtreecommitdiff
path: root/libopie2/opienet
Unidiff
Diffstat (limited to 'libopie2/opienet') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index c185fc5..c3c213c 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,114 +1,118 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "omanufacturerdb.h" 16#include "omanufacturerdb.h"
17 17
18// Qt 18/* QT */
19#include <qstring.h> 19#include <qstring.h>
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22 22
23OManufacturerDB* OManufacturerDB::_instance = 0; 23OManufacturerDB* OManufacturerDB::_instance = 0;
24 24
25OManufacturerDB* OManufacturerDB::instance() 25OManufacturerDB* OManufacturerDB::instance()
26{ 26{
27 if ( !OManufacturerDB::_instance ) 27 if ( !OManufacturerDB::_instance )
28 { 28 {
29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." ); 29 qDebug( "OManufacturerDB::instance(): creating OManufacturerDB..." );
30 _instance = new OManufacturerDB(); 30 _instance = new OManufacturerDB();
31 } 31 }
32 return _instance; 32 return _instance;
33} 33}
34 34
35 35
36OManufacturerDB::OManufacturerDB() 36OManufacturerDB::OManufacturerDB()
37{ 37{
38 QString filename( "/etc/manufacturers" ); 38 QString filename( "/etc/manufacturers" );
39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 39 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
40 if ( !QFile::exists( filename ) ) 40 if ( !QFile::exists( filename ) )
41 { 41 {
42 filename = "/opt/QtPalmtop/etc/manufacturers"; 42 filename = "/opt/QtPalmtop/etc/manufacturers";
43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 43 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
44 if ( !QFile::exists( filename ) ) 44 if ( !QFile::exists( filename ) )
45 { 45 {
46 filename = "/usr/share/wellenreiter/manufacturers"; 46 filename = "/usr/share/wellenreiter/manufacturers";
47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename ); 47 qDebug( "OManufacturerDB: trying to read '%s'...", (const char*) filename );
48 } 48 }
49 } 49 }
50 50
51 QFile file( filename ); 51 QFile file( filename );
52 bool hasFile = file.open( IO_ReadOnly ); 52 bool hasFile = file.open( IO_ReadOnly );
53 if (!hasFile) 53 if (!hasFile)
54 { 54 {
55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename ); 55 qWarning( "OManufacturerDB: no valid manufacturer list found.", (const char*) filename );
56 } 56 }
57 else 57 else
58 { 58 {
59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); 59 qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename );
60 QTextStream s( &file ); 60 QTextStream s( &file );
61 QString addr; 61 QString addr;
62 QString manu; 62 QString manu;
63 QString extManu; 63 QString extManu;
64 while (!s.atEnd()) 64 while (!s.atEnd())
65 { 65 {
66 s >> addr; 66 s >> addr;
67 if ( !addr ) // read nothing!? 67 if ( !addr ) // read nothing!?
68 { 68 {
69 continue; 69 continue;
70 } 70 }
71 else 71 else
72 if ( addr[0] == '#' ) 72 if ( addr[0] == '#' )
73 { 73 {
74 continue; 74 continue;
75 } 75 }
76 s.skipWhiteSpace(); 76 s.skipWhiteSpace();
77 s >> manu; 77 s >> manu;
78 s.skipWhiteSpace(); 78 s.skipWhiteSpace();
79 s >> extManu; 79 s >> extManu;
80 if ( extManu[0] == '#' ) // we have an extended manufacturer 80 if ( extManu[0] == '#' ) // we have an extended manufacturer
81 { 81 {
82 s.skipWhiteSpace(); 82 s.skipWhiteSpace();
83 extManu = s.readLine(); 83 extManu = s.readLine();
84 #ifdef DEBUG
84 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu ); 85 qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu );
86 #endif
85 manufacturersExt.insert( addr, extManu ); 87 manufacturersExt.insert( addr, extManu );
86 } 88 }
87 else 89 else
88 s.readLine(); 90 s.readLine();
91 #ifdef DEBUG
89 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu ); 92 qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu );
93 #endif
90 manufacturers.insert( addr, manu ); 94 manufacturers.insert( addr, manu );
91 95
92 } 96 }
93 } 97 }
94 98
95} 99}
96 100
97 101
98OManufacturerDB::~OManufacturerDB() 102OManufacturerDB::~OManufacturerDB()
99{ 103{
100} 104}
101 105
102 106
103const QString& OManufacturerDB::lookup( const QString& macaddr ) const 107const QString& OManufacturerDB::lookup( const QString& macaddr ) const
104{ 108{
105 return manufacturers[macaddr.upper().left(8)]; 109 return manufacturers[macaddr.upper().left(8)];
106} 110}
107 111
108 112
109const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 113const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
110{ 114{
111 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 115 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
112 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 116 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
113} 117}
114 118