summaryrefslogtreecommitdiff
path: root/libopie2/opiedb
Unidiff
Diffstat (limited to 'libopie2/opiedb') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/osqlbackendmanager.cpp1
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp1
-rw-r--r--libopie2/opiedb/osqlmanager.cpp2
-rw-r--r--libopie2/opiedb/osqlresult.cpp1
4 files changed, 0 insertions, 5 deletions
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp
index 0f261b9..95ed77b 100644
--- a/libopie2/opiedb/osqlbackendmanager.cpp
+++ b/libopie2/opiedb/osqlbackendmanager.cpp
@@ -1,50 +1,49 @@
1#include <qdir.h> 1#include <qdir.h>
2#include <qfile.h>
3#include <qmap.h> 2#include <qmap.h>
4 3
5#include "osqlbackendmanager.h" 4#include "osqlbackendmanager.h"
6 5
7namespace { 6namespace {
8 class Config { 7 class Config {
9 typedef QMap<QString, QString> List; 8 typedef QMap<QString, QString> List;
10 public: 9 public:
11 Config( const QString& fileName ); 10 Config( const QString& fileName );
12 /** 11 /**
13 * Quite simple layout in nature 12 * Quite simple layout in nature
14 * BeginFile 13 * BeginFile
15 * Key = Value 14 * Key = Value
16 */ 15 */
17 bool load(); 16 bool load();
18 QString value( const QString& key ); 17 QString value( const QString& key );
19 private: 18 private:
20 List m_list; 19 List m_list;
21 QString m_fileName; 20 QString m_fileName;
22 }; 21 };
23 Config::Config( const QString& fileName ) 22 Config::Config( const QString& fileName )
24 : m_fileName( fileName ) { 23 : m_fileName( fileName ) {
25 } 24 }
26 25
27 bool Config::load() { 26 bool Config::load() {
28 if (!QFile::exists( m_fileName ) ) 27 if (!QFile::exists( m_fileName ) )
29 return false; 28 return false;
30 QFile file( m_fileName ); 29 QFile file( m_fileName );
31 if (!file.open(IO_ReadOnly ) ) 30 if (!file.open(IO_ReadOnly ) )
32 return false; 31 return false;
33 QStringList list = QStringList::split( '\n', file.readAll() ); 32 QStringList list = QStringList::split( '\n', file.readAll() );
34 QStringList::Iterator it; 33 QStringList::Iterator it;
35 QString line; 34 QString line;
36 for (it = list.begin(); it != list.end(); ++it ) { 35 for (it = list.begin(); it != list.end(); ++it ) {
37 line = (*it).stripWhiteSpace(); 36 line = (*it).stripWhiteSpace();
38 qWarning("Anonymous::Config:" + line ); 37 qWarning("Anonymous::Config:" + line );
39 QStringList test = QStringList::split(' ', line ); 38 QStringList test = QStringList::split(' ', line );
40 m_list.insert( test[0], test[2] ); 39 m_list.insert( test[0], test[2] );
41 } 40 }
42 return true; 41 return true;
43 } 42 }
44 QString Config::value( const QString& key ) { 43 QString Config::value( const QString& key ) {
45 return m_list[key]; 44 return m_list[key];
46 } 45 }
47}; 46};
48OSQLBackEndManager::OSQLBackEndManager( const QStringList& path ) 47OSQLBackEndManager::OSQLBackEndManager( const QStringList& path )
49 :m_path( path ) 48 :m_path( path )
50{ 49{
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index b857534..6141504 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -1,79 +1,78 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
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 "osqlresult.h"
32#include "osqlquery.h" 31#include "osqlquery.h"
33#include "osqlitedriver.h" 32#include "osqlitedriver.h"
34 33
35#include <opie2/odebug.h> 34#include <opie2/odebug.h>
36 35
37#include <stdlib.h> 36#include <stdlib.h>
38 37
39// fromLocal8Bit() does not work as expected. Thus it 38// fromLocal8Bit() does not work as expected. Thus it
40// is replaced by fromLatin1() (eilers) 39// is replaced by fromLatin1() (eilers)
41#define __BUGGY_LOCAL8BIT_ 40#define __BUGGY_LOCAL8BIT_
42 41
43 42
44namespace { 43namespace {
45 struct Query { 44 struct Query {
46 OSQLError::ValueList errors; 45 OSQLError::ValueList errors;
47 OSQLResultItem::ValueList items; 46 OSQLResultItem::ValueList items;
48 OSQLiteDriver *driver; 47 OSQLiteDriver *driver;
49 }; 48 };
50} 49}
51 50
52 51
53OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) 52OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
54 : OSQLDriver( lib ) 53 : OSQLDriver( lib )
55{ 54{
56 m_sqlite = 0l; 55 m_sqlite = 0l;
57} 56}
58 57
59 58
60OSQLiteDriver::~OSQLiteDriver() { 59OSQLiteDriver::~OSQLiteDriver() {
61 close(); 60 close();
62} 61}
63 62
64 63
65QString OSQLiteDriver::id()const { 64QString OSQLiteDriver::id()const {
66 return QString::fromLatin1("SQLite"); 65 return QString::fromLatin1("SQLite");
67} 66}
68 67
69void OSQLiteDriver::setUserName( const QString& ) {} 68void OSQLiteDriver::setUserName( const QString& ) {}
70 69
71 70
72void OSQLiteDriver::setPassword( const QString& ) {} 71void OSQLiteDriver::setPassword( const QString& ) {}
73 72
74 73
75void OSQLiteDriver::setUrl( const QString& url ) { 74void OSQLiteDriver::setUrl( const QString& url ) {
76 m_url = url; 75 m_url = url;
77} 76}
78 77
79 78
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp
index b0fea04..766ebe1 100644
--- a/libopie2/opiedb/osqlmanager.cpp
+++ b/libopie2/opiedb/osqlmanager.cpp
@@ -1,53 +1,51 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "osqlbackend.h"
5#include "osqldriver.h"
6#include "osqlmanager.h" 4#include "osqlmanager.h"
7#include "osqlbackendmanager.h" 5#include "osqlbackendmanager.h"
8#include "osqlitedriver.h" 6#include "osqlitedriver.h"
9 7
10OSQLManager::OSQLManager() { 8OSQLManager::OSQLManager() {
11} 9}
12OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { 10OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
13 m_list.clear(); 11 m_list.clear();
14 QString opie = QString::fromLatin1( getenv("OPIEDIR") ); 12 QString opie = QString::fromLatin1( getenv("OPIEDIR") );
15 QString qpe = QString::fromLatin1( getenv("QPEDIR") ); 13 QString qpe = QString::fromLatin1( getenv("QPEDIR") );
16 14
17 if ( !m_path.contains(opie) && !opie.isEmpty() ) 15 if ( !m_path.contains(opie) && !opie.isEmpty() )
18 m_path << opie; 16 m_path << opie;
19 if ( !m_path.contains(qpe) && !qpe.isEmpty() ) 17 if ( !m_path.contains(qpe) && !qpe.isEmpty() )
20 m_path << qpe; 18 m_path << qpe;
21 19
22 OSQLBackEndManager mng( m_path ); 20 OSQLBackEndManager mng( m_path );
23 m_list = mng.scan(); 21 m_list = mng.scan();
24 m_list += builtIn(); 22 m_list += builtIn();
25 23
26 return m_list; 24 return m_list;
27} 25}
28/* 26/*
29 * loading dso's is currently not enabled due problems with QLibrary 27 * loading dso's is currently not enabled due problems with QLibrary
30 * beeing in libqpe and not libqte 28 * beeing in libqpe and not libqte
31 */ 29 */
32OSQLDriver* OSQLManager::load( const QString& name ) { 30OSQLDriver* OSQLManager::load( const QString& name ) {
33 OSQLDriver* driver = 0l; 31 OSQLDriver* driver = 0l;
34 32
35 if ( name == "SQLite" ) { 33 if ( name == "SQLite" ) {
36 driver = new OSQLiteDriver(); 34 driver = new OSQLiteDriver();
37 } 35 }
38 return driver; 36 return driver;
39} 37}
40/* 38/*
41 * same as above 39 * same as above
42 */ 40 */
43OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { 41OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
44 OSQLDriver *driver = 0l; 42 OSQLDriver *driver = 0l;
45 if ( end.library() == "builtin" && 43 if ( end.library() == "builtin" &&
46 end.name() == "SQLite" ) 44 end.name() == "SQLite" )
47 driver = new OSQLiteDriver(); 45 driver = new OSQLiteDriver();
48 46
49 return driver; 47 return driver;
50} 48}
51/* 49/*
52 * let's find the a default with the highes preference 50 * let's find the a default with the highes preference
53 */ 51 */
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp
index 490fb45..42da356 100644
--- a/libopie2/opiedb/osqlresult.cpp
+++ b/libopie2/opiedb/osqlresult.cpp
@@ -1,50 +1,49 @@
1 1
2#include "osqlquery.h"
3#include "osqlresult.h" 2#include "osqlresult.h"
4 3
5OSQLResultItem::OSQLResultItem( const TableString& string, 4OSQLResultItem::OSQLResultItem( const TableString& string,
6 const TableInt& Int) 5 const TableInt& Int)
7 : m_string( string ), m_int( Int ) 6 : m_string( string ), m_int( Int )
8{ 7{
9 8
10} 9}
11OSQLResultItem::~OSQLResultItem() { 10OSQLResultItem::~OSQLResultItem() {
12} 11}
13OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { 12OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
14 *this = item; 13 *this = item;
15} 14}
16OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { 15OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
17 m_string = other.m_string; 16 m_string = other.m_string;
18 m_int = other.m_int; 17 m_int = other.m_int;
19 return *this; 18 return *this;
20} 19}
21OSQLResultItem::TableString OSQLResultItem::tableString()const{ 20OSQLResultItem::TableString OSQLResultItem::tableString()const{
22 return m_string; 21 return m_string;
23} 22}
24OSQLResultItem::TableInt OSQLResultItem::tableInt()const { 23OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
25 return m_int; 24 return m_int;
26} 25}
27QString OSQLResultItem::data( const QString& columnName, bool *ok ) { 26QString OSQLResultItem::data( const QString& columnName, bool *ok ) {
28 TableString::Iterator it = m_string.find( columnName ); 27 TableString::Iterator it = m_string.find( columnName );
29 28
30 /* if found */ 29 /* if found */
31 if ( it != m_string.end() ) { 30 if ( it != m_string.end() ) {
32 if ( ok ) *ok = true; 31 if ( ok ) *ok = true;
33 return it.data(); 32 return it.data();
34 }else{ 33 }else{
35 if ( ok ) *ok = false; 34 if ( ok ) *ok = false;
36 return QString::null; 35 return QString::null;
37 } 36 }
38 37
39} 38}
40QString OSQLResultItem::data( int column, bool *ok ) { 39QString OSQLResultItem::data( int column, bool *ok ) {
41 TableInt::Iterator it = m_int.find( column ); 40 TableInt::Iterator it = m_int.find( column );
42 41
43 /* if found */ 42 /* if found */
44 if ( it != m_int.end() ) { 43 if ( it != m_int.end() ) {
45 if ( ok ) *ok = true; 44 if ( ok ) *ok = true;
46 return it.data(); 45 return it.data();
47 }else{ 46 }else{
48 if ( ok ) *ok = false; 47 if ( ok ) *ok = false;
49 return QString::null; 48 return QString::null;
50 } 49 }