summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h26
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h30
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp7
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp7
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h12
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h45
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h6
8 files changed, 134 insertions, 11 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 3a73210..ad6cf5a 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -13,12 +13,17 @@
13 * ToDo: Use plugins 13 * ToDo: Use plugins
14 * ===================================================================== 14 * =====================================================================
15 * Version: $Id$ 15 * Version: $Id$
16 * ===================================================================== 16 * =====================================================================
17 * History: 17 * History:
18 * $Log$ 18 * $Log$
19 * Revision 1.6 2003/04/13 18:07:10 zecke
20 * More API doc
21 * QString -> const QString&
22 * QString = 0l -> QString::null
23 *
19 * Revision 1.5 2003/02/21 23:31:52 zecke 24 * Revision 1.5 2003/02/21 23:31:52 zecke
20 * Add XML datebookresource 25 * Add XML datebookresource
21 * -clean up todoaccessxml header 26 * -clean up todoaccessxml header
22 * -implement some more stuff in the oeven tester 27 * -implement some more stuff in the oeven tester
23 * -extend DefaultFactory to not crash and to use datebook 28 * -extend DefaultFactory to not crash and to use datebook
24 * 29 *
@@ -60,25 +65,44 @@
60#include "odatebookaccessbackend_xml.h" 65#include "odatebookaccessbackend_xml.h"
61 66
62#ifdef __USE_SQL 67#ifdef __USE_SQL
63#include "otodoaccesssql.h" 68#include "otodoaccesssql.h"
64#endif 69#endif
65 70
66 71/**
72 * This class is our factory. It will give us the default implementations
73 * of at least Todolist, Contacts and Datebook. In the future this class will
74 * allow users to switch the backend with ( XML->SQLite ) without the need
75 * to recompile.#
76 * This class as the whole PIM Api is making use of templates
77 *
78 * <pre>
79 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null );
80 * backend->load();
81 * </pre>
82 *
83 * @author Stefan Eilers
84 * @version 0.1
85 */
67template<class T> 86template<class T>
68class OBackendFactory 87class OBackendFactory
69{ 88{
70 public: 89 public:
71 OBackendFactory() {}; 90 OBackendFactory() {};
72 91
73 enum BACKENDS { 92 enum BACKENDS {
74 TODO, 93 TODO,
75 CONTACT, 94 CONTACT,
76 DATE 95 DATE
77 }; 96 };
78 97
98 /**
99 * Returns a backend implementation for backendName
100 * @param backendName the type of the backend
101 * @param appName will be passed on to the backend
102 */
79 static T* Default( const QString backendName, const QString& appName ){ 103 static T* Default( const QString backendName, const QString& appName ){
80 104
81 // __asm__("int3"); 105 // __asm__("int3");
82 106
83 Config config( "pimaccess" ); 107 Config config( "pimaccess" );
84 config.setGroup ( backendName ); 108 config.setGroup ( backendName );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 821f5bf..ebeb42d 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -16,12 +16,17 @@
16 * ToDo: Define enum for query settings 16 * ToDo: Define enum for query settings
17 * ===================================================================== 17 * =====================================================================
18 * Version: $Id$ 18 * Version: $Id$
19 * ===================================================================== 19 * =====================================================================
20 * History: 20 * History:
21 * $Log$ 21 * $Log$
22 * Revision 1.5 2003/04/13 18:07:10 zecke
23 * More API doc
24 * QString -> const QString&
25 * QString = 0l -> QString::null
26 *
22 * Revision 1.4 2002/11/13 14:14:51 eilers 27 * Revision 1.4 2002/11/13 14:14:51 eilers
23 * Added sorted for Contacts.. 28 * Added sorted for Contacts..
24 * 29 *
25 * Revision 1.3 2002/11/01 15:10:42 eilers 30 * Revision 1.3 2002/11/01 15:10:42 eilers
26 * Added regExp-search in database for all fields in a contact. 31 * Added regExp-search in database for all fields in a contact.
27 * 32 *
@@ -41,21 +46,32 @@
41#ifndef _OCONTACTACCESSBACKEND_H_ 46#ifndef _OCONTACTACCESSBACKEND_H_
42#define _OCONTACTACCESSBACKEND_H_ 47#define _OCONTACTACCESSBACKEND_H_
43 48
44#include "ocontact.h" 49#include "ocontact.h"
45#include "opimaccessbackend.h" 50#include "opimaccessbackend.h"
46 51
47#include "qregexp.h" 52#include <qregexp.h>
48 53
54/**
55 * This class represents the interface of all Contact Backends.
56 * Derivates of this class will be used to access the contacts.
57 * As implementation currently XML and vCard exist. This class needs to be implemented
58 * if you want to provide your own storage.
59 * In all queries a list of uids is passed on instead of loading the actual record!
60 *
61 * @see OContactAccessBackend_VCard
62 * @see OContactAccessBackend_XML
63 */
49class OContactAccessBackend: public OPimAccessBackend<OContact> { 64class OContactAccessBackend: public OPimAccessBackend<OContact> {
50 public: 65 public:
51 OContactAccessBackend() {} 66 OContactAccessBackend() {}
52 virtual ~OContactAccessBackend() {} 67 virtual ~OContactAccessBackend() {}
53 68
54 69
55 /** Return if database was changed externally. 70 /**
71 * Return if database was changed externally.
56 * This may just make sense on file based databases like a XML-File. 72 * This may just make sense on file based databases like a XML-File.
57 * It is used to prevent to overwrite the current database content 73 * It is used to prevent to overwrite the current database content
58 * if the file was already changed by something else ! 74 * if the file was already changed by something else !
59 * If this happens, we have to reload before save our data. 75 * If this happens, we have to reload before save our data.
60 * If we use real databases, this should be handled by the database 76 * If we use real databases, this should be handled by the database
61 * management system themselve, therefore this function should always return false in 77 * management system themselve, therefore this function should always return false in
@@ -65,21 +81,27 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
65 * in this situation. 81 * in this situation.
66 */ 82 */
67 virtual bool wasChangedExternally() = 0; 83 virtual bool wasChangedExternally() = 0;
68 84
69 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
70 86
71 /** Return all possible settings. 87 /**
88 * Return all possible settings.
72 * @return All settings provided by the current backend 89 * @return All settings provided by the current backend
73 * (i.e.: query_WildCards & query_IgnoreCase) 90 * (i.e.: query_WildCards & query_IgnoreCase)
74 */ 91 */
75 virtual const uint querySettings() = 0; 92 virtual const uint querySettings() = 0;
76 93
77 /** Check whether settings are correct. 94 /**
95 * Check whether settings are correct.
78 * @return <i>true</i> if the given settings are correct and possible. 96 * @return <i>true</i> if the given settings are correct and possible.
79 */ 97 */
80 virtual bool hasQuerySettings (uint querySettings) const = 0; 98 virtual bool hasQuerySettings (uint querySettings) const = 0;
81 99
100 /**
101 * FIXME!!!
102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
103 */
82 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; 104 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
83 105
84}; 106};
85#endif 107#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index f24523f..270bef3 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -14,12 +14,17 @@
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.10 2003/04/13 18:07:10 zecke
21 * More API doc
22 * QString -> const QString&
23 * QString = 0l -> QString::null
24 *
20 * Revision 1.9 2003/03/21 10:33:09 eilers 25 * Revision 1.9 2003/03/21 10:33:09 eilers
21 * Merged speed optimized xml backend for contacts to main. 26 * Merged speed optimized xml backend for contacts to main.
22 * Added QDateTime to querybyexample. For instance, it is now possible to get 27 * Added QDateTime to querybyexample. For instance, it is now possible to get
23 * all Birthdays/Anniversaries between two dates. This should be used 28 * all Birthdays/Anniversaries between two dates. This should be used
24 * to show all birthdays in the datebook.. 29 * to show all birthdays in the datebook..
25 * This change is sourcecode backward compatible but you have to upgrade 30 * This change is sourcecode backward compatible but you have to upgrade
@@ -73,13 +78,13 @@
73#include "../../library/backend/qfiledirect_p.h" 78#include "../../library/backend/qfiledirect_p.h"
74 79
75#include <qpe/timeconversion.h> 80#include <qpe/timeconversion.h>
76 81
77#include <qfile.h> 82#include <qfile.h>
78 83
79OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ): 84OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ):
80 m_dirty( false ), 85 m_dirty( false ),
81 m_file( filename ) 86 m_file( filename )
82{ 87{
83 load(); 88 load();
84} 89}
85 90
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 93e2da3..712d769 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -14,12 +14,17 @@
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.6 2003/04/13 18:07:10 zecke
21 * More API doc
22 * QString -> const QString&
23 * QString = 0l -> QString::null
24 *
20 * Revision 1.5 2003/03/21 10:33:09 eilers 25 * Revision 1.5 2003/03/21 10:33:09 eilers
21 * Merged speed optimized xml backend for contacts to main. 26 * Merged speed optimized xml backend for contacts to main.
22 * Added QDateTime to querybyexample. For instance, it is now possible to get 27 * Added QDateTime to querybyexample. For instance, it is now possible to get
23 * all Birthdays/Anniversaries between two dates. This should be used 28 * all Birthdays/Anniversaries between two dates. This should be used
24 * to show all birthdays in the datebook.. 29 * to show all birthdays in the datebook..
25 * This change is sourcecode backward compatible but you have to upgrade 30 * This change is sourcecode backward compatible but you have to upgrade
@@ -44,15 +49,20 @@
44#include <opie/ocontact.h> 49#include <opie/ocontact.h>
45 50
46#include "ocontactaccessbackend.h" 51#include "ocontactaccessbackend.h"
47 52
48class VObject; 53class VObject;
49 54
55/**
56 * This is the vCard 2.1 implementation of the Contact Storage
57 * @see OContactAccessBackend_XML
58 * @see OPimAccessBackend
59 */
50class OContactAccessBackend_VCard : public OContactAccessBackend { 60class OContactAccessBackend_VCard : public OContactAccessBackend {
51 public: 61 public:
52 OContactAccessBackend_VCard ( QString appname, QString filename = 0l ); 62 OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
53 63
54 bool load (); 64 bool load ();
55 bool reload(); 65 bool reload();
56 bool save(); 66 bool save();
57 void clear (); 67 void clear ();
58 68
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index c5a7820..661cd51 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -14,12 +14,17 @@
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.5 2003/04/13 18:07:10 zecke
21 * More API doc
22 * QString -> const QString&
23 * QString = 0l -> QString::null
24 *
20 * Revision 1.4 2003/03/21 14:32:54 mickeyl 25 * Revision 1.4 2003/03/21 14:32:54 mickeyl
21 * g++ compliance fix: default arguments belong into the declaration, but not the definition 26 * g++ compliance fix: default arguments belong into the declaration, but not the definition
22 * 27 *
23 * Revision 1.3 2003/03/21 12:26:28 eilers 28 * Revision 1.3 2003/03/21 12:26:28 eilers
24 * Fixing small bug: If we search a birthday from today to today, it returned 29 * Fixing small bug: If we search a birthday from today to today, it returned
25 * every contact .. 30 * every contact ..
@@ -104,13 +109,13 @@
104#include <stdlib.h> 109#include <stdlib.h>
105#include <errno.h> 110#include <errno.h>
106 111
107using namespace Opie; 112using namespace Opie;
108 113
109 114
110OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString filename ): 115OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
111 m_changed( false ) 116 m_changed( false )
112{ 117{
113 // Just m_contactlist should call delete if an entry 118 // Just m_contactlist should call delete if an entry
114 // is removed. 119 // is removed.
115 m_contactList.setAutoDelete( true ); 120 m_contactList.setAutoDelete( true );
116 m_uidToContact.setAutoDelete( false ); 121 m_uidToContact.setAutoDelete( false );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index 4d6a7ef..7b5365b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -14,12 +14,17 @@
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.14 2003/04/13 18:07:10 zecke
21 * More API doc
22 * QString -> const QString&
23 * QString = 0l -> QString::null
24 *
20 * Revision 1.13 2003/03/21 10:33:09 eilers 25 * Revision 1.13 2003/03/21 10:33:09 eilers
21 * Merged speed optimized xml backend for contacts to main. 26 * Merged speed optimized xml backend for contacts to main.
22 * Added QDateTime to querybyexample. For instance, it is now possible to get 27 * Added QDateTime to querybyexample. For instance, it is now possible to get
23 * all Birthdays/Anniversaries between two dates. This should be used 28 * all Birthdays/Anniversaries between two dates. This should be used
24 * to show all birthdays in the datebook.. 29 * to show all birthdays in the datebook..
25 * This change is sourcecode backward compatible but you have to upgrade 30 * This change is sourcecode backward compatible but you have to upgrade
@@ -81,15 +86,20 @@
81#include "ocontactaccess.h" 86#include "ocontactaccess.h"
82 87
83#include <qlist.h> 88#include <qlist.h>
84#include <qdict.h> 89#include <qdict.h>
85 90
86/* the default xml implementation */ 91/* the default xml implementation */
92/**
93 * This class is the XML implementation of a Contact backend
94 * it does implement everything available for OContact.
95 * @see OPimAccessBackend for more information of available methods
96 */
87class OContactAccessBackend_XML : public OContactAccessBackend { 97class OContactAccessBackend_XML : public OContactAccessBackend {
88 public: 98 public:
89 OContactAccessBackend_XML ( QString appname, QString filename = 0l ); 99 OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
90 100
91 bool save(); 101 bool save();
92 102
93 bool load (); 103 bool load ();
94 104
95 void clear (); 105 void clear ();
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index eb6e8fb..86ff298 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -3,30 +3,71 @@
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include "opimaccessbackend.h" 6#include "opimaccessbackend.h"
7#include "oevent.h" 7#include "oevent.h"
8 8
9/**
10 * This class is the interface to the storage of Events.
11 * @see OPimAccessBackend
12 *
13 */
9class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { 14class ODateBookAccessBackend : public OPimAccessBackend<OEvent> {
10public: 15public:
11 typedef int UID; 16 typedef int UID;
17
18 /**
19 * c'tor without parameter
20 */
12 ODateBookAccessBackend(); 21 ODateBookAccessBackend();
13 ~ODateBookAccessBackend(); 22 ~ODateBookAccessBackend();
14 23
24 /**
25 * This method should return a list of UIDs containing
26 * all events. No filter should be applied
27 * @return list of events
28 */
15 virtual QArray<UID> rawEvents()const = 0; 29 virtual QArray<UID> rawEvents()const = 0;
30
31 /**
32 * This method should return a list of UIDs containing
33 * all repeating events. No filter should be applied
34 * @return list of repeating events
35 */
16 virtual QArray<UID> rawRepeats()const = 0; 36 virtual QArray<UID> rawRepeats()const = 0;
37
38 /**
39 * This mthod should return a list of UIDs containing all non
40 * repeating events. No filter should be applied
41 * @return list of nonrepeating events
42 */
17 virtual QArray<UID> nonRepeats() const = 0; 43 virtual QArray<UID> nonRepeats() const = 0;
18 44
19 /** 45 /**
20 * these two methods are used if you do not implement 46 * If you do not want to implement the effectiveEvents methods below
21 * effectiveEvents... 47 * you need to supply it with directNonRepeats.
48 * This method can return empty lists if effectiveEvents is implememted
22 */ 49 */
23 virtual OEvent::ValueList directNonRepeats() = 0; 50 virtual OEvent::ValueList directNonRepeats() = 0;
51
52 /**
53 * Same as above but return raw repeats!
54 */
24 virtual OEvent::ValueList directRawRepeats() = 0; 55 virtual OEvent::ValueList directRawRepeats() = 0;
25 56
26 /* is implemented by default but you can reimplement it*/ 57 /* is implemented by default but you can reimplement it*/
58 /**
59 * Effective Events are special event occuring during a time frame. This method does calcualte
60 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
61 * yourself
62 */
27 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); 63 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
64
65 /**
66 * this is an overloaded member function
67 * @see effecticeEvents
68 */
28 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); 69 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
29 70
30}; 71};
31 72
32#endif 73#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 563c31f..7848f7c 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -2,12 +2,18 @@
2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 2#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
3 3
4#include <qmap.h> 4#include <qmap.h>
5 5
6#include "odatebookaccessbackend.h" 6#include "odatebookaccessbackend.h"
7 7
8/**
9 * This is the default XML implementation for DateBoook XML storage
10 * It fully implements the interface
11 * @see ODateBookAccessBackend
12 * @see OPimAccessBackend
13 */
8class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 14class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
9public: 15public:
10 ODateBookAccessBackend_XML( const QString& appName, 16 ODateBookAccessBackend_XML( const QString& appName,
11 const QString& fileName = QString::null); 17 const QString& fileName = QString::null);
12 ~ODateBookAccessBackend_XML(); 18 ~ODateBookAccessBackend_XML();
13 19