Diffstat (limited to 'libopie2/opiedb/osqlmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiedb/osqlmanager.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp index 766ebe1..990d258 100644 --- a/libopie2/opiedb/osqlmanager.cpp +++ b/libopie2/opiedb/osqlmanager.cpp | |||
@@ -1,81 +1,83 @@ | |||
1 | 1 | ||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include "osqlmanager.h" | 4 | #include "osqlmanager.h" |
5 | #include "osqlbackendmanager.h" | 5 | #include "osqlbackendmanager.h" |
6 | #include "osqlitedriver.h" | 6 | #include "osqlitedriver.h" |
7 | 7 | ||
8 | using namespace Opie::DB; | ||
9 | |||
8 | OSQLManager::OSQLManager() { | 10 | OSQLManager::OSQLManager() { |
9 | } | 11 | } |
10 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { | 12 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { |
11 | m_list.clear(); | 13 | m_list.clear(); |
12 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); | 14 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); |
13 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); | 15 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); |
14 | 16 | ||
15 | if ( !m_path.contains(opie) && !opie.isEmpty() ) | 17 | if ( !m_path.contains(opie) && !opie.isEmpty() ) |
16 | m_path << opie; | 18 | m_path << opie; |
17 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) | 19 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) |
18 | m_path << qpe; | 20 | m_path << qpe; |
19 | 21 | ||
20 | OSQLBackEndManager mng( m_path ); | 22 | OSQLBackEndManager mng( m_path ); |
21 | m_list = mng.scan(); | 23 | m_list = mng.scan(); |
22 | m_list += builtIn(); | 24 | m_list += builtIn(); |
23 | 25 | ||
24 | return m_list; | 26 | return m_list; |
25 | } | 27 | } |
26 | /* | 28 | /* |
27 | * loading dso's is currently not enabled due problems with QLibrary | 29 | * loading dso's is currently not enabled due problems with QLibrary |
28 | * beeing in libqpe and not libqte | 30 | * beeing in libqpe and not libqte |
29 | */ | 31 | */ |
30 | OSQLDriver* OSQLManager::load( const QString& name ) { | 32 | OSQLDriver* OSQLManager::load( const QString& name ) { |
31 | OSQLDriver* driver = 0l; | 33 | OSQLDriver* driver = 0l; |
32 | 34 | ||
33 | if ( name == "SQLite" ) { | 35 | if ( name == "SQLite" ) { |
34 | driver = new OSQLiteDriver(); | 36 | driver = new Opie::DB::Private::OSQLiteDriver; |
35 | } | 37 | } |
36 | return driver; | 38 | return driver; |
37 | } | 39 | } |
38 | /* | 40 | /* |
39 | * same as above | 41 | * same as above |
40 | */ | 42 | */ |
41 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { | 43 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { |
42 | OSQLDriver *driver = 0l; | 44 | OSQLDriver *driver = 0l; |
43 | if ( end.library() == "builtin" && | 45 | if ( end.library() == "builtin" && |
44 | end.name() == "SQLite" ) | 46 | end.name() == "SQLite" ) |
45 | driver = new OSQLiteDriver(); | 47 | driver = new Opie::DB::Private::OSQLiteDriver; |
46 | 48 | ||
47 | return driver; | 49 | return driver; |
48 | } | 50 | } |
49 | /* | 51 | /* |
50 | * let's find the a default with the highes preference | 52 | * let's find the a default with the highes preference |
51 | */ | 53 | */ |
52 | OSQLDriver* OSQLManager::standard() { | 54 | OSQLDriver* OSQLManager::standard() { |
53 | OSQLDriver* driver =0l; | 55 | OSQLDriver* driver =0l; |
54 | if ( m_list.isEmpty() ) queryBackEnd(); | 56 | if ( m_list.isEmpty() ) queryBackEnd(); |
55 | OSQLBackEnd::ValueList::Iterator it; | 57 | OSQLBackEnd::ValueList::Iterator it; |
56 | OSQLBackEnd back; | 58 | OSQLBackEnd back; |
57 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 59 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
58 | if ( (*it).isDefault() && | 60 | if ( (*it).isDefault() && |
59 | back.preference() < (*it).preference() ) { | 61 | back.preference() < (*it).preference() ) { |
60 | back = (*it); | 62 | back = (*it); |
61 | } | 63 | } |
62 | } | 64 | } |
63 | driver = load( back ); | 65 | driver = load( back ); |
64 | return driver; | 66 | return driver; |
65 | } | 67 | } |
66 | void OSQLManager::registerPath( const QString& path ) { | 68 | void OSQLManager::registerPath( const QString& path ) { |
67 | m_path << path; | 69 | m_path << path; |
68 | } | 70 | } |
69 | bool OSQLManager::unregisterPath( const QString& path ) { | 71 | bool OSQLManager::unregisterPath( const QString& path ) { |
70 | m_path.remove( path ); | 72 | m_path.remove( path ); |
71 | return true; | 73 | return true; |
72 | } | 74 | } |
73 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { | 75 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { |
74 | OSQLBackEnd::ValueList list; | 76 | OSQLBackEnd::ValueList list; |
75 | // create the OSQLiteBackend | 77 | // create the OSQLiteBackend |
76 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); | 78 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); |
77 | back.setDefault( true ); | 79 | back.setDefault( true ); |
78 | back.setPreference( 50 ); | 80 | back.setPreference( 50 ); |
79 | list.append( back ); | 81 | list.append( back ); |
80 | return list; | 82 | return list; |
81 | } | 83 | } |