-rw-r--r-- | libopie2/opiedb/osqlitedriver.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlitedriver.h | 2 | ||||
-rw-r--r-- | libopie2/opiedb/osqlmanager.cpp | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp index 47bc250..2c53248 100644 --- a/libopie2/opiedb/osqlitedriver.cpp +++ b/libopie2/opiedb/osqlitedriver.cpp | |||
@@ -12,65 +12,65 @@ | |||
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 "osqlquery.h" | 31 | #include "osqlquery.h" |
32 | #include "osqlitedriver.h" | 32 | #include "osqlitedriver.h" |
33 | 33 | ||
34 | #include <opie2/odebug.h> | 34 | #include <opie2/odebug.h> |
35 | 35 | ||
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | // fromLocal8Bit() does not work as expected. Thus it | 38 | // fromLocal8Bit() does not work as expected. Thus it |
39 | // is replaced by fromLatin1() (eilers) | 39 | // is replaced by fromLatin1() (eilers) |
40 | #define __BUGGY_LOCAL8BIT_ | 40 | #define __BUGGY_LOCAL8BIT_ |
41 | 41 | ||
42 | 42 | ||
43 | using namespace Opie::DB; | 43 | using namespace Opie::DB; |
44 | using namespace Opie::DB::Private; | 44 | using namespace Opie::DB::Internal; |
45 | 45 | ||
46 | namespace { | 46 | namespace { |
47 | struct Query { | 47 | struct Query { |
48 | OSQLError::ValueList errors; | 48 | OSQLError::ValueList errors; |
49 | OSQLResultItem::ValueList items; | 49 | OSQLResultItem::ValueList items; |
50 | OSQLiteDriver *driver; | 50 | OSQLiteDriver *driver; |
51 | }; | 51 | }; |
52 | } | 52 | } |
53 | 53 | ||
54 | 54 | ||
55 | OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) | 55 | OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) |
56 | : OSQLDriver( lib ) | 56 | : OSQLDriver( lib ) |
57 | { | 57 | { |
58 | m_sqlite = 0l; | 58 | m_sqlite = 0l; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | OSQLiteDriver::~OSQLiteDriver() { | 62 | OSQLiteDriver::~OSQLiteDriver() { |
63 | close(); | 63 | close(); |
64 | } | 64 | } |
65 | 65 | ||
66 | 66 | ||
67 | QString OSQLiteDriver::id()const { | 67 | QString OSQLiteDriver::id()const { |
68 | return QString::fromLatin1("SQLite"); | 68 | return QString::fromLatin1("SQLite"); |
69 | } | 69 | } |
70 | 70 | ||
71 | void OSQLiteDriver::setUserName( const QString& ) {} | 71 | void OSQLiteDriver::setUserName( const QString& ) {} |
72 | 72 | ||
73 | 73 | ||
74 | void OSQLiteDriver::setPassword( const QString& ) {} | 74 | void OSQLiteDriver::setPassword( const QString& ) {} |
75 | 75 | ||
76 | 76 | ||
diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h index 3e1325b..9064e52 100644 --- a/libopie2/opiedb/osqlitedriver.h +++ b/libopie2/opiedb/osqlitedriver.h | |||
@@ -1,42 +1,42 @@ | |||
1 | #ifndef OSQL_LITE_DRIVER_H | 1 | #ifndef OSQL_LITE_DRIVER_H |
2 | #define OSQL_LITE_DRIVER_H | 2 | #define OSQL_LITE_DRIVER_H |
3 | 3 | ||
4 | #include <sqlite.h> | 4 | #include <sqlite.h> |
5 | 5 | ||
6 | #include "osqldriver.h" | 6 | #include "osqldriver.h" |
7 | #include "osqlerror.h" | 7 | #include "osqlerror.h" |
8 | #include "osqlresult.h" | 8 | #include "osqlresult.h" |
9 | 9 | ||
10 | namespace Opie { | 10 | namespace Opie { |
11 | namespace DB { | 11 | namespace DB { |
12 | namespace Private { | 12 | namespace Internal { |
13 | 13 | ||
14 | class OSQLiteDriver : public OSQLDriver { | 14 | class OSQLiteDriver : public OSQLDriver { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | public: | 16 | public: |
17 | OSQLiteDriver( QLibrary *lib = 0l ); | 17 | OSQLiteDriver( QLibrary *lib = 0l ); |
18 | ~OSQLiteDriver(); | 18 | ~OSQLiteDriver(); |
19 | QString id()const; | 19 | QString id()const; |
20 | void setUserName( const QString& ); | 20 | void setUserName( const QString& ); |
21 | void setPassword( const QString& ); | 21 | void setPassword( const QString& ); |
22 | void setUrl( const QString& url ); | 22 | void setUrl( const QString& url ); |
23 | void setOptions( const QStringList& ); | 23 | void setOptions( const QStringList& ); |
24 | bool open(); | 24 | bool open(); |
25 | bool close(); | 25 | bool close(); |
26 | OSQLError lastError(); | 26 | OSQLError lastError(); |
27 | OSQLResult query( OSQLQuery* ); | 27 | OSQLResult query( OSQLQuery* ); |
28 | OSQLTable::ValueList tables()const; | 28 | OSQLTable::ValueList tables()const; |
29 | private: | 29 | private: |
30 | OSQLError m_lastE; | 30 | OSQLError m_lastE; |
31 | OSQLResult m_result; | 31 | OSQLResult m_result; |
32 | OSQLResultItem m_items; | 32 | OSQLResultItem m_items; |
33 | int handleCallBack( int, char**, char** ); | 33 | int handleCallBack( int, char**, char** ); |
34 | static int call_back( void*, int, char**, char** ); | 34 | static int call_back( void*, int, char**, char** ); |
35 | QString m_url; | 35 | QString m_url; |
36 | sqlite *m_sqlite; | 36 | sqlite *m_sqlite; |
37 | }; | 37 | }; |
38 | } | 38 | } |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | #endif | 42 | #endif |
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp index 990d258..a6498df 100644 --- a/libopie2/opiedb/osqlmanager.cpp +++ b/libopie2/opiedb/osqlmanager.cpp | |||
@@ -4,76 +4,76 @@ | |||
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; | 8 | using namespace Opie::DB; |
9 | 9 | ||
10 | OSQLManager::OSQLManager() { | 10 | OSQLManager::OSQLManager() { |
11 | } | 11 | } |
12 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { | 12 | OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { |
13 | m_list.clear(); | 13 | m_list.clear(); |
14 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); | 14 | QString opie = QString::fromLatin1( getenv("OPIEDIR") ); |
15 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); | 15 | QString qpe = QString::fromLatin1( getenv("QPEDIR") ); |
16 | 16 | ||
17 | if ( !m_path.contains(opie) && !opie.isEmpty() ) | 17 | if ( !m_path.contains(opie) && !opie.isEmpty() ) |
18 | m_path << opie; | 18 | m_path << opie; |
19 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) | 19 | if ( !m_path.contains(qpe) && !qpe.isEmpty() ) |
20 | m_path << qpe; | 20 | m_path << qpe; |
21 | 21 | ||
22 | OSQLBackEndManager mng( m_path ); | 22 | OSQLBackEndManager mng( m_path ); |
23 | m_list = mng.scan(); | 23 | m_list = mng.scan(); |
24 | m_list += builtIn(); | 24 | m_list += builtIn(); |
25 | 25 | ||
26 | return m_list; | 26 | return m_list; |
27 | } | 27 | } |
28 | /* | 28 | /* |
29 | * loading dso's is currently not enabled due problems with QLibrary | 29 | * loading dso's is currently not enabled due problems with QLibrary |
30 | * beeing in libqpe and not libqte | 30 | * beeing in libqpe and not libqte |
31 | */ | 31 | */ |
32 | OSQLDriver* OSQLManager::load( const QString& name ) { | 32 | OSQLDriver* OSQLManager::load( const QString& name ) { |
33 | OSQLDriver* driver = 0l; | 33 | OSQLDriver* driver = 0l; |
34 | 34 | ||
35 | if ( name == "SQLite" ) { | 35 | if ( name == "SQLite" ) { |
36 | driver = new Opie::DB::Private::OSQLiteDriver; | 36 | driver = new Opie::DB::Internal::OSQLiteDriver; |
37 | } | 37 | } |
38 | return driver; | 38 | return driver; |
39 | } | 39 | } |
40 | /* | 40 | /* |
41 | * same as above | 41 | * same as above |
42 | */ | 42 | */ |
43 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { | 43 | OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { |
44 | OSQLDriver *driver = 0l; | 44 | OSQLDriver *driver = 0l; |
45 | if ( end.library() == "builtin" && | 45 | if ( end.library() == "builtin" && |
46 | end.name() == "SQLite" ) | 46 | end.name() == "SQLite" ) |
47 | driver = new Opie::DB::Private::OSQLiteDriver; | 47 | driver = new Opie::DB::Internal::OSQLiteDriver; |
48 | 48 | ||
49 | return driver; | 49 | return driver; |
50 | } | 50 | } |
51 | /* | 51 | /* |
52 | * let's find the a default with the highes preference | 52 | * let's find the a default with the highes preference |
53 | */ | 53 | */ |
54 | OSQLDriver* OSQLManager::standard() { | 54 | OSQLDriver* OSQLManager::standard() { |
55 | OSQLDriver* driver =0l; | 55 | OSQLDriver* driver =0l; |
56 | if ( m_list.isEmpty() ) queryBackEnd(); | 56 | if ( m_list.isEmpty() ) queryBackEnd(); |
57 | OSQLBackEnd::ValueList::Iterator it; | 57 | OSQLBackEnd::ValueList::Iterator it; |
58 | OSQLBackEnd back; | 58 | OSQLBackEnd back; |
59 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 59 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
60 | if ( (*it).isDefault() && | 60 | if ( (*it).isDefault() && |
61 | back.preference() < (*it).preference() ) { | 61 | back.preference() < (*it).preference() ) { |
62 | back = (*it); | 62 | back = (*it); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | driver = load( back ); | 65 | driver = load( back ); |
66 | return driver; | 66 | return driver; |
67 | } | 67 | } |
68 | void OSQLManager::registerPath( const QString& path ) { | 68 | void OSQLManager::registerPath( const QString& path ) { |
69 | m_path << path; | 69 | m_path << path; |
70 | } | 70 | } |
71 | bool OSQLManager::unregisterPath( const QString& path ) { | 71 | bool OSQLManager::unregisterPath( const QString& path ) { |
72 | m_path.remove( path ); | 72 | m_path.remove( path ); |
73 | return true; | 73 | return true; |
74 | } | 74 | } |
75 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { | 75 | OSQLBackEnd::ValueList OSQLManager::builtIn()const { |
76 | OSQLBackEnd::ValueList list; | 76 | OSQLBackEnd::ValueList list; |
77 | // create the OSQLiteBackend | 77 | // create the OSQLiteBackend |
78 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); | 78 | OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); |
79 | back.setDefault( true ); | 79 | back.setDefault( true ); |