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