author | ar <ar> | 2004-06-01 21:38:07 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-01 21:38:07 (UTC) |
commit | baed1d5ab8589aef14440009bc4e7380bcc5a741 (patch) (unidiff) | |
tree | c636e892c5eec0df2b36d16cb601a7da41a2ef0f /libopie2/opiedb/osqlbackendmanager.cpp | |
parent | 4438393d8eef624565e840b798429071829adea8 (diff) | |
download | opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.zip opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.gz opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.bz2 |
- convert to odebug framework
Diffstat (limited to 'libopie2/opiedb/osqlbackendmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiedb/osqlbackendmanager.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp index fc18e07..bbfbf3d 100644 --- a/libopie2/opiedb/osqlbackendmanager.cpp +++ b/libopie2/opiedb/osqlbackendmanager.cpp | |||
@@ -1,16 +1,22 @@ | |||
1 | |||
2 | #include "osqlbackendmanager.h" | ||
3 | |||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | |||
7 | /* QT */ | ||
1 | #include <qdir.h> | 8 | #include <qdir.h> |
2 | #include <qmap.h> | 9 | #include <qmap.h> |
3 | 10 | ||
4 | #include "osqlbackendmanager.h" | ||
5 | 11 | ||
6 | /** | 12 | /** |
7 | * \todo FIXME CONFIG!!! | 13 | * \todo FIXME CONFIG!!! |
8 | */ | 14 | */ |
9 | 15 | ||
10 | namespace { | 16 | namespace { |
11 | class Config { | 17 | class Config { |
12 | typedef QMap<QString, QString> List; | 18 | typedef QMap<QString, QString> List; |
13 | public: | 19 | public: |
14 | Config( const QString& fileName ); | 20 | Config( const QString& fileName ); |
15 | /** | 21 | /** |
16 | * Quite simple layout in nature | 22 | * Quite simple layout in nature |
@@ -29,25 +35,25 @@ namespace { | |||
29 | 35 | ||
30 | bool Config::load() { | 36 | bool Config::load() { |
31 | if (!QFile::exists( m_fileName ) ) | 37 | if (!QFile::exists( m_fileName ) ) |
32 | return false; | 38 | return false; |
33 | QFile file( m_fileName ); | 39 | QFile file( m_fileName ); |
34 | if (!file.open(IO_ReadOnly ) ) | 40 | if (!file.open(IO_ReadOnly ) ) |
35 | return false; | 41 | return false; |
36 | QStringList list = QStringList::split( '\n', file.readAll() ); | 42 | QStringList list = QStringList::split( '\n', file.readAll() ); |
37 | QStringList::Iterator it; | 43 | QStringList::Iterator it; |
38 | QString line; | 44 | QString line; |
39 | for (it = list.begin(); it != list.end(); ++it ) { | 45 | for (it = list.begin(); it != list.end(); ++it ) { |
40 | line = (*it).stripWhiteSpace(); | 46 | line = (*it).stripWhiteSpace(); |
41 | qWarning("Anonymous::Config:" + line ); | 47 | owarn << "Anonymous::Config:" + line << oendl; |
42 | QStringList test = QStringList::split(' ', line ); | 48 | QStringList test = QStringList::split(' ', line ); |
43 | m_list.insert( test[0], test[2] ); | 49 | m_list.insert( test[0], test[2] ); |
44 | } | 50 | } |
45 | return true; | 51 | return true; |
46 | } | 52 | } |
47 | QString Config::value( const QString& key ) { | 53 | QString Config::value( const QString& key ) { |
48 | return m_list[key]; | 54 | return m_list[key]; |
49 | } | 55 | } |
50 | }; | 56 | }; |
51 | 57 | ||
52 | 58 | ||
53 | using namespace Opie::DB; | 59 | using namespace Opie::DB; |
@@ -83,24 +89,24 @@ OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { | |||
83 | for ( it = files.begin(); it != files.end(); ++it ) { | 89 | for ( it = files.begin(); it != files.end(); ++it ) { |
84 | list.append( file2backend( (*it) ) ); | 90 | list.append( file2backend( (*it) ) ); |
85 | } | 91 | } |
86 | } | 92 | } |
87 | return list; | 93 | return list; |
88 | } | 94 | } |
89 | 95 | ||
90 | /** | 96 | /** |
91 | * read a config file and convert it to a OSQLBackEnd | 97 | * read a config file and convert it to a OSQLBackEnd |
92 | */ | 98 | */ |
93 | OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { | 99 | OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { |
94 | OSQLBackEnd end; | 100 | OSQLBackEnd end; |
95 | qWarning("fileName: " + file ); | 101 | owarn << "fileName: " + file << oendl; |
96 | Config cfg( file ); | 102 | Config cfg( file ); |
97 | if (cfg.load() ) { | 103 | if (cfg.load() ) { |
98 | end.setName( cfg.value( "Name") ); | 104 | end.setName( cfg.value( "Name") ); |
99 | end.setVendor( cfg.value("Vendor") ); | 105 | end.setVendor( cfg.value("Vendor") ); |
100 | end.setLicense( cfg.value("License") ); | 106 | end.setLicense( cfg.value("License") ); |
101 | end.setLibrary( cfg.value("Library").local8Bit() ); | 107 | end.setLibrary( cfg.value("Library").local8Bit() ); |
102 | end.setDefault( cfg.value("Default").toInt() ); | 108 | end.setDefault( cfg.value("Default").toInt() ); |
103 | end.setPreference( cfg.value("Preference").toInt() ); | 109 | end.setPreference( cfg.value("Preference").toInt() ); |
104 | } | 110 | } |
105 | return end; | 111 | return end; |
106 | } | 112 | } |