summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-07 22:42:35 (UTC)
committer mickeyl <mickeyl>2004-01-07 22:42:35 (UTC)
commit872dc276a047a289561779fb59ab4ce45aaa9062 (patch) (unidiff)
treedaa13890125d0a6498a006787c273a73180827b5
parent6a5c0635fdc3053bdcded01a7477ad96d4690b4a (diff)
downloadopie-872dc276a047a289561779fb59ab4ce45aaa9062.zip
opie-872dc276a047a289561779fb59ab4ce45aaa9062.tar.gz
opie-872dc276a047a289561779fb59ab4ce45aaa9062.tar.bz2
add status output
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opienet/omanufacturerdb.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp
index f61270b..2da549c 100644
--- a/libopie2/opienet/omanufacturerdb.cpp
+++ b/libopie2/opienet/omanufacturerdb.cpp
@@ -1,127 +1,136 @@
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#define OPIE_IMPROVE_GUI_LATENCY 1
34
35/* OPIE */
34#include <opie2/odebug.h> 36#include <opie2/odebug.h>
37#ifdef OPIE_IMPROVE_GUI_LATENCY
38#include <qpe/global.h>
39#endif
35 40
36/* QT */ 41/* QT */
37#include <qapplication.h> 42#include <qapplication.h>
38#include <qstring.h> 43#include <qstring.h>
39#include <qfile.h> 44#include <qfile.h>
40#include <qtextstream.h> 45#include <qtextstream.h>
41 46
42#define OPIE_IMPROVE_GUI_LATENCY 1
43
44OManufacturerDB* OManufacturerDB::_instance = 0; 47OManufacturerDB* OManufacturerDB::_instance = 0;
45 48
46OManufacturerDB* OManufacturerDB::instance() 49OManufacturerDB* OManufacturerDB::instance()
47{ 50{
48 if ( !OManufacturerDB::_instance ) 51 if ( !OManufacturerDB::_instance )
49 { 52 {
50 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; 53 odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl;
51 _instance = new OManufacturerDB(); 54 _instance = new OManufacturerDB();
52 } 55 }
53 return _instance; 56 return _instance;
54} 57}
55 58
56 59
57OManufacturerDB::OManufacturerDB() 60OManufacturerDB::OManufacturerDB()
58{ 61{
62 #ifdef OPIE_IMPROVE_GUI_LATENCY
63 Global::statusMessage( "Reading Manufacturers..." );
64 #endif
59 QString filename( "/etc/manufacturers" ); 65 QString filename( "/etc/manufacturers" );
60 odebug << "OManufacturerDB: trying to read " << filename << oendl; 66 odebug << "OManufacturerDB: trying to read " << filename << oendl;
61 if ( !QFile::exists( filename ) ) 67 if ( !QFile::exists( filename ) )
62 { 68 {
63 filename = "/opt/QtPalmtop/etc/manufacturers"; 69 filename = "/opt/QtPalmtop/etc/manufacturers";
64 odebug << "OManufacturerDB: trying to read " << filename << oendl; 70 odebug << "OManufacturerDB: trying to read " << filename << oendl;
65 if ( !QFile::exists( filename ) ) 71 if ( !QFile::exists( filename ) )
66 { 72 {
67 filename = "/usr/share/wellenreiter/manufacturers"; 73 filename = "/usr/share/wellenreiter/manufacturers";
68 odebug << "OManufacturerDB: trying to read " << filename << oendl; 74 odebug << "OManufacturerDB: trying to read " << filename << oendl;
69 } 75 }
70 } 76 }
71 77
72 QFile file( filename ); 78 QFile file( filename );
73 bool hasFile = file.open( IO_ReadOnly ); 79 bool hasFile = file.open( IO_ReadOnly );
74 if (!hasFile) 80 if (!hasFile)
75 { 81 {
76 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; 82 owarn << "OManufacturerDB: no valid manufacturer list found." << oendl;
77 } 83 }
78 else 84 else
79 { 85 {
80 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; 86 odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl;
81 QTextStream s( &file ); 87 QTextStream s( &file );
82 QString addr; 88 QString addr;
83 QString manu; 89 QString manu;
84 QString extManu; 90 QString extManu;
85 #ifdef OPIE_IMPROVE_GUI_LATENCY 91 #ifdef OPIE_IMPROVE_GUI_LATENCY
86 int counter = 0; 92 int counter = 0;
87 #endif 93 #endif
88 while (!s.atEnd()) 94 while (!s.atEnd())
89 { 95 {
90 s >> addr; 96 s >> addr;
91 s >> manu; 97 s >> manu;
92 s >> extManu; 98 s >> extManu;
93 99
94 manufacturers.insert( addr, manu ); 100 manufacturers.insert( addr, manu );
95 manufacturersExt.insert( addr, extManu ); 101 manufacturersExt.insert( addr, extManu );
96 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; 102 // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl;
97 #ifdef OPIE_IMPROVE_GUI_LATENCY 103 #ifdef OPIE_IMPROVE_GUI_LATENCY
98 counter++; 104 counter++;
99 if ( counter == 50 ) 105 if ( counter == 50 )
100 { 106 {
101 qApp->processEvents(); 107 qApp->processEvents();
102 counter = 0; 108 counter = 0;
103 } 109 }
104 #endif 110 #endif
105 } 111 }
106 odebug << "OManufacturerDB: manufacturer list completed." << oendl; 112 odebug << "OManufacturerDB: manufacturer list completed." << oendl;
113 #ifdef OPIE_IMPROVE_GUI_LATENCY
114 Global::statusMessage( "Manufacturers Complete..." );
115 #endif
107 } 116 }
108} 117}
109 118
110 119
111OManufacturerDB::~OManufacturerDB() 120OManufacturerDB::~OManufacturerDB()
112{ 121{
113} 122}
114 123
115 124
116const QString& OManufacturerDB::lookup( const QString& macaddr ) const 125const QString& OManufacturerDB::lookup( const QString& macaddr ) const
117{ 126{
118 return manufacturers[macaddr.upper().left(8)]; 127 return manufacturers[macaddr.upper().left(8)];
119} 128}
120 129
121 130
122const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const 131const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const
123{ 132{
124 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); 133 QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) );
125 return it == manufacturersExt.end() ? lookup( macaddr ) : *it; 134 return it == manufacturersExt.end() ? lookup( macaddr ) : *it;
126} 135}
127 136