summaryrefslogtreecommitdiff
path: root/libopie2/opiedb
Unidiff
Diffstat (limited to 'libopie2/opiedb') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/opiedb.pro51
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp69
2 files changed, 84 insertions, 36 deletions
diff --git a/libopie2/opiedb/opiedb.pro b/libopie2/opiedb/opiedb.pro
index d869e6f..249d8b5 100644
--- a/libopie2/opiedb/opiedb.pro
+++ b/libopie2/opiedb/opiedb.pro
@@ -1,34 +1,29 @@
1TEMPLATE = lib 1TEMPLATE = lib
2#CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3CONFIG += qt warn_on release
4DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
5HEADERS = osqlbackend.h \ 4HEADERS = osqlbackend.h \
6 osqldriver.h \ 5 osqldriver.h \
7 osqlerror.h \ 6 osqlerror.h \
8 osqlmanager.h \ 7 osqlmanager.h \
9 osqlquery.h \ 8 osqlquery.h \
10 osqlresult.h \ 9 osqlresult.h \
11 osqltable.h \ 10 osqltable.h \
12 osqlbackendmanager.h \ 11 osqlbackendmanager.h \
13 osqlitedriver.h 12 osqlitedriver.h
14SOURCES = osqlbackend.cpp \ 13SOURCES = osqlbackend.cpp \
15 osqldriver.cpp \ 14 osqldriver.cpp \
16 osqlerror.cpp \ 15 osqlerror.cpp \
17 osqlmanager.cpp \ 16 osqlmanager.cpp \
18 osqlquery.cpp \ 17 osqlquery.cpp \
19 osqlresult.cpp \ 18 osqlresult.cpp \
20 osqltable.cpp \ 19 osqltable.cpp \
21 osqlbackendmanager.cpp \ 20 osqlbackendmanager.cpp \
22 osqlitedriver.cpp 21 osqlitedriver.cpp
23INTERFACES = 22INTERFACES =
24TARGET = opiedb2 23TARGET = opiedb2
25VERSION = 1.8.2 24VERSION = 1.8.2
26INCLUDEPATH += $(OPIEDIR)/include 25INCLUDEPATH = $(OPIEDIR)/include
27DEPENDPATH += $(OPIEDIR)/include 26DEPENDPATH = $(OPIEDIR)/include
28 27LIBS += -lsqlite -lqpe
29MOC_DIR = moc
30OBJECTS_DIR = obj
31
32LIBS += -lsqlite -lqpe
33 28
34!contains( platform, x11 ) { 29!contains( platform, x11 ) {
@@ -37,5 +32,5 @@ LIBS += -lsqlite -lqpe
37 32
38contains( platform, x11 ) { 33contains( platform, x11 ) {
39 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 34 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
40} 35}
41 36
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 99fd218..b857534 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -1,3 +1,31 @@
1#include <stdlib.h> 1/*
2                 This file is part of the Opie Project
3
4 =.
5 .=l.
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28
29*/
2 30
3#include "osqlresult.h" 31#include "osqlresult.h"
@@ -5,5 +33,9 @@
5#include "osqlitedriver.h" 33#include "osqlitedriver.h"
6 34
7// fromLocal8Bit() does not work as expected. Thus it 35#include <opie2/odebug.h>
36
37#include <stdlib.h>
38
39// fromLocal8Bit() does not work as expected. Thus it
8// is replaced by fromLatin1() (eilers) 40// is replaced by fromLatin1() (eilers)
9#define __BUGGY_LOCAL8BIT_ 41#define __BUGGY_LOCAL8BIT_
@@ -18,4 +50,5 @@ namespace {
18} 50}
19 51
52
20OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) 53OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
21 : OSQLDriver( lib ) 54 : OSQLDriver( lib )
@@ -23,8 +56,11 @@ OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
23 m_sqlite = 0l; 56 m_sqlite = 0l;
24} 57}
58
59
25OSQLiteDriver::~OSQLiteDriver() { 60OSQLiteDriver::~OSQLiteDriver() {
26 close(); 61 close();
27} 62}
28 63
64
29QString OSQLiteDriver::id()const { 65QString OSQLiteDriver::id()const {
30 return QString::fromLatin1("SQLite"); 66 return QString::fromLatin1("SQLite");
@@ -32,11 +68,18 @@ QString OSQLiteDriver::id()const {
32 68
33void OSQLiteDriver::setUserName( const QString& ) {} 69void OSQLiteDriver::setUserName( const QString& ) {}
70
71
34void OSQLiteDriver::setPassword( const QString& ) {} 72void OSQLiteDriver::setPassword( const QString& ) {}
35 73
74
36void OSQLiteDriver::setUrl( const QString& url ) { 75void OSQLiteDriver::setUrl( const QString& url ) {
37 m_url = url; 76 m_url = url;
38} 77}
78
79
39void OSQLiteDriver::setOptions( const QStringList& ) { 80void OSQLiteDriver::setOptions( const QStringList& ) {
40} 81}
82
83
41/* 84/*
42 * try to open a db specified via setUrl 85 * try to open a db specified via setUrl
@@ -45,5 +88,5 @@ void OSQLiteDriver::setOptions( const QStringList& ) {
45bool OSQLiteDriver::open() { 88bool OSQLiteDriver::open() {
46 char *error; 89 char *error;
47 qWarning("about to open"); 90 odebug << "OSQLiteDriver::open: about to open" << oendl;
48 m_sqlite = sqlite_open(m_url.local8Bit(), 91 m_sqlite = sqlite_open(m_url.local8Bit(),
49 0, 92 0,
@@ -53,5 +96,5 @@ bool OSQLiteDriver::open() {
53 if (m_sqlite == 0l ) { 96 if (m_sqlite == 0l ) {
54 // FIXME set the last error 97 // FIXME set the last error
55 qWarning("error:%s", error ); 98 owarn << "OSQLiteDriver::open: " << error << oendl;
56 free( error ); 99 free( error );
57 return false; 100 return false;
@@ -59,4 +102,6 @@ bool OSQLiteDriver::open() {
59 return true; 102 return true;
60} 103}
104
105
61/* close the db 106/* close the db
62 * sqlite closes them without 107 * sqlite closes them without
@@ -69,4 +114,6 @@ bool OSQLiteDriver::close() {
69 return true; 114 return true;
70} 115}
116
117
71/* Query */ 118/* Query */
72OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 119OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
@@ -81,9 +128,9 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
81 /* SQLITE_OK 0 if return code > 0 == failure */ 128 /* SQLITE_OK 0 if return code > 0 == failure */
82 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 129 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
83 qWarning("Error while executing"); 130 owarn << "OSQLiteDriver::query: Error while executing" << oendl;
84 free(err ); 131 free(err );
85 // FixMe Errors 132 // FixMe Errors
86 } 133 }
87 // qWarning("Item count is %d", query.items.count() ); 134
88 OSQLResult result(OSQLResult::Success, 135 OSQLResult result(OSQLResult::Success,
89 query.items, 136 query.items,
@@ -91,11 +138,17 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
91 return result; 138 return result;
92} 139}
140
141
93OSQLTable::ValueList OSQLiteDriver::tables() const { 142OSQLTable::ValueList OSQLiteDriver::tables() const {
94 143
95} 144}
145
146
96OSQLError OSQLiteDriver::lastError() { 147OSQLError OSQLiteDriver::lastError() {
97 OSQLError error; 148 OSQLError error;
98 return error; 149 return error;
99}; 150};
151
152
100/* handle a callback add the row to the global 153/* handle a callback add the row to the global
101 * OSQLResultItem 154 * OSQLResultItem
@@ -104,8 +157,9 @@ int OSQLiteDriver::handleCallBack( int, char**, char** ) {
104 return 0; 157 return 0;
105} 158}
159
160
106/* callback_handler add the values to the list*/ 161/* callback_handler add the values to the list*/
107int OSQLiteDriver::call_back( void* voi, int argc, 162int OSQLiteDriver::call_back( void* voi, int argc,
108 char** argv, char** columns) { 163 char** argv, char** columns) {
109 // qWarning("Callback with %d items", argc );
110 Query* qu = (Query*)voi; 164 Query* qu = (Query*)voi;
111 165
@@ -114,5 +168,4 @@ int OSQLiteDriver::call_back( void* voi, int argc,
114 QMap<int, QString> tableInt; 168 QMap<int, QString> tableInt;
115 for (int i = 0; i < argc; i++ ) { 169 for (int i = 0; i < argc; i++ ) {
116 //qWarning("%s|%s", columns[i], argv[i] );
117 170
118#ifdef __BUGGY_LOCAL8BIT_ 171#ifdef __BUGGY_LOCAL8BIT_