summaryrefslogtreecommitdiff
path: root/libopie2/opienet/omanufacturerdb.cpp
Unidiff
Diffstat (limited to 'libopie2/opienet/omanufacturerdb.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index 123aee8..3af3d4c 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -19,26 +19,24 @@
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
32
33/* OPIE */ 31/* OPIE */
34#include <opie2/odebug.h> 32#include <opie2/odebug.h>
35#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
36#ifdef OPIE_IMPROVE_GUI_LATENCY 34#ifdef OPIE_IMPROVE_GUI_LATENCY
37#include <qpe/global.h> 35#include <qpe/global.h>
38#endif 36#endif
39 37
40 38
41 39
42/* QT */ 40/* QT */
43#include <qapplication.h> 41#include <qapplication.h>
44#include <qfile.h> 42#include <qfile.h>
@@ -54,27 +52,25 @@ OManufacturerDB* OManufacturerDB::instance()
54{ 52{
55 if ( !OManufacturerDB::_instance ) 53 if ( !OManufacturerDB::_instance )
56 { 54 {
57 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 55 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
58 _instance = new OManufacturerDB(); 56 _instance = new OManufacturerDB();
59 } 57 }
60 return _instance; 58 return _instance;
61} 59}
62 60
63 61
64OManufacturerDB::OManufacturerDB() 62OManufacturerDB::OManufacturerDB()
65{ 63{
66 #ifdef OPIE_IMPROVE_GUI_LATENCY 64 if ( qApp ) Global::statusMessage( "Reading Manufacturers..." );
67 Global::statusMessage( "Reading Manufacturers..." );
68 #endif
69 QString filename( "/etc/manufacturers" ); 65 QString filename( "/etc/manufacturers" );
70 odebug << "OManufacturerDB: trying to read " << filename << oendl; 66 odebug << "OManufacturerDB: trying to read " << filename << oendl;
71 if ( !QFile::exists( filename ) ) 67 if ( !QFile::exists( filename ) )
72 { 68 {
73 filename = QPEApplication::qpeDir()+"etc/manufacturers"; 69 filename = QPEApplication::qpeDir()+"etc/manufacturers";
74 odebug << "OManufacturerDB: trying to read " << filename << oendl; 70 odebug << "OManufacturerDB: trying to read " << filename << oendl;
75 if ( !QFile::exists( filename ) ) 71 if ( !QFile::exists( filename ) )
76 { 72 {
77 filename = "/usr/share/wellenreiter/manufacturers"; 73 filename = "/usr/share/wellenreiter/manufacturers";
78 odebug << "OManufacturerDB: trying to read " << filename << oendl; 74 odebug << "OManufacturerDB: trying to read " << filename << oendl;
79 } 75 }
80 } 76 }
@@ -83,49 +79,44 @@ OManufacturerDB::OManufacturerDB()
83 bool hasFile = file.open( IO_ReadOnly ); 79 bool hasFile = file.open( IO_ReadOnly );
84 if (!hasFile) 80 if (!hasFile)
85 { 81 {
86 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 82 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
87 } 83 }
88 else 84 else
89 { 85 {
90 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 86 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
91 QTextStream s( &file ); 87 QTextStream s( &file );
92 QString addr; 88 QString addr;
93 QString manu; 89 QString manu;
94 QString extManu; 90 QString extManu;
95 #ifdef OPIE_IMPROVE_GUI_LATENCY
96 int counter = 0; 91 int counter = 0;
97 #endif 92
98 while (!s.atEnd()) 93 while (!s.atEnd())
99 { 94 {
100 s >> addr; 95 s >> addr;
101 s >> manu; 96 s >> manu;
102 s >> extManu; 97 s >> extManu;
103 98
104 manufacturers.insert( addr, manu ); 99 manufacturers.insert( addr, manu );
105 manufacturersExt.insert( addr, extManu ); 100 manufacturersExt.insert( addr, extManu );
106 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 101 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
107 #ifdef OPIE_IMPROVE_GUI_LATENCY
108 counter++; 102 counter++;
109 if ( counter == 50 ) 103 if ( counter == 50 )
110 { 104 {
111 qApp->processEvents(); 105 if ( qApp ) qApp->processEvents();
112 counter = 0; 106 counter = 0;
113 } 107 }
114 #endif
115 } 108 }
116 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 109 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
117 #ifdef OPIE_IMPROVE_GUI_LATENCY 110 if ( qApp ) Global::statusMessage( "Manufacturers Complete..." );
118 Global::statusMessage( "Manufacturers Complete..." );
119 #endif
120 } 111 }
121} 112}
122 113
123 114
124OManufacturerDB::~OManufacturerDB() 115OManufacturerDB::~OManufacturerDB()
125{ 116{
126} 117}
127 118
128 119
129const QString& OManufacturerDB::lookup( const QString& macaddr ) const 120const QString& OManufacturerDB::lookup( const QString& macaddr ) const
130{ 121{
131 return manufacturers[macaddr.upper().left(8)]; 122 return manufacturers[macaddr.upper().left(8)];