summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index 3003e12..32bae0a 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,140 +1,143 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 .=l. 4 .=l.
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29#include "omanufacturerdb.h" 29#include "omanufacturerdb.h"
30 30
31#define OPIE_IMPROVE_GUI_LATENCY 1 31#define OPIE_IMPROVE_GUI_LATENCY 1
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35#include <qpe/qpeapplication.h>
35#ifdef OPIE_IMPROVE_GUI_LATENCY 36#ifdef OPIE_IMPROVE_GUI_LATENCY
36#include <qpe/global.h> 37#include <qpe/global.h>
37#endif 38#endif
38 39
40
41
39/* QT */ 42/* QT */
40#include <qapplication.h> 43#include <qapplication.h>
41#include <qfile.h> 44#include <qfile.h>
42#include <qtextstream.h> 45#include <qtextstream.h>
43 46
44using namespace Opie::Core; 47using namespace Opie::Core;
45namespace Opie { 48namespace Opie {
46namespace Net { 49namespace Net {
47 50
48OManufacturerDB* OManufacturerDB::_instance = 0; 51OManufacturerDB* OManufacturerDB::_instance = 0;
49 52
50OManufacturerDB* OManufacturerDB::instance() 53OManufacturerDB* OManufacturerDB::instance()
51{ 54{
52 if ( !OManufacturerDB::_instance ) 55 if ( !OManufacturerDB::_instance )
53 { 56 {
54 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 57 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
55 _instance = new OManufacturerDB(); 58 _instance = new OManufacturerDB();
56 } 59 }
57 return _instance; 60 return _instance;
58} 61}
59 62
60 63
61OManufacturerDB::OManufacturerDB() 64OManufacturerDB::OManufacturerDB()
62{ 65{
63 #ifdef OPIE_IMPROVE_GUI_LATENCY 66 #ifdef OPIE_IMPROVE_GUI_LATENCY
64 Global::statusMessage( "Reading Manufacturers..." ); 67 Global::statusMessage( "Reading Manufacturers..." );
65 #endif 68 #endif
66 QString filename( "/etc/manufacturers" ); 69 QString filename( "/etc/manufacturers" );
67 odebug << "OManufacturerDB: trying to read " << filename << oendl; 70 odebug << "OManufacturerDB: trying to read " << filename << oendl;
68 if ( !QFile::exists( filename ) ) 71 if ( !QFile::exists( filename ) )
69 { 72 {
70 filename = "/opt/QtPalmtop/etc/manufacturers"; 73 filename = QPEApplication::qpeDir()+"/etc/manufacturers";
71 odebug << "OManufacturerDB: trying to read " << filename << oendl; 74 odebug << "OManufacturerDB: trying to read " << filename << oendl;
72 if ( !QFile::exists( filename ) ) 75 if ( !QFile::exists( filename ) )
73 { 76 {
74 filename = "/usr/share/wellenreiter/manufacturers"; 77 filename = "/usr/share/wellenreiter/manufacturers";
75 odebug << "OManufacturerDB: trying to read " << filename << oendl; 78 odebug << "OManufacturerDB: trying to read " << filename << oendl;
76 } 79 }
77 } 80 }
78 81
79 QFile file( filename ); 82 QFile file( filename );
80 bool hasFile = file.open( IO_ReadOnly ); 83 bool hasFile = file.open( IO_ReadOnly );
81 if (!hasFile) 84 if (!hasFile)
82 { 85 {
83 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 86 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
84 } 87 }
85 else 88 else
86 { 89 {
87 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 90 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
88 QTextStream s( &file ); 91 QTextStream s( &file );
89 QString addr; 92 QString addr;
90 QString manu; 93 QString manu;
91 QString extManu; 94 QString extManu;
92 #ifdef OPIE_IMPROVE_GUI_LATENCY 95 #ifdef OPIE_IMPROVE_GUI_LATENCY
93 int counter = 0; 96 int counter = 0;
94 #endif 97 #endif
95 while (!s.atEnd()) 98 while (!s.atEnd())
96 { 99 {
97 s >> addr; 100 s >> addr;
98 s >> manu; 101 s >> manu;
99 s >> extManu; 102 s >> extManu;
100 103
101 manufacturers.insert( addr, manu ); 104 manufacturers.insert( addr, manu );
102 manufacturersExt.insert( addr, extManu ); 105 manufacturersExt.insert( addr, extManu );
103 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 106 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
104 #ifdef OPIE_IMPROVE_GUI_LATENCY 107 #ifdef OPIE_IMPROVE_GUI_LATENCY
105 counter++; 108 counter++;
106 if ( counter == 50 ) 109 if ( counter == 50 )
107 { 110 {
108 qApp->processEvents(); 111 qApp->processEvents();
109 counter = 0; 112 counter = 0;
110 } 113 }
111 #endif 114 #endif
112 } 115 }
113 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 116 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
114 #ifdef OPIE_IMPROVE_GUI_LATENCY 117 #ifdef OPIE_IMPROVE_GUI_LATENCY
115 Global::statusMessage( "Manufacturers Complete..." ); 118 Global::statusMessage( "Manufacturers Complete..." );
116 #endif 119 #endif
117 } 120 }
118} 121}
119 122
120 123
121OManufacturerDB::~OManufacturerDB() 124OManufacturerDB::~OManufacturerDB()
122{ 125{
123} 126}
124 127
125 128
126const QString& OManufacturerDB::lookup( const QString& macaddr ) const 129const QString& OManufacturerDB::lookup( const QString& macaddr ) const
127{ 130{
128 return manufacturers[macaddr.upper().left(8)]; 131 return manufacturers[macaddr.upper().left(8)];
129} 132}
130 133
131 134
132const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 135const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
133{ 136{
134 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 137 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
135 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 138 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
136} 139}
137 140
138} 141}
139} 142}
140 143