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.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp22
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp3
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp6
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp26
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp6
10 files changed, 89 insertions, 10 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index ad6cf5a..f3c339d 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -1,42 +1,50 @@
1/* 1/*
2 * Class to manage Backends. 2 * Class to manage Backends.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
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; 9 * License as published by the Free Software Foundation;
10 * either version 2 of the License, or (at your option) any later 10 * either version 2 of the License, or (at your option) any later
11 * version. 11 * version.
12 * ===================================================================== 12 * =====================================================================
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.7 2003/08/01 12:30:16 eilers
20 * Merging changes from BRANCH_1_0 to HEAD
21 *
22 * Revision 1.6.4.1 2003/06/30 14:34:19 eilers
23 * Patches from Zecke:
24 * Fixing and cleaning up extraMap handling
25 * Adding d_ptr for binary compatibility in the future
26 *
19 * Revision 1.6 2003/04/13 18:07:10 zecke 27 * Revision 1.6 2003/04/13 18:07:10 zecke
20 * More API doc 28 * More API doc
21 * QString -> const QString& 29 * QString -> const QString&
22 * QString = 0l -> QString::null 30 * QString = 0l -> QString::null
23 * 31 *
24 * Revision 1.5 2003/02/21 23:31:52 zecke 32 * Revision 1.5 2003/02/21 23:31:52 zecke
25 * Add XML datebookresource 33 * Add XML datebookresource
26 * -clean up todoaccessxml header 34 * -clean up todoaccessxml header
27 * -implement some more stuff in the oeven tester 35 * -implement some more stuff in the oeven tester
28 * -extend DefaultFactory to not crash and to use datebook 36 * -extend DefaultFactory to not crash and to use datebook
29 * 37 *
30 * -reading of OEvents is working nicely.. saving will be added 38 * -reading of OEvents is working nicely.. saving will be added
31 * tomorrow 39 * tomorrow
32 * -fix spelling in ODateBookAcces 40 * -fix spelling in ODateBookAcces
33 * 41 *
34 * Revision 1.4 2002/10/14 15:55:18 eilers 42 * Revision 1.4 2002/10/14 15:55:18 eilers
35 * Redeactivate SQL.. ;) 43 * Redeactivate SQL.. ;)
36 * 44 *
37 * Revision 1.3 2002/10/10 17:08:58 zecke 45 * Revision 1.3 2002/10/10 17:08:58 zecke
38 * The Cache is finally in place 46 * The Cache is finally in place
39 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) 47 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
40 * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... 48 * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster....
41 * I still have to fully implement read ahead 49 * I still have to fully implement read ahead
42 * This change is bic but sc 50 * This change is bic but sc
@@ -47,48 +55,50 @@
47 * compile itself would need to install libsqlite, libopiesql... 55 * compile itself would need to install libsqlite, libopiesql...
48 * Therefore, the backend currently uses XML only.. 56 * Therefore, the backend currently uses XML only..
49 * 57 *
50 * Revision 1.1 2002/10/07 17:35:01 eilers 58 * Revision 1.1 2002/10/07 17:35:01 eilers
51 * added OBackendFactory for advanced backend access 59 * added OBackendFactory for advanced backend access
52 * 60 *
53 * 61 *
54 * ===================================================================== 62 * =====================================================================
55 */ 63 */
56#ifndef OPIE_BACKENDFACTORY_H_ 64#ifndef OPIE_BACKENDFACTORY_H_
57#define OPIE_BACKENDFACTORY_H_ 65#define OPIE_BACKENDFACTORY_H_
58 66
59#include <qstring.h> 67#include <qstring.h>
60#include <qasciidict.h> 68#include <qasciidict.h>
61#include <qpe/config.h> 69#include <qpe/config.h>
62 70
63#include "otodoaccessxml.h" 71#include "otodoaccessxml.h"
64#include "ocontactaccessbackend_xml.h" 72#include "ocontactaccessbackend_xml.h"
65#include "odatebookaccessbackend_xml.h" 73#include "odatebookaccessbackend_xml.h"
66 74
67#ifdef __USE_SQL 75#ifdef __USE_SQL
68#include "otodoaccesssql.h" 76#include "otodoaccesssql.h"
69#endif 77#endif
70 78
79class OBackendPrivate;
80
71/** 81/**
72 * This class is our factory. It will give us the default implementations 82 * 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 83 * 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 84 * allow users to switch the backend with ( XML->SQLite ) without the need
75 * to recompile.# 85 * to recompile.#
76 * This class as the whole PIM Api is making use of templates 86 * This class as the whole PIM Api is making use of templates
77 * 87 *
78 * <pre> 88 * <pre>
79 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); 89 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null );
80 * backend->load(); 90 * backend->load();
81 * </pre> 91 * </pre>
82 * 92 *
83 * @author Stefan Eilers 93 * @author Stefan Eilers
84 * @version 0.1 94 * @version 0.1
85 */ 95 */
86template<class T> 96template<class T>
87class OBackendFactory 97class OBackendFactory
88{ 98{
89 public: 99 public:
90 OBackendFactory() {}; 100 OBackendFactory() {};
91 101
92 enum BACKENDS { 102 enum BACKENDS {
93 TODO, 103 TODO,
94 CONTACT, 104 CONTACT,
@@ -127,28 +137,30 @@ class OBackendFactory
127 if ( backend == "sql" ) 137 if ( backend == "sql" )
128 return (T*) new OTodoAccessBackendSQL(""); 138 return (T*) new OTodoAccessBackendSQL("");
129#else 139#else
130 if ( backend == "sql" ) 140 if ( backend == "sql" )
131 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 141 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
132#endif 142#endif
133 143
134 return (T*) new OTodoAccessXML( appName ); 144 return (T*) new OTodoAccessXML( appName );
135 case CONTACT: 145 case CONTACT:
136 if ( backend == "sql" ) 146 if ( backend == "sql" )
137 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 147 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
138 148
139 return (T*) new OContactAccessBackend_XML( appName ); 149 return (T*) new OContactAccessBackend_XML( appName );
140 case DATE: 150 case DATE:
141 if ( backend == "sql" ) 151 if ( backend == "sql" )
142 qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); 152 qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!");
143 153
144 return (T*) new ODateBookAccessBackend_XML( appName ); 154 return (T*) new ODateBookAccessBackend_XML( appName );
145 default: 155 default:
146 return NULL; 156 return NULL;
147 } 157 }
148 158
149 159
150 } 160 }
161 private:
162 OBackendPrivate* d;
151}; 163};
152 164
153 165
154#endif 166#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index ebeb42d..280e05c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -1,45 +1,53 @@
1/** 1/**
2 * The class responsible for managing a backend. 2 * The class responsible for managing a backend.
3 * The implementation of this abstract class contains 3 * The implementation of this abstract class contains
4 * the complete database handling. 4 * the complete database handling.
5 * 5 *
6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
8 * 8 *
9 * ===================================================================== 9 * =====================================================================
10 *This program is free software; you can redistribute it and/or 10 *This program is free software; you can redistribute it and/or
11 *modify it under the terms of the GNU Library General Public 11 *modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; 12 * License as published by the Free Software Foundation;
13 * either version 2 of the License, or (at your option) any later 13 * either version 2 of the License, or (at your option) any later
14 * version. 14 * version.
15 * ===================================================================== 15 * =====================================================================
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.6 2003/08/01 12:30:16 eilers
23 * Merging changes from BRANCH_1_0 to HEAD
24 *
25 * Revision 1.5.4.1 2003/06/30 14:34:19 eilers
26 * Patches from Zecke:
27 * Fixing and cleaning up extraMap handling
28 * Adding d_ptr for binary compatibility in the future
29 *
22 * Revision 1.5 2003/04/13 18:07:10 zecke 30 * Revision 1.5 2003/04/13 18:07:10 zecke
23 * More API doc 31 * More API doc
24 * QString -> const QString& 32 * QString -> const QString&
25 * QString = 0l -> QString::null 33 * QString = 0l -> QString::null
26 * 34 *
27 * Revision 1.4 2002/11/13 14:14:51 eilers 35 * Revision 1.4 2002/11/13 14:14:51 eilers
28 * Added sorted for Contacts.. 36 * Added sorted for Contacts..
29 * 37 *
30 * Revision 1.3 2002/11/01 15:10:42 eilers 38 * Revision 1.3 2002/11/01 15:10:42 eilers
31 * Added regExp-search in database for all fields in a contact. 39 * Added regExp-search in database for all fields in a contact.
32 * 40 *
33 * Revision 1.2 2002/10/07 17:34:24 eilers 41 * Revision 1.2 2002/10/07 17:34:24 eilers
34 * added OBackendFactory for advanced backend access 42 * added OBackendFactory for advanced backend access
35 * 43 *
36 * Revision 1.1 2002/09/27 17:11:44 eilers 44 * Revision 1.1 2002/09/27 17:11:44 eilers
37 * Added API for accessing the Contact-Database ! It is compiling, but 45 * Added API for accessing the Contact-Database ! It is compiling, but
38 * please do not expect that anything is working ! 46 * please do not expect that anything is working !
39 * I will debug that stuff in the next time .. 47 * I will debug that stuff in the next time ..
40 * Please read README_COMPILE for compiling ! 48 * Please read README_COMPILE for compiling !
41 * 49 *
42 * ===================================================================== 50 * =====================================================================
43 * 51 *
44 */ 52 */
45 53
@@ -82,26 +90,30 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
82 */ 90 */
83 virtual bool wasChangedExternally() = 0; 91 virtual bool wasChangedExternally() = 0;
84 92
85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 93 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
86 94
87 /** 95 /**
88 * Return all possible settings. 96 * Return all possible settings.
89 * @return All settings provided by the current backend 97 * @return All settings provided by the current backend
90 * (i.e.: query_WildCards & query_IgnoreCase) 98 * (i.e.: query_WildCards & query_IgnoreCase)
91 */ 99 */
92 virtual const uint querySettings() = 0; 100 virtual const uint querySettings() = 0;
93 101
94 /** 102 /**
95 * Check whether settings are correct. 103 * Check whether settings are correct.
96 * @return <i>true</i> if the given settings are correct and possible. 104 * @return <i>true</i> if the given settings are correct and possible.
97 */ 105 */
98 virtual bool hasQuerySettings (uint querySettings) const = 0; 106 virtual bool hasQuerySettings (uint querySettings) const = 0;
99 107
100 /** 108 /**
101 * FIXME!!! 109 * FIXME!!!
102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category 110 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
103 */ 111 */
104 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; 112 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
105 113
114
115private:
116 class Private;
117 Private *d;
106}; 118};
107#endif 119#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 270bef3..b60c5be 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,43 +1,58 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.11 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD
22 *
23 * Revision 1.10.4.3 2003/07/23 08:54:37 eilers
24 * Default email was added to the list of all emails, which already contains
25 * the default email..
26 * This closes bug #1045
27 *
28 * Revision 1.10.4.2 2003/07/23 08:44:45 eilers
29 * Importing of Notes in vcard files wasn't implemented.
30 * Closes bug #1044
31 *
32 * Revision 1.10.4.1 2003/06/02 13:37:49 eilers
33 * Fixing memory leak
34 *
20 * Revision 1.10 2003/04/13 18:07:10 zecke 35 * Revision 1.10 2003/04/13 18:07:10 zecke
21 * More API doc 36 * More API doc
22 * QString -> const QString& 37 * QString -> const QString&
23 * QString = 0l -> QString::null 38 * QString = 0l -> QString::null
24 * 39 *
25 * Revision 1.9 2003/03/21 10:33:09 eilers 40 * Revision 1.9 2003/03/21 10:33:09 eilers
26 * Merged speed optimized xml backend for contacts to main. 41 * Merged speed optimized xml backend for contacts to main.
27 * Added QDateTime to querybyexample. For instance, it is now possible to get 42 * Added QDateTime to querybyexample. For instance, it is now possible to get
28 * all Birthdays/Anniversaries between two dates. This should be used 43 * all Birthdays/Anniversaries between two dates. This should be used
29 * to show all birthdays in the datebook.. 44 * to show all birthdays in the datebook..
30 * This change is sourcecode backward compatible but you have to upgrade 45 * This change is sourcecode backward compatible but you have to upgrade
31 * the binaries for today-addressbook. 46 * the binaries for today-addressbook.
32 * 47 *
33 * Revision 1.8 2003/02/21 16:52:49 zecke 48 * Revision 1.8 2003/02/21 16:52:49 zecke
34 * -Remove old Todo classes they're deprecated and today I already using the 49 * -Remove old Todo classes they're deprecated and today I already using the
35 * new API 50 * new API
36 * -Guard against self assignment in OTodo 51 * -Guard against self assignment in OTodo
37 * -Add test apps for OPIM 52 * -Add test apps for OPIM
38 * -Opiefied Event classes 53 * -Opiefied Event classes
39 * -Added TimeZone handling and pinning of TimeZones to OEvent 54 * -Added TimeZone handling and pinning of TimeZones to OEvent
40 * -Adjust ORecur and the widget to better timezone behaviour 55 * -Adjust ORecur and the widget to better timezone behaviour
41 * 56 *
42 * Revision 1.7 2003/02/16 22:25:46 zecke 57 * Revision 1.7 2003/02/16 22:25:46 zecke
43 * 0000276 Fix for that bug.. or better temp workaround 58 * 0000276 Fix for that bug.. or better temp workaround
@@ -130,48 +145,49 @@ bool OContactAccessBackend_VCard::load ()
130bool OContactAccessBackend_VCard::reload() 145bool OContactAccessBackend_VCard::reload()
131{ 146{
132 return load(); 147 return load();
133} 148}
134bool OContactAccessBackend_VCard::save() 149bool OContactAccessBackend_VCard::save()
135{ 150{
136 if (!m_dirty ) 151 if (!m_dirty )
137 return true; 152 return true;
138 153
139 QFileDirect file( m_file ); 154 QFileDirect file( m_file );
140 if (!file.open(IO_WriteOnly ) ) 155 if (!file.open(IO_WriteOnly ) )
141 return false; 156 return false;
142 157
143 VObject *obj; 158 VObject *obj;
144 obj = newVObject( VCCalProp ); 159 obj = newVObject( VCCalProp );
145 addPropValue( obj, VCVersionProp, "1.0" ); 160 addPropValue( obj, VCVersionProp, "1.0" );
146 161
147 VObject *vo; 162 VObject *vo;
148 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 163 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
149 vo = createVObject( *it ); 164 vo = createVObject( *it );
150 writeVObject( file.directHandle() , vo ); 165 writeVObject( file.directHandle() , vo );
151 cleanVObject( vo ); 166 cleanVObject( vo );
152 } 167 }
153 cleanStrTbl(); 168 cleanStrTbl();
169 deleteVObject( obj );
154 170
155 m_dirty = false; 171 m_dirty = false;
156 return true; 172 return true;
157 173
158 174
159} 175}
160void OContactAccessBackend_VCard::clear () 176void OContactAccessBackend_VCard::clear ()
161{ 177{
162 m_map.clear(); 178 m_map.clear();
163 m_dirty = true; // ??? sure ? (se) 179 m_dirty = true; // ??? sure ? (se)
164} 180}
165 181
166bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 182bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
167{ 183{
168 m_map.insert( newcontact.uid(), newcontact ); 184 m_map.insert( newcontact.uid(), newcontact );
169 m_dirty = true; 185 m_dirty = true;
170 return true; 186 return true;
171} 187}
172 188
173bool OContactAccessBackend_VCard::remove ( int uid ) 189bool OContactAccessBackend_VCard::remove ( int uid )
174{ 190{
175 m_map.remove( uid ); 191 m_map.remove( uid );
176 m_dirty = true; 192 m_dirty = true;
177 return true; 193 return true;
@@ -425,49 +441,51 @@ OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
425 } 441 }
426 else if ( name == "X-Qtopia-Assistant" ) { 442 else if ( name == "X-Qtopia-Assistant" ) {
427 c.setAssistant( value ); 443 c.setAssistant( value );
428 } 444 }
429 else if ( name == "X-Qtopia-Spouse" ) { 445 else if ( name == "X-Qtopia-Spouse" ) {
430 c.setSpouse( value ); 446 c.setSpouse( value );
431 } 447 }
432 else if ( name == "X-Qtopia-Gender" ) { 448 else if ( name == "X-Qtopia-Gender" ) {
433 c.setGender( value ); 449 c.setGender( value );
434 } 450 }
435 else if ( name == "X-Qtopia-Anniversary" ) { 451 else if ( name == "X-Qtopia-Anniversary" ) {
436 c.setAnniversary( convVCardDateToDate( value ) ); 452 c.setAnniversary( convVCardDateToDate( value ) );
437 } 453 }
438 else if ( name == "X-Qtopia-Nickname" ) { 454 else if ( name == "X-Qtopia-Nickname" ) {
439 c.setNickname( value ); 455 c.setNickname( value );
440 } 456 }
441 else if ( name == "X-Qtopia-Children" ) { 457 else if ( name == "X-Qtopia-Children" ) {
442 c.setChildren( value ); 458 c.setChildren( value );
443 } 459 }
444 else if ( name == VCBirthDateProp ) { 460 else if ( name == VCBirthDateProp ) {
445 // Reading Birthdate regarding RFC 2425 (5.8.4) 461 // Reading Birthdate regarding RFC 2425 (5.8.4)
446 c.setBirthday( convVCardDateToDate( value ) ); 462 c.setBirthday( convVCardDateToDate( value ) );
447 463
448 } 464 }
449 465 else if ( name == VCCommentProp ) {
466 c.setNotes( value );
467 }
450#if 0 468#if 0
451 else { 469 else {
452 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 470 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
453 VObjectIterator nit; 471 VObjectIterator nit;
454 initPropIterator( &nit, o ); 472 initPropIterator( &nit, o );
455 while( moreIteration( &nit ) ) { 473 while( moreIteration( &nit ) ) {
456 VObject *o = nextVObject( &nit ); 474 VObject *o = nextVObject( &nit );
457 QCString name = vObjectName( o ); 475 QCString name = vObjectName( o );
458 QString value = vObjectStringZValue( o ); 476 QString value = vObjectStringZValue( o );
459 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 477 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
460 } 478 }
461 } 479 }
462#endif 480#endif
463 } 481 }
464 c.setFileAs(); 482 c.setFileAs();
465 return c; 483 return c;
466} 484}
467 485
468 486
469VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 487VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
470{ 488{
471 VObject *vcard = newVObject( VCCardProp ); 489 VObject *vcard = newVObject( VCCardProp );
472 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 490 safeAddPropValue( vcard, VCVersionProp, "2.1" );
473 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 491 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
@@ -513,49 +531,49 @@ VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
513 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 531 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
514 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 532 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
515 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 533 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
516 534
517 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 535 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
518 safeAddProp( work_phone, VCWorkProp ); 536 safeAddProp( work_phone, VCWorkProp );
519 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 537 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
520 safeAddProp( work_phone, VCWorkProp ); 538 safeAddProp( work_phone, VCWorkProp );
521 safeAddProp( work_phone, VCCellularProp ); 539 safeAddProp( work_phone, VCCellularProp );
522 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 540 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
523 safeAddProp( work_phone, VCWorkProp ); 541 safeAddProp( work_phone, VCWorkProp );
524 safeAddProp( work_phone, VCFaxProp ); 542 safeAddProp( work_phone, VCFaxProp );
525 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 543 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
526 safeAddProp( work_phone, VCWorkProp ); 544 safeAddProp( work_phone, VCWorkProp );
527 safeAddProp( work_phone, VCPagerProp ); 545 safeAddProp( work_phone, VCPagerProp );
528 546
529 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 547 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
530 safeAddProp( url, VCWorkProp ); 548 safeAddProp( url, VCWorkProp );
531 549
532 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 550 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
533 safeAddProp( title, VCWorkProp ); 551 safeAddProp( title, VCWorkProp );
534 552
535 553
536 QStringList emails = c.emailList(); 554 QStringList emails = c.emailList();
537 emails.prepend( c.defaultEmail() ); 555 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
538 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 556 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
539 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 557 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
540 safeAddProp( email, VCInternetProp ); 558 safeAddProp( email, VCInternetProp );
541 } 559 }
542 560
543 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 561 safeAddPropValue( vcard, VCNoteProp, c.notes() );
544 562
545 // Exporting Birthday regarding RFC 2425 (5.8.4) 563 // Exporting Birthday regarding RFC 2425 (5.8.4)
546 if ( c.birthday().isValid() ){ 564 if ( c.birthday().isValid() ){
547 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 565 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
548 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 566 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
549 } 567 }
550 568
551 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 569 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
552 VObject *org = safeAddProp( vcard, VCOrgProp ); 570 VObject *org = safeAddProp( vcard, VCOrgProp );
553 safeAddPropValue( org, VCOrgNameProp, c.company() ); 571 safeAddPropValue( org, VCOrgNameProp, c.company() );
554 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 572 safeAddPropValue( org, VCOrgUnitProp, c.department() );
555 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 573 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
556 } 574 }
557 575
558 // some values we have to export as custom fields 576 // some values we have to export as custom fields
559 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 577 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
560 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 578 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
561 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 579 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 097142b..1c21619 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,43 +1,46 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
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 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * 13 *
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.7 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD
22 *
20 * Revision 1.6 2003/07/07 16:19:47 eilers 23 * Revision 1.6 2003/07/07 16:19:47 eilers
21 * Fixing serious bug in hasQuerySettings() 24 * Fixing serious bug in hasQuerySettings()
22 * 25 *
23 * Revision 1.5 2003/04/13 18:07:10 zecke 26 * Revision 1.5 2003/04/13 18:07:10 zecke
24 * More API doc 27 * More API doc
25 * QString -> const QString& 28 * QString -> const QString&
26 * QString = 0l -> QString::null 29 * QString = 0l -> QString::null
27 * 30 *
28 * Revision 1.4 2003/03/21 14:32:54 mickeyl 31 * Revision 1.4 2003/03/21 14:32:54 mickeyl
29 * g++ compliance fix: default arguments belong into the declaration, but not the definition 32 * g++ compliance fix: default arguments belong into the declaration, but not the definition
30 * 33 *
31 * Revision 1.3 2003/03/21 12:26:28 eilers 34 * Revision 1.3 2003/03/21 12:26:28 eilers
32 * Fixing small bug: If we search a birthday from today to today, it returned 35 * Fixing small bug: If we search a birthday from today to today, it returned
33 * every contact .. 36 * every contact ..
34 * 37 *
35 * Revision 1.2 2003/03/21 10:33:09 eilers 38 * Revision 1.2 2003/03/21 10:33:09 eilers
36 * Merged speed optimized xml backend for contacts to main. 39 * Merged speed optimized xml backend for contacts to main.
37 * Added QDateTime to querybyexample. For instance, it is now possible to get 40 * Added QDateTime to querybyexample. For instance, it is now possible to get
38 * all Birthdays/Anniversaries between two dates. This should be used 41 * all Birthdays/Anniversaries between two dates. This should be used
39 * to show all birthdays in the datebook.. 42 * to show all birthdays in the datebook..
40 * This change is sourcecode backward compatible but you have to upgrade 43 * This change is sourcecode backward compatible but you have to upgrade
41 * the binaries for today-addressbook. 44 * the binaries for today-addressbook.
42 * 45 *
43 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 46 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index 86ff298..3c02c42 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -47,27 +47,31 @@ public:
47 * you need to supply it with directNonRepeats. 47 * you need to supply it with directNonRepeats.
48 * This method can return empty lists if effectiveEvents is implememted 48 * This method can return empty lists if effectiveEvents is implememted
49 */ 49 */
50 virtual OEvent::ValueList directNonRepeats() = 0; 50 virtual OEvent::ValueList directNonRepeats() = 0;
51 51
52 /** 52 /**
53 * Same as above but return raw repeats! 53 * Same as above but return raw repeats!
54 */ 54 */
55 virtual OEvent::ValueList directRawRepeats() = 0; 55 virtual OEvent::ValueList directRawRepeats() = 0;
56 56
57 /* is implemented by default but you can reimplement it*/ 57 /* is implemented by default but you can reimplement it*/
58 /** 58 /**
59 * Effective Events are special event occuring during a time frame. This method does calcualte 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 60 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
61 * yourself 61 * yourself
62 */ 62 */
63 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to ); 63 virtual OEffectiveEvent::ValueList effecticeEvents( const QDate& from, const QDate& to );
64 64
65 /** 65 /**
66 * this is an overloaded member function 66 * this is an overloaded member function
67 * @see effecticeEvents 67 * @see effecticeEvents
68 */ 68 */
69 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start ); 69 virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
70 70
71private:
72 class Private;
73 Private *d;
74
71}; 75};
72 76
73#endif 77#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index ab2eea4..5ea945c 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -409,72 +409,72 @@ bool ODateBookAccessBackend_XML::loadFile() {
409 haveUtf = TRUE; 409 haveUtf = TRUE;
410 if ( dt[j] == '&' ) 410 if ( dt[j] == '&' )
411 haveEnt = TRUE; 411 haveEnt = TRUE;
412 ++j; 412 ++j;
413 } 413 }
414 if ( i == j ) { 414 if ( i == j ) {
415 // empty value 415 // empty value
416 i = j + 1; 416 i = j + 1;
417 continue; 417 continue;
418 } 418 }
419 419
420 QCString value( dt+i, j-i+1 ); 420 QCString value( dt+i, j-i+1 );
421 i = j + 1; 421 i = j + 1;
422 422
423 QString str = (haveUtf ? QString::fromUtf8( value ) 423 QString str = (haveUtf ? QString::fromUtf8( value )
424 : QString::fromLatin1( value ) ); 424 : QString::fromLatin1( value ) );
425 if ( haveEnt ) 425 if ( haveEnt )
426 str = Qtopia::plainString( str ); 426 str = Qtopia::plainString( str );
427 427
428 /* 428 /*
429 * add key + value 429 * add key + value
430 */ 430 */
431 find = dict[attr.data()]; 431 find = dict[attr.data()];
432 if (!find) 432 if (!find)
433 ev.setCustomField( attr, value ); 433 ev.setCustomField( attr, str );
434 else { 434 else {
435 setField( ev, *find, value ); 435 setField( ev, *find, str );
436 } 436 }
437 } 437 }
438 /* time to finalize */ 438 /* time to finalize */
439 finalizeRecord( ev ); 439 finalizeRecord( ev );
440 delete rec; 440 delete rec;
441 } 441 }
442 ::munmap(map_addr, attribute.st_size ); 442 ::munmap(map_addr, attribute.st_size );
443 m_changed = false; // changed during add 443 m_changed = false; // changed during add
444 444
445 return true; 445 return true;
446} 446}
447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { 447void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) {
448 /* AllDay is alway in UTC */ 448 /* AllDay is alway in UTC */
449 if ( ev.isAllDay() ) { 449 if ( ev.isAllDay() ) {
450 OTimeZone utc = OTimeZone::utc(); 450 OTimeZone utc = OTimeZone::utc();
451 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 451 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 452 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
453 ev.setTimeZone( "UTC"); // make sure it is really utc 453 ev.setTimeZone( "UTC"); // make sure it is really utc
454 }else { 454 }else {
455 /* to current date time */ 455 /* to current date time */
456 qWarning(" Start is %d", start ); 456 // qWarning(" Start is %d", start );
457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 457 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() );
458 QDateTime date = zone.toDateTime( start ); 458 QDateTime date = zone.toDateTime( start );
459 qWarning(" Start is %s", date.toString().latin1() ); 459 qWarning(" Start is %s", date.toString().latin1() );
460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 460 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) );
461 461
462 date = zone.toDateTime( end ); 462 date = zone.toDateTime( end );
463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 463 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) );
464 } 464 }
465 if ( rec && rec->doesRecur() ) { 465 if ( rec && rec->doesRecur() ) {
466 OTimeZone utc = OTimeZone::utc(); 466 OTimeZone utc = OTimeZone::utc();
467 ORecur recu( *rec ); // call copy c'tor; 467 ORecur recu( *rec ); // call copy c'tor;
468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 468 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 469 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
470 recu.setStart( ev.startDateTime().date() ); 470 recu.setStart( ev.startDateTime().date() );
471 ev.setRecurrence( recu ); 471 ev.setRecurrence( recu );
472 } 472 }
473 473
474 if (alarmTime != -1 ) { 474 if (alarmTime != -1 ) {
475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 475 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
476 OPimAlarm al( snd , dt ); 476 OPimAlarm al( snd , dt );
477 ev.notifiers().add( al ); 477 ev.notifiers().add( al );
478 } 478 }
479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 479 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
480 qWarning("already contains assign uid"); 480 qWarning("already contains assign uid");
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index f4bbe35..c3d91f7 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,33 +1,34 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10class OPimAccessBackendPrivate;
10/** 11/**
11 * OPimAccessBackend is the base class 12 * OPimAccessBackend is the base class
12 * for all private backends 13 * for all private backends
13 * it operates on OPimRecord as the base class 14 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 15 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 16 * the resource the implementation takes care
16 * of 17 * of
17 */ 18 */
18template <class T = OPimRecord> 19template <class T = OPimRecord>
19class OPimAccessBackend { 20class OPimAccessBackend {
20public: 21public:
21 typedef OTemplateBase<T> Frontend; 22 typedef OTemplateBase<T> Frontend;
22 23
23 /** The access hint from the frontend */ 24 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 25 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 26 virtual ~OPimAccessBackend();
26 27
27 /** 28 /**
28 * load the resource 29 * load the resource
29 */ 30 */
30 virtual bool load() = 0; 31 virtual bool load() = 0;
31 32
32 /** 33 /**
33 * reload the resource 34 * reload the resource
@@ -86,50 +87,49 @@ public:
86 */ 87 */
87 virtual bool replace( const T& t ) = 0; 88 virtual bool replace( const T& t ) = 0;
88 89
89 /* 90 /*
90 * setTheFrontEnd!!! 91 * setTheFrontEnd!!!
91 */ 92 */
92 void setFrontend( Frontend* front ); 93 void setFrontend( Frontend* front );
93 94
94 /** 95 /**
95 * set the read ahead count 96 * set the read ahead count
96 */ 97 */
97 void setReadAhead( uint count ); 98 void setReadAhead( uint count );
98protected: 99protected:
99 int access()const; 100 int access()const;
100 void cache( const T& t )const; 101 void cache( const T& t )const;
101 102
102 /** 103 /**
103 * use a prime number here! 104 * use a prime number here!
104 */ 105 */
105 void setSaneCacheSize( int ); 106 void setSaneCacheSize( int );
106 107
107 uint readAhead()const; 108 uint readAhead()const;
108 109
109private: 110private:
110 class Private; 111 OPimAccessBackendPrivate *d;
111 Private* d;
112 Frontend* m_front; 112 Frontend* m_front;
113 uint m_read; 113 uint m_read;
114 int m_acc; 114 int m_acc;
115 115
116}; 116};
117 117
118template <class T> 118template <class T>
119OPimAccessBackend<T>::OPimAccessBackend(int acc) 119OPimAccessBackend<T>::OPimAccessBackend(int acc)
120 : m_acc( acc ) 120 : m_acc( acc )
121{ 121{
122 m_front = 0l; 122 m_front = 0l;
123} 123}
124template <class T> 124template <class T>
125OPimAccessBackend<T>::~OPimAccessBackend() { 125OPimAccessBackend<T>::~OPimAccessBackend() {
126 126
127} 127}
128template <class T> 128template <class T>
129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
130 m_front = fr; 130 m_front = fr;
131} 131}
132template <class T> 132template <class T>
133void OPimAccessBackend<T>::cache( const T& t )const { 133void OPimAccessBackend<T>::cache( const T& t )const {
134 if (m_front ) 134 if (m_front )
135 m_front->cache( t ); 135 m_front->cache( t );
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 05e8ca9..6be95bc 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -1,24 +1,28 @@
1#ifndef OPIE_TODO_ACCESS_BACKEND_H 1#ifndef OPIE_TODO_ACCESS_BACKEND_H
2#define OPIE_TODO_ACCESS_BACKEND_H 2#define OPIE_TODO_ACCESS_BACKEND_H
3 3
4#include <qbitarray.h> 4#include <qbitarray.h>
5 5
6#include "otodo.h" 6#include "otodo.h"
7#include "opimaccessbackend.h" 7#include "opimaccessbackend.h"
8 8
9class OTodoAccessBackend : public OPimAccessBackend<OTodo> { 9class OTodoAccessBackend : public OPimAccessBackend<OTodo> {
10public: 10public:
11 OTodoAccessBackend(); 11 OTodoAccessBackend();
12 ~OTodoAccessBackend(); 12 ~OTodoAccessBackend();
13 virtual QArray<int> effectiveToDos( const QDate& start, 13 virtual QArray<int> effectiveToDos( const QDate& start,
14 const QDate& end, 14 const QDate& end,
15 bool includeNoDates ) = 0; 15 bool includeNoDates ) = 0;
16 virtual QArray<int> overDue() = 0; 16 virtual QArray<int> overDue() = 0;
17 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 17 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
18 int cat ) = 0; 18 int cat ) = 0;
19 virtual void removeAllCompleted() = 0; 19 virtual void removeAllCompleted() = 0;
20 virtual QBitArray supports()const = 0; 20 virtual QBitArray supports()const = 0;
21 21
22private:
23 class Private;
24 Private *d;
25
22}; 26};
23 27
24#endif 28#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 3577e14..6415952 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,47 +1,55 @@
1#include <qfile.h> 1#include <qfile.h>
2 2
3#include <qtopia/private/vobject_p.h> 3#include <qtopia/private/vobject_p.h>
4#include <qtopia/timeconversion.h> 4#include <qtopia/timeconversion.h>
5#include <qtopia/private/qfiledirect_p.h> 5#include <qtopia/private/qfiledirect_p.h>
6 6
7#include "otodoaccessvcal.h" 7#include "otodoaccessvcal.h"
8 8
9namespace { 9namespace {
10 static OTodo eventByVObj( VObject *obj ){ 10 static OTodo eventByVObj( VObject *obj ){
11 OTodo event; 11 OTodo event;
12 VObject *ob; 12 VObject *ob;
13 QCString name; 13 QCString name;
14 // no uid, attendees, ... and no fun 14 // no uid, attendees, ... and no fun
15 // description 15 // description
16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 16 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
17 name = vObjectStringZValue( ob ); 17 name = vObjectStringZValue( ob );
18#if 0
18 event.setDescription( name ); 19 event.setDescription( name );
20#else
21 event.setSummary( name );
22#endif
19 } 23 }
20 // summary 24 // summary
21 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 25 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
22 name = vObjectStringZValue( ob ); 26 name = vObjectStringZValue( ob );
27#if 0
23 event.setSummary( name ); 28 event.setSummary( name );
29#else
30 event.setDescription( name );
31#endif
24 } 32 }
25 // completed 33 // completed
26 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 34 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
27 name = vObjectStringZValue( ob ); 35 name = vObjectStringZValue( ob );
28 if( name == "COMPLETED" ){ 36 if( name == "COMPLETED" ){
29 event.setCompleted( true ); 37 event.setCompleted( true );
30 }else{ 38 }else{
31 event.setCompleted( false ); 39 event.setCompleted( false );
32 } 40 }
33 }else 41 }else
34 event.setCompleted( false ); 42 event.setCompleted( false );
35 // priority 43 // priority
36 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 44 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
37 name = vObjectStringZValue( ob ); 45 name = vObjectStringZValue( ob );
38 bool ok; 46 bool ok;
39 event.setPriority(name.toInt(&ok) ); 47 event.setPriority(name.toInt(&ok) );
40 } 48 }
41 //due date 49 //due date
42 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 50 if((ob = isAPropertyOf(obj, VCDueProp)) ){
43 event.setHasDueDate( true ); 51 event.setHasDueDate( true );
44 name = vObjectStringZValue( ob ); 52 name = vObjectStringZValue( ob );
45 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 53 event.setDueDate( TimeConversion::fromISO8601( name).date() );
46 } 54 }
47 // categories 55 // categories
@@ -53,53 +61,69 @@ namespace {
53 event.setUid( 1 ); 61 event.setUid( 1 );
54 return event; 62 return event;
55 }; 63 };
56 static VObject *vobjByEvent( const OTodo &event ) { 64 static VObject *vobjByEvent( const OTodo &event ) {
57 VObject *task = newVObject( VCTodoProp ); 65 VObject *task = newVObject( VCTodoProp );
58 if( task == 0 ) 66 if( task == 0 )
59 return 0l; 67 return 0l;
60 68
61 if( event.hasDueDate() ) { 69 if( event.hasDueDate() ) {
62 QTime time(0, 0, 0); 70 QTime time(0, 0, 0);
63 QDateTime date(event.dueDate(), time ); 71 QDateTime date(event.dueDate(), time );
64 addPropValue( task, VCDueProp, 72 addPropValue( task, VCDueProp,
65 TimeConversion::toISO8601( date ) ); 73 TimeConversion::toISO8601( date ) );
66 } 74 }
67 75
68 if( event.isCompleted() ) 76 if( event.isCompleted() )
69 addPropValue( task, VCStatusProp, "COMPLETED"); 77 addPropValue( task, VCStatusProp, "COMPLETED");
70 78
71 QString string = QString::number(event.priority() ); 79 QString string = QString::number(event.priority() );
72 addPropValue( task, VCPriorityProp, string.local8Bit() ); 80 addPropValue( task, VCPriorityProp, string.local8Bit() );
73 81
74 addPropValue( task, VCCategoriesProp, 82 addPropValue( task, VCCategoriesProp,
75 event.idsToString( event.categories() ).local8Bit() ); 83 event.idsToString( event.categories() ).local8Bit() );
76 84
85#if 0
86
87 // There seems a misrepresentation between summary in otodoevent
88 // and summary in vcard.
89 // The same with description..
90 // Description is summary and vice versa.. Argh.. (eilers)
91
92
77 addPropValue( task, VCDescriptionProp, 93 addPropValue( task, VCDescriptionProp,
78 event.description().local8Bit() ); 94 event.description().local8Bit() );
79 95
80 addPropValue( task, VCSummaryProp, 96 addPropValue( task, VCSummaryProp,
81 event.summary().local8Bit() ); 97 event.summary().local8Bit() );
98
99#else
100 addPropValue( task, VCDescriptionProp,
101 event.summary().local8Bit() );
102
103 addPropValue( task, VCSummaryProp,
104 event.description().local8Bit() );
105#endif
82 return task; 106 return task;
83}; 107};
84} 108}
85 109
86OTodoAccessVCal::OTodoAccessVCal( const QString& path ) 110OTodoAccessVCal::OTodoAccessVCal( const QString& path )
87 : m_dirty(false), m_file( path ) 111 : m_dirty(false), m_file( path )
88{ 112{
89} 113}
90OTodoAccessVCal::~OTodoAccessVCal() { 114OTodoAccessVCal::~OTodoAccessVCal() {
91} 115}
92bool OTodoAccessVCal::load() { 116bool OTodoAccessVCal::load() {
93 m_map.clear(); 117 m_map.clear();
94 m_dirty = false; 118 m_dirty = false;
95 119
96 VObject* vcal = 0l; 120 VObject* vcal = 0l;
97 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 121 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
98 if (!vcal ) 122 if (!vcal )
99 return false; 123 return false;
100 124
101 // Iterate over the list 125 // Iterate over the list
102 VObjectIterator it; 126 VObjectIterator it;
103 VObject* vobj; 127 VObject* vobj;
104 128
105 initPropIterator(&it, vcal); 129 initPropIterator(&it, vcal);
@@ -164,49 +188,49 @@ void OTodoAccessVCal::removeAllCompleted() {
164 } 188 }
165} 189}
166bool OTodoAccessVCal::replace( const OTodo& to ) { 190bool OTodoAccessVCal::replace( const OTodo& to ) {
167 m_map.replace( to.uid(), to ); 191 m_map.replace( to.uid(), to );
168 m_dirty = true; 192 m_dirty = true;
169 return true; 193 return true;
170} 194}
171OTodo OTodoAccessVCal::find(int uid )const { 195OTodo OTodoAccessVCal::find(int uid )const {
172 return m_map[uid]; 196 return m_map[uid];
173} 197}
174QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 198QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) {
175 QArray<int> ar(0); 199 QArray<int> ar(0);
176 return ar; 200 return ar;
177} 201}
178QArray<int> OTodoAccessVCal::allRecords()const { 202QArray<int> OTodoAccessVCal::allRecords()const {
179 QArray<int> ar( m_map.count() ); 203 QArray<int> ar( m_map.count() );
180 QMap<int, OTodo>::ConstIterator it; 204 QMap<int, OTodo>::ConstIterator it;
181 int i = 0; 205 int i = 0;
182 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 206 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
183 ar[i] = it.key(); 207 ar[i] = it.key();
184 i++; 208 i++;
185 } 209 }
186 return ar; 210 return ar;
187} 211}
188QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp &r)const { 212QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const {
189 QArray<int> ar(0); 213 QArray<int> ar(0);
190 return ar; 214 return ar;
191} 215}
192QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 216QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) {
193 QArray<int> ar(0); 217 QArray<int> ar(0);
194 return ar; 218 return ar;
195} 219}
196QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 220QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
197 const QDate& , 221 const QDate& ,
198 bool ) { 222 bool ) {
199 QArray<int> ar(0); 223 QArray<int> ar(0);
200 return ar; 224 return ar;
201} 225}
202QArray<int> OTodoAccessVCal::overDue() { 226QArray<int> OTodoAccessVCal::overDue() {
203 QArray<int> ar(0); 227 QArray<int> ar(0);
204 return ar; 228 return ar;
205} 229}
206QBitArray OTodoAccessVCal::supports()const { 230QBitArray OTodoAccessVCal::supports()const {
207 static QBitArray ar = sup(); 231 static QBitArray ar = sup();
208 232
209 return ar; 233 return ar;
210} 234}
211QBitArray OTodoAccessVCal::sup() { 235QBitArray OTodoAccessVCal::sup() {
212 QBitArray ar ( OTodo::CompletedDate +1 ); 236 QBitArray ar ( OTodo::CompletedDate +1 );
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 3d15354..f688735 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -66,49 +66,49 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
66} 66}
67} 67}
68 68
69 69
70OTodoAccessXML::OTodoAccessXML( const QString& appName, 70OTodoAccessXML::OTodoAccessXML( const QString& appName,
71 const QString& fileName ) 71 const QString& fileName )
72 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 72 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
73{ 73{
74 if (!fileName.isEmpty() ) 74 if (!fileName.isEmpty() )
75 m_file = fileName; 75 m_file = fileName;
76 else 76 else
77 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 77 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
78} 78}
79OTodoAccessXML::~OTodoAccessXML() { 79OTodoAccessXML::~OTodoAccessXML() {
80 80
81} 81}
82bool OTodoAccessXML::load() { 82bool OTodoAccessXML::load() {
83 rec = 0; 83 rec = 0;
84 m_opened = true; 84 m_opened = true;
85 m_changed = false; 85 m_changed = false;
86 /* initialize dict */ 86 /* initialize dict */
87 /* 87 /*
88 * UPDATE dict if you change anything!!! 88 * UPDATE dict if you change anything!!!
89 */ 89 */
90 QAsciiDict<int> dict(21); 90 QAsciiDict<int> dict(26);
91 dict.setAutoDelete( TRUE ); 91 dict.setAutoDelete( TRUE );
92 dict.insert("Categories" , new int(OTodo::Category) ); 92 dict.insert("Categories" , new int(OTodo::Category) );
93 dict.insert("Uid" , new int(OTodo::Uid) ); 93 dict.insert("Uid" , new int(OTodo::Uid) );
94 dict.insert("HasDate" , new int(OTodo::HasDate) ); 94 dict.insert("HasDate" , new int(OTodo::HasDate) );
95 dict.insert("Completed" , new int(OTodo::Completed) ); 95 dict.insert("Completed" , new int(OTodo::Completed) );
96 dict.insert("Description" , new int(OTodo::Description) ); 96 dict.insert("Description" , new int(OTodo::Description) );
97 dict.insert("Summary" , new int(OTodo::Summary) ); 97 dict.insert("Summary" , new int(OTodo::Summary) );
98 dict.insert("Priority" , new int(OTodo::Priority) ); 98 dict.insert("Priority" , new int(OTodo::Priority) );
99 dict.insert("DateDay" , new int(OTodo::DateDay) ); 99 dict.insert("DateDay" , new int(OTodo::DateDay) );
100 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 100 dict.insert("DateMonth" , new int(OTodo::DateMonth) );
101 dict.insert("DateYear" , new int(OTodo::DateYear) ); 101 dict.insert("DateYear" , new int(OTodo::DateYear) );
102 dict.insert("Progress" , new int(OTodo::Progress) ); 102 dict.insert("Progress" , new int(OTodo::Progress) );
103 dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); 103 dict.insert("CompletedDate", new int(OTodo::CompletedDate) );
104 dict.insert("StartDate", new int(OTodo::StartDate) ); 104 dict.insert("StartDate", new int(OTodo::StartDate) );
105 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 105 dict.insert("CrossReference", new int(OTodo::CrossReference) );
106 dict.insert("State", new int(OTodo::State) ); 106 dict.insert("State", new int(OTodo::State) );
107 dict.insert("Alarms", new int(OTodo::Alarms) ); 107 dict.insert("Alarms", new int(OTodo::Alarms) );
108 dict.insert("Reminders", new int(OTodo::Reminders) ); 108 dict.insert("Reminders", new int(OTodo::Reminders) );
109 dict.insert("Notifiers", new int(OTodo::Notifiers) ); 109 dict.insert("Notifiers", new int(OTodo::Notifiers) );
110 dict.insert("Maintainer", new int(OTodo::Maintainer) ); 110 dict.insert("Maintainer", new int(OTodo::Maintainer) );
111 dict.insert("rtype", new int(FRType) ); 111 dict.insert("rtype", new int(FRType) );
112 dict.insert("rweekdays", new int(FRWeekdays) ); 112 dict.insert("rweekdays", new int(FRWeekdays) );
113 dict.insert("rposition", new int(FRPosition) ); 113 dict.insert("rposition", new int(FRPosition) );
114 dict.insert("rfreq", new int(FRFreq) ); 114 dict.insert("rfreq", new int(FRFreq) );
@@ -815,52 +815,54 @@ QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder,
815 continue; 815 continue;
816 } 816 }
817 817
818 if ((*it).isCompleted() && comp ) { 818 if ((*it).isCompleted() && comp ) {
819 continue; 819 continue;
820 } 820 }
821 821
822 822
823 OTodoXMLContainer* con = new OTodoXMLContainer(); 823 OTodoXMLContainer* con = new OTodoXMLContainer();
824 con->todo = (*it); 824 con->todo = (*it);
825 vector.insert(item, con ); 825 vector.insert(item, con );
826 item++; 826 item++;
827 } 827 }
828 vector.resize( item ); 828 vector.resize( item );
829 /* sort it now */ 829 /* sort it now */
830 vector.sort(); 830 vector.sort();
831 /* now get the uids */ 831 /* now get the uids */
832 QArray<int> array( vector.count() ); 832 QArray<int> array( vector.count() );
833 for (uint i= 0; i < vector.count(); i++ ) { 833 for (uint i= 0; i < vector.count(); i++ ) {
834 array[i] = ( vector.at(i) )->todo.uid(); 834 array[i] = ( vector.at(i) )->todo.uid();
835 } 835 }
836 return array; 836 return array;
837}; 837};
838void OTodoAccessXML::removeAllCompleted() { 838void OTodoAccessXML::removeAllCompleted() {
839 QMap<int, OTodo> events = m_events;
839 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 840 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
840 if ( (*it).isCompleted() ) 841 if ( (*it).isCompleted() )
841 m_events.remove( it ); 842 events.remove( it.key() );
842 } 843 }
844 m_events = events;
843} 845}
844QBitArray OTodoAccessXML::supports()const { 846QBitArray OTodoAccessXML::supports()const {
845 static QBitArray ar = sup(); 847 static QBitArray ar = sup();
846 return ar; 848 return ar;
847} 849}
848QBitArray OTodoAccessXML::sup() { 850QBitArray OTodoAccessXML::sup() {
849 QBitArray ar( OTodo::CompletedDate +1 ); 851 QBitArray ar( OTodo::CompletedDate +1 );
850 ar.fill( true ); 852 ar.fill( true );
851 ar[OTodo::CrossReference] = false; 853 ar[OTodo::CrossReference] = false;
852 ar[OTodo::State ] = false; 854 ar[OTodo::State ] = false;
853 ar[OTodo::Reminders] = false; 855 ar[OTodo::Reminders] = false;
854 ar[OTodo::Notifiers] = false; 856 ar[OTodo::Notifiers] = false;
855 ar[OTodo::Maintainer] = false; 857 ar[OTodo::Maintainer] = false;
856 858
857 return ar; 859 return ar;
858} 860}
859QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const 861QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
860{ 862{
861 QArray<int> m_currentQuery( m_events.count() ); 863 QArray<int> m_currentQuery( m_events.count() );
862 uint arraycounter = 0; 864 uint arraycounter = 0;
863 865
864 QMap<int, OTodo>::ConstIterator it; 866 QMap<int, OTodo>::ConstIterator it;
865 for (it = m_events.begin(); it != m_events.end(); ++it ) { 867 for (it = m_events.begin(); it != m_events.end(); ++it ) {
866 if ( it.data().match( r ) ) 868 if ( it.data().match( r ) )