author | mickeyl <mickeyl> | 2003-08-10 15:42:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-08-10 15:42:26 (UTC) |
commit | 90dbd3e9e7139c1280e71f9c77ed4362b8d0f367 (patch) (unidiff) | |
tree | 22f0947337ea9b21a1d8f56d04ce3292c9d6f19e /libsql/osqlbackendmanager.cpp | |
parent | 616e919ff6aea6a30e18edb37128c229e806beae (diff) | |
download | opie-90dbd3e9e7139c1280e71f9c77ed4362b8d0f367.zip opie-90dbd3e9e7139c1280e71f9c77ed4362b8d0f367.tar.gz opie-90dbd3e9e7139c1280e71f9c77ed4362b8d0f367.tar.bz2 |
libsql is now a part of libopie2
Diffstat (limited to 'libsql/osqlbackendmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libsql/osqlbackendmanager.cpp | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/libsql/osqlbackendmanager.cpp b/libsql/osqlbackendmanager.cpp deleted file mode 100644 index 0f261b9..0000000 --- a/libsql/osqlbackendmanager.cpp +++ b/dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | #include <qdir.h> | ||
2 | #include <qfile.h> | ||
3 | #include <qmap.h> | ||
4 | |||
5 | #include "osqlbackendmanager.h" | ||
6 | |||
7 | namespace { | ||
8 | class Config { | ||
9 | typedef QMap<QString, QString> List; | ||
10 | public: | ||
11 | Config( const QString& fileName ); | ||
12 | /** | ||
13 | * Quite simple layout in nature | ||
14 | * BeginFile | ||
15 | * Key = Value | ||
16 | */ | ||
17 | bool load(); | ||
18 | QString value( const QString& key ); | ||
19 | private: | ||
20 | List m_list; | ||
21 | QString m_fileName; | ||
22 | }; | ||
23 | Config::Config( const QString& fileName ) | ||
24 | : m_fileName( fileName ) { | ||
25 | } | ||
26 | |||
27 | bool Config::load() { | ||
28 | if (!QFile::exists( m_fileName ) ) | ||
29 | return false; | ||
30 | QFile file( m_fileName ); | ||
31 | if (!file.open(IO_ReadOnly ) ) | ||
32 | return false; | ||
33 | QStringList list = QStringList::split( '\n', file.readAll() ); | ||
34 | QStringList::Iterator it; | ||
35 | QString line; | ||
36 | for (it = list.begin(); it != list.end(); ++it ) { | ||
37 | line = (*it).stripWhiteSpace(); | ||
38 | qWarning("Anonymous::Config:" + line ); | ||
39 | QStringList test = QStringList::split(' ', line ); | ||
40 | m_list.insert( test[0], test[2] ); | ||
41 | } | ||
42 | return true; | ||
43 | } | ||
44 | QString Config::value( const QString& key ) { | ||
45 | return m_list[key]; | ||
46 | } | ||
47 | }; | ||
48 | OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) | ||
49 | :m_path( path ) | ||
50 | { | ||
51 | } | ||
52 | OSQLBackEndManager::~OSQLBackEndManager() { | ||
53 | } | ||
54 | /** | ||
55 | * scan dirs | ||
56 | */ | ||
57 | OSQLBackEnd::ValueList OSQLBackEndManager::scan() { | ||
58 | OSQLBackEnd::ValueList list; | ||
59 | if (!m_path.isEmpty() ) { | ||
60 | QStringList::Iterator it; | ||
61 | for ( it = m_path.begin(); it != m_path.end(); ++it ) { | ||
62 | list += scanDir( (*it) ); | ||
63 | } | ||
64 | } | ||
65 | return list; | ||
66 | } | ||
67 | /** | ||
68 | * scan a specified dir for *.osql | ||
69 | */ | ||
70 | OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) { | ||
71 | OSQLBackEnd::ValueList list; | ||
72 | QDir dir( dirName ); | ||
73 | if (dir.exists() ) { | ||
74 | QStringList files = dir.entryList( "*.osql" ); | ||
75 | QStringList::Iterator it; | ||
76 | for ( it = files.begin(); it != files.end(); ++it ) { | ||
77 | list.append( file2backend( (*it) ) ); | ||
78 | } | ||
79 | } | ||
80 | return list; | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * read a config file and convert it to a OSQLBackEnd | ||
85 | */ | ||
86 | OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { | ||
87 | OSQLBackEnd end; | ||
88 | qWarning("fileName: " + file ); | ||
89 | Config cfg( file ); | ||
90 | if (cfg.load() ) { | ||
91 | end.setName( cfg.value( "Name") ); | ||
92 | end.setVendor( cfg.value("Vendor") ); | ||
93 | end.setLicense( cfg.value("License") ); | ||
94 | end.setLibrary( cfg.value("Library").local8Bit() ); | ||
95 | end.setDefault( cfg.value("Default").toInt() ); | ||
96 | end.setPreference( cfg.value("Preference").toInt() ); | ||
97 | } | ||
98 | return end; | ||
99 | } | ||