summaryrefslogtreecommitdiff
path: root/libopie/pim
Unidiff
Diffstat (limited to 'libopie/pim') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_sql.cpp5
-rw-r--r--libopie/pim/ocontactaccessbackend_sql.h10
-rw-r--r--libopie/pim/odatebookaccessbackend_sql.cpp4
-rw-r--r--libopie/pim/odatebookaccessbackend_sql.h7
-rw-r--r--libopie/pim/otodoaccesssql.cpp1
-rw-r--r--libopie/pim/otodoaccesssql.h13
6 files changed, 31 insertions, 9 deletions
diff --git a/libopie/pim/ocontactaccessbackend_sql.cpp b/libopie/pim/ocontactaccessbackend_sql.cpp
index a5be4c8..d20df56 100644
--- a/libopie/pim/ocontactaccessbackend_sql.cpp
+++ b/libopie/pim/ocontactaccessbackend_sql.cpp
@@ -5,24 +5,27 @@
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ===================================================================== 12 * =====================================================================
13 * Version: $Id$ 13 * Version: $Id$
14 * ===================================================================== 14 * =====================================================================
15 * History: 15 * History:
16 * $Log$ 16 * $Log$
17 * Revision 1.5 2004/03/14 13:50:35 alwin
18 * namespace correction
19 *
17 * Revision 1.4 2003/12/22 10:19:26 eilers 20 * Revision 1.4 2003/12/22 10:19:26 eilers
18 * Finishing implementation of sql-backend for datebook. But I have to 21 * Finishing implementation of sql-backend for datebook. But I have to
19 * port the PIM datebook application to use it, before I could debug the 22 * port the PIM datebook application to use it, before I could debug the
20 * whole stuff. 23 * whole stuff.
21 * Thus, PIM-Database backend is finished, but highly experimental. And some 24 * Thus, PIM-Database backend is finished, but highly experimental. And some
22 * parts are still generic. For instance, the "queryByExample()" methods are 25 * parts are still generic. For instance, the "queryByExample()" methods are
23 * not (or not fully) implemented. Todo: custom-entries not stored. 26 * not (or not fully) implemented. Todo: custom-entries not stored.
24 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 27 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
25 * expression search in the database, which is not supported by sqlite ! 28 * expression search in the database, which is not supported by sqlite !
26 * Therefore we need either an extended sqlite or a workaround which would 29 * Therefore we need either an extended sqlite or a workaround which would
27 * be very slow and memory consuming.. 30 * be very slow and memory consuming..
28 * 31 *
@@ -48,25 +51,25 @@
48#include <qstringlist.h> 51#include <qstringlist.h>
49 52
50#include <qpe/global.h> 53#include <qpe/global.h>
51#include <qpe/recordfields.h> 54#include <qpe/recordfields.h>
52 55
53#include <opie/ocontactfields.h> 56#include <opie/ocontactfields.h>
54#include <opie/oconversion.h> 57#include <opie/oconversion.h>
55#include <opie2/osqldriver.h> 58#include <opie2/osqldriver.h>
56#include <opie2/osqlresult.h> 59#include <opie2/osqlresult.h>
57#include <opie2/osqlmanager.h> 60#include <opie2/osqlmanager.h>
58#include <opie2/osqlquery.h> 61#include <opie2/osqlquery.h>
59 62
60 63using namespace Opie::DB;
61 64
62 65
63// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead 66// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
64// vertical like "uid, type, value". 67// vertical like "uid, type, value".
65// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! 68// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
66#define __STORE_HORIZONTAL_ 69#define __STORE_HORIZONTAL_
67 70
68// Distinct loading is not very fast. If I expect that every person has just 71// Distinct loading is not very fast. If I expect that every person has just
69// one (and always one) 'Last Name', I can request all uid's for existing lastnames, 72// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
70// which is faster.. 73// which is faster..
71// But this may not be true for all entries, like company contacts.. 74// But this may not be true for all entries, like company contacts..
72// The current AddressBook application handles this problem, but other may not.. (eilers) 75// The current AddressBook application handles this problem, but other may not.. (eilers)
diff --git a/libopie/pim/ocontactaccessbackend_sql.h b/libopie/pim/ocontactaccessbackend_sql.h
index b8f1d8d..f553760 100644
--- a/libopie/pim/ocontactaccessbackend_sql.h
+++ b/libopie/pim/ocontactaccessbackend_sql.h
@@ -7,48 +7,54 @@
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * 12 *
13 * 13 *
14 * ===================================================================== 14 * =====================================================================
15 * Version: $Id$ 15 * Version: $Id$
16 * ===================================================================== 16 * =====================================================================
17 * History: 17 * History:
18 * $Log$ 18 * $Log$
19 * Revision 1.3 2004/03/14 13:50:35 alwin
20 * namespace correction
21 *
19 * Revision 1.2 2003/12/08 15:18:11 eilers 22 * Revision 1.2 2003/12/08 15:18:11 eilers
20 * Committing unfinished sql implementation before merging to libopie2 starts.. 23 * Committing unfinished sql implementation before merging to libopie2 starts..
21 * 24 *
22 * Revision 1.1 2003/09/22 14:31:16 eilers 25 * Revision 1.1 2003/09/22 14:31:16 eilers
23 * Added first experimental incarnation of sql-backend for addressbook. 26 * Added first experimental incarnation of sql-backend for addressbook.
24 * Some modifications to be able to compile the todo sql-backend. 27 * Some modifications to be able to compile the todo sql-backend.
25 * A lot of changes fill follow... 28 * A lot of changes fill follow...
26 * 29 *
27 * 30 *
28 */ 31 */
29 32
30#ifndef _OContactAccessBackend_SQL_ 33#ifndef _OContactAccessBackend_SQL_
31#define _OContactAccessBackend_SQL_ 34#define _OContactAccessBackend_SQL_
32 35
33#include "ocontactaccessbackend.h" 36#include "ocontactaccessbackend.h"
34#include "ocontactaccess.h" 37#include "ocontactaccess.h"
35 38
36#include <qlist.h> 39#include <qlist.h>
37#include <qdict.h> 40#include <qdict.h>
38 41
42namespace Opie { namespace DB {
39class OSQLDriver; 43class OSQLDriver;
40class OSQLResult; 44class OSQLResult;
41class OSQLResultItem; 45class OSQLResultItem;
42 46
47}}
48
43/* the default xml implementation */ 49/* the default xml implementation */
44/** 50/**
45 * This class is the SQL implementation of a Contact backend 51 * This class is the SQL implementation of a Contact backend
46 * it does implement everything available for OContact. 52 * it does implement everything available for OContact.
47 * @see OPimAccessBackend for more information of available methods 53 * @see OPimAccessBackend for more information of available methods
48 */ 54 */
49class OContactAccessBackend_SQL : public OContactAccessBackend { 55class OContactAccessBackend_SQL : public OContactAccessBackend {
50 public: 56 public:
51 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 57 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
52 58
53 ~OContactAccessBackend_SQL (); 59 ~OContactAccessBackend_SQL ();
54 60
@@ -76,26 +82,26 @@ class OContactAccessBackend_SQL : public OContactAccessBackend {
76 bool hasQuerySettings (uint querySettings) const; 82 bool hasQuerySettings (uint querySettings) const;
77 83
78 // Currently only asc implemented.. 84 // Currently only asc implemented..
79 QArray<int> sorted( bool asc, int , int , int ); 85 QArray<int> sorted( bool asc, int , int , int );
80 bool add ( const OContact &newcontact ); 86 bool add ( const OContact &newcontact );
81 87
82 bool replace ( const OContact &contact ); 88 bool replace ( const OContact &contact );
83 89
84 bool remove ( int uid ); 90 bool remove ( int uid );
85 bool reload(); 91 bool reload();
86 92
87 private: 93 private:
88 QArray<int> extractUids( OSQLResult& res ) const; 94 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
89 QMap<int, QString> requestNonCustom( int uid ) const; 95 QMap<int, QString> requestNonCustom( int uid ) const;
90 QMap<QString, QString> requestCustom( int uid ) const; 96 QMap<QString, QString> requestCustom( int uid ) const;
91 void update(); 97 void update();
92 98
93 protected: 99 protected:
94 bool m_changed; 100 bool m_changed;
95 QString m_fileName; 101 QString m_fileName;
96 QArray<int> m_uids; 102 QArray<int> m_uids;
97 103
98 OSQLDriver* m_driver; 104 Opie::DB::OSQLDriver* m_driver;
99}; 105};
100 106
101#endif 107#endif
diff --git a/libopie/pim/odatebookaccessbackend_sql.cpp b/libopie/pim/odatebookaccessbackend_sql.cpp
index 756f405..44dd2bc 100644
--- a/libopie/pim/odatebookaccessbackend_sql.cpp
+++ b/libopie/pim/odatebookaccessbackend_sql.cpp
@@ -5,24 +5,27 @@
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ===================================================================== 12 * =====================================================================
13 * Version: $Id$ 13 * Version: $Id$
14 * ===================================================================== 14 * =====================================================================
15 * History: 15 * History:
16 * $Log$ 16 * $Log$
17 * Revision 1.4 2004/03/14 13:50:35 alwin
18 * namespace correction
19 *
17 * Revision 1.3 2003/12/22 11:41:39 eilers 20 * Revision 1.3 2003/12/22 11:41:39 eilers
18 * Fixing stupid bug, found by sourcode review.. 21 * Fixing stupid bug, found by sourcode review..
19 * 22 *
20 * Revision 1.2 2003/12/22 10:19:26 eilers 23 * Revision 1.2 2003/12/22 10:19:26 eilers
21 * Finishing implementation of sql-backend for datebook. But I have to 24 * Finishing implementation of sql-backend for datebook. But I have to
22 * port the PIM datebook application to use it, before I could debug the 25 * port the PIM datebook application to use it, before I could debug the
23 * whole stuff. 26 * whole stuff.
24 * Thus, PIM-Database backend is finished, but highly experimental. And some 27 * Thus, PIM-Database backend is finished, but highly experimental. And some
25 * parts are still generic. For instance, the "queryByExample()" methods are 28 * parts are still generic. For instance, the "queryByExample()" methods are
26 * not (or not fully) implemented. Todo: custom-entries not stored. 29 * not (or not fully) implemented. Todo: custom-entries not stored.
27 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 30 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
28 * expression search in the database, which is not supported by sqlite ! 31 * expression search in the database, which is not supported by sqlite !
@@ -41,24 +44,25 @@
41#include <qarray.h> 44#include <qarray.h>
42#include <qstringlist.h> 45#include <qstringlist.h>
43 46
44#include <qpe/global.h> 47#include <qpe/global.h>
45 48
46#include <opie2/osqldriver.h> 49#include <opie2/osqldriver.h>
47#include <opie2/osqlmanager.h> 50#include <opie2/osqlmanager.h>
48#include <opie2/osqlquery.h> 51#include <opie2/osqlquery.h>
49 52
50#include "orecur.h" 53#include "orecur.h"
51#include "odatebookaccessbackend_sql.h" 54#include "odatebookaccessbackend_sql.h"
52 55
56using namespace Opie::DB;
53 57
54 58
55ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , 59ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
56 const QString& fileName ) 60 const QString& fileName )
57 : ODateBookAccessBackend(), m_driver( NULL ) 61 : ODateBookAccessBackend(), m_driver( NULL )
58{ 62{
59 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; 63 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
60 64
61 // Get the standart sql-driver from the OSQLManager.. 65 // Get the standart sql-driver from the OSQLManager..
62 OSQLManager man; 66 OSQLManager man;
63 m_driver = man.standard(); 67 m_driver = man.standard();
64 m_driver->setUrl( m_fileName ); 68 m_driver->setUrl( m_fileName );
diff --git a/libopie/pim/odatebookaccessbackend_sql.h b/libopie/pim/odatebookaccessbackend_sql.h
index f39e154..ba514bc 100644
--- a/libopie/pim/odatebookaccessbackend_sql.h
+++ b/libopie/pim/odatebookaccessbackend_sql.h
@@ -1,22 +1,25 @@
1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 1#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5#include <opie2/osqlresult.h> 5#include <opie2/osqlresult.h>
6 6
7#include "odatebookaccessbackend.h" 7#include "odatebookaccessbackend.h"
8 8
9namespace Opie { namespace DB {
9class OSQLDriver; 10class OSQLDriver;
10 11
12}}
13
11/** 14/**
12 * This is the default SQL implementation for DateBoook SQL storage 15 * This is the default SQL implementation for DateBoook SQL storage
13 * It fully implements the interface 16 * It fully implements the interface
14 * @see ODateBookAccessBackend 17 * @see ODateBookAccessBackend
15 * @see OPimAccessBackend 18 * @see OPimAccessBackend
16 */ 19 */
17class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { 20class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
18public: 21public:
19 ODateBookAccessBackend_SQL( const QString& appName, 22 ODateBookAccessBackend_SQL( const QString& appName,
20 const QString& fileName = QString::null); 23 const QString& fileName = QString::null);
21 ~ODateBookAccessBackend_SQL(); 24 ~ODateBookAccessBackend_SQL();
22 25
@@ -39,24 +42,24 @@ public:
39 42
40 OEvent::ValueList directNonRepeats(); 43 OEvent::ValueList directNonRepeats();
41 OEvent::ValueList directRawRepeats(); 44 OEvent::ValueList directRawRepeats();
42 45
43private: 46private:
44 bool loadFile(); 47 bool loadFile();
45 QString m_fileName; 48 QString m_fileName;
46 QArray<int> m_uids; 49 QArray<int> m_uids;
47 50
48 QMap<int, QString> m_fieldMap; 51 QMap<int, QString> m_fieldMap;
49 QMap<QString, int> m_reverseFieldMap; 52 QMap<QString, int> m_reverseFieldMap;
50 53
51 OSQLDriver* m_driver; 54 Opie::DB::OSQLDriver* m_driver;
52 55
53 class Private; 56 class Private;
54 Private *d; 57 Private *d;
55 58
56 void initFields(); 59 void initFields();
57 void update(); 60 void update();
58 QArray<int> extractUids( OSQLResult& res ) const; 61 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
59 62
60}; 63};
61 64
62#endif 65#endif
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index 3764c7e..fd01a42 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -4,24 +4,25 @@
4#include <qpe/global.h> 4#include <qpe/global.h>
5 5
6#include <opie2/osqldriver.h> 6#include <opie2/osqldriver.h>
7#include <opie2/osqlresult.h> 7#include <opie2/osqlresult.h>
8#include <opie2/osqlmanager.h> 8#include <opie2/osqlmanager.h>
9#include <opie2/osqlquery.h> 9#include <opie2/osqlquery.h>
10 10
11#include "otodoaccesssql.h" 11#include "otodoaccesssql.h"
12#include "opimstate.h" 12#include "opimstate.h"
13#include "opimnotifymanager.h" 13#include "opimnotifymanager.h"
14#include "orecur.h" 14#include "orecur.h"
15 15
16using namespace Opie::DB;
16/* 17/*
17 * first some query 18 * first some query
18 * CREATE query 19 * CREATE query
19 * LOAD query 20 * LOAD query
20 * INSERT 21 * INSERT
21 * REMOVE 22 * REMOVE
22 * CLEAR 23 * CLEAR
23 */ 24 */
24namespace { 25namespace {
25 /** 26 /**
26 * CreateQuery for the Todolist Table 27 * CreateQuery for the Todolist Table
27 */ 28 */
diff --git a/libopie/pim/otodoaccesssql.h b/libopie/pim/otodoaccesssql.h
index 1c55567..72214de 100644
--- a/libopie/pim/otodoaccesssql.h
+++ b/libopie/pim/otodoaccesssql.h
@@ -1,22 +1,27 @@
1#ifndef OPIE_PIM_ACCESS_SQL_H 1#ifndef OPIE_PIM_ACCESS_SQL_H
2#define OPIE_PIM_ACCESS_SQL_H 2#define OPIE_PIM_ACCESS_SQL_H
3 3
4#include <qasciidict.h> 4#include <qasciidict.h>
5 5
6#include "otodoaccessbackend.h" 6#include "otodoaccessbackend.h"
7 7
8namespace Opie{
9namespace DB {
8class OSQLDriver; 10class OSQLDriver;
9class OSQLResult; 11class OSQLResult;
10class OSQLResultItem; 12class OSQLResultItem;
13}
14}
15
11class OTodoAccessBackendSQL : public OTodoAccessBackend { 16class OTodoAccessBackendSQL : public OTodoAccessBackend {
12public: 17public:
13 OTodoAccessBackendSQL( const QString& file ); 18 OTodoAccessBackendSQL( const QString& file );
14 ~OTodoAccessBackendSQL(); 19 ~OTodoAccessBackendSQL();
15 20
16 bool load(); 21 bool load();
17 bool reload(); 22 bool reload();
18 bool save(); 23 bool save();
19 QArray<int> allRecords()const; 24 QArray<int> allRecords()const;
20 25
21 QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); 26 QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() );
22 OTodo find(int uid)const; 27 OTodo find(int uid)const;
@@ -31,26 +36,26 @@ public:
31 const QDate& end, bool includeNoDates ); 36 const QDate& end, bool includeNoDates );
32 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 37 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
33 38
34 QBitArray supports()const; 39 QBitArray supports()const;
35 QArray<int> matchRegexp( const QRegExp &r ) const; 40 QArray<int> matchRegexp( const QRegExp &r ) const;
36 void removeAllCompleted(); 41 void removeAllCompleted();
37 42
38 43
39private: 44private:
40 void update()const; 45 void update()const;
41 void fillDict(); 46 void fillDict();
42 inline bool date( QDate& date, const QString& )const; 47 inline bool date( QDate& date, const QString& )const;
43 inline OTodo todo( const OSQLResult& )const; 48 inline OTodo todo( const Opie::DB::OSQLResult& )const;
44 inline OTodo todo( OSQLResultItem& )const; 49 inline OTodo todo( Opie::DB::OSQLResultItem& )const;
45 inline QArray<int> uids( const OSQLResult& )const; 50 inline QArray<int> uids( const Opie::DB::OSQLResult& )const;
46 OTodo todo( int uid )const; 51 OTodo todo( int uid )const;
47 QBitArray sup() const; 52 QBitArray sup() const;
48 53
49 QAsciiDict<int> m_dict; 54 QAsciiDict<int> m_dict;
50 OSQLDriver* m_driver; 55 Opie::DB::OSQLDriver* m_driver;
51 QArray<int> m_uids; 56 QArray<int> m_uids;
52 bool m_dirty : 1; 57 bool m_dirty : 1;
53}; 58};
54 59
55 60
56#endif 61#endif