summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h10
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h12
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp136
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h22
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp52
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h22
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp158
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h26
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp18
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h8
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp64
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.h12
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp86
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h20
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h2
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.cpp6
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h8
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp164
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h22
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp70
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h16
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp228
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h24
-rw-r--r--libopie2/opiepim/core/core.pro16
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp36
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h20
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp2
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h4
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h6
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp (renamed from libopie2/opiepim/ocontact.cpp)264
-rw-r--r--libopie2/opiepim/core/opimcontact.h (renamed from libopie2/opiepim/ocontact.h)16
-rw-r--r--libopie2/opiepim/core/opimcontactfields.cpp (renamed from libopie2/opiepim/ocontactfields.cpp)48
-rw-r--r--libopie2/opiepim/core/opimcontactfields.h (renamed from libopie2/opiepim/ocontactfields.h)12
-rw-r--r--libopie2/opiepim/core/opimdateconversion.cpp (renamed from libopie2/opiepim/core/oconversion.cpp)10
-rw-r--r--libopie2/opiepim/core/opimdateconversion.h (renamed from libopie2/opiepim/core/oconversion.h)2
-rw-r--r--libopie2/opiepim/core/opimevent.cpp (renamed from libopie2/opiepim/oevent.cpp)250
-rw-r--r--libopie2/opiepim/core/opimevent.h (renamed from libopie2/opiepim/oevent.h)46
-rw-r--r--libopie2/opiepim/core/opimnotify.h2
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp8
-rw-r--r--libopie2/opiepim/core/opimrecordlist.h (renamed from libopie2/opiepim/orecordlist.h)90
-rw-r--r--libopie2/opiepim/core/opimrecurrence.cpp (renamed from libopie2/opiepim/core/orecur.cpp)160
-rw-r--r--libopie2/opiepim/core/opimrecurrence.h (renamed from libopie2/opiepim/core/orecur.h)20
-rw-r--r--libopie2/opiepim/core/opimresolver.cpp8
-rw-r--r--libopie2/opiepim/core/opimresolver.h2
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h (renamed from libopie2/opiepim/core/otemplatebase.h)0
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp (renamed from libopie2/opiepim/core/otimezone.cpp)36
-rw-r--r--libopie2/opiepim/core/opimtimezone.h (renamed from libopie2/opiepim/core/otimezone.h)12
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp (renamed from libopie2/opiepim/otodo.cpp)140
-rw-r--r--libopie2/opiepim/core/opimtodo.h (renamed from libopie2/opiepim/otodo.h)50
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp32
-rw-r--r--libopie2/opiepim/core/otodoaccess.h34
-rw-r--r--libopie2/opiepim/libopiepim2.control4
-rw-r--r--libopie2/opiepim/opiepim.pro17
53 files changed, 1266 insertions, 1267 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 346e2f5..06421d1 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -1,150 +1,150 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * ===================================================================== 30 * =====================================================================
31 * ToDo: Use plugins 31 * ToDo: Use plugins
32 * ===================================================================== 32 * =====================================================================
33 */ 33 */
34#ifndef OPIE_BACKENDFACTORY_H_ 34#ifndef OPIE_BACKENDFACTORY_H_
35#define OPIE_BACKENDFACTORY_H_ 35#define OPIE_BACKENDFACTORY_H_
36 36
37#include <qstring.h> 37#include <qstring.h>
38#include <qasciidict.h> 38#include <qasciidict.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41#include <opie2/otodoaccessxml.h> 41#include <opie2/otodoaccessxml.h>
42#include <opie2/ocontactaccessbackend_xml.h> 42#include <opie2/ocontactaccessbackend_xml.h>
43#include <opie2/odatebookaccessbackend_xml.h> 43#include <opie2/odatebookaccessbackend_xml.h>
44 44
45#ifdef __USE_SQL 45#ifdef __USE_SQL
46#include <opie2/otodoaccesssql.h> 46#include <opie2/otodoaccesssql.h>
47#include <opie2/ocontactaccessbackend_sql.h> 47#include <opie2/ocontactaccessbackend_sql.h>
48#include <opie2/odatebookaccessbackend_sql.h> 48#include <opie2/odatebookaccessbackend_sql.h>
49#endif 49#endif
50 50
51namespace Opie { 51namespace Opie {
52 52
53class OBackendPrivate; 53class OBackendPrivate;
54 54
55/** 55/**
56 * This class is our factory. It will give us the default implementations 56 * This class is our factory. It will give us the default implementations
57 * of at least Todolist, Contacts and Datebook. In the future this class will 57 * of at least Todolist, Contacts and Datebook. In the future this class will
58 * allow users to switch the backend with ( XML->SQLite ) without the need 58 * allow users to switch the backend with ( XML->SQLite ) without the need
59 * to recompile.# 59 * to recompile.#
60 * This class as the whole PIM Api is making use of templates 60 * This class as the whole PIM Api is making use of templates
61 * 61 *
62 * <pre> 62 * <pre>
63 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); 63 * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null );
64 * backend->load(); 64 * backend->load();
65 * </pre> 65 * </pre>
66 * 66 *
67 * @author Stefan Eilers 67 * @author Stefan Eilers
68 * @version 0.1 68 * @version 0.1
69 */ 69 */
70template<class T> 70template<class T>
71class OBackendFactory 71class OBackendFactory
72{ 72{
73 public: 73 public:
74 OBackendFactory() {}; 74 OBackendFactory() {};
75 75
76 enum BACKENDS { 76 enum BACKENDS {
77 TODO, 77 TODO,
78 CONTACT, 78 CONTACT,
79 DATE 79 DATE
80 }; 80 };
81 81
82 /** 82 /**
83 * Returns a backend implementation for backendName 83 * Returns a backend implementation for backendName
84 * @param backendName the type of the backend 84 * @param backendName the type of the backend
85 * @param appName will be passed on to the backend 85 * @param appName will be passed on to the backend
86 */ 86 */
87 static T* Default( const QString backendName, const QString& appName ){ 87 static T* Default( const QString backendName, const QString& appName ){
88 88
89 // __asm__("int3"); 89 // __asm__("int3");
90 90
91 Config config( "pimaccess" ); 91 Config config( "pimaccess" );
92 config.setGroup ( backendName ); 92 config.setGroup ( backendName );
93 QString backend = config.readEntry( "usebackend" ); 93 QString backend = config.readEntry( "usebackend" );
94 94
95 qWarning("Selected backend for %s is: %s", backendName.latin1(), backend.latin1() ); 95 qWarning("Selected backend for %s is: %s", backendName.latin1(), backend.latin1() );
96 96
97 QAsciiDict<int> dict ( 3 ); 97 QAsciiDict<int> dict ( 3 );
98 dict.setAutoDelete ( TRUE ); 98 dict.setAutoDelete ( TRUE );
99 99
100 dict.insert( "todo", new int (TODO) ); 100 dict.insert( "todo", new int (TODO) );
101 dict.insert( "contact", new int (CONTACT) ); 101 dict.insert( "contact", new int (CONTACT) );
102 dict.insert( "datebook", new int(DATE) ); 102 dict.insert( "datebook", new int(DATE) );
103 103
104 int *find = dict[ backendName ]; 104 int *find = dict[ backendName ];
105 if (!find ) return 0; 105 if (!find ) return 0;
106 106
107 switch ( *find ){ 107 switch ( *find ){
108 case TODO: 108 case TODO:
109#ifdef __USE_SQL 109#ifdef __USE_SQL
110 if ( backend == "sql" ) 110 if ( backend == "sql" )
111 return (T*) new OTodoAccessBackendSQL(""); 111 return (T*) new OPimTodoAccessBackendSQL("");
112#else 112#else
113 if ( backend == "sql" ) 113 if ( backend == "sql" )
114 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); 114 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!");
115#endif 115#endif
116 116
117 return (T*) new OTodoAccessXML( appName ); 117 return (T*) new OPimTodoAccessXML( appName );
118 case CONTACT: 118 case CONTACT:
119#ifdef __USE_SQL 119#ifdef __USE_SQL
120 if ( backend == "sql" ) 120 if ( backend == "sql" )
121 return (T*) new OContactAccessBackend_SQL(""); 121 return (T*) new OPimContactAccessBackend_SQL("");
122#else 122#else
123 if ( backend == "sql" ) 123 if ( backend == "sql" )
124 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); 124 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!");
125#endif 125#endif
126 126
127 return (T*) new OContactAccessBackend_XML( appName ); 127 return (T*) new OPimContactAccessBackend_XML( appName );
128 case DATE: 128 case DATE:
129#ifdef __USE_SQL 129#ifdef __USE_SQL
130 if ( backend == "sql" ) 130 if ( backend == "sql" )
131 return (T*) new ODateBookAccessBackend_SQL(""); 131 return (T*) new ODateBookAccessBackend_SQL("");
132#else 132#else
133 if ( backend == "sql" ) 133 if ( backend == "sql" )
134 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); 134 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!");
135#endif 135#endif
136 136
137 return (T*) new ODateBookAccessBackend_XML( appName ); 137 return (T*) new ODateBookAccessBackend_XML( appName );
138 default: 138 default:
139 return NULL; 139 return NULL;
140 } 140 }
141 141
142 142
143 } 143 }
144 private: 144 private:
145 OBackendPrivate* d; 145 OBackendPrivate* d;
146}; 146};
147 147
148} 148}
149 149
150#endif 150#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 6113cea..8436adc 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -1,114 +1,114 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/** 29/**
30 * The class responsible for managing a backend. 30 * The class responsible for managing a backend.
31 * The implementation of this abstract class contains 31 * The implementation of this abstract class contains
32 * the complete database handling. 32 * the complete database handling.
33 * 33 *
34 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 34 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
35 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 35 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
36 * 36 *
37 */ 37 */
38 38
39#ifndef _OCONTACTACCESSBACKEND_H_ 39#ifndef _OCONTACTACCESSBACKEND_H_
40#define _OCONTACTACCESSBACKEND_H_ 40#define _OCONTACTACCESSBACKEND_H_
41 41
42#include <opie2/ocontact.h> 42#include <opie2/opimcontact.h>
43#include <opie2/opimaccessbackend.h> 43#include <opie2/opimaccessbackend.h>
44 44
45#include <qregexp.h> 45#include <qregexp.h>
46 46
47namespace Opie { 47namespace Opie {
48/** 48/**
49 * This class represents the interface of all Contact Backends. 49 * This class represents the interface of all Contact Backends.
50 * Derivates of this class will be used to access the contacts. 50 * Derivates of this class will be used to access the contacts.
51 * As implementation currently XML and vCard exist. This class needs to be implemented 51 * As implementation currently XML and vCard exist. This class needs to be implemented
52 * if you want to provide your own storage. 52 * if you want to provide your own storage.
53 * In all queries a list of uids is passed on instead of loading the actual record! 53 * In all queries a list of uids is passed on instead of loading the actual record!
54 * 54 *
55 * @see OContactAccessBackend_VCard 55 * @see OPimContactAccessBackend_VCard
56 * @see OContactAccessBackend_XML 56 * @see OPimContactAccessBackend_XML
57 */ 57 */
58class OContactAccessBackend: public OPimAccessBackend<OContact> { 58class OPimContactAccessBackend: public OPimAccessBackend<OPimContact> {
59 public: 59 public:
60 /** 60 /**
61 * @todo make non line in regard to BC guide of KDE 61 * @todo make non line in regard to BC guide of KDE
62 */ 62 */
63 OContactAccessBackend() {} 63 OPimContactAccessBackend() {}
64 /** 64 /**
65 * @todo make non inline in regard to the BC guide of KDE 65 * @todo make non inline in regard to the BC guide of KDE
66 */ 66 */
67 virtual ~OContactAccessBackend() {} 67 virtual ~OPimContactAccessBackend() {}
68 68
69 69
70 /** 70 /**
71 * Return if database was changed externally. 71 * Return if database was changed externally.
72 * 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.
73 * It is used to prevent to overwrite the current database content 73 * It is used to prevent to overwrite the current database content
74 * if the file was already changed by something else ! 74 * if the file was already changed by something else !
75 * If this happens, we have to reload before save our data. 75 * If this happens, we have to reload before save our data.
76 * 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
77 * management system themselve, therefore this function should always return false in 77 * management system themselve, therefore this function should always return false in
78 * this case. It is not our problem to handle this conflict ... 78 * this case. It is not our problem to handle this conflict ...
79 * @return <i>true</i> if the database was changed and if save without reload will 79 * @return <i>true</i> if the database was changed and if save without reload will
80 * be dangerous. <i>false</i> if the database was not changed or it is save to write 80 * be dangerous. <i>false</i> if the database was not changed or it is save to write
81 * in this situation. 81 * in this situation.
82 */ 82 */
83 virtual bool wasChangedExternally() = 0; 83 virtual bool wasChangedExternally() = 0;
84 84
85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 85 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
86 86
87 /** 87 /**
88 * Return all possible settings. 88 * Return all possible settings.
89 * @return All settings provided by the current backend 89 * @return All settings provided by the current backend
90 * (i.e.: query_WildCards & query_IgnoreCase) 90 * (i.e.: query_WildCards & query_IgnoreCase)
91 */ 91 */
92 virtual const uint querySettings() = 0; 92 virtual const uint querySettings() = 0;
93 93
94 /** 94 /**
95 * Check whether settings are correct. 95 * Check whether settings are correct.
96 * @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.
97 */ 97 */
98 virtual bool hasQuerySettings (uint querySettings) const = 0; 98 virtual bool hasQuerySettings (uint querySettings) const = 0;
99 99
100 /** 100 /**
101 * FIXME!!! 101 * FIXME!!!
102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category 102 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
103 */ 103 */
104 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;
105 105
106 106
107private: 107private:
108 class Private; 108 class Private;
109 Private *d; 109 Private *d;
110}; 110};
111 111
112} 112}
113 113
114#endif 114#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index d0c8052..f121cc2 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -1,935 +1,935 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * SQL Backend for the OPIE-Contact Database. 30 * SQL Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include "ocontactaccessbackend_sql.h" 33#include "ocontactaccessbackend_sql.h"
34 34
35#include <qarray.h> 35#include <qarray.h>
36#include <qdatetime.h> 36#include <qdatetime.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39#include <qpe/global.h> 39#include <qpe/global.h>
40#include <qpe/recordfields.h> 40#include <qpe/recordfields.h>
41 41
42#include <opie2/ocontactfields.h> 42#include <opie2/opimcontactfields.h>
43#include <opie2/oconversion.h> 43#include <opie2/opimdateconversion.h>
44#include <opie2/osqldriver.h> 44#include <opie2/osqldriver.h>
45#include <opie2/osqlresult.h> 45#include <opie2/osqlresult.h>
46#include <opie2/osqlmanager.h> 46#include <opie2/osqlmanager.h>
47#include <opie2/osqlquery.h> 47#include <opie2/osqlquery.h>
48 48
49 49
50 50
51 51
52// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead 52// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
53// vertical like "uid, type, value". 53// vertical like "uid, type, value".
54// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! 54// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
55#define __STORE_HORIZONTAL_ 55#define __STORE_HORIZONTAL_
56 56
57// Distinct loading is not very fast. If I expect that every person has just 57// Distinct loading is not very fast. If I expect that every person has just
58// one (and always one) 'Last Name', I can request all uid's for existing lastnames, 58// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
59// which is faster.. 59// which is faster..
60// But this may not be true for all entries, like company contacts.. 60// But this may not be true for all entries, like company contacts..
61// The current AddressBook application handles this problem, but other may not.. (eilers) 61// The current AddressBook application handles this problem, but other may not.. (eilers)
62#define __USE_SUPERFAST_LOADQUERY 62#define __USE_SUPERFAST_LOADQUERY
63 63
64 64
65/* 65/*
66 * Implementation of used query types 66 * Implementation of used query types
67 * CREATE query 67 * CREATE query
68 * LOAD query 68 * LOAD query
69 * INSERT 69 * INSERT
70 * REMOVE 70 * REMOVE
71 * CLEAR 71 * CLEAR
72 */ 72 */
73namespace Opie { 73namespace Opie {
74 /** 74 /**
75 * CreateQuery for the Todolist Table 75 * CreateQuery for the Todolist Table
76 */ 76 */
77 class CreateQuery : public OSQLQuery { 77 class CreateQuery : public OSQLQuery {
78 public: 78 public:
79 CreateQuery(); 79 CreateQuery();
80 ~CreateQuery(); 80 ~CreateQuery();
81 QString query()const; 81 QString query()const;
82 }; 82 };
83 83
84 /** 84 /**
85 * Clears (delete) a Table 85 * Clears (delete) a Table
86 */ 86 */
87 class ClearQuery : public OSQLQuery { 87 class ClearQuery : public OSQLQuery {
88 public: 88 public:
89 ClearQuery(); 89 ClearQuery();
90 ~ClearQuery(); 90 ~ClearQuery();
91 QString query()const; 91 QString query()const;
92 92
93 }; 93 };
94 94
95 95
96 /** 96 /**
97 * LoadQuery 97 * LoadQuery
98 * this one queries for all uids 98 * this one queries for all uids
99 */ 99 */
100 class LoadQuery : public OSQLQuery { 100 class LoadQuery : public OSQLQuery {
101 public: 101 public:
102 LoadQuery(); 102 LoadQuery();
103 ~LoadQuery(); 103 ~LoadQuery();
104 QString query()const; 104 QString query()const;
105 }; 105 };
106 106
107 /** 107 /**
108 * inserts/adds a OContact to the table 108 * inserts/adds a OPimContact to the table
109 */ 109 */
110 class InsertQuery : public OSQLQuery { 110 class InsertQuery : public OSQLQuery {
111 public: 111 public:
112 InsertQuery(const OContact& ); 112 InsertQuery(const OPimContact& );
113 ~InsertQuery(); 113 ~InsertQuery();
114 QString query()const; 114 QString query()const;
115 private: 115 private:
116 OContact m_contact; 116 OPimContact m_contact;
117 }; 117 };
118 118
119 119
120 /** 120 /**
121 * removes one from the table 121 * removes one from the table
122 */ 122 */
123 class RemoveQuery : public OSQLQuery { 123 class RemoveQuery : public OSQLQuery {
124 public: 124 public:
125 RemoveQuery(int uid ); 125 RemoveQuery(int uid );
126 ~RemoveQuery(); 126 ~RemoveQuery();
127 QString query()const; 127 QString query()const;
128 private: 128 private:
129 int m_uid; 129 int m_uid;
130 }; 130 };
131 131
132 /** 132 /**
133 * a find query for noncustom elements 133 * a find query for noncustom elements
134 */ 134 */
135 class FindQuery : public OSQLQuery { 135 class FindQuery : public OSQLQuery {
136 public: 136 public:
137 FindQuery(int uid); 137 FindQuery(int uid);
138 FindQuery(const QArray<int>& ); 138 FindQuery(const QArray<int>& );
139 ~FindQuery(); 139 ~FindQuery();
140 QString query()const; 140 QString query()const;
141 private: 141 private:
142 QString single()const; 142 QString single()const;
143 QString multi()const; 143 QString multi()const;
144 QArray<int> m_uids; 144 QArray<int> m_uids;
145 int m_uid; 145 int m_uid;
146 }; 146 };
147 147
148 /** 148 /**
149 * a find query for custom elements 149 * a find query for custom elements
150 */ 150 */
151 class FindCustomQuery : public OSQLQuery { 151 class FindCustomQuery : public OSQLQuery {
152 public: 152 public:
153 FindCustomQuery(int uid); 153 FindCustomQuery(int uid);
154 FindCustomQuery(const QArray<int>& ); 154 FindCustomQuery(const QArray<int>& );
155 ~FindCustomQuery(); 155 ~FindCustomQuery();
156 QString query()const; 156 QString query()const;
157 private: 157 private:
158 QString single()const; 158 QString single()const;
159 QString multi()const; 159 QString multi()const;
160 QArray<int> m_uids; 160 QArray<int> m_uids;
161 int m_uid; 161 int m_uid;
162 }; 162 };
163 163
164 164
165 165
166 // We using three tables to store the information: 166 // We using three tables to store the information:
167 // 1. addressbook : It contains General information about the contact (non custom) 167 // 1. addressbook : It contains General information about the contact (non custom)
168 // 2. custom_data : Not official supported entries 168 // 2. custom_data : Not official supported entries
169 // All tables are connected by the uid of the contact. 169 // All tables are connected by the uid of the contact.
170 // Maybe I should add a table for meta-information ? 170 // Maybe I should add a table for meta-information ?
171 CreateQuery::CreateQuery() : OSQLQuery() {} 171 CreateQuery::CreateQuery() : OSQLQuery() {}
172 CreateQuery::~CreateQuery() {} 172 CreateQuery::~CreateQuery() {}
173 QString CreateQuery::query()const { 173 QString CreateQuery::query()const {
174 QString qu; 174 QString qu;
175#ifdef __STORE_HORIZONTAL_ 175#ifdef __STORE_HORIZONTAL_
176 176
177 qu += "create table addressbook( uid PRIMARY KEY "; 177 qu += "create table addressbook( uid PRIMARY KEY ";
178 178
179 QStringList fieldList = OContactFields::untrfields( false ); 179 QStringList fieldList = OPimContactFields::untrfields( false );
180 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 180 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
181 qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); 181 qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it );
182 } 182 }
183 qu += " );"; 183 qu += " );";
184 184
185 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 185 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
186 186
187#else 187#else
188 188
189 qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));"; 189 qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));";
190 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 190 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
191 // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );"; 191 // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );";
192 192
193#endif // __STORE_HORIZONTAL_ 193#endif // __STORE_HORIZONTAL_
194 return qu; 194 return qu;
195 } 195 }
196 196
197 ClearQuery::ClearQuery() 197 ClearQuery::ClearQuery()
198 : OSQLQuery() {} 198 : OSQLQuery() {}
199 ClearQuery::~ClearQuery() {} 199 ClearQuery::~ClearQuery() {}
200 QString ClearQuery::query()const { 200 QString ClearQuery::query()const {
201 QString qu = "drop table addressbook;"; 201 QString qu = "drop table addressbook;";
202 qu += "drop table custom_data;"; 202 qu += "drop table custom_data;";
203 // qu += "drop table dates;"; 203 // qu += "drop table dates;";
204 return qu; 204 return qu;
205 } 205 }
206 206
207 207
208 LoadQuery::LoadQuery() : OSQLQuery() {} 208 LoadQuery::LoadQuery() : OSQLQuery() {}
209 LoadQuery::~LoadQuery() {} 209 LoadQuery::~LoadQuery() {}
210 QString LoadQuery::query()const { 210 QString LoadQuery::query()const {
211 QString qu; 211 QString qu;
212#ifdef __STORE_HORIZONTAL_ 212#ifdef __STORE_HORIZONTAL_
213 qu += "select uid from addressbook"; 213 qu += "select uid from addressbook";
214#else 214#else
215# ifndef __USE_SUPERFAST_LOADQUERY 215# ifndef __USE_SUPERFAST_LOADQUERY
216 qu += "select distinct uid from addressbook"; 216 qu += "select distinct uid from addressbook";
217# else 217# else
218 qu += "select uid from addressbook where type = 'Last Name'"; 218 qu += "select uid from addressbook where type = 'Last Name'";
219# endif // __USE_SUPERFAST_LOADQUERY 219# endif // __USE_SUPERFAST_LOADQUERY
220#endif // __STORE_HORIZONTAL_ 220#endif // __STORE_HORIZONTAL_
221 221
222 return qu; 222 return qu;
223 } 223 }
224 224
225 225
226 InsertQuery::InsertQuery( const OContact& contact ) 226 InsertQuery::InsertQuery( const OPimContact& contact )
227 : OSQLQuery(), m_contact( contact ) { 227 : OSQLQuery(), m_contact( contact ) {
228 } 228 }
229 229
230 InsertQuery::~InsertQuery() { 230 InsertQuery::~InsertQuery() {
231 } 231 }
232 232
233 /* 233 /*
234 * converts from a OContact to a query 234 * converts from a OPimContact to a query
235 */ 235 */
236 QString InsertQuery::query()const{ 236 QString InsertQuery::query()const{
237 237
238#ifdef __STORE_HORIZONTAL_ 238#ifdef __STORE_HORIZONTAL_
239 QString qu; 239 QString qu;
240 qu += "insert into addressbook VALUES( " + 240 qu += "insert into addressbook VALUES( " +
241 QString::number( m_contact.uid() ); 241 QString::number( m_contact.uid() );
242 242
243 // Get all information out of the contact-class 243 // Get all information out of the contact-class
244 // Remember: The category is stored in contactMap, too ! 244 // Remember: The category is stored in contactMap, too !
245 QMap<int, QString> contactMap = m_contact.toMap(); 245 QMap<int, QString> contactMap = m_contact.toMap();
246 246
247 QStringList fieldList = OContactFields::untrfields( false ); 247 QStringList fieldList = OPimContactFields::untrfields( false );
248 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 248 QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
249 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 249 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
250 // Convert Column-String to Id and get value for this id.. 250 // Convert Column-String to Id and get value for this id..
251 // Hmmm.. Maybe not very cute solution.. 251 // Hmmm.. Maybe not very cute solution..
252 int id = translate[*it]; 252 int id = translate[*it];
253 switch ( id ){ 253 switch ( id ){
254 case Qtopia::Birthday:{ 254 case Qtopia::Birthday:{
255 // These entries should stored in a special format 255 // These entries should stored in a special format
256 // year-month-day 256 // year-month-day
257 QDate day = m_contact.birthday(); 257 QDate day = m_contact.birthday();
258 if ( day.isValid() ){ 258 if ( day.isValid() ){
259 qu += QString(",\"%1-%2-%3\"") 259 qu += QString(",\"%1-%2-%3\"")
260 .arg( day.year() ) 260 .arg( day.year() )
261 .arg( day.month() ) 261 .arg( day.month() )
262 .arg( day.day() ); 262 .arg( day.day() );
263 } else { 263 } else {
264 qu += ",\"\""; 264 qu += ",\"\"";
265 } 265 }
266 } 266 }
267 break; 267 break;
268 case Qtopia::Anniversary:{ 268 case Qtopia::Anniversary:{
269 // These entries should stored in a special format 269 // These entries should stored in a special format
270 // year-month-day 270 // year-month-day
271 QDate day = m_contact.anniversary(); 271 QDate day = m_contact.anniversary();
272 if ( day.isValid() ){ 272 if ( day.isValid() ){
273 qu += QString(",\"%1-%2-%3\"") 273 qu += QString(",\"%1-%2-%3\"")
274 .arg( day.year() ) 274 .arg( day.year() )
275 .arg( day.month() ) 275 .arg( day.month() )
276 .arg( day.day() ); 276 .arg( day.day() );
277 } else { 277 } else {
278 qu += ",\"\""; 278 qu += ",\"\"";
279 } 279 }
280 } 280 }
281 break; 281 break;
282 282
283 default: 283 default:
284 qu += QString( ",\"%1\"" ).arg( contactMap[id] ); 284 qu += QString( ",\"%1\"" ).arg( contactMap[id] );
285 } 285 }
286 } 286 }
287 qu += " );"; 287 qu += " );";
288 288
289 289
290#else 290#else
291 // Get all information out of the contact-class 291 // Get all information out of the contact-class
292 // Remember: The category is stored in contactMap, too ! 292 // Remember: The category is stored in contactMap, too !
293 QMap<int, QString> contactMap = m_contact.toMap(); 293 QMap<int, QString> contactMap = m_contact.toMap();
294 294
295 QMap<QString, QString> addressbook_db; 295 QMap<QString, QString> addressbook_db;
296 296
297 // Get the translation from the ID to the String 297 // Get the translation from the ID to the String
298 QMap<int, QString> transMap = OContactFields::idToUntrFields(); 298 QMap<int, QString> transMap = OPimContactFields::idToUntrFields();
299 299
300 for( QMap<int, QString>::Iterator it = contactMap.begin(); 300 for( QMap<int, QString>::Iterator it = contactMap.begin();
301 it != contactMap.end(); ++it ){ 301 it != contactMap.end(); ++it ){
302 switch ( it.key() ){ 302 switch ( it.key() ){
303 case Qtopia::Birthday:{ 303 case Qtopia::Birthday:{
304 // These entries should stored in a special format 304 // These entries should stored in a special format
305 // year-month-day 305 // year-month-day
306 QDate day = m_contact.birthday(); 306 QDate day = m_contact.birthday();
307 addressbook_db.insert( transMap[it.key()], 307 addressbook_db.insert( transMap[it.key()],
308 QString("%1-%2-%3") 308 QString("%1-%2-%3")
309 .arg( day.year() ) 309 .arg( day.year() )
310 .arg( day.month() ) 310 .arg( day.month() )
311 .arg( day.day() ) ); 311 .arg( day.day() ) );
312 } 312 }
313 break; 313 break;
314 case Qtopia::Anniversary:{ 314 case Qtopia::Anniversary:{
315 // These entries should stored in a special format 315 // These entries should stored in a special format
316 // year-month-day 316 // year-month-day
317 QDate day = m_contact.anniversary(); 317 QDate day = m_contact.anniversary();
318 addressbook_db.insert( transMap[it.key()], 318 addressbook_db.insert( transMap[it.key()],
319 QString("%1-%2-%3") 319 QString("%1-%2-%3")
320 .arg( day.year() ) 320 .arg( day.year() )
321 .arg( day.month() ) 321 .arg( day.month() )
322 .arg( day.day() ) ); 322 .arg( day.day() ) );
323 } 323 }
324 break; 324 break;
325 case Qtopia::AddressUid: // Ignore UID 325 case Qtopia::AddressUid: // Ignore UID
326 break; 326 break;
327 default: // Translate id to String 327 default: // Translate id to String
328 addressbook_db.insert( transMap[it.key()], it.data() ); 328 addressbook_db.insert( transMap[it.key()], it.data() );
329 break; 329 break;
330 } 330 }
331 331
332 } 332 }
333 333
334 // Now convert this whole stuff into a SQL String, beginning with 334 // Now convert this whole stuff into a SQL String, beginning with
335 // the addressbook table.. 335 // the addressbook table..
336 QString qu; 336 QString qu;
337 // qu += "begin transaction;"; 337 // qu += "begin transaction;";
338 int id = 0; 338 int id = 0;
339 for( QMap<QString, QString>::Iterator it = addressbook_db.begin(); 339 for( QMap<QString, QString>::Iterator it = addressbook_db.begin();
340 it != addressbook_db.end(); ++it ){ 340 it != addressbook_db.end(); ++it ){
341 qu += "insert into addressbook VALUES(" 341 qu += "insert into addressbook VALUES("
342 + QString::number( m_contact.uid() ) 342 + QString::number( m_contact.uid() )
343 + "," 343 + ","
344 + QString::number( id++ ) 344 + QString::number( id++ )
345 + ",'" 345 + ",'"
346 + it.key() //.latin1() 346 + it.key() //.latin1()
347 + "'," 347 + "',"
348 + "0" // Priority for future enhancements 348 + "0" // Priority for future enhancements
349 + ",'" 349 + ",'"
350 + it.data() //.latin1() 350 + it.data() //.latin1()
351 + "');"; 351 + "');";
352 } 352 }
353 353
354 #endif //__STORE_HORIZONTAL_ 354 #endif //__STORE_HORIZONTAL_
355 // Now add custom data.. 355 // Now add custom data..
356#ifdef __STORE_HORIZONTAL_ 356#ifdef __STORE_HORIZONTAL_
357 int id = 0; 357 int id = 0;
358#endif 358#endif
359 id = 0; 359 id = 0;
360 QMap<QString, QString> customMap = m_contact.toExtraMap(); 360 QMap<QString, QString> customMap = m_contact.toExtraMap();
361 for( QMap<QString, QString>::Iterator it = customMap.begin(); 361 for( QMap<QString, QString>::Iterator it = customMap.begin();
362 it != customMap.end(); ++it ){ 362 it != customMap.end(); ++it ){
363 qu += "insert into custom_data VALUES(" 363 qu += "insert into custom_data VALUES("
364 + QString::number( m_contact.uid() ) 364 + QString::number( m_contact.uid() )
365 + "," 365 + ","
366 + QString::number( id++ ) 366 + QString::number( id++ )
367 + ",'" 367 + ",'"
368 + it.key() //.latin1() 368 + it.key() //.latin1()
369 + "'," 369 + "',"
370 + "0" // Priority for future enhancements 370 + "0" // Priority for future enhancements
371 + ",'" 371 + ",'"
372 + it.data() //.latin1() 372 + it.data() //.latin1()
373 + "');"; 373 + "');";
374 } 374 }
375 // qu += "commit;"; 375 // qu += "commit;";
376 qWarning("add %s", qu.latin1() ); 376 qWarning("add %s", qu.latin1() );
377 return qu; 377 return qu;
378 } 378 }
379 379
380 380
381 RemoveQuery::RemoveQuery(int uid ) 381 RemoveQuery::RemoveQuery(int uid )
382 : OSQLQuery(), m_uid( uid ) {} 382 : OSQLQuery(), m_uid( uid ) {}
383 RemoveQuery::~RemoveQuery() {} 383 RemoveQuery::~RemoveQuery() {}
384 QString RemoveQuery::query()const { 384 QString RemoveQuery::query()const {
385 QString qu = "DELETE from addressbook where uid = " 385 QString qu = "DELETE from addressbook where uid = "
386 + QString::number(m_uid) + ";"; 386 + QString::number(m_uid) + ";";
387 qu += "DELETE from custom_data where uid = " 387 qu += "DELETE from custom_data where uid = "
388 + QString::number(m_uid) + ";"; 388 + QString::number(m_uid) + ";";
389 return qu; 389 return qu;
390 } 390 }
391 391
392 392
393 393
394 394
395 FindQuery::FindQuery(int uid) 395 FindQuery::FindQuery(int uid)
396 : OSQLQuery(), m_uid( uid ) { 396 : OSQLQuery(), m_uid( uid ) {
397 } 397 }
398 FindQuery::FindQuery(const QArray<int>& ints) 398 FindQuery::FindQuery(const QArray<int>& ints)
399 : OSQLQuery(), m_uids( ints ){ 399 : OSQLQuery(), m_uids( ints ){
400 } 400 }
401 FindQuery::~FindQuery() { 401 FindQuery::~FindQuery() {
402 } 402 }
403 QString FindQuery::query()const{ 403 QString FindQuery::query()const{
404 // if ( m_uids.count() == 0 ) 404 // if ( m_uids.count() == 0 )
405 return single(); 405 return single();
406 } 406 }
407 /* 407 /*
408 else 408 else
409 return multi(); 409 return multi();
410 } 410 }
411 QString FindQuery::multi()const { 411 QString FindQuery::multi()const {
412 QString qu = "select uid, type, value from addressbook where"; 412 QString qu = "select uid, type, value from addressbook where";
413 for (uint i = 0; i < m_uids.count(); i++ ) { 413 for (uint i = 0; i < m_uids.count(); i++ ) {
414 qu += " UID = " + QString::number( m_uids[i] ) + " OR"; 414 qu += " UID = " + QString::number( m_uids[i] ) + " OR";
415 } 415 }
416 qu.remove( qu.length()-2, 2 ); // Hmmmm.. 416 qu.remove( qu.length()-2, 2 ); // Hmmmm..
417 return qu; 417 return qu;
418 } 418 }
419 */ 419 */
420#ifdef __STORE_HORIZONTAL_ 420#ifdef __STORE_HORIZONTAL_
421 QString FindQuery::single()const{ 421 QString FindQuery::single()const{
422 QString qu = "select *"; 422 QString qu = "select *";
423 qu += " from addressbook where uid = " + QString::number(m_uid); 423 qu += " from addressbook where uid = " + QString::number(m_uid);
424 424
425 // qWarning("find query: %s", qu.latin1() ); 425 // qWarning("find query: %s", qu.latin1() );
426 return qu; 426 return qu;
427 } 427 }
428#else 428#else
429 QString FindQuery::single()const{ 429 QString FindQuery::single()const{
430 QString qu = "select uid, type, value from addressbook where uid = "; 430 QString qu = "select uid, type, value from addressbook where uid = ";
431 qu += QString::number(m_uid); 431 qu += QString::number(m_uid);
432 return qu; 432 return qu;
433 } 433 }
434#endif 434#endif
435 435
436 436
437 FindCustomQuery::FindCustomQuery(int uid) 437 FindCustomQuery::FindCustomQuery(int uid)
438 : OSQLQuery(), m_uid( uid ) { 438 : OSQLQuery(), m_uid( uid ) {
439 } 439 }
440 FindCustomQuery::FindCustomQuery(const QArray<int>& ints) 440 FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
441 : OSQLQuery(), m_uids( ints ){ 441 : OSQLQuery(), m_uids( ints ){
442 } 442 }
443 FindCustomQuery::~FindCustomQuery() { 443 FindCustomQuery::~FindCustomQuery() {
444 } 444 }
445 QString FindCustomQuery::query()const{ 445 QString FindCustomQuery::query()const{
446 // if ( m_uids.count() == 0 ) 446 // if ( m_uids.count() == 0 )
447 return single(); 447 return single();
448 } 448 }
449 QString FindCustomQuery::single()const{ 449 QString FindCustomQuery::single()const{
450 QString qu = "select uid, type, value from custom_data where uid = "; 450 QString qu = "select uid, type, value from custom_data where uid = ";
451 qu += QString::number(m_uid); 451 qu += QString::number(m_uid);
452 return qu; 452 return qu;
453 } 453 }
454 454
455}; 455};
456 456
457 457
458/* --------------------------------------------------------------------------- */ 458/* --------------------------------------------------------------------------- */
459 459
460namespace Opie { 460namespace Opie {
461 461
462OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */, 462OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */,
463 const QString& filename ): 463 const QString& filename ):
464 OContactAccessBackend(), m_changed(false), m_driver( NULL ) 464 OPimContactAccessBackend(), m_changed(false), m_driver( NULL )
465{ 465{
466 qWarning("C'tor OContactAccessBackend_SQL starts"); 466 qWarning("C'tor OPimContactAccessBackend_SQL starts");
467 QTime t; 467 QTime t;
468 t.start(); 468 t.start();
469 469
470 /* Expecting to access the default filename if nothing else is set */ 470 /* Expecting to access the default filename if nothing else is set */
471 if ( filename.isEmpty() ){ 471 if ( filename.isEmpty() ){
472 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); 472 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
473 } else 473 } else
474 m_fileName = filename; 474 m_fileName = filename;
475 475
476 // Get the standart sql-driver from the OSQLManager.. 476 // Get the standart sql-driver from the OSQLManager..
477 OSQLManager man; 477 OSQLManager man;
478 m_driver = man.standard(); 478 m_driver = man.standard();
479 m_driver->setUrl( m_fileName ); 479 m_driver->setUrl( m_fileName );
480 480
481 load(); 481 load();
482 482
483 qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() ); 483 qWarning("C'tor OPimContactAccessBackend_SQL ends: %d ms", t.elapsed() );
484} 484}
485 485
486OContactAccessBackend_SQL::~OContactAccessBackend_SQL () 486OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL ()
487{ 487{
488 if( m_driver ) 488 if( m_driver )
489 delete m_driver; 489 delete m_driver;
490} 490}
491 491
492bool OContactAccessBackend_SQL::load () 492bool OPimContactAccessBackend_SQL::load ()
493{ 493{
494 if (!m_driver->open() ) 494 if (!m_driver->open() )
495 return false; 495 return false;
496 496
497 // Don't expect that the database exists. 497 // Don't expect that the database exists.
498 // It is save here to create the table, even if it 498 // It is save here to create the table, even if it
499 // do exist. ( Is that correct for all databases ?? ) 499 // do exist. ( Is that correct for all databases ?? )
500 CreateQuery creat; 500 CreateQuery creat;
501 OSQLResult res = m_driver->query( &creat ); 501 OSQLResult res = m_driver->query( &creat );
502 502
503 update(); 503 update();
504 504
505 return true; 505 return true;
506 506
507} 507}
508 508
509bool OContactAccessBackend_SQL::reload() 509bool OPimContactAccessBackend_SQL::reload()
510{ 510{
511 return load(); 511 return load();
512} 512}
513 513
514bool OContactAccessBackend_SQL::save() 514bool OPimContactAccessBackend_SQL::save()
515{ 515{
516 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 516 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
517} 517}
518 518
519 519
520void OContactAccessBackend_SQL::clear () 520void OPimContactAccessBackend_SQL::clear ()
521{ 521{
522 ClearQuery cle; 522 ClearQuery cle;
523 OSQLResult res = m_driver->query( &cle ); 523 OSQLResult res = m_driver->query( &cle );
524 524
525 reload(); 525 reload();
526} 526}
527 527
528bool OContactAccessBackend_SQL::wasChangedExternally() 528bool OPimContactAccessBackend_SQL::wasChangedExternally()
529{ 529{
530 return false; 530 return false;
531} 531}
532 532
533QArray<int> OContactAccessBackend_SQL::allRecords() const 533QArray<int> OPimContactAccessBackend_SQL::allRecords() const
534{ 534{
535 535
536 // FIXME: Think about cute handling of changed tables.. 536 // FIXME: Think about cute handling of changed tables..
537 // Thus, we don't have to call update here... 537 // Thus, we don't have to call update here...
538 if ( m_changed ) 538 if ( m_changed )
539 ((OContactAccessBackend_SQL*)this)->update(); 539 ((OPimContactAccessBackend_SQL*)this)->update();
540 540
541 return m_uids; 541 return m_uids;
542} 542}
543 543
544bool OContactAccessBackend_SQL::add ( const OContact &newcontact ) 544bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
545{ 545{
546 InsertQuery ins( newcontact ); 546 InsertQuery ins( newcontact );
547 OSQLResult res = m_driver->query( &ins ); 547 OSQLResult res = m_driver->query( &ins );
548 548
549 if ( res.state() == OSQLResult::Failure ) 549 if ( res.state() == OSQLResult::Failure )
550 return false; 550 return false;
551 551
552 int c = m_uids.count(); 552 int c = m_uids.count();
553 m_uids.resize( c+1 ); 553 m_uids.resize( c+1 );
554 m_uids[c] = newcontact.uid(); 554 m_uids[c] = newcontact.uid();
555 555
556 return true; 556 return true;
557} 557}
558 558
559 559
560bool OContactAccessBackend_SQL::remove ( int uid ) 560bool OPimContactAccessBackend_SQL::remove ( int uid )
561{ 561{
562 RemoveQuery rem( uid ); 562 RemoveQuery rem( uid );
563 OSQLResult res = m_driver->query(&rem ); 563 OSQLResult res = m_driver->query(&rem );
564 564
565 if ( res.state() == OSQLResult::Failure ) 565 if ( res.state() == OSQLResult::Failure )
566 return false; 566 return false;
567 567
568 m_changed = true; 568 m_changed = true;
569 569
570 return true; 570 return true;
571} 571}
572 572
573bool OContactAccessBackend_SQL::replace ( const OContact &contact ) 573bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact )
574{ 574{
575 if ( !remove( contact.uid() ) ) 575 if ( !remove( contact.uid() ) )
576 return false; 576 return false;
577 577
578 return add( contact ); 578 return add( contact );
579} 579}
580 580
581 581
582OContact OContactAccessBackend_SQL::find ( int uid ) const 582OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const
583{ 583{
584 qWarning("OContactAccessBackend_SQL::find()"); 584 qWarning("OPimContactAccessBackend_SQL::find()");
585 QTime t; 585 QTime t;
586 t.start(); 586 t.start();
587 587
588 OContact retContact( requestNonCustom( uid ) ); 588 OPimContact retContact( requestNonCustom( uid ) );
589 retContact.setExtraMap( requestCustom( uid ) ); 589 retContact.setExtraMap( requestCustom( uid ) );
590 590
591 qWarning("OContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() ); 591 qWarning("OPimContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() );
592 return retContact; 592 return retContact;
593} 593}
594 594
595 595
596 596
597QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ) 597QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() )
598{ 598{
599 QString qu = "SELECT uid FROM addressbook WHERE"; 599 QString qu = "SELECT uid FROM addressbook WHERE";
600 600
601 QMap<int, QString> queryFields = query.toMap(); 601 QMap<int, QString> queryFields = query.toMap();
602 QStringList fieldList = OContactFields::untrfields( false ); 602 QStringList fieldList = OPimContactFields::untrfields( false );
603 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 603 QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
604 604
605 // Convert every filled field to a SQL-Query 605 // Convert every filled field to a SQL-Query
606 bool isAnyFieldSelected = false; 606 bool isAnyFieldSelected = false;
607 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 607 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
608 int id = translate[*it]; 608 int id = translate[*it];
609 QString queryStr = queryFields[id]; 609 QString queryStr = queryFields[id];
610 if ( !queryStr.isEmpty() ){ 610 if ( !queryStr.isEmpty() ){
611 isAnyFieldSelected = true; 611 isAnyFieldSelected = true;
612 switch( id ){ 612 switch( id ){
613 default: 613 default:
614 // Switching between case sensitive and insensitive... 614 // Switching between case sensitive and insensitive...
615 // LIKE is not case sensitive, GLOB is case sensitive 615 // LIKE is not case sensitive, GLOB is case sensitive
616 // Do exist a better solution to switch this ? 616 // Do exist a better solution to switch this ?
617 if ( settings & OContactAccess::IgnoreCase ) 617 if ( settings & OPimContactAccess::IgnoreCase )
618 qu += "(\"" + *it + "\"" + " LIKE " + "'" 618 qu += "(\"" + *it + "\"" + " LIKE " + "'"
619 + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND "; 619 + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND ";
620 else 620 else
621 qu += "(\"" + *it + "\"" + " GLOB " + "'" 621 qu += "(\"" + *it + "\"" + " GLOB " + "'"
622 + queryStr + "'" + ") AND "; 622 + queryStr + "'" + ") AND ";
623 623
624 } 624 }
625 } 625 }
626 } 626 }
627 // Skip trailing "AND" 627 // Skip trailing "AND"
628 if ( isAnyFieldSelected ) 628 if ( isAnyFieldSelected )
629 qu = qu.left( qu.length() - 4 ); 629 qu = qu.left( qu.length() - 4 );
630 630
631 qWarning( "queryByExample query: %s", qu.latin1() ); 631 qWarning( "queryByExample query: %s", qu.latin1() );
632 632
633 // Execute query and return the received uid's 633 // Execute query and return the received uid's
634 OSQLRawQuery raw( qu ); 634 OSQLRawQuery raw( qu );
635 OSQLResult res = m_driver->query( &raw ); 635 OSQLResult res = m_driver->query( &raw );
636 if ( res.state() != OSQLResult::Success ){ 636 if ( res.state() != OSQLResult::Success ){
637 QArray<int> empty; 637 QArray<int> empty;
638 return empty; 638 return empty;
639 } 639 }
640 640
641 QArray<int> list = extractUids( res ); 641 QArray<int> list = extractUids( res );
642 642
643 return list; 643 return list;
644} 644}
645 645
646QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 646QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
647{ 647{
648 QArray<int> nix(0); 648 QArray<int> nix(0);
649 return nix; 649 return nix;
650} 650}
651 651
652const uint OContactAccessBackend_SQL::querySettings() 652const uint OPimContactAccessBackend_SQL::querySettings()
653{ 653{
654 return OContactAccess::IgnoreCase 654 return OPimContactAccess::IgnoreCase
655 || OContactAccess::WildCards; 655 || OPimContactAccess::WildCards;
656} 656}
657 657
658bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const 658bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
659{ 659{
660 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 660 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
661 * may be added with any of the other settings. IgnoreCase should never used alone. 661 * may be added with any of the other settings. IgnoreCase should never used alone.
662 * Wildcards, RegExp, ExactMatch should never used at the same time... 662 * Wildcards, RegExp, ExactMatch should never used at the same time...
663 */ 663 */
664 664
665 // Step 1: Check whether the given settings are supported by this backend 665 // Step 1: Check whether the given settings are supported by this backend
666 if ( ( querySettings & ( 666 if ( ( querySettings & (
667 OContactAccess::IgnoreCase 667 OPimContactAccess::IgnoreCase
668 | OContactAccess::WildCards 668 | OPimContactAccess::WildCards
669 // | OContactAccess::DateDiff 669 // | OPimContactAccess::DateDiff
670 // | OContactAccess::DateYear 670 // | OPimContactAccess::DateYear
671 // | OContactAccess::DateMonth 671 // | OPimContactAccess::DateMonth
672 // | OContactAccess::DateDay 672 // | OPimContactAccess::DateDay
673 // | OContactAccess::RegExp 673 // | OPimContactAccess::RegExp
674 // | OContactAccess::ExactMatch 674 // | OPimContactAccess::ExactMatch
675 ) ) != querySettings ) 675 ) ) != querySettings )
676 return false; 676 return false;
677 677
678 // Step 2: Check whether the given combinations are ok.. 678 // Step 2: Check whether the given combinations are ok..
679 679
680 // IngoreCase alone is invalid 680 // IngoreCase alone is invalid
681 if ( querySettings == OContactAccess::IgnoreCase ) 681 if ( querySettings == OPimContactAccess::IgnoreCase )
682 return false; 682 return false;
683 683
684 // WildCards, RegExp and ExactMatch should never used at the same time 684 // WildCards, RegExp and ExactMatch should never used at the same time
685 switch ( querySettings & ~( OContactAccess::IgnoreCase 685 switch ( querySettings & ~( OPimContactAccess::IgnoreCase
686 | OContactAccess::DateDiff 686 | OPimContactAccess::DateDiff
687 | OContactAccess::DateYear 687 | OPimContactAccess::DateYear
688 | OContactAccess::DateMonth 688 | OPimContactAccess::DateMonth
689 | OContactAccess::DateDay 689 | OPimContactAccess::DateDay
690 ) 690 )
691 ){ 691 ){
692 case OContactAccess::RegExp: 692 case OPimContactAccess::RegExp:
693 return ( true ); 693 return ( true );
694 case OContactAccess::WildCards: 694 case OPimContactAccess::WildCards:
695 return ( true ); 695 return ( true );
696 case OContactAccess::ExactMatch: 696 case OPimContactAccess::ExactMatch:
697 return ( true ); 697 return ( true );
698 case 0: // one of the upper removed bits were set.. 698 case 0: // one of the upper removed bits were set..
699 return ( true ); 699 return ( true );
700 default: 700 default:
701 return ( false ); 701 return ( false );
702 } 702 }
703 703
704} 704}
705 705
706QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int ) 706QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int )
707{ 707{
708 QTime t; 708 QTime t;
709 t.start(); 709 t.start();
710 710
711#ifdef __STORE_HORIZONTAL_ 711#ifdef __STORE_HORIZONTAL_
712 QString query = "SELECT uid FROM addressbook "; 712 QString query = "SELECT uid FROM addressbook ";
713 query += "ORDER BY \"Last Name\" "; 713 query += "ORDER BY \"Last Name\" ";
714#else 714#else
715 QString query = "SELECT uid FROM addressbook WHERE type = 'Last Name' "; 715 QString query = "SELECT uid FROM addressbook WHERE type = 'Last Name' ";
716 query += "ORDER BY upper( value )"; 716 query += "ORDER BY upper( value )";
717#endif 717#endif
718 718
719 if ( !asc ) 719 if ( !asc )
720 query += "DESC"; 720 query += "DESC";
721 721
722 // qWarning("sorted query is: %s", query.latin1() ); 722 // qWarning("sorted query is: %s", query.latin1() );
723 723
724 OSQLRawQuery raw( query ); 724 OSQLRawQuery raw( query );
725 OSQLResult res = m_driver->query( &raw ); 725 OSQLResult res = m_driver->query( &raw );
726 if ( res.state() != OSQLResult::Success ){ 726 if ( res.state() != OSQLResult::Success ){
727 QArray<int> empty; 727 QArray<int> empty;
728 return empty; 728 return empty;
729 } 729 }
730 730
731 QArray<int> list = extractUids( res ); 731 QArray<int> list = extractUids( res );
732 732
733 qWarning("sorted needed %d ms!", t.elapsed() ); 733 qWarning("sorted needed %d ms!", t.elapsed() );
734 return list; 734 return list;
735} 735}
736 736
737 737
738void OContactAccessBackend_SQL::update() 738void OPimContactAccessBackend_SQL::update()
739{ 739{
740 qWarning("Update starts"); 740 qWarning("Update starts");
741 QTime t; 741 QTime t;
742 t.start(); 742 t.start();
743 743
744 // Now load the database set and extract the uid's 744 // Now load the database set and extract the uid's
745 // which will be held locally 745 // which will be held locally
746 746
747 LoadQuery lo; 747 LoadQuery lo;
748 OSQLResult res = m_driver->query(&lo); 748 OSQLResult res = m_driver->query(&lo);
749 if ( res.state() != OSQLResult::Success ) 749 if ( res.state() != OSQLResult::Success )
750 return; 750 return;
751 751
752 m_uids = extractUids( res ); 752 m_uids = extractUids( res );
753 753
754 m_changed = false; 754 m_changed = false;
755 755
756 qWarning("Update ends %d ms", t.elapsed() ); 756 qWarning("Update ends %d ms", t.elapsed() );
757} 757}
758 758
759QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const 759QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
760{ 760{
761 qWarning("extractUids"); 761 qWarning("extractUids");
762 QTime t; 762 QTime t;
763 t.start(); 763 t.start();
764 OSQLResultItem::ValueList list = res.results(); 764 OSQLResultItem::ValueList list = res.results();
765 OSQLResultItem::ValueList::Iterator it; 765 OSQLResultItem::ValueList::Iterator it;
766 QArray<int> ints(list.count() ); 766 QArray<int> ints(list.count() );
767 qWarning(" count = %d", list.count() ); 767 qWarning(" count = %d", list.count() );
768 768
769 int i = 0; 769 int i = 0;
770 for (it = list.begin(); it != list.end(); ++it ) { 770 for (it = list.begin(); it != list.end(); ++it ) {
771 ints[i] = (*it).data("uid").toInt(); 771 ints[i] = (*it).data("uid").toInt();
772 i++; 772 i++;
773 } 773 }
774 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 774 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
775 775
776 return ints; 776 return ints;
777 777
778} 778}
779 779
780#ifdef __STORE_HORIZONTAL_ 780#ifdef __STORE_HORIZONTAL_
781QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const 781QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
782{ 782{
783 QTime t; 783 QTime t;
784 t.start(); 784 t.start();
785 785
786 QMap<int, QString> nonCustomMap; 786 QMap<int, QString> nonCustomMap;
787 787
788 int t2needed = 0; 788 int t2needed = 0;
789 int t3needed = 0; 789 int t3needed = 0;
790 QTime t2; 790 QTime t2;
791 t2.start(); 791 t2.start();
792 FindQuery query( uid ); 792 FindQuery query( uid );
793 OSQLResult res_noncustom = m_driver->query( &query ); 793 OSQLResult res_noncustom = m_driver->query( &query );
794 t2needed = t2.elapsed(); 794 t2needed = t2.elapsed();
795 795
796 OSQLResultItem resItem = res_noncustom.first(); 796 OSQLResultItem resItem = res_noncustom.first();
797 797
798 QTime t3; 798 QTime t3;
799 t3.start(); 799 t3.start();
800 // Now loop through all columns 800 // Now loop through all columns
801 QStringList fieldList = OContactFields::untrfields( false ); 801 QStringList fieldList = OPimContactFields::untrfields( false );
802 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 802 QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
803 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 803 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
804 // Get data for the selected column and store it with the 804 // Get data for the selected column and store it with the
805 // corresponding id into the map.. 805 // corresponding id into the map..
806 806
807 int id = translate[*it]; 807 int id = translate[*it];
808 QString value = resItem.data( (*it) ); 808 QString value = resItem.data( (*it) );
809 809
810 // qWarning("Reading %s... found: %s", (*it).latin1(), value.latin1() ); 810 // qWarning("Reading %s... found: %s", (*it).latin1(), value.latin1() );
811 811
812 switch( id ){ 812 switch( id ){
813 case Qtopia::Birthday: 813 case Qtopia::Birthday:
814 case Qtopia::Anniversary:{ 814 case Qtopia::Anniversary:{
815 // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) 815 // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
816 QStringList list = QStringList::split( '-', value ); 816 QStringList list = QStringList::split( '-', value );
817 QStringList::Iterator lit = list.begin(); 817 QStringList::Iterator lit = list.begin();
818 int year = (*lit).toInt(); 818 int year = (*lit).toInt();
819 int month = (*(++lit)).toInt(); 819 int month = (*(++lit)).toInt();
820 int day = (*(++lit)).toInt(); 820 int day = (*(++lit)).toInt();
821 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){ 821 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
822 QDate date( year, month, day ); 822 QDate date( year, month, day );
823 nonCustomMap.insert( id, OConversion::dateToString( date ) ); 823 nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) );
824 } 824 }
825 } 825 }
826 break; 826 break;
827 case Qtopia::AddressCategory: 827 case Qtopia::AddressCategory:
828 qWarning("Category is: %s", value.latin1() ); 828 qWarning("Category is: %s", value.latin1() );
829 default: 829 default:
830 nonCustomMap.insert( id, value ); 830 nonCustomMap.insert( id, value );
831 } 831 }
832 } 832 }
833 833
834 // First insert uid 834 // First insert uid
835 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) ); 835 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) );
836 t3needed = t3.elapsed(); 836 t3needed = t3.elapsed();
837 837
838 // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() ); 838 // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() );
839 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", 839 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms",
840 t.elapsed(), t2needed, t3needed ); 840 t.elapsed(), t2needed, t3needed );
841 841
842 return nonCustomMap; 842 return nonCustomMap;
843} 843}
844#else 844#else
845 845
846QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const 846QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
847{ 847{
848 QTime t; 848 QTime t;
849 t.start(); 849 t.start();
850 850
851 QMap<int, QString> nonCustomMap; 851 QMap<int, QString> nonCustomMap;
852 852
853 int t2needed = 0; 853 int t2needed = 0;
854 QTime t2; 854 QTime t2;
855 t2.start(); 855 t2.start();
856 FindQuery query( uid ); 856 FindQuery query( uid );
857 OSQLResult res_noncustom = m_driver->query( &query ); 857 OSQLResult res_noncustom = m_driver->query( &query );
858 t2needed = t2.elapsed(); 858 t2needed = t2.elapsed();
859 859
860 if ( res_noncustom.state() == OSQLResult::Failure ) { 860 if ( res_noncustom.state() == OSQLResult::Failure ) {
861 qWarning("OSQLResult::Failure in find query !!"); 861 qWarning("OSQLResult::Failure in find query !!");
862 QMap<int, QString> empty; 862 QMap<int, QString> empty;
863 return empty; 863 return empty;
864 } 864 }
865 865
866 int t3needed = 0; 866 int t3needed = 0;
867 QTime t3; 867 QTime t3;
868 t3.start(); 868 t3.start();
869 QMap<QString, int> translateMap = OContactFields::untrFieldsToId(); 869 QMap<QString, int> translateMap = OPimContactFields::untrFieldsToId();
870 870
871 OSQLResultItem::ValueList list = res_noncustom.results(); 871 OSQLResultItem::ValueList list = res_noncustom.results();
872 OSQLResultItem::ValueList::Iterator it = list.begin(); 872 OSQLResultItem::ValueList::Iterator it = list.begin();
873 for ( ; it != list.end(); ++it ) { 873 for ( ; it != list.end(); ++it ) {
874 if ( (*it).data("type") != "" ){ 874 if ( (*it).data("type") != "" ){
875 int typeId = translateMap[(*it).data( "type" )]; 875 int typeId = translateMap[(*it).data( "type" )];
876 switch( typeId ){ 876 switch( typeId ){
877 case Qtopia::Birthday: 877 case Qtopia::Birthday:
878 case Qtopia::Anniversary:{ 878 case Qtopia::Anniversary:{
879 // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) 879 // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
880 QStringList list = QStringList::split( '-', (*it).data( "value" ) ); 880 QStringList list = QStringList::split( '-', (*it).data( "value" ) );
881 QStringList::Iterator lit = list.begin(); 881 QStringList::Iterator lit = list.begin();
882 int year = (*lit).toInt(); 882 int year = (*lit).toInt();
883 qWarning("1. %s", (*lit).latin1()); 883 qWarning("1. %s", (*lit).latin1());
884 int month = (*(++lit)).toInt(); 884 int month = (*(++lit)).toInt();
885 qWarning("2. %s", (*lit).latin1()); 885 qWarning("2. %s", (*lit).latin1());
886 int day = (*(++lit)).toInt(); 886 int day = (*(++lit)).toInt();
887 qWarning("3. %s", (*lit).latin1()); 887 qWarning("3. %s", (*lit).latin1());
888 qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day ); 888 qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day );
889 QDate date( year, month, day ); 889 QDate date( year, month, day );
890 nonCustomMap.insert( typeId, OConversion::dateToString( date ) ); 890 nonCustomMap.insert( typeId, OPimDateConversion::dateToString( date ) );
891 } 891 }
892 break; 892 break;
893 default: 893 default:
894 nonCustomMap.insert( typeId, 894 nonCustomMap.insert( typeId,
895 (*it).data( "value" ) ); 895 (*it).data( "value" ) );
896 } 896 }
897 } 897 }
898 } 898 }
899 // Add UID to Map.. 899 // Add UID to Map..
900 nonCustomMap.insert( Qtopia::AddressUid, QString::number( uid ) ); 900 nonCustomMap.insert( Qtopia::AddressUid, QString::number( uid ) );
901 t3needed = t3.elapsed(); 901 t3needed = t3.elapsed();
902 902
903 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed ); 903 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed );
904 return nonCustomMap; 904 return nonCustomMap;
905} 905}
906 906
907#endif // __STORE_HORIZONTAL_ 907#endif // __STORE_HORIZONTAL_
908 908
909QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) const 909QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const
910{ 910{
911 QTime t; 911 QTime t;
912 t.start(); 912 t.start();
913 913
914 QMap<QString, QString> customMap; 914 QMap<QString, QString> customMap;
915 915
916 FindCustomQuery query( uid ); 916 FindCustomQuery query( uid );
917 OSQLResult res_custom = m_driver->query( &query ); 917 OSQLResult res_custom = m_driver->query( &query );
918 918
919 if ( res_custom.state() == OSQLResult::Failure ) { 919 if ( res_custom.state() == OSQLResult::Failure ) {
920 qWarning("OSQLResult::Failure in find query !!"); 920 qWarning("OSQLResult::Failure in find query !!");
921 QMap<QString, QString> empty; 921 QMap<QString, QString> empty;
922 return empty; 922 return empty;
923 } 923 }
924 924
925 OSQLResultItem::ValueList list = res_custom.results(); 925 OSQLResultItem::ValueList list = res_custom.results();
926 OSQLResultItem::ValueList::Iterator it = list.begin(); 926 OSQLResultItem::ValueList::Iterator it = list.begin();
927 for ( ; it != list.end(); ++it ) { 927 for ( ; it != list.end(); ++it ) {
928 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 928 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
929 } 929 }
930 930
931 qWarning("RequestCustom needed: %d ms", t.elapsed() ); 931 qWarning("RequestCustom needed: %d ms", t.elapsed() );
932 return customMap; 932 return customMap;
933} 933}
934 934
935} 935}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index 55b95fd..58ae2ae 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -1,109 +1,109 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * SQL Backend for the OPIE-Contact Database. 30 * SQL Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#ifndef _OContactAccessBackend_SQL_ 33#ifndef _OPimContactAccessBackend_SQL_
34#define _OContactAccessBackend_SQL_ 34#define _OPimContactAccessBackend_SQL_
35 35
36#include <opie2/ocontactaccessbackend.h> 36#include <opie2/ocontactaccessbackend.h>
37#include <opie2/ocontactaccess.h> 37#include <opie2/ocontactaccess.h>
38 38
39#include <qlist.h> 39#include <qlist.h>
40#include <qdict.h> 40#include <qdict.h>
41 41
42/* aren't in namespace Opie yet - alwin */ 42/* aren't in namespace Opie yet - alwin */
43class OSQLDriver; 43class OSQLDriver;
44class OSQLResult; 44class OSQLResult;
45class OSQLResultItem; 45class OSQLResultItem;
46 46
47namespace Opie { 47namespace Opie {
48 48
49/* the default xml implementation */ 49/* the default xml implementation */
50/** 50/**
51 * This class is the SQL implementation of a Contact backend 51 * This class is the SQL implementation of a Contact backend
52 * it does implement everything available for OContact. 52 * it does implement everything available for OPimContact.
53 * @see OPimAccessBackend for more information of available methods 53 * @see OPimAccessBackend for more information of available methods
54 */ 54 */
55class OContactAccessBackend_SQL : public OContactAccessBackend { 55class OPimContactAccessBackend_SQL : public OPimContactAccessBackend {
56 public: 56 public:
57 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 57 OPimContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
58 58
59 ~OContactAccessBackend_SQL (); 59 ~OPimContactAccessBackend_SQL ();
60 60
61 bool save(); 61 bool save();
62 62
63 bool load (); 63 bool load ();
64 64
65 void clear (); 65 void clear ();
66 66
67 bool wasChangedExternally(); 67 bool wasChangedExternally();
68 68
69 QArray<int> allRecords() const; 69 QArray<int> allRecords() const;
70 70
71 OContact find ( int uid ) const; 71 OPimContact find ( int uid ) const;
72 // FIXME: Add lookahead-cache support ! 72 // FIXME: Add lookahead-cache support !
73 //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 73 //OPimContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
74 74
75 QArray<int> queryByExample ( const OContact &query, int settings, 75 QArray<int> queryByExample ( const OPimContact &query, int settings,
76 const QDateTime& d ); 76 const QDateTime& d );
77 77
78 QArray<int> matchRegexp( const QRegExp &r ) const; 78 QArray<int> matchRegexp( const QRegExp &r ) const;
79 79
80 const uint querySettings(); 80 const uint querySettings();
81 81
82 bool hasQuerySettings (uint querySettings) const; 82 bool hasQuerySettings (uint querySettings) const;
83 83
84 // Currently only asc implemented.. 84 // Currently only asc implemented..
85 QArray<int> sorted( bool asc, int , int , int ); 85 QArray<int> sorted( bool asc, int , int , int );
86 bool add ( const OContact &newcontact ); 86 bool add ( const OPimContact &newcontact );
87 87
88 bool replace ( const OContact &contact ); 88 bool replace ( const OPimContact &contact );
89 89
90 bool remove ( int uid ); 90 bool remove ( int uid );
91 bool reload(); 91 bool reload();
92 92
93 private: 93 private:
94 QArray<int> extractUids( OSQLResult& res ) const; 94 QArray<int> extractUids( OSQLResult& res ) const;
95 QMap<int, QString> requestNonCustom( int uid ) const; 95 QMap<int, QString> requestNonCustom( int uid ) const;
96 QMap<QString, QString> requestCustom( int uid ) const; 96 QMap<QString, QString> requestCustom( int uid ) const;
97 void update(); 97 void update();
98 98
99 protected: 99 protected:
100 bool m_changed; 100 bool m_changed;
101 QString m_fileName; 101 QString m_fileName;
102 QArray<int> m_uids; 102 QArray<int> m_uids;
103 103
104 OSQLDriver* m_driver; 104 OSQLDriver* m_driver;
105}; 105};
106 106
107} 107}
108 108
109#endif 109#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index f85cf38..b569f8b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,591 +1,591 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * VCard Backend for the OPIE-Contact Database. 30 * VCard Backend for the OPIE-Contact Database.
31 */ 31 */
32#include <opie2/ocontactaccessbackend_vcard.h> 32#include <opie2/ocontactaccessbackend_vcard.h>
33#include "../../../../library/backend/vobject_p.h" 33#include "../../../../library/backend/vobject_p.h"
34#include "../../../../library/backend/qfiledirect_p.h" 34#include "../../../../library/backend/qfiledirect_p.h"
35 35
36#include <qpe/timeconversion.h> 36#include <qpe/timeconversion.h>
37 37
38#include <qfile.h> 38#include <qfile.h>
39 39
40namespace Opie { 40namespace Opie {
41 41
42OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): 42OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
43 m_dirty( false ), 43 m_dirty( false ),
44 m_file( filename ) 44 m_file( filename )
45{ 45{
46 load(); 46 load();
47} 47}
48 48
49 49
50bool OContactAccessBackend_VCard::load () 50bool OPimContactAccessBackend_VCard::load ()
51{ 51{
52 m_map.clear(); 52 m_map.clear();
53 m_dirty = false; 53 m_dirty = false;
54 54
55 VObject* obj = 0l; 55 VObject* obj = 0l;
56 56
57 if ( QFile::exists(m_file) ){ 57 if ( QFile::exists(m_file) ){
58 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 58 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
59 if ( !obj ) 59 if ( !obj )
60 return false; 60 return false;
61 }else{ 61 }else{
62 qWarning("File \"%s\" not found !", m_file.latin1() ); 62 qWarning("File \"%s\" not found !", m_file.latin1() );
63 return false; 63 return false;
64 } 64 }
65 65
66 while ( obj ) { 66 while ( obj ) {
67 OContact con = parseVObject( obj ); 67 OPimContact con = parseVObject( obj );
68 /* 68 /*
69 * if uid is 0 assign a new one 69 * if uid is 0 assign a new one
70 * this at least happens on 70 * this at least happens on
71 * Nokia6210 71 * Nokia6210
72 */ 72 */
73 if ( con.uid() == 0 ){ 73 if ( con.uid() == 0 ){
74 con.setUid( 1 ); 74 con.setUid( 1 );
75 qWarning("assigned new uid %d",con.uid() ); 75 qWarning("assigned new uid %d",con.uid() );
76 } 76 }
77 77
78 m_map.insert( con.uid(), con ); 78 m_map.insert( con.uid(), con );
79 79
80 VObject *t = obj; 80 VObject *t = obj;
81 obj = nextVObjectInList(obj); 81 obj = nextVObjectInList(obj);
82 cleanVObject( t ); 82 cleanVObject( t );
83 } 83 }
84 84
85 return true; 85 return true;
86 86
87} 87}
88bool OContactAccessBackend_VCard::reload() 88bool OPimContactAccessBackend_VCard::reload()
89{ 89{
90 return load(); 90 return load();
91} 91}
92bool OContactAccessBackend_VCard::save() 92bool OPimContactAccessBackend_VCard::save()
93{ 93{
94 if (!m_dirty ) 94 if (!m_dirty )
95 return true; 95 return true;
96 96
97 QFileDirect file( m_file ); 97 QFileDirect file( m_file );
98 if (!file.open(IO_WriteOnly ) ) 98 if (!file.open(IO_WriteOnly ) )
99 return false; 99 return false;
100 100
101 VObject *obj; 101 VObject *obj;
102 obj = newVObject( VCCalProp ); 102 obj = newVObject( VCCalProp );
103 addPropValue( obj, VCVersionProp, "1.0" ); 103 addPropValue( obj, VCVersionProp, "1.0" );
104 104
105 VObject *vo; 105 VObject *vo;
106 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 106 for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
107 vo = createVObject( *it ); 107 vo = createVObject( *it );
108 writeVObject( file.directHandle() , vo ); 108 writeVObject( file.directHandle() , vo );
109 cleanVObject( vo ); 109 cleanVObject( vo );
110 } 110 }
111 cleanStrTbl(); 111 cleanStrTbl();
112 deleteVObject( obj ); 112 deleteVObject( obj );
113 113
114 m_dirty = false; 114 m_dirty = false;
115 return true; 115 return true;
116 116
117 117
118} 118}
119void OContactAccessBackend_VCard::clear () 119void OPimContactAccessBackend_VCard::clear ()
120{ 120{
121 m_map.clear(); 121 m_map.clear();
122 m_dirty = true; // ??? sure ? (se) 122 m_dirty = true; // ??? sure ? (se)
123} 123}
124 124
125bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 125bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact )
126{ 126{
127 m_map.insert( newcontact.uid(), newcontact ); 127 m_map.insert( newcontact.uid(), newcontact );
128 m_dirty = true; 128 m_dirty = true;
129 return true; 129 return true;
130} 130}
131 131
132bool OContactAccessBackend_VCard::remove ( int uid ) 132bool OPimContactAccessBackend_VCard::remove ( int uid )
133{ 133{
134 m_map.remove( uid ); 134 m_map.remove( uid );
135 m_dirty = true; 135 m_dirty = true;
136 return true; 136 return true;
137} 137}
138 138
139bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 139bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact )
140{ 140{
141 m_map.replace( contact.uid(), contact ); 141 m_map.replace( contact.uid(), contact );
142 m_dirty = true; 142 m_dirty = true;
143 return true; 143 return true;
144} 144}
145 145
146OContact OContactAccessBackend_VCard::find ( int uid ) const 146OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const
147{ 147{
148 return m_map[uid]; 148 return m_map[uid];
149} 149}
150 150
151QArray<int> OContactAccessBackend_VCard::allRecords() const 151QArray<int> OPimContactAccessBackend_VCard::allRecords() const
152{ 152{
153 QArray<int> ar( m_map.count() ); 153 QArray<int> ar( m_map.count() );
154 QMap<int, OContact>::ConstIterator it; 154 QMap<int, OPimContact>::ConstIterator it;
155 int i = 0; 155 int i = 0;
156 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 156 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
157 ar[i] = it.key(); 157 ar[i] = it.key();
158 i++; 158 i++;
159 } 159 }
160 return ar; 160 return ar;
161} 161}
162 162
163// Not implemented 163// Not implemented
164QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) 164QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&, int, const QDateTime& )
165{ 165{
166 QArray<int> ar(0); 166 QArray<int> ar(0);
167 return ar; 167 return ar;
168} 168}
169 169
170// Not implemented 170// Not implemented
171QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 171QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
172{ 172{
173 QArray<int> ar(0); 173 QArray<int> ar(0);
174 return ar; 174 return ar;
175} 175}
176 176
177const uint OContactAccessBackend_VCard::querySettings() 177const uint OPimContactAccessBackend_VCard::querySettings()
178{ 178{
179 return 0; // No search possible 179 return 0; // No search possible
180} 180}
181 181
182bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 182bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const
183{ 183{
184 return false; // No search possible, therefore all settings invalid ;) 184 return false; // No search possible, therefore all settings invalid ;)
185} 185}
186 186
187bool OContactAccessBackend_VCard::wasChangedExternally() 187bool OPimContactAccessBackend_VCard::wasChangedExternally()
188{ 188{
189 return false; // Don't expect concurrent access 189 return false; // Don't expect concurrent access
190} 190}
191 191
192// Not implemented 192// Not implemented
193QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) 193QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int )
194{ 194{
195 QArray<int> ar(0); 195 QArray<int> ar(0);
196 return ar; 196 return ar;
197} 197}
198 198
199// *** Private stuff *** 199// *** Private stuff ***
200 200
201 201
202OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 202OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
203{ 203{
204 OContact c; 204 OPimContact c;
205 205
206 VObjectIterator it; 206 VObjectIterator it;
207 initPropIterator( &it, obj ); 207 initPropIterator( &it, obj );
208 while( moreIteration( &it ) ) { 208 while( moreIteration( &it ) ) {
209 VObject *o = nextVObject( &it ); 209 VObject *o = nextVObject( &it );
210 QCString name = vObjectName( o ); 210 QCString name = vObjectName( o );
211 QCString value = vObjectStringZValue( o ); 211 QCString value = vObjectStringZValue( o );
212 if ( name == VCNameProp ) { 212 if ( name == VCNameProp ) {
213 VObjectIterator nit; 213 VObjectIterator nit;
214 initPropIterator( &nit, o ); 214 initPropIterator( &nit, o );
215 while( moreIteration( &nit ) ) { 215 while( moreIteration( &nit ) ) {
216 VObject *o = nextVObject( &nit ); 216 VObject *o = nextVObject( &nit );
217 QCString name = vObjectTypeInfo( o ); 217 QCString name = vObjectTypeInfo( o );
218 QString value = vObjectStringZValue( o ); 218 QString value = vObjectStringZValue( o );
219 if ( name == VCNamePrefixesProp ) 219 if ( name == VCNamePrefixesProp )
220 c.setTitle( value ); 220 c.setTitle( value );
221 else if ( name == VCNameSuffixesProp ) 221 else if ( name == VCNameSuffixesProp )
222 c.setSuffix( value ); 222 c.setSuffix( value );
223 else if ( name == VCFamilyNameProp ) 223 else if ( name == VCFamilyNameProp )
224 c.setLastName( value ); 224 c.setLastName( value );
225 else if ( name == VCGivenNameProp ) 225 else if ( name == VCGivenNameProp )
226 c.setFirstName( value ); 226 c.setFirstName( value );
227 else if ( name == VCAdditionalNamesProp ) 227 else if ( name == VCAdditionalNamesProp )
228 c.setMiddleName( value ); 228 c.setMiddleName( value );
229 } 229 }
230 } 230 }
231 else if ( name == VCAdrProp ) { 231 else if ( name == VCAdrProp ) {
232 bool work = TRUE; // default address is work address 232 bool work = TRUE; // default address is work address
233 QString street; 233 QString street;
234 QString city; 234 QString city;
235 QString region; 235 QString region;
236 QString postal; 236 QString postal;
237 QString country; 237 QString country;
238 238
239 VObjectIterator nit; 239 VObjectIterator nit;
240 initPropIterator( &nit, o ); 240 initPropIterator( &nit, o );
241 while( moreIteration( &nit ) ) { 241 while( moreIteration( &nit ) ) {
242 VObject *o = nextVObject( &nit ); 242 VObject *o = nextVObject( &nit );
243 QCString name = vObjectName( o ); 243 QCString name = vObjectName( o );
244 QString value = vObjectStringZValue( o ); 244 QString value = vObjectStringZValue( o );
245 if ( name == VCHomeProp ) 245 if ( name == VCHomeProp )
246 work = FALSE; 246 work = FALSE;
247 else if ( name == VCWorkProp ) 247 else if ( name == VCWorkProp )
248 work = TRUE; 248 work = TRUE;
249 else if ( name == VCStreetAddressProp ) 249 else if ( name == VCStreetAddressProp )
250 street = value; 250 street = value;
251 else if ( name == VCCityProp ) 251 else if ( name == VCCityProp )
252 city = value; 252 city = value;
253 else if ( name == VCRegionProp ) 253 else if ( name == VCRegionProp )
254 region = value; 254 region = value;
255 else if ( name == VCPostalCodeProp ) 255 else if ( name == VCPostalCodeProp )
256 postal = value; 256 postal = value;
257 else if ( name == VCCountryNameProp ) 257 else if ( name == VCCountryNameProp )
258 country = value; 258 country = value;
259 } 259 }
260 if ( work ) { 260 if ( work ) {
261 c.setBusinessStreet( street ); 261 c.setBusinessStreet( street );
262 c.setBusinessCity( city ); 262 c.setBusinessCity( city );
263 c.setBusinessCountry( country ); 263 c.setBusinessCountry( country );
264 c.setBusinessZip( postal ); 264 c.setBusinessZip( postal );
265 c.setBusinessState( region ); 265 c.setBusinessState( region );
266 } else { 266 } else {
267 c.setHomeStreet( street ); 267 c.setHomeStreet( street );
268 c.setHomeCity( city ); 268 c.setHomeCity( city );
269 c.setHomeCountry( country ); 269 c.setHomeCountry( country );
270 c.setHomeZip( postal ); 270 c.setHomeZip( postal );
271 c.setHomeState( region ); 271 c.setHomeState( region );
272 } 272 }
273 } 273 }
274 else if ( name == VCTelephoneProp ) { 274 else if ( name == VCTelephoneProp ) {
275 enum { 275 enum {
276 HOME = 0x01, 276 HOME = 0x01,
277 WORK = 0x02, 277 WORK = 0x02,
278 VOICE = 0x04, 278 VOICE = 0x04,
279 CELL = 0x08, 279 CELL = 0x08,
280 FAX = 0x10, 280 FAX = 0x10,
281 PAGER = 0x20, 281 PAGER = 0x20,
282 UNKNOWN = 0x80 282 UNKNOWN = 0x80
283 }; 283 };
284 int type = 0; 284 int type = 0;
285 285
286 VObjectIterator nit; 286 VObjectIterator nit;
287 initPropIterator( &nit, o ); 287 initPropIterator( &nit, o );
288 while( moreIteration( &nit ) ) { 288 while( moreIteration( &nit ) ) {
289 VObject *o = nextVObject( &nit ); 289 VObject *o = nextVObject( &nit );
290 QCString name = vObjectTypeInfo( o ); 290 QCString name = vObjectTypeInfo( o );
291 if ( name == VCHomeProp ) 291 if ( name == VCHomeProp )
292 type |= HOME; 292 type |= HOME;
293 else if ( name == VCWorkProp ) 293 else if ( name == VCWorkProp )
294 type |= WORK; 294 type |= WORK;
295 else if ( name == VCVoiceProp ) 295 else if ( name == VCVoiceProp )
296 type |= VOICE; 296 type |= VOICE;
297 else if ( name == VCCellularProp ) 297 else if ( name == VCCellularProp )
298 type |= CELL; 298 type |= CELL;
299 else if ( name == VCFaxProp ) 299 else if ( name == VCFaxProp )
300 type |= FAX; 300 type |= FAX;
301 else if ( name == VCPagerProp ) 301 else if ( name == VCPagerProp )
302 type |= PAGER; 302 type |= PAGER;
303 else if ( name == VCPreferredProp ) 303 else if ( name == VCPreferredProp )
304 ; 304 ;
305 else 305 else
306 type |= UNKNOWN; 306 type |= UNKNOWN;
307 } 307 }
308 if ( (type & UNKNOWN) != UNKNOWN ) { 308 if ( (type & UNKNOWN) != UNKNOWN ) {
309 if ( ( type & (HOME|WORK) ) == 0 ) // default 309 if ( ( type & (HOME|WORK) ) == 0 ) // default
310 type |= HOME; 310 type |= HOME;
311 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 311 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
312 type |= VOICE; 312 type |= VOICE;
313 313
314 qWarning("value %s %d", value.data(), type ); 314 qWarning("value %s %d", value.data(), type );
315 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 315 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
316 c.setHomePhone( value ); 316 c.setHomePhone( value );
317 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 317 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
318 c.setHomeFax( value ); 318 c.setHomeFax( value );
319 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 319 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
320 c.setHomeMobile( value ); 320 c.setHomeMobile( value );
321 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) 321 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
322 c.setBusinessPhone( value ); 322 c.setBusinessPhone( value );
323 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 323 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
324 c.setBusinessFax( value ); 324 c.setBusinessFax( value );
325 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 325 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
326 c.setBusinessMobile( value ); 326 c.setBusinessMobile( value );
327 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 327 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
328 c.setBusinessPager( value ); 328 c.setBusinessPager( value );
329 } 329 }
330 } 330 }
331 else if ( name == VCEmailAddressProp ) { 331 else if ( name == VCEmailAddressProp ) {
332 QString email = vObjectStringZValue( o ); 332 QString email = vObjectStringZValue( o );
333 bool valid = TRUE; 333 bool valid = TRUE;
334 VObjectIterator nit; 334 VObjectIterator nit;
335 initPropIterator( &nit, o ); 335 initPropIterator( &nit, o );
336 while( moreIteration( &nit ) ) { 336 while( moreIteration( &nit ) ) {
337 VObject *o = nextVObject( &nit ); 337 VObject *o = nextVObject( &nit );
338 QCString name = vObjectTypeInfo( o ); 338 QCString name = vObjectTypeInfo( o );
339 if ( name != VCInternetProp && name != VCHomeProp && 339 if ( name != VCInternetProp && name != VCHomeProp &&
340 name != VCWorkProp && 340 name != VCWorkProp &&
341 name != VCPreferredProp ) 341 name != VCPreferredProp )
342 // ### preffered should map to default email 342 // ### preffered should map to default email
343 valid = FALSE; 343 valid = FALSE;
344 } 344 }
345 if ( valid ) { 345 if ( valid ) {
346 c.insertEmail( email ); 346 c.insertEmail( email );
347 } 347 }
348 } 348 }
349 else if ( name == VCURLProp ) { 349 else if ( name == VCURLProp ) {
350 VObjectIterator nit; 350 VObjectIterator nit;
351 initPropIterator( &nit, o ); 351 initPropIterator( &nit, o );
352 while( moreIteration( &nit ) ) { 352 while( moreIteration( &nit ) ) {
353 VObject *o = nextVObject( &nit ); 353 VObject *o = nextVObject( &nit );
354 QCString name = vObjectTypeInfo( o ); 354 QCString name = vObjectTypeInfo( o );
355 if ( name == VCHomeProp ) 355 if ( name == VCHomeProp )
356 c.setHomeWebpage( value ); 356 c.setHomeWebpage( value );
357 else if ( name == VCWorkProp ) 357 else if ( name == VCWorkProp )
358 c.setBusinessWebpage( value ); 358 c.setBusinessWebpage( value );
359 } 359 }
360 } 360 }
361 else if ( name == VCOrgProp ) { 361 else if ( name == VCOrgProp ) {
362 VObjectIterator nit; 362 VObjectIterator nit;
363 initPropIterator( &nit, o ); 363 initPropIterator( &nit, o );
364 while( moreIteration( &nit ) ) { 364 while( moreIteration( &nit ) ) {
365 VObject *o = nextVObject( &nit ); 365 VObject *o = nextVObject( &nit );
366 QCString name = vObjectName( o ); 366 QCString name = vObjectName( o );
367 QString value = vObjectStringZValue( o ); 367 QString value = vObjectStringZValue( o );
368 if ( name == VCOrgNameProp ) 368 if ( name == VCOrgNameProp )
369 c.setCompany( value ); 369 c.setCompany( value );
370 else if ( name == VCOrgUnitProp ) 370 else if ( name == VCOrgUnitProp )
371 c.setDepartment( value ); 371 c.setDepartment( value );
372 else if ( name == VCOrgUnit2Prop ) 372 else if ( name == VCOrgUnit2Prop )
373 c.setOffice( value ); 373 c.setOffice( value );
374 } 374 }
375 } 375 }
376 else if ( name == VCTitleProp ) { 376 else if ( name == VCTitleProp ) {
377 c.setJobTitle( value ); 377 c.setJobTitle( value );
378 } 378 }
379 else if ( name == "X-Qtopia-Profession" ) { 379 else if ( name == "X-Qtopia-Profession" ) {
380 c.setProfession( value ); 380 c.setProfession( value );
381 } 381 }
382 else if ( name == "X-Qtopia-Manager" ) { 382 else if ( name == "X-Qtopia-Manager" ) {
383 c.setManager( value ); 383 c.setManager( value );
384 } 384 }
385 else if ( name == "X-Qtopia-Assistant" ) { 385 else if ( name == "X-Qtopia-Assistant" ) {
386 c.setAssistant( value ); 386 c.setAssistant( value );
387 } 387 }
388 else if ( name == "X-Qtopia-Spouse" ) { 388 else if ( name == "X-Qtopia-Spouse" ) {
389 c.setSpouse( value ); 389 c.setSpouse( value );
390 } 390 }
391 else if ( name == "X-Qtopia-Gender" ) { 391 else if ( name == "X-Qtopia-Gender" ) {
392 c.setGender( value ); 392 c.setGender( value );
393 } 393 }
394 else if ( name == "X-Qtopia-Anniversary" ) { 394 else if ( name == "X-Qtopia-Anniversary" ) {
395 c.setAnniversary( convVCardDateToDate( value ) ); 395 c.setAnniversary( convVCardDateToDate( value ) );
396 } 396 }
397 else if ( name == "X-Qtopia-Nickname" ) { 397 else if ( name == "X-Qtopia-Nickname" ) {
398 c.setNickname( value ); 398 c.setNickname( value );
399 } 399 }
400 else if ( name == "X-Qtopia-Children" ) { 400 else if ( name == "X-Qtopia-Children" ) {
401 c.setChildren( value ); 401 c.setChildren( value );
402 } 402 }
403 else if ( name == VCBirthDateProp ) { 403 else if ( name == VCBirthDateProp ) {
404 // Reading Birthdate regarding RFC 2425 (5.8.4) 404 // Reading Birthdate regarding RFC 2425 (5.8.4)
405 c.setBirthday( convVCardDateToDate( value ) ); 405 c.setBirthday( convVCardDateToDate( value ) );
406 406
407 } 407 }
408 else if ( name == VCCommentProp ) { 408 else if ( name == VCCommentProp ) {
409 c.setNotes( value ); 409 c.setNotes( value );
410 } 410 }
411#if 0 411#if 0
412 else { 412 else {
413 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 413 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
414 VObjectIterator nit; 414 VObjectIterator nit;
415 initPropIterator( &nit, o ); 415 initPropIterator( &nit, o );
416 while( moreIteration( &nit ) ) { 416 while( moreIteration( &nit ) ) {
417 VObject *o = nextVObject( &nit ); 417 VObject *o = nextVObject( &nit );
418 QCString name = vObjectName( o ); 418 QCString name = vObjectName( o );
419 QString value = vObjectStringZValue( o ); 419 QString value = vObjectStringZValue( o );
420 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 420 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
421 } 421 }
422 } 422 }
423#endif 423#endif
424 } 424 }
425 c.setFileAs(); 425 c.setFileAs();
426 return c; 426 return c;
427} 427}
428 428
429 429
430VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 430VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
431{ 431{
432 VObject *vcard = newVObject( VCCardProp ); 432 VObject *vcard = newVObject( VCCardProp );
433 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 433 safeAddPropValue( vcard, VCVersionProp, "2.1" );
434 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 434 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
435 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 435 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
436 436
437 // full name 437 // full name
438 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 438 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
439 439
440 // name properties 440 // name properties
441 VObject *name = safeAddProp( vcard, VCNameProp ); 441 VObject *name = safeAddProp( vcard, VCNameProp );
442 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 442 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
443 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 443 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
444 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 444 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
445 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 445 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
446 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 446 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
447 447
448 // home properties 448 // home properties
449 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 449 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
450 safeAddProp( home_adr, VCHomeProp ); 450 safeAddProp( home_adr, VCHomeProp );
451 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 451 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
452 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 452 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
453 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 453 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
454 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 454 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
455 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 455 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
456 456
457 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 457 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
458 safeAddProp( home_phone, VCHomeProp ); 458 safeAddProp( home_phone, VCHomeProp );
459 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 459 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
460 safeAddProp( home_phone, VCHomeProp ); 460 safeAddProp( home_phone, VCHomeProp );
461 safeAddProp( home_phone, VCCellularProp ); 461 safeAddProp( home_phone, VCCellularProp );
462 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 462 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
463 safeAddProp( home_phone, VCHomeProp ); 463 safeAddProp( home_phone, VCHomeProp );
464 safeAddProp( home_phone, VCFaxProp ); 464 safeAddProp( home_phone, VCFaxProp );
465 465
466 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 466 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
467 safeAddProp( url, VCHomeProp ); 467 safeAddProp( url, VCHomeProp );
468 468
469 // work properties 469 // work properties
470 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 470 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
471 safeAddProp( work_adr, VCWorkProp ); 471 safeAddProp( work_adr, VCWorkProp );
472 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 472 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
473 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 473 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
474 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 474 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
475 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 475 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
476 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 476 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
477 477
478 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 478 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
479 safeAddProp( work_phone, VCWorkProp ); 479 safeAddProp( work_phone, VCWorkProp );
480 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 480 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
481 safeAddProp( work_phone, VCWorkProp ); 481 safeAddProp( work_phone, VCWorkProp );
482 safeAddProp( work_phone, VCCellularProp ); 482 safeAddProp( work_phone, VCCellularProp );
483 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 483 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
484 safeAddProp( work_phone, VCWorkProp ); 484 safeAddProp( work_phone, VCWorkProp );
485 safeAddProp( work_phone, VCFaxProp ); 485 safeAddProp( work_phone, VCFaxProp );
486 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 486 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
487 safeAddProp( work_phone, VCWorkProp ); 487 safeAddProp( work_phone, VCWorkProp );
488 safeAddProp( work_phone, VCPagerProp ); 488 safeAddProp( work_phone, VCPagerProp );
489 489
490 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 490 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
491 safeAddProp( url, VCWorkProp ); 491 safeAddProp( url, VCWorkProp );
492 492
493 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 493 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
494 safeAddProp( title, VCWorkProp ); 494 safeAddProp( title, VCWorkProp );
495 495
496 496
497 QStringList emails = c.emailList(); 497 QStringList emails = c.emailList();
498 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 498 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
499 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 499 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
500 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 500 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
501 safeAddProp( email, VCInternetProp ); 501 safeAddProp( email, VCInternetProp );
502 } 502 }
503 503
504 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 504 safeAddPropValue( vcard, VCNoteProp, c.notes() );
505 505
506 // Exporting Birthday regarding RFC 2425 (5.8.4) 506 // Exporting Birthday regarding RFC 2425 (5.8.4)
507 if ( c.birthday().isValid() ){ 507 if ( c.birthday().isValid() ){
508 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 508 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
509 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 509 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
510 } 510 }
511 511
512 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 512 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
513 VObject *org = safeAddProp( vcard, VCOrgProp ); 513 VObject *org = safeAddProp( vcard, VCOrgProp );
514 safeAddPropValue( org, VCOrgNameProp, c.company() ); 514 safeAddPropValue( org, VCOrgNameProp, c.company() );
515 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 515 safeAddPropValue( org, VCOrgUnitProp, c.department() );
516 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 516 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
517 } 517 }
518 518
519 // some values we have to export as custom fields 519 // some values we have to export as custom fields
520 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 520 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
521 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 521 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
522 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 522 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
523 523
524 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 524 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
525 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 525 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
526 if ( c.anniversary().isValid() ){ 526 if ( c.anniversary().isValid() ){
527 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 527 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
528 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 528 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
529 } 529 }
530 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 530 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
531 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 531 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
532 532
533 return vcard; 533 return vcard;
534} 534}
535 535
536QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 536QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
537{ 537{
538 QString str_rfc2425 = QString("%1-%2-%3") 538 QString str_rfc2425 = QString("%1-%2-%3")
539 .arg( d.year() ) 539 .arg( d.year() )
540 .arg( d.month(), 2 ) 540 .arg( d.month(), 2 )
541 .arg( d.day(), 2 ); 541 .arg( d.day(), 2 );
542 // Now replace spaces with "0"... 542 // Now replace spaces with "0"...
543 int pos = 0; 543 int pos = 0;
544 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 544 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
545 str_rfc2425.replace( pos, 1, "0" ); 545 str_rfc2425.replace( pos, 1, "0" );
546 546
547 return str_rfc2425; 547 return str_rfc2425;
548} 548}
549 549
550QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 550QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
551{ 551{
552 int monthPos = datestr.find('-'); 552 int monthPos = datestr.find('-');
553 int dayPos = datestr.find('-', monthPos+1 ); 553 int dayPos = datestr.find('-', monthPos+1 );
554 int sep_ignore = 1; 554 int sep_ignore = 1;
555 if ( monthPos == -1 || dayPos == -1 ) { 555 if ( monthPos == -1 || dayPos == -1 ) {
556 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 556 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
557 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 557 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
558 if ( datestr.length() == 8 ){ 558 if ( datestr.length() == 8 ){
559 monthPos = 4; 559 monthPos = 4;
560 dayPos = 6; 560 dayPos = 6;
561 sep_ignore = 0; 561 sep_ignore = 0;
562 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 562 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
563 } else { 563 } else {
564 return QDate(); 564 return QDate();
565 } 565 }
566 } 566 }
567 int y = datestr.left( monthPos ).toInt(); 567 int y = datestr.left( monthPos ).toInt();
568 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 568 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
569 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 569 int d = datestr.mid( dayPos + sep_ignore ).toInt();
570 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 570 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
571 QDate date ( y,m,d ); 571 QDate date ( y,m,d );
572 return date; 572 return date;
573} 573}
574 574
575VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 575VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
576{ 576{
577 VObject *ret = 0; 577 VObject *ret = 0;
578 if ( o && !value.isEmpty() ) 578 if ( o && !value.isEmpty() )
579 ret = addPropValue( o, prop, value.latin1() ); 579 ret = addPropValue( o, prop, value.latin1() );
580 return ret; 580 return ret;
581} 581}
582 582
583VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) 583VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)
584{ 584{
585 VObject *ret = 0; 585 VObject *ret = 0;
586 if ( o ) 586 if ( o )
587 ret = addProp( o, prop ); 587 ret = addProp( o, prop );
588 return ret; 588 return ret;
589} 589}
590 590
591} 591}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 11be027..2a786af 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -1,85 +1,85 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * VCard Backend for the OPIE-Contact Database. 30 * VCard Backend for the OPIE-Contact Database.
31 */ 31 */
32#ifndef __OCONTACTACCESSBACKEND_VCARD_H_ 32#ifndef __OCONTACTACCESSBACKEND_VCARD_H_
33#define __OCONTACTACCESSBACKEND_VCARD_H_ 33#define __OCONTACTACCESSBACKEND_VCARD_H_
34 34
35#include <opie2/ocontact.h> 35#include <opie2/opimcontact.h>
36 36
37#include <opie2/ocontactaccessbackend.h> 37#include <opie2/ocontactaccessbackend.h>
38 38
39class VObject; 39class VObject;
40 40
41namespace Opie { 41namespace Opie {
42/** 42/**
43 * This is the vCard 2.1 implementation of the Contact Storage 43 * This is the vCard 2.1 implementation of the Contact Storage
44 * @see OContactAccessBackend_XML 44 * @see OPimContactAccessBackend_XML
45 * @see OPimAccessBackend 45 * @see OPimAccessBackend
46 */ 46 */
47class OContactAccessBackend_VCard : public OContactAccessBackend { 47class OPimContactAccessBackend_VCard : public OPimContactAccessBackend {
48 public: 48 public:
49 OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); 49 OPimContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
50 50
51 bool load (); 51 bool load ();
52 bool reload(); 52 bool reload();
53 bool save(); 53 bool save();
54 void clear (); 54 void clear ();
55 55
56 bool add ( const OContact& newcontact ); 56 bool add ( const OPimContact& newcontact );
57 bool remove ( int uid ); 57 bool remove ( int uid );
58 bool replace ( const OContact& contact ); 58 bool replace ( const OPimContact& contact );
59 59
60 OContact find ( int uid ) const; 60 OPimContact find ( int uid ) const;
61 QArray<int> allRecords() const; 61 QArray<int> allRecords() const;
62 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); 62 QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() );
63 QArray<int> matchRegexp( const QRegExp &r ) const; 63 QArray<int> matchRegexp( const QRegExp &r ) const;
64 64
65 const uint querySettings(); 65 const uint querySettings();
66 bool hasQuerySettings (uint querySettings) const; 66 bool hasQuerySettings (uint querySettings) const;
67 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); 67 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
68 bool wasChangedExternally(); 68 bool wasChangedExternally();
69 69
70private: 70private:
71 OContact parseVObject( VObject* obj ); 71 OPimContact parseVObject( VObject* obj );
72 VObject* createVObject( const OContact& c ); 72 VObject* createVObject( const OPimContact& c );
73 QString convDateToVCardDate( const QDate& c ) const; 73 QString convDateToVCardDate( const QDate& c ) const;
74 QDate convVCardDateToDate( const QString& datestr ); 74 QDate convVCardDateToDate( const QString& datestr );
75 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); 75 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
76 VObject *safeAddProp( VObject* o, const char* prop); 76 VObject *safeAddProp( VObject* o, const char* prop);
77 77
78 bool m_dirty : 1; 78 bool m_dirty : 1;
79 QString m_file; 79 QString m_file;
80 QMap<int, OContact> m_map; 80 QMap<int, OPimContact> m_map;
81}; 81};
82 82
83} 83}
84 84
85#endif 85#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 07ad29a..0adba68 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,751 +1,751 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include <opie2/ocontactaccessbackend_xml.h> 33#include <opie2/ocontactaccessbackend_xml.h>
34 34
35#include <qasciidict.h> 35#include <qasciidict.h>
36#include <qdatetime.h> 36#include <qdatetime.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h> 38#include <qfileinfo.h>
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qarray.h> 40#include <qarray.h>
41#include <qmap.h> 41#include <qmap.h>
42#include <qdatetime.h> 42#include <qdatetime.h>
43 43
44#include <qpe/global.h> 44#include <qpe/global.h>
45 45
46#include <opie2/xmltree.h> 46#include <opie2/xmltree.h>
47#include <opie2/ocontactaccessbackend.h> 47#include <opie2/ocontactaccessbackend.h>
48#include <opie2/ocontactaccess.h> 48#include <opie2/ocontactaccess.h>
49 49
50#include <stdlib.h> 50#include <stdlib.h>
51#include <errno.h> 51#include <errno.h>
52 52
53using namespace Opie; 53using namespace Opie;
54 54
55 55
56namespace Opie { 56namespace Opie {
57OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): 57OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
58 m_changed( false ) 58 m_changed( false )
59{ 59{
60 // Just m_contactlist should call delete if an entry 60 // Just m_contactlist should call delete if an entry
61 // is removed. 61 // is removed.
62 m_contactList.setAutoDelete( true ); 62 m_contactList.setAutoDelete( true );
63 m_uidToContact.setAutoDelete( false ); 63 m_uidToContact.setAutoDelete( false );
64 64
65 m_appName = appname; 65 m_appName = appname;
66 66
67 /* Set journalfile name ... */ 67 /* Set journalfile name ... */
68 m_journalName = getenv("HOME"); 68 m_journalName = getenv("HOME");
69 m_journalName +="/.abjournal" + appname; 69 m_journalName +="/.abjournal" + appname;
70 70
71 /* Expecting to access the default filename if nothing else is set */ 71 /* Expecting to access the default filename if nothing else is set */
72 if ( filename.isEmpty() ){ 72 if ( filename.isEmpty() ){
73 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 73 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
74 } else 74 } else
75 m_fileName = filename; 75 m_fileName = filename;
76 76
77 /* Load Database now */ 77 /* Load Database now */
78 load (); 78 load ();
79} 79}
80 80
81bool OContactAccessBackend_XML::save() 81bool OPimContactAccessBackend_XML::save()
82{ 82{
83 83
84 if ( !m_changed ) 84 if ( !m_changed )
85 return true; 85 return true;
86 86
87 QString strNewFile = m_fileName + ".new"; 87 QString strNewFile = m_fileName + ".new";
88 QFile f( strNewFile ); 88 QFile f( strNewFile );
89 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 89 if ( !f.open( IO_WriteOnly|IO_Raw ) )
90 return false; 90 return false;
91 91
92 int total_written; 92 int total_written;
93 int idx_offset = 0; 93 int idx_offset = 0;
94 QString out; 94 QString out;
95 95
96 // Write Header 96 // Write Header
97 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 97 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
98 " <Groups>\n" 98 " <Groups>\n"
99 " </Groups>\n" 99 " </Groups>\n"
100 " <Contacts>\n"; 100 " <Contacts>\n";
101 QCString cstr = out.utf8(); 101 QCString cstr = out.utf8();
102 f.writeBlock( cstr.data(), cstr.length() ); 102 f.writeBlock( cstr.data(), cstr.length() );
103 idx_offset += cstr.length(); 103 idx_offset += cstr.length();
104 out = ""; 104 out = "";
105 105
106 // Write all contacts 106 // Write all contacts
107 QListIterator<OContact> it( m_contactList ); 107 QListIterator<OPimContact> it( m_contactList );
108 for ( ; it.current(); ++it ) { 108 for ( ; it.current(); ++it ) {
109 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 109 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
110 out += "<Contact "; 110 out += "<Contact ";
111 (*it)->save( out ); 111 (*it)->save( out );
112 out += "/>\n"; 112 out += "/>\n";
113 cstr = out.utf8(); 113 cstr = out.utf8();
114 total_written = f.writeBlock( cstr.data(), cstr.length() ); 114 total_written = f.writeBlock( cstr.data(), cstr.length() );
115 idx_offset += cstr.length(); 115 idx_offset += cstr.length();
116 if ( total_written != int(cstr.length()) ) { 116 if ( total_written != int(cstr.length()) ) {
117 f.close(); 117 f.close();
118 QFile::remove( strNewFile ); 118 QFile::remove( strNewFile );
119 return false; 119 return false;
120 } 120 }
121 out = ""; 121 out = "";
122 } 122 }
123 out += " </Contacts>\n</AddressBook>\n"; 123 out += " </Contacts>\n</AddressBook>\n";
124 124
125 // Write Footer 125 // Write Footer
126 cstr = out.utf8(); 126 cstr = out.utf8();
127 total_written = f.writeBlock( cstr.data(), cstr.length() ); 127 total_written = f.writeBlock( cstr.data(), cstr.length() );
128 if ( total_written != int( cstr.length() ) ) { 128 if ( total_written != int( cstr.length() ) ) {
129 f.close(); 129 f.close();
130 QFile::remove( strNewFile ); 130 QFile::remove( strNewFile );
131 return false; 131 return false;
132 } 132 }
133 f.close(); 133 f.close();
134 134
135 // move the file over, I'm just going to use the system call 135 // move the file over, I'm just going to use the system call
136 // because, I don't feel like using QDir. 136 // because, I don't feel like using QDir.
137 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { 137 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
138 qWarning( "problem renaming file %s to %s, errno: %d", 138 qWarning( "problem renaming file %s to %s, errno: %d",
139 strNewFile.latin1(), m_journalName.latin1(), errno ); 139 strNewFile.latin1(), m_journalName.latin1(), errno );
140 // remove the tmp file... 140 // remove the tmp file...
141 QFile::remove( strNewFile ); 141 QFile::remove( strNewFile );
142 } 142 }
143 143
144 /* The journalfile should be removed now... */ 144 /* The journalfile should be removed now... */
145 removeJournal(); 145 removeJournal();
146 146
147 m_changed = false; 147 m_changed = false;
148 return true; 148 return true;
149} 149}
150 150
151bool OContactAccessBackend_XML::load () 151bool OPimContactAccessBackend_XML::load ()
152{ 152{
153 m_contactList.clear(); 153 m_contactList.clear();
154 m_uidToContact.clear(); 154 m_uidToContact.clear();
155 155
156 /* Load XML-File and journal if it exists */ 156 /* Load XML-File and journal if it exists */
157 if ( !load ( m_fileName, false ) ) 157 if ( !load ( m_fileName, false ) )
158 return false; 158 return false;
159 /* The returncode of the journalfile is ignored due to the 159 /* The returncode of the journalfile is ignored due to the
160 * fact that it does not exist when this class is instantiated ! 160 * fact that it does not exist when this class is instantiated !
161 * But there may such a file exist, if the application crashed. 161 * But there may such a file exist, if the application crashed.
162 * Therefore we try to load it to get the changes before the # 162 * Therefore we try to load it to get the changes before the #
163 * crash happened... 163 * crash happened...
164 */ 164 */
165 load (m_journalName, true); 165 load (m_journalName, true);
166 166
167 return true; 167 return true;
168} 168}
169 169
170void OContactAccessBackend_XML::clear () 170void OPimContactAccessBackend_XML::clear ()
171{ 171{
172 m_contactList.clear(); 172 m_contactList.clear();
173 m_uidToContact.clear(); 173 m_uidToContact.clear();
174 174
175 m_changed = false; 175 m_changed = false;
176} 176}
177 177
178bool OContactAccessBackend_XML::wasChangedExternally() 178bool OPimContactAccessBackend_XML::wasChangedExternally()
179{ 179{
180 QFileInfo fi( m_fileName ); 180 QFileInfo fi( m_fileName );
181 181
182 QDateTime lastmod = fi.lastModified (); 182 QDateTime lastmod = fi.lastModified ();
183 183
184 return (lastmod != m_readtime); 184 return (lastmod != m_readtime);
185} 185}
186 186
187QArray<int> OContactAccessBackend_XML::allRecords() const 187QArray<int> OPimContactAccessBackend_XML::allRecords() const
188{ 188{
189 QArray<int> uid_list( m_contactList.count() ); 189 QArray<int> uid_list( m_contactList.count() );
190 190
191 uint counter = 0; 191 uint counter = 0;
192 QListIterator<OContact> it( m_contactList ); 192 QListIterator<OPimContact> it( m_contactList );
193 for( ; it.current(); ++it ){ 193 for( ; it.current(); ++it ){
194 uid_list[counter++] = (*it)->uid(); 194 uid_list[counter++] = (*it)->uid();
195 } 195 }
196 196
197 return ( uid_list ); 197 return ( uid_list );
198} 198}
199 199
200OContact OContactAccessBackend_XML::find ( int uid ) const 200OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
201{ 201{
202 OContact foundContact; //Create empty contact 202 OPimContact foundContact; //Create empty contact
203 203
204 OContact* found = m_uidToContact.find( QString().setNum( uid ) ); 204 OPimContact* found = m_uidToContact.find( QString().setNum( uid ) );
205 205
206 if ( found ){ 206 if ( found ){
207 foundContact = *found; 207 foundContact = *found;
208 } 208 }
209 209
210 return ( foundContact ); 210 return ( foundContact );
211} 211}
212 212
213QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings, 213QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings,
214 const QDateTime& d ) 214 const QDateTime& d )
215{ 215{
216 216
217 QArray<int> m_currentQuery( m_contactList.count() ); 217 QArray<int> m_currentQuery( m_contactList.count() );
218 QListIterator<OContact> it( m_contactList ); 218 QListIterator<OPimContact> it( m_contactList );
219 uint arraycounter = 0; 219 uint arraycounter = 0;
220 220
221 for( ; it.current(); ++it ){ 221 for( ; it.current(); ++it ){
222 /* Search all fields and compare them with query object. Store them into list 222 /* Search all fields and compare them with query object. Store them into list
223 * if all fields matches. 223 * if all fields matches.
224 */ 224 */
225 QDate* queryDate = 0l; 225 QDate* queryDate = 0l;
226 QDate* checkDate = 0l; 226 QDate* checkDate = 0l;
227 bool allcorrect = true; 227 bool allcorrect = true;
228 for ( int i = 0; i < Qtopia::Groups; i++ ) { 228 for ( int i = 0; i < Qtopia::Groups; i++ ) {
229 // Birthday and anniversary are special nonstring fields and should 229 // Birthday and anniversary are special nonstring fields and should
230 // be handled specially 230 // be handled specially
231 switch ( i ){ 231 switch ( i ){
232 case Qtopia::Birthday: 232 case Qtopia::Birthday:
233 queryDate = new QDate( query.birthday() ); 233 queryDate = new QDate( query.birthday() );
234 checkDate = new QDate( (*it)->birthday() ); 234 checkDate = new QDate( (*it)->birthday() );
235 case Qtopia::Anniversary: 235 case Qtopia::Anniversary:
236 if ( queryDate == 0l ){ 236 if ( queryDate == 0l ){
237 queryDate = new QDate( query.anniversary() ); 237 queryDate = new QDate( query.anniversary() );
238 checkDate = new QDate( (*it)->anniversary() ); 238 checkDate = new QDate( (*it)->anniversary() );
239 } 239 }
240 240
241 if ( queryDate->isValid() ){ 241 if ( queryDate->isValid() ){
242 if( checkDate->isValid() ){ 242 if( checkDate->isValid() ){
243 if ( settings & OContactAccess::DateYear ){ 243 if ( settings & OPimContactAccess::DateYear ){
244 if ( queryDate->year() != checkDate->year() ) 244 if ( queryDate->year() != checkDate->year() )
245 allcorrect = false; 245 allcorrect = false;
246 } 246 }
247 if ( settings & OContactAccess::DateMonth ){ 247 if ( settings & OPimContactAccess::DateMonth ){
248 if ( queryDate->month() != checkDate->month() ) 248 if ( queryDate->month() != checkDate->month() )
249 allcorrect = false; 249 allcorrect = false;
250 } 250 }
251 if ( settings & OContactAccess::DateDay ){ 251 if ( settings & OPimContactAccess::DateDay ){
252 if ( queryDate->day() != checkDate->day() ) 252 if ( queryDate->day() != checkDate->day() )
253 allcorrect = false; 253 allcorrect = false;
254 } 254 }
255 if ( settings & OContactAccess::DateDiff ) { 255 if ( settings & OPimContactAccess::DateDiff ) {
256 QDate current; 256 QDate current;
257 // If we get an additional date, we 257 // If we get an additional date, we
258 // will take this date instead of 258 // will take this date instead of
259 // the current one.. 259 // the current one..
260 if ( !d.date().isValid() ) 260 if ( !d.date().isValid() )
261 current = QDate::currentDate(); 261 current = QDate::currentDate();
262 else 262 else
263 current = d.date(); 263 current = d.date();
264 264
265 // We have to equalize the year, otherwise 265 // We have to equalize the year, otherwise
266 // the search will fail.. 266 // the search will fail..
267 checkDate->setYMD( current.year(), 267 checkDate->setYMD( current.year(),
268 checkDate->month(), 268 checkDate->month(),
269 checkDate->day() ); 269 checkDate->day() );
270 if ( *checkDate < current ) 270 if ( *checkDate < current )
271 checkDate->setYMD( current.year()+1, 271 checkDate->setYMD( current.year()+1,
272 checkDate->month(), 272 checkDate->month(),
273 checkDate->day() ); 273 checkDate->day() );
274 274
275 // Check whether the birthday/anniversary date is between 275 // Check whether the birthday/anniversary date is between
276 // the current/given date and the maximum date 276 // the current/given date and the maximum date
277 // ( maximum time range ) ! 277 // ( maximum time range ) !
278 qWarning("Checking if %s is between %s and %s ! ", 278 qWarning("Checking if %s is between %s and %s ! ",
279 checkDate->toString().latin1(), 279 checkDate->toString().latin1(),
280 current.toString().latin1(), 280 current.toString().latin1(),
281 queryDate->toString().latin1() ); 281 queryDate->toString().latin1() );
282 if ( current.daysTo( *queryDate ) >= 0 ){ 282 if ( current.daysTo( *queryDate ) >= 0 ){
283 if ( !( ( *checkDate >= current ) && 283 if ( !( ( *checkDate >= current ) &&
284 ( *checkDate <= *queryDate ) ) ){ 284 ( *checkDate <= *queryDate ) ) ){
285 allcorrect = false; 285 allcorrect = false;
286 qWarning (" Nope!.."); 286 qWarning (" Nope!..");
287 } 287 }
288 } 288 }
289 } 289 }
290 } else{ 290 } else{
291 // checkDate is invalid. Therefore this entry is always rejected 291 // checkDate is invalid. Therefore this entry is always rejected
292 allcorrect = false; 292 allcorrect = false;
293 } 293 }
294 } 294 }
295 295
296 delete queryDate; 296 delete queryDate;
297 queryDate = 0l; 297 queryDate = 0l;
298 delete checkDate; 298 delete checkDate;
299 checkDate = 0l; 299 checkDate = 0l;
300 break; 300 break;
301 default: 301 default:
302 /* Just compare fields which are not empty in the query object */ 302 /* Just compare fields which are not empty in the query object */
303 if ( !query.field(i).isEmpty() ){ 303 if ( !query.field(i).isEmpty() ){
304 switch ( settings & ~( OContactAccess::IgnoreCase 304 switch ( settings & ~( OPimContactAccess::IgnoreCase
305 | OContactAccess::DateDiff 305 | OPimContactAccess::DateDiff
306 | OContactAccess::DateYear 306 | OPimContactAccess::DateYear
307 | OContactAccess::DateMonth 307 | OPimContactAccess::DateMonth
308 | OContactAccess::DateDay 308 | OPimContactAccess::DateDay
309 | OContactAccess::MatchOne 309 | OPimContactAccess::MatchOne
310 ) ){ 310 ) ){
311 311
312 case OContactAccess::RegExp:{ 312 case OPimContactAccess::RegExp:{
313 QRegExp expr ( query.field(i), 313 QRegExp expr ( query.field(i),
314 !(settings & OContactAccess::IgnoreCase), 314 !(settings & OPimContactAccess::IgnoreCase),
315 false ); 315 false );
316 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 316 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
317 allcorrect = false; 317 allcorrect = false;
318 } 318 }
319 break; 319 break;
320 case OContactAccess::WildCards:{ 320 case OPimContactAccess::WildCards:{
321 QRegExp expr ( query.field(i), 321 QRegExp expr ( query.field(i),
322 !(settings & OContactAccess::IgnoreCase), 322 !(settings & OPimContactAccess::IgnoreCase),
323 true ); 323 true );
324 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 324 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
325 allcorrect = false; 325 allcorrect = false;
326 } 326 }
327 break; 327 break;
328 case OContactAccess::ExactMatch:{ 328 case OPimContactAccess::ExactMatch:{
329 if (settings & OContactAccess::IgnoreCase){ 329 if (settings & OPimContactAccess::IgnoreCase){
330 if ( query.field(i).upper() != 330 if ( query.field(i).upper() !=
331 (*it)->field(i).upper() ) 331 (*it)->field(i).upper() )
332 allcorrect = false; 332 allcorrect = false;
333 }else{ 333 }else{
334 if ( query.field(i) != (*it)->field(i) ) 334 if ( query.field(i) != (*it)->field(i) )
335 allcorrect = false; 335 allcorrect = false;
336 } 336 }
337 } 337 }
338 break; 338 break;
339 } 339 }
340 } 340 }
341 } 341 }
342 } 342 }
343 if ( allcorrect ){ 343 if ( allcorrect ){
344 m_currentQuery[arraycounter++] = (*it)->uid(); 344 m_currentQuery[arraycounter++] = (*it)->uid();
345 } 345 }
346 } 346 }
347 347
348 // Shrink to fit.. 348 // Shrink to fit..
349 m_currentQuery.resize(arraycounter); 349 m_currentQuery.resize(arraycounter);
350 350
351 return m_currentQuery; 351 return m_currentQuery;
352} 352}
353 353
354QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const 354QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
355{ 355{
356 QArray<int> m_currentQuery( m_contactList.count() ); 356 QArray<int> m_currentQuery( m_contactList.count() );
357 QListIterator<OContact> it( m_contactList ); 357 QListIterator<OPimContact> it( m_contactList );
358 uint arraycounter = 0; 358 uint arraycounter = 0;
359 359
360 for( ; it.current(); ++it ){ 360 for( ; it.current(); ++it ){
361 if ( (*it)->match( r ) ){ 361 if ( (*it)->match( r ) ){
362 m_currentQuery[arraycounter++] = (*it)->uid(); 362 m_currentQuery[arraycounter++] = (*it)->uid();
363 } 363 }
364 364
365 } 365 }
366 // Shrink to fit.. 366 // Shrink to fit..
367 m_currentQuery.resize(arraycounter); 367 m_currentQuery.resize(arraycounter);
368 368
369 return m_currentQuery; 369 return m_currentQuery;
370} 370}
371 371
372const uint OContactAccessBackend_XML::querySettings() 372const uint OPimContactAccessBackend_XML::querySettings()
373{ 373{
374 return ( OContactAccess::WildCards 374 return ( OPimContactAccess::WildCards
375 | OContactAccess::IgnoreCase 375 | OPimContactAccess::IgnoreCase
376 | OContactAccess::RegExp 376 | OPimContactAccess::RegExp
377 | OContactAccess::ExactMatch 377 | OPimContactAccess::ExactMatch
378 | OContactAccess::DateDiff 378 | OPimContactAccess::DateDiff
379 | OContactAccess::DateYear 379 | OPimContactAccess::DateYear
380 | OContactAccess::DateMonth 380 | OPimContactAccess::DateMonth
381 | OContactAccess::DateDay 381 | OPimContactAccess::DateDay
382 ); 382 );
383} 383}
384 384
385bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const 385bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
386{ 386{
387 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 387 /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
388 * may be added with any of the other settings. IgnoreCase should never used alone. 388 * may be added with any of the other settings. IgnoreCase should never used alone.
389 * Wildcards, RegExp, ExactMatch should never used at the same time... 389 * Wildcards, RegExp, ExactMatch should never used at the same time...
390 */ 390 */
391 391
392 // Step 1: Check whether the given settings are supported by this backend 392 // Step 1: Check whether the given settings are supported by this backend
393 if ( ( querySettings & ( 393 if ( ( querySettings & (
394 OContactAccess::IgnoreCase 394 OPimContactAccess::IgnoreCase
395 | OContactAccess::WildCards 395 | OPimContactAccess::WildCards
396 | OContactAccess::DateDiff 396 | OPimContactAccess::DateDiff
397 | OContactAccess::DateYear 397 | OPimContactAccess::DateYear
398 | OContactAccess::DateMonth 398 | OPimContactAccess::DateMonth
399 | OContactAccess::DateDay 399 | OPimContactAccess::DateDay
400 | OContactAccess::RegExp 400 | OPimContactAccess::RegExp
401 | OContactAccess::ExactMatch 401 | OPimContactAccess::ExactMatch
402 ) ) != querySettings ) 402 ) ) != querySettings )
403 return false; 403 return false;
404 404
405 // Step 2: Check whether the given combinations are ok.. 405 // Step 2: Check whether the given combinations are ok..
406 406
407 // IngoreCase alone is invalid 407 // IngoreCase alone is invalid
408 if ( querySettings == OContactAccess::IgnoreCase ) 408 if ( querySettings == OPimContactAccess::IgnoreCase )
409 return false; 409 return false;
410 410
411 // WildCards, RegExp and ExactMatch should never used at the same time 411 // WildCards, RegExp and ExactMatch should never used at the same time
412 switch ( querySettings & ~( OContactAccess::IgnoreCase 412 switch ( querySettings & ~( OPimContactAccess::IgnoreCase
413 | OContactAccess::DateDiff 413 | OPimContactAccess::DateDiff
414 | OContactAccess::DateYear 414 | OPimContactAccess::DateYear
415 | OContactAccess::DateMonth 415 | OPimContactAccess::DateMonth
416 | OContactAccess::DateDay 416 | OPimContactAccess::DateDay
417 ) 417 )
418 ){ 418 ){
419 case OContactAccess::RegExp: 419 case OPimContactAccess::RegExp:
420 return ( true ); 420 return ( true );
421 case OContactAccess::WildCards: 421 case OPimContactAccess::WildCards:
422 return ( true ); 422 return ( true );
423 case OContactAccess::ExactMatch: 423 case OPimContactAccess::ExactMatch:
424 return ( true ); 424 return ( true );
425 case 0: // one of the upper removed bits were set.. 425 case 0: // one of the upper removed bits were set..
426 return ( true ); 426 return ( true );
427 default: 427 default:
428 return ( false ); 428 return ( false );
429 } 429 }
430} 430}
431 431
432// Currently only asc implemented.. 432// Currently only asc implemented..
433QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) 433QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
434{ 434{
435 QMap<QString, int> nameToUid; 435 QMap<QString, int> nameToUid;
436 QStringList names; 436 QStringList names;
437 QArray<int> m_currentQuery( m_contactList.count() ); 437 QArray<int> m_currentQuery( m_contactList.count() );
438 438
439 // First fill map and StringList with all Names 439 // First fill map and StringList with all Names
440 // Afterwards sort namelist and use map to fill array to return.. 440 // Afterwards sort namelist and use map to fill array to return..
441 QListIterator<OContact> it( m_contactList ); 441 QListIterator<OPimContact> it( m_contactList );
442 for( ; it.current(); ++it ){ 442 for( ; it.current(); ++it ){
443 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); 443 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
444 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); 444 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
445 } 445 }
446 names.sort(); 446 names.sort();
447 447
448 int i = 0; 448 int i = 0;
449 if ( asc ){ 449 if ( asc ){
450 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) 450 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
451 m_currentQuery[i++] = nameToUid[ (*it) ]; 451 m_currentQuery[i++] = nameToUid[ (*it) ];
452 }else{ 452 }else{
453 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) 453 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
454 m_currentQuery[i++] = nameToUid[ (*it) ]; 454 m_currentQuery[i++] = nameToUid[ (*it) ];
455 } 455 }
456 456
457 return m_currentQuery; 457 return m_currentQuery;
458 458
459} 459}
460 460
461bool OContactAccessBackend_XML::add ( const OContact &newcontact ) 461bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
462{ 462{
463 //qWarning("odefaultbackend: ACTION::ADD"); 463 //qWarning("odefaultbackend: ACTION::ADD");
464 updateJournal (newcontact, ACTION_ADD); 464 updateJournal (newcontact, ACTION_ADD);
465 addContact_p( newcontact ); 465 addContact_p( newcontact );
466 466
467 m_changed = true; 467 m_changed = true;
468 468
469 return true; 469 return true;
470} 470}
471 471
472bool OContactAccessBackend_XML::replace ( const OContact &contact ) 472bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
473{ 473{
474 m_changed = true; 474 m_changed = true;
475 475
476 OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) ); 476 OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
477 477
478 if ( found ) { 478 if ( found ) {
479 OContact* newCont = new OContact( contact ); 479 OPimContact* newCont = new OPimContact( contact );
480 480
481 updateJournal ( *newCont, ACTION_REPLACE); 481 updateJournal ( *newCont, ACTION_REPLACE);
482 m_contactList.removeRef ( found ); 482 m_contactList.removeRef ( found );
483 m_contactList.append ( newCont ); 483 m_contactList.append ( newCont );
484 m_uidToContact.remove( QString().setNum( contact.uid() ) ); 484 m_uidToContact.remove( QString().setNum( contact.uid() ) );
485 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); 485 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
486 486
487 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid()); 487 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid());
488 488
489 return true; 489 return true;
490 } else 490 } else
491 return false; 491 return false;
492} 492}
493 493
494bool OContactAccessBackend_XML::remove ( int uid ) 494bool OPimContactAccessBackend_XML::remove ( int uid )
495{ 495{
496 m_changed = true; 496 m_changed = true;
497 497
498 OContact* found = m_uidToContact.find ( QString().setNum( uid ) ); 498 OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) );
499 499
500 if ( found ) { 500 if ( found ) {
501 updateJournal ( *found, ACTION_REMOVE); 501 updateJournal ( *found, ACTION_REMOVE);
502 m_contactList.removeRef ( found ); 502 m_contactList.removeRef ( found );
503 m_uidToContact.remove( QString().setNum( uid ) ); 503 m_uidToContact.remove( QString().setNum( uid ) );
504 504
505 return true; 505 return true;
506 } else 506 } else
507 return false; 507 return false;
508} 508}
509 509
510bool OContactAccessBackend_XML::reload(){ 510bool OPimContactAccessBackend_XML::reload(){
511 /* Reload is the same as load in this implementation */ 511 /* Reload is the same as load in this implementation */
512 return ( load() ); 512 return ( load() );
513} 513}
514 514
515void OContactAccessBackend_XML::addContact_p( const OContact &newcontact ) 515void OPimContactAccessBackend_XML::addContact_p( const OPimContact &newcontact )
516{ 516{
517 OContact* contRef = new OContact( newcontact ); 517 OPimContact* contRef = new OPimContact( newcontact );
518 518
519 m_contactList.append ( contRef ); 519 m_contactList.append ( contRef );
520 m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef ); 520 m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef );
521} 521}
522 522
523/* This function loads the xml-database and the journalfile */ 523/* This function loads the xml-database and the journalfile */
524bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) 524bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal )
525{ 525{
526 526
527 /* We use the time of the last read to check if the file was 527 /* We use the time of the last read to check if the file was
528 * changed externally. 528 * changed externally.
529 */ 529 */
530 if ( !isJournal ){ 530 if ( !isJournal ){
531 QFileInfo fi( filename ); 531 QFileInfo fi( filename );
532 m_readtime = fi.lastModified (); 532 m_readtime = fi.lastModified ();
533 } 533 }
534 534
535 const int JOURNALACTION = Qtopia::Notes + 1; 535 const int JOURNALACTION = Qtopia::Notes + 1;
536 const int JOURNALROW = JOURNALACTION + 1; 536 const int JOURNALROW = JOURNALACTION + 1;
537 537
538 bool foundAction = false; 538 bool foundAction = false;
539 journal_action action = ACTION_ADD; 539 journal_action action = ACTION_ADD;
540 int journalKey = 0; 540 int journalKey = 0;
541 QMap<int, QString> contactMap; 541 QMap<int, QString> contactMap;
542 QMap<QString, QString> customMap; 542 QMap<QString, QString> customMap;
543 QMap<QString, QString>::Iterator customIt; 543 QMap<QString, QString>::Iterator customIt;
544 QAsciiDict<int> dict( 47 ); 544 QAsciiDict<int> dict( 47 );
545 545
546 dict.setAutoDelete( TRUE ); 546 dict.setAutoDelete( TRUE );
547 dict.insert( "Uid", new int(Qtopia::AddressUid) ); 547 dict.insert( "Uid", new int(Qtopia::AddressUid) );
548 dict.insert( "Title", new int(Qtopia::Title) ); 548 dict.insert( "Title", new int(Qtopia::Title) );
549 dict.insert( "FirstName", new int(Qtopia::FirstName) ); 549 dict.insert( "FirstName", new int(Qtopia::FirstName) );
550 dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); 550 dict.insert( "MiddleName", new int(Qtopia::MiddleName) );
551 dict.insert( "LastName", new int(Qtopia::LastName) ); 551 dict.insert( "LastName", new int(Qtopia::LastName) );
552 dict.insert( "Suffix", new int(Qtopia::Suffix) ); 552 dict.insert( "Suffix", new int(Qtopia::Suffix) );
553 dict.insert( "FileAs", new int(Qtopia::FileAs) ); 553 dict.insert( "FileAs", new int(Qtopia::FileAs) );
554 dict.insert( "Categories", new int(Qtopia::AddressCategory) ); 554 dict.insert( "Categories", new int(Qtopia::AddressCategory) );
555 dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); 555 dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) );
556 dict.insert( "Emails", new int(Qtopia::Emails) ); 556 dict.insert( "Emails", new int(Qtopia::Emails) );
557 dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); 557 dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) );
558 dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); 558 dict.insert( "HomeCity", new int(Qtopia::HomeCity) );
559 dict.insert( "HomeState", new int(Qtopia::HomeState) ); 559 dict.insert( "HomeState", new int(Qtopia::HomeState) );
560 dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); 560 dict.insert( "HomeZip", new int(Qtopia::HomeZip) );
561 dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); 561 dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) );
562 dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); 562 dict.insert( "HomePhone", new int(Qtopia::HomePhone) );
563 dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); 563 dict.insert( "HomeFax", new int(Qtopia::HomeFax) );
564 dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); 564 dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) );
565 dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); 565 dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) );
566 dict.insert( "Company", new int(Qtopia::Company) ); 566 dict.insert( "Company", new int(Qtopia::Company) );
567 dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); 567 dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) );
568 dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); 568 dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) );
569 dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); 569 dict.insert( "BusinessState", new int(Qtopia::BusinessState) );
570 dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); 570 dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) );
571 dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); 571 dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) );
572 dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); 572 dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) );
573 dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); 573 dict.insert( "JobTitle", new int(Qtopia::JobTitle) );
574 dict.insert( "Department", new int(Qtopia::Department) ); 574 dict.insert( "Department", new int(Qtopia::Department) );
575 dict.insert( "Office", new int(Qtopia::Office) ); 575 dict.insert( "Office", new int(Qtopia::Office) );
576 dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); 576 dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) );
577 dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); 577 dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) );
578 dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); 578 dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) );
579 dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); 579 dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) );
580 dict.insert( "Profession", new int(Qtopia::Profession) ); 580 dict.insert( "Profession", new int(Qtopia::Profession) );
581 dict.insert( "Assistant", new int(Qtopia::Assistant) ); 581 dict.insert( "Assistant", new int(Qtopia::Assistant) );
582 dict.insert( "Manager", new int(Qtopia::Manager) ); 582 dict.insert( "Manager", new int(Qtopia::Manager) );
583 dict.insert( "Spouse", new int(Qtopia::Spouse) ); 583 dict.insert( "Spouse", new int(Qtopia::Spouse) );
584 dict.insert( "Children", new int(Qtopia::Children) ); 584 dict.insert( "Children", new int(Qtopia::Children) );
585 dict.insert( "Gender", new int(Qtopia::Gender) ); 585 dict.insert( "Gender", new int(Qtopia::Gender) );
586 dict.insert( "Birthday", new int(Qtopia::Birthday) ); 586 dict.insert( "Birthday", new int(Qtopia::Birthday) );
587 dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); 587 dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
588 dict.insert( "Nickname", new int(Qtopia::Nickname) ); 588 dict.insert( "Nickname", new int(Qtopia::Nickname) );
589 dict.insert( "Notes", new int(Qtopia::Notes) ); 589 dict.insert( "Notes", new int(Qtopia::Notes) );
590 dict.insert( "action", new int(JOURNALACTION) ); 590 dict.insert( "action", new int(JOURNALACTION) );
591 dict.insert( "actionrow", new int(JOURNALROW) ); 591 dict.insert( "actionrow", new int(JOURNALROW) );
592 592
593 //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() ); 593 //qWarning( "OPimContactDefaultBackEnd::loading %s", filename.latin1() );
594 594
595 XMLElement *root = XMLElement::load( filename ); 595 XMLElement *root = XMLElement::load( filename );
596 if(root != 0l ){ // start parsing 596 if(root != 0l ){ // start parsing
597 /* Parse all XML-Elements and put the data into the 597 /* Parse all XML-Elements and put the data into the
598 * Contact-Class 598 * Contact-Class
599 */ 599 */
600 XMLElement *element = root->firstChild(); 600 XMLElement *element = root->firstChild();
601 //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() ); 601 //qWarning("OPimContactAccess::load tagName(): %s", root->tagName().latin1() );
602 element = element->firstChild(); 602 element = element->firstChild();
603 603
604 /* Search Tag "Contacts" which is the parent of all Contacts */ 604 /* Search Tag "Contacts" which is the parent of all Contacts */
605 while( element && !isJournal ){ 605 while( element && !isJournal ){
606 if( element->tagName() != QString::fromLatin1("Contacts") ){ 606 if( element->tagName() != QString::fromLatin1("Contacts") ){
607 //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s", 607 //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
608 // element->tagName().latin1()); 608 // element->tagName().latin1());
609 element = element->nextChild(); 609 element = element->nextChild();
610 } else { 610 } else {
611 element = element->firstChild(); 611 element = element->firstChild();
612 break; 612 break;
613 } 613 }
614 } 614 }
615 /* Parse all Contacts and ignore unknown tags */ 615 /* Parse all Contacts and ignore unknown tags */
616 while( element ){ 616 while( element ){
617 if( element->tagName() != QString::fromLatin1("Contact") ){ 617 if( element->tagName() != QString::fromLatin1("Contact") ){
618 //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", 618 //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s",
619 // element->tagName().latin1()); 619 // element->tagName().latin1());
620 element = element->nextChild(); 620 element = element->nextChild();
621 continue; 621 continue;
622 } 622 }
623 /* Found alement with tagname "contact", now parse and store all 623 /* Found alement with tagname "contact", now parse and store all
624 * attributes contained 624 * attributes contained
625 */ 625 */
626 //qWarning("OContactDefBack::load element tagName() : %s", 626 //qWarning("OPimContactDefBack::load element tagName() : %s",
627 // element->tagName().latin1() ); 627 // element->tagName().latin1() );
628 QString dummy; 628 QString dummy;
629 foundAction = false; 629 foundAction = false;
630 630
631 XMLElement::AttributeMap aMap = element->attributes(); 631 XMLElement::AttributeMap aMap = element->attributes();
632 XMLElement::AttributeMap::Iterator it; 632 XMLElement::AttributeMap::Iterator it;
633 contactMap.clear(); 633 contactMap.clear();
634 customMap.clear(); 634 customMap.clear();
635 for( it = aMap.begin(); it != aMap.end(); ++it ){ 635 for( it = aMap.begin(); it != aMap.end(); ++it ){
636 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); 636 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
637 637
638 int *find = dict[ it.key() ]; 638 int *find = dict[ it.key() ];
639 /* Unknown attributes will be stored as "Custom" elements */ 639 /* Unknown attributes will be stored as "Custom" elements */
640 if ( !find ) { 640 if ( !find ) {
641 // qWarning("Attribute %s not known.", it.key().latin1()); 641 // qWarning("Attribute %s not known.", it.key().latin1());
642 //contact.setCustomField(it.key(), it.data()); 642 //contact.setCustomField(it.key(), it.data());
643 customMap.insert( it.key(), it.data() ); 643 customMap.insert( it.key(), it.data() );
644 continue; 644 continue;
645 } 645 }
646 646
647 /* Check if special conversion is needed and add attribute 647 /* Check if special conversion is needed and add attribute
648 * into Contact class 648 * into Contact class
649 */ 649 */
650 switch( *find ) { 650 switch( *find ) {
651 /* 651 /*
652 case Qtopia::AddressUid: 652 case Qtopia::AddressUid:
653 contact.setUid( it.data().toInt() ); 653 contact.setUid( it.data().toInt() );
654 break; 654 break;
655 case Qtopia::AddressCategory: 655 case Qtopia::AddressCategory:
656 contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); 656 contact.setCategories( Qtopia::Record::idsFromString( it.data( )));
657 break; 657 break;
658 */ 658 */
659 case JOURNALACTION: 659 case JOURNALACTION:
660 action = journal_action(it.data().toInt()); 660 action = journal_action(it.data().toInt());
661 foundAction = true; 661 foundAction = true;
662 qWarning ("ODefBack(journal)::ACTION found: %d", action); 662 qWarning ("ODefBack(journal)::ACTION found: %d", action);
663 break; 663 break;
664 case JOURNALROW: 664 case JOURNALROW:
665 journalKey = it.data().toInt(); 665 journalKey = it.data().toInt();
666 break; 666 break;
667 default: // no conversion needed add them to the map 667 default: // no conversion needed add them to the map
668 contactMap.insert( *find, it.data() ); 668 contactMap.insert( *find, it.data() );
669 break; 669 break;
670 } 670 }
671 } 671 }
672 /* now generate the Contact contact */ 672 /* now generate the Contact contact */
673 OContact contact( contactMap ); 673 OPimContact contact( contactMap );
674 674
675 for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { 675 for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
676 contact.setCustomField( customIt.key(), customIt.data() ); 676 contact.setCustomField( customIt.key(), customIt.data() );
677 } 677 }
678 678
679 if (foundAction){ 679 if (foundAction){
680 foundAction = false; 680 foundAction = false;
681 switch ( action ) { 681 switch ( action ) {
682 case ACTION_ADD: 682 case ACTION_ADD:
683 addContact_p (contact); 683 addContact_p (contact);
684 break; 684 break;
685 case ACTION_REMOVE: 685 case ACTION_REMOVE:
686 if ( !remove (contact.uid()) ) 686 if ( !remove (contact.uid()) )
687 qWarning ("ODefBack(journal)::Unable to remove uid: %d", 687 qWarning ("ODefBack(journal)::Unable to remove uid: %d",
688 contact.uid() ); 688 contact.uid() );
689 break; 689 break;
690 case ACTION_REPLACE: 690 case ACTION_REPLACE:
691 if ( !replace ( contact ) ) 691 if ( !replace ( contact ) )
692 qWarning ("ODefBack(journal)::Unable to replace uid: %d", 692 qWarning ("ODefBack(journal)::Unable to replace uid: %d",
693 contact.uid() ); 693 contact.uid() );
694 break; 694 break;
695 default: 695 default:
696 qWarning ("Unknown action: ignored !"); 696 qWarning ("Unknown action: ignored !");
697 break; 697 break;
698 } 698 }
699 }else{ 699 }else{
700 /* Add contact to list */ 700 /* Add contact to list */
701 addContact_p (contact); 701 addContact_p (contact);
702 } 702 }
703 703
704 /* Move to next element */ 704 /* Move to next element */
705 element = element->nextChild(); 705 element = element->nextChild();
706 } 706 }
707 }else { 707 }else {
708 qWarning("ODefBack::could not load"); 708 qWarning("ODefBack::could not load");
709 } 709 }
710 delete root; 710 delete root;
711 qWarning("returning from loading" ); 711 qWarning("returning from loading" );
712 return true; 712 return true;
713} 713}
714 714
715 715
716void OContactAccessBackend_XML::updateJournal( const OContact& cnt, 716void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt,
717 journal_action action ) 717 journal_action action )
718{ 718{
719 QFile f( m_journalName ); 719 QFile f( m_journalName );
720 bool created = !f.exists(); 720 bool created = !f.exists();
721 if ( !f.open(IO_WriteOnly|IO_Append) ) 721 if ( !f.open(IO_WriteOnly|IO_Append) )
722 return; 722 return;
723 723
724 QString buf; 724 QString buf;
725 QCString str; 725 QCString str;
726 726
727 // if the file was created, we have to set the Tag "<CONTACTS>" to 727 // if the file was created, we have to set the Tag "<CONTACTS>" to
728 // get a XML-File which is readable by our parser. 728 // get a XML-File which is readable by our parser.
729 // This is just a cheat, but better than rewrite the parser. 729 // This is just a cheat, but better than rewrite the parser.
730 if ( created ){ 730 if ( created ){
731 buf = "<Contacts>"; 731 buf = "<Contacts>";
732 QCString cstr = buf.utf8(); 732 QCString cstr = buf.utf8();
733 f.writeBlock( cstr.data(), cstr.length() ); 733 f.writeBlock( cstr.data(), cstr.length() );
734 } 734 }
735 735
736 buf = "<Contact "; 736 buf = "<Contact ";
737 cnt.save( buf ); 737 cnt.save( buf );
738 buf += " action=\"" + QString::number( (int)action ) + "\" "; 738 buf += " action=\"" + QString::number( (int)action ) + "\" ";
739 buf += "/>\n"; 739 buf += "/>\n";
740 QCString cstr = buf.utf8(); 740 QCString cstr = buf.utf8();
741 f.writeBlock( cstr.data(), cstr.length() ); 741 f.writeBlock( cstr.data(), cstr.length() );
742} 742}
743 743
744void OContactAccessBackend_XML::removeJournal() 744void OPimContactAccessBackend_XML::removeJournal()
745{ 745{
746 QFile f ( m_journalName ); 746 QFile f ( m_journalName );
747 if ( f.exists() ) 747 if ( f.exists() )
748 f.remove(); 748 f.remove();
749} 749}
750 750
751} 751}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index f439c4c..eaea352 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -1,108 +1,108 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#ifndef _OContactAccessBackend_XML_ 33#ifndef _OPimContactAccessBackend_XML_
34#define _OContactAccessBackend_XML_ 34#define _OPimContactAccessBackend_XML_
35 35
36#include <opie2/ocontactaccessbackend.h> 36#include <opie2/ocontactaccessbackend.h>
37#include <opie2/ocontactaccess.h> 37#include <opie2/ocontactaccess.h>
38 38
39#include <qlist.h> 39#include <qlist.h>
40#include <qdict.h> 40#include <qdict.h>
41 41
42namespace Opie { 42namespace Opie {
43/* the default xml implementation */ 43/* the default xml implementation */
44/** 44/**
45 * This class is the XML implementation of a Contact backend 45 * This class is the XML implementation of a Contact backend
46 * it does implement everything available for OContact. 46 * it does implement everything available for OPimContact.
47 * @see OPimAccessBackend for more information of available methods 47 * @see OPimAccessBackend for more information of available methods
48 */ 48 */
49class OContactAccessBackend_XML : public OContactAccessBackend { 49class OPimContactAccessBackend_XML : public OPimContactAccessBackend {
50 public: 50 public:
51 OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); 51 OPimContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
52 52
53 bool save(); 53 bool save();
54 54
55 bool load (); 55 bool load ();
56 56
57 void clear (); 57 void clear ();
58 58
59 bool wasChangedExternally(); 59 bool wasChangedExternally();
60 60
61 QArray<int> allRecords() const; 61 QArray<int> allRecords() const;
62 62
63 OContact find ( int uid ) const; 63 OPimContact find ( int uid ) const;
64 64
65 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); 65 QArray<int> queryByExample ( const OPimContact &query, int settings, const QDateTime& d = QDateTime() );
66 66
67 QArray<int> matchRegexp( const QRegExp &r ) const; 67 QArray<int> matchRegexp( const QRegExp &r ) const;
68 68
69 const uint querySettings(); 69 const uint querySettings();
70 70
71 bool hasQuerySettings (uint querySettings) const; 71 bool hasQuerySettings (uint querySettings) const;
72 72
73 // Currently only asc implemented.. 73 // Currently only asc implemented..
74 QArray<int> sorted( bool asc, int , int , int ); 74 QArray<int> sorted( bool asc, int , int , int );
75 bool add ( const OContact &newcontact ); 75 bool add ( const OPimContact &newcontact );
76 76
77 bool replace ( const OContact &contact ); 77 bool replace ( const OPimContact &contact );
78 78
79 bool remove ( int uid ); 79 bool remove ( int uid );
80 bool reload(); 80 bool reload();
81 81
82 private: 82 private:
83 83
84 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 84 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
85 85
86 void addContact_p( const OContact &newcontact ); 86 void addContact_p( const OPimContact &newcontact );
87 87
88 /* This function loads the xml-database and the journalfile */ 88 /* This function loads the xml-database and the journalfile */
89 bool load( const QString filename, bool isJournal ); 89 bool load( const QString filename, bool isJournal );
90 90
91 91
92 void updateJournal( const OContact& cnt, journal_action action ); 92 void updateJournal( const OPimContact& cnt, journal_action action );
93 void removeJournal(); 93 void removeJournal();
94 94
95 protected: 95 protected:
96 bool m_changed; 96 bool m_changed;
97 QString m_journalName; 97 QString m_journalName;
98 QString m_fileName; 98 QString m_fileName;
99 QString m_appName; 99 QString m_appName;
100 QList<OContact> m_contactList; 100 QList<OPimContact> m_contactList;
101 QDateTime m_readtime; 101 QDateTime m_readtime;
102 102
103 QDict<OContact> m_uidToContact; 103 QDict<OPimContact> m_uidToContact;
104}; 104};
105 105
106} 106}
107 107
108#endif 108#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index 9bf4bf0..f3b7b5f 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -1,216 +1,216 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qtl.h> 29#include <qtl.h>
30 30
31#include <opie2/orecur.h> 31#include <opie2/opimrecurrence.h>
32 32
33#include <opie2/odatebookaccessbackend.h> 33#include <opie2/odatebookaccessbackend.h>
34 34
35using namespace Opie; 35using namespace Opie;
36 36
37namespace { 37namespace {
38/* a small helper to get all NonRepeating events for a range of time */ 38/* a small helper to get all NonRepeating events for a range of time */
39 void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, 39 void events( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& events,
40 const QDate& from, const QDate& to ) { 40 const QDate& from, const QDate& to ) {
41 QDateTime dtStart, dtEnd; 41 QDateTime dtStart, dtEnd;
42 42
43 for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { 43 for ( OPimEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
44 dtStart = (*it).startDateTime(); 44 dtStart = (*it).startDateTime();
45 dtEnd = (*it).endDateTime(); 45 dtEnd = (*it).endDateTime();
46 46
47 /* 47 /*
48 * If in range 48 * If in range
49 */ 49 */
50 if (dtStart.date() >= from && dtEnd.date() <= to ) { 50 if (dtStart.date() >= from && dtEnd.date() <= to ) {
51 OEffectiveEvent eff; 51 OEffectiveEvent eff;
52 eff.setEvent( (*it) ); 52 eff.setEvent( (*it) );
53 eff.setDate( dtStart.date() ); 53 eff.setDate( dtStart.date() );
54 eff.setStartTime( dtStart.time() ); 54 eff.setStartTime( dtStart.time() );
55 55
56 /* if not on the same day */ 56 /* if not on the same day */
57 if ( dtStart.date() != dtEnd.date() ) 57 if ( dtStart.date() != dtEnd.date() )
58 eff.setEndTime( QTime(23, 59, 0 ) ); 58 eff.setEndTime( QTime(23, 59, 0 ) );
59 else 59 else
60 eff.setEndTime( dtEnd.time() ); 60 eff.setEndTime( dtEnd.time() );
61 61
62 tmpList.append( eff ); 62 tmpList.append( eff );
63 } 63 }
64 64
65 /* we must also check for end date information... */ 65 /* we must also check for end date information... */
66 if ( dtEnd.date() != dtStart.date() && dtEnd.date() >= from ) { 66 if ( dtEnd.date() != dtStart.date() && dtEnd.date() >= from ) {
67 QDateTime dt = dtStart.addDays( 1 ); 67 QDateTime dt = dtStart.addDays( 1 );
68 dt.setTime( QTime(0, 0, 0 ) ); 68 dt.setTime( QTime(0, 0, 0 ) );
69 QDateTime dtStop; 69 QDateTime dtStop;
70 if ( dtEnd > to ) 70 if ( dtEnd > to )
71 dtStop = to; 71 dtStop = to;
72 else 72 else
73 dtStop = dtEnd; 73 dtStop = dtEnd;
74 74
75 while ( dt <= dtStop ) { 75 while ( dt <= dtStop ) {
76 OEffectiveEvent eff; 76 OEffectiveEvent eff;
77 eff.setEvent( (*it) ); 77 eff.setEvent( (*it) );
78 eff.setDate( dt.date() ); 78 eff.setDate( dt.date() );
79 79
80 if ( dt >= from ) { 80 if ( dt >= from ) {
81 eff.setStartTime( QTime(0, 0, 0 ) ); 81 eff.setStartTime( QTime(0, 0, 0 ) );
82 if ( dt.date() == dtEnd.date() ) 82 if ( dt.date() == dtEnd.date() )
83 eff.setEndTime( dtEnd.time() ); 83 eff.setEndTime( dtEnd.time() );
84 else 84 else
85 eff.setEndTime( QTime(23, 59, 0 ) ); 85 eff.setEndTime( QTime(23, 59, 0 ) );
86 tmpList.append( eff ); 86 tmpList.append( eff );
87 } 87 }
88 dt = dt.addDays( 1 ); 88 dt = dt.addDays( 1 );
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 void repeat( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& list, 94 void repeat( OEffectiveEvent::ValueList& tmpList, const OPimEvent::ValueList& list,
95 const QDate& from, const QDate& to ) { 95 const QDate& from, const QDate& to ) {
96 QDate repeat; 96 QDate repeat;
97 for ( OEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 97 for ( OPimEvent::ValueList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
98 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() ); 98 int dur = (*it).startDateTime().date().daysTo( (*it).endDateTime().date() );
99 QDate itDate = from.addDays(-dur ); 99 QDate itDate = from.addDays(-dur );
100 ORecur rec = (*it).recurrence(); 100 OPimRecurrence rec = (*it).recurrence();
101 if ( !rec.hasEndDate() || rec.endDate() > to ) { 101 if ( !rec.hasEndDate() || rec.endDate() > to ) {
102 rec.setEndDate( to ); 102 rec.setEndDate( to );
103 rec.setHasEndDate( true ); 103 rec.setHasEndDate( true );
104 } 104 }
105 while (rec.nextOcurrence(itDate, repeat ) ) { 105 while (rec.nextOcurrence(itDate, repeat ) ) {
106 if (repeat > to ) break; 106 if (repeat > to ) break;
107 OEffectiveEvent eff; 107 OEffectiveEvent eff;
108 eff.setDate( repeat ); 108 eff.setDate( repeat );
109 if ( (*it).isAllDay() ) { 109 if ( (*it).isAllDay() ) {
110 eff.setStartTime( QTime(0, 0, 0 ) ); 110 eff.setStartTime( QTime(0, 0, 0 ) );
111 eff.setEndTime( QTime(23, 59, 59 ) ); 111 eff.setEndTime( QTime(23, 59, 59 ) );
112 }else { 112 }else {
113 /* we only occur by days, not hours/minutes/seconds. Hence 113 /* we only occur by days, not hours/minutes/seconds. Hence
114 * the actual end and start times will be the same for 114 * the actual end and start times will be the same for
115 * every repeated event. For multi day events this is 115 * every repeated event. For multi day events this is
116 * fixed up later if on wronge day span 116 * fixed up later if on wronge day span
117 */ 117 */
118 eff.setStartTime( (*it).startDateTime().time() ); 118 eff.setStartTime( (*it).startDateTime().time() );
119 eff.setEndTime( (*it).endDateTime().time() ); 119 eff.setEndTime( (*it).endDateTime().time() );
120 } 120 }
121 if ( dur != 0 ) { 121 if ( dur != 0 ) {
122 // multi-day repeating events 122 // multi-day repeating events
123 QDate sub_it = QMAX( repeat, from ); 123 QDate sub_it = QMAX( repeat, from );
124 QDate startDate = repeat; 124 QDate startDate = repeat;
125 QDate endDate = startDate.addDays( dur ); 125 QDate endDate = startDate.addDays( dur );
126 126
127 while ( sub_it <= endDate && sub_it <= to ) { 127 while ( sub_it <= endDate && sub_it <= to ) {
128 OEffectiveEvent tmpEff = eff; 128 OEffectiveEvent tmpEff = eff;
129 tmpEff.setEvent( (*it) ); 129 tmpEff.setEvent( (*it) );
130 if ( sub_it != startDate ) 130 if ( sub_it != startDate )
131 tmpEff.setStartTime( QTime(0, 0, 0 ) ); 131 tmpEff.setStartTime( QTime(0, 0, 0 ) );
132 if ( sub_it != endDate ) 132 if ( sub_it != endDate )
133 tmpEff.setEndTime( QTime( 23, 59, 59 ) ); 133 tmpEff.setEndTime( QTime( 23, 59, 59 ) );
134 134
135 tmpEff.setDate( sub_it ); 135 tmpEff.setDate( sub_it );
136 tmpEff.setEffectiveDates( startDate, endDate ); 136 tmpEff.setEffectiveDates( startDate, endDate );
137 tmpList.append( tmpEff ); 137 tmpList.append( tmpEff );
138 138
139 sub_it = sub_it.addDays( 1 ); 139 sub_it = sub_it.addDays( 1 );
140 } 140 }
141 itDate = endDate; 141 itDate = endDate;
142 }else { 142 }else {
143 eff.setEvent( (*it) ); 143 eff.setEvent( (*it) );
144 tmpList.append( eff ); 144 tmpList.append( eff );
145 itDate = repeat.addDays( 1 ); 145 itDate = repeat.addDays( 1 );
146 } 146 }
147 } 147 }
148 } 148 }
149 } 149 }
150} 150}
151 151
152namespace Opie { 152namespace Opie {
153 153
154ODateBookAccessBackend::ODateBookAccessBackend() 154ODateBookAccessBackend::ODateBookAccessBackend()
155 : OPimAccessBackend<OEvent>() 155 : OPimAccessBackend<OPimEvent>()
156{ 156{
157 157
158} 158}
159ODateBookAccessBackend::~ODateBookAccessBackend() { 159ODateBookAccessBackend::~ODateBookAccessBackend() {
160 160
161} 161}
162OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, 162OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from,
163 const QDate& to ) { 163 const QDate& to ) {
164 OEffectiveEvent::ValueList tmpList; 164 OEffectiveEvent::ValueList tmpList;
165 OEvent::ValueList list = directNonRepeats(); 165 OPimEvent::ValueList list = directNonRepeats();
166 166
167 events( tmpList, list, from, to ); 167 events( tmpList, list, from, to );
168 repeat( tmpList, directRawRepeats(),from,to ); 168 repeat( tmpList, directRawRepeats(),from,to );
169 169
170 list = directRawRepeats(); // Useless, isn't it ? (eilers) 170 list = directRawRepeats(); // Useless, isn't it ? (eilers)
171 171
172 qHeapSort( tmpList ); 172 qHeapSort( tmpList );
173 return tmpList; 173 return tmpList;
174} 174}
175OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { 175OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) {
176 OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); 176 OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() );
177 OEffectiveEvent::ValueList::Iterator it; 177 OEffectiveEvent::ValueList::Iterator it;
178 178
179 OEffectiveEvent::ValueList tmpList; 179 OEffectiveEvent::ValueList tmpList;
180 QDateTime dtTmp; 180 QDateTime dtTmp;
181 for ( it = day.begin(); it != day.end(); ++it ) { 181 for ( it = day.begin(); it != day.end(); ++it ) {
182 dtTmp = QDateTime( (*it).date(), (*it).startTime() ); 182 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
183 if ( QABS(dt.secsTo(dtTmp) ) < 60 ) 183 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
184 tmpList.append( (*it) ); 184 tmpList.append( (*it) );
185 } 185 }
186 186
187 return tmpList; 187 return tmpList;
188} 188}
189 189
190OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from, 190OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDate& from,
191 const QDate& to ) { 191 const QDate& to ) {
192 OEffectiveEvent::ValueList tmpList; 192 OEffectiveEvent::ValueList tmpList;
193 OEvent::ValueList list = directNonRepeats(); 193 OPimEvent::ValueList list = directNonRepeats();
194 194
195 events( tmpList, list, from, to ); 195 events( tmpList, list, from, to );
196 196
197 qHeapSort( tmpList ); 197 qHeapSort( tmpList );
198 return tmpList; 198 return tmpList;
199} 199}
200 200
201OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { 201OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) {
202 OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); 202 OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
203 OEffectiveEvent::ValueList::Iterator it; 203 OEffectiveEvent::ValueList::Iterator it;
204 204
205 OEffectiveEvent::ValueList tmpList; 205 OEffectiveEvent::ValueList tmpList;
206 QDateTime dtTmp; 206 QDateTime dtTmp;
207 for ( it = day.begin(); it != day.end(); ++it ) { 207 for ( it = day.begin(); it != day.end(); ++it ) {
208 dtTmp = QDateTime( (*it).date(), (*it).startTime() ); 208 dtTmp = QDateTime( (*it).date(), (*it).startTime() );
209 if ( QABS(dt.secsTo(dtTmp) ) < 60 ) 209 if ( QABS(dt.secsTo(dtTmp) ) < 60 )
210 tmpList.append( (*it) ); 210 tmpList.append( (*it) );
211 } 211 }
212 212
213 return tmpList; 213 return tmpList;
214} 214}
215 215
216} 216}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index 6853670..a9cce6a 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -1,121 +1,121 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H 29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H
30#define OPIE_DATE_BOOK_ACCESS_BACKEND_H 30#define OPIE_DATE_BOOK_ACCESS_BACKEND_H
31 31
32#include <qarray.h> 32#include <qarray.h>
33 33
34#include <opie2/opimaccessbackend.h> 34#include <opie2/opimaccessbackend.h>
35#include <opie2/oevent.h> 35#include <opie2/opimevent.h>
36 36
37namespace Opie { 37namespace Opie {
38/** 38/**
39 * This class is the interface to the storage of Events. 39 * This class is the interface to the storage of Events.
40 * @see OPimAccessBackend 40 * @see OPimAccessBackend
41 * 41 *
42 */ 42 */
43class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { 43class ODateBookAccessBackend : public OPimAccessBackend<OPimEvent> {
44public: 44public:
45 typedef int UID; 45 typedef int UID;
46 46
47 /** 47 /**
48 * c'tor without parameter 48 * c'tor without parameter
49 */ 49 */
50 ODateBookAccessBackend(); 50 ODateBookAccessBackend();
51 ~ODateBookAccessBackend(); 51 ~ODateBookAccessBackend();
52 52
53 /** 53 /**
54 * This method should return a list of UIDs containing 54 * This method should return a list of UIDs containing
55 * all events. No filter should be applied 55 * all events. No filter should be applied
56 * @return list of events 56 * @return list of events
57 */ 57 */
58 virtual QArray<UID> rawEvents()const = 0; 58 virtual QArray<UID> rawEvents()const = 0;
59 59
60 /** 60 /**
61 * This method should return a list of UIDs containing 61 * This method should return a list of UIDs containing
62 * all repeating events. No filter should be applied 62 * all repeating events. No filter should be applied
63 * @return list of repeating events 63 * @return list of repeating events
64 */ 64 */
65 virtual QArray<UID> rawRepeats()const = 0; 65 virtual QArray<UID> rawRepeats()const = 0;
66 66
67 /** 67 /**
68 * This mthod should return a list of UIDs containing all non 68 * This mthod should return a list of UIDs containing all non
69 * repeating events. No filter should be applied 69 * repeating events. No filter should be applied
70 * @return list of nonrepeating events 70 * @return list of nonrepeating events
71 */ 71 */
72 virtual QArray<UID> nonRepeats() const = 0; 72 virtual QArray<UID> nonRepeats() const = 0;
73 73
74 /** 74 /**
75 * If you do not want to implement the effectiveEvents methods below 75 * If you do not want to implement the effectiveEvents methods below
76 * you need to supply it with directNonRepeats. 76 * you need to supply it with directNonRepeats.
77 * This method can return empty lists if effectiveEvents is implememted 77 * This method can return empty lists if effectiveEvents is implememted
78 */ 78 */
79 virtual OEvent::ValueList directNonRepeats() = 0; 79 virtual OPimEvent::ValueList directNonRepeats() = 0;
80 80
81 /** 81 /**
82 * Same as above but return raw repeats! 82 * Same as above but return raw repeats!
83 */ 83 */
84 virtual OEvent::ValueList directRawRepeats() = 0; 84 virtual OPimEvent::ValueList directRawRepeats() = 0;
85 85
86 /* is implemented by default but you can reimplement it*/ 86 /* is implemented by default but you can reimplement it*/
87 /** 87 /**
88 * Effective Events are special event occuring during a time frame. This method does calcualte 88 * Effective Events are special event occuring during a time frame. This method does calcualte
89 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method 89 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
90 * yourself 90 * yourself
91 */ 91 */
92 virtual OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ); 92 virtual OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to );
93 93
94 /** 94 /**
95 * this is an overloaded member function 95 * this is an overloaded member function
96 * @see effectiveEvents( const QDate& from, const QDate& to ) 96 * @see effectiveEvents( const QDate& from, const QDate& to )
97 */ 97 */
98 virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ); 98 virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start );
99 99
100 /** 100 /**
101 * Effective Events are special event occuring during a time frame. This method does calcualte 101 * Effective Events are special event occuring during a time frame. This method does calcualte
102 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method 102 * EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
103 * yourself 103 * yourself
104 */ 104 */
105 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ); 105 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to );
106 106
107 /** 107 /**
108 * this is an overloaded member function 108 * this is an overloaded member function
109 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) 109 * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to )
110 */ 110 */
111 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ); 111 virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start );
112 112
113private: 113private:
114 class Private; 114 class Private;
115 Private *d; 115 Private *d;
116 116
117}; 117};
118 118
119} 119}
120 120
121#endif 121#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index e79696c..2ee76cc 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -1,366 +1,366 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * SQL Backend for the OPIE-Calender Database. 30 * SQL Backend for the OPIE-Calender Database.
31 * 31 *
32 */ 32 */
33 33
34#include <stdio.h> 34#include <stdio.h>
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include <qarray.h> 37#include <qarray.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39 39
40#include <qpe/global.h> 40#include <qpe/global.h>
41 41
42#include <opie2/osqldriver.h> 42#include <opie2/osqldriver.h>
43#include <opie2/osqlmanager.h> 43#include <opie2/osqlmanager.h>
44#include <opie2/osqlquery.h> 44#include <opie2/osqlquery.h>
45 45
46#include <opie2/orecur.h> 46#include <opie2/opimrecurrence.h>
47#include <opie2/odatebookaccessbackend_sql.h> 47#include <opie2/odatebookaccessbackend_sql.h>
48 48
49namespace Opie { 49namespace Opie {
50 50
51 51
52ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , 52ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
53 const QString& fileName ) 53 const QString& fileName )
54 : ODateBookAccessBackend(), m_driver( NULL ) 54 : ODateBookAccessBackend(), m_driver( NULL )
55{ 55{
56 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; 56 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
57 57
58 // Get the standart sql-driver from the OSQLManager.. 58 // Get the standart sql-driver from the OSQLManager..
59 OSQLManager man; 59 OSQLManager man;
60 m_driver = man.standard(); 60 m_driver = man.standard();
61 m_driver->setUrl( m_fileName ); 61 m_driver->setUrl( m_fileName );
62 62
63 initFields(); 63 initFields();
64 64
65 load(); 65 load();
66} 66}
67 67
68ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { 68ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
69 if( m_driver ) 69 if( m_driver )
70 delete m_driver; 70 delete m_driver;
71} 71}
72 72
73void ODateBookAccessBackend_SQL::initFields() 73void ODateBookAccessBackend_SQL::initFields()
74{ 74{
75 75
76 // This map contains the translation of the fieldtype id's to 76 // This map contains the translation of the fieldtype id's to
77 // the names of the table columns 77 // the names of the table columns
78 m_fieldMap.insert( OEvent::FUid, "uid" ); 78 m_fieldMap.insert( OPimEvent::FUid, "uid" );
79 m_fieldMap.insert( OEvent::FCategories, "Categories" ); 79 m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
80 m_fieldMap.insert( OEvent::FDescription, "Description" ); 80 m_fieldMap.insert( OPimEvent::FDescription, "Description" );
81 m_fieldMap.insert( OEvent::FLocation, "Location" ); 81 m_fieldMap.insert( OPimEvent::FLocation, "Location" );
82 m_fieldMap.insert( OEvent::FType, "Type" ); 82 m_fieldMap.insert( OPimEvent::FType, "Type" );
83 m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); 83 m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
84 m_fieldMap.insert( OEvent::FSound, "Sound" ); 84 m_fieldMap.insert( OPimEvent::FSound, "Sound" );
85 m_fieldMap.insert( OEvent::FRType, "RType" ); 85 m_fieldMap.insert( OPimEvent::FRType, "RType" );
86 m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); 86 m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
87 m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); 87 m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
88 m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); 88 m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
89 m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); 89 m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
90 m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); 90 m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
91 m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); 91 m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
92 m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); 92 m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
93 m_fieldMap.insert( OEvent::FStart, "Start" ); 93 m_fieldMap.insert( OPimEvent::FStart, "Start" );
94 m_fieldMap.insert( OEvent::FEnd, "End" ); 94 m_fieldMap.insert( OPimEvent::FEnd, "End" );
95 m_fieldMap.insert( OEvent::FNote, "Note" ); 95 m_fieldMap.insert( OPimEvent::FNote, "Note" );
96 m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); 96 m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
97 m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); 97 m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
98 m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); 98 m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
99 99
100 // Create a map that maps the column name to the id 100 // Create a map that maps the column name to the id
101 QMapConstIterator<int, QString> it; 101 QMapConstIterator<int, QString> it;
102 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 102 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
103 m_reverseFieldMap.insert( it.data(), it.key() ); 103 m_reverseFieldMap.insert( it.data(), it.key() );
104 } 104 }
105 105
106} 106}
107 107
108bool ODateBookAccessBackend_SQL::load() 108bool ODateBookAccessBackend_SQL::load()
109{ 109{
110 if (!m_driver->open() ) 110 if (!m_driver->open() )
111 return false; 111 return false;
112 112
113 // Don't expect that the database exists. 113 // Don't expect that the database exists.
114 // It is save here to create the table, even if it 114 // It is save here to create the table, even if it
115 // do exist. ( Is that correct for all databases ?? ) 115 // do exist. ( Is that correct for all databases ?? )
116 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY "; 116 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY ";
117 117
118 QMap<int, QString>::Iterator it; 118 QMap<int, QString>::Iterator it;
119 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 119 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
120 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); 120 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
121 } 121 }
122 qu += " );"; 122 qu += " );";
123 123
124 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 124 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
125 125
126 qWarning( "command: %s", qu.latin1() ); 126 qWarning( "command: %s", qu.latin1() );
127 127
128 OSQLRawQuery raw( qu ); 128 OSQLRawQuery raw( qu );
129 OSQLResult res = m_driver->query( &raw ); 129 OSQLResult res = m_driver->query( &raw );
130 if ( res.state() != OSQLResult::Success ) 130 if ( res.state() != OSQLResult::Success )
131 return false; 131 return false;
132 132
133 update(); 133 update();
134 134
135 return true; 135 return true;
136} 136}
137 137
138void ODateBookAccessBackend_SQL::update() 138void ODateBookAccessBackend_SQL::update()
139{ 139{
140 140
141 QString qu = "select uid from datebook"; 141 QString qu = "select uid from datebook";
142 OSQLRawQuery raw( qu ); 142 OSQLRawQuery raw( qu );
143 OSQLResult res = m_driver->query( &raw ); 143 OSQLResult res = m_driver->query( &raw );
144 if ( res.state() != OSQLResult::Success ){ 144 if ( res.state() != OSQLResult::Success ){
145 // m_uids.clear(); 145 // m_uids.clear();
146 return; 146 return;
147 } 147 }
148 148
149 m_uids = extractUids( res ); 149 m_uids = extractUids( res );
150 150
151} 151}
152 152
153bool ODateBookAccessBackend_SQL::reload() 153bool ODateBookAccessBackend_SQL::reload()
154{ 154{
155 return load(); 155 return load();
156} 156}
157 157
158bool ODateBookAccessBackend_SQL::save() 158bool ODateBookAccessBackend_SQL::save()
159{ 159{
160 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 160 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
161} 161}
162 162
163QArray<int> ODateBookAccessBackend_SQL::allRecords()const 163QArray<int> ODateBookAccessBackend_SQL::allRecords()const
164{ 164{
165 return m_uids; 165 return m_uids;
166} 166}
167 167
168QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { 168QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) {
169 return QArray<int>(); 169 return QArray<int>();
170} 170}
171 171
172void ODateBookAccessBackend_SQL::clear() 172void ODateBookAccessBackend_SQL::clear()
173{ 173{
174 QString qu = "drop table datebook;"; 174 QString qu = "drop table datebook;";
175 qu += "drop table custom_data;"; 175 qu += "drop table custom_data;";
176 176
177 OSQLRawQuery raw( qu ); 177 OSQLRawQuery raw( qu );
178 OSQLResult res = m_driver->query( &raw ); 178 OSQLResult res = m_driver->query( &raw );
179 179
180 reload(); 180 reload();
181} 181}
182 182
183 183
184OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ 184OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
185 QString qu = "select *"; 185 QString qu = "select *";
186 qu += "from datebook where uid = " + QString::number(uid); 186 qu += "from datebook where uid = " + QString::number(uid);
187 187
188 OSQLRawQuery raw( qu ); 188 OSQLRawQuery raw( qu );
189 OSQLResult res = m_driver->query( &raw ); 189 OSQLResult res = m_driver->query( &raw );
190 190
191 OSQLResultItem resItem = res.first(); 191 OSQLResultItem resItem = res.first();
192 192
193 // Create Map for date event and insert UID 193 // Create Map for date event and insert UID
194 QMap<int,QString> dateEventMap; 194 QMap<int,QString> dateEventMap;
195 dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); 195 dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
196 196
197 // Now insert the data out of the columns into the map. 197 // Now insert the data out of the columns into the map.
198 QMapConstIterator<int, QString> it; 198 QMapConstIterator<int, QString> it;
199 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 199 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
200 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); 200 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
201 } 201 }
202 202
203 // Last step: Put map into date event and return it 203 // Last step: Put map into date event and return it
204 OEvent retDate( dateEventMap ); 204 OPimEvent retDate( dateEventMap );
205 205
206 return retDate; 206 return retDate;
207} 207}
208 208
209// FIXME: Speed up update of uid's.. 209// FIXME: Speed up update of uid's..
210bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) 210bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
211{ 211{
212 QMap<int,QString> eventMap = ev.toMap(); 212 QMap<int,QString> eventMap = ev.toMap();
213 213
214 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); 214 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
215 QMap<int, QString>::Iterator it; 215 QMap<int, QString>::Iterator it;
216 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 216 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
217 if ( !eventMap[it.key()].isEmpty() ) 217 if ( !eventMap[it.key()].isEmpty() )
218 qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); 218 qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] );
219 else 219 else
220 qu += QString( ",\"\"" ); 220 qu += QString( ",\"\"" );
221 } 221 }
222 qu += " );"; 222 qu += " );";
223 223
224 // Add custom entries 224 // Add custom entries
225 int id = 0; 225 int id = 0;
226 QMap<QString, QString> customMap = ev.toExtraMap(); 226 QMap<QString, QString> customMap = ev.toExtraMap();
227 for( QMap<QString, QString>::Iterator it = customMap.begin(); 227 for( QMap<QString, QString>::Iterator it = customMap.begin();
228 it != customMap.end(); ++it ){ 228 it != customMap.end(); ++it ){
229 qu += "insert into custom_data VALUES(" 229 qu += "insert into custom_data VALUES("
230 + QString::number( ev.uid() ) 230 + QString::number( ev.uid() )
231 + "," 231 + ","
232 + QString::number( id++ ) 232 + QString::number( id++ )
233 + ",'" 233 + ",'"
234 + it.key() //.latin1() 234 + it.key() //.latin1()
235 + "'," 235 + "',"
236 + "0" // Priority for future enhancements 236 + "0" // Priority for future enhancements
237 + ",'" 237 + ",'"
238 + it.data() //.latin1() 238 + it.data() //.latin1()
239 + "');"; 239 + "');";
240 } 240 }
241 qWarning("add %s", qu.latin1() ); 241 qWarning("add %s", qu.latin1() );
242 242
243 OSQLRawQuery raw( qu ); 243 OSQLRawQuery raw( qu );
244 OSQLResult res = m_driver->query( &raw ); 244 OSQLResult res = m_driver->query( &raw );
245 if ( res.state() != OSQLResult::Success ){ 245 if ( res.state() != OSQLResult::Success ){
246 return false; 246 return false;
247 } 247 }
248 248
249 // Update list of uid's 249 // Update list of uid's
250 update(); 250 update();
251 251
252 return true; 252 return true;
253} 253}
254 254
255// FIXME: Speed up update of uid's.. 255// FIXME: Speed up update of uid's..
256bool ODateBookAccessBackend_SQL::remove( int uid ) 256bool ODateBookAccessBackend_SQL::remove( int uid )
257{ 257{
258 QString qu = "DELETE from datebook where uid = " 258 QString qu = "DELETE from datebook where uid = "
259 + QString::number( uid ) + ";"; 259 + QString::number( uid ) + ";";
260 qu += "DELETE from custom_data where uid = " 260 qu += "DELETE from custom_data where uid = "
261 + QString::number( uid ) + ";"; 261 + QString::number( uid ) + ";";
262 262
263 OSQLRawQuery raw( qu ); 263 OSQLRawQuery raw( qu );
264 OSQLResult res = m_driver->query( &raw ); 264 OSQLResult res = m_driver->query( &raw );
265 if ( res.state() != OSQLResult::Success ){ 265 if ( res.state() != OSQLResult::Success ){
266 return false; 266 return false;
267 } 267 }
268 268
269 // Update list of uid's 269 // Update list of uid's
270 update(); 270 update();
271 271
272 return true; 272 return true;
273} 273}
274 274
275bool ODateBookAccessBackend_SQL::replace( const OEvent& ev ) 275bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
276{ 276{
277 remove( ev.uid() ); 277 remove( ev.uid() );
278 return add( ev ); 278 return add( ev );
279} 279}
280 280
281QArray<int> ODateBookAccessBackend_SQL::rawEvents()const 281QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
282{ 282{
283 return allRecords(); 283 return allRecords();
284} 284}
285 285
286QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const 286QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
287{ 287{
288 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\""; 288 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
289 OSQLRawQuery raw( qu ); 289 OSQLRawQuery raw( qu );
290 OSQLResult res = m_driver->query( &raw ); 290 OSQLResult res = m_driver->query( &raw );
291 if ( res.state() != OSQLResult::Success ){ 291 if ( res.state() != OSQLResult::Success ){
292 QArray<int> nix; 292 QArray<int> nix;
293 return nix; 293 return nix;
294 } 294 }
295 295
296 return extractUids( res ); 296 return extractUids( res );
297} 297}
298 298
299QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const 299QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
300{ 300{
301 QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\""; 301 QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\"";
302 OSQLRawQuery raw( qu ); 302 OSQLRawQuery raw( qu );
303 OSQLResult res = m_driver->query( &raw ); 303 OSQLResult res = m_driver->query( &raw );
304 if ( res.state() != OSQLResult::Success ){ 304 if ( res.state() != OSQLResult::Success ){
305 QArray<int> nix; 305 QArray<int> nix;
306 return nix; 306 return nix;
307 } 307 }
308 308
309 return extractUids( res ); 309 return extractUids( res );
310} 310}
311 311
312OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() 312OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
313{ 313{
314 QArray<int> nonRepUids = nonRepeats(); 314 QArray<int> nonRepUids = nonRepeats();
315 OEvent::ValueList list; 315 OPimEvent::ValueList list;
316 316
317 for (uint i = 0; i < nonRepUids.count(); ++i ){ 317 for (uint i = 0; i < nonRepUids.count(); ++i ){
318 list.append( find( nonRepUids[i] ) ); 318 list.append( find( nonRepUids[i] ) );
319 } 319 }
320 320
321 return list; 321 return list;
322 322
323} 323}
324OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() 324OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
325{ 325{
326 QArray<int> rawRepUids = rawRepeats(); 326 QArray<int> rawRepUids = rawRepeats();
327 OEvent::ValueList list; 327 OPimEvent::ValueList list;
328 328
329 for (uint i = 0; i < rawRepUids.count(); ++i ){ 329 for (uint i = 0; i < rawRepUids.count(); ++i ){
330 list.append( find( rawRepUids[i] ) ); 330 list.append( find( rawRepUids[i] ) );
331 } 331 }
332 332
333 return list; 333 return list;
334} 334}
335 335
336 336
337QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 337QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
338{ 338{
339 QArray<int> null; 339 QArray<int> null;
340 return null; 340 return null;
341} 341}
342 342
343/* ===== Private Functions ========================================== */ 343/* ===== Private Functions ========================================== */
344 344
345QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const 345QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
346{ 346{
347 qWarning("extractUids"); 347 qWarning("extractUids");
348 QTime t; 348 QTime t;
349 t.start(); 349 t.start();
350 OSQLResultItem::ValueList list = res.results(); 350 OSQLResultItem::ValueList list = res.results();
351 OSQLResultItem::ValueList::Iterator it; 351 OSQLResultItem::ValueList::Iterator it;
352 QArray<int> ints(list.count() ); 352 QArray<int> ints(list.count() );
353 qWarning(" count = %d", list.count() ); 353 qWarning(" count = %d", list.count() );
354 354
355 int i = 0; 355 int i = 0;
356 for (it = list.begin(); it != list.end(); ++it ) { 356 for (it = list.begin(); it != list.end(); ++it ) {
357 ints[i] = (*it).data("uid").toInt(); 357 ints[i] = (*it).data("uid").toInt();
358 i++; 358 i++;
359 } 359 }
360 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 360 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
361 361
362 return ints; 362 return ints;
363 363
364} 364}
365 365
366} 366}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
index 89939ef..cbfeb97 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
@@ -1,93 +1,93 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
30#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H 30#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
31 31
32#include <qmap.h> 32#include <qmap.h>
33#include <opie2/osqlresult.h> 33#include <opie2/osqlresult.h>
34 34
35#include <opie2/odatebookaccessbackend.h> 35#include <opie2/odatebookaccessbackend.h>
36 36
37class OSQLDriver; 37class OSQLDriver;
38 38
39namespace Opie { 39namespace Opie {
40/** 40/**
41 * This is the default SQL implementation for DateBoook SQL storage 41 * This is the default SQL implementation for DateBoook SQL storage
42 * It fully implements the interface 42 * It fully implements the interface
43 * @see ODateBookAccessBackend 43 * @see ODateBookAccessBackend
44 * @see OPimAccessBackend 44 * @see OPimAccessBackend
45 */ 45 */
46class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { 46class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
47public: 47public:
48 ODateBookAccessBackend_SQL( const QString& appName, 48 ODateBookAccessBackend_SQL( const QString& appName,
49 const QString& fileName = QString::null); 49 const QString& fileName = QString::null);
50 ~ODateBookAccessBackend_SQL(); 50 ~ODateBookAccessBackend_SQL();
51 51
52 bool load(); 52 bool load();
53 bool reload(); 53 bool reload();
54 bool save(); 54 bool save();
55 55
56 QArray<int> allRecords()const; 56 QArray<int> allRecords()const;
57 QArray<int> matchRegexp(const QRegExp &r) const; 57 QArray<int> matchRegexp(const QRegExp &r) const;
58 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 58 QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() );
59 OEvent find( int uid )const; 59 OPimEvent find( int uid )const;
60 void clear(); 60 void clear();
61 bool add( const OEvent& ev ); 61 bool add( const OPimEvent& ev );
62 bool remove( int uid ); 62 bool remove( int uid );
63 bool replace( const OEvent& ev ); 63 bool replace( const OPimEvent& ev );
64 64
65 QArray<UID> rawEvents()const; 65 QArray<UID> rawEvents()const;
66 QArray<UID> rawRepeats()const; 66 QArray<UID> rawRepeats()const;
67 QArray<UID> nonRepeats()const; 67 QArray<UID> nonRepeats()const;
68 68
69 OEvent::ValueList directNonRepeats(); 69 OPimEvent::ValueList directNonRepeats();
70 OEvent::ValueList directRawRepeats(); 70 OPimEvent::ValueList directRawRepeats();
71 71
72private: 72private:
73 bool loadFile(); 73 bool loadFile();
74 QString m_fileName; 74 QString m_fileName;
75 QArray<int> m_uids; 75 QArray<int> m_uids;
76 76
77 QMap<int, QString> m_fieldMap; 77 QMap<int, QString> m_fieldMap;
78 QMap<QString, int> m_reverseFieldMap; 78 QMap<QString, int> m_reverseFieldMap;
79 79
80 OSQLDriver* m_driver; 80 OSQLDriver* m_driver;
81 81
82 class Private; 82 class Private;
83 Private *d; 83 Private *d;
84 84
85 void initFields(); 85 void initFields();
86 void update(); 86 void update();
87 QArray<int> extractUids( OSQLResult& res ) const; 87 QArray<int> extractUids( OSQLResult& res ) const;
88 88
89}; 89};
90 90
91} 91}
92 92
93#endif 93#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 0ebda98..77c0253 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -1,645 +1,645 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <errno.h> 29#include <errno.h>
30#include <fcntl.h> 30#include <fcntl.h>
31 31
32#include <stdio.h> 32#include <stdio.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/mman.h> 36#include <sys/mman.h>
37#include <sys/stat.h> 37#include <sys/stat.h>
38 38
39#include <unistd.h> 39#include <unistd.h>
40 40
41#include <qasciidict.h> 41#include <qasciidict.h>
42#include <qfile.h> 42#include <qfile.h>
43 43
44#include <qtopia/global.h> 44#include <qtopia/global.h>
45#include <qtopia/stringutil.h> 45#include <qtopia/stringutil.h>
46#include <qtopia/timeconversion.h> 46#include <qtopia/timeconversion.h>
47 47
48#include <opie2/opimnotifymanager.h> 48#include <opie2/opimnotifymanager.h>
49#include <opie2/orecur.h> 49#include <opie2/opimrecurrence.h>
50#include <opie2/otimezone.h> 50#include <opie2/opimtimezone.h>
51#include <opie2/odatebookaccessbackend_xml.h> 51#include <opie2/odatebookaccessbackend_xml.h>
52 52
53using namespace Opie; 53using namespace Opie;
54 54
55namespace { 55namespace {
56 // FROM TT again 56 // FROM TT again
57char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 57char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
58{ 58{
59 char needleChar; 59 char needleChar;
60 char haystackChar; 60 char haystackChar;
61 if (!needle || !haystack || !hLen || !nLen) 61 if (!needle || !haystack || !hLen || !nLen)
62 return 0; 62 return 0;
63 63
64 const char* hsearch = haystack; 64 const char* hsearch = haystack;
65 65
66 if ((needleChar = *needle++) != 0) { 66 if ((needleChar = *needle++) != 0) {
67 nLen--; //(to make up for needle++) 67 nLen--; //(to make up for needle++)
68 do { 68 do {
69 do { 69 do {
70 if ((haystackChar = *hsearch++) == 0) 70 if ((haystackChar = *hsearch++) == 0)
71 return (0); 71 return (0);
72 if (hsearch >= haystack + hLen) 72 if (hsearch >= haystack + hLen)
73 return (0); 73 return (0);
74 } while (haystackChar != needleChar); 74 } while (haystackChar != needleChar);
75 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); 75 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
76 hsearch--; 76 hsearch--;
77 } 77 }
78 return ((char *)hsearch); 78 return ((char *)hsearch);
79} 79}
80} 80}
81 81
82namespace { 82namespace {
83 time_t start, end, created, rp_end; 83 time_t start, end, created, rp_end;
84 ORecur* rec; 84 OPimRecurrence* rec;
85 ORecur* recur() { 85 OPimRecurrence* recur() {
86 if (!rec) 86 if (!rec)
87 rec = new ORecur; 87 rec = new OPimRecurrence;
88 88
89 return rec; 89 return rec;
90 } 90 }
91 int alarmTime; 91 int alarmTime;
92 int snd; 92 int snd;
93 enum Attribute{ 93 enum Attribute{
94 FDescription = 0, 94 FDescription = 0,
95 FLocation, 95 FLocation,
96 FCategories, 96 FCategories,
97 FUid, 97 FUid,
98 FType, 98 FType,
99 FAlarm, 99 FAlarm,
100 FSound, 100 FSound,
101 FRType, 101 FRType,
102 FRWeekdays, 102 FRWeekdays,
103 FRPosition, 103 FRPosition,
104 FRFreq, 104 FRFreq,
105 FRHasEndDate, 105 FRHasEndDate,
106 FREndDate, 106 FREndDate,
107 FRStart, 107 FRStart,
108 FREnd, 108 FREnd,
109 FNote, 109 FNote,
110 FCreated, // Should't this be called FRCreated ? 110 FCreated, // Should't this be called FRCreated ?
111 FTimeZone, 111 FTimeZone,
112 FRecParent, 112 FRecParent,
113 FRecChildren, 113 FRecChildren,
114 FExceptions 114 FExceptions
115 }; 115 };
116 116
117 // FIXME: Use OEvent::toMap() here !! (eilers) 117 // FIXME: Use OPimEvent::toMap() here !! (eilers)
118 inline void save( const OEvent& ev, QString& buf ) { 118 inline void save( const OPimEvent& ev, QString& buf ) {
119 qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); 119 qWarning("Saving %d %s", ev.uid(), ev.description().latin1() );
120 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; 120 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
121 if (!ev.location().isEmpty() ) 121 if (!ev.location().isEmpty() )
122 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; 122 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\"";
123 123
124 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; 124 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\"";
125 buf += " uid=\"" + QString::number( ev.uid() ) + "\""; 125 buf += " uid=\"" + QString::number( ev.uid() ) + "\"";
126 126
127 if (ev.isAllDay() ) 127 if (ev.isAllDay() )
128 buf += " type=\"AllDay\""; // is that all ?? (eilers) 128 buf += " type=\"AllDay\""; // is that all ?? (eilers)
129 129
130 if (ev.hasNotifiers() ) { 130 if (ev.hasNotifiers() ) {
131 OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first 131 OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first
132 int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60; 132 int minutes = alarm.dateTime().secsTo( ev.startDateTime() ) / 60;
133 buf += " alarm=\"" + QString::number(minutes) + "\" sound=\""; 133 buf += " alarm=\"" + QString::number(minutes) + "\" sound=\"";
134 if ( alarm.sound() == OPimAlarm::Loud ) 134 if ( alarm.sound() == OPimAlarm::Loud )
135 buf += "loud"; 135 buf += "loud";
136 else 136 else
137 buf += "silent"; 137 buf += "silent";
138 buf += "\""; 138 buf += "\"";
139 } 139 }
140 if ( ev.hasRecurrence() ) { 140 if ( ev.hasRecurrence() ) {
141 buf += ev.recurrence().toString(); 141 buf += ev.recurrence().toString();
142 } 142 }
143 143
144 /* 144 /*
145 * fscking timezones :) well, we'll first convert 145 * fscking timezones :) well, we'll first convert
146 * the QDateTime to a QDateTime in UTC time 146 * the QDateTime to a QDateTime in UTC time
147 * and then we'll create a nice time_t 147 * and then we'll create a nice time_t
148 */ 148 */
149 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 149 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() );
150 buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OTimeZone::utc() ) ) ) + "\""; 150 buf += " start=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.startDateTime(), OPimTimeZone::utc() ) ) ) + "\"";
151 buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OTimeZone::utc() ) ) ) + "\""; 151 buf += " end=\"" + QString::number( zone.fromUTCDateTime( zone.toDateTime( ev.endDateTime() , OPimTimeZone::utc() ) ) ) + "\"";
152 if (!ev.note().isEmpty() ) { 152 if (!ev.note().isEmpty() ) {
153 buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\""; 153 buf += " note=\"" + Qtopia::escapeString( ev.note() ) + "\"";
154 } 154 }
155 155
156 buf += " timezone=\""; 156 buf += " timezone=\"";
157 if ( ev.timeZone().isEmpty() ) 157 if ( ev.timeZone().isEmpty() )
158 buf += "None"; 158 buf += "None";
159 else 159 else
160 buf += ev.timeZone(); 160 buf += ev.timeZone();
161 buf += "\""; 161 buf += "\"";
162 162
163 if (ev.parent() != 0 ) { 163 if (ev.parent() != 0 ) {
164 buf += " recparent=\""+QString::number(ev.parent() )+"\""; 164 buf += " recparent=\""+QString::number(ev.parent() )+"\"";
165 } 165 }
166 166
167 if (ev.children().count() != 0 ) { 167 if (ev.children().count() != 0 ) {
168 QArray<int> children = ev.children(); 168 QArray<int> children = ev.children();
169 buf += " recchildren=\""; 169 buf += " recchildren=\"";
170 for ( uint i = 0; i < children.count(); i++ ) { 170 for ( uint i = 0; i < children.count(); i++ ) {
171 if ( i != 0 ) buf += " "; 171 if ( i != 0 ) buf += " ";
172 buf += QString::number( children[i] ); 172 buf += QString::number( children[i] );
173 } 173 }
174 buf+= "\""; 174 buf+= "\"";
175 } 175 }
176 176
177 // skip custom writing 177 // skip custom writing
178 } 178 }
179 179
180 inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { 180 inline bool forAll( const QMap<int, OPimEvent>& list, QFile& file ) {
181 QMap<int, OEvent>::ConstIterator it; 181 QMap<int, OPimEvent>::ConstIterator it;
182 QString buf; 182 QString buf;
183 QCString str; 183 QCString str;
184 int total_written; 184 int total_written;
185 for ( it = list.begin(); it != list.end(); ++it ) { 185 for ( it = list.begin(); it != list.end(); ++it ) {
186 buf = "<event"; 186 buf = "<event";
187 save( it.data(), buf ); 187 save( it.data(), buf );
188 buf += " />\n"; 188 buf += " />\n";
189 str = buf.utf8(); 189 str = buf.utf8();
190 190
191 total_written = file.writeBlock(str.data(), str.length() ); 191 total_written = file.writeBlock(str.data(), str.length() );
192 if ( total_written != int(str.length() ) ) 192 if ( total_written != int(str.length() ) )
193 return false; 193 return false;
194 } 194 }
195 return true; 195 return true;
196 } 196 }
197} 197}
198 198
199namespace Opie { 199namespace Opie {
200ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , 200ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& ,
201 const QString& fileName ) 201 const QString& fileName )
202 : ODateBookAccessBackend() { 202 : ODateBookAccessBackend() {
203 m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; 203 m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName;
204 m_changed = false; 204 m_changed = false;
205} 205}
206ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { 206ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() {
207} 207}
208bool ODateBookAccessBackend_XML::load() { 208bool ODateBookAccessBackend_XML::load() {
209 return loadFile(); 209 return loadFile();
210} 210}
211bool ODateBookAccessBackend_XML::reload() { 211bool ODateBookAccessBackend_XML::reload() {
212 clear(); 212 clear();
213 return load(); 213 return load();
214} 214}
215bool ODateBookAccessBackend_XML::save() { 215bool ODateBookAccessBackend_XML::save() {
216 if (!m_changed) return true; 216 if (!m_changed) return true;
217 217
218 int total_written; 218 int total_written;
219 QString strFileNew = m_name + ".new"; 219 QString strFileNew = m_name + ".new";
220 220
221 QFile f( strFileNew ); 221 QFile f( strFileNew );
222 if (!f.open( IO_WriteOnly | IO_Raw ) ) return false; 222 if (!f.open( IO_WriteOnly | IO_Raw ) ) return false;
223 223
224 QString buf( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ); 224 QString buf( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
225 buf += "<!DOCTYPE DATEBOOK><DATEBOOK>\n"; 225 buf += "<!DOCTYPE DATEBOOK><DATEBOOK>\n";
226 buf += "<events>\n"; 226 buf += "<events>\n";
227 QCString str = buf.utf8(); 227 QCString str = buf.utf8();
228 total_written = f.writeBlock( str.data(), str.length() ); 228 total_written = f.writeBlock( str.data(), str.length() );
229 if ( total_written != int(str.length() ) ) { 229 if ( total_written != int(str.length() ) ) {
230 f.close(); 230 f.close();
231 QFile::remove( strFileNew ); 231 QFile::remove( strFileNew );
232 return false; 232 return false;
233 } 233 }
234 234
235 if (!forAll( m_raw, f ) ) { 235 if (!forAll( m_raw, f ) ) {
236 f.close(); 236 f.close();
237 QFile::remove( strFileNew ); 237 QFile::remove( strFileNew );
238 return false; 238 return false;
239 } 239 }
240 if (!forAll( m_rep, f ) ) { 240 if (!forAll( m_rep, f ) ) {
241 f.close(); 241 f.close();
242 QFile::remove( strFileNew ); 242 QFile::remove( strFileNew );
243 return false; 243 return false;
244 } 244 }
245 245
246 buf = "</events>\n</DATEBOOK>\n"; 246 buf = "</events>\n</DATEBOOK>\n";
247 str = buf.utf8(); 247 str = buf.utf8();
248 total_written = f.writeBlock( str.data(), str.length() ); 248 total_written = f.writeBlock( str.data(), str.length() );
249 if ( total_written != int(str.length() ) ) { 249 if ( total_written != int(str.length() ) ) {
250 f.close(); 250 f.close();
251 QFile::remove( strFileNew ); 251 QFile::remove( strFileNew );
252 return false; 252 return false;
253 } 253 }
254 f.close(); 254 f.close();
255 255
256 if ( ::rename( strFileNew, m_name ) < 0 ) { 256 if ( ::rename( strFileNew, m_name ) < 0 ) {
257 QFile::remove( strFileNew ); 257 QFile::remove( strFileNew );
258 return false; 258 return false;
259 } 259 }
260 260
261 m_changed = false; 261 m_changed = false;
262 return true; 262 return true;
263} 263}
264QArray<int> ODateBookAccessBackend_XML::allRecords()const { 264QArray<int> ODateBookAccessBackend_XML::allRecords()const {
265 QArray<int> ints( m_raw.count()+ m_rep.count() ); 265 QArray<int> ints( m_raw.count()+ m_rep.count() );
266 uint i = 0; 266 uint i = 0;
267 QMap<int, OEvent>::ConstIterator it; 267 QMap<int, OPimEvent>::ConstIterator it;
268 268
269 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { 269 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) {
270 ints[i] = it.key(); 270 ints[i] = it.key();
271 i++; 271 i++;
272 } 272 }
273 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { 273 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) {
274 ints[i] = it.key(); 274 ints[i] = it.key();
275 i++; 275 i++;
276 } 276 }
277 277
278 return ints; 278 return ints;
279} 279}
280QArray<int> ODateBookAccessBackend_XML::queryByExample(const OEvent&, int, const QDateTime& ) { 280QArray<int> ODateBookAccessBackend_XML::queryByExample(const OPimEvent&, int, const QDateTime& ) {
281 return QArray<int>(); 281 return QArray<int>();
282} 282}
283void ODateBookAccessBackend_XML::clear() { 283void ODateBookAccessBackend_XML::clear() {
284 m_changed = true; 284 m_changed = true;
285 m_raw.clear(); 285 m_raw.clear();
286 m_rep.clear(); 286 m_rep.clear();
287} 287}
288OEvent ODateBookAccessBackend_XML::find( int uid ) const{ 288OPimEvent ODateBookAccessBackend_XML::find( int uid ) const{
289 if ( m_raw.contains( uid ) ) 289 if ( m_raw.contains( uid ) )
290 return m_raw[uid]; 290 return m_raw[uid];
291 else 291 else
292 return m_rep[uid]; 292 return m_rep[uid];
293} 293}
294bool ODateBookAccessBackend_XML::add( const OEvent& ev ) { 294bool ODateBookAccessBackend_XML::add( const OPimEvent& ev ) {
295 m_changed = true; 295 m_changed = true;
296 if (ev.hasRecurrence() ) 296 if (ev.hasRecurrence() )
297 m_rep.insert( ev.uid(), ev ); 297 m_rep.insert( ev.uid(), ev );
298 else 298 else
299 m_raw.insert( ev.uid(), ev ); 299 m_raw.insert( ev.uid(), ev );
300 300
301 return true; 301 return true;
302} 302}
303bool ODateBookAccessBackend_XML::remove( int uid ) { 303bool ODateBookAccessBackend_XML::remove( int uid ) {
304 m_changed = true; 304 m_changed = true;
305 m_rep.remove( uid ); 305 m_rep.remove( uid );
306 m_rep.remove( uid ); 306 m_rep.remove( uid );
307 307
308 return true; 308 return true;
309} 309}
310bool ODateBookAccessBackend_XML::replace( const OEvent& ev ) { 310bool ODateBookAccessBackend_XML::replace( const OPimEvent& ev ) {
311 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers) 311 replace( ev.uid() ); // ??? Shouldn't this be "remove( ev.uid() ) ??? (eilers)
312 return add( ev ); 312 return add( ev );
313} 313}
314QArray<int> ODateBookAccessBackend_XML::rawEvents()const { 314QArray<int> ODateBookAccessBackend_XML::rawEvents()const {
315 return allRecords(); 315 return allRecords();
316} 316}
317QArray<int> ODateBookAccessBackend_XML::rawRepeats()const { 317QArray<int> ODateBookAccessBackend_XML::rawRepeats()const {
318 QArray<int> ints( m_rep.count() ); 318 QArray<int> ints( m_rep.count() );
319 uint i = 0; 319 uint i = 0;
320 QMap<int, OEvent>::ConstIterator it; 320 QMap<int, OPimEvent>::ConstIterator it;
321 321
322 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) { 322 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) {
323 ints[i] = it.key(); 323 ints[i] = it.key();
324 i++; 324 i++;
325 } 325 }
326 326
327 return ints; 327 return ints;
328} 328}
329QArray<int> ODateBookAccessBackend_XML::nonRepeats()const { 329QArray<int> ODateBookAccessBackend_XML::nonRepeats()const {
330 QArray<int> ints( m_raw.count() ); 330 QArray<int> ints( m_raw.count() );
331 uint i = 0; 331 uint i = 0;
332 QMap<int, OEvent>::ConstIterator it; 332 QMap<int, OPimEvent>::ConstIterator it;
333 333
334 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) { 334 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) {
335 ints[i] = it.key(); 335 ints[i] = it.key();
336 i++; 336 i++;
337 } 337 }
338 338
339 return ints; 339 return ints;
340} 340}
341OEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() { 341OPimEvent::ValueList ODateBookAccessBackend_XML::directNonRepeats() {
342 OEvent::ValueList list; 342 OPimEvent::ValueList list;
343 QMap<int, OEvent>::ConstIterator it; 343 QMap<int, OPimEvent>::ConstIterator it;
344 for (it = m_raw.begin(); it != m_raw.end(); ++it ) 344 for (it = m_raw.begin(); it != m_raw.end(); ++it )
345 list.append( it.data() ); 345 list.append( it.data() );
346 346
347 return list; 347 return list;
348} 348}
349OEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() { 349OPimEvent::ValueList ODateBookAccessBackend_XML::directRawRepeats() {
350 OEvent::ValueList list; 350 OPimEvent::ValueList list;
351 QMap<int, OEvent>::ConstIterator it; 351 QMap<int, OPimEvent>::ConstIterator it;
352 for (it = m_rep.begin(); it != m_rep.end(); ++it ) 352 for (it = m_rep.begin(); it != m_rep.end(); ++it )
353 list.append( it.data() ); 353 list.append( it.data() );
354 354
355 return list; 355 return list;
356} 356}
357 357
358// FIXME: Use OEvent::fromMap() (eilers) 358// FIXME: Use OPimEvent::fromMap() (eilers)
359bool ODateBookAccessBackend_XML::loadFile() { 359bool ODateBookAccessBackend_XML::loadFile() {
360 m_changed = false; 360 m_changed = false;
361 361
362 int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY ); 362 int fd = ::open( QFile::encodeName(m_name).data(), O_RDONLY );
363 if ( fd < 0 ) return false; 363 if ( fd < 0 ) return false;
364 364
365 struct stat attribute; 365 struct stat attribute;
366 if ( ::fstat(fd, &attribute ) == -1 ) { 366 if ( ::fstat(fd, &attribute ) == -1 ) {
367 ::close( fd ); 367 ::close( fd );
368 return false; 368 return false;
369 } 369 }
370 void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 ); 370 void* map_addr = ::mmap(NULL, attribute.st_size, PROT_READ, MAP_SHARED, fd, 0 );
371 if ( map_addr == ( (caddr_t)-1) ) { 371 if ( map_addr == ( (caddr_t)-1) ) {
372 ::close( fd ); 372 ::close( fd );
373 return false; 373 return false;
374 } 374 }
375 375
376 ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL ); 376 ::madvise( map_addr, attribute.st_size, MADV_SEQUENTIAL );
377 ::close( fd ); 377 ::close( fd );
378 378
379 QAsciiDict<int> dict(FExceptions+1); 379 QAsciiDict<int> dict(FExceptions+1);
380 dict.setAutoDelete( true ); 380 dict.setAutoDelete( true );
381 dict.insert( "description", new int(FDescription) ); 381 dict.insert( "description", new int(FDescription) );
382 dict.insert( "location", new int(FLocation) ); 382 dict.insert( "location", new int(FLocation) );
383 dict.insert( "categories", new int(FCategories) ); 383 dict.insert( "categories", new int(FCategories) );
384 dict.insert( "uid", new int(FUid) ); 384 dict.insert( "uid", new int(FUid) );
385 dict.insert( "type", new int(FType) ); 385 dict.insert( "type", new int(FType) );
386 dict.insert( "alarm", new int(FAlarm) ); 386 dict.insert( "alarm", new int(FAlarm) );
387 dict.insert( "sound", new int(FSound) ); 387 dict.insert( "sound", new int(FSound) );
388 dict.insert( "rtype", new int(FRType) ); 388 dict.insert( "rtype", new int(FRType) );
389 dict.insert( "rweekdays", new int(FRWeekdays) ); 389 dict.insert( "rweekdays", new int(FRWeekdays) );
390 dict.insert( "rposition", new int(FRPosition) ); 390 dict.insert( "rposition", new int(FRPosition) );
391 dict.insert( "rfreq", new int(FRFreq) ); 391 dict.insert( "rfreq", new int(FRFreq) );
392 dict.insert( "rhasenddate", new int(FRHasEndDate) ); 392 dict.insert( "rhasenddate", new int(FRHasEndDate) );
393 dict.insert( "enddt", new int(FREndDate) ); 393 dict.insert( "enddt", new int(FREndDate) );
394 dict.insert( "start", new int(FRStart) ); 394 dict.insert( "start", new int(FRStart) );
395 dict.insert( "end", new int(FREnd) ); 395 dict.insert( "end", new int(FREnd) );
396 dict.insert( "note", new int(FNote) ); 396 dict.insert( "note", new int(FNote) );
397 dict.insert( "created", new int(FCreated) ); // Shouldn't this be FRCreated ?? 397 dict.insert( "created", new int(FCreated) ); // Shouldn't this be FRCreated ??
398 dict.insert( "recparent", new int(FRecParent) ); 398 dict.insert( "recparent", new int(FRecParent) );
399 dict.insert( "recchildren", new int(FRecChildren) ); 399 dict.insert( "recchildren", new int(FRecChildren) );
400 dict.insert( "exceptions", new int(FExceptions) ); 400 dict.insert( "exceptions", new int(FExceptions) );
401 dict.insert( "timezone", new int(FTimeZone) ); 401 dict.insert( "timezone", new int(FTimeZone) );
402 402
403 char* dt = (char*)map_addr; 403 char* dt = (char*)map_addr;
404 int len = attribute.st_size; 404 int len = attribute.st_size;
405 int i = 0; 405 int i = 0;
406 char* point; 406 char* point;
407 const char* collectionString = "<event "; 407 const char* collectionString = "<event ";
408 int strLen = ::strlen(collectionString); 408 int strLen = ::strlen(collectionString);
409 int *find; 409 int *find;
410 while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) { 410 while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) {
411 i = point -dt; 411 i = point -dt;
412 i+= strLen; 412 i+= strLen;
413 413
414 alarmTime = -1; 414 alarmTime = -1;
415 snd = 0; // silent 415 snd = 0; // silent
416 416
417 OEvent ev; 417 OPimEvent ev;
418 rec = 0; 418 rec = 0;
419 419
420 while ( TRUE ) { 420 while ( TRUE ) {
421 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 421 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
422 ++i; 422 ++i;
423 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 423 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
424 break; 424 break;
425 425
426 426
427 // we have another attribute, read it. 427 // we have another attribute, read it.
428 int j = i; 428 int j = i;
429 while ( j < len && dt[j] != '=' ) 429 while ( j < len && dt[j] != '=' )
430 ++j; 430 ++j;
431 QCString attr( dt+i, j-i+1); 431 QCString attr( dt+i, j-i+1);
432 432
433 i = ++j; // skip = 433 i = ++j; // skip =
434 434
435 // find the start of quotes 435 // find the start of quotes
436 while ( i < len && dt[i] != '"' ) 436 while ( i < len && dt[i] != '"' )
437 ++i; 437 ++i;
438 j = ++i; 438 j = ++i;
439 439
440 bool haveUtf = FALSE; 440 bool haveUtf = FALSE;
441 bool haveEnt = FALSE; 441 bool haveEnt = FALSE;
442 while ( j < len && dt[j] != '"' ) { 442 while ( j < len && dt[j] != '"' ) {
443 if ( ((unsigned char)dt[j]) > 0x7f ) 443 if ( ((unsigned char)dt[j]) > 0x7f )
444 haveUtf = TRUE; 444 haveUtf = TRUE;
445 if ( dt[j] == '&' ) 445 if ( dt[j] == '&' )
446 haveEnt = TRUE; 446 haveEnt = TRUE;
447 ++j; 447 ++j;
448 } 448 }
449 if ( i == j ) { 449 if ( i == j ) {
450 // empty value 450 // empty value
451 i = j + 1; 451 i = j + 1;
452 continue; 452 continue;
453 } 453 }
454 454
455 QCString value( dt+i, j-i+1 ); 455 QCString value( dt+i, j-i+1 );
456 i = j + 1; 456 i = j + 1;
457 457
458 QString str = (haveUtf ? QString::fromUtf8( value ) 458 QString str = (haveUtf ? QString::fromUtf8( value )
459 : QString::fromLatin1( value ) ); 459 : QString::fromLatin1( value ) );
460 if ( haveEnt ) 460 if ( haveEnt )
461 str = Qtopia::plainString( str ); 461 str = Qtopia::plainString( str );
462 462
463 /* 463 /*
464 * add key + value 464 * add key + value
465 */ 465 */
466 find = dict[attr.data()]; 466 find = dict[attr.data()];
467 if (!find) 467 if (!find)
468 ev.setCustomField( attr, str ); 468 ev.setCustomField( attr, str );
469 else { 469 else {
470 setField( ev, *find, str ); 470 setField( ev, *find, str );
471 } 471 }
472 } 472 }
473 /* time to finalize */ 473 /* time to finalize */
474 finalizeRecord( ev ); 474 finalizeRecord( ev );
475 delete rec; 475 delete rec;
476 } 476 }
477 ::munmap(map_addr, attribute.st_size ); 477 ::munmap(map_addr, attribute.st_size );
478 m_changed = false; // changed during add 478 m_changed = false; // changed during add
479 479
480 return true; 480 return true;
481} 481}
482 482
483// FIXME: Use OEvent::fromMap() which makes this obsolete.. (eilers) 483// FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers)
484void ODateBookAccessBackend_XML::finalizeRecord( OEvent& ev ) { 484void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
485 /* AllDay is alway in UTC */ 485 /* AllDay is alway in UTC */
486 if ( ev.isAllDay() ) { 486 if ( ev.isAllDay() ) {
487 OTimeZone utc = OTimeZone::utc(); 487 OPimTimeZone utc = OPimTimeZone::utc();
488 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 488 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
489 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 489 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
490 ev.setTimeZone( "UTC"); // make sure it is really utc 490 ev.setTimeZone( "UTC"); // make sure it is really utc
491 }else { 491 }else {
492 /* to current date time */ 492 /* to current date time */
493 // qWarning(" Start is %d", start ); 493 // qWarning(" Start is %d", start );
494 OTimeZone zone( ev.timeZone().isEmpty() ? OTimeZone::current() : ev.timeZone() ); 494 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() );
495 QDateTime date = zone.toDateTime( start ); 495 QDateTime date = zone.toDateTime( start );
496 qWarning(" Start is %s", date.toString().latin1() ); 496 qWarning(" Start is %s", date.toString().latin1() );
497 ev.setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 497 ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
498 498
499 date = zone.toDateTime( end ); 499 date = zone.toDateTime( end );
500 ev.setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 500 ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
501 } 501 }
502 if ( rec && rec->doesRecur() ) { 502 if ( rec && rec->doesRecur() ) {
503 OTimeZone utc = OTimeZone::utc(); 503 OPimTimeZone utc = OPimTimeZone::utc();
504 ORecur recu( *rec ); // call copy c'tor; 504 OPimRecurrence recu( *rec ); // call copy c'tor;
505 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 505 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
506 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 506 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
507 recu.setStart( ev.startDateTime().date() ); 507 recu.setStart( ev.startDateTime().date() );
508 ev.setRecurrence( recu ); 508 ev.setRecurrence( recu );
509 } 509 }
510 510
511 if (alarmTime != -1 ) { 511 if (alarmTime != -1 ) {
512 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 512 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
513 OPimAlarm al( snd , dt ); 513 OPimAlarm al( snd , dt );
514 ev.notifiers().add( al ); 514 ev.notifiers().add( al );
515 } 515 }
516 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 516 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
517 qWarning("already contains assign uid"); 517 qWarning("already contains assign uid");
518 ev.setUid( 1 ); 518 ev.setUid( 1 );
519 } 519 }
520 qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); 520 qWarning("addind %d %s", ev.uid(), ev.description().latin1() );
521 if ( ev.hasRecurrence() ) 521 if ( ev.hasRecurrence() )
522 m_rep.insert( ev.uid(), ev ); 522 m_rep.insert( ev.uid(), ev );
523 else 523 else
524 m_raw.insert( ev.uid(), ev ); 524 m_raw.insert( ev.uid(), ev );
525 525
526} 526}
527void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& value) { 527void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) {
528// qWarning(" setting %s", value.latin1() ); 528// qWarning(" setting %s", value.latin1() );
529 switch( id ) { 529 switch( id ) {
530 case FDescription: 530 case FDescription:
531 e.setDescription( value ); 531 e.setDescription( value );
532 break; 532 break;
533 case FLocation: 533 case FLocation:
534 e.setLocation( value ); 534 e.setLocation( value );
535 break; 535 break;
536 case FCategories: 536 case FCategories:
537 e.setCategories( e.idsFromString( value ) ); 537 e.setCategories( e.idsFromString( value ) );
538 break; 538 break;
539 case FUid: 539 case FUid:
540 e.setUid( value.toInt() ); 540 e.setUid( value.toInt() );
541 break; 541 break;
542 case FType: 542 case FType:
543 if ( value == "AllDay" ) { 543 if ( value == "AllDay" ) {
544 e.setAllDay( true ); 544 e.setAllDay( true );
545 e.setTimeZone( "UTC" ); 545 e.setTimeZone( "UTC" );
546 } 546 }
547 break; 547 break;
548 case FAlarm: 548 case FAlarm:
549 alarmTime = value.toInt(); 549 alarmTime = value.toInt();
550 break; 550 break;
551 case FSound: 551 case FSound:
552 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent; 552 snd = value == "loud" ? OPimAlarm::Loud : OPimAlarm::Silent;
553 break; 553 break;
554 // recurrence stuff 554 // recurrence stuff
555 case FRType: 555 case FRType:
556 if ( value == "Daily" ) 556 if ( value == "Daily" )
557 recur()->setType( ORecur::Daily ); 557 recur()->setType( OPimRecurrence::Daily );
558 else if ( value == "Weekly" ) 558 else if ( value == "Weekly" )
559 recur()->setType( ORecur::Weekly); 559 recur()->setType( OPimRecurrence::Weekly);
560 else if ( value == "MonthlyDay" ) 560 else if ( value == "MonthlyDay" )
561 recur()->setType( ORecur::MonthlyDay ); 561 recur()->setType( OPimRecurrence::MonthlyDay );
562 else if ( value == "MonthlyDate" ) 562 else if ( value == "MonthlyDate" )
563 recur()->setType( ORecur::MonthlyDate ); 563 recur()->setType( OPimRecurrence::MonthlyDate );
564 else if ( value == "Yearly" ) 564 else if ( value == "Yearly" )
565 recur()->setType( ORecur::Yearly ); 565 recur()->setType( OPimRecurrence::Yearly );
566 else 566 else
567 recur()->setType( ORecur::NoRepeat ); 567 recur()->setType( OPimRecurrence::NoRepeat );
568 break; 568 break;
569 case FRWeekdays: 569 case FRWeekdays:
570 recur()->setDays( value.toInt() ); 570 recur()->setDays( value.toInt() );
571 break; 571 break;
572 case FRPosition: 572 case FRPosition:
573 recur()->setPosition( value.toInt() ); 573 recur()->setPosition( value.toInt() );
574 break; 574 break;
575 case FRFreq: 575 case FRFreq:
576 recur()->setFrequency( value.toInt() ); 576 recur()->setFrequency( value.toInt() );
577 break; 577 break;
578 case FRHasEndDate: 578 case FRHasEndDate:
579 recur()->setHasEndDate( value.toInt() ); 579 recur()->setHasEndDate( value.toInt() );
580 break; 580 break;
581 case FREndDate: { 581 case FREndDate: {
582 rp_end = (time_t) value.toLong(); 582 rp_end = (time_t) value.toLong();
583 break; 583 break;
584 } 584 }
585 case FRStart: { 585 case FRStart: {
586 start = (time_t) value.toLong(); 586 start = (time_t) value.toLong();
587 break; 587 break;
588 } 588 }
589 case FREnd: { 589 case FREnd: {
590 end = ( (time_t) value.toLong() ); 590 end = ( (time_t) value.toLong() );
591 break; 591 break;
592 } 592 }
593 case FNote: 593 case FNote:
594 e.setNote( value ); 594 e.setNote( value );
595 break; 595 break;
596 case FCreated: 596 case FCreated:
597 created = value.toInt(); 597 created = value.toInt();
598 break; 598 break;
599 case FRecParent: 599 case FRecParent:
600 e.setParent( value.toInt() ); 600 e.setParent( value.toInt() );
601 break; 601 break;
602 case FRecChildren:{ 602 case FRecChildren:{
603 QStringList list = QStringList::split(' ', value ); 603 QStringList list = QStringList::split(' ', value );
604 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 604 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
605 e.addChild( (*it).toInt() ); 605 e.addChild( (*it).toInt() );
606 } 606 }
607 } 607 }
608 break; 608 break;
609 case FExceptions:{ 609 case FExceptions:{
610 QStringList list = QStringList::split(' ', value ); 610 QStringList list = QStringList::split(' ', value );
611 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 611 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
612 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 612 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
613 qWarning("adding exception %s", date.toString().latin1() ); 613 qWarning("adding exception %s", date.toString().latin1() );
614 recur()->exceptions().append( date ); 614 recur()->exceptions().append( date );
615 } 615 }
616 } 616 }
617 break; 617 break;
618 case FTimeZone: 618 case FTimeZone:
619 if ( value != "None" ) 619 if ( value != "None" )
620 e.setTimeZone( value ); 620 e.setTimeZone( value );
621 break; 621 break;
622 default: 622 default:
623 break; 623 break;
624 } 624 }
625} 625}
626QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const 626QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
627{ 627{
628 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); 628 QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
629 uint arraycounter = 0; 629 uint arraycounter = 0;
630 QMap<int, OEvent>::ConstIterator it; 630 QMap<int, OPimEvent>::ConstIterator it;
631 631
632 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) 632 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
633 if ( it.data().match( r ) ) 633 if ( it.data().match( r ) )
634 m_currentQuery[arraycounter++] = it.data().uid(); 634 m_currentQuery[arraycounter++] = it.data().uid();
635 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) 635 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
636 if ( it.data().match( r ) ) 636 if ( it.data().match( r ) )
637 m_currentQuery[arraycounter++] = it.data().uid(); 637 m_currentQuery[arraycounter++] = it.data().uid();
638 638
639 // Shrink to fit.. 639 // Shrink to fit..
640 m_currentQuery.resize(arraycounter); 640 m_currentQuery.resize(arraycounter);
641 641
642 return m_currentQuery; 642 return m_currentQuery;
643} 643}
644 644
645} 645}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 29f5f4f..6823ce6 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -1,86 +1,86 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 29#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
30#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H 30#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
31 31
32#include <qmap.h> 32#include <qmap.h>
33 33
34#include <opie2/odatebookaccessbackend.h> 34#include <opie2/odatebookaccessbackend.h>
35 35
36namespace Opie { 36namespace Opie {
37/** 37/**
38 * This is the default XML implementation for DateBoook XML storage 38 * This is the default XML implementation for DateBoook XML storage
39 * It fully implements the interface 39 * It fully implements the interface
40 * @see ODateBookAccessBackend 40 * @see ODateBookAccessBackend
41 * @see OPimAccessBackend 41 * @see OPimAccessBackend
42 */ 42 */
43class ODateBookAccessBackend_XML : public ODateBookAccessBackend { 43class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
44public: 44public:
45 ODateBookAccessBackend_XML( const QString& appName, 45 ODateBookAccessBackend_XML( const QString& appName,
46 const QString& fileName = QString::null); 46 const QString& fileName = QString::null);
47 ~ODateBookAccessBackend_XML(); 47 ~ODateBookAccessBackend_XML();
48 48
49 bool load(); 49 bool load();
50 bool reload(); 50 bool reload();
51 bool save(); 51 bool save();
52 52
53 QArray<int> allRecords()const; 53 QArray<int> allRecords()const;
54 QArray<int> matchRegexp(const QRegExp &r) const; 54 QArray<int> matchRegexp(const QRegExp &r) const;
55 QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); 55 QArray<int> queryByExample( const OPimEvent&, int, const QDateTime& d = QDateTime() );
56 OEvent find( int uid )const; 56 OPimEvent find( int uid )const;
57 void clear(); 57 void clear();
58 bool add( const OEvent& ev ); 58 bool add( const OPimEvent& ev );
59 bool remove( int uid ); 59 bool remove( int uid );
60 bool replace( const OEvent& ev ); 60 bool replace( const OPimEvent& ev );
61 61
62 QArray<UID> rawEvents()const; 62 QArray<UID> rawEvents()const;
63 QArray<UID> rawRepeats()const; 63 QArray<UID> rawRepeats()const;
64 QArray<UID> nonRepeats()const; 64 QArray<UID> nonRepeats()const;
65 65
66 OEvent::ValueList directNonRepeats(); 66 OPimEvent::ValueList directNonRepeats();
67 OEvent::ValueList directRawRepeats(); 67 OPimEvent::ValueList directRawRepeats();
68 68
69private: 69private:
70 bool m_changed :1 ; 70 bool m_changed :1 ;
71 bool loadFile(); 71 bool loadFile();
72 inline void finalizeRecord( OEvent& ev ); 72 inline void finalizeRecord( OPimEvent& ev );
73 inline void setField( OEvent&, int field, const QString& val ); 73 inline void setField( OPimEvent&, int field, const QString& val );
74 QString m_name; 74 QString m_name;
75 QMap<int, OEvent> m_raw; 75 QMap<int, OPimEvent> m_raw;
76 QMap<int, OEvent> m_rep; 76 QMap<int, OPimEvent> m_rep;
77 77
78 struct Data; 78 struct Data;
79 Data* data; 79 Data* data;
80 class Private; 80 class Private;
81 Private *d; 81 Private *d;
82}; 82};
83 83
84} 84}
85 85
86#endif 86#endif
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 505358e..0682063 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,192 +1,192 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_ACCESS_BACKEND 29#ifndef OPIE_PIM_ACCESS_BACKEND
30#define OPIE_PIM_ACCESS_BACKEND 30#define OPIE_PIM_ACCESS_BACKEND
31 31
32#include <qarray.h> 32#include <qarray.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34 34
35#include <opie2/otemplatebase.h> 35#include <opie2/opimtemplatebase.h>
36#include <opie2/opimrecord.h> 36#include <opie2/opimrecord.h>
37 37
38 38
39namespace Opie { 39namespace Opie {
40class OPimAccessBackendPrivate; 40class OPimAccessBackendPrivate;
41/** 41/**
42 * OPimAccessBackend is the base class 42 * OPimAccessBackend is the base class
43 * for all private backends 43 * for all private backends
44 * it operates on OPimRecord as the base class 44 * it operates on OPimRecord as the base class
45 * and it's responsible for fast manipulating 45 * and it's responsible for fast manipulating
46 * the resource the implementation takes care 46 * the resource the implementation takes care
47 * of 47 * of
48 */ 48 */
49template <class T = OPimRecord> 49template <class T = OPimRecord>
50class OPimAccessBackend { 50class OPimAccessBackend {
51public: 51public:
52 typedef OTemplateBase<T> Frontend; 52 typedef OTemplateBase<T> Frontend;
53 53
54 /** The access hint from the frontend */ 54 /** The access hint from the frontend */
55 OPimAccessBackend(int access = 0); 55 OPimAccessBackend(int access = 0);
56 virtual ~OPimAccessBackend(); 56 virtual ~OPimAccessBackend();
57 57
58 /** 58 /**
59 * load the resource 59 * load the resource
60 */ 60 */
61 virtual bool load() = 0; 61 virtual bool load() = 0;
62 62
63 /** 63 /**
64 * reload the resource 64 * reload the resource
65 */ 65 */
66 virtual bool reload() = 0; 66 virtual bool reload() = 0;
67 67
68 /** 68 /**
69 * save the resource and 69 * save the resource and
70 * all it's changes 70 * all it's changes
71 */ 71 */
72 virtual bool save() = 0; 72 virtual bool save() = 0;
73 73
74 /** 74 /**
75 * return an array of 75 * return an array of
76 * all available uids 76 * all available uids
77 */ 77 */
78 virtual QArray<int> allRecords()const = 0; 78 virtual QArray<int> allRecords()const = 0;
79 79
80 /** 80 /**
81 * return a List of records 81 * return a List of records
82 * that match the regex 82 * that match the regex
83 */ 83 */
84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
85 85
86 /** 86 /**
87 * queryByExample for T with the given Settings 87 * queryByExample for T with the given Settings
88 * 88 *
89 */ 89 */
90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
91 91
92 /** 92 /**
93 * find the OPimRecord with uid @param uid 93 * find the OPimRecord with uid @param uid
94 * returns T and T.isEmpty() if nothing was found 94 * returns T and T.isEmpty() if nothing was found
95 */ 95 */
96 virtual T find(int uid )const = 0; 96 virtual T find(int uid )const = 0;
97 97
98 virtual T find(int uid, const QArray<int>& items, 98 virtual T find(int uid, const QArray<int>& items,
99 uint current, typename Frontend::CacheDirection )const ; 99 uint current, typename Frontend::CacheDirection )const ;
100 /** 100 /**
101 * clear the back end 101 * clear the back end
102 */ 102 */
103 virtual void clear() = 0; 103 virtual void clear() = 0;
104 104
105 /** 105 /**
106 * add T 106 * add T
107 */ 107 */
108 virtual bool add( const T& t ) = 0; 108 virtual bool add( const T& t ) = 0;
109 109
110 /** 110 /**
111 * remove 111 * remove
112 */ 112 */
113 virtual bool remove( int uid ) = 0; 113 virtual bool remove( int uid ) = 0;
114 114
115 /** 115 /**
116 * replace a record with T.uid() 116 * replace a record with T.uid()
117 */ 117 */
118 virtual bool replace( const T& t ) = 0; 118 virtual bool replace( const T& t ) = 0;
119 119
120 /* 120 /*
121 * setTheFrontEnd!!! 121 * setTheFrontEnd!!!
122 */ 122 */
123 void setFrontend( Frontend* front ); 123 void setFrontend( Frontend* front );
124 124
125 /** 125 /**
126 * set the read ahead count 126 * set the read ahead count
127 */ 127 */
128 void setReadAhead( uint count ); 128 void setReadAhead( uint count );
129protected: 129protected:
130 int access()const; 130 int access()const;
131 void cache( const T& t )const; 131 void cache( const T& t )const;
132 132
133 /** 133 /**
134 * use a prime number here! 134 * use a prime number here!
135 */ 135 */
136 void setSaneCacheSize( int ); 136 void setSaneCacheSize( int );
137 137
138 uint readAhead()const; 138 uint readAhead()const;
139 139
140private: 140private:
141 OPimAccessBackendPrivate *d; 141 OPimAccessBackendPrivate *d;
142 Frontend* m_front; 142 Frontend* m_front;
143 uint m_read; 143 uint m_read;
144 int m_acc; 144 int m_acc;
145 145
146}; 146};
147 147
148template <class T> 148template <class T>
149OPimAccessBackend<T>::OPimAccessBackend(int acc) 149OPimAccessBackend<T>::OPimAccessBackend(int acc)
150 : m_acc( acc ) 150 : m_acc( acc )
151{ 151{
152 m_front = 0l; 152 m_front = 0l;
153} 153}
154template <class T> 154template <class T>
155OPimAccessBackend<T>::~OPimAccessBackend() { 155OPimAccessBackend<T>::~OPimAccessBackend() {
156 156
157} 157}
158template <class T> 158template <class T>
159void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 159void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
160 m_front = fr; 160 m_front = fr;
161} 161}
162template <class T> 162template <class T>
163void OPimAccessBackend<T>::cache( const T& t )const { 163void OPimAccessBackend<T>::cache( const T& t )const {
164 if (m_front ) 164 if (m_front )
165 m_front->cache( t ); 165 m_front->cache( t );
166} 166}
167template <class T> 167template <class T>
168void OPimAccessBackend<T>::setSaneCacheSize( int size) { 168void OPimAccessBackend<T>::setSaneCacheSize( int size) {
169 if (m_front ) 169 if (m_front )
170 m_front->setSaneCacheSize( size ); 170 m_front->setSaneCacheSize( size );
171} 171}
172template <class T> 172template <class T>
173T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 173T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
174 uint, typename Frontend::CacheDirection )const { 174 uint, typename Frontend::CacheDirection )const {
175 return find( uid ); 175 return find( uid );
176} 176}
177template <class T> 177template <class T>
178void OPimAccessBackend<T>::setReadAhead( uint count ) { 178void OPimAccessBackend<T>::setReadAhead( uint count ) {
179 m_read = count; 179 m_read = count;
180} 180}
181template <class T> 181template <class T>
182uint OPimAccessBackend<T>::readAhead()const { 182uint OPimAccessBackend<T>::readAhead()const {
183 return m_read; 183 return m_read;
184} 184}
185template <class T> 185template <class T>
186int OPimAccessBackend<T>::access()const { 186int OPimAccessBackend<T>::access()const {
187 return m_acc; 187 return m_acc;
188} 188}
189 189
190} 190}
191 191
192#endif 192#endif
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp
index d27f5ef..790a764 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.cpp
+++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp
@@ -1,41 +1,41 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <opie2/otodoaccessbackend.h> 30#include <opie2/otodoaccessbackend.h>
31 31
32namespace Opie { 32namespace Opie {
33OTodoAccessBackend::OTodoAccessBackend() 33OPimTodoAccessBackend::OPimTodoAccessBackend()
34 : OPimAccessBackend<OTodo>() 34 : OPimAccessBackend<OPimTodo>()
35{ 35{
36} 36}
37OTodoAccessBackend::~OTodoAccessBackend() { 37OPimTodoAccessBackend::~OPimTodoAccessBackend() {
38 38
39} 39}
40 40
41} 41}
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 54b52cc..9dfda45 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -1,59 +1,59 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_TODO_ACCESS_BACKEND_H 29#ifndef OPIE_TODO_ACCESS_BACKEND_H
30#define OPIE_TODO_ACCESS_BACKEND_H 30#define OPIE_TODO_ACCESS_BACKEND_H
31 31
32#include <qbitarray.h> 32#include <qbitarray.h>
33 33
34#include <opie2/otodo.h> 34#include <opie2/opimtodo.h>
35#include <opie2/opimaccessbackend.h> 35#include <opie2/opimaccessbackend.h>
36 36
37namespace Opie { 37namespace Opie {
38class OTodoAccessBackend : public OPimAccessBackend<OTodo> { 38class OPimTodoAccessBackend : public OPimAccessBackend<OPimTodo> {
39public: 39public:
40 OTodoAccessBackend(); 40 OPimTodoAccessBackend();
41 ~OTodoAccessBackend(); 41 ~OPimTodoAccessBackend();
42 virtual QArray<int> effectiveToDos( const QDate& start, 42 virtual QArray<int> effectiveToDos( const QDate& start,
43 const QDate& end, 43 const QDate& end,
44 bool includeNoDates ) = 0; 44 bool includeNoDates ) = 0;
45 virtual QArray<int> overDue() = 0; 45 virtual QArray<int> overDue() = 0;
46 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 46 virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
47 int cat ) = 0; 47 int cat ) = 0;
48 virtual void removeAllCompleted() = 0; 48 virtual void removeAllCompleted() = 0;
49 virtual QBitArray supports()const = 0; 49 virtual QBitArray supports()const = 0;
50 50
51private: 51private:
52 class Private; 52 class Private;
53 Private *d; 53 Private *d;
54 54
55}; 55};
56 56
57} 57}
58 58
59#endif 59#endif
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 944f82a..72232e5 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -1,726 +1,726 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32#include <qpe/global.h> 32#include <qpe/global.h>
33 33
34#include <opie2/osqldriver.h> 34#include <opie2/osqldriver.h>
35#include <opie2/osqlresult.h> 35#include <opie2/osqlresult.h>
36#include <opie2/osqlmanager.h> 36#include <opie2/osqlmanager.h>
37#include <opie2/osqlquery.h> 37#include <opie2/osqlquery.h>
38 38
39#include <opie2/otodoaccesssql.h> 39#include <opie2/otodoaccesssql.h>
40#include <opie2/opimstate.h> 40#include <opie2/opimstate.h>
41#include <opie2/opimnotifymanager.h> 41#include <opie2/opimnotifymanager.h>
42#include <opie2/orecur.h> 42#include <opie2/opimrecurrence.h>
43 43
44using namespace Opie; 44using namespace Opie;
45/* 45/*
46 * first some query 46 * first some query
47 * CREATE query 47 * CREATE query
48 * LOAD query 48 * LOAD query
49 * INSERT 49 * INSERT
50 * REMOVE 50 * REMOVE
51 * CLEAR 51 * CLEAR
52 */ 52 */
53namespace { 53namespace {
54 /** 54 /**
55 * CreateQuery for the Todolist Table 55 * CreateQuery for the Todolist Table
56 */ 56 */
57 class CreateQuery : public OSQLQuery { 57 class CreateQuery : public OSQLQuery {
58 public: 58 public:
59 CreateQuery(); 59 CreateQuery();
60 ~CreateQuery(); 60 ~CreateQuery();
61 QString query()const; 61 QString query()const;
62 }; 62 };
63 63
64 /** 64 /**
65 * LoadQuery 65 * LoadQuery
66 * this one queries for all uids 66 * this one queries for all uids
67 */ 67 */
68 class LoadQuery : public OSQLQuery { 68 class LoadQuery : public OSQLQuery {
69 public: 69 public:
70 LoadQuery(); 70 LoadQuery();
71 ~LoadQuery(); 71 ~LoadQuery();
72 QString query()const; 72 QString query()const;
73 }; 73 };
74 74
75 /** 75 /**
76 * inserts/adds a OTodo to the table 76 * inserts/adds a OPimTodo to the table
77 */ 77 */
78 class InsertQuery : public OSQLQuery { 78 class InsertQuery : public OSQLQuery {
79 public: 79 public:
80 InsertQuery(const OTodo& ); 80 InsertQuery(const OPimTodo& );
81 ~InsertQuery(); 81 ~InsertQuery();
82 QString query()const; 82 QString query()const;
83 private: 83 private:
84 OTodo m_todo; 84 OPimTodo m_todo;
85 }; 85 };
86 86
87 /** 87 /**
88 * removes one from the table 88 * removes one from the table
89 */ 89 */
90 class RemoveQuery : public OSQLQuery { 90 class RemoveQuery : public OSQLQuery {
91 public: 91 public:
92 RemoveQuery(int uid ); 92 RemoveQuery(int uid );
93 ~RemoveQuery(); 93 ~RemoveQuery();
94 QString query()const; 94 QString query()const;
95 private: 95 private:
96 int m_uid; 96 int m_uid;
97 }; 97 };
98 98
99 /** 99 /**
100 * Clears (delete) a Table 100 * Clears (delete) a Table
101 */ 101 */
102 class ClearQuery : public OSQLQuery { 102 class ClearQuery : public OSQLQuery {
103 public: 103 public:
104 ClearQuery(); 104 ClearQuery();
105 ~ClearQuery(); 105 ~ClearQuery();
106 QString query()const; 106 QString query()const;
107 107
108 }; 108 };
109 109
110 /** 110 /**
111 * a find query 111 * a find query
112 */ 112 */
113 class FindQuery : public OSQLQuery { 113 class FindQuery : public OSQLQuery {
114 public: 114 public:
115 FindQuery(int uid); 115 FindQuery(int uid);
116 FindQuery(const QArray<int>& ); 116 FindQuery(const QArray<int>& );
117 ~FindQuery(); 117 ~FindQuery();
118 QString query()const; 118 QString query()const;
119 private: 119 private:
120 QString single()const; 120 QString single()const;
121 QString multi()const; 121 QString multi()const;
122 QArray<int> m_uids; 122 QArray<int> m_uids;
123 int m_uid; 123 int m_uid;
124 }; 124 };
125 125
126 /** 126 /**
127 * overdue query 127 * overdue query
128 */ 128 */
129 class OverDueQuery : public OSQLQuery { 129 class OverDueQuery : public OSQLQuery {
130 public: 130 public:
131 OverDueQuery(); 131 OverDueQuery();
132 ~OverDueQuery(); 132 ~OverDueQuery();
133 QString query()const; 133 QString query()const;
134 }; 134 };
135 class EffQuery : public OSQLQuery { 135 class EffQuery : public OSQLQuery {
136 public: 136 public:
137 EffQuery( const QDate&, const QDate&, bool inc ); 137 EffQuery( const QDate&, const QDate&, bool inc );
138 ~EffQuery(); 138 ~EffQuery();
139 QString query()const; 139 QString query()const;
140 private: 140 private:
141 QString with()const; 141 QString with()const;
142 QString out()const; 142 QString out()const;
143 QDate m_start; 143 QDate m_start;
144 QDate m_end; 144 QDate m_end;
145 bool m_inc :1; 145 bool m_inc :1;
146 }; 146 };
147 147
148 148
149 CreateQuery::CreateQuery() : OSQLQuery() {} 149 CreateQuery::CreateQuery() : OSQLQuery() {}
150 CreateQuery::~CreateQuery() {} 150 CreateQuery::~CreateQuery() {}
151 QString CreateQuery::query()const { 151 QString CreateQuery::query()const {
152 QString qu; 152 QString qu;
153 qu += "create table todolist( uid PRIMARY KEY, categories, completed, "; 153 qu += "create table todolist( uid PRIMARY KEY, categories, completed, ";
154 qu += "description, summary, priority, DueDate, progress , state, "; 154 qu += "description, summary, priority, DueDate, progress , state, ";
155 // This is the recurrance-stuff .. Exceptions are currently not supported (see ORecur.cpp) ! (eilers) 155 // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers)
156 qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, "; 156 qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, ";
157 qu += "reminders, alarms, maintainer, startdate, completeddate);"; 157 qu += "reminders, alarms, maintainer, startdate, completeddate);";
158 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; 158 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
159 return qu; 159 return qu;
160 } 160 }
161 161
162 LoadQuery::LoadQuery() : OSQLQuery() {} 162 LoadQuery::LoadQuery() : OSQLQuery() {}
163 LoadQuery::~LoadQuery() {} 163 LoadQuery::~LoadQuery() {}
164 QString LoadQuery::query()const { 164 QString LoadQuery::query()const {
165 QString qu; 165 QString qu;
166 // We do not need "distinct" here. The primary key is always unique.. 166 // We do not need "distinct" here. The primary key is always unique..
167 //qu += "select distinct uid from todolist"; 167 //qu += "select distinct uid from todolist";
168 qu += "select uid from todolist"; 168 qu += "select uid from todolist";
169 169
170 return qu; 170 return qu;
171 } 171 }
172 172
173 InsertQuery::InsertQuery( const OTodo& todo ) 173 InsertQuery::InsertQuery( const OPimTodo& todo )
174 : OSQLQuery(), m_todo( todo ) { 174 : OSQLQuery(), m_todo( todo ) {
175 } 175 }
176 InsertQuery::~InsertQuery() { 176 InsertQuery::~InsertQuery() {
177 } 177 }
178 /* 178 /*
179 * converts from a OTodo to a query 179 * converts from a OPimTodo to a query
180 * we leave out X-Ref + Alarms 180 * we leave out X-Ref + Alarms
181 */ 181 */
182 QString InsertQuery::query()const{ 182 QString InsertQuery::query()const{
183 183
184 int year, month, day; 184 int year, month, day;
185 year = month = day = 0; 185 year = month = day = 0;
186 if (m_todo.hasDueDate() ) { 186 if (m_todo.hasDueDate() ) {
187 QDate date = m_todo.dueDate(); 187 QDate date = m_todo.dueDate();
188 year = date.year(); 188 year = date.year();
189 month = date.month(); 189 month = date.month();
190 day = date.day(); 190 day = date.day();
191 } 191 }
192 int sYear = 0, sMonth = 0, sDay = 0; 192 int sYear = 0, sMonth = 0, sDay = 0;
193 if( m_todo.hasStartDate() ){ 193 if( m_todo.hasStartDate() ){
194 QDate sDate = m_todo.startDate(); 194 QDate sDate = m_todo.startDate();
195 sYear = sDate.year(); 195 sYear = sDate.year();
196 sMonth= sDate.month(); 196 sMonth= sDate.month();
197 sDay = sDate.day(); 197 sDay = sDate.day();
198 } 198 }
199 199
200 int eYear = 0, eMonth = 0, eDay = 0; 200 int eYear = 0, eMonth = 0, eDay = 0;
201 if( m_todo.hasCompletedDate() ){ 201 if( m_todo.hasCompletedDate() ){
202 QDate eDate = m_todo.completedDate(); 202 QDate eDate = m_todo.completedDate();
203 eYear = eDate.year(); 203 eYear = eDate.year();
204 eMonth= eDate.month(); 204 eMonth= eDate.month();
205 eDay = eDate.day(); 205 eDay = eDate.day();
206 } 206 }
207 QString qu; 207 QString qu;
208 QMap<int, QString> recMap = m_todo.recurrence().toMap(); 208 QMap<int, QString> recMap = m_todo.recurrence().toMap();
209 qu = "insert into todolist VALUES(" 209 qu = "insert into todolist VALUES("
210 + QString::number( m_todo.uid() ) + "," 210 + QString::number( m_todo.uid() ) + ","
211 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + "," 211 + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
212 + QString::number( m_todo.isCompleted() ) + "," 212 + QString::number( m_todo.isCompleted() ) + ","
213 + "'" + m_todo.description() + "'" + "," 213 + "'" + m_todo.description() + "'" + ","
214 + "'" + m_todo.summary() + "'" + "," 214 + "'" + m_todo.summary() + "'" + ","
215 + QString::number(m_todo.priority() ) + "," 215 + QString::number(m_todo.priority() ) + ","
216 + "'" + QString::number(year) + "-" 216 + "'" + QString::number(year) + "-"
217 + QString::number(month) 217 + QString::number(month)
218 + "-" + QString::number( day ) + "'" + "," 218 + "-" + QString::number( day ) + "'" + ","
219 + QString::number( m_todo.progress() ) + "," 219 + QString::number( m_todo.progress() ) + ","
220 + QString::number( m_todo.state().state() ) + "," 220 + QString::number( m_todo.state().state() ) + ","
221 + "'" + recMap[ ORecur::RType ] + "'" + "," 221 + "'" + recMap[ OPimRecurrence::RType ] + "'" + ","
222 + "'" + recMap[ ORecur::RWeekdays ] + "'" + "," 222 + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + ","
223 + "'" + recMap[ ORecur::RPosition ] + "'" + "," 223 + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + ","
224 + "'" + recMap[ ORecur::RFreq ] + "'" + "," 224 + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + ","
225 + "'" + recMap[ ORecur::RHasEndDate ] + "'" + "," 225 + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + ","
226 + "'" + recMap[ ORecur::EndDate ] + "'" + "," 226 + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + ","
227 + "'" + recMap[ ORecur::Created ] + "'" + "," 227 + "'" + recMap[ OPimRecurrence::Created ] + "'" + ","
228 + "'" + recMap[ ORecur::Exceptions ] + "'" + ","; 228 + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ",";
229 229
230 if ( m_todo.hasNotifiers() ) { 230 if ( m_todo.hasNotifiers() ) {
231 OPimNotifyManager manager = m_todo.notifiers(); 231 OPimNotifyManager manager = m_todo.notifiers();
232 qu += "'" + manager.remindersToString() + "'" + "," 232 qu += "'" + manager.remindersToString() + "'" + ","
233 + "'" + manager.alarmsToString() + "'" + ","; 233 + "'" + manager.alarmsToString() + "'" + ",";
234 } 234 }
235 else{ 235 else{
236 qu += QString( "''" ) + "," 236 qu += QString( "''" ) + ","
237 + "''" + ","; 237 + "''" + ",";
238 } 238 }
239 239
240 qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !) 240 qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
241 + "'" + QString::number(sYear) + "-" 241 + "'" + QString::number(sYear) + "-"
242 + QString::number(sMonth) 242 + QString::number(sMonth)
243 + "-" + QString::number(sDay) + "'" + "," 243 + "-" + QString::number(sDay) + "'" + ","
244 + "'" + QString::number(eYear) + "-" 244 + "'" + QString::number(eYear) + "-"
245 + QString::number(eMonth) 245 + QString::number(eMonth)
246 + "-"+QString::number(eDay) + "'" 246 + "-"+QString::number(eDay) + "'"
247 + ")"; 247 + ")";
248 248
249 qWarning("add %s", qu.latin1() ); 249 qWarning("add %s", qu.latin1() );
250 return qu; 250 return qu;
251 } 251 }
252 252
253 RemoveQuery::RemoveQuery(int uid ) 253 RemoveQuery::RemoveQuery(int uid )
254 : OSQLQuery(), m_uid( uid ) {} 254 : OSQLQuery(), m_uid( uid ) {}
255 RemoveQuery::~RemoveQuery() {} 255 RemoveQuery::~RemoveQuery() {}
256 QString RemoveQuery::query()const { 256 QString RemoveQuery::query()const {
257 QString qu = "DELETE from todolist where uid = " + QString::number(m_uid); 257 QString qu = "DELETE from todolist where uid = " + QString::number(m_uid);
258 return qu; 258 return qu;
259 } 259 }
260 260
261 261
262 ClearQuery::ClearQuery() 262 ClearQuery::ClearQuery()
263 : OSQLQuery() {} 263 : OSQLQuery() {}
264 ClearQuery::~ClearQuery() {} 264 ClearQuery::~ClearQuery() {}
265 QString ClearQuery::query()const { 265 QString ClearQuery::query()const {
266 QString qu = "drop table todolist"; 266 QString qu = "drop table todolist";
267 return qu; 267 return qu;
268 } 268 }
269 FindQuery::FindQuery(int uid) 269 FindQuery::FindQuery(int uid)
270 : OSQLQuery(), m_uid(uid ) { 270 : OSQLQuery(), m_uid(uid ) {
271 } 271 }
272 FindQuery::FindQuery(const QArray<int>& ints) 272 FindQuery::FindQuery(const QArray<int>& ints)
273 : OSQLQuery(), m_uids(ints){ 273 : OSQLQuery(), m_uids(ints){
274 } 274 }
275 FindQuery::~FindQuery() { 275 FindQuery::~FindQuery() {
276 } 276 }
277 QString FindQuery::query()const{ 277 QString FindQuery::query()const{
278 if (m_uids.count() == 0 ) 278 if (m_uids.count() == 0 )
279 return single(); 279 return single();
280 else 280 else
281 return multi(); 281 return multi();
282 } 282 }
283 QString FindQuery::single()const{ 283 QString FindQuery::single()const{
284 QString qu = "select * from todolist where uid = " + QString::number(m_uid); 284 QString qu = "select * from todolist where uid = " + QString::number(m_uid);
285 return qu; 285 return qu;
286 } 286 }
287 QString FindQuery::multi()const { 287 QString FindQuery::multi()const {
288 QString qu = "select * from todolist where "; 288 QString qu = "select * from todolist where ";
289 for (uint i = 0; i < m_uids.count(); i++ ) { 289 for (uint i = 0; i < m_uids.count(); i++ ) {
290 qu += " UID = " + QString::number( m_uids[i] ) + " OR"; 290 qu += " UID = " + QString::number( m_uids[i] ) + " OR";
291 } 291 }
292 qu.remove( qu.length()-2, 2 ); 292 qu.remove( qu.length()-2, 2 );
293 return qu; 293 return qu;
294 } 294 }
295 295
296 OverDueQuery::OverDueQuery(): OSQLQuery() {} 296 OverDueQuery::OverDueQuery(): OSQLQuery() {}
297 OverDueQuery::~OverDueQuery() {} 297 OverDueQuery::~OverDueQuery() {}
298 QString OverDueQuery::query()const { 298 QString OverDueQuery::query()const {
299 QDate date = QDate::currentDate(); 299 QDate date = QDate::currentDate();
300 QString str; 300 QString str;
301 str = QString("select uid from todolist where DueDate ='%1-%2-%3'").arg(date.year() ).arg(date.month() ).arg(date.day() ); 301 str = QString("select uid from todolist where DueDate ='%1-%2-%3'").arg(date.year() ).arg(date.month() ).arg(date.day() );
302 302
303 return str; 303 return str;
304 } 304 }
305 305
306 306
307 EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) 307 EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc )
308 : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} 308 : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {}
309 EffQuery::~EffQuery() {} 309 EffQuery::~EffQuery() {}
310 QString EffQuery::query()const { 310 QString EffQuery::query()const {
311 return m_inc ? with() : out(); 311 return m_inc ? with() : out();
312 } 312 }
313 QString EffQuery::with()const { 313 QString EffQuery::with()const {
314 QString str; 314 QString str;
315 str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") 315 str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ")
316 .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) 316 .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() )
317 .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); 317 .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() );
318 return str; 318 return str;
319 } 319 }
320 QString EffQuery::out()const { 320 QString EffQuery::out()const {
321 QString str; 321 QString str;
322 str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") 322 str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'")
323 .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) 323 .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() )
324 .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); 324 .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() );
325 325
326 return str; 326 return str;
327 } 327 }
328}; 328};
329 329
330 330
331namespace Opie { 331namespace Opie {
332OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) 332OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file )
333 : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) 333 : OPimTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true)
334{ 334{
335 QString fi = file; 335 QString fi = file;
336 if ( fi.isEmpty() ) 336 if ( fi.isEmpty() )
337 fi = Global::applicationFileName( "todolist", "todolist.db" ); 337 fi = Global::applicationFileName( "todolist", "todolist.db" );
338 OSQLManager man; 338 OSQLManager man;
339 m_driver = man.standard(); 339 m_driver = man.standard();
340 m_driver->setUrl(fi); 340 m_driver->setUrl(fi);
341 // fillDict(); 341 // fillDict();
342} 342}
343 343
344OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ 344OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){
345 if( m_driver ) 345 if( m_driver )
346 delete m_driver; 346 delete m_driver;
347} 347}
348 348
349bool OTodoAccessBackendSQL::load(){ 349bool OPimTodoAccessBackendSQL::load(){
350 if (!m_driver->open() ) 350 if (!m_driver->open() )
351 return false; 351 return false;
352 352
353 CreateQuery creat; 353 CreateQuery creat;
354 OSQLResult res = m_driver->query(&creat ); 354 OSQLResult res = m_driver->query(&creat );
355 355
356 m_dirty = true; 356 m_dirty = true;
357 return true; 357 return true;
358} 358}
359bool OTodoAccessBackendSQL::reload(){ 359bool OPimTodoAccessBackendSQL::reload(){
360 return load(); 360 return load();
361} 361}
362 362
363bool OTodoAccessBackendSQL::save(){ 363bool OPimTodoAccessBackendSQL::save(){
364 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 364 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
365} 365}
366QArray<int> OTodoAccessBackendSQL::allRecords()const { 366QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
367 if (m_dirty ) 367 if (m_dirty )
368 update(); 368 update();
369 369
370 return m_uids; 370 return m_uids;
371} 371}
372QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int, const QDateTime& ){ 372QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){
373 QArray<int> ints(0); 373 QArray<int> ints(0);
374 return ints; 374 return ints;
375} 375}
376OTodo OTodoAccessBackendSQL::find(int uid ) const{ 376OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
377 FindQuery query( uid ); 377 FindQuery query( uid );
378 return todo( m_driver->query(&query) ); 378 return todo( m_driver->query(&query) );
379 379
380} 380}
381OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 381OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
382 uint cur, Frontend::CacheDirection dir ) const{ 382 uint cur, Frontend::CacheDirection dir ) const{
383 uint CACHE = readAhead(); 383 uint CACHE = readAhead();
384 qWarning("searching for %d", uid ); 384 qWarning("searching for %d", uid );
385 QArray<int> search( CACHE ); 385 QArray<int> search( CACHE );
386 uint size =0; 386 uint size =0;
387 OTodo to; 387 OPimTodo to;
388 388
389 // we try to cache CACHE items 389 // we try to cache CACHE items
390 switch( dir ) { 390 switch( dir ) {
391 /* forward */ 391 /* forward */
392 case 0: // FIXME: Not a good style to use magic numbers here (eilers) 392 case 0: // FIXME: Not a good style to use magic numbers here (eilers)
393 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 393 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
394 qWarning("size %d %d", size, ints[i] ); 394 qWarning("size %d %d", size, ints[i] );
395 search[size] = ints[i]; 395 search[size] = ints[i];
396 size++; 396 size++;
397 } 397 }
398 break; 398 break;
399 /* reverse */ 399 /* reverse */
400 case 1: // FIXME: Not a good style to use magic numbers here (eilers) 400 case 1: // FIXME: Not a good style to use magic numbers here (eilers)
401 for (uint i = cur; i != 0 && size < CACHE; i-- ) { 401 for (uint i = cur; i != 0 && size < CACHE; i-- ) {
402 search[size] = ints[i]; 402 search[size] = ints[i];
403 size++; 403 size++;
404 } 404 }
405 break; 405 break;
406 } 406 }
407 search.resize( size ); 407 search.resize( size );
408 FindQuery query( search ); 408 FindQuery query( search );
409 OSQLResult res = m_driver->query( &query ); 409 OSQLResult res = m_driver->query( &query );
410 if ( res.state() != OSQLResult::Success ) 410 if ( res.state() != OSQLResult::Success )
411 return to; 411 return to;
412 412
413 return todo( res ); 413 return todo( res );
414} 414}
415void OTodoAccessBackendSQL::clear() { 415void OPimTodoAccessBackendSQL::clear() {
416 ClearQuery cle; 416 ClearQuery cle;
417 OSQLResult res = m_driver->query( &cle ); 417 OSQLResult res = m_driver->query( &cle );
418 CreateQuery qu; 418 CreateQuery qu;
419 res = m_driver->query(&qu); 419 res = m_driver->query(&qu);
420} 420}
421bool OTodoAccessBackendSQL::add( const OTodo& t) { 421bool OPimTodoAccessBackendSQL::add( const OPimTodo& t) {
422 InsertQuery ins( t ); 422 InsertQuery ins( t );
423 OSQLResult res = m_driver->query( &ins ); 423 OSQLResult res = m_driver->query( &ins );
424 424
425 if ( res.state() == OSQLResult::Failure ) 425 if ( res.state() == OSQLResult::Failure )
426 return false; 426 return false;
427 int c = m_uids.count(); 427 int c = m_uids.count();
428 m_uids.resize( c+1 ); 428 m_uids.resize( c+1 );
429 m_uids[c] = t.uid(); 429 m_uids[c] = t.uid();
430 430
431 return true; 431 return true;
432} 432}
433bool OTodoAccessBackendSQL::remove( int uid ) { 433bool OPimTodoAccessBackendSQL::remove( int uid ) {
434 RemoveQuery rem( uid ); 434 RemoveQuery rem( uid );
435 OSQLResult res = m_driver->query(&rem ); 435 OSQLResult res = m_driver->query(&rem );
436 436
437 if ( res.state() == OSQLResult::Failure ) 437 if ( res.state() == OSQLResult::Failure )
438 return false; 438 return false;
439 439
440 m_dirty = true; 440 m_dirty = true;
441 return true; 441 return true;
442} 442}
443/* 443/*
444 * FIXME better set query 444 * FIXME better set query
445 * but we need the cache for that 445 * but we need the cache for that
446 * now we remove 446 * now we remove
447 */ 447 */
448bool OTodoAccessBackendSQL::replace( const OTodo& t) { 448bool OPimTodoAccessBackendSQL::replace( const OPimTodo& t) {
449 remove( t.uid() ); 449 remove( t.uid() );
450 bool b= add(t); 450 bool b= add(t);
451 m_dirty = false; // we changed some stuff but the UID stayed the same 451 m_dirty = false; // we changed some stuff but the UID stayed the same
452 return b; 452 return b;
453} 453}
454QArray<int> OTodoAccessBackendSQL::overDue() { 454QArray<int> OPimTodoAccessBackendSQL::overDue() {
455 OverDueQuery qu; 455 OverDueQuery qu;
456 return uids( m_driver->query(&qu ) ); 456 return uids( m_driver->query(&qu ) );
457} 457}
458QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s, 458QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
459 const QDate& t, 459 const QDate& t,
460 bool u) { 460 bool u) {
461 EffQuery ef(s, t, u ); 461 EffQuery ef(s, t, u );
462 return uids (m_driver->query(&ef) ); 462 return uids (m_driver->query(&ef) );
463} 463}
464/* 464/*
465 * 465 *
466 */ 466 */
467QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, 467QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
468 int sortFilter, int cat ) { 468 int sortFilter, int cat ) {
469 qWarning("sorted %d, %d", asc, sortOrder ); 469 qWarning("sorted %d, %d", asc, sortOrder );
470 QString query; 470 QString query;
471 query = "select uid from todolist WHERE "; 471 query = "select uid from todolist WHERE ";
472 472
473 /* 473 /*
474 * Sort Filter stuff 474 * Sort Filter stuff
475 * not that straight forward 475 * not that straight forward
476 * FIXME: Replace magic numbers 476 * FIXME: Replace magic numbers
477 * 477 *
478 */ 478 */
479 /* Category */ 479 /* Category */
480 if ( sortFilter & 1 ) { 480 if ( sortFilter & 1 ) {
481 QString str; 481 QString str;
482 if (cat != 0 ) str = QString::number( cat ); 482 if (cat != 0 ) str = QString::number( cat );
483 query += " categories like '%" +str+"%' AND"; 483 query += " categories like '%" +str+"%' AND";
484 } 484 }
485 /* Show only overdue */ 485 /* Show only overdue */
486 if ( sortFilter & 2 ) { 486 if ( sortFilter & 2 ) {
487 QDate date = QDate::currentDate(); 487 QDate date = QDate::currentDate();
488 QString due; 488 QString due;
489 QString base; 489 QString base;
490 base = QString("DueDate <= '%1-%2-%3' AND completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() ); 490 base = QString("DueDate <= '%1-%2-%3' AND completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() );
491 query += " " + base + " AND"; 491 query += " " + base + " AND";
492 } 492 }
493 /* not show completed */ 493 /* not show completed */
494 if ( sortFilter & 4 ) { 494 if ( sortFilter & 4 ) {
495 query += " completed = 0 AND"; 495 query += " completed = 0 AND";
496 }else{ 496 }else{
497 query += " ( completed = 1 OR completed = 0) AND"; 497 query += " ( completed = 1 OR completed = 0) AND";
498 } 498 }
499 /* srtip the end */ 499 /* srtip the end */
500 query = query.remove( query.length()-3, 3 ); 500 query = query.remove( query.length()-3, 3 );
501 501
502 502
503 /* 503 /*
504 * sort order stuff 504 * sort order stuff
505 * quite straight forward 505 * quite straight forward
506 */ 506 */
507 query += "ORDER BY "; 507 query += "ORDER BY ";
508 switch( sortOrder ) { 508 switch( sortOrder ) {
509 /* completed */ 509 /* completed */
510 case 0: 510 case 0:
511 query += "completed"; 511 query += "completed";
512 break; 512 break;
513 case 1: 513 case 1:
514 query += "priority"; 514 query += "priority";
515 break; 515 break;
516 case 2: 516 case 2:
517 query += "summary"; 517 query += "summary";
518 break; 518 break;
519 case 3: 519 case 3:
520 query += "DueDate"; 520 query += "DueDate";
521 break; 521 break;
522 } 522 }
523 523
524 if ( !asc ) { 524 if ( !asc ) {
525 qWarning("not ascending!"); 525 qWarning("not ascending!");
526 query += " DESC"; 526 query += " DESC";
527 } 527 }
528 528
529 qWarning( query ); 529 qWarning( query );
530 OSQLRawQuery raw(query ); 530 OSQLRawQuery raw(query );
531 return uids( m_driver->query(&raw) ); 531 return uids( m_driver->query(&raw) );
532} 532}
533bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 533bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
534 if ( str == "0-0-0" ) 534 if ( str == "0-0-0" )
535 return false; 535 return false;
536 else{ 536 else{
537 int day, year, month; 537 int day, year, month;
538 QStringList list = QStringList::split("-", str ); 538 QStringList list = QStringList::split("-", str );
539 year = list[0].toInt(); 539 year = list[0].toInt();
540 month = list[1].toInt(); 540 month = list[1].toInt();
541 day = list[2].toInt(); 541 day = list[2].toInt();
542 da.setYMD( year, month, day ); 542 da.setYMD( year, month, day );
543 return true; 543 return true;
544 } 544 }
545} 545}
546OTodo OTodoAccessBackendSQL::todo( const OSQLResult& res) const{ 546OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res) const{
547 if ( res.state() == OSQLResult::Failure ) { 547 if ( res.state() == OSQLResult::Failure ) {
548 OTodo to; 548 OPimTodo to;
549 return to; 549 return to;
550 } 550 }
551 551
552 OSQLResultItem::ValueList list = res.results(); 552 OSQLResultItem::ValueList list = res.results();
553 OSQLResultItem::ValueList::Iterator it = list.begin(); 553 OSQLResultItem::ValueList::Iterator it = list.begin();
554 qWarning("todo1"); 554 qWarning("todo1");
555 OTodo to = todo( (*it) ); 555 OPimTodo to = todo( (*it) );
556 cache( to ); 556 cache( to );
557 ++it; 557 ++it;
558 558
559 for ( ; it != list.end(); ++it ) { 559 for ( ; it != list.end(); ++it ) {
560 qWarning("caching"); 560 qWarning("caching");
561 cache( todo( (*it) ) ); 561 cache( todo( (*it) ) );
562 } 562 }
563 return to; 563 return to;
564} 564}
565OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 565OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
566 qWarning("todo"); 566 qWarning("todo");
567 bool hasDueDate = false; QDate dueDate = QDate::currentDate(); 567 bool hasDueDate = false; QDate dueDate = QDate::currentDate();
568 hasDueDate = date( dueDate, item.data("DueDate") ); 568 hasDueDate = date( dueDate, item.data("DueDate") );
569 QStringList cats = QStringList::split(";", item.data("categories") ); 569 QStringList cats = QStringList::split(";", item.data("categories") );
570 570
571 qWarning("Item is completed: %d", item.data("completed").toInt() ); 571 qWarning("Item is completed: %d", item.data("completed").toInt() );
572 572
573 OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 573 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
574 cats, item.data("summary"), item.data("description"), 574 cats, item.data("summary"), item.data("description"),
575 item.data("progress").toUShort(), hasDueDate, dueDate, 575 item.data("progress").toUShort(), hasDueDate, dueDate,
576 item.data("uid").toInt() ); 576 item.data("uid").toInt() );
577 577
578 bool isOk; 578 bool isOk;
579 int prioInt = QString( item.data("priority") ).toInt( &isOk ); 579 int prioInt = QString( item.data("priority") ).toInt( &isOk );
580 if ( isOk ) 580 if ( isOk )
581 to.setPriority( prioInt ); 581 to.setPriority( prioInt );
582 582
583 bool hasStartDate = false; QDate startDate = QDate::currentDate(); 583 bool hasStartDate = false; QDate startDate = QDate::currentDate();
584 hasStartDate = date( startDate, item.data("startdate") ); 584 hasStartDate = date( startDate, item.data("startdate") );
585 bool hasCompletedDate = false; QDate completedDate = QDate::currentDate(); 585 bool hasCompletedDate = false; QDate completedDate = QDate::currentDate();
586 hasCompletedDate = date( completedDate, item.data("completeddate") ); 586 hasCompletedDate = date( completedDate, item.data("completeddate") );
587 587
588 if ( hasStartDate ) 588 if ( hasStartDate )
589 to.setStartDate( startDate ); 589 to.setStartDate( startDate );
590 if ( hasCompletedDate ) 590 if ( hasCompletedDate )
591 to.setCompletedDate( completedDate ); 591 to.setCompletedDate( completedDate );
592 592
593 OPimNotifyManager& manager = to.notifiers(); 593 OPimNotifyManager& manager = to.notifiers();
594 manager.alarmsFromString( item.data("alarms") ); 594 manager.alarmsFromString( item.data("alarms") );
595 manager.remindersFromString( item.data("reminders") ); 595 manager.remindersFromString( item.data("reminders") );
596 596
597 OPimState pimState; 597 OPimState pimState;
598 pimState.setState( QString( item.data("state") ).toInt() ); 598 pimState.setState( QString( item.data("state") ).toInt() );
599 to.setState( pimState ); 599 to.setState( pimState );
600 600
601 QMap<int, QString> recMap; 601 QMap<int, QString> recMap;
602 recMap.insert( ORecur::RType , item.data("RType") ); 602 recMap.insert( OPimRecurrence::RType , item.data("RType") );
603 recMap.insert( ORecur::RWeekdays , item.data("RWeekdays") ); 603 recMap.insert( OPimRecurrence::RWeekdays , item.data("RWeekdays") );
604 recMap.insert( ORecur::RPosition , item.data("RPosition") ); 604 recMap.insert( OPimRecurrence::RPosition , item.data("RPosition") );
605 recMap.insert( ORecur::RFreq , item.data("RFreq") ); 605 recMap.insert( OPimRecurrence::RFreq , item.data("RFreq") );
606 recMap.insert( ORecur::RHasEndDate, item.data("RHasEndDate") ); 606 recMap.insert( OPimRecurrence::RHasEndDate, item.data("RHasEndDate") );
607 recMap.insert( ORecur::EndDate , item.data("EndDate") ); 607 recMap.insert( OPimRecurrence::EndDate , item.data("EndDate") );
608 recMap.insert( ORecur::Created , item.data("Created") ); 608 recMap.insert( OPimRecurrence::Created , item.data("Created") );
609 recMap.insert( ORecur::Exceptions , item.data("Exceptions") ); 609 recMap.insert( OPimRecurrence::Exceptions , item.data("Exceptions") );
610 610
611 ORecur recur; 611 OPimRecurrence recur;
612 recur.fromMap( recMap ); 612 recur.fromMap( recMap );
613 to.setRecurrence( recur ); 613 to.setRecurrence( recur );
614 614
615 return to; 615 return to;
616} 616}
617OTodo OTodoAccessBackendSQL::todo( int uid )const { 617OPimTodo OPimTodoAccessBackendSQL::todo( int uid )const {
618 FindQuery find( uid ); 618 FindQuery find( uid );
619 return todo( m_driver->query(&find) ); 619 return todo( m_driver->query(&find) );
620} 620}
621/* 621/*
622 * update the dict 622 * update the dict
623 */ 623 */
624void OTodoAccessBackendSQL::fillDict() { 624void OPimTodoAccessBackendSQL::fillDict() {
625 /* initialize dict */ 625 /* initialize dict */
626 /* 626 /*
627 * UPDATE dict if you change anything!!! 627 * UPDATE dict if you change anything!!!
628 * FIXME: Isn't this dict obsolete ? (eilers) 628 * FIXME: Isn't this dict obsolete ? (eilers)
629 */ 629 */
630 m_dict.setAutoDelete( TRUE ); 630 m_dict.setAutoDelete( TRUE );
631 m_dict.insert("Categories" , new int(OTodo::Category) ); 631 m_dict.insert("Categories" , new int(OPimTodo::Category) );
632 m_dict.insert("Uid" , new int(OTodo::Uid) ); 632 m_dict.insert("Uid" , new int(OPimTodo::Uid) );
633 m_dict.insert("HasDate" , new int(OTodo::HasDate) ); 633 m_dict.insert("HasDate" , new int(OPimTodo::HasDate) );
634 m_dict.insert("Completed" , new int(OTodo::Completed) ); 634 m_dict.insert("Completed" , new int(OPimTodo::Completed) );
635 m_dict.insert("Description" , new int(OTodo::Description) ); 635 m_dict.insert("Description" , new int(OPimTodo::Description) );
636 m_dict.insert("Summary" , new int(OTodo::Summary) ); 636 m_dict.insert("Summary" , new int(OPimTodo::Summary) );
637 m_dict.insert("Priority" , new int(OTodo::Priority) ); 637 m_dict.insert("Priority" , new int(OPimTodo::Priority) );
638 m_dict.insert("DateDay" , new int(OTodo::DateDay) ); 638 m_dict.insert("DateDay" , new int(OPimTodo::DateDay) );
639 m_dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 639 m_dict.insert("DateMonth" , new int(OPimTodo::DateMonth) );
640 m_dict.insert("DateYear" , new int(OTodo::DateYear) ); 640 m_dict.insert("DateYear" , new int(OPimTodo::DateYear) );
641 m_dict.insert("Progress" , new int(OTodo::Progress) ); 641 m_dict.insert("Progress" , new int(OPimTodo::Progress) );
642 m_dict.insert("Completed", new int(OTodo::Completed) ); // Why twice ? (eilers) 642 m_dict.insert("Completed", new int(OPimTodo::Completed) ); // Why twice ? (eilers)
643 m_dict.insert("CrossReference", new int(OTodo::CrossReference) ); 643 m_dict.insert("CrossReference", new int(OPimTodo::CrossReference) );
644// m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); // old stuff (eilers) 644// m_dict.insert("HasAlarmDateTime",new int(OPimTodo::HasAlarmDateTime) ); // old stuff (eilers)
645// m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); // old stuff (eilers) 645// m_dict.insert("AlarmDateTime", new int(OPimTodo::AlarmDateTime) ); // old stuff (eilers)
646} 646}
647/* 647/*
648 * need to be const so let's fool the 648 * need to be const so let's fool the
649 * compiler :( 649 * compiler :(
650 */ 650 */
651void OTodoAccessBackendSQL::update()const { 651void OPimTodoAccessBackendSQL::update()const {
652 ((OTodoAccessBackendSQL*)this)->m_dirty = false; 652 ((OPimTodoAccessBackendSQL*)this)->m_dirty = false;
653 LoadQuery lo; 653 LoadQuery lo;
654 OSQLResult res = m_driver->query(&lo); 654 OSQLResult res = m_driver->query(&lo);
655 if ( res.state() != OSQLResult::Success ) 655 if ( res.state() != OSQLResult::Success )
656 return; 656 return;
657 657
658 ((OTodoAccessBackendSQL*)this)->m_uids = uids( res ); 658 ((OPimTodoAccessBackendSQL*)this)->m_uids = uids( res );
659} 659}
660QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ 660QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
661 661
662 OSQLResultItem::ValueList list = res.results(); 662 OSQLResultItem::ValueList list = res.results();
663 OSQLResultItem::ValueList::Iterator it; 663 OSQLResultItem::ValueList::Iterator it;
664 QArray<int> ints(list.count() ); 664 QArray<int> ints(list.count() );
665 qWarning(" count = %d", list.count() ); 665 qWarning(" count = %d", list.count() );
666 666
667 int i = 0; 667 int i = 0;
668 for (it = list.begin(); it != list.end(); ++it ) { 668 for (it = list.begin(); it != list.end(); ++it ) {
669 ints[i] = (*it).data("uid").toInt(); 669 ints[i] = (*it).data("uid").toInt();
670 i++; 670 i++;
671 } 671 }
672 return ints; 672 return ints;
673} 673}
674 674
675QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const 675QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
676{ 676{
677 677
678#warning OTodoAccessBackendSQL::matchRegexp() not implemented !! 678#warning OPimTodoAccessBackendSQL::matchRegexp() not implemented !!
679 679
680#if 0 680#if 0
681 681
682 Copied from xml-backend by not adapted to sql (eilers) 682 Copied from xml-backend by not adapted to sql (eilers)
683 683
684 QArray<int> m_currentQuery( m_events.count() ); 684 QArray<int> m_currentQuery( m_events.count() );
685 uint arraycounter = 0; 685 uint arraycounter = 0;
686 686
687 687
688 688
689 QMap<int, OTodo>::ConstIterator it; 689 QMap<int, OPimTodo>::ConstIterator it;
690 for (it = m_events.begin(); it != m_events.end(); ++it ) { 690 for (it = m_events.begin(); it != m_events.end(); ++it ) {
691 if ( it.data().match( r ) ) 691 if ( it.data().match( r ) )
692 m_currentQuery[arraycounter++] = it.data().uid(); 692 m_currentQuery[arraycounter++] = it.data().uid();
693 693
694 } 694 }
695 // Shrink to fit.. 695 // Shrink to fit..
696 m_currentQuery.resize(arraycounter); 696 m_currentQuery.resize(arraycounter);
697 697
698 return m_currentQuery; 698 return m_currentQuery;
699#endif 699#endif
700 QArray<int> empty; 700 QArray<int> empty;
701 return empty; 701 return empty;
702} 702}
703QBitArray OTodoAccessBackendSQL::supports()const { 703QBitArray OPimTodoAccessBackendSQL::supports()const {
704 704
705 return sup(); 705 return sup();
706} 706}
707 707
708QBitArray OTodoAccessBackendSQL::sup() const{ 708QBitArray OPimTodoAccessBackendSQL::sup() const{
709 709
710 QBitArray ar( OTodo::CompletedDate + 1 ); 710 QBitArray ar( OPimTodo::CompletedDate + 1 );
711 ar.fill( true ); 711 ar.fill( true );
712 ar[OTodo::CrossReference] = false; 712 ar[OPimTodo::CrossReference] = false;
713 ar[OTodo::State ] = false; 713 ar[OPimTodo::State ] = false;
714 ar[OTodo::Reminders] = false; 714 ar[OPimTodo::Reminders] = false;
715 ar[OTodo::Notifiers] = false; 715 ar[OPimTodo::Notifiers] = false;
716 ar[OTodo::Maintainer] = false; 716 ar[OPimTodo::Maintainer] = false;
717 717
718 return ar; 718 return ar;
719} 719}
720 720
721void OTodoAccessBackendSQL::removeAllCompleted(){ 721void OPimTodoAccessBackendSQL::removeAllCompleted(){
722#warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! 722#warning OPimTodoAccessBackendSQL::removeAllCompleted() not implemented !!
723 723
724} 724}
725 725
726} 726}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 1a6f614..e945863 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -1,88 +1,88 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_ACCESS_SQL_H 29#ifndef OPIE_PIM_ACCESS_SQL_H
30#define OPIE_PIM_ACCESS_SQL_H 30#define OPIE_PIM_ACCESS_SQL_H
31 31
32#include <qasciidict.h> 32#include <qasciidict.h>
33 33
34#include <opie2/otodoaccessbackend.h> 34#include <opie2/otodoaccessbackend.h>
35 35
36class OSQLDriver; 36class OSQLDriver;
37class OSQLResult; 37class OSQLResult;
38class OSQLResultItem; 38class OSQLResultItem;
39 39
40namespace Opie { 40namespace Opie {
41 41
42class OTodoAccessBackendSQL : public OTodoAccessBackend { 42class OPimTodoAccessBackendSQL : public OPimTodoAccessBackend {
43public: 43public:
44 OTodoAccessBackendSQL( const QString& file ); 44 OPimTodoAccessBackendSQL( const QString& file );
45 ~OTodoAccessBackendSQL(); 45 ~OPimTodoAccessBackendSQL();
46 46
47 bool load(); 47 bool load();
48 bool reload(); 48 bool reload();
49 bool save(); 49 bool save();
50 QArray<int> allRecords()const; 50 QArray<int> allRecords()const;
51 51
52 QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); 52 QArray<int> queryByExample( const OPimTodo& t, int settings, const QDateTime& d = QDateTime() );
53 OTodo find(int uid)const; 53 OPimTodo find(int uid)const;
54 OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 54 OPimTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
55 void clear(); 55 void clear();
56 bool add( const OTodo& t ); 56 bool add( const OPimTodo& t );
57 bool remove( int uid ); 57 bool remove( int uid );
58 bool replace( const OTodo& t ); 58 bool replace( const OPimTodo& t );
59 59
60 QArray<int> overDue(); 60 QArray<int> overDue();
61 QArray<int> effectiveToDos( const QDate& start, 61 QArray<int> effectiveToDos( const QDate& start,
62 const QDate& end, bool includeNoDates ); 62 const QDate& end, bool includeNoDates );
63 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); 63 QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
64 64
65 QBitArray supports()const; 65 QBitArray supports()const;
66 QArray<int> matchRegexp( const QRegExp &r ) const; 66 QArray<int> matchRegexp( const QRegExp &r ) const;
67 void removeAllCompleted(); 67 void removeAllCompleted();
68 68
69 69
70private: 70private:
71 void update()const; 71 void update()const;
72 void fillDict(); 72 void fillDict();
73 inline bool date( QDate& date, const QString& )const; 73 inline bool date( QDate& date, const QString& )const;
74 inline OTodo todo( const OSQLResult& )const; 74 inline OPimTodo todo( const OSQLResult& )const;
75 inline OTodo todo( OSQLResultItem& )const; 75 inline OPimTodo todo( OSQLResultItem& )const;
76 inline QArray<int> uids( const OSQLResult& )const; 76 inline QArray<int> uids( const OSQLResult& )const;
77 OTodo todo( int uid )const; 77 OPimTodo todo( int uid )const;
78 QBitArray sup() const; 78 QBitArray sup() const;
79 79
80 QAsciiDict<int> m_dict; 80 QAsciiDict<int> m_dict;
81 OSQLDriver* m_driver; 81 OSQLDriver* m_driver;
82 QArray<int> m_uids; 82 QArray<int> m_uids;
83 bool m_dirty : 1; 83 bool m_dirty : 1;
84}; 84};
85 85
86} 86}
87 87
88#endif 88#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index e364ee2..0a1baf9 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,282 +1,282 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include <qtopia/private/vobject_p.h> 31#include <qtopia/private/vobject_p.h>
32#include <qtopia/timeconversion.h> 32#include <qtopia/timeconversion.h>
33#include <qtopia/private/qfiledirect_p.h> 33#include <qtopia/private/qfiledirect_p.h>
34 34
35#include <opie2/otodoaccessvcal.h> 35#include <opie2/otodoaccessvcal.h>
36 36
37using namespace Opie; 37using namespace Opie;
38 38
39namespace { 39namespace {
40 static OTodo eventByVObj( VObject *obj ){ 40 static OPimTodo eventByVObj( VObject *obj ){
41 OTodo event; 41 OPimTodo event;
42 VObject *ob; 42 VObject *ob;
43 QCString name; 43 QCString name;
44 // no uid, attendees, ... and no fun 44 // no uid, attendees, ... and no fun
45 // description 45 // description
46 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 46 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
47 name = vObjectStringZValue( ob ); 47 name = vObjectStringZValue( ob );
48#if 0 48#if 0
49 event.setDescription( name ); 49 event.setDescription( name );
50#else 50#else
51 event.setSummary( name ); 51 event.setSummary( name );
52#endif 52#endif
53 } 53 }
54 // summary 54 // summary
55 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { 55 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
56 name = vObjectStringZValue( ob ); 56 name = vObjectStringZValue( ob );
57#if 0 57#if 0
58 event.setSummary( name ); 58 event.setSummary( name );
59#else 59#else
60 event.setDescription( name ); 60 event.setDescription( name );
61#endif 61#endif
62 } 62 }
63 // completed 63 // completed
64 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 64 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
65 name = vObjectStringZValue( ob ); 65 name = vObjectStringZValue( ob );
66 if( name == "COMPLETED" ){ 66 if( name == "COMPLETED" ){
67 event.setCompleted( true ); 67 event.setCompleted( true );
68 }else{ 68 }else{
69 event.setCompleted( false ); 69 event.setCompleted( false );
70 } 70 }
71 }else 71 }else
72 event.setCompleted( false ); 72 event.setCompleted( false );
73 // priority 73 // priority
74 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 74 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
75 name = vObjectStringZValue( ob ); 75 name = vObjectStringZValue( ob );
76 bool ok; 76 bool ok;
77 event.setPriority(name.toInt(&ok) ); 77 event.setPriority(name.toInt(&ok) );
78 } 78 }
79 //due date 79 //due date
80 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 80 if((ob = isAPropertyOf(obj, VCDueProp)) ){
81 event.setHasDueDate( true ); 81 event.setHasDueDate( true );
82 name = vObjectStringZValue( ob ); 82 name = vObjectStringZValue( ob );
83 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 83 event.setDueDate( TimeConversion::fromISO8601( name).date() );
84 } 84 }
85 // categories 85 // categories
86 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 86 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
87 name = vObjectStringZValue( ob ); 87 name = vObjectStringZValue( ob );
88 qWarning("Categories:%s", name.data() ); 88 qWarning("Categories:%s", name.data() );
89 } 89 }
90 90
91 event.setUid( 1 ); 91 event.setUid( 1 );
92 return event; 92 return event;
93 }; 93 };
94 static VObject *vobjByEvent( const OTodo &event ) { 94 static VObject *vobjByEvent( const OPimTodo &event ) {
95 VObject *task = newVObject( VCTodoProp ); 95 VObject *task = newVObject( VCTodoProp );
96 if( task == 0 ) 96 if( task == 0 )
97 return 0l; 97 return 0l;
98 98
99 if( event.hasDueDate() ) { 99 if( event.hasDueDate() ) {
100 QTime time(0, 0, 0); 100 QTime time(0, 0, 0);
101 QDateTime date(event.dueDate(), time ); 101 QDateTime date(event.dueDate(), time );
102 addPropValue( task, VCDueProp, 102 addPropValue( task, VCDueProp,
103 TimeConversion::toISO8601( date ) ); 103 TimeConversion::toISO8601( date ) );
104 } 104 }
105 105
106 if( event.isCompleted() ) 106 if( event.isCompleted() )
107 addPropValue( task, VCStatusProp, "COMPLETED"); 107 addPropValue( task, VCStatusProp, "COMPLETED");
108 108
109 QString string = QString::number(event.priority() ); 109 QString string = QString::number(event.priority() );
110 addPropValue( task, VCPriorityProp, string.local8Bit() ); 110 addPropValue( task, VCPriorityProp, string.local8Bit() );
111 111
112 addPropValue( task, VCCategoriesProp, 112 addPropValue( task, VCCategoriesProp,
113 event.idsToString( event.categories() ).local8Bit() ); 113 event.idsToString( event.categories() ).local8Bit() );
114 114
115#if 0 115#if 0
116 116
117 // There seems a misrepresentation between summary in otodoevent 117 // There seems a misrepresentation between summary in otodoevent
118 // and summary in vcard. 118 // and summary in vcard.
119 // The same with description.. 119 // The same with description..
120 // Description is summary and vice versa.. Argh.. (eilers) 120 // Description is summary and vice versa.. Argh.. (eilers)
121 121
122 122
123 addPropValue( task, VCDescriptionProp, 123 addPropValue( task, VCDescriptionProp,
124 event.description().local8Bit() ); 124 event.description().local8Bit() );
125 125
126 addPropValue( task, VCSummaryProp, 126 addPropValue( task, VCSummaryProp,
127 event.summary().local8Bit() ); 127 event.summary().local8Bit() );
128 128
129#else 129#else
130 addPropValue( task, VCDescriptionProp, 130 addPropValue( task, VCDescriptionProp,
131 event.summary().local8Bit() ); 131 event.summary().local8Bit() );
132 132
133 addPropValue( task, VCSummaryProp, 133 addPropValue( task, VCSummaryProp,
134 event.description().local8Bit() ); 134 event.description().local8Bit() );
135#endif 135#endif
136 return task; 136 return task;
137}; 137};
138} 138}
139 139
140namespace Opie { 140namespace Opie {
141OTodoAccessVCal::OTodoAccessVCal( const QString& path ) 141OPimTodoAccessVCal::OPimTodoAccessVCal( const QString& path )
142 : m_dirty(false), m_file( path ) 142 : m_dirty(false), m_file( path )
143{ 143{
144} 144}
145OTodoAccessVCal::~OTodoAccessVCal() { 145OPimTodoAccessVCal::~OPimTodoAccessVCal() {
146} 146}
147bool OTodoAccessVCal::load() { 147bool OPimTodoAccessVCal::load() {
148 m_map.clear(); 148 m_map.clear();
149 m_dirty = false; 149 m_dirty = false;
150 150
151 VObject* vcal = 0l; 151 VObject* vcal = 0l;
152 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 152 vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
153 if (!vcal ) 153 if (!vcal )
154 return false; 154 return false;
155 155
156 // Iterate over the list 156 // Iterate over the list
157 VObjectIterator it; 157 VObjectIterator it;
158 VObject* vobj; 158 VObject* vobj;
159 159
160 initPropIterator(&it, vcal); 160 initPropIterator(&it, vcal);
161 161
162 while( moreIteration( &it ) ) { 162 while( moreIteration( &it ) ) {
163 vobj = ::nextVObject( &it ); 163 vobj = ::nextVObject( &it );
164 QCString name = ::vObjectName( vobj ); 164 QCString name = ::vObjectName( vobj );
165 if( name == VCTodoProp ){ 165 if( name == VCTodoProp ){
166 OTodo to = eventByVObj( vobj ); 166 OPimTodo to = eventByVObj( vobj );
167 m_map.insert( to.uid(), to ); 167 m_map.insert( to.uid(), to );
168 } 168 }
169 } 169 }
170 170
171 // Should I do a delete vcal? 171 // Should I do a delete vcal?
172 172
173 return true; 173 return true;
174} 174}
175bool OTodoAccessVCal::reload() { 175bool OPimTodoAccessVCal::reload() {
176 return load(); 176 return load();
177} 177}
178bool OTodoAccessVCal::save() { 178bool OPimTodoAccessVCal::save() {
179 if (!m_dirty ) 179 if (!m_dirty )
180 return true; 180 return true;
181 181
182 QFileDirect file( m_file ); 182 QFileDirect file( m_file );
183 if (!file.open(IO_WriteOnly ) ) 183 if (!file.open(IO_WriteOnly ) )
184 return false; 184 return false;
185 185
186 VObject *obj; 186 VObject *obj;
187 obj = newVObject( VCCalProp ); 187 obj = newVObject( VCCalProp );
188 addPropValue( obj, VCVersionProp, "1.0" ); 188 addPropValue( obj, VCVersionProp, "1.0" );
189 VObject *vo; 189 VObject *vo;
190 for(QMap<int, OTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 190 for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
191 vo = vobjByEvent( it.data() ); 191 vo = vobjByEvent( it.data() );
192 addVObjectProp(obj, vo ); 192 addVObjectProp(obj, vo );
193 } 193 }
194 writeVObject( file.directHandle(), obj ); 194 writeVObject( file.directHandle(), obj );
195 cleanVObject( obj ); 195 cleanVObject( obj );
196 cleanStrTbl(); 196 cleanStrTbl();
197 197
198 m_dirty = false; 198 m_dirty = false;
199 return true; 199 return true;
200} 200}
201void OTodoAccessVCal::clear() { 201void OPimTodoAccessVCal::clear() {
202 m_map.clear(); 202 m_map.clear();
203 m_dirty = true; 203 m_dirty = true;
204} 204}
205bool OTodoAccessVCal::add( const OTodo& to ) { 205bool OPimTodoAccessVCal::add( const OPimTodo& to ) {
206 m_map.insert( to.uid(), to ); 206 m_map.insert( to.uid(), to );
207 m_dirty = true; 207 m_dirty = true;
208 return true; 208 return true;
209} 209}
210bool OTodoAccessVCal::remove( int uid ) { 210bool OPimTodoAccessVCal::remove( int uid ) {
211 m_map.remove( uid ); 211 m_map.remove( uid );
212 m_dirty = true; 212 m_dirty = true;
213 return true; 213 return true;
214} 214}
215void OTodoAccessVCal::removeAllCompleted() { 215void OPimTodoAccessVCal::removeAllCompleted() {
216 for ( QMap<int, OTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) { 216 for ( QMap<int, OPimTodo>::Iterator it = m_map.begin(); it != m_map.end(); ++it ) {
217 if ( (*it).isCompleted() ) 217 if ( (*it).isCompleted() )
218 m_map.remove( it ); 218 m_map.remove( it );
219 } 219 }
220} 220}
221bool OTodoAccessVCal::replace( const OTodo& to ) { 221bool OPimTodoAccessVCal::replace( const OPimTodo& to ) {
222 m_map.replace( to.uid(), to ); 222 m_map.replace( to.uid(), to );
223 m_dirty = true; 223 m_dirty = true;
224 return true; 224 return true;
225} 225}
226OTodo OTodoAccessVCal::find(int uid )const { 226OPimTodo OPimTodoAccessVCal::find(int uid )const {
227 return m_map[uid]; 227 return m_map[uid];
228} 228}
229QArray<int> OTodoAccessVCal::sorted( bool, int, int, int ) { 229QArray<int> OPimTodoAccessVCal::sorted( bool, int, int, int ) {
230 QArray<int> ar(0); 230 QArray<int> ar(0);
231 return ar; 231 return ar;
232} 232}
233QArray<int> OTodoAccessVCal::allRecords()const { 233QArray<int> OPimTodoAccessVCal::allRecords()const {
234 QArray<int> ar( m_map.count() ); 234 QArray<int> ar( m_map.count() );
235 QMap<int, OTodo>::ConstIterator it; 235 QMap<int, OPimTodo>::ConstIterator it;
236 int i = 0; 236 int i = 0;
237 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 237 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
238 ar[i] = it.key(); 238 ar[i] = it.key();
239 i++; 239 i++;
240 } 240 }
241 return ar; 241 return ar;
242} 242}
243QArray<int> OTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const { 243QArray<int> OPimTodoAccessVCal::matchRegexp(const QRegExp& /* r */)const {
244 QArray<int> ar(0); 244 QArray<int> ar(0);
245 return ar; 245 return ar;
246} 246}
247QArray<int> OTodoAccessVCal::queryByExample( const OTodo&, int, const QDateTime& ) { 247QArray<int> OPimTodoAccessVCal::queryByExample( const OPimTodo&, int, const QDateTime& ) {
248 QArray<int> ar(0); 248 QArray<int> ar(0);
249 return ar; 249 return ar;
250} 250}
251QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , 251QArray<int> OPimTodoAccessVCal::effectiveToDos( const QDate& ,
252 const QDate& , 252 const QDate& ,
253 bool ) { 253 bool ) {
254 QArray<int> ar(0); 254 QArray<int> ar(0);
255 return ar; 255 return ar;
256} 256}
257QArray<int> OTodoAccessVCal::overDue() { 257QArray<int> OPimTodoAccessVCal::overDue() {
258 QArray<int> ar(0); 258 QArray<int> ar(0);
259 return ar; 259 return ar;
260} 260}
261QBitArray OTodoAccessVCal::supports()const { 261QBitArray OPimTodoAccessVCal::supports()const {
262 static QBitArray ar = sup(); 262 static QBitArray ar = sup();
263 263
264 return ar; 264 return ar;
265} 265}
266QBitArray OTodoAccessVCal::sup() { 266QBitArray OPimTodoAccessVCal::sup() {
267 QBitArray ar ( OTodo::CompletedDate +1 ); 267 QBitArray ar ( OPimTodo::CompletedDate +1 );
268 ar.fill( true ); 268 ar.fill( true );
269 269
270 ar[OTodo::CrossReference] = false; 270 ar[OPimTodo::CrossReference] = false;
271 ar[OTodo::State ] = false; 271 ar[OPimTodo::State ] = false;
272 ar[OTodo::Reminders] = false; 272 ar[OPimTodo::Reminders] = false;
273 ar[OTodo::Notifiers] = false; 273 ar[OPimTodo::Notifiers] = false;
274 ar[OTodo::Maintainer] = false; 274 ar[OPimTodo::Maintainer] = false;
275 ar[OTodo::Progress] = false; 275 ar[OPimTodo::Progress] = false;
276 ar[OTodo::Alarms ] = false; 276 ar[OPimTodo::Alarms ] = false;
277 ar[OTodo::Recurrence] = false; 277 ar[OPimTodo::Recurrence] = false;
278 278
279 return ar; 279 return ar;
280} 280}
281 281
282} 282}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index f9323fb..1e106d3 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -1,72 +1,72 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_OTODO_ACCESS_VCAL_H 29#ifndef OPIE_OTODO_ACCESS_VCAL_H
30#define OPIE_OTODO_ACCESS_VCAL_H 30#define OPIE_OTODO_ACCESS_VCAL_H
31 31
32#include <opie2/otodoaccessbackend.h> 32#include <opie2/otodoaccessbackend.h>
33 33
34namespace Opie { 34namespace Opie {
35 35
36class OTodoAccessVCal : public OTodoAccessBackend { 36class OPimTodoAccessVCal : public OPimTodoAccessBackend {
37public: 37public:
38 OTodoAccessVCal(const QString& ); 38 OPimTodoAccessVCal(const QString& );
39 ~OTodoAccessVCal(); 39 ~OPimTodoAccessVCal();
40 40
41 bool load(); 41 bool load();
42 bool reload(); 42 bool reload();
43 bool save(); 43 bool save();
44 44
45 QArray<int> allRecords()const; 45 QArray<int> allRecords()const;
46 QArray<int> matchRegexp(const QRegExp &r) const; 46 QArray<int> matchRegexp(const QRegExp &r) const;
47 QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); 47 QArray<int> queryByExample( const OPimTodo& t, int sort, const QDateTime& d = QDateTime() );
48 QArray<int> effectiveToDos( const QDate& start, 48 QArray<int> effectiveToDos( const QDate& start,
49 const QDate& end, 49 const QDate& end,
50 bool includeNoDates ); 50 bool includeNoDates );
51 QArray<int> overDue(); 51 QArray<int> overDue();
52 QArray<int> sorted( bool asc, int sortOrder, int sortFilter, 52 QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
53 int cat ); 53 int cat );
54 OTodo find(int uid)const; 54 OPimTodo find(int uid)const;
55 void clear(); 55 void clear();
56 bool add( const OTodo& ); 56 bool add( const OPimTodo& );
57 bool remove( int uid ); 57 bool remove( int uid );
58 bool replace( const OTodo& ); 58 bool replace( const OPimTodo& );
59 59
60 void removeAllCompleted(); 60 void removeAllCompleted();
61 virtual QBitArray supports()const; 61 virtual QBitArray supports()const;
62 62
63private: 63private:
64 static QBitArray sup(); 64 static QBitArray sup();
65 bool m_dirty : 1; 65 bool m_dirty : 1;
66 QString m_file; 66 QString m_file;
67 QMap<int, OTodo> m_map; 67 QMap<int, OPimTodo> m_map;
68}; 68};
69 69
70} 70}
71 71
72#endif 72#endif
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 2d50ecd..cce6111 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,909 +1,909 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <errno.h> 29#include <errno.h>
30#include <fcntl.h> 30#include <fcntl.h>
31 31
32#include <sys/mman.h> 32#include <sys/mman.h>
33#include <sys/stat.h> 33#include <sys/stat.h>
34#include <sys/types.h> 34#include <sys/types.h>
35 35
36#include <unistd.h> 36#include <unistd.h>
37 37
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qvector.h> 40#include <qvector.h>
41 41
42#include <qpe/global.h> 42#include <qpe/global.h>
43#include <qpe/stringutil.h> 43#include <qpe/stringutil.h>
44#include <qpe/timeconversion.h> 44#include <qpe/timeconversion.h>
45 45
46#include <opie2/oconversion.h> 46#include <opie2/opimdateconversion.h>
47#include <opie2/opimstate.h> 47#include <opie2/opimstate.h>
48#include <opie2/otimezone.h> 48#include <opie2/opimtimezone.h>
49#include <opie2/opimnotifymanager.h> 49#include <opie2/opimnotifymanager.h>
50#include <opie2/orecur.h> 50#include <opie2/opimrecurrence.h>
51#include <opie2/otodoaccessxml.h> 51#include <opie2/otodoaccessxml.h>
52 52
53using namespace Opie; 53using namespace Opie;
54 54
55namespace { 55namespace {
56 time_t rp_end; 56 time_t rp_end;
57 ORecur* rec; 57 OPimRecurrence* rec;
58 ORecur *recur() { 58 OPimRecurrence *recur() {
59 if (!rec ) rec = new ORecur; 59 if (!rec ) rec = new OPimRecurrence;
60 return rec; 60 return rec;
61 } 61 }
62 int snd; 62 int snd;
63 enum MoreAttributes { 63 enum MoreAttributes {
64 FRType = OTodo::CompletedDate + 2, 64 FRType = OPimTodo::CompletedDate + 2,
65 FRWeekdays, 65 FRWeekdays,
66 FRPosition, 66 FRPosition,
67 FRFreq, 67 FRFreq,
68 FRHasEndDate, 68 FRHasEndDate,
69 FREndDate, 69 FREndDate,
70 FRStart, 70 FRStart,
71 FREnd 71 FREnd
72 }; 72 };
73 // FROM TT again 73 // FROM TT again
74char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 74char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
75{ 75{
76 char needleChar; 76 char needleChar;
77 char haystackChar; 77 char haystackChar;
78 if (!needle || !haystack || !hLen || !nLen) 78 if (!needle || !haystack || !hLen || !nLen)
79 return 0; 79 return 0;
80 80
81 const char* hsearch = haystack; 81 const char* hsearch = haystack;
82 82
83 if ((needleChar = *needle++) != 0) { 83 if ((needleChar = *needle++) != 0) {
84 nLen--; //(to make up for needle++) 84 nLen--; //(to make up for needle++)
85 do { 85 do {
86 do { 86 do {
87 if ((haystackChar = *hsearch++) == 0) 87 if ((haystackChar = *hsearch++) == 0)
88 return (0); 88 return (0);
89 if (hsearch >= haystack + hLen) 89 if (hsearch >= haystack + hLen)
90 return (0); 90 return (0);
91 } while (haystackChar != needleChar); 91 } while (haystackChar != needleChar);
92 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); 92 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
93 hsearch--; 93 hsearch--;
94 } 94 }
95 return ((char *)hsearch); 95 return ((char *)hsearch);
96} 96}
97} 97}
98 98
99namespace Opie { 99namespace Opie {
100 100
101OTodoAccessXML::OTodoAccessXML( const QString& appName, 101OPimTodoAccessXML::OPimTodoAccessXML( const QString& appName,
102 const QString& fileName ) 102 const QString& fileName )
103 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 103 : OPimTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
104{ 104{
105 if (!fileName.isEmpty() ) 105 if (!fileName.isEmpty() )
106 m_file = fileName; 106 m_file = fileName;
107 else 107 else
108 m_file = Global::applicationFileName( "todolist", "todolist.xml" ); 108 m_file = Global::applicationFileName( "todolist", "todolist.xml" );
109} 109}
110OTodoAccessXML::~OTodoAccessXML() { 110OPimTodoAccessXML::~OPimTodoAccessXML() {
111 111
112} 112}
113bool OTodoAccessXML::load() { 113bool OPimTodoAccessXML::load() {
114 rec = 0; 114 rec = 0;
115 m_opened = true; 115 m_opened = true;
116 m_changed = false; 116 m_changed = false;
117 /* initialize dict */ 117 /* initialize dict */
118 /* 118 /*
119 * UPDATE dict if you change anything!!! 119 * UPDATE dict if you change anything!!!
120 */ 120 */
121 QAsciiDict<int> dict(26); 121 QAsciiDict<int> dict(26);
122 dict.setAutoDelete( TRUE ); 122 dict.setAutoDelete( TRUE );
123 dict.insert("Categories" , new int(OTodo::Category) ); 123 dict.insert("Categories" , new int(OPimTodo::Category) );
124 dict.insert("Uid" , new int(OTodo::Uid) ); 124 dict.insert("Uid" , new int(OPimTodo::Uid) );
125 dict.insert("HasDate" , new int(OTodo::HasDate) ); 125 dict.insert("HasDate" , new int(OPimTodo::HasDate) );
126 dict.insert("Completed" , new int(OTodo::Completed) ); 126 dict.insert("Completed" , new int(OPimTodo::Completed) );
127 dict.insert("Description" , new int(OTodo::Description) ); 127 dict.insert("Description" , new int(OPimTodo::Description) );
128 dict.insert("Summary" , new int(OTodo::Summary) ); 128 dict.insert("Summary" , new int(OPimTodo::Summary) );
129 dict.insert("Priority" , new int(OTodo::Priority) ); 129 dict.insert("Priority" , new int(OPimTodo::Priority) );
130 dict.insert("DateDay" , new int(OTodo::DateDay) ); 130 dict.insert("DateDay" , new int(OPimTodo::DateDay) );
131 dict.insert("DateMonth" , new int(OTodo::DateMonth) ); 131 dict.insert("DateMonth" , new int(OPimTodo::DateMonth) );
132 dict.insert("DateYear" , new int(OTodo::DateYear) ); 132 dict.insert("DateYear" , new int(OPimTodo::DateYear) );
133 dict.insert("Progress" , new int(OTodo::Progress) ); 133 dict.insert("Progress" , new int(OPimTodo::Progress) );
134 dict.insert("CompletedDate", new int(OTodo::CompletedDate) ); 134 dict.insert("CompletedDate", new int(OPimTodo::CompletedDate) );
135 dict.insert("StartDate", new int(OTodo::StartDate) ); 135 dict.insert("StartDate", new int(OPimTodo::StartDate) );
136 dict.insert("CrossReference", new int(OTodo::CrossReference) ); 136 dict.insert("CrossReference", new int(OPimTodo::CrossReference) );
137 dict.insert("State", new int(OTodo::State) ); 137 dict.insert("State", new int(OPimTodo::State) );
138 dict.insert("Alarms", new int(OTodo::Alarms) ); 138 dict.insert("Alarms", new int(OPimTodo::Alarms) );
139 dict.insert("Reminders", new int(OTodo::Reminders) ); 139 dict.insert("Reminders", new int(OPimTodo::Reminders) );
140 dict.insert("Notifiers", new int(OTodo::Notifiers) ); 140 dict.insert("Notifiers", new int(OPimTodo::Notifiers) );
141 dict.insert("Maintainer", new int(OTodo::Maintainer) ); 141 dict.insert("Maintainer", new int(OPimTodo::Maintainer) );
142 dict.insert("rtype", new int(FRType) ); 142 dict.insert("rtype", new int(FRType) );
143 dict.insert("rweekdays", new int(FRWeekdays) ); 143 dict.insert("rweekdays", new int(FRWeekdays) );
144 dict.insert("rposition", new int(FRPosition) ); 144 dict.insert("rposition", new int(FRPosition) );
145 dict.insert("rfreq", new int(FRFreq) ); 145 dict.insert("rfreq", new int(FRFreq) );
146 dict.insert("start", new int(FRStart) ); 146 dict.insert("start", new int(FRStart) );
147 dict.insert("rhasenddate", new int(FRHasEndDate) ); 147 dict.insert("rhasenddate", new int(FRHasEndDate) );
148 dict.insert("enddt", new int(FREndDate) ); 148 dict.insert("enddt", new int(FREndDate) );
149 149
150 // here the custom XML parser from TT it's GPL 150 // here the custom XML parser from TT it's GPL
151 // but we want to push OpiePIM... to TT..... 151 // but we want to push OpiePIM... to TT.....
152 // mmap part from zecke :) 152 // mmap part from zecke :)
153 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY ); 153 int fd = ::open( QFile::encodeName(m_file).data(), O_RDONLY );
154 struct stat attribut; 154 struct stat attribut;
155 if ( fd < 0 ) return false; 155 if ( fd < 0 ) return false;
156 156
157 if ( fstat(fd, &attribut ) == -1 ) { 157 if ( fstat(fd, &attribut ) == -1 ) {
158 ::close( fd ); 158 ::close( fd );
159 return false; 159 return false;
160 } 160 }
161 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 ); 161 void* map_addr = ::mmap(NULL, attribut.st_size, PROT_READ, MAP_SHARED, fd, 0 );
162 if ( map_addr == ( (caddr_t)-1) ) { 162 if ( map_addr == ( (caddr_t)-1) ) {
163 ::close(fd ); 163 ::close(fd );
164 return false; 164 return false;
165 } 165 }
166 /* advise the kernel who we want to read it */ 166 /* advise the kernel who we want to read it */
167 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL ); 167 ::madvise( map_addr, attribut.st_size, MADV_SEQUENTIAL );
168 /* we do not the file any more */ 168 /* we do not the file any more */
169 ::close( fd ); 169 ::close( fd );
170 170
171 char* dt = (char*)map_addr; 171 char* dt = (char*)map_addr;
172 int len = attribut.st_size; 172 int len = attribut.st_size;
173 int i = 0; 173 int i = 0;
174 char *point; 174 char *point;
175 const char* collectionString = "<Task "; 175 const char* collectionString = "<Task ";
176 int strLen = strlen(collectionString); 176 int strLen = strlen(collectionString);
177 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { 177 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
178 i = point -dt; 178 i = point -dt;
179 i+= strLen; 179 i+= strLen;
180 qWarning("Found a start at %d %d", i, (point-dt) ); 180 qWarning("Found a start at %d %d", i, (point-dt) );
181 181
182 OTodo ev; 182 OPimTodo ev;
183 m_year = m_month = m_day = 0; 183 m_year = m_month = m_day = 0;
184 184
185 while ( TRUE ) { 185 while ( TRUE ) {
186 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 186 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
187 ++i; 187 ++i;
188 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 188 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
189 break; 189 break;
190 190
191 // we have another attribute, read it. 191 // we have another attribute, read it.
192 int j = i; 192 int j = i;
193 while ( j < len && dt[j] != '=' ) 193 while ( j < len && dt[j] != '=' )
194 ++j; 194 ++j;
195 QCString attr( dt+i, j-i+1); 195 QCString attr( dt+i, j-i+1);
196 196
197 i = ++j; // skip = 197 i = ++j; // skip =
198 198
199 // find the start of quotes 199 // find the start of quotes
200 while ( i < len && dt[i] != '"' ) 200 while ( i < len && dt[i] != '"' )
201 ++i; 201 ++i;
202 j = ++i; 202 j = ++i;
203 203
204 bool haveUtf = FALSE; 204 bool haveUtf = FALSE;
205 bool haveEnt = FALSE; 205 bool haveEnt = FALSE;
206 while ( j < len && dt[j] != '"' ) { 206 while ( j < len && dt[j] != '"' ) {
207 if ( ((unsigned char)dt[j]) > 0x7f ) 207 if ( ((unsigned char)dt[j]) > 0x7f )
208 haveUtf = TRUE; 208 haveUtf = TRUE;
209 if ( dt[j] == '&' ) 209 if ( dt[j] == '&' )
210 haveEnt = TRUE; 210 haveEnt = TRUE;
211 ++j; 211 ++j;
212 } 212 }
213 if ( i == j ) { 213 if ( i == j ) {
214 // empty value 214 // empty value
215 i = j + 1; 215 i = j + 1;
216 continue; 216 continue;
217 } 217 }
218 218
219 QCString value( dt+i, j-i+1 ); 219 QCString value( dt+i, j-i+1 );
220 i = j + 1; 220 i = j + 1;
221 221
222 QString str = (haveUtf ? QString::fromUtf8( value ) 222 QString str = (haveUtf ? QString::fromUtf8( value )
223 : QString::fromLatin1( value ) ); 223 : QString::fromLatin1( value ) );
224 if ( haveEnt ) 224 if ( haveEnt )
225 str = Qtopia::plainString( str ); 225 str = Qtopia::plainString( str );
226 226
227 /* 227 /*
228 * add key + value 228 * add key + value
229 */ 229 */
230 todo( &dict, ev, attr, str ); 230 todo( &dict, ev, attr, str );
231 231
232 } 232 }
233 /* 233 /*
234 * now add it 234 * now add it
235 */ 235 */
236 qWarning("End at %d", i ); 236 qWarning("End at %d", i );
237 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 237 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
238 ev.setUid( 1 ); 238 ev.setUid( 1 );
239 m_changed = true; 239 m_changed = true;
240 } 240 }
241 if ( ev.hasDueDate() ) { 241 if ( ev.hasDueDate() ) {
242 ev.setDueDate( QDate(m_year, m_month, m_day) ); 242 ev.setDueDate( QDate(m_year, m_month, m_day) );
243 } 243 }
244 if ( rec && rec->doesRecur() ) { 244 if ( rec && rec->doesRecur() ) {
245 OTimeZone utc = OTimeZone::utc(); 245 OPimTimeZone utc = OPimTimeZone::utc();
246 ORecur recu( *rec ); // call copy c'tor 246 OPimRecurrence recu( *rec ); // call copy c'tor
247 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); 247 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() );
248 recu.setStart( ev.dueDate() ); 248 recu.setStart( ev.dueDate() );
249 ev.setRecurrence( recu ); 249 ev.setRecurrence( recu );
250 } 250 }
251 m_events.insert(ev.uid(), ev ); 251 m_events.insert(ev.uid(), ev );
252 m_year = m_month = m_day = -1; 252 m_year = m_month = m_day = -1;
253 delete rec; 253 delete rec;
254 rec = 0; 254 rec = 0;
255 } 255 }
256 256
257 munmap(map_addr, attribut.st_size ); 257 munmap(map_addr, attribut.st_size );
258 258
259 qWarning("counts %d records loaded!", m_events.count() ); 259 qWarning("counts %d records loaded!", m_events.count() );
260 return true; 260 return true;
261} 261}
262bool OTodoAccessXML::reload() { 262bool OPimTodoAccessXML::reload() {
263 m_events.clear(); 263 m_events.clear();
264 return load(); 264 return load();
265} 265}
266bool OTodoAccessXML::save() { 266bool OPimTodoAccessXML::save() {
267// qWarning("saving"); 267// qWarning("saving");
268 if (!m_opened || !m_changed ) { 268 if (!m_opened || !m_changed ) {
269// qWarning("not saving"); 269// qWarning("not saving");
270 return true; 270 return true;
271 } 271 }
272 QString strNewFile = m_file + ".new"; 272 QString strNewFile = m_file + ".new";
273 QFile f( strNewFile ); 273 QFile f( strNewFile );
274 if (!f.open( IO_WriteOnly|IO_Raw ) ) 274 if (!f.open( IO_WriteOnly|IO_Raw ) )
275 return false; 275 return false;
276 276
277 int written; 277 int written;
278 QString out; 278 QString out;
279 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 279 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
280 280
281 // for all todos 281 // for all todos
282 QMap<int, OTodo>::Iterator it; 282 QMap<int, OPimTodo>::Iterator it;
283 for (it = m_events.begin(); it != m_events.end(); ++it ) { 283 for (it = m_events.begin(); it != m_events.end(); ++it ) {
284 out+= "<Task " + toString( (*it) ) + " />\n"; 284 out+= "<Task " + toString( (*it) ) + " />\n";
285 QCString cstr = out.utf8(); 285 QCString cstr = out.utf8();
286 written = f.writeBlock( cstr.data(), cstr.length() ); 286 written = f.writeBlock( cstr.data(), cstr.length() );
287 287
288 /* less written then we wanted */ 288 /* less written then we wanted */
289 if ( written != (int)cstr.length() ) { 289 if ( written != (int)cstr.length() ) {
290 f.close(); 290 f.close();
291 QFile::remove( strNewFile ); 291 QFile::remove( strNewFile );
292 return false; 292 return false;
293 } 293 }
294 out = QString::null; 294 out = QString::null;
295 } 295 }
296 296
297 out += "</Tasks>"; 297 out += "</Tasks>";
298 QCString cstr = out.utf8(); 298 QCString cstr = out.utf8();
299 written = f.writeBlock( cstr.data(), cstr.length() ); 299 written = f.writeBlock( cstr.data(), cstr.length() );
300 300
301 if ( written != (int)cstr.length() ) { 301 if ( written != (int)cstr.length() ) {
302 f.close(); 302 f.close();
303 QFile::remove( strNewFile ); 303 QFile::remove( strNewFile );
304 return false; 304 return false;
305 } 305 }
306 /* flush before renaming */ 306 /* flush before renaming */
307 f.close(); 307 f.close();
308 308
309 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 309 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
310// qWarning("error renaming"); 310// qWarning("error renaming");
311 QFile::remove( strNewFile ); 311 QFile::remove( strNewFile );
312 } 312 }
313 313
314 m_changed = false; 314 m_changed = false;
315 return true; 315 return true;
316} 316}
317QArray<int> OTodoAccessXML::allRecords()const { 317QArray<int> OPimTodoAccessXML::allRecords()const {
318 QArray<int> ids( m_events.count() ); 318 QArray<int> ids( m_events.count() );
319 QMap<int, OTodo>::ConstIterator it; 319 QMap<int, OPimTodo>::ConstIterator it;
320 int i = 0; 320 int i = 0;
321 321
322 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 322 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
323 ids[i] = it.key(); 323 ids[i] = it.key();
324 i++; 324 i++;
325 } 325 }
326 return ids; 326 return ids;
327} 327}
328QArray<int> OTodoAccessXML::queryByExample( const OTodo&, int, const QDateTime& ) { 328QArray<int> OPimTodoAccessXML::queryByExample( const OPimTodo&, int, const QDateTime& ) {
329 QArray<int> ids(0); 329 QArray<int> ids(0);
330 return ids; 330 return ids;
331} 331}
332OTodo OTodoAccessXML::find( int uid )const { 332OPimTodo OPimTodoAccessXML::find( int uid )const {
333 OTodo todo; 333 OPimTodo todo;
334 todo.setUid( 0 ); // isEmpty() 334 todo.setUid( 0 ); // isEmpty()
335 QMap<int, OTodo>::ConstIterator it = m_events.find( uid ); 335 QMap<int, OPimTodo>::ConstIterator it = m_events.find( uid );
336 if ( it != m_events.end() ) 336 if ( it != m_events.end() )
337 todo = it.data(); 337 todo = it.data();
338 338
339 return todo; 339 return todo;
340} 340}
341void OTodoAccessXML::clear() { 341void OPimTodoAccessXML::clear() {
342 if (m_opened ) 342 if (m_opened )
343 m_changed = true; 343 m_changed = true;
344 344
345 m_events.clear(); 345 m_events.clear();
346} 346}
347bool OTodoAccessXML::add( const OTodo& todo ) { 347bool OPimTodoAccessXML::add( const OPimTodo& todo ) {
348// qWarning("add"); 348// qWarning("add");
349 m_changed = true; 349 m_changed = true;
350 m_events.insert( todo.uid(), todo ); 350 m_events.insert( todo.uid(), todo );
351 351
352 return true; 352 return true;
353} 353}
354bool OTodoAccessXML::remove( int uid ) { 354bool OPimTodoAccessXML::remove( int uid ) {
355 m_changed = true; 355 m_changed = true;
356 m_events.remove( uid ); 356 m_events.remove( uid );
357 357
358 return true; 358 return true;
359} 359}
360bool OTodoAccessXML::replace( const OTodo& todo) { 360bool OPimTodoAccessXML::replace( const OPimTodo& todo) {
361 m_changed = true; 361 m_changed = true;
362 m_events.replace( todo.uid(), todo ); 362 m_events.replace( todo.uid(), todo );
363 363
364 return true; 364 return true;
365} 365}
366QArray<int> OTodoAccessXML::effectiveToDos( const QDate& start, 366QArray<int> OPimTodoAccessXML::effectiveToDos( const QDate& start,
367 const QDate& end, 367 const QDate& end,
368 bool includeNoDates ) { 368 bool includeNoDates ) {
369 QArray<int> ids( m_events.count() ); 369 QArray<int> ids( m_events.count() );
370 QMap<int, OTodo>::Iterator it; 370 QMap<int, OPimTodo>::Iterator it;
371 371
372 int i = 0; 372 int i = 0;
373 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 373 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
374 if ( !it.data().hasDueDate() ) { 374 if ( !it.data().hasDueDate() ) {
375 if ( includeNoDates ) { 375 if ( includeNoDates ) {
376 ids[i] = it.key(); 376 ids[i] = it.key();
377 i++; 377 i++;
378 } 378 }
379 }else if ( it.data().dueDate() >= start && 379 }else if ( it.data().dueDate() >= start &&
380 it.data().dueDate() <= end ) { 380 it.data().dueDate() <= end ) {
381 ids[i] = it.key(); 381 ids[i] = it.key();
382 i++; 382 i++;
383 } 383 }
384 } 384 }
385 ids.resize( i ); 385 ids.resize( i );
386 return ids; 386 return ids;
387} 387}
388QArray<int> OTodoAccessXML::overDue() { 388QArray<int> OPimTodoAccessXML::overDue() {
389 QArray<int> ids( m_events.count() ); 389 QArray<int> ids( m_events.count() );
390 int i = 0; 390 int i = 0;
391 391
392 QMap<int, OTodo>::Iterator it; 392 QMap<int, OPimTodo>::Iterator it;
393 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 393 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
394 if ( it.data().isOverdue() ) { 394 if ( it.data().isOverdue() ) {
395 ids[i] = it.key(); 395 ids[i] = it.key();
396 i++; 396 i++;
397 } 397 }
398 } 398 }
399 ids.resize( i ); 399 ids.resize( i );
400 return ids; 400 return ids;
401} 401}
402 402
403 403
404/* private */ 404/* private */
405void OTodoAccessXML::todo( QAsciiDict<int>* dict, OTodo& ev, 405void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
406 const QCString& attr, const QString& val) { 406 const QCString& attr, const QString& val) {
407// qWarning("parse to do from XMLElement" ); 407// qWarning("parse to do from XMLElement" );
408 408
409 int *find=0; 409 int *find=0;
410 410
411 find = (*dict)[ attr.data() ]; 411 find = (*dict)[ attr.data() ];
412 if (!find ) { 412 if (!find ) {
413// qWarning("Unknown option" + it.key() ); 413// qWarning("Unknown option" + it.key() );
414 ev.setCustomField( attr, val ); 414 ev.setCustomField( attr, val );
415 return; 415 return;
416 } 416 }
417 417
418 switch( *find ) { 418 switch( *find ) {
419 case OTodo::Uid: 419 case OPimTodo::Uid:
420 ev.setUid( val.toInt() ); 420 ev.setUid( val.toInt() );
421 break; 421 break;
422 case OTodo::Category: 422 case OPimTodo::Category:
423 ev.setCategories( ev.idsFromString( val ) ); 423 ev.setCategories( ev.idsFromString( val ) );
424 break; 424 break;
425 case OTodo::HasDate: 425 case OPimTodo::HasDate:
426 ev.setHasDueDate( val.toInt() ); 426 ev.setHasDueDate( val.toInt() );
427 break; 427 break;
428 case OTodo::Completed: 428 case OPimTodo::Completed:
429 ev.setCompleted( val.toInt() ); 429 ev.setCompleted( val.toInt() );
430 break; 430 break;
431 case OTodo::Description: 431 case OPimTodo::Description:
432 ev.setDescription( val ); 432 ev.setDescription( val );
433 break; 433 break;
434 case OTodo::Summary: 434 case OPimTodo::Summary:
435 ev.setSummary( val ); 435 ev.setSummary( val );
436 break; 436 break;
437 case OTodo::Priority: 437 case OPimTodo::Priority:
438 ev.setPriority( val.toInt() ); 438 ev.setPriority( val.toInt() );
439 break; 439 break;
440 case OTodo::DateDay: 440 case OPimTodo::DateDay:
441 m_day = val.toInt(); 441 m_day = val.toInt();
442 break; 442 break;
443 case OTodo::DateMonth: 443 case OPimTodo::DateMonth:
444 m_month = val.toInt(); 444 m_month = val.toInt();
445 break; 445 break;
446 case OTodo::DateYear: 446 case OPimTodo::DateYear:
447 m_year = val.toInt(); 447 m_year = val.toInt();
448 break; 448 break;
449 case OTodo::Progress: 449 case OPimTodo::Progress:
450 ev.setProgress( val.toInt() ); 450 ev.setProgress( val.toInt() );
451 break; 451 break;
452 case OTodo::CompletedDate: 452 case OPimTodo::CompletedDate:
453 ev.setCompletedDate( OConversion::dateFromString( val ) ); 453 ev.setCompletedDate( OPimDateConversion::dateFromString( val ) );
454 break; 454 break;
455 case OTodo::StartDate: 455 case OPimTodo::StartDate:
456 ev.setStartDate( OConversion::dateFromString( val ) ); 456 ev.setStartDate( OPimDateConversion::dateFromString( val ) );
457 break; 457 break;
458 case OTodo::State: 458 case OPimTodo::State:
459 ev.setState( val.toInt() ); 459 ev.setState( val.toInt() );
460 break; 460 break;
461 case OTodo::Alarms:{ 461 case OPimTodo::Alarms:{
462 OPimNotifyManager &manager = ev.notifiers(); 462 OPimNotifyManager &manager = ev.notifiers();
463 QStringList als = QStringList::split(";", val ); 463 QStringList als = QStringList::split(";", val );
464 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { 464 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
465 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 465 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
466 qWarning("alarm: %s", alarm.join("___").latin1() ); 466 qWarning("alarm: %s", alarm.join("___").latin1() );
467 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 467 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() );
468 OPimAlarm al( alarm[2].toInt(), OConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); 468 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
469 manager.add( al ); 469 manager.add( al );
470 } 470 }
471 } 471 }
472 break; 472 break;
473 case OTodo::Reminders:{ 473 case OPimTodo::Reminders:{
474 OPimNotifyManager &manager = ev.notifiers(); 474 OPimNotifyManager &manager = ev.notifiers();
475 QStringList rems = QStringList::split(";", val ); 475 QStringList rems = QStringList::split(";", val );
476 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { 476 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
477 OPimReminder rem( (*it).toInt() ); 477 OPimReminder rem( (*it).toInt() );
478 manager.add( rem ); 478 manager.add( rem );
479 } 479 }
480 } 480 }
481 break; 481 break;
482 case OTodo::CrossReference: 482 case OPimTodo::CrossReference:
483 { 483 {
484 /* 484 /*
485 * A cross refernce looks like 485 * A cross refernce looks like
486 * appname,id;appname,id 486 * appname,id;appname,id
487 * we need to split it up 487 * we need to split it up
488 */ 488 */
489 QStringList refs = QStringList::split(';', val ); 489 QStringList refs = QStringList::split(';', val );
490 QStringList::Iterator strIt; 490 QStringList::Iterator strIt;
491 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) { 491 for (strIt = refs.begin(); strIt != refs.end(); ++strIt ) {
492 int pos = (*strIt).find(','); 492 int pos = (*strIt).find(',');
493 if ( pos > -1 ) 493 if ( pos > -1 )
494 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() ); 494 ; // ev.addRelation( (*strIt).left(pos), (*strIt).mid(pos+1).toInt() );
495 495
496 } 496 }
497 break; 497 break;
498 } 498 }
499 /* Recurrence stuff below + post processing later */ 499 /* Recurrence stuff below + post processing later */
500 case FRType: 500 case FRType:
501 if ( val == "Daily" ) 501 if ( val == "Daily" )
502 recur()->setType( ORecur::Daily ); 502 recur()->setType( OPimRecurrence::Daily );
503 else if ( val == "Weekly" ) 503 else if ( val == "Weekly" )
504 recur()->setType( ORecur::Weekly); 504 recur()->setType( OPimRecurrence::Weekly);
505 else if ( val == "MonthlyDay" ) 505 else if ( val == "MonthlyDay" )
506 recur()->setType( ORecur::MonthlyDay ); 506 recur()->setType( OPimRecurrence::MonthlyDay );
507 else if ( val == "MonthlyDate" ) 507 else if ( val == "MonthlyDate" )
508 recur()->setType( ORecur::MonthlyDate ); 508 recur()->setType( OPimRecurrence::MonthlyDate );
509 else if ( val == "Yearly" ) 509 else if ( val == "Yearly" )
510 recur()->setType( ORecur::Yearly ); 510 recur()->setType( OPimRecurrence::Yearly );
511 else 511 else
512 recur()->setType( ORecur::NoRepeat ); 512 recur()->setType( OPimRecurrence::NoRepeat );
513 break; 513 break;
514 case FRWeekdays: 514 case FRWeekdays:
515 recur()->setDays( val.toInt() ); 515 recur()->setDays( val.toInt() );
516 break; 516 break;
517 case FRPosition: 517 case FRPosition:
518 recur()->setPosition( val.toInt() ); 518 recur()->setPosition( val.toInt() );
519 break; 519 break;
520 case FRFreq: 520 case FRFreq:
521 recur()->setFrequency( val.toInt() ); 521 recur()->setFrequency( val.toInt() );
522 break; 522 break;
523 case FRHasEndDate: 523 case FRHasEndDate:
524 recur()->setHasEndDate( val.toInt() ); 524 recur()->setHasEndDate( val.toInt() );
525 break; 525 break;
526 case FREndDate: { 526 case FREndDate: {
527 rp_end = (time_t) val.toLong(); 527 rp_end = (time_t) val.toLong();
528 break; 528 break;
529 } 529 }
530 default: 530 default:
531 ev.setCustomField( attr, val ); 531 ev.setCustomField( attr, val );
532 break; 532 break;
533 } 533 }
534} 534}
535 535
536// from PalmtopRecord... GPL ### FIXME 536// from PalmtopRecord... GPL ### FIXME
537namespace { 537namespace {
538QString customToXml(const QMap<QString, QString>& customMap ) 538QString customToXml(const QMap<QString, QString>& customMap )
539{ 539{
540 //qWarning(QString("writing custom %1").arg(customMap.count())); 540 //qWarning(QString("writing custom %1").arg(customMap.count()));
541 QString buf(" "); 541 QString buf(" ");
542 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 542 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
543 cit != customMap.end(); ++cit) { 543 cit != customMap.end(); ++cit) {
544 // qWarning(".ITEM."); 544 // qWarning(".ITEM.");
545 buf += cit.key(); 545 buf += cit.key();
546 buf += "=\""; 546 buf += "=\"";
547 buf += Qtopia::escapeString(cit.data()); 547 buf += Qtopia::escapeString(cit.data());
548 buf += "\" "; 548 buf += "\" ";
549 } 549 }
550 return buf; 550 return buf;
551} 551}
552 552
553 553
554} 554}
555 555
556QString OTodoAccessXML::toString( const OTodo& ev )const { 556QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
557 QString str; 557 QString str;
558 558
559 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" "; 559 str += "Completed=\"" + QString::number( ev.isCompleted() ) + "\" ";
560 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" "; 560 str += "HasDate=\"" + QString::number( ev.hasDueDate() ) + "\" ";
561 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 561 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
562 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 562 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
563 563
564 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 564 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
565 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 565 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
566 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 566 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
567 567
568 if ( ev.hasDueDate() ) { 568 if ( ev.hasDueDate() ) {
569 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 569 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
570 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 570 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
571 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 571 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
572 } 572 }
573// qWarning( "Uid %d", ev.uid() ); 573// qWarning( "Uid %d", ev.uid() );
574 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 574 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
575 575
576// append the extra options 576// append the extra options
577 /* FIXME Qtopia::Record this is currently not 577 /* FIXME Qtopia::Record this is currently not
578 * possible you can set custom fields 578 * possible you can set custom fields
579 * but don' iterate over the list 579 * but don' iterate over the list
580 * I may do #define private protected 580 * I may do #define private protected
581 * for this case - cough --zecke 581 * for this case - cough --zecke
582 */ 582 */
583 /* 583 /*
584 QMap<QString, QString> extras = ev.extras(); 584 QMap<QString, QString> extras = ev.extras();
585 QMap<QString, QString>::Iterator extIt; 585 QMap<QString, QString>::Iterator extIt;
586 for (extIt = extras.begin(); extIt != extras.end(); ++extIt ) 586 for (extIt = extras.begin(); extIt != extras.end(); ++extIt )
587 str += extIt.key() + "=\"" + extIt.data() + "\" "; 587 str += extIt.key() + "=\"" + extIt.data() + "\" ";
588 */ 588 */
589 // cross refernce 589 // cross refernce
590 if ( ev.hasRecurrence() ) { 590 if ( ev.hasRecurrence() ) {
591 str += ev.recurrence().toString(); 591 str += ev.recurrence().toString();
592 } 592 }
593 if ( ev.hasStartDate() ) 593 if ( ev.hasStartDate() )
594 str += "StartDate=\""+ OConversion::dateToString( ev.startDate() ) +"\" "; 594 str += "StartDate=\""+ OPimDateConversion::dateToString( ev.startDate() ) +"\" ";
595 if ( ev.hasCompletedDate() ) 595 if ( ev.hasCompletedDate() )
596 str += "CompletedDate=\""+ OConversion::dateToString( ev.completedDate() ) +"\" "; 596 str += "CompletedDate=\""+ OPimDateConversion::dateToString( ev.completedDate() ) +"\" ";
597 if ( ev.hasState() ) 597 if ( ev.hasState() )
598 str += "State=\""+QString::number( ev.state().state() )+"\" "; 598 str += "State=\""+QString::number( ev.state().state() )+"\" ";
599 599
600 /* 600 /*
601 * save reminders and notifiers! 601 * save reminders and notifiers!
602 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:.... 602 * DATE_TIME:DURATION:SOUND:NOT_USED_YET;OTHER_DATE_TIME:OTHER_DURATION:SOUND:....
603 */ 603 */
604 if ( ev.hasNotifiers() ) { 604 if ( ev.hasNotifiers() ) {
605 OPimNotifyManager manager = ev.notifiers(); 605 OPimNotifyManager manager = ev.notifiers();
606 OPimNotifyManager::Alarms alarms = manager.alarms(); 606 OPimNotifyManager::Alarms alarms = manager.alarms();
607 if (!alarms.isEmpty() ) { 607 if (!alarms.isEmpty() ) {
608 QStringList als; 608 QStringList als;
609 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 609 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
610 for ( ; it != alarms.end(); ++it ) { 610 for ( ; it != alarms.end(); ++it ) {
611 /* only if time is valid */ 611 /* only if time is valid */
612 if ( (*it).dateTime().isValid() ) { 612 if ( (*it).dateTime().isValid() ) {
613 als << OConversion::dateTimeToString( (*it).dateTime() ) 613 als << OPimDateConversion::dateTimeToString( (*it).dateTime() )
614 + ":" + QString::number( (*it).duration() ) 614 + ":" + QString::number( (*it).duration() )
615 + ":" + QString::number( (*it).sound() ) 615 + ":" + QString::number( (*it).sound() )
616 + ":"; 616 + ":";
617 } 617 }
618 } 618 }
619 // now write the list 619 // now write the list
620 qWarning("als: %s", als.join("____________").latin1() ); 620 qWarning("als: %s", als.join("____________").latin1() );
621 str += "Alarms=\""+als.join(";") +"\" "; 621 str += "Alarms=\""+als.join(";") +"\" ";
622 } 622 }
623 623
624 /* 624 /*
625 * now the same for reminders but more easy. We just save the uid of the OEvent. 625 * now the same for reminders but more easy. We just save the uid of the OPimEvent.
626 */ 626 */
627 OPimNotifyManager::Reminders reminders = manager.reminders(); 627 OPimNotifyManager::Reminders reminders = manager.reminders();
628 if (!reminders.isEmpty() ) { 628 if (!reminders.isEmpty() ) {
629 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 629 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
630 QStringList records; 630 QStringList records;
631 for ( ; it != reminders.end(); ++it ) { 631 for ( ; it != reminders.end(); ++it ) {
632 records << QString::number( (*it).recordUid() ); 632 records << QString::number( (*it).recordUid() );
633 } 633 }
634 str += "Reminders=\""+ records.join(";") +"\" "; 634 str += "Reminders=\""+ records.join(";") +"\" ";
635 } 635 }
636 } 636 }
637 str += customToXml( ev.toExtraMap() ); 637 str += customToXml( ev.toExtraMap() );
638 638
639 639
640 return str; 640 return str;
641} 641}
642QString OTodoAccessXML::toString( const QArray<int>& ints ) const { 642QString OPimTodoAccessXML::toString( const QArray<int>& ints ) const {
643 return Qtopia::Record::idsToString( ints ); 643 return Qtopia::Record::idsToString( ints );
644} 644}
645 645
646/* internal class for sorting 646/* internal class for sorting
647 * 647 *
648 * Inspired by todoxmlio.cpp from TT 648 * Inspired by todoxmlio.cpp from TT
649 */ 649 */
650 650
651struct OTodoXMLContainer { 651struct OPimTodoXMLContainer {
652 OTodo todo; 652 OPimTodo todo;
653}; 653};
654 654
655namespace { 655namespace {
656 inline QString string( const OTodo& todo) { 656 inline QString string( const OPimTodo& todo) {
657 return todo.summary().isEmpty() ? 657 return todo.summary().isEmpty() ?
658 todo.description().left(20 ) : 658 todo.description().left(20 ) :
659 todo.summary(); 659 todo.summary();
660 } 660 }
661 inline int completed( const OTodo& todo1, const OTodo& todo2) { 661 inline int completed( const OPimTodo& todo1, const OPimTodo& todo2) {
662 int ret = 0; 662 int ret = 0;
663 if ( todo1.isCompleted() ) ret++; 663 if ( todo1.isCompleted() ) ret++;
664 if ( todo2.isCompleted() ) ret--; 664 if ( todo2.isCompleted() ) ret--;
665 return ret; 665 return ret;
666 } 666 }
667 inline int priority( const OTodo& t1, const OTodo& t2) { 667 inline int priority( const OPimTodo& t1, const OPimTodo& t2) {
668 return ( t1.priority() - t2.priority() ); 668 return ( t1.priority() - t2.priority() );
669 } 669 }
670 inline int description( const OTodo& t1, const OTodo& t2) { 670 inline int description( const OPimTodo& t1, const OPimTodo& t2) {
671 return QString::compare( string(t1), string(t2) ); 671 return QString::compare( string(t1), string(t2) );
672 } 672 }
673 inline int deadline( const OTodo& t1, const OTodo& t2) { 673 inline int deadline( const OPimTodo& t1, const OPimTodo& t2) {
674 int ret = 0; 674 int ret = 0;
675 if ( t1.hasDueDate() && 675 if ( t1.hasDueDate() &&
676 t2.hasDueDate() ) 676 t2.hasDueDate() )
677 ret = t2.dueDate().daysTo( t1.dueDate() ); 677 ret = t2.dueDate().daysTo( t1.dueDate() );
678 else if ( t1.hasDueDate() ) 678 else if ( t1.hasDueDate() )
679 ret = -1; 679 ret = -1;
680 else if ( t2.hasDueDate() ) 680 else if ( t2.hasDueDate() )
681 ret = 1; 681 ret = 1;
682 else 682 else
683 ret = 0; 683 ret = 0;
684 684
685 return ret; 685 return ret;
686 } 686 }
687 687
688}; 688};
689 689
690/* 690/*
691 * Returns: 691 * Returns:
692 * 0 if item1 == item2 692 * 0 if item1 == item2
693 * 693 *
694 * non-zero if item1 != item2 694 * non-zero if item1 != item2
695 * 695 *
696 * This function returns int rather than bool so that reimplementations 696 * This function returns int rather than bool so that reimplementations
697 * can return one of three values and use it to sort by: 697 * can return one of three values and use it to sort by:
698 * 698 *
699 * 0 if item1 == item2 699 * 0 if item1 == item2
700 * 700 *
701 * > 0 (positive integer) if item1 > item2 701 * > 0 (positive integer) if item1 > item2
702 * 702 *
703 * < 0 (negative integer) if item1 < item2 703 * < 0 (negative integer) if item1 < item2
704 * 704 *
705 */ 705 */
706class OTodoXMLVector : public QVector<OTodoXMLContainer> { 706class OPimTodoXMLVector : public QVector<OPimTodoXMLContainer> {
707public: 707public:
708 OTodoXMLVector(int size, bool asc, int sort) 708 OPimTodoXMLVector(int size, bool asc, int sort)
709 : QVector<OTodoXMLContainer>( size ) 709 : QVector<OPimTodoXMLContainer>( size )
710 { 710 {
711 setAutoDelete( true ); 711 setAutoDelete( true );
712 m_asc = asc; 712 m_asc = asc;
713 m_sort = sort; 713 m_sort = sort;
714 } 714 }
715 /* return the summary/description */ 715 /* return the summary/description */
716 QString string( const OTodo& todo) { 716 QString string( const OPimTodo& todo) {
717 return todo.summary().isEmpty() ? 717 return todo.summary().isEmpty() ?
718 todo.description().left(20 ) : 718 todo.description().left(20 ) :
719 todo.summary(); 719 todo.summary();
720 } 720 }
721 /** 721 /**
722 * we take the sortorder( switch on it ) 722 * we take the sortorder( switch on it )
723 * 723 *
724 */ 724 */
725 int compareItems( Item d1, Item d2 ) { 725 int compareItems( Item d1, Item d2 ) {
726 bool seComp, sePrio, seDesc, seDeadline; 726 bool seComp, sePrio, seDesc, seDeadline;
727 seComp = sePrio = seDeadline = seDesc = false; 727 seComp = sePrio = seDeadline = seDesc = false;
728 int ret =0; 728 int ret =0;
729 OTodoXMLContainer* con1 = (OTodoXMLContainer*)d1; 729 OPimTodoXMLContainer* con1 = (OPimTodoXMLContainer*)d1;
730 OTodoXMLContainer* con2 = (OTodoXMLContainer*)d2; 730 OPimTodoXMLContainer* con2 = (OPimTodoXMLContainer*)d2;
731 731
732 /* same item */ 732 /* same item */
733 if ( con1->todo.uid() == con2->todo.uid() ) 733 if ( con1->todo.uid() == con2->todo.uid() )
734 return 0; 734 return 0;
735 735
736 switch ( m_sort ) { 736 switch ( m_sort ) {
737 /* completed */ 737 /* completed */
738 case 0: { 738 case 0: {
739 ret = completed( con1->todo, con2->todo ); 739 ret = completed( con1->todo, con2->todo );
740 seComp = TRUE; 740 seComp = TRUE;
741 break; 741 break;
742 } 742 }
743 /* priority */ 743 /* priority */
744 case 1: { 744 case 1: {
745 ret = priority( con1->todo, con2->todo ); 745 ret = priority( con1->todo, con2->todo );
746 sePrio = TRUE; 746 sePrio = TRUE;
747 break; 747 break;
748 } 748 }
749 /* description */ 749 /* description */
750 case 2: { 750 case 2: {
751 ret = description( con1->todo, con2->todo ); 751 ret = description( con1->todo, con2->todo );
752 seDesc = TRUE; 752 seDesc = TRUE;
753 break; 753 break;
754 } 754 }
755 /* deadline */ 755 /* deadline */
756 case 3: { 756 case 3: {
757 ret = deadline( con1->todo, con2->todo ); 757 ret = deadline( con1->todo, con2->todo );
758 seDeadline = TRUE; 758 seDeadline = TRUE;
759 break; 759 break;
760 } 760 }
761 default: 761 default:
762 ret = 0; 762 ret = 0;
763 break; 763 break;
764 }; 764 };
765 /* 765 /*
766 * FIXME do better sorting if the first sort criteria 766 * FIXME do better sorting if the first sort criteria
767 * ret equals 0 start with complete and so on... 767 * ret equals 0 start with complete and so on...
768 */ 768 */
769 769
770 /* twist it we're not ascending*/ 770 /* twist it we're not ascending*/
771 if (!m_asc) 771 if (!m_asc)
772 ret = ret * -1; 772 ret = ret * -1;
773 773
774 if ( ret ) 774 if ( ret )
775 return ret; 775 return ret;
776 776
777 // default did not gave difference let's try it other way around 777 // default did not gave difference let's try it other way around
778 /* 778 /*
779 * General try if already checked if not test 779 * General try if already checked if not test
780 * and return 780 * and return
781 * 1.Completed 781 * 1.Completed
782 * 2.Priority 782 * 2.Priority
783 * 3.Description 783 * 3.Description
784 * 4.DueDate 784 * 4.DueDate
785 */ 785 */
786 if (!seComp ) { 786 if (!seComp ) {
787 if ( (ret = completed( con1->todo, con2->todo ) ) ) { 787 if ( (ret = completed( con1->todo, con2->todo ) ) ) {
788 if (!m_asc ) ret *= -1; 788 if (!m_asc ) ret *= -1;
789 return ret; 789 return ret;
790 } 790 }
791 } 791 }
792 if (!sePrio ) { 792 if (!sePrio ) {
793 if ( (ret = priority( con1->todo, con2->todo ) ) ) { 793 if ( (ret = priority( con1->todo, con2->todo ) ) ) {
794 if (!m_asc ) ret *= -1; 794 if (!m_asc ) ret *= -1;
795 return ret; 795 return ret;
796 } 796 }
797 } 797 }
798 if (!seDesc ) { 798 if (!seDesc ) {
799 if ( (ret = description(con1->todo, con2->todo ) ) ) { 799 if ( (ret = description(con1->todo, con2->todo ) ) ) {
800 if (!m_asc) ret *= -1; 800 if (!m_asc) ret *= -1;
801 return ret; 801 return ret;
802 } 802 }
803 } 803 }
804 if (!seDeadline) { 804 if (!seDeadline) {
805 if ( (ret = deadline( con1->todo, con2->todo ) ) ) { 805 if ( (ret = deadline( con1->todo, con2->todo ) ) ) {
806 if (!m_asc) ret *= -1; 806 if (!m_asc) ret *= -1;
807 return ret; 807 return ret;
808 } 808 }
809 } 809 }
810 810
811 return 0; 811 return 0;
812 } 812 }
813 private: 813 private:
814 bool m_asc; 814 bool m_asc;
815 int m_sort; 815 int m_sort;
816 816
817}; 817};
818 818
819QArray<int> OTodoAccessXML::sorted( bool asc, int sortOrder, 819QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder,
820 int sortFilter, int cat ) { 820 int sortFilter, int cat ) {
821 OTodoXMLVector vector(m_events.count(), asc,sortOrder ); 821 OPimTodoXMLVector vector(m_events.count(), asc,sortOrder );
822 QMap<int, OTodo>::Iterator it; 822 QMap<int, OPimTodo>::Iterator it;
823 int item = 0; 823 int item = 0;
824 824
825 bool bCat = sortFilter & 1 ? true : false; 825 bool bCat = sortFilter & 1 ? true : false;
826 bool bOnly = sortFilter & 2 ? true : false; 826 bool bOnly = sortFilter & 2 ? true : false;
827 bool comp = sortFilter & 4 ? true : false; 827 bool comp = sortFilter & 4 ? true : false;
828 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 828 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
829 829
830 /* show category */ 830 /* show category */
831 /* -1 == unfiled */ 831 /* -1 == unfiled */
832 if ( bCat && cat == -1 ) { 832 if ( bCat && cat == -1 ) {
833 if(!(*it).categories().isEmpty() ) 833 if(!(*it).categories().isEmpty() )
834 continue; 834 continue;
835 }else if ( bCat && cat != 0) 835 }else if ( bCat && cat != 0)
836 if (!(*it).categories().contains( cat ) ) { 836 if (!(*it).categories().contains( cat ) ) {
837 continue; 837 continue;
838 } 838 }
839 /* isOverdue but we should not show overdue - why?*/ 839 /* isOverdue but we should not show overdue - why?*/
840/* if ( (*it).isOverdue() && !bOnly ) { 840/* if ( (*it).isOverdue() && !bOnly ) {
841 qWarning("item is overdue but !bOnly"); 841 qWarning("item is overdue but !bOnly");
842 continue; 842 continue;
843 } 843 }
844*/ 844*/
845 if ( !(*it).isOverdue() && bOnly ) { 845 if ( !(*it).isOverdue() && bOnly ) {
846 continue; 846 continue;
847 } 847 }
848 848
849 if ((*it).isCompleted() && comp ) { 849 if ((*it).isCompleted() && comp ) {
850 continue; 850 continue;
851 } 851 }
852 852
853 853
854 OTodoXMLContainer* con = new OTodoXMLContainer(); 854 OPimTodoXMLContainer* con = new OPimTodoXMLContainer();
855 con->todo = (*it); 855 con->todo = (*it);
856 vector.insert(item, con ); 856 vector.insert(item, con );
857 item++; 857 item++;
858 } 858 }
859 vector.resize( item ); 859 vector.resize( item );
860 /* sort it now */ 860 /* sort it now */
861 vector.sort(); 861 vector.sort();
862 /* now get the uids */ 862 /* now get the uids */
863 QArray<int> array( vector.count() ); 863 QArray<int> array( vector.count() );
864 for (uint i= 0; i < vector.count(); i++ ) { 864 for (uint i= 0; i < vector.count(); i++ ) {
865 array[i] = ( vector.at(i) )->todo.uid(); 865 array[i] = ( vector.at(i) )->todo.uid();
866 } 866 }
867 return array; 867 return array;
868}; 868};
869void OTodoAccessXML::removeAllCompleted() { 869void OPimTodoAccessXML::removeAllCompleted() {
870 QMap<int, OTodo> events = m_events; 870 QMap<int, OPimTodo> events = m_events;
871 for ( QMap<int, OTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) { 871 for ( QMap<int, OPimTodo>::Iterator it = m_events.begin(); it != m_events.end(); ++it ) {
872 if ( (*it).isCompleted() ) 872 if ( (*it).isCompleted() )
873 events.remove( it.key() ); 873 events.remove( it.key() );
874 } 874 }
875 m_events = events; 875 m_events = events;
876} 876}
877QBitArray OTodoAccessXML::supports()const { 877QBitArray OPimTodoAccessXML::supports()const {
878 static QBitArray ar = sup(); 878 static QBitArray ar = sup();
879 return ar; 879 return ar;
880} 880}
881QBitArray OTodoAccessXML::sup() { 881QBitArray OPimTodoAccessXML::sup() {
882 QBitArray ar( OTodo::CompletedDate +1 ); 882 QBitArray ar( OPimTodo::CompletedDate +1 );
883 ar.fill( true ); 883 ar.fill( true );
884 ar[OTodo::CrossReference] = false; 884 ar[OPimTodo::CrossReference] = false;
885 ar[OTodo::State ] = false; 885 ar[OPimTodo::State ] = false;
886 ar[OTodo::Reminders] = false; 886 ar[OPimTodo::Reminders] = false;
887 ar[OTodo::Notifiers] = false; 887 ar[OPimTodo::Notifiers] = false;
888 ar[OTodo::Maintainer] = false; 888 ar[OPimTodo::Maintainer] = false;
889 889
890 return ar; 890 return ar;
891} 891}
892QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const 892QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
893{ 893{
894 QArray<int> m_currentQuery( m_events.count() ); 894 QArray<int> m_currentQuery( m_events.count() );
895 uint arraycounter = 0; 895 uint arraycounter = 0;
896 896
897 QMap<int, OTodo>::ConstIterator it; 897 QMap<int, OPimTodo>::ConstIterator it;
898 for (it = m_events.begin(); it != m_events.end(); ++it ) { 898 for (it = m_events.begin(); it != m_events.end(); ++it ) {
899 if ( it.data().match( r ) ) 899 if ( it.data().match( r ) )
900 m_currentQuery[arraycounter++] = it.data().uid(); 900 m_currentQuery[arraycounter++] = it.data().uid();
901 901
902 } 902 }
903 // Shrink to fit.. 903 // Shrink to fit..
904 m_currentQuery.resize(arraycounter); 904 m_currentQuery.resize(arraycounter);
905 905
906 return m_currentQuery; 906 return m_currentQuery;
907} 907}
908 908
909} 909}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index d634398..3a51543 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -1,89 +1,89 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_TODO_ACCESS_XML_H 29#ifndef OPIE_TODO_ACCESS_XML_H
30#define OPIE_TODO_ACCESS_XML_H 30#define OPIE_TODO_ACCESS_XML_H
31 31
32#include <qasciidict.h> 32#include <qasciidict.h>
33#include <qmap.h> 33#include <qmap.h>
34 34
35#include <opie2/otodoaccessbackend.h> 35#include <opie2/otodoaccessbackend.h>
36 36
37namespace Opie { 37namespace Opie {
38 class XMLElement; 38 class XMLElement;
39 39
40class OTodoAccessXML : public OTodoAccessBackend { 40class OPimTodoAccessXML : public OPimTodoAccessBackend {
41public: 41public:
42 /** 42 /**
43 * fileName if Empty we will use the default path 43 * fileName if Empty we will use the default path
44 */ 44 */
45 OTodoAccessXML( const QString& appName, 45 OPimTodoAccessXML( const QString& appName,
46 const QString& fileName = QString::null ); 46 const QString& fileName = QString::null );
47 ~OTodoAccessXML(); 47 ~OPimTodoAccessXML();
48 48
49 bool load(); 49 bool load();
50 bool reload(); 50 bool reload();
51 bool save(); 51 bool save();
52 52
53 QArray<int> allRecords()const; 53 QArray<int> allRecords()const;
54 QArray<int> matchRegexp(const QRegExp &r) const; 54 QArray<int> matchRegexp(const QRegExp &r) const;
55 QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); 55 QArray<int> queryByExample( const OPimTodo&, int querysettings, const QDateTime& d = QDateTime() );
56 OTodo find( int uid )const; 56 OPimTodo find( int uid )const;
57 void clear(); 57 void clear();
58 bool add( const OTodo& ); 58 bool add( const OPimTodo& );
59 bool remove( int uid ); 59 bool remove( int uid );
60 void removeAllCompleted(); 60 void removeAllCompleted();
61 bool replace( const OTodo& ); 61 bool replace( const OPimTodo& );
62 62
63 /* our functions */ 63 /* our functions */
64 QArray<int> effectiveToDos( const QDate& start, 64 QArray<int> effectiveToDos( const QDate& start,
65 const QDate& end, 65 const QDate& end,
66 bool includeNoDates ); 66 bool includeNoDates );
67 QArray<int> overDue(); 67 QArray<int> overDue();
68 QArray<int> sorted( bool asc, int sortOrder, 68 QArray<int> sorted( bool asc, int sortOrder,
69 int sortFilter, int cat ); 69 int sortFilter, int cat );
70 QBitArray supports()const; 70 QBitArray supports()const;
71private: 71private:
72 static QBitArray sup(); 72 static QBitArray sup();
73 void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); 73 void todo( QAsciiDict<int>*, OPimTodo&,const QCString&,const QString& );
74 QString toString( const OTodo& )const; 74 QString toString( const OPimTodo& )const;
75 QString toString( const QArray<int>& ints ) const; 75 QString toString( const QArray<int>& ints ) const;
76 QMap<int, OTodo> m_events; 76 QMap<int, OPimTodo> m_events;
77 QString m_file; 77 QString m_file;
78 QString m_app; 78 QString m_app;
79 bool m_opened : 1; 79 bool m_opened : 1;
80 bool m_changed : 1; 80 bool m_changed : 1;
81 class OTodoAccessXMLPrivate; 81 class OPimTodoAccessXMLPrivate;
82 OTodoAccessXMLPrivate* d; 82 OPimTodoAccessXMLPrivate* d;
83 int m_year, m_month, m_day; 83 int m_year, m_month, m_day;
84 84
85}; 85};
86 86
87}; 87};
88 88
89#endif 89#endif
diff --git a/libopie2/opiepim/core/core.pro b/libopie2/opiepim/core/core.pro
index 0473622..597b1e8 100644
--- a/libopie2/opiepim/core/core.pro
+++ b/libopie2/opiepim/core/core.pro
@@ -1,21 +1,23 @@
1HEADERS += core/oconversion.h \ 1HEADERS += \
2 core/opimdateconversion.h \
2 core/opimcache.h \ 3 core/opimcache.h \
3 core/opimmaintainer.h \ 4 core/opimmaintainer.h \
4 core/opimresolver.h \ 5 core/opimresolver.h \
5 core/opimstate.h \ 6 core/opimstate.h \
6 core/opimxref.h \ 7 core/opimxref.h \
7 core/opimxrefmanager.h \ 8 core/opimxrefmanager.h \
8 core/opimxrefpartner.h \ 9 core/opimxrefpartner.h \
9 core/orecur.h \ 10 core/opimrecurrence.h \
10 core/otemplatebase.h \ 11 core/opimtemplatebase.h \
11 core/otimezone.h 12 core/opimtimezone.h
12 13
13SOURCES += core/oconversion.cpp \ 14SOURCES += \
15 core/opimdateconversion.cpp \
14 core/opimmaintainer.cpp \ 16 core/opimmaintainer.cpp \
15 core/opimresolver.cpp \ 17 core/opimresolver.cpp \
16 core/opimstate.cpp \ 18 core/opimstate.cpp \
17 core/opimxref.cpp \ 19 core/opimxref.cpp \
18 core/opimxrefmanager.cpp \ 20 core/opimxrefmanager.cpp \
19 core/opimxrefpartner.cpp \ 21 core/opimxrefpartner.cpp \
20 core/orecur.cpp \ 22 core/opimrecurrence.cpp \
21 core/otimezone.cpp 23 core/opimtimezone.cpp
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index f67a40c..c12e138 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,152 +1,152 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * ===================================================================== 30 * =====================================================================
31 * ToDo: XML-Backend: Automatic reload if something was changed... 31 * ToDo: XML-Backend: Automatic reload if something was changed...
32 * 32 *
33 * 33 *
34 */ 34 */
35 35
36#include "ocontactaccess.h" 36#include "ocontactaccess.h"
37#include "obackendfactory.h" 37#include "obackendfactory.h"
38 38
39#include <qasciidict.h> 39#include <qasciidict.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qlist.h> 43#include <qlist.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46//#include <qpe/qcopenvelope_qws.h> 46//#include <qpe/qcopenvelope_qws.h>
47#include <qpe/global.h> 47#include <qpe/global.h>
48 48
49#include <errno.h> 49#include <errno.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <unistd.h> 51#include <unistd.h>
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include <opie2/ocontactaccessbackend_xml.h> 54#include <opie2/ocontactaccessbackend_xml.h>
55 55
56namespace Opie { 56namespace Opie {
57 57
58OContactAccess::OContactAccess ( const QString appname, const QString , 58OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
59 OContactAccessBackend* end, bool autosync ): 59 OPimContactAccessBackend* end, bool autosync ):
60 OPimAccessTemplate<OContact>( end ) 60 OPimAccessTemplate<OPimContact>( end )
61{ 61{
62 /* take care of the backend. If there is no one defined, we 62 /* take care of the backend. If there is no one defined, we
63 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 63 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
64 */ 64 */
65 if( end == 0 ) { 65 if( end == 0 ) {
66 qWarning ("Using BackendFactory !"); 66 qWarning ("Using BackendFactory !");
67 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 67 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname );
68 } 68 }
69 // Set backend locally and in template 69 // Set backend locally and in template
70 m_backEnd = end; 70 m_backEnd = end;
71 OPimAccessTemplate<OContact>::setBackEnd (end); 71 OPimAccessTemplate<OPimContact>::setBackEnd (end);
72 72
73 73
74 /* Connect signal of external db change to function */ 74 /* Connect signal of external db change to function */
75 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 75 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
76 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 76 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
77 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 77 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
78 if ( autosync ){ 78 if ( autosync ){
79 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 79 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
80 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 80 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
81 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 81 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
82 } 82 }
83 83
84 84
85} 85}
86OContactAccess::~OContactAccess () 86OPimContactAccess::~OPimContactAccess ()
87{ 87{
88 /* The user may forget to save the changed database, therefore try to 88 /* The user may forget to save the changed database, therefore try to
89 * do it for him.. 89 * do it for him..
90 */ 90 */
91 save(); 91 save();
92 // delete m_backEnd; is done by template.. 92 // delete m_backEnd; is done by template..
93} 93}
94 94
95 95
96bool OContactAccess::save () 96bool OPimContactAccess::save ()
97{ 97{
98 /* If the database was changed externally, we could not save the 98 /* If the database was changed externally, we could not save the
99 * Data. This will remove added items which is unacceptable ! 99 * Data. This will remove added items which is unacceptable !
100 * Therefore: Reload database and merge the data... 100 * Therefore: Reload database and merge the data...
101 */ 101 */
102 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 102 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() )
103 reload(); 103 reload();
104 104
105 bool status = OPimAccessTemplate<OContact>::save(); 105 bool status = OPimAccessTemplate<OPimContact>::save();
106 if ( !status ) return false; 106 if ( !status ) return false;
107 107
108 /* Now tell everyone that new data is available. 108 /* Now tell everyone that new data is available.
109 */ 109 */
110 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 110 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
111 111
112 return true; 112 return true;
113} 113}
114 114
115const uint OContactAccess::querySettings() 115const uint OPimContactAccess::querySettings()
116{ 116{
117 return ( m_backEnd->querySettings() ); 117 return ( m_backEnd->querySettings() );
118} 118}
119 119
120bool OContactAccess::hasQuerySettings ( int querySettings ) const 120bool OPimContactAccess::hasQuerySettings ( int querySettings ) const
121{ 121{
122 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 122 return ( m_backEnd->hasQuerySettings ( querySettings ) );
123} 123}
124ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 124OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
125{ 125{
126 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 126 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
127 return ( ORecordList<OContact>(matchingContacts, this) ); 127 return ( OPimRecordList<OPimContact>(matchingContacts, this) );
128} 128}
129 129
130 130
131bool OContactAccess::wasChangedExternally()const 131bool OPimContactAccess::wasChangedExternally()const
132{ 132{
133 return ( m_backEnd->wasChangedExternally() ); 133 return ( m_backEnd->wasChangedExternally() );
134} 134}
135 135
136 136
137void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 137void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
138{ 138{
139 if ( msg == "addressbookUpdated()" ){ 139 if ( msg == "addressbookUpdated()" ){
140 qWarning ("OContactAccess: Received addressbokUpdated()"); 140 qWarning ("OPimContactAccess: Received addressbokUpdated()");
141 emit signalChanged ( this ); 141 emit signalChanged ( this );
142 } else if ( msg == "flush()" ) { 142 } else if ( msg == "flush()" ) {
143 qWarning ("OContactAccess: Received flush()"); 143 qWarning ("OPimContactAccess: Received flush()");
144 save (); 144 save ();
145 } else if ( msg == "reload()" ) { 145 } else if ( msg == "reload()" ) {
146 qWarning ("OContactAccess: Received reload()"); 146 qWarning ("OPimContactAccess: Received reload()");
147 reload (); 147 reload ();
148 emit signalChanged ( this ); 148 emit signalChanged ( this );
149 } 149 }
150} 150}
151 151
152} 152}
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index 505c87b..cf5333a 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -1,158 +1,158 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * ===================================================================== 30 * =====================================================================
31 * ToDo: Define enum for query settings 31 * ToDo: Define enum for query settings
32 * ===================================================================== 32 * =====================================================================
33 */ 33 */
34#ifndef _OCONTACTACCESS_H 34#ifndef _OCONTACTACCESS_H
35#define _OCONTACTACCESS_H 35#define _OCONTACTACCESS_H
36 36
37#include <qobject.h> 37#include <qobject.h>
38 38
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40 40
41#include <qvaluelist.h> 41#include <qvaluelist.h>
42#include <qfileinfo.h> 42#include <qfileinfo.h>
43 43
44#include <opie2/ocontact.h> 44#include <opie2/opimcontact.h>
45#include <opie2/ocontactaccessbackend.h> 45#include <opie2/ocontactaccessbackend.h>
46#include <opie2/opimaccesstemplate.h> 46#include <opie2/opimaccesstemplate.h>
47 47
48namespace Opie { 48namespace Opie {
49/** 49/**
50 * Class to access the contacts database. 50 * Class to access the contacts database.
51 * This is just a frontend for the real database handling which is 51 * This is just a frontend for the real database handling which is
52 * done by the backend. 52 * done by the backend.
53 * This class is used to access the Contacts on a system. This class as any OPIE PIM 53 * This class is used to access the Contacts on a system. This class as any OPIE PIM
54 * class is backend independent. 54 * class is backend independent.
55 * @author Stefan Eilers, Holger Freyther 55 * @author Stefan Eilers, Holger Freyther
56 * @see OPimAccessTemplate 56 * @see OPimAccessTemplate
57 */ 57 */
58class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 58class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
59{ 59{
60 Q_OBJECT 60 Q_OBJECT
61 61
62 public: 62 public:
63 /** 63 /**
64 * Create Database with contacts (addressbook). 64 * Create Database with contacts (addressbook).
65 * @param appname Name of application which wants access to the database 65 * @param appname Name of application which wants access to the database
66 * (i.e. "todolist") 66 * (i.e. "todolist")
67 * @param filename The name of the database file. If not set, the default one 67 * @param filename The name of the database file. If not set, the default one
68 * is used. 68 * is used.
69 * @param backend Pointer to an alternative Backend. If not set, we will use 69 * @param backend Pointer to an alternative Backend. If not set, we will use
70 * the default backend. 70 * the default backend.
71 * @param handlesync If <b>true</b> the database stores the current state 71 * @param handlesync If <b>true</b> the database stores the current state
72 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 72 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
73 * which are used before and after synchronisation. If the application wants 73 * which are used before and after synchronisation. If the application wants
74 * to react itself, it should be disabled by setting it to <b>false</b> 74 * to react itself, it should be disabled by setting it to <b>false</b>
75 * @see OContactAccessBackend 75 * @see OPimContactAccessBackend
76 */ 76 */
77 OContactAccess (const QString appname, const QString filename = 0l, 77 OPimContactAccess (const QString appname, const QString filename = 0l,
78 OContactAccessBackend* backend = 0l, bool handlesync = true); 78 OPimContactAccessBackend* backend = 0l, bool handlesync = true);
79 ~OContactAccess (); 79 ~OPimContactAccess ();
80 80
81 /** Constants for query. 81 /** Constants for query.
82 * Use this constants to set the query parameters. 82 * Use this constants to set the query parameters.
83 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 83 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
84 * @see queryByExample() 84 * @see queryByExample()
85 */ 85 */
86 enum QuerySettings { 86 enum QuerySettings {
87 WildCards = 0x0001, 87 WildCards = 0x0001,
88 IgnoreCase = 0x0002, 88 IgnoreCase = 0x0002,
89 RegExp = 0x0004, 89 RegExp = 0x0004,
90 ExactMatch = 0x0008, 90 ExactMatch = 0x0008,
91 MatchOne = 0x0010, // Only one Entry must match 91 MatchOne = 0x0010, // Only one Entry must match
92 DateDiff = 0x0020, // Find all entries from today until given date 92 DateDiff = 0x0020, // Find all entries from today until given date
93 DateYear = 0x0040, // The year matches 93 DateYear = 0x0040, // The year matches
94 DateMonth = 0x0080, // The month matches 94 DateMonth = 0x0080, // The month matches
95 DateDay = 0x0100, // The day matches 95 DateDay = 0x0100, // The day matches
96 }; 96 };
97 97
98 98
99 /** Return all Contacts in a sorted manner. 99 /** Return all Contacts in a sorted manner.
100 * @param ascending true: Sorted in acending order. 100 * @param ascending true: Sorted in acending order.
101 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 101 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
102 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 102 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
103 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 103 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
104 */ 104 */
105 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 105 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
106 106
107 /** Return all possible settings. 107 /** Return all possible settings.
108 * @return All settings provided by the current backend 108 * @return All settings provided by the current backend
109 * (i.e.: query_WildCards & query_IgnoreCase) 109 * (i.e.: query_WildCards & query_IgnoreCase)
110 */ 110 */
111 const uint querySettings(); 111 const uint querySettings();
112 112
113 /** Check whether settings are correct. 113 /** Check whether settings are correct.
114 * @return <i>true</i> if the given settings are correct and possible. 114 * @return <i>true</i> if the given settings are correct and possible.
115 */ 115 */
116 bool hasQuerySettings ( int querySettings ) const; 116 bool hasQuerySettings ( int querySettings ) const;
117 117
118 /** 118 /**
119 * if the resource was changed externally. 119 * if the resource was changed externally.
120 * You should use the signal instead of polling possible changes ! 120 * You should use the signal instead of polling possible changes !
121 */ 121 */
122 bool wasChangedExternally()const; 122 bool wasChangedExternally()const;
123 123
124 124
125 /** Save contacts database. 125 /** Save contacts database.
126 * Save is more a "commit". After calling this function, all changes are public available. 126 * Save is more a "commit". After calling this function, all changes are public available.
127 * @return true if successful 127 * @return true if successful
128 */ 128 */
129 bool save(); 129 bool save();
130 130
131 signals: 131 signals:
132 /* Signal is emitted if the database was changed. Therefore 132 /* Signal is emitted if the database was changed. Therefore
133 * we may need to reload to stay consistent. 133 * we may need to reload to stay consistent.
134 * @param which Pointer to the database who created this event. This pointer 134 * @param which Pointer to the database who created this event. This pointer
135 * is useful if an application has to handle multiple databases at the same time. 135 * is useful if an application has to handle multiple databases at the same time.
136 * @see reload() 136 * @see reload()
137 */ 137 */
138 void signalChanged ( const OContactAccess *which ); 138 void signalChanged ( const OPimContactAccess *which );
139 139
140 140
141 private: 141 private:
142 // class OContactAccessPrivate; 142 // class OPimContactAccessPrivate;
143 // OContactAccessPrivate* d; 143 // OPimContactAccessPrivate* d;
144 OContactAccessBackend *m_backEnd; 144 OPimContactAccessBackend *m_backEnd;
145 bool m_loading:1; 145 bool m_loading:1;
146 146
147 private slots: 147 private slots:
148 void copMessage( const QCString &msg, const QByteArray &data ); 148 void copMessage( const QCString &msg, const QByteArray &data );
149 149
150 private: 150 private:
151 class Private; 151 class Private;
152 Private *d; 152 Private *d;
153 153
154}; 154};
155 155
156} 156}
157 157
158#endif 158#endif
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index 8c527f6..ac310c1 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -1,112 +1,112 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <opie2/obackendfactory.h> 29#include <opie2/obackendfactory.h>
30#include <opie2/odatebookaccess.h> 30#include <opie2/odatebookaccess.h>
31 31
32namespace Opie { 32namespace Opie {
33/** 33/**
34 * Simple constructor 34 * Simple constructor
35 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation 35 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation
36 * will be used! 36 * will be used!
37 * @param back The backend to be used or 0 for the default backend 37 * @param back The backend to be used or 0 for the default backend
38 * @param ac What kind of access is intended 38 * @param ac What kind of access is intended
39 */ 39 */
40ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) 40ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
41 : OPimAccessTemplate<OEvent>( back ) 41 : OPimAccessTemplate<OPimEvent>( back )
42{ 42{
43 if (!back ) 43 if (!back )
44 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null ); 44 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null );
45 45
46 m_backEnd = back; 46 m_backEnd = back;
47 setBackEnd( m_backEnd ); 47 setBackEnd( m_backEnd );
48} 48}
49ODateBookAccess::~ODateBookAccess() { 49ODateBookAccess::~ODateBookAccess() {
50} 50}
51 51
52/** 52/**
53 * @return all events available 53 * @return all events available
54 */ 54 */
55ODateBookAccess::List ODateBookAccess::rawEvents()const { 55ODateBookAccess::List ODateBookAccess::rawEvents()const {
56 QArray<int> ints = m_backEnd->rawEvents(); 56 QArray<int> ints = m_backEnd->rawEvents();
57 57
58 List lis( ints, this ); 58 List lis( ints, this );
59 return lis; 59 return lis;
60} 60}
61 61
62/** 62/**
63 * @return all repeating events 63 * @return all repeating events
64 */ 64 */
65ODateBookAccess::List ODateBookAccess::rawRepeats()const { 65ODateBookAccess::List ODateBookAccess::rawRepeats()const {
66 QArray<int> ints = m_backEnd->rawRepeats(); 66 QArray<int> ints = m_backEnd->rawRepeats();
67 67
68 List lis( ints, this ); 68 List lis( ints, this );
69 return lis; 69 return lis;
70} 70}
71 71
72/** 72/**
73 * @return all non repeating events 73 * @return all non repeating events
74 */ 74 */
75ODateBookAccess::List ODateBookAccess::nonRepeats()const { 75ODateBookAccess::List ODateBookAccess::nonRepeats()const {
76 QArray<int> ints = m_backEnd->nonRepeats(); 76 QArray<int> ints = m_backEnd->nonRepeats();
77 77
78 List lis( ints, this ); 78 List lis( ints, this );
79 return lis; 79 return lis;
80} 80}
81 81
82/** 82/**
83 * @return dates in the time span between from and to 83 * @return dates in the time span between from and to
84 * @param from Include all events from... 84 * @param from Include all events from...
85 * @param to Include all events to... 85 * @param to Include all events to...
86 */ 86 */
87OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { 87OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const {
88 return m_backEnd->effectiveEvents( from, to ); 88 return m_backEnd->effectiveEvents( from, to );
89} 89}
90/** 90/**
91 * @return all events at a given datetime 91 * @return all events at a given datetime
92 */ 92 */
93OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { 93OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const {
94 return m_backEnd->effectiveEvents( start ); 94 return m_backEnd->effectiveEvents( start );
95} 95}
96 96
97/** 97/**
98 * @return non repeating dates in the time span between from and to 98 * @return non repeating dates in the time span between from and to
99 * @param from Include all events from... 99 * @param from Include all events from...
100 * @param to Include all events to... 100 * @param to Include all events to...
101 */ 101 */
102OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { 102OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const {
103 return m_backEnd->effectiveNonRepeatingEvents( from, to ); 103 return m_backEnd->effectiveNonRepeatingEvents( from, to );
104} 104}
105/** 105/**
106 * @return all non repeating events at a given datetime 106 * @return all non repeating events at a given datetime
107 */ 107 */
108OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { 108OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
109 return m_backEnd->effectiveNonRepeatingEvents( start ); 109 return m_backEnd->effectiveNonRepeatingEvents( start );
110} 110}
111 111
112} 112}
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
index 38dc754..6c9290f 100644
--- a/libopie2/opiepim/core/odatebookaccess.h
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -1,75 +1,75 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_DATE_BOOK_ACCESS_H 29#ifndef OPIE_DATE_BOOK_ACCESS_H
30#define OPIE_DATE_BOOK_ACCESS_H 30#define OPIE_DATE_BOOK_ACCESS_H
31 31
32#include "odatebookaccessbackend.h" 32#include "odatebookaccessbackend.h"
33#include "opimaccesstemplate.h" 33#include "opimaccesstemplate.h"
34 34
35#include <opie2/oevent.h> 35#include <opie2/opimevent.h>
36 36
37namespace Opie { 37namespace Opie {
38/** 38/**
39 * This is the object orientated datebook database. It'll use OBackendFactory 39 * This is the object orientated datebook database. It'll use OBackendFactory
40 * to query for a backend. 40 * to query for a backend.
41 * All access to the datebook should be done via this class. 41 * All access to the datebook should be done via this class.
42 * Make sure to load and save the datebook this is not part of 42 * Make sure to load and save the datebook this is not part of
43 * destructing and creating the object 43 * destructing and creating the object
44 * 44 *
45 * @author Holger Freyther, Stefan Eilers 45 * @author Holger Freyther, Stefan Eilers
46 */ 46 */
47class ODateBookAccess : public OPimAccessTemplate<OEvent> { 47class ODateBookAccess : public OPimAccessTemplate<OPimEvent> {
48public: 48public:
49 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); 49 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random );
50 ~ODateBookAccess(); 50 ~ODateBookAccess();
51 51
52 /* return all events */ 52 /* return all events */
53 List rawEvents()const; 53 List rawEvents()const;
54 54
55 /* return repeating events */ 55 /* return repeating events */
56 List rawRepeats()const; 56 List rawRepeats()const;
57 57
58 /* return non repeating events */ 58 /* return non repeating events */
59 List nonRepeats()const; 59 List nonRepeats()const;
60 60
61 /* return non repeating events (from,to) */ 61 /* return non repeating events (from,to) */
62 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; 62 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const;
63 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; 63 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const;
64 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; 64 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const;
65 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; 65 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const;
66 66
67private: 67private:
68 ODateBookAccessBackend* m_backEnd; 68 ODateBookAccessBackend* m_backEnd;
69 class Private; 69 class Private;
70 Private* d; 70 Private* d;
71}; 71};
72 72
73} 73}
74 74
75#endif 75#endif
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 5826cbc..f1bcc44 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -1,252 +1,252 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_PIM_ACCESS_TEMPLATE_H 29#ifndef OPIE_PIM_ACCESS_TEMPLATE_H
30#define OPIE_PIM_ACCESS_TEMPLATE_H 30#define OPIE_PIM_ACCESS_TEMPLATE_H
31 31
32#include <qarray.h> 32#include <qarray.h>
33 33
34#include <opie2/opimrecord.h> 34#include <opie2/opimrecord.h>
35#include <opie2/opimaccessbackend.h> 35#include <opie2/opimaccessbackend.h>
36#include <opie2/orecordlist.h> 36#include <opie2/opimrecordlist.h>
37 37
38#include <opie2/opimcache.h> 38#include <opie2/opimcache.h>
39#include <opie2/otemplatebase.h> 39#include <opie2/opimtemplatebase.h>
40 40
41namespace Opie { 41namespace Opie {
42 42
43class OPimAccessTemplatePrivate; 43class OPimAccessTemplatePrivate;
44/** 44/**
45 * Thats the frontend to our OPIE PIM 45 * Thats the frontend to our OPIE PIM
46 * Library. Either you want to use it's 46 * Library. Either you want to use it's
47 * interface or you want to implement 47 * interface or you want to implement
48 * your own Access lib 48 * your own Access lib
49 * Just create a OPimRecord and inherit from 49 * Just create a OPimRecord and inherit from
50 * the plugins 50 * the plugins
51 */ 51 */
52 52
53template <class T = OPimRecord > 53template <class T = OPimRecord >
54class OPimAccessTemplate : public OTemplateBase<T> { 54class OPimAccessTemplate : public OTemplateBase<T> {
55public: 55public:
56 enum Access { 56 enum Access {
57 Random = 0, 57 Random = 0,
58 SortedAccess 58 SortedAccess
59 }; 59 };
60 typedef ORecordList<T> List; 60 typedef OPimRecordList<T> List;
61 typedef OPimAccessBackend<T> BackEnd; 61 typedef OPimAccessBackend<T> BackEnd;
62 typedef OPimCache<T> Cache; 62 typedef OPimCache<T> Cache;
63 63
64 /** 64 /**
65 * c'tor BackEnd 65 * c'tor BackEnd
66 * enum Access a small hint on how to handle the backend 66 * enum Access a small hint on how to handle the backend
67 */ 67 */
68 OPimAccessTemplate( BackEnd* end); 68 OPimAccessTemplate( BackEnd* end);
69 69
70 virtual ~OPimAccessTemplate(); 70 virtual ~OPimAccessTemplate();
71 71
72 /** 72 /**
73 * load from the backend 73 * load from the backend
74 */ 74 */
75 bool load(); 75 bool load();
76 76
77 /** Reload database. 77 /** Reload database.
78 * You should execute this function if the external database 78 * You should execute this function if the external database
79 * was changed. 79 * was changed.
80 * This function will load the external database and afterwards 80 * This function will load the external database and afterwards
81 * rejoin the local changes. Therefore the local database will be set consistent. 81 * rejoin the local changes. Therefore the local database will be set consistent.
82 */ 82 */
83 virtual bool reload(); 83 virtual bool reload();
84 84
85 /** Save contacts database. 85 /** Save contacts database.
86 * Save is more a "commit". After calling this function, all changes are public available. 86 * Save is more a "commit". After calling this function, all changes are public available.
87 * @return true if successful 87 * @return true if successful
88 */ 88 */
89 bool save(); 89 bool save();
90 90
91 /** 91 /**
92 * if the resource was changed externally 92 * if the resource was changed externally
93 * You should use the signal handling instead of polling possible changes ! 93 * You should use the signal handling instead of polling possible changes !
94 * zecke: Do you implement a signal for otodoaccess ? 94 * zecke: Do you implement a signal for otodoaccess ?
95 */ 95 */
96 bool wasChangedExternally()const; 96 bool wasChangedExternally()const;
97 97
98 /** 98 /**
99 * return a List of records 99 * return a List of records
100 * you can iterate over them 100 * you can iterate over them
101 */ 101 */
102 virtual List allRecords()const; 102 virtual List allRecords()const;
103 103
104 /** 104 /**
105 * return a List of records 105 * return a List of records
106 * that match the regex 106 * that match the regex
107 */ 107 */
108 virtual List matchRegexp( const QRegExp &r ) const; 108 virtual List matchRegexp( const QRegExp &r ) const;
109 109
110 /** 110 /**
111 * queryByExample. 111 * queryByExample.
112 * @see otodoaccess, ocontactaccess 112 * @see otodoaccess, ocontactaccess
113 */ 113 */
114 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() ); 114 virtual List queryByExample( const T& t, int querySettings, const QDateTime& d = QDateTime() );
115 115
116 /** 116 /**
117 * find the OPimRecord uid 117 * find the OPimRecord uid
118 */ 118 */
119 virtual T find( int uid )const; 119 virtual T find( int uid )const;
120 120
121 /** 121 /**
122 * read ahead cache find method ;) 122 * read ahead cache find method ;)
123 */ 123 */
124 virtual T find( int uid, const QArray<int>&, 124 virtual T find( int uid, const QArray<int>&,
125 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 125 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
126 126
127 /* invalidate cache here */ 127 /* invalidate cache here */
128 /** 128 /**
129 * clears the backend and invalidates the backend 129 * clears the backend and invalidates the backend
130 */ 130 */
131 void clear() ; 131 void clear() ;
132 132
133 /** 133 /**
134 * add T to the backend 134 * add T to the backend
135 * @param t The item to add. 135 * @param t The item to add.
136 * @return <i>true</i> if added successfully. 136 * @return <i>true</i> if added successfully.
137 */ 137 */
138 virtual bool add( const T& t ) ; 138 virtual bool add( const T& t ) ;
139 bool add( const OPimRecord& ); 139 bool add( const OPimRecord& );
140 140
141 /* only the uid matters */ 141 /* only the uid matters */
142 /** 142 /**
143 * remove T from the backend 143 * remove T from the backend
144 * @param t The item to remove 144 * @param t The item to remove
145 * @return <i>true</i> if successful. 145 * @return <i>true</i> if successful.
146 */ 146 */
147 virtual bool remove( const T& t ); 147 virtual bool remove( const T& t );
148 148
149 /** 149 /**
150 * remove the OPimRecord with uid 150 * remove the OPimRecord with uid
151 * @param uid The ID of the item to remove 151 * @param uid The ID of the item to remove
152 * @return <i>true</i> if successful. 152 * @return <i>true</i> if successful.
153 */ 153 */
154 bool remove( int uid ); 154 bool remove( int uid );
155 bool remove( const OPimRecord& ); 155 bool remove( const OPimRecord& );
156 156
157 /** 157 /**
158 * replace T from backend 158 * replace T from backend
159 * @param t The item to replace 159 * @param t The item to replace
160 * @return <i>true</i> if successful. 160 * @return <i>true</i> if successful.
161 */ 161 */
162 virtual bool replace( const T& t) ; 162 virtual bool replace( const T& t) ;
163 163
164 void setReadAhead( uint count ); 164 void setReadAhead( uint count );
165 /** 165 /**
166 * @internal 166 * @internal
167 */ 167 */
168 void cache( const T& )const; 168 void cache( const T& )const;
169 void setSaneCacheSize( int ); 169 void setSaneCacheSize( int );
170 170
171 QArray<int> records()const; 171 QArray<int> records()const;
172protected: 172protected:
173 /** 173 /**
174 * invalidate the cache 174 * invalidate the cache
175 */ 175 */
176 void invalidateCache(); 176 void invalidateCache();
177 177
178 void setBackEnd( BackEnd* end ); 178 void setBackEnd( BackEnd* end );
179 /** 179 /**
180 * returns the backend 180 * returns the backend
181 */ 181 */
182 BackEnd* backEnd(); 182 BackEnd* backEnd();
183 BackEnd* m_backEnd; 183 BackEnd* m_backEnd;
184 Cache m_cache; 184 Cache m_cache;
185 185
186private: 186private:
187 OPimAccessTemplatePrivate *d; 187 OPimAccessTemplatePrivate *d;
188 188
189}; 189};
190 190
191template <class T> 191template <class T>
192OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) 192OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end )
193 : OTemplateBase<T>(), m_backEnd( end ) 193 : OTemplateBase<T>(), m_backEnd( end )
194{ 194{
195 if (end ) 195 if (end )
196 end->setFrontend( this ); 196 end->setFrontend( this );
197} 197}
198template <class T> 198template <class T>
199OPimAccessTemplate<T>::~OPimAccessTemplate() { 199OPimAccessTemplate<T>::~OPimAccessTemplate() {
200 qWarning("~OPimAccessTemplate<T>"); 200 qWarning("~OPimAccessTemplate<T>");
201 delete m_backEnd; 201 delete m_backEnd;
202} 202}
203template <class T> 203template <class T>
204bool OPimAccessTemplate<T>::load() { 204bool OPimAccessTemplate<T>::load() {
205 invalidateCache(); 205 invalidateCache();
206 return m_backEnd->load(); 206 return m_backEnd->load();
207} 207}
208template <class T> 208template <class T>
209bool OPimAccessTemplate<T>::reload() { 209bool OPimAccessTemplate<T>::reload() {
210 invalidateCache(); // zecke: I think this should be added (se) 210 invalidateCache(); // zecke: I think this should be added (se)
211 return m_backEnd->reload(); 211 return m_backEnd->reload();
212} 212}
213template <class T> 213template <class T>
214bool OPimAccessTemplate<T>::save() { 214bool OPimAccessTemplate<T>::save() {
215 return m_backEnd->save(); 215 return m_backEnd->save();
216} 216}
217template <class T> 217template <class T>
218typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { 218typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
219 QArray<int> ints = m_backEnd->allRecords(); 219 QArray<int> ints = m_backEnd->allRecords();
220 List lis(ints, this ); 220 List lis(ints, this );
221 return lis; 221 return lis;
222} 222}
223template <class T> 223template <class T>
224typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const { 224typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::matchRegexp( const QRegExp &r )const {
225 QArray<int> ints = m_backEnd->matchRegexp( r ); 225 QArray<int> ints = m_backEnd->matchRegexp( r );
226 List lis(ints, this ); 226 List lis(ints, this );
227 return lis; 227 return lis;
228} 228}
229template <class T> 229template <class T>
230QArray<int> OPimAccessTemplate<T>::records()const { 230QArray<int> OPimAccessTemplate<T>::records()const {
231 return m_backEnd->allRecords(); 231 return m_backEnd->allRecords();
232} 232}
233template <class T> 233template <class T>
234typename OPimAccessTemplate<T>::List 234typename OPimAccessTemplate<T>::List
235OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { 235OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) {
236 QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); 236 QArray<int> ints = m_backEnd->queryByExample( t, settings, d );
237 237
238 List lis(ints, this ); 238 List lis(ints, this );
239 return lis; 239 return lis;
240} 240}
241template <class T> 241template <class T>
242T OPimAccessTemplate<T>::find( int uid ) const{ 242T OPimAccessTemplate<T>::find( int uid ) const{
243 T t = m_backEnd->find( uid ); 243 T t = m_backEnd->find( uid );
244 cache( t ); 244 cache( t );
245 return t; 245 return t;
246} 246}
247template <class T> 247template <class T>
248T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 248T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
249 uint current, typename OTemplateBase<T>::CacheDirection dir )const { 249 uint current, typename OTemplateBase<T>::CacheDirection dir )const {
250 /* 250 /*
251 * better do T.isEmpty() 251 * better do T.isEmpty()
252 * after a find this way we would 252 * after a find this way we would
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index fa5313f..a5df597 100644
--- a/libopie2/opiepim/ocontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -1,1293 +1,1293 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#define QTOPIA_INTERNAL_CONTACT_MRE 30#define QTOPIA_INTERNAL_CONTACT_MRE
31 31
32#include "ocontact.h" 32#include "opimcontact.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/opimresolver.h> 35#include <opie2/opimresolver.h>
36#include <opie2/oconversion.h> 36#include <opie2/opimdateconversion.h>
37#include <qpe/stringutil.h> 37#include <qpe/stringutil.h>
38#include <qpe/timestring.h> 38#include <qpe/timestring.h>
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41/* QT */ 41/* QT */
42#include <qobject.h> 42#include <qobject.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qstylesheet.h> 44#include <qstylesheet.h>
45#include <qfileinfo.h> 45#include <qfileinfo.h>
46#include <qmap.h> 46#include <qmap.h>
47 47
48/* STD */ 48/* STD */
49#include <stdio.h> 49#include <stdio.h>
50 50
51/*! 51/*!
52 \class Contact contact.h 52 \class Contact contact.h
53 \brief The Contact class holds the data of an address book entry. 53 \brief The Contact class holds the data of an address book entry.
54 54
55 This data includes information the name of the person, contact 55 This data includes information the name of the person, contact
56 information, and business information such as deparment and job title. 56 information, and business information such as deparment and job title.
57 57
58 \ingroup qtopiaemb 58 \ingroup qtopiaemb
59 \ingroup qtopiadesktop 59 \ingroup qtopiadesktop
60*/ 60*/
61 61
62 62
63namespace Opie 63namespace Opie
64{ 64{
65/*! 65/*!
66 Creates a new, empty contact. 66 Creates a new, empty contact.
67*/ 67*/
68OContact::OContact():OPimRecord(), mMap(), d( 0 ) 68OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 )
69{} 69{}
70 70
71/*! 71/*!
72 \internal 72 \internal
73 Creates a new contact. The properties of the contact are 73 Creates a new contact. The properties of the contact are
74 set from \a fromMap. 74 set from \a fromMap.
75*/ 75*/
76OContact::OContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) 76OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
77{ 77{
78 QString cats = mMap[ Qtopia::AddressCategory ]; 78 QString cats = mMap[ Qtopia::AddressCategory ];
79 if ( !cats.isEmpty() ) 79 if ( !cats.isEmpty() )
80 setCategories( idsFromString( cats ) ); 80 setCategories( idsFromString( cats ) );
81 81
82 QString uidStr = find( Qtopia::AddressUid ); 82 QString uidStr = find( Qtopia::AddressUid );
83 83
84 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) 84 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
85 { 85 {
86 qWarning( "Invalid UID found. Generate new one.." ); 86 qWarning( "Invalid UID found. Generate new one.." );
87 setUid( uidGen().generate() ); 87 setUid( uidGen().generate() );
88 } 88 }
89 else 89 else
90 setUid( uidStr.toInt() ); 90 setUid( uidStr.toInt() );
91 91
92 // if ( !uidStr.isEmpty() ) 92 // if ( !uidStr.isEmpty() )
93 // setUid( uidStr.toInt() ); 93 // setUid( uidStr.toInt() );
94} 94}
95 95
96/*! 96/*!
97 Destroys a contact. 97 Destroys a contact.
98*/ 98*/
99OContact::~OContact() 99OPimContact::~OPimContact()
100{} 100{}
101 101
102/*! \fn void OContact::setTitle( const QString &str ) 102/*! \fn void OPimContact::setTitle( const QString &str )
103 Sets the title of the contact to \a str. 103 Sets the title of the contact to \a str.
104*/ 104*/
105 105
106/*! \fn void OContact::setFirstName( const QString &str ) 106/*! \fn void OPimContact::setFirstName( const QString &str )
107 Sets the first name of the contact to \a str. 107 Sets the first name of the contact to \a str.
108*/ 108*/
109 109
110/*! \fn void OContact::setMiddleName( const QString &str ) 110/*! \fn void OPimContact::setMiddleName( const QString &str )
111 Sets the middle name of the contact to \a str. 111 Sets the middle name of the contact to \a str.
112*/ 112*/
113 113
114/*! \fn void OContact::setLastName( const QString &str ) 114/*! \fn void OPimContact::setLastName( const QString &str )
115 Sets the last name of the contact to \a str. 115 Sets the last name of the contact to \a str.
116*/ 116*/
117 117
118/*! \fn void OContact::setSuffix( const QString &str ) 118/*! \fn void OPimContact::setSuffix( const QString &str )
119 Sets the suffix of the contact to \a str. 119 Sets the suffix of the contact to \a str.
120*/ 120*/
121 121
122/*! \fn void OContact::setFileAs( const QString &str ) 122/*! \fn void OPimContact::setFileAs( const QString &str )
123 Sets the contact to filed as \a str. 123 Sets the contact to filed as \a str.
124*/ 124*/
125 125
126/*! \fn void OContact::setDefaultEmail( const QString &str ) 126/*! \fn void OPimContact::setDefaultEmail( const QString &str )
127 Sets the default email of the contact to \a str. 127 Sets the default email of the contact to \a str.
128*/ 128*/
129 129
130/*! \fn void OContact::setHomeStreet( const QString &str ) 130/*! \fn void OPimContact::setHomeStreet( const QString &str )
131 Sets the home street address of the contact to \a str. 131 Sets the home street address of the contact to \a str.
132*/ 132*/
133 133
134/*! \fn void OContact::setHomeCity( const QString &str ) 134/*! \fn void OPimContact::setHomeCity( const QString &str )
135 Sets the home city of the contact to \a str. 135 Sets the home city of the contact to \a str.
136*/ 136*/
137 137
138/*! \fn void OContact::setHomeState( const QString &str ) 138/*! \fn void OPimContact::setHomeState( const QString &str )
139 Sets the home state of the contact to \a str. 139 Sets the home state of the contact to \a str.
140*/ 140*/
141 141
142/*! \fn void OContact::setHomeZip( const QString &str ) 142/*! \fn void OPimContact::setHomeZip( const QString &str )
143 Sets the home zip code of the contact to \a str. 143 Sets the home zip code of the contact to \a str.
144*/ 144*/
145 145
146/*! \fn void OContact::setHomeCountry( const QString &str ) 146/*! \fn void OPimContact::setHomeCountry( const QString &str )
147 Sets the home country of the contact to \a str. 147 Sets the home country of the contact to \a str.
148*/ 148*/
149 149
150/*! \fn void OContact::setHomePhone( const QString &str ) 150/*! \fn void OPimContact::setHomePhone( const QString &str )
151 Sets the home phone number of the contact to \a str. 151 Sets the home phone number of the contact to \a str.
152*/ 152*/
153 153
154/*! \fn void OContact::setHomeFax( const QString &str ) 154/*! \fn void OPimContact::setHomeFax( const QString &str )
155 Sets the home fax number of the contact to \a str. 155 Sets the home fax number of the contact to \a str.
156*/ 156*/
157 157
158/*! \fn void OContact::setHomeMobile( const QString &str ) 158/*! \fn void OPimContact::setHomeMobile( const QString &str )
159 Sets the home mobile phone number of the contact to \a str. 159 Sets the home mobile phone number of the contact to \a str.
160*/ 160*/
161 161
162/*! \fn void OContact::setHomeWebpage( const QString &str ) 162/*! \fn void OPimContact::setHomeWebpage( const QString &str )
163 Sets the home webpage of the contact to \a str. 163 Sets the home webpage of the contact to \a str.
164*/ 164*/
165 165
166/*! \fn void OContact::setCompany( const QString &str ) 166/*! \fn void OPimContact::setCompany( const QString &str )
167 Sets the company for contact to \a str. 167 Sets the company for contact to \a str.
168*/ 168*/
169 169
170/*! \fn void OContact::setJobTitle( const QString &str ) 170/*! \fn void OPimContact::setJobTitle( const QString &str )
171 Sets the job title of the contact to \a str. 171 Sets the job title of the contact to \a str.
172*/ 172*/
173 173
174/*! \fn void OContact::setDepartment( const QString &str ) 174/*! \fn void OPimContact::setDepartment( const QString &str )
175 Sets the department for contact to \a str. 175 Sets the department for contact to \a str.
176*/ 176*/
177 177
178/*! \fn void OContact::setOffice( const QString &str ) 178/*! \fn void OPimContact::setOffice( const QString &str )
179 Sets the office for contact to \a str. 179 Sets the office for contact to \a str.
180*/ 180*/
181 181
182/*! \fn void OContact::setBusinessStreet( const QString &str ) 182/*! \fn void OPimContact::setBusinessStreet( const QString &str )
183 Sets the business street address of the contact to \a str. 183 Sets the business street address of the contact to \a str.
184*/ 184*/
185 185
186/*! \fn void OContact::setBusinessCity( const QString &str ) 186/*! \fn void OPimContact::setBusinessCity( const QString &str )
187 Sets the business city of the contact to \a str. 187 Sets the business city of the contact to \a str.
188*/ 188*/
189 189
190/*! \fn void OContact::setBusinessState( const QString &str ) 190/*! \fn void OPimContact::setBusinessState( const QString &str )
191 Sets the business state of the contact to \a str. 191 Sets the business state of the contact to \a str.
192*/ 192*/
193 193
194/*! \fn void OContact::setBusinessZip( const QString &str ) 194/*! \fn void OPimContact::setBusinessZip( const QString &str )
195 Sets the business zip code of the contact to \a str. 195 Sets the business zip code of the contact to \a str.
196*/ 196*/
197 197
198/*! \fn void OContact::setBusinessCountry( const QString &str ) 198/*! \fn void OPimContact::setBusinessCountry( const QString &str )
199 Sets the business country of the contact to \a str. 199 Sets the business country of the contact to \a str.
200*/ 200*/
201 201
202/*! \fn void OContact::setBusinessPhone( const QString &str ) 202/*! \fn void OPimContact::setBusinessPhone( const QString &str )
203 Sets the business phone number of the contact to \a str. 203 Sets the business phone number of the contact to \a str.
204*/ 204*/
205 205
206/*! \fn void OContact::setBusinessFax( const QString &str ) 206/*! \fn void OPimContact::setBusinessFax( const QString &str )
207 Sets the business fax number of the contact to \a str. 207 Sets the business fax number of the contact to \a str.
208*/ 208*/
209 209
210/*! \fn void OContact::setBusinessMobile( const QString &str ) 210/*! \fn void OPimContact::setBusinessMobile( const QString &str )
211 Sets the business mobile phone number of the contact to \a str. 211 Sets the business mobile phone number of the contact to \a str.
212*/ 212*/
213 213
214/*! \fn void OContact::setBusinessPager( const QString &str ) 214/*! \fn void OPimContact::setBusinessPager( const QString &str )
215 Sets the business pager number of the contact to \a str. 215 Sets the business pager number of the contact to \a str.
216*/ 216*/
217 217
218/*! \fn void OContact::setBusinessWebpage( const QString &str ) 218/*! \fn void OPimContact::setBusinessWebpage( const QString &str )
219 Sets the business webpage of the contact to \a str. 219 Sets the business webpage of the contact to \a str.
220*/ 220*/
221 221
222/*! \fn void OContact::setProfession( const QString &str ) 222/*! \fn void OPimContact::setProfession( const QString &str )
223 Sets the profession of the contact to \a str. 223 Sets the profession of the contact to \a str.
224*/ 224*/
225 225
226/*! \fn void OContact::setAssistant( const QString &str ) 226/*! \fn void OPimContact::setAssistant( const QString &str )
227 Sets the assistant of the contact to \a str. 227 Sets the assistant of the contact to \a str.
228*/ 228*/
229 229
230/*! \fn void OContact::setManager( const QString &str ) 230/*! \fn void OPimContact::setManager( const QString &str )
231 Sets the manager of the contact to \a str. 231 Sets the manager of the contact to \a str.
232*/ 232*/
233 233
234/*! \fn void OContact::setSpouse( const QString &str ) 234/*! \fn void OPimContact::setSpouse( const QString &str )
235 Sets the spouse of the contact to \a str. 235 Sets the spouse of the contact to \a str.
236*/ 236*/
237 237
238/*! \fn void OContact::setGender( const QString &str ) 238/*! \fn void OPimContact::setGender( const QString &str )
239 Sets the gender of the contact to \a str. 239 Sets the gender of the contact to \a str.
240*/ 240*/
241 241
242/*! \fn void OContact::setNickname( const QString &str ) 242/*! \fn void OPimContact::setNickname( const QString &str )
243 Sets the nickname of the contact to \a str. 243 Sets the nickname of the contact to \a str.
244*/ 244*/
245 245
246/*! \fn void OContact::setNotes( const QString &str ) 246/*! \fn void OPimContact::setNotes( const QString &str )
247 Sets the notes about the contact to \a str. 247 Sets the notes about the contact to \a str.
248*/ 248*/
249 249
250/*! \fn QString OContact::title() const 250/*! \fn QString OPimContact::title() const
251 Returns the title of the contact. 251 Returns the title of the contact.
252*/ 252*/
253 253
254/*! \fn QString OContact::firstName() const 254/*! \fn QString OPimContact::firstName() const
255 Returns the first name of the contact. 255 Returns the first name of the contact.
256*/ 256*/
257 257
258/*! \fn QString OContact::middleName() const 258/*! \fn QString OPimContact::middleName() const
259 Returns the middle name of the contact. 259 Returns the middle name of the contact.
260*/ 260*/
261 261
262/*! \fn QString OContact::lastName() const 262/*! \fn QString OPimContact::lastName() const
263 Returns the last name of the contact. 263 Returns the last name of the contact.
264*/ 264*/
265 265
266/*! \fn QString OContact::suffix() const 266/*! \fn QString OPimContact::suffix() const
267 Returns the suffix of the contact. 267 Returns the suffix of the contact.
268*/ 268*/
269 269
270/*! \fn QString OContact::fileAs() const 270/*! \fn QString OPimContact::fileAs() const
271 Returns the string the contact is filed as. 271 Returns the string the contact is filed as.
272*/ 272*/
273 273
274/*! \fn QString OContact::defaultEmail() const 274/*! \fn QString OPimContact::defaultEmail() const
275 Returns the default email address of the contact. 275 Returns the default email address of the contact.
276*/ 276*/
277 277
278/*! \fn QString OContact::emails() const 278/*! \fn QString OPimContact::emails() const
279 Returns the list of email address for a contact separated by ';'s in a single 279 Returns the list of email address for a contact separated by ';'s in a single
280 string. 280 string.
281*/ 281*/
282 282
283/*! \fn QString OContact::homeStreet() const 283/*! \fn QString OPimContact::homeStreet() const
284 Returns the home street address of the contact. 284 Returns the home street address of the contact.
285*/ 285*/
286 286
287/*! \fn QString OContact::homeCity() const 287/*! \fn QString OPimContact::homeCity() const
288 Returns the home city of the contact. 288 Returns the home city of the contact.
289*/ 289*/
290 290
291/*! \fn QString OContact::homeState() const 291/*! \fn QString OPimContact::homeState() const
292 Returns the home state of the contact. 292 Returns the home state of the contact.
293*/ 293*/
294 294
295/*! \fn QString OContact::homeZip() const 295/*! \fn QString OPimContact::homeZip() const
296 Returns the home zip of the contact. 296 Returns the home zip of the contact.
297*/ 297*/
298 298
299/*! \fn QString OContact::homeCountry() const 299/*! \fn QString OPimContact::homeCountry() const
300 Returns the home country of the contact. 300 Returns the home country of the contact.
301*/ 301*/
302 302
303/*! \fn QString OContact::homePhone() const 303/*! \fn QString OPimContact::homePhone() const
304 Returns the home phone number of the contact. 304 Returns the home phone number of the contact.
305*/ 305*/
306 306
307/*! \fn QString OContact::homeFax() const 307/*! \fn QString OPimContact::homeFax() const
308 Returns the home fax number of the contact. 308 Returns the home fax number of the contact.
309*/ 309*/
310 310
311/*! \fn QString OContact::homeMobile() const 311/*! \fn QString OPimContact::homeMobile() const
312 Returns the home mobile number of the contact. 312 Returns the home mobile number of the contact.
313*/ 313*/
314 314
315/*! \fn QString OContact::homeWebpage() const 315/*! \fn QString OPimContact::homeWebpage() const
316 Returns the home webpage of the contact. 316 Returns the home webpage of the contact.
317*/ 317*/
318 318
319/*! \fn QString OContact::company() const 319/*! \fn QString OPimContact::company() const
320 Returns the company for the contact. 320 Returns the company for the contact.
321*/ 321*/
322 322
323/*! \fn QString OContact::department() const 323/*! \fn QString OPimContact::department() const
324 Returns the department for the contact. 324 Returns the department for the contact.
325*/ 325*/
326 326
327/*! \fn QString OContact::office() const 327/*! \fn QString OPimContact::office() const
328 Returns the office for the contact. 328 Returns the office for the contact.
329*/ 329*/
330 330
331/*! \fn QString OContact::jobTitle() const 331/*! \fn QString OPimContact::jobTitle() const
332 Returns the job title of the contact. 332 Returns the job title of the contact.
333*/ 333*/
334 334
335/*! \fn QString OContact::profession() const 335/*! \fn QString OPimContact::profession() const
336 Returns the profession of the contact. 336 Returns the profession of the contact.
337*/ 337*/
338 338
339/*! \fn QString OContact::assistant() const 339/*! \fn QString OPimContact::assistant() const
340 Returns the assistant of the contact. 340 Returns the assistant of the contact.
341*/ 341*/
342 342
343/*! \fn QString OContact::manager() const 343/*! \fn QString OPimContact::manager() const
344 Returns the manager of the contact. 344 Returns the manager of the contact.
345*/ 345*/
346 346
347/*! \fn QString OContact::businessStreet() const 347/*! \fn QString OPimContact::businessStreet() const
348 Returns the business street address of the contact. 348 Returns the business street address of the contact.
349*/ 349*/
350 350
351/*! \fn QString OContact::businessCity() const 351/*! \fn QString OPimContact::businessCity() const
352 Returns the business city of the contact. 352 Returns the business city of the contact.
353*/ 353*/
354 354
355/*! \fn QString OContact::businessState() const 355/*! \fn QString OPimContact::businessState() const
356 Returns the business state of the contact. 356 Returns the business state of the contact.
357*/ 357*/
358 358
359/*! \fn QString OContact::businessZip() const 359/*! \fn QString OPimContact::businessZip() const
360 Returns the business zip of the contact. 360 Returns the business zip of the contact.
361*/ 361*/
362 362
363/*! \fn QString OContact::businessCountry() const 363/*! \fn QString OPimContact::businessCountry() const
364 Returns the business country of the contact. 364 Returns the business country of the contact.
365*/ 365*/
366 366
367/*! \fn QString OContact::businessPhone() const 367/*! \fn QString OPimContact::businessPhone() const
368 Returns the business phone number of the contact. 368 Returns the business phone number of the contact.
369*/ 369*/
370 370
371/*! \fn QString OContact::businessFax() const 371/*! \fn QString OPimContact::businessFax() const
372 Returns the business fax number of the contact. 372 Returns the business fax number of the contact.
373*/ 373*/
374 374
375/*! \fn QString OContact::businessMobile() const 375/*! \fn QString OPimContact::businessMobile() const
376 Returns the business mobile number of the contact. 376 Returns the business mobile number of the contact.
377*/ 377*/
378 378
379/*! \fn QString OContact::businessPager() const 379/*! \fn QString OPimContact::businessPager() const
380 Returns the business pager number of the contact. 380 Returns the business pager number of the contact.
381*/ 381*/
382 382
383/*! \fn QString OContact::businessWebpage() const 383/*! \fn QString OPimContact::businessWebpage() const
384 Returns the business webpage of the contact. 384 Returns the business webpage of the contact.
385*/ 385*/
386 386
387/*! \fn QString OContact::spouse() const 387/*! \fn QString OPimContact::spouse() const
388 Returns the spouse of the contact. 388 Returns the spouse of the contact.
389*/ 389*/
390 390
391/*! \fn QString OContact::gender() const 391/*! \fn QString OPimContact::gender() const
392 Returns the gender of the contact. 392 Returns the gender of the contact.
393*/ 393*/
394 394
395/*! \fn QString OContact::nickname() const 395/*! \fn QString OPimContact::nickname() const
396 Returns the nickname of the contact. 396 Returns the nickname of the contact.
397*/ 397*/
398 398
399/*! \fn QString OContact::children() const 399/*! \fn QString OPimContact::children() const
400 Returns the children of the contact. 400 Returns the children of the contact.
401*/ 401*/
402 402
403/*! \fn QString OContact::notes() const 403/*! \fn QString OPimContact::notes() const
404 Returns the notes relating to the the contact. 404 Returns the notes relating to the the contact.
405*/ 405*/
406 406
407/*! \fn QString OContact::groups() const 407/*! \fn QString OPimContact::groups() const
408 \internal 408 \internal
409 Returns the groups for the contact. 409 Returns the groups for the contact.
410*/ 410*/
411 411
412/*! \fn QStringList OContact::groupList() const 412/*! \fn QStringList OPimContact::groupList() const
413 \internal 413 \internal
414*/ 414*/
415 415
416/*! \fn QString OContact::field(int) const 416/*! \fn QString OPimContact::field(int) const
417 \internal 417 \internal
418*/ 418*/
419 419
420/*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) 420/*! \fn void OPimContact::saveJournal( journal_action, const QString & = QString::null )
421 \internal 421 \internal
422*/ 422*/
423 423
424/*! \fn void OContact::setUid( int id ) 424/*! \fn void OPimContact::setUid( int id )
425 \internal 425 \internal
426 Sets the uid for this record to \a id. 426 Sets the uid for this record to \a id.
427*/ 427*/
428 428
429/*! \enum OContact::journal_action 429/*! \enum OPimContact::journal_action
430 \internal 430 \internal
431*/ 431*/
432 432
433/*! 433/*!
434 \internal 434 \internal
435*/ 435*/
436QMap<int, QString> OContact::toMap() const 436QMap<int, QString> OPimContact::toMap() const
437{ 437{
438 QMap<int, QString> map = mMap; 438 QMap<int, QString> map = mMap;
439 QString cats = idsToString( categories() ); 439 QString cats = idsToString( categories() );
440 if ( !cats.isEmpty() ) 440 if ( !cats.isEmpty() )
441 map.insert( Qtopia::AddressCategory, cats ); 441 map.insert( Qtopia::AddressCategory, cats );
442 return map; 442 return map;
443} 443}
444 444
445/*! 445/*!
446 Returns a rich text formatted QString representing the contents the contact. 446 Returns a rich text formatted QString representing the contents the contact.
447*/ 447*/
448QString OContact::toRichText() const 448QString OPimContact::toRichText() const
449{ 449{
450 QString text; 450 QString text;
451 QString value, comp, state; 451 QString value, comp, state;
452 QString str; 452 QString str;
453 bool marker = false; 453 bool marker = false;
454 454
455 Config cfg( "qpe" ); 455 Config cfg( "qpe" );
456 cfg.setGroup( "Appearance" ); 456 cfg.setGroup( "Appearance" );
457 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); 457 int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State );
458 458
459 // name, jobtitle and company 459 // name, jobtitle and company
460 if ( !( value = fullName() ).isEmpty() ) 460 if ( !( value = fullName() ).isEmpty() )
461 text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>"; 461 text += "<b><h3><img src=\"addressbook/AddressBook\"> " + Qtopia::escapeString( value ) + "</h3></b>";
462 462
463 if ( !( value = jobTitle() ).isEmpty() ) 463 if ( !( value = jobTitle() ).isEmpty() )
464 text += Qtopia::escapeString( value ) + " "; 464 text += Qtopia::escapeString( value ) + " ";
465 465
466 comp = company(); 466 comp = company();
467 if ( !( value = department() ).isEmpty() ) 467 if ( !( value = department() ).isEmpty() )
468 { 468 {
469 text += Qtopia::escapeString( value ); 469 text += Qtopia::escapeString( value );
470 if ( comp ) 470 if ( comp )
471 text += ", " + Qtopia::escapeString( comp ); 471 text += ", " + Qtopia::escapeString( comp );
472 } 472 }
473 else if ( comp ) 473 else if ( comp )
474 text += "<br>" + Qtopia::escapeString( comp ); 474 text += "<br>" + Qtopia::escapeString( comp );
475 text += "<br><hr>"; 475 text += "<br><hr>";
476 476
477 // defailt email 477 // defailt email
478 QString defEmail = defaultEmail(); 478 QString defEmail = defaultEmail();
479 if ( !defEmail.isEmpty() ) 479 if ( !defEmail.isEmpty() )
480 { 480 {
481 text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>" 481 text += "<b><img src=\"addressbook/email\"> " + QObject::tr( "Default Email: " ) + "</b>"
482 + Qtopia::escapeString( defEmail ); 482 + Qtopia::escapeString( defEmail );
483 marker = true; 483 marker = true;
484 } 484 }
485 485
486 // business address 486 // business address
487 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || 487 if ( !businessStreet().isEmpty() || !businessCity().isEmpty() ||
488 !businessZip().isEmpty() || !businessCountry().isEmpty() ) 488 !businessZip().isEmpty() || !businessCountry().isEmpty() )
489 { 489 {
490 text += QObject::tr( "<br><b>Work Address:</b>" ); 490 text += QObject::tr( "<br><b>Work Address:</b>" );
491 marker = true; 491 marker = true;
492 } 492 }
493 493
494 if ( !( value = businessStreet() ).isEmpty() ) 494 if ( !( value = businessStreet() ).isEmpty() )
495 { 495 {
496 text += "<br>" + Qtopia::escapeString( value ); 496 text += "<br>" + Qtopia::escapeString( value );
497 marker = true; 497 marker = true;
498 } 498 }
499 499
500 switch ( addressformat ) 500 switch ( addressformat )
501 { 501 {
502 case Zip_City_State: 502 case Zip_City_State:
503 { // Zip_Code City, State 503 { // Zip_Code City, State
504 state = businessState(); 504 state = businessState();
505 if ( !( value = businessZip() ).isEmpty() ) 505 if ( !( value = businessZip() ).isEmpty() )
506 { 506 {
507 text += "<br>" + Qtopia::escapeString( value ) + " "; 507 text += "<br>" + Qtopia::escapeString( value ) + " ";
508 marker = true; 508 marker = true;
509 509
510 } 510 }
511 if ( !( value = businessCity() ).isEmpty() ) 511 if ( !( value = businessCity() ).isEmpty() )
512 { 512 {
513 marker = true; 513 marker = true;
514 if ( businessZip().isEmpty() && !businessStreet().isEmpty() ) 514 if ( businessZip().isEmpty() && !businessStreet().isEmpty() )
515 text += "<br>"; 515 text += "<br>";
516 text += Qtopia::escapeString( value ); 516 text += Qtopia::escapeString( value );
517 if ( state ) 517 if ( state )
518 text += ", " + Qtopia::escapeString( state ); 518 text += ", " + Qtopia::escapeString( state );
519 } 519 }
520 else if ( !state.isEmpty() ) 520 else if ( !state.isEmpty() )
521 { 521 {
522 text += "<br>" + Qtopia::escapeString( state ); 522 text += "<br>" + Qtopia::escapeString( state );
523 marker = true; 523 marker = true;
524 } 524 }
525 break; 525 break;
526 } 526 }
527 case City_State_Zip: 527 case City_State_Zip:
528 { // City, State Zip_Code 528 { // City, State Zip_Code
529 state = businessState(); 529 state = businessState();
530 if ( !( value = businessCity() ).isEmpty() ) 530 if ( !( value = businessCity() ).isEmpty() )
531 { 531 {
532 marker = true; 532 marker = true;
533 text += "<br>" + Qtopia::escapeString( value ); 533 text += "<br>" + Qtopia::escapeString( value );
534 if ( state ) 534 if ( state )
535 text += ", " + Qtopia::escapeString( state ); 535 text += ", " + Qtopia::escapeString( state );
536 } 536 }
537 else if ( !state.isEmpty() ) 537 else if ( !state.isEmpty() )
538 { 538 {
539 text += "<br>" + Qtopia::escapeString( state ); 539 text += "<br>" + Qtopia::escapeString( state );
540 marker = true; 540 marker = true;
541 } 541 }
542 if ( !( value = businessZip() ).isEmpty() ) 542 if ( !( value = businessZip() ).isEmpty() )
543 { 543 {
544 text += " " + Qtopia::escapeString( value ); 544 text += " " + Qtopia::escapeString( value );
545 marker = true; 545 marker = true;
546 } 546 }
547 break; 547 break;
548 } 548 }
549 } 549 }
550 550
551 if ( !( value = businessCountry() ).isEmpty() ) 551 if ( !( value = businessCountry() ).isEmpty() )
552 { 552 {
553 text += "<br>" + Qtopia::escapeString( value ); 553 text += "<br>" + Qtopia::escapeString( value );
554 marker = true; 554 marker = true;
555 } 555 }
556 556
557 // rest of Business data 557 // rest of Business data
558 str = office(); 558 str = office();
559 if ( !str.isEmpty() ) 559 if ( !str.isEmpty() )
560 { 560 {
561 text += "<br><b>" + QObject::tr( "Office: " ) + "</b>" 561 text += "<br><b>" + QObject::tr( "Office: " ) + "</b>"
562 + Qtopia::escapeString( str ); 562 + Qtopia::escapeString( str );
563 marker = true; 563 marker = true;
564 } 564 }
565 str = businessWebpage(); 565 str = businessWebpage();
566 if ( !str.isEmpty() ) 566 if ( !str.isEmpty() )
567 { 567 {
568 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>" 568 text += "<br><b><img src=\"addressbook/webpagework\"> " + QObject::tr( "Business Web Page: " ) + "</b>"
569 + Qtopia::escapeString( str ); 569 + Qtopia::escapeString( str );
570 marker = true; 570 marker = true;
571 } 571 }
572 str = businessPhone(); 572 str = businessPhone();
573 if ( !str.isEmpty() ) 573 if ( !str.isEmpty() )
574 { 574 {
575 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>" 575 text += "<br><b><img src=\"addressbook/phonework\"> " + QObject::tr( "Business Phone: " ) + "</b>"
576 + Qtopia::escapeString( str ); 576 + Qtopia::escapeString( str );
577 marker = true; 577 marker = true;
578 } 578 }
579 str = businessFax(); 579 str = businessFax();
580 if ( !str.isEmpty() ) 580 if ( !str.isEmpty() )
581 { 581 {
582 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>" 582 text += "<br><b><img src=\"addressbook/faxwork\"> " + QObject::tr( "Business Fax: " ) + "</b>"
583 + Qtopia::escapeString( str ); 583 + Qtopia::escapeString( str );
584 marker = true; 584 marker = true;
585 } 585 }
586 str = businessMobile(); 586 str = businessMobile();
587 if ( !str.isEmpty() ) 587 if ( !str.isEmpty() )
588 { 588 {
589 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>" 589 text += "<br><b><img src=\"addressbook/mobilework\"> " + QObject::tr( "Business Mobile: " ) + "</b>"
590 + Qtopia::escapeString( str ); 590 + Qtopia::escapeString( str );
591 marker = true; 591 marker = true;
592 } 592 }
593 str = businessPager(); 593 str = businessPager();
594 if ( !str.isEmpty() ) 594 if ( !str.isEmpty() )
595 { 595 {
596 text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>" 596 text += "<br><b>" + QObject::tr( "Business Pager: " ) + "</b>"
597 + Qtopia::escapeString( str ); 597 + Qtopia::escapeString( str );
598 marker = true; 598 marker = true;
599 } 599 }
600 600
601 // text += "<br>"; 601 // text += "<br>";
602 602
603 // home address 603 // home address
604 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || 604 if ( !homeStreet().isEmpty() || !homeCity().isEmpty() ||
605 !homeZip().isEmpty() || !homeCountry().isEmpty() ) 605 !homeZip().isEmpty() || !homeCountry().isEmpty() )
606 { 606 {
607 text += QObject::tr( "<br><b>Home Address:</b>" ); 607 text += QObject::tr( "<br><b>Home Address:</b>" );
608 marker = true; 608 marker = true;
609 } 609 }
610 610
611 if ( !( value = homeStreet() ).isEmpty() ) 611 if ( !( value = homeStreet() ).isEmpty() )
612 { 612 {
613 text += "<br>" + Qtopia::escapeString( value ); 613 text += "<br>" + Qtopia::escapeString( value );
614 marker = true; 614 marker = true;
615 } 615 }
616 616
617 switch ( addressformat ) 617 switch ( addressformat )
618 { 618 {
619 case Zip_City_State: 619 case Zip_City_State:
620 { // Zip_Code City, State 620 { // Zip_Code City, State
621 state = homeState(); 621 state = homeState();
622 if ( !( value = homeZip() ).isEmpty() ) 622 if ( !( value = homeZip() ).isEmpty() )
623 { 623 {
624 text += "<br>" + Qtopia::escapeString( value ) + " "; 624 text += "<br>" + Qtopia::escapeString( value ) + " ";
625 marker = true; 625 marker = true;
626 } 626 }
627 if ( !( value = homeCity() ).isEmpty() ) 627 if ( !( value = homeCity() ).isEmpty() )
628 { 628 {
629 marker = true; 629 marker = true;
630 if ( homeZip().isEmpty() && !homeStreet().isEmpty() ) 630 if ( homeZip().isEmpty() && !homeStreet().isEmpty() )
631 text += "<br>"; 631 text += "<br>";
632 text += Qtopia::escapeString( value ); 632 text += Qtopia::escapeString( value );
633 if ( !state.isEmpty() ) 633 if ( !state.isEmpty() )
634 text += ", " + Qtopia::escapeString( state ); 634 text += ", " + Qtopia::escapeString( state );
635 } 635 }
636 else if ( !state.isEmpty() ) 636 else if ( !state.isEmpty() )
637 { 637 {
638 text += "<br>" + Qtopia::escapeString( state ); 638 text += "<br>" + Qtopia::escapeString( state );
639 marker = true; 639 marker = true;
640 } 640 }
641 break; 641 break;
642 } 642 }
643 case City_State_Zip: 643 case City_State_Zip:
644 { // City, State Zip_Code 644 { // City, State Zip_Code
645 state = homeState(); 645 state = homeState();
646 if ( !( value = homeCity() ).isEmpty() ) 646 if ( !( value = homeCity() ).isEmpty() )
647 { 647 {
648 marker = true; 648 marker = true;
649 text += "<br>" + Qtopia::escapeString( value ); 649 text += "<br>" + Qtopia::escapeString( value );
650 if ( state ) 650 if ( state )
651 text += ", " + Qtopia::escapeString( state ); 651 text += ", " + Qtopia::escapeString( state );
652 } 652 }
653 else if ( !state.isEmpty() ) 653 else if ( !state.isEmpty() )
654 { 654 {
655 text += "<br>" + Qtopia::escapeString( state ); 655 text += "<br>" + Qtopia::escapeString( state );
656 marker = true; 656 marker = true;
657 } 657 }
658 if ( !( value = homeZip() ).isEmpty() ) 658 if ( !( value = homeZip() ).isEmpty() )
659 { 659 {
660 text += " " + Qtopia::escapeString( value ); 660 text += " " + Qtopia::escapeString( value );
661 marker = true; 661 marker = true;
662 } 662 }
663 break; 663 break;
664 } 664 }
665 } 665 }
666 666
667 if ( !( value = homeCountry() ).isEmpty() ) 667 if ( !( value = homeCountry() ).isEmpty() )
668 { 668 {
669 text += "<br>" + Qtopia::escapeString( value ); 669 text += "<br>" + Qtopia::escapeString( value );
670 marker = true; 670 marker = true;
671 } 671 }
672 672
673 // rest of Home data 673 // rest of Home data
674 str = homeWebpage(); 674 str = homeWebpage();
675 if ( !str.isEmpty() ) 675 if ( !str.isEmpty() )
676 { 676 {
677 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>" 677 text += "<br><b><img src=\"addressbook/webpagehome\"> " + QObject::tr( "Home Web Page: " ) + "</b>"
678 + Qtopia::escapeString( str ); 678 + Qtopia::escapeString( str );
679 marker = true; 679 marker = true;
680 } 680 }
681 str = homePhone(); 681 str = homePhone();
682 if ( !str.isEmpty() ) 682 if ( !str.isEmpty() )
683 { 683 {
684 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>" 684 text += "<br><b><img src=\"addressbook/phonehome\"> " + QObject::tr( "Home Phone: " ) + "</b>"
685 + Qtopia::escapeString( str ); 685 + Qtopia::escapeString( str );
686 marker = true; 686 marker = true;
687 } 687 }
688 str = homeFax(); 688 str = homeFax();
689 if ( !str.isEmpty() ) 689 if ( !str.isEmpty() )
690 { 690 {
691 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>" 691 text += "<br><b><img src=\"addressbook/faxhome\"> " + QObject::tr( "Home Fax: " ) + "</b>"
692 + Qtopia::escapeString( str ); 692 + Qtopia::escapeString( str );
693 marker = true; 693 marker = true;
694 } 694 }
695 str = homeMobile(); 695 str = homeMobile();
696 if ( !str.isEmpty() ) 696 if ( !str.isEmpty() )
697 { 697 {
698 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>" 698 text += "<br><b><img src=\"addressbook/mobilehome\"> " + QObject::tr( "Home Mobile: " ) + "</b>"
699 + Qtopia::escapeString( str ); 699 + Qtopia::escapeString( str );
700 marker = true; 700 marker = true;
701 } 701 }
702 702
703 if ( marker ) 703 if ( marker )
704 text += "<br><hr>"; 704 text += "<br><hr>";
705 705
706 // the rest... 706 // the rest...
707 str = emails(); 707 str = emails();
708 if ( !str.isEmpty() && ( str != defEmail ) ) 708 if ( !str.isEmpty() && ( str != defEmail ) )
709 text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>" 709 text += "<br><b>" + QObject::tr( "All Emails: " ) + "</b>"
710 + Qtopia::escapeString( str ); 710 + Qtopia::escapeString( str );
711 str = profession(); 711 str = profession();
712 if ( !str.isEmpty() ) 712 if ( !str.isEmpty() )
713 text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>" 713 text += "<br><b>" + QObject::tr( "Profession: " ) + "</b>"
714 + Qtopia::escapeString( str ); 714 + Qtopia::escapeString( str );
715 str = assistant(); 715 str = assistant();
716 if ( !str.isEmpty() ) 716 if ( !str.isEmpty() )
717 text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>" 717 text += "<br><b>" + QObject::tr( "Assistant: " ) + "</b>"
718 + Qtopia::escapeString( str ); 718 + Qtopia::escapeString( str );
719 str = manager(); 719 str = manager();
720 if ( !str.isEmpty() ) 720 if ( !str.isEmpty() )
721 text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>" 721 text += "<br><b>" + QObject::tr( "Manager: " ) + "</b>"
722 + Qtopia::escapeString( str ); 722 + Qtopia::escapeString( str );
723 str = gender(); 723 str = gender();
724 if ( !str.isEmpty() && str.toInt() != 0 ) 724 if ( !str.isEmpty() && str.toInt() != 0 )
725 { 725 {
726 text += "<br>"; 726 text += "<br>";
727 if ( str.toInt() == 1 ) 727 if ( str.toInt() == 1 )
728 str = QObject::tr( "Male" ); 728 str = QObject::tr( "Male" );
729 else if ( str.toInt() == 2 ) 729 else if ( str.toInt() == 2 )
730 str = QObject::tr( "Female" ); 730 str = QObject::tr( "Female" );
731 text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str; 731 text += "<b>" + QObject::tr( "Gender: " ) + "</b>" + str;
732 } 732 }
733 str = spouse(); 733 str = spouse();
734 if ( !str.isEmpty() ) 734 if ( !str.isEmpty() )
735 text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>" 735 text += "<br><b>" + QObject::tr( "Spouse: " ) + "</b>"
736 + Qtopia::escapeString( str ); 736 + Qtopia::escapeString( str );
737 if ( birthday().isValid() ) 737 if ( birthday().isValid() )
738 { 738 {
739 str = TimeString::numberDateString( birthday() ); 739 str = TimeString::numberDateString( birthday() );
740 text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>" 740 text += "<br><b>" + QObject::tr( "Birthday: " ) + "</b>"
741 + Qtopia::escapeString( str ); 741 + Qtopia::escapeString( str );
742 } 742 }
743 if ( anniversary().isValid() ) 743 if ( anniversary().isValid() )
744 { 744 {
745 str = TimeString::numberDateString( anniversary() ); 745 str = TimeString::numberDateString( anniversary() );
746 text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>" 746 text += "<br><b>" + QObject::tr( "Anniversary: " ) + "</b>"
747 + Qtopia::escapeString( str ); 747 + Qtopia::escapeString( str );
748 } 748 }
749 str = children(); 749 str = children();
750 if ( !str.isEmpty() ) 750 if ( !str.isEmpty() )
751 text += "<br><b>" + QObject::tr( "Children: " ) + "</b>" 751 text += "<br><b>" + QObject::tr( "Children: " ) + "</b>"
752 + Qtopia::escapeString( str ); 752 + Qtopia::escapeString( str );
753 753
754 str = nickname(); 754 str = nickname();
755 if ( !str.isEmpty() ) 755 if ( !str.isEmpty() )
756 text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>" 756 text += "<br><b>" + QObject::tr( "Nickname: " ) + "</b>"
757 + Qtopia::escapeString( str ); 757 + Qtopia::escapeString( str );
758 758
759 // categories 759 // categories
760 if ( categoryNames( "Contacts" ).count() ) 760 if ( categoryNames( "Contacts" ).count() )
761 { 761 {
762 text += "<br><b>" + QObject::tr( "Category:" ) + "</b> "; 762 text += "<br><b>" + QObject::tr( "Category:" ) + "</b> ";
763 text += categoryNames( "Contacts" ).join( ", " ); 763 text += categoryNames( "Contacts" ).join( ", " );
764 } 764 }
765 765
766 // notes last 766 // notes last
767 if ( !( value = notes() ).isEmpty() ) 767 if ( !( value = notes() ).isEmpty() )
768 { 768 {
769 text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> "; 769 text += "<br><hr><b>" + QObject::tr( "Notes:" ) + "</b> ";
770 QRegExp reg( "\n" ); 770 QRegExp reg( "\n" );
771 771
772 //QString tmp = Qtopia::escapeString(value); 772 //QString tmp = Qtopia::escapeString(value);
773 QString tmp = QStyleSheet::convertFromPlainText( value ); 773 QString tmp = QStyleSheet::convertFromPlainText( value );
774 //tmp.replace( reg, "<br>" ); 774 //tmp.replace( reg, "<br>" );
775 text += "<br>" + tmp + "<br>"; 775 text += "<br>" + tmp + "<br>";
776 } 776 }
777 return text; 777 return text;
778} 778}
779 779
780/*! 780/*!
781 \internal 781 \internal
782*/ 782*/
783void OContact::insert( int key, const QString &v ) 783void OPimContact::insert( int key, const QString &v )
784{ 784{
785 QString value = v.stripWhiteSpace(); 785 QString value = v.stripWhiteSpace();
786 if ( value.isEmpty() ) 786 if ( value.isEmpty() )
787 mMap.remove( key ); 787 mMap.remove( key );
788 else 788 else
789 mMap.insert( key, value ); 789 mMap.insert( key, value );
790} 790}
791 791
792/*! 792/*!
793 \internal 793 \internal
794*/ 794*/
795void OContact::replace( int key, const QString & v ) 795void OPimContact::replace( int key, const QString & v )
796{ 796{
797 QString value = v.stripWhiteSpace(); 797 QString value = v.stripWhiteSpace();
798 if ( value.isEmpty() ) 798 if ( value.isEmpty() )
799 mMap.remove( key ); 799 mMap.remove( key );
800 else 800 else
801 mMap.replace( key, value ); 801 mMap.replace( key, value );
802} 802}
803 803
804/*! 804/*!
805 \internal 805 \internal
806*/ 806*/
807QString OContact::find( int key ) const 807QString OPimContact::find( int key ) const
808{ 808{
809 return mMap[ key ]; 809 return mMap[ key ];
810} 810}
811 811
812/*! 812/*!
813 \internal 813 \internal
814*/ 814*/
815QString OContact::displayAddress( const QString &street, 815QString OPimContact::displayAddress( const QString &street,
816 const QString &city, 816 const QString &city,
817 const QString &state, 817 const QString &state,
818 const QString &zip, 818 const QString &zip,
819 const QString &country ) const 819 const QString &country ) const
820{ 820{
821 QString s = street; 821 QString s = street;
822 if ( !street.isEmpty() ) 822 if ( !street.isEmpty() )
823 s += "\n"; 823 s += "\n";
824 s += city; 824 s += city;
825 if ( !city.isEmpty() && !state.isEmpty() ) 825 if ( !city.isEmpty() && !state.isEmpty() )
826 s += ", "; 826 s += ", ";
827 s += state; 827 s += state;
828 if ( !state.isEmpty() && !zip.isEmpty() ) 828 if ( !state.isEmpty() && !zip.isEmpty() )
829 s += " "; 829 s += " ";
830 s += zip; 830 s += zip;
831 if ( !country.isEmpty() && !s.isEmpty() ) 831 if ( !country.isEmpty() && !s.isEmpty() )
832 s += "\n"; 832 s += "\n";
833 s += country; 833 s += country;
834 return s; 834 return s;
835} 835}
836 836
837/*! 837/*!
838 \internal 838 \internal
839*/ 839*/
840QString OContact::displayBusinessAddress() const 840QString OPimContact::displayBusinessAddress() const
841{ 841{
842 return displayAddress( businessStreet(), businessCity(), 842 return displayAddress( businessStreet(), businessCity(),
843 businessState(), businessZip(), 843 businessState(), businessZip(),
844 businessCountry() ); 844 businessCountry() );
845} 845}
846 846
847/*! 847/*!
848 \internal 848 \internal
849*/ 849*/
850QString OContact::displayHomeAddress() const 850QString OPimContact::displayHomeAddress() const
851{ 851{
852 return displayAddress( homeStreet(), homeCity(), 852 return displayAddress( homeStreet(), homeCity(),
853 homeState(), homeZip(), 853 homeState(), homeZip(),
854 homeCountry() ); 854 homeCountry() );
855} 855}
856 856
857/*! 857/*!
858 Returns the full name of the contact 858 Returns the full name of the contact
859*/ 859*/
860QString OContact::fullName() const 860QString OPimContact::fullName() const
861{ 861{
862 QString title = find( Qtopia::Title ); 862 QString title = find( Qtopia::Title );
863 QString firstName = find( Qtopia::FirstName ); 863 QString firstName = find( Qtopia::FirstName );
864 QString middleName = find( Qtopia::MiddleName ); 864 QString middleName = find( Qtopia::MiddleName );
865 QString lastName = find( Qtopia::LastName ); 865 QString lastName = find( Qtopia::LastName );
866 QString suffix = find( Qtopia::Suffix ); 866 QString suffix = find( Qtopia::Suffix );
867 867
868 QString name = title; 868 QString name = title;
869 if ( !firstName.isEmpty() ) 869 if ( !firstName.isEmpty() )
870 { 870 {
871 if ( !name.isEmpty() ) 871 if ( !name.isEmpty() )
872 name += " "; 872 name += " ";
873 name += firstName; 873 name += firstName;
874 } 874 }
875 if ( !middleName.isEmpty() ) 875 if ( !middleName.isEmpty() )
876 { 876 {
877 if ( !name.isEmpty() ) 877 if ( !name.isEmpty() )
878 name += " "; 878 name += " ";
879 name += middleName; 879 name += middleName;
880 } 880 }
881 if ( !lastName.isEmpty() ) 881 if ( !lastName.isEmpty() )
882 { 882 {
883 if ( !name.isEmpty() ) 883 if ( !name.isEmpty() )
884 name += " "; 884 name += " ";
885 name += lastName; 885 name += lastName;
886 } 886 }
887 if ( !suffix.isEmpty() ) 887 if ( !suffix.isEmpty() )
888 { 888 {
889 if ( !name.isEmpty() ) 889 if ( !name.isEmpty() )
890 name += " "; 890 name += " ";
891 name += suffix; 891 name += suffix;
892 } 892 }
893 return name.simplifyWhiteSpace(); 893 return name.simplifyWhiteSpace();
894} 894}
895 895
896/*! 896/*!
897 Returns a list of the names of the children of the contact. 897 Returns a list of the names of the children of the contact.
898*/ 898*/
899QStringList OContact::childrenList() const 899QStringList OPimContact::childrenList() const
900{ 900{
901 return QStringList::split( " ", find( Qtopia::Children ) ); 901 return QStringList::split( " ", find( Qtopia::Children ) );
902} 902}
903 903
904/*! \fn void OContact::insertEmail( const QString &email ) 904/*! \fn void OPimContact::insertEmail( const QString &email )
905 905
906 Insert \a email into the email list. Ensures \a email can only be added 906 Insert \a email into the email list. Ensures \a email can only be added
907 once. If there is no default email address set, it sets it to the \a email. 907 once. If there is no default email address set, it sets it to the \a email.
908*/ 908*/
909 909
910/*! \fn void OContact::removeEmail( const QString &email ) 910/*! \fn void OPimContact::removeEmail( const QString &email )
911 911
912 Removes the \a email from the email list. If the default email was \a email, 912 Removes the \a email from the email list. If the default email was \a email,
913 then the default email address is assigned to the first email in the 913 then the default email address is assigned to the first email in the
914 email list 914 email list
915*/ 915*/
916 916
917/*! \fn void OContact::clearEmails() 917/*! \fn void OPimContact::clearEmails()
918 918
919 Clears the email list. 919 Clears the email list.
920 */ 920 */
921 921
922/*! \fn void OContact::insertEmails( const QStringList &emailList ) 922/*! \fn void OPimContact::insertEmails( const QStringList &emailList )
923 923
924 Appends the \a emailList to the exiting email list 924 Appends the \a emailList to the exiting email list
925 */ 925 */
926 926
927/*! 927/*!
928 Returns a list of email addresses belonging to the contact, including 928 Returns a list of email addresses belonging to the contact, including
929 the default email address. 929 the default email address.
930*/ 930*/
931QStringList OContact::emailList() const 931QStringList OPimContact::emailList() const
932{ 932{
933 QString emailStr = emails(); 933 QString emailStr = emails();
934 934
935 QStringList r; 935 QStringList r;
936 if ( !emailStr.isEmpty() ) 936 if ( !emailStr.isEmpty() )
937 { 937 {
938 qDebug( " emailstr " ); 938 qDebug( " emailstr " );
939 QStringList l = QStringList::split( emailSeparator(), emailStr ); 939 QStringList l = QStringList::split( emailSeparator(), emailStr );
940 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 940 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
941 r += ( *it ).simplifyWhiteSpace(); 941 r += ( *it ).simplifyWhiteSpace();
942 } 942 }
943 943
944 return r; 944 return r;
945} 945}
946 946
947/*! 947/*!
948 \overload 948 \overload
949 949
950 Generates the string for the contact to be filed as from the first, 950 Generates the string for the contact to be filed as from the first,
951 middle and last name of the contact. 951 middle and last name of the contact.
952*/ 952*/
953void OContact::setFileAs() 953void OPimContact::setFileAs()
954{ 954{
955 QString lastName, firstName, middleName, fileas; 955 QString lastName, firstName, middleName, fileas;
956 956
957 lastName = find( Qtopia::LastName ); 957 lastName = find( Qtopia::LastName );
958 firstName = find( Qtopia::FirstName ); 958 firstName = find( Qtopia::FirstName );
959 middleName = find( Qtopia::MiddleName ); 959 middleName = find( Qtopia::MiddleName );
960 if ( !lastName.isEmpty() && !firstName.isEmpty() 960 if ( !lastName.isEmpty() && !firstName.isEmpty()
961 && !middleName.isEmpty() ) 961 && !middleName.isEmpty() )
962 fileas = lastName + ", " + firstName + " " + middleName; 962 fileas = lastName + ", " + firstName + " " + middleName;
963 else if ( !lastName.isEmpty() && !firstName.isEmpty() ) 963 else if ( !lastName.isEmpty() && !firstName.isEmpty() )
964 fileas = lastName + ", " + firstName; 964 fileas = lastName + ", " + firstName;
965 else if ( !lastName.isEmpty() || !firstName.isEmpty() || 965 else if ( !lastName.isEmpty() || !firstName.isEmpty() ||
966 !middleName.isEmpty() ) 966 !middleName.isEmpty() )
967 fileas = firstName + ( firstName.isEmpty() ? "" : " " ) 967 fileas = firstName + ( firstName.isEmpty() ? "" : " " )
968 + middleName + ( middleName.isEmpty() ? "" : " " ) 968 + middleName + ( middleName.isEmpty() ? "" : " " )
969 + lastName; 969 + lastName;
970 970
971 replace( Qtopia::FileAs, fileas ); 971 replace( Qtopia::FileAs, fileas );
972} 972}
973 973
974/*! 974/*!
975 \internal 975 \internal
976 Appends the contact information to \a buf. 976 Appends the contact information to \a buf.
977*/ 977*/
978void OContact::save( QString &buf ) const 978void OPimContact::save( QString &buf ) const
979{ 979{
980 static const QStringList SLFIELDS = fields(); 980 static const QStringList SLFIELDS = fields();
981 // I'm expecting "<Contact " in front of this... 981 // I'm expecting "<Contact " in front of this...
982 for ( QMap<int, QString>::ConstIterator it = mMap.begin(); 982 for ( QMap<int, QString>::ConstIterator it = mMap.begin();
983 it != mMap.end(); ++it ) 983 it != mMap.end(); ++it )
984 { 984 {
985 const QString &value = it.data(); 985 const QString &value = it.data();
986 int key = it.key(); 986 int key = it.key();
987 if ( !value.isEmpty() ) 987 if ( !value.isEmpty() )
988 { 988 {
989 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid ) 989 if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid )
990 continue; 990 continue;
991 991
992 key -= Qtopia::AddressCategory + 1; 992 key -= Qtopia::AddressCategory + 1;
993 buf += SLFIELDS[ key ]; 993 buf += SLFIELDS[ key ];
994 buf += "=\"" + Qtopia::escapeString( value ) + "\" "; 994 buf += "=\"" + Qtopia::escapeString( value ) + "\" ";
995 } 995 }
996 } 996 }
997 buf += customToXml(); 997 buf += customToXml();
998 if ( categories().count() > 0 ) 998 if ( categories().count() > 0 )
999 buf += "Categories=\"" + idsToString( categories() ) + "\" "; 999 buf += "Categories=\"" + idsToString( categories() ) + "\" ";
1000 buf += "Uid=\"" + QString::number( uid() ) + "\" "; 1000 buf += "Uid=\"" + QString::number( uid() ) + "\" ";
1001 // You need to close this yourself 1001 // You need to close this yourself
1002} 1002}
1003 1003
1004 1004
1005/*! 1005/*!
1006 \internal 1006 \internal
1007 Returns the list of fields belonging to a contact 1007 Returns the list of fields belonging to a contact
1008 Never change order of this list ! It has to be regarding 1008 Never change order of this list ! It has to be regarding
1009 enum AddressBookFields !! 1009 enum AddressBookFields !!
1010*/ 1010*/
1011QStringList OContact::fields() 1011QStringList OPimContact::fields()
1012{ 1012{
1013 QStringList list; 1013 QStringList list;
1014 1014
1015 list.append( "Title" ); // Not Used! 1015 list.append( "Title" ); // Not Used!
1016 list.append( "FirstName" ); 1016 list.append( "FirstName" );
1017 list.append( "MiddleName" ); 1017 list.append( "MiddleName" );
1018 list.append( "LastName" ); 1018 list.append( "LastName" );
1019 list.append( "Suffix" ); 1019 list.append( "Suffix" );
1020 list.append( "FileAs" ); 1020 list.append( "FileAs" );
1021 1021
1022 list.append( "JobTitle" ); 1022 list.append( "JobTitle" );
1023 list.append( "Department" ); 1023 list.append( "Department" );
1024 list.append( "Company" ); 1024 list.append( "Company" );
1025 list.append( "BusinessPhone" ); 1025 list.append( "BusinessPhone" );
1026 list.append( "BusinessFax" ); 1026 list.append( "BusinessFax" );
1027 list.append( "BusinessMobile" ); 1027 list.append( "BusinessMobile" );
1028 1028
1029 list.append( "DefaultEmail" ); 1029 list.append( "DefaultEmail" );
1030 list.append( "Emails" ); 1030 list.append( "Emails" );
1031 1031
1032 list.append( "HomePhone" ); 1032 list.append( "HomePhone" );
1033 list.append( "HomeFax" ); 1033 list.append( "HomeFax" );
1034 list.append( "HomeMobile" ); 1034 list.append( "HomeMobile" );
1035 1035
1036 list.append( "BusinessStreet" ); 1036 list.append( "BusinessStreet" );
1037 list.append( "BusinessCity" ); 1037 list.append( "BusinessCity" );
1038 list.append( "BusinessState" ); 1038 list.append( "BusinessState" );
1039 list.append( "BusinessZip" ); 1039 list.append( "BusinessZip" );
1040 list.append( "BusinessCountry" ); 1040 list.append( "BusinessCountry" );
1041 list.append( "BusinessPager" ); 1041 list.append( "BusinessPager" );
1042 list.append( "BusinessWebPage" ); 1042 list.append( "BusinessWebPage" );
1043 1043
1044 list.append( "Office" ); 1044 list.append( "Office" );
1045 list.append( "Profession" ); 1045 list.append( "Profession" );
1046 list.append( "Assistant" ); 1046 list.append( "Assistant" );
1047 list.append( "Manager" ); 1047 list.append( "Manager" );
1048 1048
1049 list.append( "HomeStreet" ); 1049 list.append( "HomeStreet" );
1050 list.append( "HomeCity" ); 1050 list.append( "HomeCity" );
1051 list.append( "HomeState" ); 1051 list.append( "HomeState" );
1052 list.append( "HomeZip" ); 1052 list.append( "HomeZip" );
1053 list.append( "HomeCountry" ); 1053 list.append( "HomeCountry" );
1054 list.append( "HomeWebPage" ); 1054 list.append( "HomeWebPage" );
1055 1055
1056 list.append( "Spouse" ); 1056 list.append( "Spouse" );
1057 list.append( "Gender" ); 1057 list.append( "Gender" );
1058 list.append( "Birthday" ); 1058 list.append( "Birthday" );
1059 list.append( "Anniversary" ); 1059 list.append( "Anniversary" );
1060 list.append( "Nickname" ); 1060 list.append( "Nickname" );
1061 list.append( "Children" ); 1061 list.append( "Children" );
1062 1062
1063 list.append( "Notes" ); 1063 list.append( "Notes" );
1064 list.append( "Groups" ); 1064 list.append( "Groups" );
1065 1065
1066 return list; 1066 return list;
1067} 1067}
1068 1068
1069 1069
1070/*! 1070/*!
1071 Sets the list of email address for contact to those contained in \a str. 1071 Sets the list of email address for contact to those contained in \a str.
1072 Email address should be separated by ';'s. 1072 Email address should be separated by ';'s.
1073*/ 1073*/
1074void OContact::setEmails( const QString &str ) 1074void OPimContact::setEmails( const QString &str )
1075{ 1075{
1076 replace( Qtopia::Emails, str ); 1076 replace( Qtopia::Emails, str );
1077 if ( str.isEmpty() ) 1077 if ( str.isEmpty() )
1078 setDefaultEmail( QString::null ); 1078 setDefaultEmail( QString::null );
1079} 1079}
1080 1080
1081/*! 1081/*!
1082 Sets the list of children for the contact to those contained in \a str. 1082 Sets the list of children for the contact to those contained in \a str.
1083*/ 1083*/
1084void OContact::setChildren( const QString &str ) 1084void OPimContact::setChildren( const QString &str )
1085{ 1085{
1086 replace( Qtopia::Children, str ); 1086 replace( Qtopia::Children, str );
1087} 1087}
1088 1088
1089/*! 1089/*!
1090 \overload 1090 \overload
1091 Returns TRUE if the contact matches the regular expression \a regexp. 1091 Returns TRUE if the contact matches the regular expression \a regexp.
1092 Otherwise returns FALSE. 1092 Otherwise returns FALSE.
1093*/ 1093*/
1094bool OContact::match( const QRegExp &r ) const 1094bool OPimContact::match( const QRegExp &r ) const
1095{ 1095{
1096 setLastHitField( -1 ); 1096 setLastHitField( -1 );
1097 bool match; 1097 bool match;
1098 match = false; 1098 match = false;
1099 QMap<int, QString>::ConstIterator it; 1099 QMap<int, QString>::ConstIterator it;
1100 for ( it = mMap.begin(); it != mMap.end(); ++it ) 1100 for ( it = mMap.begin(); it != mMap.end(); ++it )
1101 { 1101 {
1102 if ( ( *it ).find( r ) > -1 ) 1102 if ( ( *it ).find( r ) > -1 )
1103 { 1103 {
1104 setLastHitField( it.key() ); 1104 setLastHitField( it.key() );
1105 match = true; 1105 match = true;
1106 break; 1106 break;
1107 } 1107 }
1108 } 1108 }
1109 return match; 1109 return match;
1110} 1110}
1111 1111
1112 1112
1113QString OContact::toShortText() const 1113QString OPimContact::toShortText() const
1114{ 1114{
1115 return ( fullName() ); 1115 return ( fullName() );
1116} 1116}
1117 1117
1118 1118
1119QString OContact::type() const 1119QString OPimContact::type() const
1120{ 1120{
1121 return QString::fromLatin1( "OContact" ); 1121 return QString::fromLatin1( "OPimContact" );
1122} 1122}
1123 1123
1124 1124
1125class QString OContact::recordField( int pos ) const 1125class QString OPimContact::recordField( int pos ) const
1126{ 1126{
1127 QStringList SLFIELDS = fields(); // ?? why this ? (se) 1127 QStringList SLFIELDS = fields(); // ?? why this ? (se)
1128 return SLFIELDS[ pos ]; 1128 return SLFIELDS[ pos ];
1129} 1129}
1130 1130
1131// In future releases, we should store birthday and anniversary 1131// In future releases, we should store birthday and anniversary
1132// internally as QDate instead of QString ! 1132// internally as QDate instead of QString !
1133// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1133// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1134 1134
1135/*! \fn void OContact::setBirthday( const QDate& date ) 1135/*! \fn void OPimContact::setBirthday( const QDate& date )
1136 Sets the birthday for the contact to \a date. If date is null 1136 Sets the birthday for the contact to \a date. If date is null
1137 the current stored date will be removed. 1137 the current stored date will be removed.
1138*/ 1138*/
1139void OContact::setBirthday( const QDate &v ) 1139void OPimContact::setBirthday( const QDate &v )
1140{ 1140{
1141 if ( v.isNull() ) 1141 if ( v.isNull() )
1142 { 1142 {
1143 qWarning( "Remove Birthday" ); 1143 qWarning( "Remove Birthday" );
1144 replace( Qtopia::Birthday, QString::null ); 1144 replace( Qtopia::Birthday, QString::null );
1145 return ; 1145 return ;
1146 } 1146 }
1147 1147
1148 if ( v.isValid() ) 1148 if ( v.isValid() )
1149 replace( Qtopia::Birthday, OConversion::dateToString( v ) ); 1149 replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) );
1150 1150
1151} 1151}
1152 1152
1153 1153
1154/*! \fn void OContact::setAnniversary( const QDate &date ) 1154/*! \fn void OPimContact::setAnniversary( const QDate &date )
1155 Sets the anniversary of the contact to \a date. If date is 1155 Sets the anniversary of the contact to \a date. If date is
1156 null, the current stored date will be removed. 1156 null, the current stored date will be removed.
1157*/ 1157*/
1158void OContact::setAnniversary( const QDate &v ) 1158void OPimContact::setAnniversary( const QDate &v )
1159{ 1159{
1160 if ( v.isNull() ) 1160 if ( v.isNull() )
1161 { 1161 {
1162 qWarning( "Remove Anniversary" ); 1162 qWarning( "Remove Anniversary" );
1163 replace( Qtopia::Anniversary, QString::null ); 1163 replace( Qtopia::Anniversary, QString::null );
1164 return ; 1164 return ;
1165 } 1165 }
1166 1166
1167 if ( v.isValid() ) 1167 if ( v.isValid() )
1168 replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); 1168 replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) );
1169} 1169}
1170 1170
1171 1171
1172/*! \fn QDate OContact::birthday() const 1172/*! \fn QDate OPimContact::birthday() const
1173 Returns the birthday of the contact. 1173 Returns the birthday of the contact.
1174*/ 1174*/
1175QDate OContact::birthday() const 1175QDate OPimContact::birthday() const
1176{ 1176{
1177 QString str = find( Qtopia::Birthday ); 1177 QString str = find( Qtopia::Birthday );
1178 // qWarning ("Birthday %s", str.latin1() ); 1178 // qWarning ("Birthday %s", str.latin1() );
1179 if ( !str.isEmpty() ) 1179 if ( !str.isEmpty() )
1180 return OConversion::dateFromString ( str ); 1180 return OPimDateConversion::dateFromString ( str );
1181 else 1181 else
1182 return QDate(); 1182 return QDate();
1183} 1183}
1184 1184
1185 1185
1186/*! \fn QDate OContact::anniversary() const 1186/*! \fn QDate OPimContact::anniversary() const
1187 Returns the anniversary of the contact. 1187 Returns the anniversary of the contact.
1188*/ 1188*/
1189QDate OContact::anniversary() const 1189QDate OPimContact::anniversary() const
1190{ 1190{
1191 QDate empty; 1191 QDate empty;
1192 QString str = find( Qtopia::Anniversary ); 1192 QString str = find( Qtopia::Anniversary );
1193 // qWarning ("Anniversary %s", str.latin1() ); 1193 // qWarning ("Anniversary %s", str.latin1() );
1194 if ( !str.isEmpty() ) 1194 if ( !str.isEmpty() )
1195 return OConversion::dateFromString ( str ); 1195 return OPimDateConversion::dateFromString ( str );
1196 else 1196 else
1197 return empty; 1197 return empty;
1198} 1198}
1199 1199
1200 1200
1201void OContact::insertEmail( const QString &v ) 1201void OPimContact::insertEmail( const QString &v )
1202{ 1202{
1203 //qDebug("insertEmail %s", v.latin1()); 1203 //qDebug("insertEmail %s", v.latin1());
1204 QString e = v.simplifyWhiteSpace(); 1204 QString e = v.simplifyWhiteSpace();
1205 QString def = defaultEmail(); 1205 QString def = defaultEmail();
1206 1206
1207 // if no default, set it as the default email and don't insert 1207 // if no default, set it as the default email and don't insert
1208 if ( def.isEmpty() ) 1208 if ( def.isEmpty() )
1209 { 1209 {
1210 setDefaultEmail( e ); // will insert into the list for us 1210 setDefaultEmail( e ); // will insert into the list for us
1211 return ; 1211 return ;
1212 } 1212 }
1213 1213
1214 // otherwise, insert assuming doesn't already exist 1214 // otherwise, insert assuming doesn't already exist
1215 QString emailsStr = find( Qtopia::Emails ); 1215 QString emailsStr = find( Qtopia::Emails );
1216 if ( emailsStr.contains( e ) ) 1216 if ( emailsStr.contains( e ) )
1217 return ; 1217 return ;
1218 if ( !emailsStr.isEmpty() ) 1218 if ( !emailsStr.isEmpty() )
1219 emailsStr += emailSeparator(); 1219 emailsStr += emailSeparator();
1220 emailsStr += e; 1220 emailsStr += e;
1221 replace( Qtopia::Emails, emailsStr ); 1221 replace( Qtopia::Emails, emailsStr );
1222} 1222}
1223 1223
1224 1224
1225 void OContact::removeEmail( const QString &v ) 1225 void OPimContact::removeEmail( const QString &v )
1226{ 1226{
1227 QString e = v.simplifyWhiteSpace(); 1227 QString e = v.simplifyWhiteSpace();
1228 QString def = defaultEmail(); 1228 QString def = defaultEmail();
1229 QString emailsStr = find( Qtopia::Emails ); 1229 QString emailsStr = find( Qtopia::Emails );
1230 QStringList emails = emailList(); 1230 QStringList emails = emailList();
1231 1231
1232 // otherwise, must first contain it 1232 // otherwise, must first contain it
1233 if ( !emailsStr.contains( e ) ) 1233 if ( !emailsStr.contains( e ) )
1234 return ; 1234 return ;
1235 1235
1236 // remove it 1236 // remove it
1237 //qDebug(" removing email from list %s", e.latin1()); 1237 //qDebug(" removing email from list %s", e.latin1());
1238 emails.remove( e ); 1238 emails.remove( e );
1239 // reset the string 1239 // reset the string
1240 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator 1240 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator
1241 replace( Qtopia::Emails, emailsStr ); 1241 replace( Qtopia::Emails, emailsStr );
1242 1242
1243 // if default, then replace the default email with the first one 1243 // if default, then replace the default email with the first one
1244 if ( def == e ) 1244 if ( def == e )
1245 { 1245 {
1246 //qDebug("removeEmail is default; setting new default"); 1246 //qDebug("removeEmail is default; setting new default");
1247 if ( !emails.count() ) 1247 if ( !emails.count() )
1248 clearEmails(); 1248 clearEmails();
1249 else // setDefaultEmail will remove e from the list 1249 else // setDefaultEmail will remove e from the list
1250 setDefaultEmail( emails.first() ); 1250 setDefaultEmail( emails.first() );
1251 } 1251 }
1252} 1252}
1253 1253
1254 1254
1255void OContact::clearEmails() 1255void OPimContact::clearEmails()
1256{ 1256{
1257 mMap.remove( Qtopia::DefaultEmail ); 1257 mMap.remove( Qtopia::DefaultEmail );
1258 mMap.remove( Qtopia::Emails ); 1258 mMap.remove( Qtopia::Emails );
1259} 1259}
1260 1260
1261 1261
1262void OContact::setDefaultEmail( const QString &v ) 1262void OPimContact::setDefaultEmail( const QString &v )
1263{ 1263{
1264 QString e = v.simplifyWhiteSpace(); 1264 QString e = v.simplifyWhiteSpace();
1265 1265
1266 //qDebug("OContact::setDefaultEmail %s", e.latin1()); 1266 //qDebug("OPimContact::setDefaultEmail %s", e.latin1());
1267 replace( Qtopia::DefaultEmail, e ); 1267 replace( Qtopia::DefaultEmail, e );
1268 1268
1269 if ( !e.isEmpty() ) 1269 if ( !e.isEmpty() )
1270 insertEmail( e ); 1270 insertEmail( e );
1271 1271
1272} 1272}
1273 1273
1274 1274
1275void OContact::insertEmails( const QStringList &v ) 1275void OPimContact::insertEmails( const QStringList &v )
1276{ 1276{
1277 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1277 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1278 insertEmail( *it ); 1278 insertEmail( *it );
1279} 1279}
1280 1280
1281 1281
1282int OContact::rtti() 1282int OPimContact::rtti()
1283{ 1283{
1284 return OPimResolver::AddressBook; 1284 return OPimResolver::AddressBook;
1285} 1285}
1286 1286
1287 1287
1288void OContact::setUid( int i ) 1288void OPimContact::setUid( int i )
1289{ 1289{
1290 OPimRecord::setUid( i ); 1290 OPimRecord::setUid( i );
1291 replace( Qtopia::AddressUid , QString::number( i ) ); 1291 replace( Qtopia::AddressUid , QString::number( i ) );
1292} 1292}
1293} 1293}
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/core/opimcontact.h
index 445fd7d..c08f7ed 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/core/opimcontact.h
@@ -1,256 +1,256 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OCONTACT_H 30#ifndef OCONTACT_H
31#define OCONTACT_H 31#define OCONTACT_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/opimrecord.h> 34#include <opie2/opimrecord.h>
35#include <qpe/recordfields.h> 35#include <qpe/recordfields.h>
36 36
37/* QT */ 37/* QT */
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40 40
41#if defined(QPC_TEMPLATEDLL) 41#if defined(QPC_TEMPLATEDLL)
42// MOC_SKIP_BEGIN 42// MOC_SKIP_BEGIN
43QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; 43QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
44// MOC_SKIP_END 44// MOC_SKIP_END
45#endif 45#endif
46 46
47namespace Opie 47namespace Opie
48{ 48{
49class OContactPrivate; 49class OPimContactPrivate;
50 50
51/** 51/**
52 * OContact class represents a specialised PIM Record for contacts. 52 * OPimContact class represents a specialised PIM Record for contacts.
53 * It does store all kind of persopn related information. 53 * It does store all kind of persopn related information.
54 * 54 *
55 * @short Contact Container 55 * @short Contact Container
56 * @author TT, Stefan Eiler, Holger Freyther 56 * @author TT, Stefan Eiler, Holger Freyther
57 */ 57 */
58class QPC_EXPORT OContact : public OPimRecord 58class QPC_EXPORT OPimContact : public OPimRecord
59{ 59{
60 friend class DataSet; 60 friend class DataSet;
61 61
62 public: 62 public:
63 OContact(); 63 OPimContact();
64 OContact( const QMap<int, QString> &fromMap ); 64 OPimContact( const QMap<int, QString> &fromMap );
65 virtual ~OContact(); 65 virtual ~OPimContact();
66 66
67 enum DateFormat{ 67 enum DateFormat{
68 Zip_City_State = 0, 68 Zip_City_State = 0,
69 City_State_Zip 69 City_State_Zip
70 }; 70 };
71 71
72 /* 72 /*
73 * do we need to inline them 73 * do we need to inline them
74 * if yes do we need to inline them this way? 74 * if yes do we need to inline them this way?
75 * -zecke 75 * -zecke
76 */ 76 */
77 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } 77 void setTitle( const QString &v ) { replace( Qtopia::Title, v ); }
78 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } 78 void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); }
79 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } 79 void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); }
80 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } 80 void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); }
81 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } 81 void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); }
82 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } 82 void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); }
83 void setFileAs(); 83 void setFileAs();
84 84
85 // default email address 85 // default email address
86 void setDefaultEmail( const QString &v ); 86 void setDefaultEmail( const QString &v );
87 // inserts email to list and ensure's doesn't already exist 87 // inserts email to list and ensure's doesn't already exist
88 void insertEmail( const QString &v ); 88 void insertEmail( const QString &v );
89 void removeEmail( const QString &v ); 89 void removeEmail( const QString &v );
90 void clearEmails(); 90 void clearEmails();
91 void insertEmails( const QStringList &v ); 91 void insertEmails( const QStringList &v );
92 92
93 // home 93 // home
94 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 94 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
95 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } 95 void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); }
96 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } 96 void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); }
97 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } 97 void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); }
98 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } 98 void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); }
99 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } 99 void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); }
100 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } 100 void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); }
101 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } 101 void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); }
102 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } 102 void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); }
103 103
104 // business 104 // business
105 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } 105 void setCompany( const QString &v ) { replace( Qtopia::Company, v ); }
106 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } 106 void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); }
107 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } 107 void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); }
108 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } 108 void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); }
109 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } 109 void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); }
110 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } 110 void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); }
111 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } 111 void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); }
112 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } 112 void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); }
113 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } 113 void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); }
114 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } 114 void setOffice( const QString &v ) { replace( Qtopia::Office, v ); }
115 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } 115 void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); }
116 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } 116 void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); }
117 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } 117 void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); }
118 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } 118 void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); }
119 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } 119 void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); }
120 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } 120 void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); }
121 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } 121 void setManager( const QString &v ) { replace( Qtopia::Manager, v ); }
122 122
123 // personal 123 // personal
124 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } 124 void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); }
125 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } 125 void setGender( const QString &v ) { replace( Qtopia::Gender, v ); }
126 void setBirthday( const QDate &v ); 126 void setBirthday( const QDate &v );
127 void setAnniversary( const QDate &v ); 127 void setAnniversary( const QDate &v );
128 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } 128 void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); }
129 void setChildren( const QString &v ); 129 void setChildren( const QString &v );
130 130
131 // other 131 // other
132 void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); } 132 void setNotes( const QString &v ) { replace( Qtopia::Notes, v ); }
133 133
134 virtual bool match( const QRegExp &regexp ) const; 134 virtual bool match( const QRegExp &regexp ) const;
135 135
136 // // custom 136 // // custom
137 // void setCustomField( const QString &key, const QString &v ) 137 // void setCustomField( const QString &key, const QString &v )
138 // { replace(Custom- + key, v ); } 138 // { replace(Custom- + key, v ); }
139 139
140 // name 140 // name
141 QString fullName() const; 141 QString fullName() const;
142 QString title() const { return find( Qtopia::Title ); } 142 QString title() const { return find( Qtopia::Title ); }
143 QString firstName() const { return find( Qtopia::FirstName ); } 143 QString firstName() const { return find( Qtopia::FirstName ); }
144 QString middleName() const { return find( Qtopia::MiddleName ); } 144 QString middleName() const { return find( Qtopia::MiddleName ); }
145 QString lastName() const { return find( Qtopia::LastName ); } 145 QString lastName() const { return find( Qtopia::LastName ); }
146 QString suffix() const { return find( Qtopia::Suffix ); } 146 QString suffix() const { return find( Qtopia::Suffix ); }
147 QString fileAs() const { return find( Qtopia::FileAs ); } 147 QString fileAs() const { return find( Qtopia::FileAs ); }
148 148
149 // email 149 // email
150 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 150 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
151 QStringList emailList() const; 151 QStringList emailList() const;
152 152
153 // home 153 // home
154 /* 154 /*
155 * OPimAddress address(enum Location)const; 155 * OPimAddress address(enum Location)const;
156 * would be some how nicer... 156 * would be some how nicer...
157 * -zecke 157 * -zecke
158 */ 158 */
159 QString homeStreet() const { return find( Qtopia::HomeStreet ); } 159 QString homeStreet() const { return find( Qtopia::HomeStreet ); }
160 QString homeCity() const { return find( Qtopia::HomeCity ); } 160 QString homeCity() const { return find( Qtopia::HomeCity ); }
161 QString homeState() const { return find( Qtopia::HomeState ); } 161 QString homeState() const { return find( Qtopia::HomeState ); }
162 QString homeZip() const { return find( Qtopia::HomeZip ); } 162 QString homeZip() const { return find( Qtopia::HomeZip ); }
163 QString homeCountry() const { return find( Qtopia::HomeCountry ); } 163 QString homeCountry() const { return find( Qtopia::HomeCountry ); }
164 QString homePhone() const { return find( Qtopia::HomePhone ); } 164 QString homePhone() const { return find( Qtopia::HomePhone ); }
165 QString homeFax() const { return find( Qtopia::HomeFax ); } 165 QString homeFax() const { return find( Qtopia::HomeFax ); }
166 QString homeMobile() const { return find( Qtopia::HomeMobile ); } 166 QString homeMobile() const { return find( Qtopia::HomeMobile ); }
167 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } 167 QString homeWebpage() const { return find( Qtopia::HomeWebPage ); }
168 /** Multi line string containing all non-empty address info in the form 168 /** Multi line string containing all non-empty address info in the form
169 * Street 169 * Street
170 * City, State Zip 170 * City, State Zip
171 * Country 171 * Country
172 */ 172 */
173 QString displayHomeAddress() const; 173 QString displayHomeAddress() const;
174 174
175 // business 175 // business
176 QString company() const { return find( Qtopia::Company ); } 176 QString company() const { return find( Qtopia::Company ); }
177 QString businessStreet() const { return find( Qtopia::BusinessStreet ); } 177 QString businessStreet() const { return find( Qtopia::BusinessStreet ); }
178 QString businessCity() const { return find( Qtopia::BusinessCity ); } 178 QString businessCity() const { return find( Qtopia::BusinessCity ); }
179 QString businessState() const { return find( Qtopia::BusinessState ); } 179 QString businessState() const { return find( Qtopia::BusinessState ); }
180 QString businessZip() const { return find( Qtopia::BusinessZip ); } 180 QString businessZip() const { return find( Qtopia::BusinessZip ); }
181 QString businessCountry() const { return find( Qtopia::BusinessCountry ); } 181 QString businessCountry() const { return find( Qtopia::BusinessCountry ); }
182 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } 182 QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
183 QString jobTitle() const { return find( Qtopia::JobTitle ); } 183 QString jobTitle() const { return find( Qtopia::JobTitle ); }
184 QString department() const { return find( Qtopia::Department ); } 184 QString department() const { return find( Qtopia::Department ); }
185 QString office() const { return find( Qtopia::Office ); } 185 QString office() const { return find( Qtopia::Office ); }
186 QString businessPhone() const { return find( Qtopia::BusinessPhone ); } 186 QString businessPhone() const { return find( Qtopia::BusinessPhone ); }
187 QString businessFax() const { return find( Qtopia::BusinessFax ); } 187 QString businessFax() const { return find( Qtopia::BusinessFax ); }
188 QString businessMobile() const { return find( Qtopia::BusinessMobile ); } 188 QString businessMobile() const { return find( Qtopia::BusinessMobile ); }
189 QString businessPager() const { return find( Qtopia::BusinessPager ); } 189 QString businessPager() const { return find( Qtopia::BusinessPager ); }
190 QString profession() const { return find( Qtopia::Profession ); } 190 QString profession() const { return find( Qtopia::Profession ); }
191 QString assistant() const { return find( Qtopia::Assistant ); } 191 QString assistant() const { return find( Qtopia::Assistant ); }
192 QString manager() const { return find( Qtopia::Manager ); } 192 QString manager() const { return find( Qtopia::Manager ); }
193 /** Multi line string containing all non-empty address info in the form 193 /** Multi line string containing all non-empty address info in the form
194 * Street 194 * Street
195 * City, State Zip 195 * City, State Zip
196 * Country 196 * Country
197 */ 197 */
198 QString displayBusinessAddress() const; 198 QString displayBusinessAddress() const;
199 199
200 //personal 200 //personal
201 QString spouse() const { return find( Qtopia::Spouse ); } 201 QString spouse() const { return find( Qtopia::Spouse ); }
202 QString gender() const { return find( Qtopia::Gender ); } 202 QString gender() const { return find( Qtopia::Gender ); }
203 QDate birthday() const; 203 QDate birthday() const;
204 QDate anniversary() const; 204 QDate anniversary() const;
205 QString nickname() const { return find( Qtopia::Nickname ); } 205 QString nickname() const { return find( Qtopia::Nickname ); }
206 QString children() const { return find( Qtopia::Children ); } 206 QString children() const { return find( Qtopia::Children ); }
207 QStringList childrenList() const; 207 QStringList childrenList() const;
208 208
209 // other 209 // other
210 QString notes() const { return find( Qtopia::Notes ); } 210 QString notes() const { return find( Qtopia::Notes ); }
211 QString groups() const { return find( Qtopia::Groups ); } 211 QString groups() const { return find( Qtopia::Groups ); }
212 QStringList groupList() const; 212 QStringList groupList() const;
213 213
214 QString toRichText() const; 214 QString toRichText() const;
215 QMap<int, QString> toMap() const; 215 QMap<int, QString> toMap() const;
216 QString field( int key ) const { return find( key ); } 216 QString field( int key ) const { return find( key ); }
217 217
218 218
219 void setUid( int i ); 219 void setUid( int i );
220 220
221 QString toShortText() const; 221 QString toShortText() const;
222 QString type() const; 222 QString type() const;
223 class QString recordField( int ) const; 223 class QString recordField( int ) const;
224 224
225 // Why private ? (eilers,se) 225 // Why private ? (eilers,se)
226 QString emailSeparator() const { return " "; } 226 QString emailSeparator() const { return " "; }
227 227
228 // the emails should be seperated by a comma 228 // the emails should be seperated by a comma
229 void setEmails( const QString &v ); 229 void setEmails( const QString &v );
230 QString emails() const { return find( Qtopia::Emails ); } 230 QString emails() const { return find( Qtopia::Emails ); }
231 static int rtti(); 231 static int rtti();
232 232
233 private: 233 private:
234 // The XML Backend needs some access to the private functions 234 // The XML Backend needs some access to the private functions
235 friend class OContactAccessBackend_XML; 235 friend class OPimContactAccessBackend_XML;
236 236
237 void insert( int key, const QString &value ); 237 void insert( int key, const QString &value );
238 void replace( int key, const QString &value ); 238 void replace( int key, const QString &value );
239 QString find( int key ) const; 239 QString find( int key ) const;
240 static QStringList fields(); 240 static QStringList fields();
241 241
242 void save( QString &buf ) const; 242 void save( QString &buf ) const;
243 243
244 QString displayAddress( const QString &street, 244 QString displayAddress( const QString &street,
245 const QString &city, 245 const QString &city,
246 const QString &state, 246 const QString &state,
247 const QString &zip, 247 const QString &zip,
248 const QString &country ) const; 248 const QString &country ) const;
249 249
250 QMap<int, QString> mMap; 250 QMap<int, QString> mMap;
251 OContactPrivate *d; 251 OPimContactPrivate *d;
252}; 252};
253 253
254} 254}
255 255
256#endif 256#endif
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/core/opimcontactfields.cpp
index bec00f7..4b0ba3b 100644
--- a/libopie2/opiepim/ocontactfields.cpp
+++ b/libopie2/opiepim/core/opimcontactfields.cpp
@@ -1,518 +1,518 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de> 3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "ocontactfields.h" 30#include "opimcontactfields.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/ocontact.h> 33#include <opie2/opimcontact.h>
34#include <qpe/recordfields.h> // We should use our own enum in the future .. 34#include <qpe/recordfields.h> // We should use our own enum in the future ..
35#include <qpe/config.h> 35#include <qpe/config.h>
36 36
37/* QT */ 37/* QT */
38#include <qobject.h> 38#include <qobject.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40 40
41 41
42namespace Opie 42namespace Opie
43{ 43{
44/*! 44/*!
45 \internal 45 \internal
46 Returns a list of personal field names for a contact. 46 Returns a list of personal field names for a contact.
47*/ 47*/
48QStringList OContactFields::personalfields( bool sorted, bool translated ) 48QStringList OPimContactFields::personalfields( bool sorted, bool translated )
49{ 49{
50 QStringList list; 50 QStringList list;
51 QMap<int, QString> mapIdToStr; 51 QMap<int, QString> mapIdToStr;
52 if ( translated ) 52 if ( translated )
53 mapIdToStr = idToTrFields(); 53 mapIdToStr = idToTrFields();
54 else 54 else
55 mapIdToStr = idToUntrFields(); 55 mapIdToStr = idToUntrFields();
56 56
57 list.append( mapIdToStr[ Qtopia::AddressUid ] ); 57 list.append( mapIdToStr[ Qtopia::AddressUid ] );
58 list.append( mapIdToStr[ Qtopia::AddressCategory ] ); 58 list.append( mapIdToStr[ Qtopia::AddressCategory ] );
59 59
60 list.append( mapIdToStr[ Qtopia::Title ] ); 60 list.append( mapIdToStr[ Qtopia::Title ] );
61 list.append( mapIdToStr[ Qtopia::FirstName ] ); 61 list.append( mapIdToStr[ Qtopia::FirstName ] );
62 list.append( mapIdToStr[ Qtopia::MiddleName ] ); 62 list.append( mapIdToStr[ Qtopia::MiddleName ] );
63 list.append( mapIdToStr[ Qtopia::LastName ] ); 63 list.append( mapIdToStr[ Qtopia::LastName ] );
64 list.append( mapIdToStr[ Qtopia::Suffix ] ); 64 list.append( mapIdToStr[ Qtopia::Suffix ] );
65 list.append( mapIdToStr[ Qtopia::FileAs ] ); 65 list.append( mapIdToStr[ Qtopia::FileAs ] );
66 66
67 list.append( mapIdToStr[ Qtopia::JobTitle ] ); 67 list.append( mapIdToStr[ Qtopia::JobTitle ] );
68 list.append( mapIdToStr[ Qtopia::Department ] ); 68 list.append( mapIdToStr[ Qtopia::Department ] );
69 list.append( mapIdToStr[ Qtopia::Company ] ); 69 list.append( mapIdToStr[ Qtopia::Company ] );
70 70
71 list.append( mapIdToStr[ Qtopia::Notes ] ); 71 list.append( mapIdToStr[ Qtopia::Notes ] );
72 list.append( mapIdToStr[ Qtopia::Groups ] ); 72 list.append( mapIdToStr[ Qtopia::Groups ] );
73 73
74 if ( sorted ) list.sort(); 74 if ( sorted ) list.sort();
75 return list; 75 return list;
76} 76}
77 77
78/*! 78/*!
79 \internal 79 \internal
80 Returns a list of details field names for a contact. 80 Returns a list of details field names for a contact.
81*/ 81*/
82QStringList OContactFields::detailsfields( bool sorted, bool translated ) 82QStringList OPimContactFields::detailsfields( bool sorted, bool translated )
83{ 83{
84 QStringList list; 84 QStringList list;
85 QMap<int, QString> mapIdToStr; 85 QMap<int, QString> mapIdToStr;
86 if ( translated ) 86 if ( translated )
87 mapIdToStr = idToTrFields(); 87 mapIdToStr = idToTrFields();
88 else 88 else
89 mapIdToStr = idToUntrFields(); 89 mapIdToStr = idToUntrFields();
90 90
91 list.append( mapIdToStr[ Qtopia::Office ] ); 91 list.append( mapIdToStr[ Qtopia::Office ] );
92 list.append( mapIdToStr[ Qtopia::Profession ] ); 92 list.append( mapIdToStr[ Qtopia::Profession ] );
93 list.append( mapIdToStr[ Qtopia::Assistant ] ); 93 list.append( mapIdToStr[ Qtopia::Assistant ] );
94 list.append( mapIdToStr[ Qtopia::Manager ] ); 94 list.append( mapIdToStr[ Qtopia::Manager ] );
95 95
96 list.append( mapIdToStr[ Qtopia::Spouse ] ); 96 list.append( mapIdToStr[ Qtopia::Spouse ] );
97 list.append( mapIdToStr[ Qtopia::Gender ] ); 97 list.append( mapIdToStr[ Qtopia::Gender ] );
98 list.append( mapIdToStr[ Qtopia::Birthday ] ); 98 list.append( mapIdToStr[ Qtopia::Birthday ] );
99 list.append( mapIdToStr[ Qtopia::Anniversary ] ); 99 list.append( mapIdToStr[ Qtopia::Anniversary ] );
100 list.append( mapIdToStr[ Qtopia::Nickname ] ); 100 list.append( mapIdToStr[ Qtopia::Nickname ] );
101 list.append( mapIdToStr[ Qtopia::Children ] ); 101 list.append( mapIdToStr[ Qtopia::Children ] );
102 102
103 if ( sorted ) list.sort(); 103 if ( sorted ) list.sort();
104 return list; 104 return list;
105} 105}
106 106
107/*! 107/*!
108 \internal 108 \internal
109 Returns a list of phone field names for a contact. 109 Returns a list of phone field names for a contact.
110*/ 110*/
111QStringList OContactFields::phonefields( bool sorted, bool translated ) 111QStringList OPimContactFields::phonefields( bool sorted, bool translated )
112{ 112{
113 QStringList list; 113 QStringList list;
114 QMap<int, QString> mapIdToStr; 114 QMap<int, QString> mapIdToStr;
115 if ( translated ) 115 if ( translated )
116 mapIdToStr = idToTrFields(); 116 mapIdToStr = idToTrFields();
117 else 117 else
118 mapIdToStr = idToUntrFields(); 118 mapIdToStr = idToUntrFields();
119 119
120 list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); 120 list.append( mapIdToStr[ Qtopia::BusinessPhone ] );
121 list.append( mapIdToStr[ Qtopia::BusinessFax ] ); 121 list.append( mapIdToStr[ Qtopia::BusinessFax ] );
122 list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); 122 list.append( mapIdToStr[ Qtopia::BusinessMobile ] );
123 list.append( mapIdToStr[ Qtopia::BusinessPager ] ); 123 list.append( mapIdToStr[ Qtopia::BusinessPager ] );
124 list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); 124 list.append( mapIdToStr[ Qtopia::BusinessWebPage ] );
125 125
126 list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); 126 list.append( mapIdToStr[ Qtopia::DefaultEmail ] );
127 list.append( mapIdToStr[ Qtopia::Emails ] ); 127 list.append( mapIdToStr[ Qtopia::Emails ] );
128 128
129 list.append( mapIdToStr[ Qtopia::HomePhone ] ); 129 list.append( mapIdToStr[ Qtopia::HomePhone ] );
130 list.append( mapIdToStr[ Qtopia::HomeFax ] ); 130 list.append( mapIdToStr[ Qtopia::HomeFax ] );
131 list.append( mapIdToStr[ Qtopia::HomeMobile ] ); 131 list.append( mapIdToStr[ Qtopia::HomeMobile ] );
132 // list.append( mapIdToStr[Qtopia::HomePager] ); 132 // list.append( mapIdToStr[Qtopia::HomePager] );
133 list.append( mapIdToStr[ Qtopia::HomeWebPage ] ); 133 list.append( mapIdToStr[ Qtopia::HomeWebPage ] );
134 134
135 if ( sorted ) list.sort(); 135 if ( sorted ) list.sort();
136 136
137 return list; 137 return list;
138} 138}
139 139
140/*! 140/*!
141 \internal 141 \internal
142 Returns a list of field names for a contact. 142 Returns a list of field names for a contact.
143*/ 143*/
144QStringList OContactFields::fields( bool sorted, bool translated ) 144QStringList OPimContactFields::fields( bool sorted, bool translated )
145{ 145{
146 QStringList list; 146 QStringList list;
147 QMap<int, QString> mapIdToStr; 147 QMap<int, QString> mapIdToStr;
148 if ( translated ) 148 if ( translated )
149 mapIdToStr = idToTrFields(); 149 mapIdToStr = idToTrFields();
150 else 150 else
151 mapIdToStr = idToUntrFields(); 151 mapIdToStr = idToUntrFields();
152 152
153 list += personalfields( sorted, translated ); 153 list += personalfields( sorted, translated );
154 154
155 list += phonefields( sorted, translated ); 155 list += phonefields( sorted, translated );
156 156
157 list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); 157 list.append( mapIdToStr[ Qtopia::BusinessStreet ] );
158 list.append( mapIdToStr[ Qtopia::BusinessCity ] ); 158 list.append( mapIdToStr[ Qtopia::BusinessCity ] );
159 list.append( mapIdToStr[ Qtopia::BusinessState ] ); 159 list.append( mapIdToStr[ Qtopia::BusinessState ] );
160 list.append( mapIdToStr[ Qtopia::BusinessZip ] ); 160 list.append( mapIdToStr[ Qtopia::BusinessZip ] );
161 list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); 161 list.append( mapIdToStr[ Qtopia::BusinessCountry ] );
162 162
163 list.append( mapIdToStr[ Qtopia::HomeStreet ] ); 163 list.append( mapIdToStr[ Qtopia::HomeStreet ] );
164 list.append( mapIdToStr[ Qtopia::HomeCity ] ); 164 list.append( mapIdToStr[ Qtopia::HomeCity ] );
165 list.append( mapIdToStr[ Qtopia::HomeState ] ); 165 list.append( mapIdToStr[ Qtopia::HomeState ] );
166 list.append( mapIdToStr[ Qtopia::HomeZip ] ); 166 list.append( mapIdToStr[ Qtopia::HomeZip ] );
167 list.append( mapIdToStr[ Qtopia::HomeCountry ] ); 167 list.append( mapIdToStr[ Qtopia::HomeCountry ] );
168 168
169 list += detailsfields( sorted, translated ); 169 list += detailsfields( sorted, translated );
170 170
171 if ( sorted ) list.sort(); 171 if ( sorted ) list.sort();
172 172
173 return list; 173 return list;
174} 174}
175 175
176 176
177/*! 177/*!
178 \internal 178 \internal
179 Returns an untranslated list of personal field names for a contact. 179 Returns an untranslated list of personal field names for a contact.
180*/ 180*/
181QStringList OContactFields::untrpersonalfields( bool sorted ) 181QStringList OPimContactFields::untrpersonalfields( bool sorted )
182{ 182{
183 return personalfields( sorted, false ); 183 return personalfields( sorted, false );
184} 184}
185 185
186 186
187/*! 187/*!
188 \internal 188 \internal
189 Returns a translated list of personal field names for a contact. 189 Returns a translated list of personal field names for a contact.
190*/ 190*/
191QStringList OContactFields::trpersonalfields( bool sorted ) 191QStringList OPimContactFields::trpersonalfields( bool sorted )
192{ 192{
193 return personalfields( sorted, true ); 193 return personalfields( sorted, true );
194} 194}
195 195
196 196
197/*! 197/*!
198 \internal 198 \internal
199 Returns an untranslated list of details field names for a contact. 199 Returns an untranslated list of details field names for a contact.
200*/ 200*/
201QStringList OContactFields::untrdetailsfields( bool sorted ) 201QStringList OPimContactFields::untrdetailsfields( bool sorted )
202{ 202{
203 return detailsfields( sorted, false ); 203 return detailsfields( sorted, false );
204} 204}
205 205
206 206
207/*! 207/*!
208 \internal 208 \internal
209 Returns a translated list of details field names for a contact. 209 Returns a translated list of details field names for a contact.
210*/ 210*/
211QStringList OContactFields::trdetailsfields( bool sorted ) 211QStringList OPimContactFields::trdetailsfields( bool sorted )
212{ 212{
213 return detailsfields( sorted, true ); 213 return detailsfields( sorted, true );
214} 214}
215 215
216 216
217/*! 217/*!
218 \internal 218 \internal
219 Returns a translated list of phone field names for a contact. 219 Returns a translated list of phone field names for a contact.
220*/ 220*/
221QStringList OContactFields::trphonefields( bool sorted ) 221QStringList OPimContactFields::trphonefields( bool sorted )
222{ 222{
223 return phonefields( sorted, true ); 223 return phonefields( sorted, true );
224} 224}
225 225
226/*! 226/*!
227 \internal 227 \internal
228 Returns an untranslated list of phone field names for a contact. 228 Returns an untranslated list of phone field names for a contact.
229*/ 229*/
230QStringList OContactFields::untrphonefields( bool sorted ) 230QStringList OPimContactFields::untrphonefields( bool sorted )
231{ 231{
232 return phonefields( sorted, false ); 232 return phonefields( sorted, false );
233} 233}
234 234
235 235
236/*! 236/*!
237 \internal 237 \internal
238 Returns a translated list of field names for a contact. 238 Returns a translated list of field names for a contact.
239*/ 239*/
240QStringList OContactFields::trfields( bool sorted ) 240QStringList OPimContactFields::trfields( bool sorted )
241{ 241{
242 return fields( sorted, true ); 242 return fields( sorted, true );
243} 243}
244 244
245/*! 245/*!
246 \internal 246 \internal
247 Returns an untranslated list of field names for a contact. 247 Returns an untranslated list of field names for a contact.
248*/ 248*/
249QStringList OContactFields::untrfields( bool sorted ) 249QStringList OPimContactFields::untrfields( bool sorted )
250{ 250{
251 return fields( sorted, false ); 251 return fields( sorted, false );
252} 252}
253 253
254QMap<int, QString> OContactFields::idToTrFields() 254QMap<int, QString> OPimContactFields::idToTrFields()
255{ 255{
256 QMap<int, QString> ret_map; 256 QMap<int, QString> ret_map;
257 257
258 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); 258 ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) );
259 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); 259 ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) );
260 260
261 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) ); 261 ret_map.insert( Qtopia::Title, QObject::tr( "Name Title" ) );
262 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) ); 262 ret_map.insert( Qtopia::FirstName, QObject::tr( "First Name" ) );
263 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) ); 263 ret_map.insert( Qtopia::MiddleName, QObject::tr( "Middle Name" ) );
264 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) ); 264 ret_map.insert( Qtopia::LastName, QObject::tr( "Last Name" ) );
265 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) ); 265 ret_map.insert( Qtopia::Suffix, QObject::tr( "Suffix" ) );
266 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) ); 266 ret_map.insert( Qtopia::FileAs, QObject::tr( "File As" ) );
267 267
268 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) ); 268 ret_map.insert( Qtopia::JobTitle, QObject::tr( "Job Title" ) );
269 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) ); 269 ret_map.insert( Qtopia::Department, QObject::tr( "Department" ) );
270 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) ); 270 ret_map.insert( Qtopia::Company, QObject::tr( "Company" ) );
271 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) ); 271 ret_map.insert( Qtopia::BusinessPhone, QObject::tr( "Business Phone" ) );
272 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) ); 272 ret_map.insert( Qtopia::BusinessFax, QObject::tr( "Business Fax" ) );
273 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) ); 273 ret_map.insert( Qtopia::BusinessMobile, QObject::tr( "Business Mobile" ) );
274 274
275 // email 275 // email
276 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) ); 276 ret_map.insert( Qtopia::DefaultEmail, QObject::tr( "Default Email" ) );
277 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) ); 277 ret_map.insert( Qtopia::Emails, QObject::tr( "Emails" ) );
278 278
279 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) ); 279 ret_map.insert( Qtopia::HomePhone, QObject::tr( "Home Phone" ) );
280 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) ); 280 ret_map.insert( Qtopia::HomeFax, QObject::tr( "Home Fax" ) );
281 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) ); 281 ret_map.insert( Qtopia::HomeMobile, QObject::tr( "Home Mobile" ) );
282 282
283 // business 283 // business
284 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) ); 284 ret_map.insert( Qtopia::BusinessStreet, QObject::tr( "Business Street" ) );
285 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) ); 285 ret_map.insert( Qtopia::BusinessCity, QObject::tr( "Business City" ) );
286 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) ); 286 ret_map.insert( Qtopia::BusinessState, QObject::tr( "Business State" ) );
287 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) ); 287 ret_map.insert( Qtopia::BusinessZip, QObject::tr( "Business Zip" ) );
288 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) ); 288 ret_map.insert( Qtopia::BusinessCountry, QObject::tr( "Business Country" ) );
289 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) ); 289 ret_map.insert( Qtopia::BusinessPager, QObject::tr( "Business Pager" ) );
290 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) ); 290 ret_map.insert( Qtopia::BusinessWebPage, QObject::tr( "Business WebPage" ) );
291 291
292 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) ); 292 ret_map.insert( Qtopia::Office, QObject::tr( "Office" ) );
293 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) ); 293 ret_map.insert( Qtopia::Profession, QObject::tr( "Profession" ) );
294 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) ); 294 ret_map.insert( Qtopia::Assistant, QObject::tr( "Assistant" ) );
295 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) ); 295 ret_map.insert( Qtopia::Manager, QObject::tr( "Manager" ) );
296 296
297 // home 297 // home
298 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) ); 298 ret_map.insert( Qtopia::HomeStreet, QObject::tr( "Home Street" ) );
299 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) ); 299 ret_map.insert( Qtopia::HomeCity, QObject::tr( "Home City" ) );
300 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) ); 300 ret_map.insert( Qtopia::HomeState, QObject::tr( "Home State" ) );
301 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) ); 301 ret_map.insert( Qtopia::HomeZip, QObject::tr( "Home Zip" ) );
302 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) ); 302 ret_map.insert( Qtopia::HomeCountry, QObject::tr( "Home Country" ) );
303 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) ); 303 ret_map.insert( Qtopia::HomeWebPage, QObject::tr( "Home Web Page" ) );
304 304
305 //personal 305 //personal
306 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) ); 306 ret_map.insert( Qtopia::Spouse, QObject::tr( "Spouse" ) );
307 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) ); 307 ret_map.insert( Qtopia::Gender, QObject::tr( "Gender" ) );
308 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) ); 308 ret_map.insert( Qtopia::Birthday, QObject::tr( "Birthday" ) );
309 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) ); 309 ret_map.insert( Qtopia::Anniversary, QObject::tr( "Anniversary" ) );
310 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) ); 310 ret_map.insert( Qtopia::Nickname, QObject::tr( "Nickname" ) );
311 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) ); 311 ret_map.insert( Qtopia::Children, QObject::tr( "Children" ) );
312 312
313 // other 313 // other
314 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) ); 314 ret_map.insert( Qtopia::Notes, QObject::tr( "Notes" ) );
315 315
316 316
317 return ret_map; 317 return ret_map;
318} 318}
319 319
320QMap<int, QString> OContactFields::idToUntrFields() 320QMap<int, QString> OPimContactFields::idToUntrFields()
321{ 321{
322 QMap<int, QString> ret_map; 322 QMap<int, QString> ret_map;
323 323
324 ret_map.insert( Qtopia::AddressUid, "User Id" ); 324 ret_map.insert( Qtopia::AddressUid, "User Id" );
325 ret_map.insert( Qtopia::AddressCategory, "Categories" ); 325 ret_map.insert( Qtopia::AddressCategory, "Categories" );
326 326
327 ret_map.insert( Qtopia::Title, "Name Title" ); 327 ret_map.insert( Qtopia::Title, "Name Title" );
328 ret_map.insert( Qtopia::FirstName, "First Name" ); 328 ret_map.insert( Qtopia::FirstName, "First Name" );
329 ret_map.insert( Qtopia::MiddleName, "Middle Name" ); 329 ret_map.insert( Qtopia::MiddleName, "Middle Name" );
330 ret_map.insert( Qtopia::LastName, "Last Name" ); 330 ret_map.insert( Qtopia::LastName, "Last Name" );
331 ret_map.insert( Qtopia::Suffix, "Suffix" ); 331 ret_map.insert( Qtopia::Suffix, "Suffix" );
332 ret_map.insert( Qtopia::FileAs, "File As" ); 332 ret_map.insert( Qtopia::FileAs, "File As" );
333 333
334 ret_map.insert( Qtopia::JobTitle, "Job Title" ); 334 ret_map.insert( Qtopia::JobTitle, "Job Title" );
335 ret_map.insert( Qtopia::Department, "Department" ); 335 ret_map.insert( Qtopia::Department, "Department" );
336 ret_map.insert( Qtopia::Company, "Company" ); 336 ret_map.insert( Qtopia::Company, "Company" );
337 ret_map.insert( Qtopia::BusinessPhone, "Business Phone" ); 337 ret_map.insert( Qtopia::BusinessPhone, "Business Phone" );
338 ret_map.insert( Qtopia::BusinessFax, "Business Fax" ); 338 ret_map.insert( Qtopia::BusinessFax, "Business Fax" );
339 ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" ); 339 ret_map.insert( Qtopia::BusinessMobile, "Business Mobile" );
340 340
341 // email 341 // email
342 ret_map.insert( Qtopia::DefaultEmail, "Default Email" ); 342 ret_map.insert( Qtopia::DefaultEmail, "Default Email" );
343 ret_map.insert( Qtopia::Emails, "Emails" ); 343 ret_map.insert( Qtopia::Emails, "Emails" );
344 344
345 ret_map.insert( Qtopia::HomePhone, "Home Phone" ); 345 ret_map.insert( Qtopia::HomePhone, "Home Phone" );
346 ret_map.insert( Qtopia::HomeFax, "Home Fax" ); 346 ret_map.insert( Qtopia::HomeFax, "Home Fax" );
347 ret_map.insert( Qtopia::HomeMobile, "Home Mobile" ); 347 ret_map.insert( Qtopia::HomeMobile, "Home Mobile" );
348 348
349 // business 349 // business
350 ret_map.insert( Qtopia::BusinessStreet, "Business Street" ); 350 ret_map.insert( Qtopia::BusinessStreet, "Business Street" );
351 ret_map.insert( Qtopia::BusinessCity, "Business City" ); 351 ret_map.insert( Qtopia::BusinessCity, "Business City" );
352 ret_map.insert( Qtopia::BusinessState, "Business State" ); 352 ret_map.insert( Qtopia::BusinessState, "Business State" );
353 ret_map.insert( Qtopia::BusinessZip, "Business Zip" ); 353 ret_map.insert( Qtopia::BusinessZip, "Business Zip" );
354 ret_map.insert( Qtopia::BusinessCountry, "Business Country" ); 354 ret_map.insert( Qtopia::BusinessCountry, "Business Country" );
355 ret_map.insert( Qtopia::BusinessPager, "Business Pager" ); 355 ret_map.insert( Qtopia::BusinessPager, "Business Pager" );
356 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" ); 356 ret_map.insert( Qtopia::BusinessWebPage, "Business WebPage" );
357 357
358 ret_map.insert( Qtopia::Office, "Office" ); 358 ret_map.insert( Qtopia::Office, "Office" );
359 ret_map.insert( Qtopia::Profession, "Profession" ); 359 ret_map.insert( Qtopia::Profession, "Profession" );
360 ret_map.insert( Qtopia::Assistant, "Assistant" ); 360 ret_map.insert( Qtopia::Assistant, "Assistant" );
361 ret_map.insert( Qtopia::Manager, "Manager" ); 361 ret_map.insert( Qtopia::Manager, "Manager" );
362 362
363 // home 363 // home
364 ret_map.insert( Qtopia::HomeStreet, "Home Street" ); 364 ret_map.insert( Qtopia::HomeStreet, "Home Street" );
365 ret_map.insert( Qtopia::HomeCity, "Home City" ); 365 ret_map.insert( Qtopia::HomeCity, "Home City" );
366 ret_map.insert( Qtopia::HomeState, "Home State" ); 366 ret_map.insert( Qtopia::HomeState, "Home State" );
367 ret_map.insert( Qtopia::HomeZip, "Home Zip" ); 367 ret_map.insert( Qtopia::HomeZip, "Home Zip" );
368 ret_map.insert( Qtopia::HomeCountry, "Home Country" ); 368 ret_map.insert( Qtopia::HomeCountry, "Home Country" );
369 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); 369 ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" );
370 370
371 //personal 371 //personal
372 ret_map.insert( Qtopia::Spouse, "Spouse" ); 372 ret_map.insert( Qtopia::Spouse, "Spouse" );
373 ret_map.insert( Qtopia::Gender, "Gender" ); 373 ret_map.insert( Qtopia::Gender, "Gender" );
374 ret_map.insert( Qtopia::Birthday, "Birthday" ); 374 ret_map.insert( Qtopia::Birthday, "Birthday" );
375 ret_map.insert( Qtopia::Anniversary, "Anniversary" ); 375 ret_map.insert( Qtopia::Anniversary, "Anniversary" );
376 ret_map.insert( Qtopia::Nickname, "Nickname" ); 376 ret_map.insert( Qtopia::Nickname, "Nickname" );
377 ret_map.insert( Qtopia::Children, "Children" ); 377 ret_map.insert( Qtopia::Children, "Children" );
378 378
379 // other 379 // other
380 ret_map.insert( Qtopia::Notes, "Notes" ); 380 ret_map.insert( Qtopia::Notes, "Notes" );
381 ret_map.insert( Qtopia::Groups, "Groups" ); 381 ret_map.insert( Qtopia::Groups, "Groups" );
382 382
383 383
384 return ret_map; 384 return ret_map;
385} 385}
386 386
387QMap<QString, int> OContactFields::trFieldsToId() 387QMap<QString, int> OPimContactFields::trFieldsToId()
388{ 388{
389 QMap<int, QString> idtostr = idToTrFields(); 389 QMap<int, QString> idtostr = idToTrFields();
390 QMap<QString, int> ret_map; 390 QMap<QString, int> ret_map;
391 391
392 392
393 QMap<int, QString>::Iterator it; 393 QMap<int, QString>::Iterator it;
394 for ( it = idtostr.begin(); it != idtostr.end(); ++it ) 394 for ( it = idtostr.begin(); it != idtostr.end(); ++it )
395 ret_map.insert( *it, it.key() ); 395 ret_map.insert( *it, it.key() );
396 396
397 397
398 return ret_map; 398 return ret_map;
399} 399}
400 400
401/* ======================================================================= */ 401/* ======================================================================= */
402 402
403QMap<QString, int> OContactFields::untrFieldsToId() 403QMap<QString, int> OPimContactFields::untrFieldsToId()
404{ 404{
405 QMap<int, QString> idtostr = idToUntrFields(); 405 QMap<int, QString> idtostr = idToUntrFields();
406 QMap<QString, int> ret_map; 406 QMap<QString, int> ret_map;
407 407
408 408
409 QMap<int, QString>::Iterator it; 409 QMap<int, QString>::Iterator it;
410 for ( it = idtostr.begin(); it != idtostr.end(); ++it ) 410 for ( it = idtostr.begin(); it != idtostr.end(); ++it )
411 ret_map.insert( *it, it.key() ); 411 ret_map.insert( *it, it.key() );
412 412
413 413
414 return ret_map; 414 return ret_map;
415} 415}
416 416
417 417
418OContactFields::OContactFields() : 418OPimContactFields::OPimContactFields() :
419 fieldOrder( DEFAULT_FIELD_ORDER ), 419 fieldOrder( DEFAULT_FIELD_ORDER ),
420 changedFieldOrder( false ) 420 changedFieldOrder( false )
421{ 421{
422 // Get the global field order from the config file and 422 // Get the global field order from the config file and
423 // use it as a start pattern 423 // use it as a start pattern
424 Config cfg ( "AddressBook" ); 424 Config cfg ( "AddressBook" );
425 cfg.setGroup( "ContactFieldOrder" ); 425 cfg.setGroup( "ContactFieldOrder" );
426 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); 426 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
427} 427}
428 428
429OContactFields::~OContactFields() 429OPimContactFields::~OPimContactFields()
430{ 430{
431 431
432 // We will store the fieldorder into the config file 432 // We will store the fieldorder into the config file
433 // to reuse it for the future.. 433 // to reuse it for the future..
434 if ( changedFieldOrder ) 434 if ( changedFieldOrder )
435 { 435 {
436 Config cfg ( "AddressBook" ); 436 Config cfg ( "AddressBook" );
437 cfg.setGroup( "ContactFieldOrder" ); 437 cfg.setGroup( "ContactFieldOrder" );
438 cfg.writeEntry( "General", globalFieldOrder ); 438 cfg.writeEntry( "General", globalFieldOrder );
439 } 439 }
440} 440}
441 441
442 442
443 443
444void OContactFields::saveToRecord( OContact &cnt ) 444void OPimContactFields::saveToRecord( OPimContact &cnt )
445{ 445{
446 446
447 qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); 447 qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() );
448 448
449 // Store fieldorder into this contact. 449 // Store fieldorder into this contact.
450 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); 450 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
451 451
452 globalFieldOrder = fieldOrder; 452 globalFieldOrder = fieldOrder;
453 changedFieldOrder = true; 453 changedFieldOrder = true;
454 454
455} 455}
456 456
457void OContactFields::loadFromRecord( const OContact &cnt ) 457void OPimContactFields::loadFromRecord( const OPimContact &cnt )
458{ 458{
459 qDebug( "ocontactfields loadFromRecord" ); 459 qDebug( "ocontactfields loadFromRecord" );
460 qDebug( "loading >%s<", cnt.fullName().latin1() ); 460 qDebug( "loading >%s<", cnt.fullName().latin1() );
461 461
462 // Get fieldorder for this contact. If none is defined, 462 // Get fieldorder for this contact. If none is defined,
463 // we will use the global one from the config file.. 463 // we will use the global one from the config file..
464 464
465 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); 465 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
466 466
467 qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); 467 qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() );
468 468
469 if ( fieldOrder.isEmpty() ) 469 if ( fieldOrder.isEmpty() )
470 { 470 {
471 fieldOrder = globalFieldOrder; 471 fieldOrder = globalFieldOrder;
472 } 472 }
473 473
474 474
475 qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); 475 qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() );
476} 476}
477 477
478void OContactFields::setFieldOrder( int num, int index ) 478void OPimContactFields::setFieldOrder( int num, int index )
479{ 479{
480 qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); 480 qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index );
481 481
482 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; 482 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ];
483 483
484 // We will store this new fieldorder globally to 484 // We will store this new fieldorder globally to
485 // remember it for contacts which have none 485 // remember it for contacts which have none
486 globalFieldOrder = fieldOrder; 486 globalFieldOrder = fieldOrder;
487 changedFieldOrder = true; 487 changedFieldOrder = true;
488 488
489 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 489 qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
490} 490}
491 491
492int OContactFields::getFieldOrder( int num, int defIndex ) 492int OPimContactFields::getFieldOrder( int num, int defIndex )
493{ 493{
494 qDebug( "ocontactfields getFieldOrder" ); 494 qDebug( "ocontactfields getFieldOrder" );
495 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 495 qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
496 496
497 // Get index of combo as char.. 497 // Get index of combo as char..
498 QChar poschar = fieldOrder[ num ]; 498 QChar poschar = fieldOrder[ num ];
499 499
500 bool ok; 500 bool ok;
501 int ret = 0; 501 int ret = 0;
502 // Convert char to number.. 502 // Convert char to number..
503 if ( !( poschar == QChar::null ) ) 503 if ( !( poschar == QChar::null ) )
504 ret = QString( poschar ).toInt( &ok, 16 ); 504 ret = QString( poschar ).toInt( &ok, 16 );
505 else 505 else
506 ok = false; 506 ok = false;
507 507
508 // Return default value if index for 508 // Return default value if index for
509 // num was not set or if anything else happened.. 509 // num was not set or if anything else happened..
510 if ( !ok ) ret = defIndex; 510 if ( !ok ) ret = defIndex;
511 511
512 qDebug( "returning >%i<", ret ); 512 qDebug( "returning >%i<", ret );
513 513
514 return ret; 514 return ret;
515 515
516} 516}
517 517
518} 518}
diff --git a/libopie2/opiepim/ocontactfields.h b/libopie2/opiepim/core/opimcontactfields.h
index 9e89532..3aa3894 100644
--- a/libopie2/opiepim/ocontactfields.h
+++ b/libopie2/opiepim/core/opimcontactfields.h
@@ -1,102 +1,102 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OCONTACTFIELDS_H 30#ifndef OCONTACTFIELDS_H
31#define OCONTACTFIELDS_H 31#define OCONTACTFIELDS_H
32 32
33class QStringList; 33class QStringList;
34 34
35/* OPIE */ 35/* OPIE */
36#include <opie2/ocontact.h> 36#include <opie2/opimcontact.h>
37 37
38/* QT */ 38/* QT */
39#include <qmap.h> 39#include <qmap.h>
40#include <qstring.h> 40#include <qstring.h>
41 41
42#define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order" 42#define CONTACT_FIELD_ORDER_NAME "opie-contactfield-order"
43#define DEFAULT_FIELD_ORDER "__________" 43#define DEFAULT_FIELD_ORDER "__________"
44 44
45namespace Opie 45namespace Opie
46{ 46{
47class OContactFields 47class OPimContactFields
48{ 48{
49 49
50 public: 50 public:
51 OContactFields(); 51 OPimContactFields();
52 ~OContactFields(); 52 ~OPimContactFields();
53 /** Set the index for combo boxes. 53 /** Set the index for combo boxes.
54 * Sets the <b>index</b> of combo <b>num</b>. 54 * Sets the <b>index</b> of combo <b>num</b>.
55 * @param num selects the number of the combo 55 * @param num selects the number of the combo
56 * @param index sets the index in the combo 56 * @param index sets the index in the combo
57 */ 57 */
58 void setFieldOrder( int num, int index ); 58 void setFieldOrder( int num, int index );
59 59
60 /** Get the index for combo boxes. 60 /** Get the index for combo boxes.
61 * Returns the index of combo <b>num</b> or defindex 61 * Returns the index of combo <b>num</b> or defindex
62 * if none was defined.. 62 * if none was defined..
63 * @param num Selects the number of the combo 63 * @param num Selects the number of the combo
64 * @param defIndex will be returned if none was defined (either 64 * @param defIndex will be returned if none was defined (either
65 * globally in the config file, nor by the contact which was used 65 * globally in the config file, nor by the contact which was used
66 * by loadFromRecord() ) 66 * by loadFromRecord() )
67 */ 67 */
68 int getFieldOrder( int num, int defIndex ); 68 int getFieldOrder( int num, int defIndex );
69 69
70 /** Store fieldorder to contact. */ 70 /** Store fieldorder to contact. */
71 void saveToRecord( OContact& ); 71 void saveToRecord( OPimContact& );
72 /** Get Fieldorder from contact. */ 72 /** Get Fieldorder from contact. */
73 void loadFromRecord( const OContact& ); 73 void loadFromRecord( const OPimContact& );
74 74
75 private: 75 private:
76 QString fieldOrder; 76 QString fieldOrder;
77 QString globalFieldOrder; 77 QString globalFieldOrder;
78 bool changedFieldOrder; 78 bool changedFieldOrder;
79 79
80 public: 80 public:
81 static QStringList personalfields( bool sorted = true, bool translated = false ); 81 static QStringList personalfields( bool sorted = true, bool translated = false );
82 static QStringList phonefields( bool sorted = true, bool translated = false ); 82 static QStringList phonefields( bool sorted = true, bool translated = false );
83 static QStringList detailsfields( bool sorted = true, bool translated = false ); 83 static QStringList detailsfields( bool sorted = true, bool translated = false );
84 static QStringList fields( bool sorted = true, bool translated = false ); 84 static QStringList fields( bool sorted = true, bool translated = false );
85 85
86 static QStringList trpersonalfields( bool sorted = true ); 86 static QStringList trpersonalfields( bool sorted = true );
87 static QStringList untrpersonalfields( bool sorted = true ); 87 static QStringList untrpersonalfields( bool sorted = true );
88 static QStringList trphonefields( bool sorted = true ); 88 static QStringList trphonefields( bool sorted = true );
89 static QStringList untrphonefields( bool sorted = true ); 89 static QStringList untrphonefields( bool sorted = true );
90 static QStringList trdetailsfields( bool sorted = true ); 90 static QStringList trdetailsfields( bool sorted = true );
91 static QStringList untrdetailsfields( bool sorted = true ); 91 static QStringList untrdetailsfields( bool sorted = true );
92 static QStringList trfields( bool sorted = true ); 92 static QStringList trfields( bool sorted = true );
93 static QStringList untrfields( bool sorted = true ); 93 static QStringList untrfields( bool sorted = true );
94 94
95 static QMap<int, QString> idToTrFields(); 95 static QMap<int, QString> idToTrFields();
96 static QMap<QString, int> trFieldsToId(); 96 static QMap<QString, int> trFieldsToId();
97 static QMap<int, QString> idToUntrFields(); 97 static QMap<int, QString> idToUntrFields();
98 static QMap<QString, int> untrFieldsToId(); 98 static QMap<QString, int> untrFieldsToId();
99 99
100}; 100};
101} 101}
102#endif 102#endif
diff --git a/libopie2/opiepim/core/oconversion.cpp b/libopie2/opiepim/core/opimdateconversion.cpp
index 160c2c6..8bf891b 100644
--- a/libopie2/opiepim/core/oconversion.cpp
+++ b/libopie2/opiepim/core/opimdateconversion.cpp
@@ -1,143 +1,143 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 .=l. 4 .=l.
5 .>+-= 5 .>+-=
6_;:, .> :=|. This program is free software; you can 6_;:, .> :=|. This program is free software; you can
7.> <`_, > . <= redistribute it and/or modify it under 7.> <`_, > . <= redistribute it and/or modify it under
8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 8:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
9.="- .-=="i, .._ License as published by the Free Software 9.="- .-=="i, .._ License as published by the Free Software
10- . .-<_> .<> Foundation; either version 2 of the License, 10- . .-<_> .<> Foundation; either version 2 of the License,
11 ._= =} : or (at your option) any later version. 11 ._= =} : or (at your option) any later version.
12 .%`+i> _;_. 12 .%`+i> _;_.
13 .i_,=:_. -<s. This program is distributed in the hope that 13 .i_,=:_. -<s. This program is distributed in the hope that
14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 14 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
15 : .. .:, . . . without even the implied warranty of 15 : .. .:, . . . without even the implied warranty of
16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 16 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 17 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.= = ; Library General Public License for more 18..}^=.= = ; Library General Public License for more
19++= -. .` .: details. 19++= -. .` .: details.
20: = ...= . :.=- 20: = ...= . :.=-
21-. .:....=;==+<; You should have received a copy of the GNU 21-. .:....=;==+<; You should have received a copy of the GNU
22 -_. . . )=. = Library General Public License along with 22 -_. . . )=. = Library General Public License along with
23 -- :-=` this library; see the file COPYING.LIB. 23 -- :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29/* OPIE */ 29/* OPIE */
30#include <opie2/oconversion.h> 30#include <opie2/opimdateconversion.h>
31#include <qpe/timeconversion.h> 31#include <qpe/timeconversion.h>
32 32
33namespace Opie 33namespace Opie
34{ 34{
35 35
36QString OConversion::dateToString( const QDate &d ) 36QString OPimDateConversion::dateToString( const QDate &d )
37{ 37{
38 if ( d.isNull() || !d.isValid() ) 38 if ( d.isNull() || !d.isValid() )
39 return QString::null; 39 return QString::null;
40 40
41 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 41 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
42 QString year = QString::number( d.year() ); 42 QString year = QString::number( d.year() );
43 QString month = QString::number( d.month() ); 43 QString month = QString::number( d.month() );
44 month = month.rightJustify( 2, '0' ); 44 month = month.rightJustify( 2, '0' );
45 QString day = QString::number( d.day() ); 45 QString day = QString::number( d.day() );
46 day = day.rightJustify( 2, '0' ); 46 day = day.rightJustify( 2, '0' );
47 47
48 QString str = year + month + day; 48 QString str = year + month + day;
49 //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); 49 //qDebug( "\tPimContact dateToStr = %s", str.latin1() );
50 50
51 return str; 51 return str;
52} 52}
53 53
54 54
55QDate OConversion::dateFromString( const QString& s ) 55QDate OPimDateConversion::dateFromString( const QString& s )
56{ 56{
57 QDate date; 57 QDate date;
58 58
59 if ( s.isEmpty() ) 59 if ( s.isEmpty() )
60 return date; 60 return date;
61 61
62 // Be backward compatible to old Opie format: 62 // Be backward compatible to old Opie format:
63 // Try to load old format. If it fails, try new ISO-Format! 63 // Try to load old format. If it fails, try new ISO-Format!
64 date = TimeConversion::fromString ( s ); 64 date = TimeConversion::fromString ( s );
65 if ( date.isValid() ) 65 if ( date.isValid() )
66 return date; 66 return date;
67 67
68 // Read ISO-Format (YYYYMMDD) 68 // Read ISO-Format (YYYYMMDD)
69 int year = s.mid( 0, 4 ).toInt(); 69 int year = s.mid( 0, 4 ).toInt();
70 int month = s.mid( 4, 2 ).toInt(); 70 int month = s.mid( 4, 2 ).toInt();
71 int day = s.mid( 6, 2 ).toInt(); 71 int day = s.mid( 6, 2 ).toInt();
72 72
73 // do some quick sanity checking -eilers 73 // do some quick sanity checking -eilers
74 // but we isValid() again? -zecke 74 // but we isValid() again? -zecke
75 if ( year < 1900 || year > 3000 ) 75 if ( year < 1900 || year > 3000 )
76 { 76 {
77 qWarning( "PimContact year is not in range" ); 77 qWarning( "PimContact year is not in range" );
78 return date; 78 return date;
79 } 79 }
80 if ( month < 0 || month > 12 ) 80 if ( month < 0 || month > 12 )
81 { 81 {
82 qWarning( "PimContact month is not in range" ); 82 qWarning( "PimContact month is not in range" );
83 return date; 83 return date;
84 } 84 }
85 if ( day < 0 || day > 31 ) 85 if ( day < 0 || day > 31 )
86 { 86 {
87 qWarning( "PimContact day is not in range" ); 87 qWarning( "PimContact day is not in range" );
88 return date; 88 return date;
89 } 89 }
90 90
91 date.setYMD( year, month, day ); 91 date.setYMD( year, month, day );
92 if ( !date.isValid() ) 92 if ( !date.isValid() )
93 { 93 {
94 qWarning( "PimContact date is not valid" ); 94 qWarning( "PimContact date is not valid" );
95 return date; 95 return date;
96 } 96 }
97 97
98 return date; 98 return date;
99} 99}
100 100
101 101
102QString OConversion::dateTimeToString( const QDateTime& dt ) 102QString OPimDateConversion::dateTimeToString( const QDateTime& dt )
103{ 103{
104 if ( !dt.isValid() || dt.isNull() ) 104 if ( !dt.isValid() || dt.isNull() )
105 return QString::null; 105 return QString::null;
106 106
107 QString year = QString::number( dt.date().year() ); 107 QString year = QString::number( dt.date().year() );
108 QString month = QString::number( dt.date().month() ); 108 QString month = QString::number( dt.date().month() );
109 QString day = QString::number( dt.date().day() ); 109 QString day = QString::number( dt.date().day() );
110 110
111 QString hour = QString::number( dt.time().hour() ); 111 QString hour = QString::number( dt.time().hour() );
112 QString min = QString::number( dt.time().minute() ); 112 QString min = QString::number( dt.time().minute() );
113 QString sec = QString::number( dt.time().second() ); 113 QString sec = QString::number( dt.time().second() );
114 114
115 month = month.rightJustify( 2, '0' ); 115 month = month.rightJustify( 2, '0' );
116 day = day. rightJustify( 2, '0' ); 116 day = day. rightJustify( 2, '0' );
117 hour = hour. rightJustify( 2, '0' ); 117 hour = hour. rightJustify( 2, '0' );
118 min = min. rightJustify( 2, '0' ); 118 min = min. rightJustify( 2, '0' );
119 sec = sec. rightJustify( 2, '0' ); 119 sec = sec. rightJustify( 2, '0' );
120 120
121 return day + month + year + hour + min + sec; 121 return day + month + year + hour + min + sec;
122} 122}
123 123
124 124
125QDateTime OConversion::dateTimeFromString( const QString& str ) 125QDateTime OPimDateConversion::dateTimeFromString( const QString& str )
126{ 126{
127 127
128 if ( str.isEmpty() ) 128 if ( str.isEmpty() )
129 return QDateTime(); 129 return QDateTime();
130 int day = str.mid( 0, 2 ).toInt(); 130 int day = str.mid( 0, 2 ).toInt();
131 int month = str.mid( 2, 2 ).toInt(); 131 int month = str.mid( 2, 2 ).toInt();
132 int year = str.mid( 4, 4 ).toInt(); 132 int year = str.mid( 4, 4 ).toInt();
133 int hour = str.mid( 8, 2 ).toInt(); 133 int hour = str.mid( 8, 2 ).toInt();
134 int min = str.mid( 10, 2 ).toInt(); 134 int min = str.mid( 10, 2 ).toInt();
135 int sec = str.mid( 12, 2 ).toInt(); 135 int sec = str.mid( 12, 2 ).toInt();
136 136
137 QDate date( year, month, day ); 137 QDate date( year, month, day );
138 QTime time( hour, min, sec ); 138 QTime time( hour, min, sec );
139 QDateTime dt( date, time ); 139 QDateTime dt( date, time );
140 return dt; 140 return dt;
141} 141}
142 142
143} 143}
diff --git a/libopie2/opiepim/core/oconversion.h b/libopie2/opiepim/core/opimdateconversion.h
index eeb97e5..45536da 100644
--- a/libopie2/opiepim/core/oconversion.h
+++ b/libopie2/opiepim/core/opimdateconversion.h
@@ -1,61 +1,61 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OCONVERSION_H 30#ifndef OCONVERSION_H
31#define OCONVERSION_H 31#define OCONVERSION_H
32 32
33/* QT */ 33/* QT */
34#include <qdatetime.h> 34#include <qdatetime.h>
35 35
36namespace Opie { 36namespace Opie {
37 37
38class OConversion 38class OPimDateConversion
39{ 39{
40public: 40public:
41 static QString dateToString( const QDate &d ); 41 static QString dateToString( const QDate &d );
42 static QDate dateFromString( const QString &datestr ); 42 static QDate dateFromString( const QString &datestr );
43 43
44 /** 44 /**
45 * simple function to store DateTime as string and read from string 45 * simple function to store DateTime as string and read from string
46 * no timezone changing is done 46 * no timezone changing is done
47 * DDMMYYYYHHMMSS is the simple format 47 * DDMMYYYYHHMMSS is the simple format
48 */ 48 */
49 static QString dateTimeToString( const QDateTime& ); 49 static QString dateTimeToString( const QDateTime& );
50 static QDateTime dateTimeFromString( const QString& ); 50 static QDateTime dateTimeFromString( const QString& );
51 51
52private: 52private:
53 class Private; 53 class Private;
54 Private* d; 54 Private* d;
55 55
56}; 56};
57 57
58} 58}
59 59
60#endif // __oconversion_h__ 60#endif // __oconversion_h__
61 61
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index d9cee2b..3ddbf85 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -1,1025 +1,1025 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "oevent.h" 30#include "opimevent.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/orecur.h> 33#include <opie2/opimrecurrence.h>
34#include <opie2/opimresolver.h> 34#include <opie2/opimresolver.h>
35#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <qpe/categories.h> 36#include <qpe/categories.h>
37#include <qpe/palmtopuidgen.h> 37#include <qpe/palmtopuidgen.h>
38#include <qpe/stringutil.h> 38#include <qpe/stringutil.h>
39 39
40/* QT */ 40/* QT */
41#include <qshared.h> 41#include <qshared.h>
42#include <qarray.h> 42#include <qarray.h>
43 43
44namespace Opie 44namespace Opie
45{ 45{
46 46
47int OCalendarHelper::week( const QDate& date ) 47int OCalendarHelper::week( const QDate& date )
48{ 48{
49 // Calculates the week this date is in within that 49 // Calculates the week this date is in within that
50 // month. Equals the "row" is is in in the month view 50 // month. Equals the "row" is is in in the month view
51 int week = 1; 51 int week = 1;
52 QDate tmp( date.year(), date.month(), 1 ); 52 QDate tmp( date.year(), date.month(), 1 );
53 if ( date.dayOfWeek() < tmp.dayOfWeek() ) 53 if ( date.dayOfWeek() < tmp.dayOfWeek() )
54 ++week; 54 ++week;
55 55
56 week += ( date.day() - 1 ) / 7; 56 week += ( date.day() - 1 ) / 7;
57 57
58 return week; 58 return week;
59} 59}
60 60
61 61
62int OCalendarHelper::ocurrence( const QDate& date ) 62int OCalendarHelper::ocurrence( const QDate& date )
63{ 63{
64 // calculates the number of occurrances of this day of the 64 // calculates the number of occurrances of this day of the
65 // week till the given date (e.g 3rd Wednesday of the month) 65 // week till the given date (e.g 3rd Wednesday of the month)
66 return ( date.day() - 1 ) / 7 + 1; 66 return ( date.day() - 1 ) / 7 + 1;
67} 67}
68 68
69 69
70int OCalendarHelper::dayOfWeek( char day ) 70int OCalendarHelper::dayOfWeek( char day )
71{ 71{
72 int dayOfWeek = 1; 72 int dayOfWeek = 1;
73 char i = ORecur::MON; 73 char i = OPimRecurrence::MON;
74 while ( !( i & day ) && i <= ORecur::SUN ) 74 while ( !( i & day ) && i <= OPimRecurrence::SUN )
75 { 75 {
76 i <<= 1; 76 i <<= 1;
77 ++dayOfWeek; 77 ++dayOfWeek;
78 } 78 }
79 return dayOfWeek; 79 return dayOfWeek;
80} 80}
81 81
82 82
83int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) 83int OCalendarHelper::monthDiff( const QDate& first, const QDate& second )
84{ 84{
85 return ( second.year() - first.year() ) * 12 + 85 return ( second.year() - first.year() ) * 12 +
86 second.month() - first.month(); 86 second.month() - first.month();
87} 87}
88 88
89 89
90struct OEvent::Data : public QShared 90struct OPimEvent::Data : public QShared
91{ 91{
92 Data() : QShared() 92 Data() : QShared()
93 { 93 {
94 child = 0; 94 child = 0;
95 recur = 0; 95 recur = 0;
96 manager = 0; 96 manager = 0;
97 isAllDay = false; 97 isAllDay = false;
98 parent = 0; 98 parent = 0;
99 } 99 }
100 ~Data() 100 ~Data()
101 { 101 {
102 delete manager; 102 delete manager;
103 delete recur; 103 delete recur;
104 } 104 }
105 QString description; 105 QString description;
106 QString location; 106 QString location;
107 OPimNotifyManager* manager; 107 OPimNotifyManager* manager;
108 ORecur* recur; 108 OPimRecurrence* recur;
109 QString note; 109 QString note;
110 QDateTime created; 110 QDateTime created;
111 QDateTime start; 111 QDateTime start;
112 QDateTime end; 112 QDateTime end;
113bool isAllDay : 1; 113bool isAllDay : 1;
114 QString timezone; 114 QString timezone;
115 QArray<int>* child; 115 QArray<int>* child;
116 int parent; 116 int parent;
117}; 117};
118 118
119 119
120OEvent::OEvent( int uid ) 120OPimEvent::OPimEvent( int uid )
121 : OPimRecord( uid ) 121 : OPimRecord( uid )
122{ 122{
123 data = new Data; 123 data = new Data;
124} 124}
125 125
126 126
127OEvent::OEvent( const OEvent& ev ) 127OPimEvent::OPimEvent( const OPimEvent& ev )
128 : OPimRecord( ev ), data( ev.data ) 128 : OPimRecord( ev ), data( ev.data )
129{ 129{
130 data->ref(); 130 data->ref();
131} 131}
132 132
133 133
134OEvent::OEvent( const QMap<int, QString> map ) 134OPimEvent::OPimEvent( const QMap<int, QString> map )
135 : OPimRecord( 0 ) 135 : OPimRecord( 0 )
136{ 136{
137 data = new Data; 137 data = new Data;
138 138
139 fromMap( map ); 139 fromMap( map );
140} 140}
141 141
142 142
143OEvent::~OEvent() 143OPimEvent::~OPimEvent()
144{ 144{
145 if ( data->deref() ) 145 if ( data->deref() )
146 { 146 {
147 delete data; 147 delete data;
148 data = 0; 148 data = 0;
149 } 149 }
150} 150}
151 151
152 152
153OEvent& OEvent::operator=( const OEvent& ev ) 153OPimEvent& OPimEvent::operator=( const OPimEvent& ev )
154{ 154{
155 if ( this == &ev ) return * this; 155 if ( this == &ev ) return * this;
156 156
157 OPimRecord::operator=( ev ); 157 OPimRecord::operator=( ev );
158 ev.data->ref(); 158 ev.data->ref();
159 deref(); 159 deref();
160 data = ev.data; 160 data = ev.data;
161 161
162 162
163 return *this; 163 return *this;
164} 164}
165 165
166 166
167QString OEvent::description() const 167QString OPimEvent::description() const
168{ 168{
169 return data->description; 169 return data->description;
170} 170}
171 171
172 172
173void OEvent::setDescription( const QString& description ) 173void OPimEvent::setDescription( const QString& description )
174{ 174{
175 changeOrModify(); 175 changeOrModify();
176 data->description = description; 176 data->description = description;
177} 177}
178 178
179 179
180void OEvent::setLocation( const QString& loc ) 180void OPimEvent::setLocation( const QString& loc )
181{ 181{
182 changeOrModify(); 182 changeOrModify();
183 data->location = loc; 183 data->location = loc;
184} 184}
185 185
186 186
187QString OEvent::location() const 187QString OPimEvent::location() const
188{ 188{
189 return data->location; 189 return data->location;
190} 190}
191 191
192 192
193OPimNotifyManager &OEvent::notifiers() const 193OPimNotifyManager &OPimEvent::notifiers() const
194{ 194{
195 // I hope we can skip the changeOrModify here 195 // I hope we can skip the changeOrModify here
196 // the notifier should take care of it 196 // the notifier should take care of it
197 // and OPimNotify is shared too 197 // and OPimNotify is shared too
198 if ( !data->manager ) 198 if ( !data->manager )
199 data->manager = new OPimNotifyManager; 199 data->manager = new OPimNotifyManager;
200 200
201 return *data->manager; 201 return *data->manager;
202} 202}
203 203
204 204
205bool OEvent::hasNotifiers() const 205bool OPimEvent::hasNotifiers() const
206{ 206{
207 if ( !data->manager ) 207 if ( !data->manager )
208 return false; 208 return false;
209 if ( data->manager->reminders().isEmpty() && 209 if ( data->manager->reminders().isEmpty() &&
210 data->manager->alarms().isEmpty() ) 210 data->manager->alarms().isEmpty() )
211 return false; 211 return false;
212 212
213 return true; 213 return true;
214} 214}
215 215
216 216
217ORecur OEvent::recurrence() const 217OPimRecurrence OPimEvent::recurrence() const
218{ 218{
219 if ( !data->recur ) 219 if ( !data->recur )
220 data->recur = new ORecur; 220 data->recur = new OPimRecurrence;
221 221
222 return *data->recur; 222 return *data->recur;
223} 223}
224 224
225 225
226void OEvent::setRecurrence( const ORecur& rec ) 226void OPimEvent::setRecurrence( const OPimRecurrence& rec )
227{ 227{
228 changeOrModify(); 228 changeOrModify();
229 if ( data->recur ) 229 if ( data->recur )
230 ( *data->recur ) = rec; 230 ( *data->recur ) = rec;
231 else 231 else
232 data->recur = new ORecur( rec ); 232 data->recur = new OPimRecurrence( rec );
233} 233}
234 234
235 235
236bool OEvent::hasRecurrence() const 236bool OPimEvent::hasRecurrence() const
237{ 237{
238 if ( !data->recur ) return false; 238 if ( !data->recur ) return false;
239 return data->recur->doesRecur(); 239 return data->recur->doesRecur();
240} 240}
241 241
242 242
243QString OEvent::note() const 243QString OPimEvent::note() const
244{ 244{
245 return data->note; 245 return data->note;
246} 246}
247 247
248 248
249void OEvent::setNote( const QString& note ) 249void OPimEvent::setNote( const QString& note )
250{ 250{
251 changeOrModify(); 251 changeOrModify();
252 data->note = note; 252 data->note = note;
253} 253}
254 254
255 255
256QDateTime OEvent::createdDateTime() const 256QDateTime OPimEvent::createdDateTime() const
257{ 257{
258 return data->created; 258 return data->created;
259} 259}
260 260
261 261
262void OEvent::setCreatedDateTime( const QDateTime& time ) 262void OPimEvent::setCreatedDateTime( const QDateTime& time )
263{ 263{
264 changeOrModify(); 264 changeOrModify();
265 data->created = time; 265 data->created = time;
266} 266}
267 267
268 268
269QDateTime OEvent::startDateTime() const 269QDateTime OPimEvent::startDateTime() const
270{ 270{
271 if ( data->isAllDay ) 271 if ( data->isAllDay )
272 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) ); 272 return QDateTime( data->start.date(), QTime( 0, 0, 0 ) );
273 return data->start; 273 return data->start;
274} 274}
275 275
276 276
277QDateTime OEvent::startDateTimeInZone() const 277QDateTime OPimEvent::startDateTimeInZone() const
278{ 278{
279 /* if no timezone, or all day event or if the current and this timeZone match... */ 279 /* if no timezone, or all day event or if the current and this timeZone match... */
280 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); 280 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return startDateTime();
281 281
282 OTimeZone zone( data->timezone ); 282 OPimTimeZone zone( data->timezone );
283 return zone.toDateTime( data->start, OTimeZone::current() ); 283 return zone.toDateTime( data->start, OPimTimeZone::current() );
284} 284}
285 285
286 286
287void OEvent::setStartDateTime( const QDateTime& dt ) 287void OPimEvent::setStartDateTime( const QDateTime& dt )
288{ 288{
289 changeOrModify(); 289 changeOrModify();
290 data->start = dt; 290 data->start = dt;
291} 291}
292 292
293 293
294QDateTime OEvent::endDateTime() const 294QDateTime OPimEvent::endDateTime() const
295{ 295{
296 /* 296 /*
297 * if all Day event the end time needs 297 * if all Day event the end time needs
298 * to be on the same day as the start 298 * to be on the same day as the start
299 */ 299 */
300 if ( data->isAllDay ) 300 if ( data->isAllDay )
301 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) ); 301 return QDateTime( data->start.date(), QTime( 23, 59, 59 ) );
302 return data->end; 302 return data->end;
303} 303}
304 304
305 305
306QDateTime OEvent::endDateTimeInZone() const 306QDateTime OPimEvent::endDateTimeInZone() const
307{ 307{
308 /* if no timezone, or all day event or if the current and this timeZone match... */ 308 /* if no timezone, or all day event or if the current and this timeZone match... */
309 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); 309 if ( data->timezone.isEmpty() || data->isAllDay || data->timezone == OPimTimeZone::current().timeZone() ) return endDateTime();
310 310
311 OTimeZone zone( data->timezone ); 311 OPimTimeZone zone( data->timezone );
312 return zone.toDateTime( data->end, OTimeZone::current() ); 312 return zone.toDateTime( data->end, OPimTimeZone::current() );
313} 313}
314 314
315 315
316void OEvent::setEndDateTime( const QDateTime& dt ) 316void OPimEvent::setEndDateTime( const QDateTime& dt )
317{ 317{
318 changeOrModify(); 318 changeOrModify();
319 data->end = dt; 319 data->end = dt;
320} 320}
321 321
322 322
323bool OEvent::isMultipleDay() const 323bool OPimEvent::isMultipleDay() const
324{ 324{
325 return data->end.date().day() - data->start.date().day(); 325 return data->end.date().day() - data->start.date().day();
326} 326}
327 327
328 328
329bool OEvent::isAllDay() const 329bool OPimEvent::isAllDay() const
330{ 330{
331 return data->isAllDay; 331 return data->isAllDay;
332} 332}
333 333
334 334
335void OEvent::setAllDay( bool allDay ) 335void OPimEvent::setAllDay( bool allDay )
336{ 336{
337 changeOrModify(); 337 changeOrModify();
338 data->isAllDay = allDay; 338 data->isAllDay = allDay;
339 if ( allDay ) data->timezone = "UTC"; 339 if ( allDay ) data->timezone = "UTC";
340} 340}
341 341
342 342
343void OEvent::setTimeZone( const QString& tz ) 343void OPimEvent::setTimeZone( const QString& tz )
344{ 344{
345 changeOrModify(); 345 changeOrModify();
346 data->timezone = tz; 346 data->timezone = tz;
347} 347}
348 348
349 349
350QString OEvent::timeZone() const 350QString OPimEvent::timeZone() const
351{ 351{
352 if ( data->isAllDay ) return QString::fromLatin1( "UTC" ); 352 if ( data->isAllDay ) return QString::fromLatin1( "UTC" );
353 return data->timezone; 353 return data->timezone;
354} 354}
355 355
356 356
357bool OEvent::match( const QRegExp& re ) const 357bool OPimEvent::match( const QRegExp& re ) const
358{ 358{
359 if ( re.match( data->description ) != -1 ) 359 if ( re.match( data->description ) != -1 )
360 { 360 {
361 setLastHitField( Qtopia::DatebookDescription ); 361 setLastHitField( Qtopia::DatebookDescription );
362 return true; 362 return true;
363 } 363 }
364 if ( re.match( data->note ) != -1 ) 364 if ( re.match( data->note ) != -1 )
365 { 365 {
366 setLastHitField( Qtopia::Note ); 366 setLastHitField( Qtopia::Note );
367 return true; 367 return true;
368 } 368 }
369 if ( re.match( data->location ) != -1 ) 369 if ( re.match( data->location ) != -1 )
370 { 370 {
371 setLastHitField( Qtopia::Location ); 371 setLastHitField( Qtopia::Location );
372 return true; 372 return true;
373 } 373 }
374 if ( re.match( data->start.toString() ) != -1 ) 374 if ( re.match( data->start.toString() ) != -1 )
375 { 375 {
376 setLastHitField( Qtopia::StartDateTime ); 376 setLastHitField( Qtopia::StartDateTime );
377 return true; 377 return true;
378 } 378 }
379 if ( re.match( data->end.toString() ) != -1 ) 379 if ( re.match( data->end.toString() ) != -1 )
380 { 380 {
381 setLastHitField( Qtopia::EndDateTime ); 381 setLastHitField( Qtopia::EndDateTime );
382 return true; 382 return true;
383 } 383 }
384 return false; 384 return false;
385} 385}
386 386
387 387
388QString OEvent::toRichText() const 388QString OPimEvent::toRichText() const
389{ 389{
390 QString text, value; 390 QString text, value;
391 391
392 // description 392 // description
393 text += "<b><h3><img src=\"datebook/DateBook\">"; 393 text += "<b><h3><img src=\"datebook/DateBook\">";
394 if ( !description().isEmpty() ) 394 if ( !description().isEmpty() )
395 { 395 {
396 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" ); 396 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "" );
397 } 397 }
398 text += "</h3></b><br><hr><br>"; 398 text += "</h3></b><br><hr><br>";
399 399
400 // location 400 // location
401 if ( !( value = location() ).isEmpty() ) 401 if ( !( value = location() ).isEmpty() )
402 { 402 {
403 text += "<b>" + QObject::tr( "Location:" ) + "</b> "; 403 text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
404 text += Qtopia::escapeString( value ) + "<br>"; 404 text += Qtopia::escapeString( value ) + "<br>";
405 } 405 }
406 406
407 // all day event 407 // all day event
408 if ( isAllDay() ) 408 if ( isAllDay() )
409 { 409 {
410 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; 410 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
411 } 411 }
412 // multiple day event 412 // multiple day event
413 else if ( isMultipleDay () ) 413 else if ( isMultipleDay () )
414 { 414 {
415 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; 415 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
416 } 416 }
417 // start & end times 417 // start & end times
418 else 418 else
419 { 419 {
420 // start time 420 // start time
421 if ( startDateTime().isValid() ) 421 if ( startDateTime().isValid() )
422 { 422 {
423 text += "<b>" + QObject::tr( "Start:" ) + "</b> "; 423 text += "<b>" + QObject::tr( "Start:" ) + "</b> ";
424 text += Qtopia::escapeString( startDateTime().toString() ). 424 text += Qtopia::escapeString( startDateTime().toString() ).
425 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 425 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
426 } 426 }
427 427
428 // end time 428 // end time
429 if ( endDateTime().isValid() ) 429 if ( endDateTime().isValid() )
430 { 430 {
431 text += "<b>" + QObject::tr( "End:" ) + "</b> "; 431 text += "<b>" + QObject::tr( "End:" ) + "</b> ";
432 text += Qtopia::escapeString( endDateTime().toString() ). 432 text += Qtopia::escapeString( endDateTime().toString() ).
433 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 433 replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
434 } 434 }
435 } 435 }
436 436
437 // categories 437 // categories
438 if ( categoryNames( "Calendar" ).count() ) 438 if ( categoryNames( "Calendar" ).count() )
439 { 439 {
440 text += "<b>" + QObject::tr( "Category:" ) + "</b> "; 440 text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
441 text += categoryNames( "Calendar" ).join( ", " ); 441 text += categoryNames( "Calendar" ).join( ", " );
442 text += "<br>"; 442 text += "<br>";
443 } 443 }
444 444
445 //notes 445 //notes
446 if ( !note().isEmpty() ) 446 if ( !note().isEmpty() )
447 { 447 {
448 text += "<b>" + QObject::tr( "Note:" ) + "</b><br>"; 448 text += "<b>" + QObject::tr( "Note:" ) + "</b><br>";
449 text += note(); 449 text += note();
450 // text += Qtopia::escapeString(note() ). 450 // text += Qtopia::escapeString(note() ).
451 // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; 451 // replace(QRegExp( "[\n]"), "<br>" ) + "<br>";
452 } 452 }
453 return text; 453 return text;
454} 454}
455 455
456 456
457QString OEvent::toShortText() const 457QString OPimEvent::toShortText() const
458{ 458{
459 QString text; 459 QString text;
460 text += QString::number( startDateTime().date().day() ); 460 text += QString::number( startDateTime().date().day() );
461 text += "."; 461 text += ".";
462 text += QString::number( startDateTime().date().month() ); 462 text += QString::number( startDateTime().date().month() );
463 text += "."; 463 text += ".";
464 text += QString::number( startDateTime().date().year() ); 464 text += QString::number( startDateTime().date().year() );
465 text += " "; 465 text += " ";
466 text += QString::number( startDateTime().time().hour() ); 466 text += QString::number( startDateTime().time().hour() );
467 text += ":"; 467 text += ":";
468 text += QString::number( startDateTime().time().minute() ); 468 text += QString::number( startDateTime().time().minute() );
469 text += " - "; 469 text += " - ";
470 text += description(); 470 text += description();
471 return text; 471 return text;
472} 472}
473 473
474 474
475QString OEvent::type() const 475QString OPimEvent::type() const
476{ 476{
477 return QString::fromLatin1( "OEvent" ); 477 return QString::fromLatin1( "OPimEvent" );
478} 478}
479 479
480 480
481QString OEvent::recordField( int /*id */ ) const 481QString OPimEvent::recordField( int /*id */ ) const
482{ 482{
483 return QString::null; 483 return QString::null;
484} 484}
485 485
486 486
487int OEvent::rtti() 487int OPimEvent::rtti()
488{ 488{
489 return OPimResolver::DateBook; 489 return OPimResolver::DateBook;
490} 490}
491 491
492 492
493bool OEvent::loadFromStream( QDataStream& ) 493bool OPimEvent::loadFromStream( QDataStream& )
494{ 494{
495 return true; 495 return true;
496} 496}
497 497
498 498
499bool OEvent::saveToStream( QDataStream& ) const 499bool OPimEvent::saveToStream( QDataStream& ) const
500{ 500{
501 return true; 501 return true;
502} 502}
503 503
504 504
505void OEvent::changeOrModify() 505void OPimEvent::changeOrModify()
506{ 506{
507 if ( data->count != 1 ) 507 if ( data->count != 1 )
508 { 508 {
509 data->deref(); 509 data->deref();
510 Data* d2 = new Data; 510 Data* d2 = new Data;
511 d2->description = data->description; 511 d2->description = data->description;
512 d2->location = data->location; 512 d2->location = data->location;
513 513
514 if ( data->manager ) 514 if ( data->manager )
515 d2->manager = new OPimNotifyManager( *data->manager ); 515 d2->manager = new OPimNotifyManager( *data->manager );
516 516
517 if ( data->recur ) 517 if ( data->recur )
518 d2->recur = new ORecur( *data->recur ); 518 d2->recur = new OPimRecurrence( *data->recur );
519 519
520 d2->note = data->note; 520 d2->note = data->note;
521 d2->created = data->created; 521 d2->created = data->created;
522 d2->start = data->start; 522 d2->start = data->start;
523 d2->end = data->end; 523 d2->end = data->end;
524 d2->isAllDay = data->isAllDay; 524 d2->isAllDay = data->isAllDay;
525 d2->timezone = data->timezone; 525 d2->timezone = data->timezone;
526 d2->parent = data->parent; 526 d2->parent = data->parent;
527 527
528 if ( data->child ) 528 if ( data->child )
529 { 529 {
530 d2->child = new QArray<int>( *data->child ); 530 d2->child = new QArray<int>( *data->child );
531 d2->child->detach(); 531 d2->child->detach();
532 } 532 }
533 533
534 data = d2; 534 data = d2;
535 } 535 }
536} 536}
537 537
538 538
539void OEvent::deref() 539void OPimEvent::deref()
540{ 540{
541 if ( data->deref() ) 541 if ( data->deref() )
542 { 542 {
543 delete data; 543 delete data;
544 data = 0; 544 data = 0;
545 } 545 }
546} 546}
547// Exporting Event data to map. Using the same 547// Exporting Event data to map. Using the same
548// encoding as ODateBookAccessBackend_xml does.. 548// encoding as ODateBookAccessBackend_xml does..
549// Thus, we could remove the stuff there and use this 549// Thus, we could remove the stuff there and use this
550// for it and for all other places.. 550// for it and for all other places..
551// Encoding should happen at one place, only ! (eilers) 551// Encoding should happen at one place, only ! (eilers)
552QMap<int, QString> OEvent::toMap() const 552QMap<int, QString> OPimEvent::toMap() const
553{ 553{
554 QMap<int, QString> retMap; 554 QMap<int, QString> retMap;
555 555
556 retMap.insert( OEvent::FUid, QString::number( uid() ) ); 556 retMap.insert( OPimEvent::FUid, QString::number( uid() ) );
557 retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) ); 557 retMap.insert( OPimEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ) );
558 retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) ); 558 retMap.insert( OPimEvent::FDescription, Qtopia::escapeString( description() ) );
559 retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) ); 559 retMap.insert( OPimEvent::FLocation, Qtopia::escapeString( location() ) );
560 retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" ); 560 retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" );
561 OPimAlarm alarm = notifiers().alarms() [ 0 ]; 561 OPimAlarm alarm = notifiers().alarms() [ 0 ];
562 retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) ); 562 retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
563 retMap.insert( OEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" ); 563 retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
564 564
565 OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); 565 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
566 retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) ); 566 retMap.insert( OPimEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OPimTimeZone::utc() ) ) ) );
567 retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) ); 567 retMap.insert( OPimEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OPimTimeZone::utc() ) ) ) );
568 retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) ); 568 retMap.insert( OPimEvent::FNote, Qtopia::escapeString( note() ) );
569 retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() ); 569 retMap.insert( OPimEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
570 if ( parent() ) 570 if ( parent() )
571 retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); 571 retMap.insert( OPimEvent::FRecParent, QString::number( parent() ) );
572 if ( children().count() ) 572 if ( children().count() )
573 { 573 {
574 QArray<int> childr = children(); 574 QArray<int> childr = children();
575 QString buf; 575 QString buf;
576 for ( uint i = 0; i < childr.count(); i++ ) 576 for ( uint i = 0; i < childr.count(); i++ )
577 { 577 {
578 if ( i != 0 ) buf += " "; 578 if ( i != 0 ) buf += " ";
579 buf += QString::number( childr[ i ] ); 579 buf += QString::number( childr[ i ] );
580 } 580 }
581 retMap.insert( OEvent::FRecChildren, buf ); 581 retMap.insert( OPimEvent::FRecChildren, buf );
582 } 582 }
583 583
584 // Add recurrence stuff 584 // Add recurrence stuff
585 if ( hasRecurrence() ) 585 if ( hasRecurrence() )
586 { 586 {
587 ORecur recur = recurrence(); 587 OPimRecurrence recur = recurrence();
588 QMap<int, QString> recFields = recur.toMap(); 588 QMap<int, QString> recFields = recur.toMap();
589 retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] ); 589 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] );
590 retMap.insert( OEvent::FRWeekdays, recFields[ ORecur::RWeekdays ] ); 590 retMap.insert( OPimEvent::FRWeekdays, recFields[ OPimRecurrence::RWeekdays ] );
591 retMap.insert( OEvent::FRPosition, recFields[ ORecur::RPosition ] ); 591 retMap.insert( OPimEvent::FRPosition, recFields[ OPimRecurrence::RPosition ] );
592 retMap.insert( OEvent::FRFreq, recFields[ ORecur::RFreq ] ); 592 retMap.insert( OPimEvent::FRFreq, recFields[ OPimRecurrence::RFreq ] );
593 retMap.insert( OEvent::FRHasEndDate, recFields[ ORecur::RHasEndDate ] ); 593 retMap.insert( OPimEvent::FRHasEndDate, recFields[ OPimRecurrence::RHasEndDate ] );
594 retMap.insert( OEvent::FREndDate, recFields[ ORecur::EndDate ] ); 594 retMap.insert( OPimEvent::FREndDate, recFields[ OPimRecurrence::EndDate ] );
595 retMap.insert( OEvent::FRCreated, recFields[ ORecur::Created ] ); 595 retMap.insert( OPimEvent::FRCreated, recFields[ OPimRecurrence::Created ] );
596 retMap.insert( OEvent::FRExceptions, recFields[ ORecur::Exceptions ] ); 596 retMap.insert( OPimEvent::FRExceptions, recFields[ OPimRecurrence::Exceptions ] );
597 } 597 }
598 else 598 else
599 { 599 {
600 ORecur recur = recurrence(); 600 OPimRecurrence recur = recurrence();
601 QMap<int, QString> recFields = recur.toMap(); 601 QMap<int, QString> recFields = recur.toMap();
602 retMap.insert( OEvent::FRType, recFields[ ORecur::RType ] ); 602 retMap.insert( OPimEvent::FRType, recFields[ OPimRecurrence::RType ] );
603 } 603 }
604 604
605 return retMap; 605 return retMap;
606} 606}
607 607
608 608
609void OEvent::fromMap( const QMap<int, QString>& map ) 609void OPimEvent::fromMap( const QMap<int, QString>& map )
610{ 610{
611 611
612 // We just want to set the UID if it is really stored. 612 // We just want to set the UID if it is really stored.
613 if ( !map[ OEvent::FUid ].isEmpty() ) 613 if ( !map[ OPimEvent::FUid ].isEmpty() )
614 setUid( map[ OEvent::FUid ].toInt() ); 614 setUid( map[ OPimEvent::FUid ].toInt() );
615 615
616 setCategories( idsFromString( map[ OEvent::FCategories ] ) ); 616 setCategories( idsFromString( map[ OPimEvent::FCategories ] ) );
617 setDescription( map[ OEvent::FDescription ] ); 617 setDescription( map[ OPimEvent::FDescription ] );
618 setLocation( map[ OEvent::FLocation ] ); 618 setLocation( map[ OPimEvent::FLocation ] );
619 619
620 if ( map[ OEvent::FType ] == "AllDay" ) 620 if ( map[ OPimEvent::FType ] == "AllDay" )
621 setAllDay( true ); 621 setAllDay( true );
622 else 622 else
623 setAllDay( false ); 623 setAllDay( false );
624 624
625 int alarmTime = -1; 625 int alarmTime = -1;
626 if ( !map[ OEvent::FAlarm ].isEmpty() ) 626 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
627 alarmTime = map[ OEvent::FAlarm ].toInt(); 627 alarmTime = map[ OPimEvent::FAlarm ].toInt();
628 628
629 int sound = ( ( map[ OEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); 629 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
630 if ( ( alarmTime != -1 ) ) 630 if ( ( alarmTime != -1 ) )
631 { 631 {
632 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 ); 632 QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
633 OPimAlarm al( sound , dt ); 633 OPimAlarm al( sound , dt );
634 notifiers().add( al ); 634 notifiers().add( al );
635 } 635 }
636 if ( !map[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) ) 636 if ( !map[ OPimEvent::FTimeZone ].isEmpty() && ( map[ OPimEvent::FTimeZone ] != "None" ) )
637 { 637 {
638 setTimeZone( map[ OEvent::FTimeZone ] ); 638 setTimeZone( map[ OPimEvent::FTimeZone ] );
639 } 639 }
640 640
641 time_t start = ( time_t ) map[ OEvent::FStart ].toLong(); 641 time_t start = ( time_t ) map[ OPimEvent::FStart ].toLong();
642 time_t end = ( time_t ) map[ OEvent::FEnd ].toLong(); 642 time_t end = ( time_t ) map[ OPimEvent::FEnd ].toLong();
643 643
644 /* AllDay is always in UTC */ 644 /* AllDay is always in UTC */
645 if ( isAllDay() ) 645 if ( isAllDay() )
646 { 646 {
647 OTimeZone utc = OTimeZone::utc(); 647 OPimTimeZone utc = OPimTimeZone::utc();
648 setStartDateTime( utc.fromUTCDateTime( start ) ); 648 setStartDateTime( utc.fromUTCDateTime( start ) );
649 setEndDateTime ( utc.fromUTCDateTime( end ) ); 649 setEndDateTime ( utc.fromUTCDateTime( end ) );
650 setTimeZone( "UTC" ); // make sure it is really utc 650 setTimeZone( "UTC" ); // make sure it is really utc
651 } 651 }
652 else 652 else
653 { 653 {
654 /* to current date time */ 654 /* to current date time */
655 // qWarning(" Start is %d", start ); 655 // qWarning(" Start is %d", start );
656 OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() ); 656 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
657 QDateTime date = zone.toDateTime( start ); 657 QDateTime date = zone.toDateTime( start );
658 qWarning( " Start is %s", date.toString().latin1() ); 658 qWarning( " Start is %s", date.toString().latin1() );
659 setStartDateTime( zone.toDateTime( date, OTimeZone::current() ) ); 659 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
660 660
661 date = zone.toDateTime( end ); 661 date = zone.toDateTime( end );
662 setEndDateTime ( zone.toDateTime( date, OTimeZone::current() ) ); 662 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
663 } 663 }
664 664
665 if ( !map[ OEvent::FRecParent ].isEmpty() ) 665 if ( !map[ OPimEvent::FRecParent ].isEmpty() )
666 setParent( map[ OEvent::FRecParent ].toInt() ); 666 setParent( map[ OPimEvent::FRecParent ].toInt() );
667 667
668 if ( !map[ OEvent::FRecChildren ].isEmpty() ) 668 if ( !map[ OPimEvent::FRecChildren ].isEmpty() )
669 { 669 {
670 QStringList list = QStringList::split( ' ', map[ OEvent::FRecChildren ] ); 670 QStringList list = QStringList::split( ' ', map[ OPimEvent::FRecChildren ] );
671 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 671 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
672 { 672 {
673 addChild( ( *it ).toInt() ); 673 addChild( ( *it ).toInt() );
674 } 674 }
675 } 675 }
676 676
677 // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. 677 // Fill recurrence stuff and put it directly into the OPimRecurrence-Object using fromMap..
678 if ( !map[ OEvent::FRType ].isEmpty() ) 678 if ( !map[ OPimEvent::FRType ].isEmpty() )
679 { 679 {
680 QMap<int, QString> recFields; 680 QMap<int, QString> recFields;
681 recFields.insert( ORecur::RType, map[ OEvent::FRType ] ); 681 recFields.insert( OPimRecurrence::RType, map[ OPimEvent::FRType ] );
682 recFields.insert( ORecur::RWeekdays, map[ OEvent::FRWeekdays ] ); 682 recFields.insert( OPimRecurrence::RWeekdays, map[ OPimEvent::FRWeekdays ] );
683 recFields.insert( ORecur::RPosition, map[ OEvent::FRPosition ] ); 683 recFields.insert( OPimRecurrence::RPosition, map[ OPimEvent::FRPosition ] );
684 recFields.insert( ORecur::RFreq, map[ OEvent::FRFreq ] ); 684 recFields.insert( OPimRecurrence::RFreq, map[ OPimEvent::FRFreq ] );
685 recFields.insert( ORecur::RHasEndDate, map[ OEvent::FRHasEndDate ] ); 685 recFields.insert( OPimRecurrence::RHasEndDate, map[ OPimEvent::FRHasEndDate ] );
686 recFields.insert( ORecur::EndDate, map[ OEvent::FREndDate ] ); 686 recFields.insert( OPimRecurrence::EndDate, map[ OPimEvent::FREndDate ] );
687 recFields.insert( ORecur::Created, map[ OEvent::FRCreated ] ); 687 recFields.insert( OPimRecurrence::Created, map[ OPimEvent::FRCreated ] );
688 recFields.insert( ORecur::Exceptions, map[ OEvent::FRExceptions ] ); 688 recFields.insert( OPimRecurrence::Exceptions, map[ OPimEvent::FRExceptions ] );
689 ORecur recur( recFields ); 689 OPimRecurrence recur( recFields );
690 setRecurrence( recur ); 690 setRecurrence( recur );
691 } 691 }
692 692
693} 693}
694 694
695 695
696int OEvent::parent() const 696int OPimEvent::parent() const
697{ 697{
698 return data->parent; 698 return data->parent;
699} 699}
700 700
701 701
702void OEvent::setParent( int uid ) 702void OPimEvent::setParent( int uid )
703{ 703{
704 changeOrModify(); 704 changeOrModify();
705 data->parent = uid; 705 data->parent = uid;
706} 706}
707 707
708 708
709QArray<int> OEvent::children() const 709QArray<int> OPimEvent::children() const
710{ 710{
711 if ( !data->child ) return QArray<int>(); 711 if ( !data->child ) return QArray<int>();
712 else 712 else
713 return data->child->copy(); 713 return data->child->copy();
714} 714}
715 715
716 716
717void OEvent::setChildren( const QArray<int>& arr ) 717void OPimEvent::setChildren( const QArray<int>& arr )
718{ 718{
719 changeOrModify(); 719 changeOrModify();
720 if ( data->child ) delete data->child; 720 if ( data->child ) delete data->child;
721 721
722 data->child = new QArray<int>( arr ); 722 data->child = new QArray<int>( arr );
723 data->child->detach(); 723 data->child->detach();
724} 724}
725 725
726 726
727void OEvent::addChild( int uid ) 727void OPimEvent::addChild( int uid )
728{ 728{
729 changeOrModify(); 729 changeOrModify();
730 if ( !data->child ) 730 if ( !data->child )
731 { 731 {
732 data->child = new QArray<int>( 1 ); 732 data->child = new QArray<int>( 1 );
733 ( *data->child ) [ 0 ] = uid; 733 ( *data->child ) [ 0 ] = uid;
734 } 734 }
735 else 735 else
736 { 736 {
737 int count = data->child->count(); 737 int count = data->child->count();
738 data->child->resize( count + 1 ); 738 data->child->resize( count + 1 );
739 ( *data->child ) [ count ] = uid; 739 ( *data->child ) [ count ] = uid;
740 } 740 }
741} 741}
742 742
743 743
744void OEvent::removeChild( int uid ) 744void OPimEvent::removeChild( int uid )
745{ 745{
746 if ( !data->child || !data->child->contains( uid ) ) return ; 746 if ( !data->child || !data->child->contains( uid ) ) return ;
747 changeOrModify(); 747 changeOrModify();
748 QArray<int> newAr( data->child->count() - 1 ); 748 QArray<int> newAr( data->child->count() - 1 );
749 int j = 0; 749 int j = 0;
750 uint count = data->child->count(); 750 uint count = data->child->count();
751 for ( uint i = 0; i < count; i++ ) 751 for ( uint i = 0; i < count; i++ )
752 { 752 {
753 if ( ( *data->child ) [ i ] != uid ) 753 if ( ( *data->child ) [ i ] != uid )
754 { 754 {
755 newAr[ j ] = ( *data->child ) [ i ]; 755 newAr[ j ] = ( *data->child ) [ i ];
756 j++; 756 j++;
757 } 757 }
758 } 758 }
759 ( *data->child ) = newAr; 759 ( *data->child ) = newAr;
760} 760}
761 761
762 762
763struct OEffectiveEvent::Data : public QShared 763struct OEffectiveEvent::Data : public QShared
764{ 764{
765 Data() : QShared() 765 Data() : QShared()
766 {} 766 {}
767 OEvent event; 767 OPimEvent event;
768 QDate date; 768 QDate date;
769 QTime start, end; 769 QTime start, end;
770 QDate startDate, endDate; 770 QDate startDate, endDate;
771bool dates : 1; 771bool dates : 1;
772}; 772};
773 773
774 774
775OEffectiveEvent::OEffectiveEvent() 775OEffectiveEvent::OEffectiveEvent()
776{ 776{
777 data = new Data; 777 data = new Data;
778 data->date = QDate::currentDate(); 778 data->date = QDate::currentDate();
779 data->start = data->end = QTime::currentTime(); 779 data->start = data->end = QTime::currentTime();
780 data->dates = false; 780 data->dates = false;
781} 781}
782 782
783 783
784OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, 784OEffectiveEvent::OEffectiveEvent( const OPimEvent& ev, const QDate& startDate,
785 Position pos ) 785 Position pos )
786{ 786{
787 data = new Data; 787 data = new Data;
788 data->event = ev; 788 data->event = ev;
789 data->date = startDate; 789 data->date = startDate;
790 if ( pos & Start ) 790 if ( pos & Start )
791 data->start = ev.startDateTime().time(); 791 data->start = ev.startDateTime().time();
792 else 792 else
793 data->start = QTime( 0, 0, 0 ); 793 data->start = QTime( 0, 0, 0 );
794 794
795 if ( pos & End ) 795 if ( pos & End )
796 data->end = ev.endDateTime().time(); 796 data->end = ev.endDateTime().time();
797 else 797 else
798 data->end = QTime( 23, 59, 59 ); 798 data->end = QTime( 23, 59, 59 );
799 799
800 data->dates = false; 800 data->dates = false;
801} 801}
802 802
803 803
804OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev ) 804OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev )
805{ 805{
806 data = ev.data; 806 data = ev.data;
807 data->ref(); 807 data->ref();
808} 808}
809 809
810 810
811OEffectiveEvent::~OEffectiveEvent() 811OEffectiveEvent::~OEffectiveEvent()
812{ 812{
813 if ( data->deref() ) 813 if ( data->deref() )
814 { 814 {
815 delete data; 815 delete data;
816 data = 0; 816 data = 0;
817 } 817 }
818} 818}
819 819
820 820
821OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) 821OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev )
822{ 822{
823 if ( *this == ev ) return * this; 823 if ( *this == ev ) return * this;
824 824
825 ev.data->ref(); 825 ev.data->ref();
826 deref(); 826 deref();
827 data = ev.data; 827 data = ev.data;
828 828
829 return *this; 829 return *this;
830} 830}
831 831
832 832
833void OEffectiveEvent::setStartTime( const QTime& ti ) 833void OEffectiveEvent::setStartTime( const QTime& ti )
834{ 834{
835 changeOrModify(); 835 changeOrModify();
836 data->start = ti; 836 data->start = ti;
837} 837}
838 838
839 839
840void OEffectiveEvent::setEndTime( const QTime& en ) 840void OEffectiveEvent::setEndTime( const QTime& en )
841{ 841{
842 changeOrModify(); 842 changeOrModify();
843 data->end = en; 843 data->end = en;
844} 844}
845 845
846 846
847void OEffectiveEvent::setEvent( const OEvent& ev ) 847void OEffectiveEvent::setEvent( const OPimEvent& ev )
848{ 848{
849 changeOrModify(); 849 changeOrModify();
850 data->event = ev; 850 data->event = ev;
851} 851}
852 852
853 853
854void OEffectiveEvent::setDate( const QDate& da ) 854void OEffectiveEvent::setDate( const QDate& da )
855{ 855{
856 changeOrModify(); 856 changeOrModify();
857 data->date = da; 857 data->date = da;
858} 858}
859 859
860 860
861void OEffectiveEvent::setEffectiveDates( const QDate& from, 861void OEffectiveEvent::setEffectiveDates( const QDate& from,
862 const QDate& to ) 862 const QDate& to )
863{ 863{
864 if ( !from.isValid() ) 864 if ( !from.isValid() )
865 { 865 {
866 data->dates = false; 866 data->dates = false;
867 return ; 867 return ;
868 } 868 }
869 869
870 data->startDate = from; 870 data->startDate = from;
871 data->endDate = to; 871 data->endDate = to;
872} 872}
873 873
874 874
875QString OEffectiveEvent::description() const 875QString OEffectiveEvent::description() const
876{ 876{
877 return data->event.description(); 877 return data->event.description();
878} 878}
879 879
880 880
881QString OEffectiveEvent::location() const 881QString OEffectiveEvent::location() const
882{ 882{
883 return data->event.location(); 883 return data->event.location();
884} 884}
885 885
886 886
887QString OEffectiveEvent::note() const 887QString OEffectiveEvent::note() const
888{ 888{
889 return data->event.note(); 889 return data->event.note();
890} 890}
891 891
892 892
893OEvent OEffectiveEvent::event() const 893OPimEvent OEffectiveEvent::event() const
894{ 894{
895 return data->event; 895 return data->event;
896} 896}
897 897
898 898
899QTime OEffectiveEvent::startTime() const 899QTime OEffectiveEvent::startTime() const
900{ 900{
901 return data->start; 901 return data->start;
902} 902}
903 903
904 904
905QTime OEffectiveEvent::endTime() const 905QTime OEffectiveEvent::endTime() const
906{ 906{
907 return data->end; 907 return data->end;
908} 908}
909 909
910 910
911QDate OEffectiveEvent::date() const 911QDate OEffectiveEvent::date() const
912{ 912{
913 return data->date; 913 return data->date;
914} 914}
915 915
916 916
917int OEffectiveEvent::length() const 917int OEffectiveEvent::length() const
918{ 918{
919 return ( data->end.hour() * 60 - data->start.hour() * 60 ) 919 return ( data->end.hour() * 60 - data->start.hour() * 60 )
920 + QABS( data->start.minute() - data->end.minute() ); 920 + QABS( data->start.minute() - data->end.minute() );
921} 921}
922 922
923 923
924int OEffectiveEvent::size() const 924int OEffectiveEvent::size() const
925{ 925{
926 return ( data->end.hour() - data->start.hour() ) * 3600 926 return ( data->end.hour() - data->start.hour() ) * 3600
927 + ( data->end.minute() - data->start.minute() * 60 927 + ( data->end.minute() - data->start.minute() * 60
928 + data->end.second() - data->start.second() ); 928 + data->end.second() - data->start.second() );
929} 929}
930 930
931 931
932QDate OEffectiveEvent::startDate() const 932QDate OEffectiveEvent::startDate() const
933{ 933{
934 if ( data->dates ) 934 if ( data->dates )
935 return data->startDate; 935 return data->startDate;
936 else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer 936 else if ( data->event.hasRecurrence() ) // single day, since multi-day should have a d pointer
937 return data->date; 937 return data->date;
938 else 938 else
939 return data->event.startDateTime().date(); 939 return data->event.startDateTime().date();
940} 940}
941 941
942 942
943QDate OEffectiveEvent::endDate() const 943QDate OEffectiveEvent::endDate() const
944{ 944{
945 if ( data->dates ) 945 if ( data->dates )
946 return data->endDate; 946 return data->endDate;
947 else if ( data->event.hasRecurrence() ) 947 else if ( data->event.hasRecurrence() )
948 return data->date; 948 return data->date;
949 else 949 else
950 return data->event.endDateTime().date(); 950 return data->event.endDateTime().date();
951} 951}
952 952
953 953
954void OEffectiveEvent::deref() 954void OEffectiveEvent::deref()
955{ 955{
956 if ( data->deref() ) 956 if ( data->deref() )
957 { 957 {
958 delete data; 958 delete data;
959 data = 0; 959 data = 0;
960 } 960 }
961} 961}
962 962
963 963
964void OEffectiveEvent::changeOrModify() 964void OEffectiveEvent::changeOrModify()
965{ 965{
966 if ( data->count != 1 ) 966 if ( data->count != 1 )
967 { 967 {
968 data->deref(); 968 data->deref();
969 Data* d2 = new Data; 969 Data* d2 = new Data;
970 d2->event = data->event; 970 d2->event = data->event;
971 d2->date = data->date; 971 d2->date = data->date;
972 d2->start = data->start; 972 d2->start = data->start;
973 d2->end = data->end; 973 d2->end = data->end;
974 d2->startDate = data->startDate; 974 d2->startDate = data->startDate;
975 d2->endDate = data->endDate; 975 d2->endDate = data->endDate;
976 d2->dates = data->dates; 976 d2->dates = data->dates;
977 data = d2; 977 data = d2;
978 } 978 }
979} 979}
980 980
981 981
982bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const 982bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const
983{ 983{
984 if ( data->date < e.date() ) 984 if ( data->date < e.date() )
985 return TRUE; 985 return TRUE;
986 if ( data->date == e.date() ) 986 if ( data->date == e.date() )
987 return ( startTime() < e.startTime() ); 987 return ( startTime() < e.startTime() );
988 else 988 else
989 return FALSE; 989 return FALSE;
990} 990}
991 991
992 992
993bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const 993bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const
994{ 994{
995 return ( data->date <= e.date() ); 995 return ( data->date <= e.date() );
996} 996}
997 997
998 998
999bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const 999bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const
1000{ 1000{
1001 return ( date() == e.date() 1001 return ( date() == e.date()
1002 && startTime() == e.startTime() 1002 && startTime() == e.startTime()
1003 && endTime() == e.endTime() 1003 && endTime() == e.endTime()
1004 && event() == e.event() ); 1004 && event() == e.event() );
1005} 1005}
1006 1006
1007 1007
1008bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const 1008bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const
1009{ 1009{
1010 return !( *this == e ); 1010 return !( *this == e );
1011} 1011}
1012 1012
1013 1013
1014bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const 1014bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const
1015{ 1015{
1016 return !( *this <= e ); 1016 return !( *this <= e );
1017} 1017}
1018 1018
1019 1019
1020bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const 1020bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const
1021{ 1021{
1022 return !( *this < e ); 1022 return !( *this < e );
1023} 1023}
1024 1024
1025} 1025}
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/core/opimevent.h
index dc5e4d6..949f263 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/core/opimevent.h
@@ -1,275 +1,275 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29// CONTAINS GPLed code of TT 29// CONTAINS GPLed code of TT
30 30
31#ifndef OEVENT_H 31#ifndef OEVENT_H
32#define OEVENT_H 32#define OEVENT_H
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/otimezone.h> 35#include <opie2/opimtimezone.h>
36#include <opie2/opimrecord.h> 36#include <opie2/opimrecord.h>
37#include <qpe/recordfields.h> 37#include <qpe/recordfields.h>
38#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
39 39
40/* QT */ 40/* QT */
41#include <qstring.h> 41#include <qstring.h>
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qvaluelist.h> 43#include <qvaluelist.h>
44 44
45namespace Opie 45namespace Opie
46{ 46{
47struct OCalendarHelper 47struct OCalendarHelper
48{ 48{
49 /** calculate the week number of the date */ 49 /** calculate the week number of the date */
50 static int week( const QDate& ); 50 static int week( const QDate& );
51 /** calculate the occurence of week days since the start of the month */ 51 /** calculate the occurence of week days since the start of the month */
52 static int ocurrence( const QDate& ); 52 static int ocurrence( const QDate& );
53 53
54 // returns the dayOfWeek for the *first* day it finds (ignores 54 // returns the dayOfWeek for the *first* day it finds (ignores
55 // any further days!). Returns 1 (Monday) if there isn't any day found 55 // any further days!). Returns 1 (Monday) if there isn't any day found
56 static int dayOfWeek( char day ); 56 static int dayOfWeek( char day );
57 57
58 /** returns the diff of month */ 58 /** returns the diff of month */
59 static int monthDiff( const QDate& first, const QDate& second ); 59 static int monthDiff( const QDate& first, const QDate& second );
60 60
61}; 61};
62 62
63class OPimNotifyManager; 63class OPimNotifyManager;
64class ORecur; 64class OPimRecurrence;
65 65
66/** 66/**
67 * This is the container for all Events. It encapsules all 67 * This is the container for all Events. It encapsules all
68 * available information for a single Event 68 * available information for a single Event
69 * @short container for events. 69 * @short container for events.
70 */ 70 */
71class OEvent : public OPimRecord 71class OPimEvent : public OPimRecord
72{ 72{
73 public: 73 public:
74 typedef QValueList<OEvent> ValueList; 74 typedef QValueList<OPimEvent> ValueList;
75 /** 75 /**
76 * RecordFields contain possible attributes 76 * RecordFields contain possible attributes
77 * used in the Results of toMap().. 77 * used in the Results of toMap()..
78 */ 78 */
79 enum RecordFields { 79 enum RecordFields {
80 FUid = Qtopia::UID_ID, 80 FUid = Qtopia::UID_ID,
81 FCategories = Qtopia::CATEGORY_ID, 81 FCategories = Qtopia::CATEGORY_ID,
82 FDescription = 0, 82 FDescription = 0,
83 FLocation, 83 FLocation,
84 FType, 84 FType,
85 FAlarm, 85 FAlarm,
86 FSound, 86 FSound,
87 FRType, 87 FRType,
88 FRWeekdays, 88 FRWeekdays,
89 FRPosition, 89 FRPosition,
90 FRFreq, 90 FRFreq,
91 FRHasEndDate, 91 FRHasEndDate,
92 FREndDate, 92 FREndDate,
93 FRCreated, 93 FRCreated,
94 FRExceptions, 94 FRExceptions,
95 FStart, 95 FStart,
96 FEnd, 96 FEnd,
97 FNote, 97 FNote,
98 FTimeZone, 98 FTimeZone,
99 FRecParent, 99 FRecParent,
100 FRecChildren, 100 FRecChildren,
101 }; 101 };
102 102
103 /** 103 /**
104 * Start with an Empty OEvent. UID == 0 means that it is empty 104 * Start with an Empty OPimEvent. UID == 0 means that it is empty
105 */ 105 */
106 OEvent( int uid = 0 ); 106 OPimEvent( int uid = 0 );
107 107
108 /** 108 /**
109 * copy c'tor 109 * copy c'tor
110 */ 110 */
111 OEvent( const OEvent& ); 111 OPimEvent( const OPimEvent& );
112 112
113 /** 113 /**
114 * Create OEvent, initialized by map 114 * Create OPimEvent, initialized by map
115 * @see enum RecordFields 115 * @see enum RecordFields
116 */ 116 */
117 OEvent( const QMap<int, QString> map ); 117 OPimEvent( const QMap<int, QString> map );
118 ~OEvent(); 118 ~OPimEvent();
119 OEvent &operator=( const OEvent& ); 119 OPimEvent &operator=( const OPimEvent& );
120 120
121 QString description() const; 121 QString description() const;
122 void setDescription( const QString& description ); 122 void setDescription( const QString& description );
123 123
124 QString location() const; 124 QString location() const;
125 void setLocation( const QString& loc ); 125 void setLocation( const QString& loc );
126 126
127 bool hasNotifiers() const; 127 bool hasNotifiers() const;
128 OPimNotifyManager &notifiers() const; 128 OPimNotifyManager &notifiers() const;
129 129
130 ORecur recurrence() const; 130 OPimRecurrence recurrence() const;
131 void setRecurrence( const ORecur& ); 131 void setRecurrence( const OPimRecurrence& );
132 bool hasRecurrence() const; 132 bool hasRecurrence() const;
133 133
134 QString note() const; 134 QString note() const;
135 void setNote( const QString& note ); 135 void setNote( const QString& note );
136 136
137 137
138 QDateTime createdDateTime() const; 138 QDateTime createdDateTime() const;
139 void setCreatedDateTime( const QDateTime& dt ); 139 void setCreatedDateTime( const QDateTime& dt );
140 140
141 /** set the date to dt. dt is the QDateTime in localtime */ 141 /** set the date to dt. dt is the QDateTime in localtime */
142 void setStartDateTime( const QDateTime& ); 142 void setStartDateTime( const QDateTime& );
143 /** returns the datetime in the local timeZone */ 143 /** returns the datetime in the local timeZone */
144 QDateTime startDateTime() const; 144 QDateTime startDateTime() const;
145 145
146 /** returns the start datetime in the current zone */ 146 /** returns the start datetime in the current zone */
147 QDateTime startDateTimeInZone() const; 147 QDateTime startDateTimeInZone() const;
148 148
149 /** in current timezone */ 149 /** in current timezone */
150 void setEndDateTime( const QDateTime& ); 150 void setEndDateTime( const QDateTime& );
151 /** in current timezone */ 151 /** in current timezone */
152 QDateTime endDateTime() const; 152 QDateTime endDateTime() const;
153 QDateTime endDateTimeInZone() const; 153 QDateTime endDateTimeInZone() const;
154 154
155 bool isMultipleDay() const; 155 bool isMultipleDay() const;
156 bool isAllDay() const; 156 bool isAllDay() const;
157 void setAllDay( bool isAllDay ); 157 void setAllDay( bool isAllDay );
158 158
159 /* pin this event to a timezone! FIXME */ 159 /* pin this event to a timezone! FIXME */
160 void setTimeZone( const QString& timeZone ); 160 void setTimeZone( const QString& timeZone );
161 QString timeZone() const; 161 QString timeZone() const;
162 162
163 163
164 virtual bool match( const QRegExp& ) const; 164 virtual bool match( const QRegExp& ) const;
165 165
166 /** For exception to recurrence here is a list of children... */ 166 /** For exception to recurrence here is a list of children... */
167 QArray<int> children() const; 167 QArray<int> children() const;
168 void setChildren( const QArray<int>& ); 168 void setChildren( const QArray<int>& );
169 void addChild( int uid ); 169 void addChild( int uid );
170 void removeChild( int uid ); 170 void removeChild( int uid );
171 171
172 /** return the parent OEvent */ 172 /** return the parent OPimEvent */
173 int parent() const; 173 int parent() const;
174 void setParent( int uid ); 174 void setParent( int uid );
175 175
176 176
177 /* needed reimp */ 177 /* needed reimp */
178 QString toRichText() const; 178 QString toRichText() const;
179 QString toShortText() const; 179 QString toShortText() const;
180 QString type() const; 180 QString type() const;
181 181
182 QMap<int, QString> toMap() const; 182 QMap<int, QString> toMap() const;
183 void fromMap( const QMap<int, QString>& map ); 183 void fromMap( const QMap<int, QString>& map );
184 QString recordField( int ) const; 184 QString recordField( int ) const;
185 185
186 static int rtti(); 186 static int rtti();
187 187
188 bool loadFromStream( QDataStream& ); 188 bool loadFromStream( QDataStream& );
189 bool saveToStream( QDataStream& ) const; 189 bool saveToStream( QDataStream& ) const;
190 190
191 /* bool operator==( const OEvent& ); 191 /* bool operator==( const OPimEvent& );
192 bool operator!=( const OEvent& ); 192 bool operator!=( const OPimEvent& );
193 bool operator<( const OEvent& ); 193 bool operator<( const OPimEvent& );
194 bool operator<=( const OEvent& ); 194 bool operator<=( const OPimEvent& );
195 bool operator>( const OEvent& ); 195 bool operator>( const OPimEvent& );
196 bool operator>=(const OEvent& ); 196 bool operator>=(const OPimEvent& );
197 */ 197 */
198 198
199 private: 199 private:
200 inline void changeOrModify(); 200 inline void changeOrModify();
201 void deref(); 201 void deref();
202 struct Data; 202 struct Data;
203 Data* data; 203 Data* data;
204 class Private; 204 class Private;
205 Private* priv; 205 Private* priv;
206 206
207}; 207};
208 208
209/** 209/**
210 * AN Event can span through multiple days. We split up a multiday eve 210 * AN Event can span through multiple days. We split up a multiday eve
211 */ 211 */
212class OEffectiveEvent 212class OEffectiveEvent
213{ 213{
214 214
215 public: 215 public:
216 typedef QValueList<OEffectiveEvent> ValueList; 216 typedef QValueList<OEffectiveEvent> ValueList;
217 enum Position { MidWay, Start, End, StartEnd }; 217 enum Position { MidWay, Start, End, StartEnd };
218 // If we calculate the effective event of a multi-day event 218 // If we calculate the effective event of a multi-day event
219 // we have to figure out whether we are at the first day, 219 // we have to figure out whether we are at the first day,
220 // at the end, or anywhere else ("middle"). This is important 220 // at the end, or anywhere else ("middle"). This is important
221 // for the start/end times (00:00/23:59) 221 // for the start/end times (00:00/23:59)
222 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- 222 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
223 // day event 223 // day event
224 // Start: start time -> 23:59 224 // Start: start time -> 23:59
225 // End: 00:00 -> end time 225 // End: 00:00 -> end time
226 // Start | End == StartEnd: for single-day events (default) 226 // Start | End == StartEnd: for single-day events (default)
227 // here we draw start time -> end time 227 // here we draw start time -> end time
228 OEffectiveEvent(); 228 OEffectiveEvent();
229 OEffectiveEvent( const OEvent& event, const QDate& startDate, Position pos = StartEnd ); 229 OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd );
230 OEffectiveEvent( const OEffectiveEvent& ); 230 OEffectiveEvent( const OEffectiveEvent& );
231 OEffectiveEvent &operator=( const OEffectiveEvent& ); 231 OEffectiveEvent &operator=( const OEffectiveEvent& );
232 ~OEffectiveEvent(); 232 ~OEffectiveEvent();
233 233
234 void setStartTime( const QTime& ); 234 void setStartTime( const QTime& );
235 void setEndTime( const QTime& ); 235 void setEndTime( const QTime& );
236 void setEvent( const OEvent& ); 236 void setEvent( const OPimEvent& );
237 void setDate( const QDate& ); 237 void setDate( const QDate& );
238 238
239 void setEffectiveDates( const QDate& from, const QDate& to ); 239 void setEffectiveDates( const QDate& from, const QDate& to );
240 240
241 QString description() const; 241 QString description() const;
242 QString location() const; 242 QString location() const;
243 QString note() const; 243 QString note() const;
244 OEvent event() const; 244 OPimEvent event() const;
245 QTime startTime() const; 245 QTime startTime() const;
246 QTime endTime() const; 246 QTime endTime() const;
247 QDate date() const; 247 QDate date() const;
248 248
249 /* return the length in hours */ 249 /* return the length in hours */
250 int length() const; 250 int length() const;
251 int size() const; 251 int size() const;
252 252
253 QDate startDate() const; 253 QDate startDate() const;
254 QDate endDate() const; 254 QDate endDate() const;
255 255
256 bool operator<( const OEffectiveEvent &e ) const; 256 bool operator<( const OEffectiveEvent &e ) const;
257 bool operator<=( const OEffectiveEvent &e ) const; 257 bool operator<=( const OEffectiveEvent &e ) const;
258 bool operator==( const OEffectiveEvent &e ) const; 258 bool operator==( const OEffectiveEvent &e ) const;
259 bool operator!=( const OEffectiveEvent &e ) const; 259 bool operator!=( const OEffectiveEvent &e ) const;
260 bool operator>( const OEffectiveEvent &e ) const; 260 bool operator>( const OEffectiveEvent &e ) const;
261 bool operator>= ( const OEffectiveEvent &e ) const; 261 bool operator>= ( const OEffectiveEvent &e ) const;
262 262
263 private: 263 private:
264 void deref(); 264 void deref();
265 inline void changeOrModify(); 265 inline void changeOrModify();
266 class Private; 266 class Private;
267 Private* priv; 267 Private* priv;
268 struct Data; 268 struct Data;
269 Data* data; 269 Data* data;
270 270
271}; 271};
272 272
273} 273}
274 274
275#endif 275#endif
diff --git a/libopie2/opiepim/core/opimnotify.h b/libopie2/opiepim/core/opimnotify.h
index d0e40ca..4f74d2e 100644
--- a/libopie2/opiepim/core/opimnotify.h
+++ b/libopie2/opiepim/core/opimnotify.h
@@ -1,181 +1,181 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OPIMNOTIFY_H 30#ifndef OPIMNOTIFY_H
31#define OPIMNOTIFY_H 31#define OPIMNOTIFY_H
32 32
33/* QT */ 33/* QT */
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37namespace Opie 37namespace Opie
38{ 38{
39/** 39/**
40 * This is the base class of Notifiers. Possible 40 * This is the base class of Notifiers. Possible
41 * notifiers would be Alarms, Reminders 41 * notifiers would be Alarms, Reminders
42 * What they share is that they have 42 * What they share is that they have
43 * A DateTime, Type, Duration 43 * A DateTime, Type, Duration
44 * This is what this base class takes care of 44 * This is what this base class takes care of
45 * on top of that it's shared 45 * on top of that it's shared
46 */ 46 */
47/* 47/*
48 * TALK to eilers: have a class OPimDuration which sets the Duration 48 * TALK to eilers: have a class OPimDuration which sets the Duration
49 * given on the Due/Start Date? -zecke 49 * given on the Due/Start Date? -zecke
50 * discuss: do we need a uid for the notify? -zecke 50 * discuss: do we need a uid for the notify? -zecke
51 */ 51 */
52class OPimNotify 52class OPimNotify
53{ 53{
54 54
55 public: 55 public:
56 typedef QValueList<OPimNotify> ValueList; 56 typedef QValueList<OPimNotify> ValueList;
57 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); 57 OPimNotify( const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
58 OPimNotify( const OPimNotify& ); 58 OPimNotify( const OPimNotify& );
59 virtual ~OPimNotify(); 59 virtual ~OPimNotify();
60 60
61 OPimNotify &operator=( const OPimNotify& ); 61 OPimNotify &operator=( const OPimNotify& );
62 bool operator==( const OPimNotify& ); 62 bool operator==( const OPimNotify& );
63 63
64 virtual QString type() const = 0; 64 virtual QString type() const = 0;
65 65
66 /** start date */ 66 /** start date */
67 QDateTime dateTime() const; 67 QDateTime dateTime() const;
68 QString service() const; 68 QString service() const;
69 69
70 /** 70 /**
71 * RETURN the parent uid 71 * RETURN the parent uid
72 */ 72 */
73 int parent() const; 73 int parent() const;
74 74
75 /** 75 /**
76 * in Seconds 76 * in Seconds
77 */ 77 */
78 int duration() const; 78 int duration() const;
79 79
80 /** 80 /**
81 * Start Time + Duration 81 * Start Time + Duration
82 */ 82 */
83 QDateTime endTime() const; 83 QDateTime endTime() const;
84 84
85 void setDateTime( const QDateTime& ); 85 void setDateTime( const QDateTime& );
86 void setDuration( int dur ); 86 void setDuration( int dur );
87 void setParent( int uid ); 87 void setParent( int uid );
88 void setService( const QString& ); 88 void setService( const QString& );
89 89
90 90
91 private: 91 private:
92 inline void copyIntern(); 92 inline void copyIntern();
93 void deref(); 93 void deref();
94 struct Data; 94 struct Data;
95 Data* data; 95 Data* data;
96 96
97 /* d-pointer */ 97 /* d-pointer */
98 class NotifyPrivate; 98 class NotifyPrivate;
99 NotifyPrivate* d; 99 NotifyPrivate* d;
100 100
101}; 101};
102/** 102/**
103 * An alarm is a sound/mail/buzzer played/send 103 * An alarm is a sound/mail/buzzer played/send
104 * at a given time to inform about 104 * at a given time to inform about
105 * an Event 105 * an Event
106 */ 106 */
107class OPimAlarm : public OPimNotify 107class OPimAlarm : public OPimNotify
108{ 108{
109 public: 109 public:
110 enum Sound{Loud = 1, Silent = 0, Custom = 2 }; 110 enum Sound{Loud = 1, Silent = 0, Custom = 2 };
111 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 ); 111 OPimAlarm( int sound = Silent, const QDateTime& start = QDateTime(), int duration = 0, int parent = 0 );
112 OPimAlarm( const OPimAlarm& ); 112 OPimAlarm( const OPimAlarm& );
113 ~OPimAlarm(); 113 ~OPimAlarm();
114 114
115 OPimAlarm &operator=( const OPimAlarm& ); 115 OPimAlarm &operator=( const OPimAlarm& );
116 bool operator==( const OPimAlarm& ); 116 bool operator==( const OPimAlarm& );
117 QString type() const; 117 QString type() const;
118 118
119 int sound() const; 119 int sound() const;
120 QString file() const; 120 QString file() const;
121 121
122 void setSound( int ); 122 void setSound( int );
123 /* only when sound is custom... */ 123 /* only when sound is custom... */
124 void setFile( const QString& sound ); 124 void setFile( const QString& sound );
125 125
126 private: 126 private:
127 void deref(); 127 void deref();
128 void copyIntern(); 128 void copyIntern();
129 struct Data; 129 struct Data;
130 Data * data; 130 Data * data;
131 131
132 class Private; 132 class Private;
133 Private* d; 133 Private* d;
134 134
135}; 135};
136 136
137/** 137/**
138 * A Reminder will be put into the 138 * A Reminder will be put into the
139 * datebook 139 * datebook
140 * Note that the returned dateTime() may be not valid. 140 * Note that the returned dateTime() may be not valid.
141 * In these cases one must resolve the uid and get the OEvent 141 * In these cases one must resolve the uid and get the OPimEvent
142 */ 142 */
143class OPimReminder : public OPimNotify 143class OPimReminder : public OPimNotify
144{ 144{
145 public: 145 public:
146 /** 146 /**
147 * c'tor of a reminder 147 * c'tor of a reminder
148 * @param uid The uid of the Record inside the Datebook 148 * @param uid The uid of the Record inside the Datebook
149 * @param start the StartDate invalid for all day... 149 * @param start the StartDate invalid for all day...
150 * @param duration The duration of the event ( -1 for all day ) 150 * @param duration The duration of the event ( -1 for all day )
151 * @param parent The 'parent' record of this reminder 151 * @param parent The 'parent' record of this reminder
152 */ 152 */
153 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(), 153 OPimReminder( int uid = 0, const QDateTime& start = QDateTime(),
154 int duration = 0, int parent = 0 ); 154 int duration = 0, int parent = 0 );
155 OPimReminder( const OPimReminder& ); 155 OPimReminder( const OPimReminder& );
156 OPimReminder &operator=( const OPimReminder& ); 156 OPimReminder &operator=( const OPimReminder& );
157 157
158 QString type() const; 158 QString type() const;
159 159
160 bool operator==( const OPimReminder& ); 160 bool operator==( const OPimReminder& );
161 161
162 /** 162 /**
163 * the uid of the alarm 163 * the uid of the alarm
164 * inside the 'datebook' application 164 * inside the 'datebook' application
165 */ 165 */
166 int recordUid() const; 166 int recordUid() const;
167 void setRecordUid( int uid ); 167 void setRecordUid( int uid );
168 168
169 private: 169 private:
170 void deref(); 170 void deref();
171 void copyIntern(); 171 void copyIntern();
172 172
173 struct Data; 173 struct Data;
174 Data* data; 174 Data* data;
175 class Private; 175 class Private;
176 Private *d; 176 Private *d;
177}; 177};
178 178
179} 179}
180 180
181#endif 181#endif
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index a54d597..573340a 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -1,249 +1,249 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimnotifymanager.h" 30#include "opimnotifymanager.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/oconversion.h> 33#include <opie2/opimdateconversion.h>
34 34
35/* QT */ 35/* QT */
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38namespace Opie 38namespace Opie
39{ 39{
40 40
41OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) 41OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al )
42 : m_rem( rem ), m_al( al ) 42 : m_rem( rem ), m_al( al )
43{} 43{}
44 44
45 45
46OPimNotifyManager::~OPimNotifyManager() 46OPimNotifyManager::~OPimNotifyManager()
47{} 47{}
48 48
49 49
50/* use static_cast and type instead of dynamic... */ 50/* use static_cast and type instead of dynamic... */
51void OPimNotifyManager::add( const OPimNotify& noti ) 51void OPimNotifyManager::add( const OPimNotify& noti )
52{ 52{
53 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) 53 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
54 { 54 {
55 const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); 55 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
56 m_rem.append( rem ); 56 m_rem.append( rem );
57 } 57 }
58 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) 58 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
59 { 59 {
60 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); 60 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
61 m_al.append( al ); 61 m_al.append( al );
62 } 62 }
63} 63}
64 64
65 65
66void OPimNotifyManager::remove( const OPimNotify& noti ) 66void OPimNotifyManager::remove( const OPimNotify& noti )
67{ 67{
68 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) 68 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
69 { 69 {
70 const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); 70 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
71 m_rem.remove( rem ); 71 m_rem.remove( rem );
72 } 72 }
73 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) 73 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
74 { 74 {
75 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); 75 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
76 m_al.remove( al ); 76 m_al.remove( al );
77 } 77 }
78} 78}
79 79
80 80
81void OPimNotifyManager::replace( const OPimNotify& noti ) 81void OPimNotifyManager::replace( const OPimNotify& noti )
82{ 82{
83 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) ) 83 if ( noti.type() == QString::fromLatin1( "OPimReminder" ) )
84 { 84 {
85 const OPimReminder & rem = static_cast<const OPimReminder&>( noti ); 85 const OPimReminder & rem = static_cast<const OPimReminder&>( noti );
86 m_rem.remove( rem ); 86 m_rem.remove( rem );
87 m_rem.append( rem ); 87 m_rem.append( rem );
88 } 88 }
89 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) ) 89 else if ( noti.type() == QString::fromLatin1( "OPimAlarm" ) )
90 { 90 {
91 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti ); 91 const OPimAlarm & al = static_cast<const OPimAlarm&>( noti );
92 m_al.remove( al ); 92 m_al.remove( al );
93 m_al.append( al ); 93 m_al.append( al );
94 } 94 }
95} 95}
96 96
97 97
98OPimNotifyManager::Reminders OPimNotifyManager::reminders() const 98OPimNotifyManager::Reminders OPimNotifyManager::reminders() const
99{ 99{
100 return m_rem; 100 return m_rem;
101} 101}
102 102
103 103
104OPimNotifyManager::Alarms OPimNotifyManager::alarms() const 104OPimNotifyManager::Alarms OPimNotifyManager::alarms() const
105{ 105{
106 return m_al; 106 return m_al;
107} 107}
108 108
109 109
110OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const 110OPimAlarm OPimNotifyManager::alarmAtDateTime( const QDateTime& when, bool& found ) const
111{ 111{
112 Alarms::ConstIterator it; 112 Alarms::ConstIterator it;
113 found = true; 113 found = true;
114 114
115 for ( it = m_al.begin(); it != m_al.end(); ++it ) 115 for ( it = m_al.begin(); it != m_al.end(); ++it )
116 { 116 {
117 if ( ( *it ).dateTime() == when ) 117 if ( ( *it ).dateTime() == when )
118 return ( *it ); 118 return ( *it );
119 } 119 }
120 120
121 // Fall through if nothing could be found 121 // Fall through if nothing could be found
122 found = false; 122 found = false;
123 OPimAlarm empty; 123 OPimAlarm empty;
124 return empty; 124 return empty;
125} 125}
126 126
127 127
128void OPimNotifyManager::setAlarms( const Alarms& al ) 128void OPimNotifyManager::setAlarms( const Alarms& al )
129{ 129{
130 m_al = al; 130 m_al = al;
131} 131}
132 132
133 133
134void OPimNotifyManager::setReminders( const Reminders& rem ) 134void OPimNotifyManager::setReminders( const Reminders& rem )
135{ 135{
136 m_rem = rem; 136 m_rem = rem;
137} 137}
138 138
139 139
140/* FIXME!!! */ 140/* FIXME!!! */
141/** 141/**
142 * The idea is to check if the provider for our service 142 * The idea is to check if the provider for our service
143 * is online 143 * is online
144 * if it is we will use QCOP 144 * if it is we will use QCOP
145 * if not the Factory to get the backend... 145 * if not the Factory to get the backend...
146 * Qtopia1.6 services would be kewl to have here.... 146 * Qtopia1.6 services would be kewl to have here....
147 */ 147 */
148void OPimNotifyManager::registerNotify( const OPimNotify& ) 148void OPimNotifyManager::registerNotify( const OPimNotify& )
149{ 149{
150} 150}
151 151
152 152
153/* FIXME!!! */ 153/* FIXME!!! */
154/** 154/**
155 * same as above... 155 * same as above...
156 * Also implement Url model 156 * Also implement Url model
157 * have a MainWindow.... 157 * have a MainWindow....
158 */ 158 */
159void OPimNotifyManager::deregister( const OPimNotify& ) 159void OPimNotifyManager::deregister( const OPimNotify& )
160{ 160{
161} 161}
162 162
163 163
164bool OPimNotifyManager::isEmpty() const 164bool OPimNotifyManager::isEmpty() const
165{ 165{
166 qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); 166 qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
167 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 167 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
168 else return false; 168 else return false;
169} 169}
170 170
171 171
172// Taken from otodoaccessxml.. code duplication bad. any alternative? 172// Taken from otodoaccessxml.. code duplication bad. any alternative?
173QString OPimNotifyManager::alarmsToString() const 173QString OPimNotifyManager::alarmsToString() const
174{ 174{
175 QString str; 175 QString str;
176 176
177 OPimNotifyManager::Alarms alarms = m_al; 177 OPimNotifyManager::Alarms alarms = m_al;
178 if ( !alarms.isEmpty() ) 178 if ( !alarms.isEmpty() )
179 { 179 {
180 QStringList als; 180 QStringList als;
181 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 181 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
182 for ( ; it != alarms.end(); ++it ) 182 for ( ; it != alarms.end(); ++it )
183 { 183 {
184 /* only if time is valid */ 184 /* only if time is valid */
185 if ( ( *it ).dateTime().isValid() ) 185 if ( ( *it ).dateTime().isValid() )
186 { 186 {
187 als << OConversion::dateTimeToString( ( *it ).dateTime() ) 187 als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() )
188 + ":" + QString::number( ( *it ).duration() ) 188 + ":" + QString::number( ( *it ).duration() )
189 + ":" + QString::number( ( *it ).sound() ) 189 + ":" + QString::number( ( *it ).sound() )
190 + ":"; 190 + ":";
191 } 191 }
192 } 192 }
193 // now write the list 193 // now write the list
194 qWarning( "als: %s", als.join( "____________" ).latin1() ); 194 qWarning( "als: %s", als.join( "____________" ).latin1() );
195 str = als.join( ";" ); 195 str = als.join( ";" );
196 } 196 }
197 197
198 return str; 198 return str;
199} 199}
200 200
201 201
202QString OPimNotifyManager::remindersToString() const 202QString OPimNotifyManager::remindersToString() const
203{ 203{
204 QString str; 204 QString str;
205 205
206 OPimNotifyManager::Reminders reminders = m_rem; 206 OPimNotifyManager::Reminders reminders = m_rem;
207 if ( !reminders.isEmpty() ) 207 if ( !reminders.isEmpty() )
208 { 208 {
209 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 209 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
210 QStringList records; 210 QStringList records;
211 for ( ; it != reminders.end(); ++it ) 211 for ( ; it != reminders.end(); ++it )
212 { 212 {
213 records << QString::number( ( *it ).recordUid() ); 213 records << QString::number( ( *it ).recordUid() );
214 } 214 }
215 str = records.join( ";" ); 215 str = records.join( ";" );
216 } 216 }
217 217
218 return str; 218 return str;
219} 219}
220 220
221 221
222void OPimNotifyManager::alarmsFromString( const QString& str ) 222void OPimNotifyManager::alarmsFromString( const QString& str )
223{ 223{
224 QStringList als = QStringList::split( ";", str ); 224 QStringList als = QStringList::split( ";", str );
225 for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) 225 for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it )
226 { 226 {
227 QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty 227 QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty
228 qWarning( "alarm: %s", alarm.join( "___" ).latin1() ); 228 qWarning( "alarm: %s", alarm.join( "___" ).latin1() );
229 qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), 229 qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(),
230 OConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); 230 OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() );
231 OPimAlarm al( alarm[ 2 ].toInt(), OConversion::dateTimeFromString( alarm[ 0 ] ), 231 OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ),
232 alarm[ 1 ].toInt() ); 232 alarm[ 1 ].toInt() );
233 add( al ); 233 add( al );
234 } 234 }
235} 235}
236 236
237 237
238void OPimNotifyManager::remindersFromString( const QString& str ) 238void OPimNotifyManager::remindersFromString( const QString& str )
239{ 239{
240 240
241 QStringList rems = QStringList::split( ";", str ); 241 QStringList rems = QStringList::split( ";", str );
242 for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) 242 for ( QStringList::Iterator it = rems.begin(); it != rems.end(); ++it )
243 { 243 {
244 OPimReminder rem( ( *it ).toInt() ); 244 OPimReminder rem( ( *it ).toInt() );
245 add( rem ); 245 add( rem );
246 } 246 }
247 247
248} 248}
249} 249}
diff --git a/libopie2/opiepim/orecordlist.h b/libopie2/opiepim/core/opimrecordlist.h
index 1742dcc..b23138d 100644
--- a/libopie2/opiepim/orecordlist.h
+++ b/libopie2/opiepim/core/opimrecordlist.h
@@ -1,402 +1,402 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ORECORDLIST_H 30#ifndef ORECORDLIST_H
31#define ORECORDLIST_H 31#define ORECORDLIST_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/otemplatebase.h> 34#include <opie2/opimtemplatebase.h>
35#include <opie2/opimrecord.h> 35#include <opie2/opimrecord.h>
36 36
37/* QT */ 37/* QT */
38#include <qarray.h> 38#include <qarray.h>
39 39
40namespace Opie 40namespace Opie
41{ 41{
42 42
43class ORecordListIteratorPrivate; 43class OPimRecordListIteratorPrivate;
44/** 44/**
45 * Our List Iterator 45 * Our List Iterator
46 * it behaves like STL or Qt 46 * it behaves like STL or Qt
47 * 47 *
48 * for(it = list.begin(); it != list.end(); ++it ) 48 * for(it = list.begin(); it != list.end(); ++it )
49 * doSomeCoolStuff( (*it) ); 49 * doSomeCoolStuff( (*it) );
50 */ 50 */
51template <class T> class ORecordList; 51template <class T> class OPimRecordList;
52template <class T = OPimRecord> 52template <class T = OPimRecord>
53class ORecordListIterator 53class OPimRecordListIterator
54{ 54{
55 friend class ORecordList<T>; 55 friend class OPimRecordList<T>;
56 56
57 public: 57 public:
58 typedef OTemplateBase<T> Base; 58 typedef OTemplateBase<T> Base;
59 59
60 /** 60 /**
61 * The c'tor used internally from 61 * The c'tor used internally from
62 * ORecordList 62 * OPimRecordList
63 */ 63 */
64 ORecordListIterator( const QArray<int>, const Base* ); 64 OPimRecordListIterator( const QArray<int>, const Base* );
65 65
66 /** 66 /**
67 * The standard c'tor 67 * The standard c'tor
68 */ 68 */
69 ORecordListIterator(); 69 OPimRecordListIterator();
70 ~ORecordListIterator(); 70 ~OPimRecordListIterator();
71 71
72 ORecordListIterator( const ORecordListIterator& ); 72 OPimRecordListIterator( const OPimRecordListIterator& );
73 ORecordListIterator &operator=( const ORecordListIterator& ); 73 OPimRecordListIterator &operator=( const OPimRecordListIterator& );
74 74
75 /** 75 /**
76 * a * operator ;) 76 * a * operator ;)
77 * use it like this T = (*it); 77 * use it like this T = (*it);
78 */ 78 */
79 T operator*(); 79 T operator*();
80 ORecordListIterator &operator++(); 80 OPimRecordListIterator &operator++();
81 ORecordListIterator &operator--(); 81 OPimRecordListIterator &operator--();
82 82
83 bool operator==( const ORecordListIterator& it ); 83 bool operator==( const OPimRecordListIterator& it );
84 bool operator!=( const ORecordListIterator& it ); 84 bool operator!=( const OPimRecordListIterator& it );
85 85
86 /** 86 /**
87 * the current item 87 * the current item
88 */ 88 */
89 uint current() const; 89 uint current() const;
90 90
91 /** 91 /**
92 * the number of items 92 * the number of items
93 */ 93 */
94 uint count() const; 94 uint count() const;
95 95
96 /** 96 /**
97 * sets the current item 97 * sets the current item
98 */ 98 */
99 void setCurrent( uint cur ); 99 void setCurrent( uint cur );
100 100
101 private: 101 private:
102 QArray<int> m_uids; 102 QArray<int> m_uids;
103 uint m_current; 103 uint m_current;
104 const Base* m_temp; 104 const Base* m_temp;
105 bool m_end : 1; 105 bool m_end : 1;
106 T m_record; 106 T m_record;
107 bool m_direction : 1; 107 bool m_direction : 1;
108 108
109 /* d pointer for future versions */ 109 /* d pointer for future versions */
110 ORecordListIteratorPrivate *d; 110 OPimRecordListIteratorPrivate *d;
111}; 111};
112 112
113 113
114class ORecordListPrivate; 114class OPimRecordListPrivate;
115/** 115/**
116 * The recordlist used as a return type 116 * The recordlist used as a return type
117 * from OPimAccessTemplate 117 * from OPimAccessTemplate
118 */ 118 */
119template <class T = OPimRecord > 119template <class T = OPimRecord >
120class ORecordList 120class OPimRecordList
121{ 121{
122 public: 122 public:
123 typedef OTemplateBase<T> Base; 123 typedef OTemplateBase<T> Base;
124 typedef ORecordListIterator<T> Iterator; 124 typedef OPimRecordListIterator<T> Iterator;
125 125
126 /** 126 /**
127 * c'tor 127 * c'tor
128 */ 128 */
129 ORecordList () 129 OPimRecordList ()
130 {} 130 {}
131 ORecordList( const QArray<int>& ids, 131 OPimRecordList( const QArray<int>& ids,
132 const Base* ); 132 const Base* );
133 ~ORecordList(); 133 ~OPimRecordList();
134 134
135 /** 135 /**
136 * the first iterator 136 * the first iterator
137 */ 137 */
138 Iterator begin(); 138 Iterator begin();
139 139
140 /** 140 /**
141 * the end 141 * the end
142 */ 142 */
143 Iterator end(); 143 Iterator end();
144 144
145 /** 145 /**
146 * the number of items in the list 146 * the number of items in the list
147 */ 147 */
148 uint count() const; 148 uint count() const;
149 149
150 T operator[] ( uint i ); 150 T operator[] ( uint i );
151 int uidAt( uint i ); 151 int uidAt( uint i );
152 152
153 /** 153 /**
154 * Remove the contact with given uid 154 * Remove the contact with given uid
155 */ 155 */
156 bool remove( int uid ); 156 bool remove( int uid );
157 157
158 /* 158 /*
159 ConstIterator begin()const; 159 ConstIterator begin()const;
160 ConstIterator end()const; 160 ConstIterator end()const;
161 */ 161 */
162 private: 162 private:
163 QArray<int> m_ids; 163 QArray<int> m_ids;
164 const Base* m_acc; 164 const Base* m_acc;
165 ORecordListPrivate *d; 165 OPimRecordListPrivate *d;
166}; 166};
167 167
168 168
169/* ok now implement it */ 169/* ok now implement it */
170template <class T> 170template <class T>
171ORecordListIterator<T>::ORecordListIterator() 171OPimRecordListIterator<T>::OPimRecordListIterator()
172{ 172{
173 m_current = 0; 173 m_current = 0;
174 m_temp = 0l; 174 m_temp = 0l;
175 m_end = true; 175 m_end = true;
176 m_record = T(); 176 m_record = T();
177 /* forward */ 177 /* forward */
178 m_direction = TRUE; 178 m_direction = TRUE;
179} 179}
180 180
181 181
182template <class T> 182template <class T>
183ORecordListIterator<T>::~ORecordListIterator() 183OPimRecordListIterator<T>::~OPimRecordListIterator()
184{ 184{
185 /* nothing to delete */ 185 /* nothing to delete */
186} 186}
187 187
188 188
189template <class T> 189template <class T>
190ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it ) 190OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it )
191{ 191{
192 // qWarning("ORecordListIterator copy c'tor"); 192 // qWarning("OPimRecordListIterator copy c'tor");
193 m_uids = it.m_uids; 193 m_uids = it.m_uids;
194 m_current = it.m_current; 194 m_current = it.m_current;
195 m_temp = it.m_temp; 195 m_temp = it.m_temp;
196 m_end = it.m_end; 196 m_end = it.m_end;
197 m_record = it.m_record; 197 m_record = it.m_record;
198 m_direction = it.m_direction; 198 m_direction = it.m_direction;
199} 199}
200 200
201 201
202template <class T> 202template <class T>
203ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it ) 203OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecordListIterator<T>& it )
204{ 204{
205 m_uids = it.m_uids; 205 m_uids = it.m_uids;
206 m_current = it.m_current; 206 m_current = it.m_current;
207 m_temp = it.m_temp; 207 m_temp = it.m_temp;
208 m_end = it.m_end; 208 m_end = it.m_end;
209 m_record = it.m_record; 209 m_record = it.m_record;
210 210
211 return *this; 211 return *this;
212} 212}
213 213
214 214
215template <class T> 215template <class T>
216T ORecordListIterator<T>::operator*() 216T OPimRecordListIterator<T>::operator*()
217{ 217{
218 //qWarning("operator* %d %d", m_current, m_uids[m_current] ); 218 //qWarning("operator* %d %d", m_current, m_uids[m_current] );
219 if ( !m_end ) 219 if ( !m_end )
220 m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, 220 m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current,
221 m_direction ? Base::Forward : 221 m_direction ? Base::Forward :
222 Base::Reverse ); 222 Base::Reverse );
223 else 223 else
224 m_record = T(); 224 m_record = T();
225 225
226 return m_record; 226 return m_record;
227} 227}
228 228
229 229
230template <class T> 230template <class T>
231ORecordListIterator<T> &ORecordListIterator<T>::operator++() 231OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator++()
232{ 232{
233 m_direction = true; 233 m_direction = true;
234 if ( m_current < m_uids.count() ) 234 if ( m_current < m_uids.count() )
235 { 235 {
236 m_end = false; 236 m_end = false;
237 ++m_current; 237 ++m_current;
238 } 238 }
239 else 239 else
240 m_end = true; 240 m_end = true;
241 241
242 return *this; 242 return *this;
243} 243}
244 244
245 245
246template <class T> 246template <class T>
247ORecordListIterator<T> &ORecordListIterator<T>::operator--() 247OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator--()
248{ 248{
249 m_direction = false; 249 m_direction = false;
250 if ( m_current > 0 ) 250 if ( m_current > 0 )
251 { 251 {
252 --m_current; 252 --m_current;
253 m_end = false; 253 m_end = false;
254 } 254 }
255 else 255 else
256 m_end = true; 256 m_end = true;
257 257
258 return *this; 258 return *this;
259} 259}
260 260
261 261
262template <class T> 262template <class T>
263bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) 263bool OPimRecordListIterator<T>::operator==( const OPimRecordListIterator<T>& it )
264{ 264{
265 265
266 /* if both are at we're the same.... */ 266 /* if both are at we're the same.... */
267 if ( m_end == it.m_end ) return true; 267 if ( m_end == it.m_end ) return true;
268 268
269 if ( m_uids != it.m_uids ) return false; 269 if ( m_uids != it.m_uids ) return false;
270 if ( m_current != it.m_current ) return false; 270 if ( m_current != it.m_current ) return false;
271 if ( m_temp != it.m_temp ) return false; 271 if ( m_temp != it.m_temp ) return false;
272 272
273 return true; 273 return true;
274} 274}
275 275
276 276
277template <class T> 277template <class T>
278bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) 278bool OPimRecordListIterator<T>::operator!=( const OPimRecordListIterator<T>& it )
279{ 279{
280 return !( *this == it ); 280 return !( *this == it );
281} 281}
282 282
283 283
284template <class T> 284template <class T>
285ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, 285OPimRecordListIterator<T>::OPimRecordListIterator( const QArray<int> uids,
286 const Base* t ) 286 const Base* t )
287 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), 287 : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ),
288 m_direction( false ) 288 m_direction( false )
289{ 289{
290 /* if the list is empty we're already at the end of the list */ 290 /* if the list is empty we're already at the end of the list */
291 if ( uids.count() == 0 ) 291 if ( uids.count() == 0 )
292 m_end = true; 292 m_end = true;
293} 293}
294 294
295 295
296template <class T> 296template <class T>
297uint ORecordListIterator<T>::current() const 297uint OPimRecordListIterator<T>::current() const
298{ 298{
299 return m_current; 299 return m_current;
300} 300}
301 301
302 302
303template <class T> 303template <class T>
304void ORecordListIterator<T>::setCurrent( uint cur ) 304void OPimRecordListIterator<T>::setCurrent( uint cur )
305{ 305{
306 if ( cur < m_uids.count() ) 306 if ( cur < m_uids.count() )
307 { 307 {
308 m_end = false; 308 m_end = false;
309 m_current = cur; 309 m_current = cur;
310 } 310 }
311} 311}
312template <class T> 312template <class T>
313uint ORecordListIterator<T>::count() const 313uint OPimRecordListIterator<T>::count() const
314{ 314{
315 return m_uids.count(); 315 return m_uids.count();
316} 316}
317 317
318 318
319template <class T> 319template <class T>
320ORecordList<T>::ORecordList( const QArray<int>& ids, 320OPimRecordList<T>::OPimRecordList( const QArray<int>& ids,
321 const Base* acc ) 321 const Base* acc )
322 : m_ids( ids ), m_acc( acc ) 322 : m_ids( ids ), m_acc( acc )
323{} 323{}
324 324
325 325
326template <class T> 326template <class T>
327ORecordList<T>::~ORecordList() 327OPimRecordList<T>::~OPimRecordList()
328{ 328{
329 /* nothing to do here */ 329 /* nothing to do here */
330} 330}
331 331
332 332
333template <class T> 333template <class T>
334typename ORecordList<T>::Iterator ORecordList<T>::begin() 334typename OPimRecordList<T>::Iterator OPimRecordList<T>::begin()
335{ 335{
336 Iterator it( m_ids, m_acc ); 336 Iterator it( m_ids, m_acc );
337 return it; 337 return it;
338} 338}
339 339
340 340
341template <class T> 341template <class T>
342typename ORecordList<T>::Iterator ORecordList<T>::end() 342typename OPimRecordList<T>::Iterator OPimRecordList<T>::end()
343{ 343{
344 Iterator it( m_ids, m_acc ); 344 Iterator it( m_ids, m_acc );
345 it.m_end = true; 345 it.m_end = true;
346 it.m_current = m_ids.count(); 346 it.m_current = m_ids.count();
347 347
348 return it; 348 return it;
349} 349}
350 350
351 351
352template <class T> 352template <class T>
353uint ORecordList<T>::count() const 353uint OPimRecordList<T>::count() const
354{ 354{
355 return m_ids.count(); 355 return m_ids.count();
356} 356}
357 357
358 358
359template <class T> 359template <class T>
360T ORecordList<T>::operator[] ( uint i ) 360T OPimRecordList<T>::operator[] ( uint i )
361{ 361{
362 if ( i >= m_ids.count() ) 362 if ( i >= m_ids.count() )
363 return T(); 363 return T();
364 /* forward */ 364 /* forward */
365 return m_acc->find( m_ids[ i ], m_ids, i ); 365 return m_acc->find( m_ids[ i ], m_ids, i );
366} 366}
367 367
368 368
369template <class T> 369template <class T>
370int ORecordList<T>::uidAt( uint i ) 370int OPimRecordList<T>::uidAt( uint i )
371{ 371{
372 return m_ids[ i ]; 372 return m_ids[ i ];
373} 373}
374 374
375 375
376template <class T> 376template <class T>
377bool ORecordList<T>::remove( int uid ) 377bool OPimRecordList<T>::remove( int uid )
378{ 378{
379 QArray<int> copy( m_ids.count() ); 379 QArray<int> copy( m_ids.count() );
380 int counter = 0; 380 int counter = 0;
381 bool ret_val = false; 381 bool ret_val = false;
382 382
383 for ( uint i = 0; i < m_ids.count(); i++ ) 383 for ( uint i = 0; i < m_ids.count(); i++ )
384 { 384 {
385 if ( m_ids[ i ] != uid ) 385 if ( m_ids[ i ] != uid )
386 { 386 {
387 copy[ counter++ ] = m_ids[ i ]; 387 copy[ counter++ ] = m_ids[ i ];
388 388
389 } 389 }
390 else 390 else
391 ret_val = true; 391 ret_val = true;
392 } 392 }
393 393
394 copy.resize( counter ); 394 copy.resize( counter );
395 m_ids = copy; 395 m_ids = copy;
396 396
397 397
398 return ret_val; 398 return ret_val;
399} 399}
400 400
401} 401}
402#endif 402#endif
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/opimrecurrence.cpp
index 5e2da25..98bd647 100644
--- a/libopie2/opiepim/core/orecur.cpp
+++ b/libopie2/opiepim/core/opimrecurrence.cpp
@@ -1,691 +1,691 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "orecur.h" 30#include "opimrecurrence.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/otimezone.h> 33#include <opie2/opimtimezone.h>
34#include <qpe/timeconversion.h> 34#include <qpe/timeconversion.h>
35 35
36/* QT */ 36/* QT */
37#include <qshared.h> 37#include <qshared.h>
38 38
39/* STD */ 39/* STD */
40#include <time.h> 40#include <time.h>
41 41
42namespace Opie { 42namespace Opie {
43 43
44struct ORecur::Data : public QShared { 44struct OPimRecurrence::Data : public QShared {
45 Data() : QShared() { 45 Data() : QShared() {
46 type = ORecur::NoRepeat; 46 type = OPimRecurrence::NoRepeat;
47 freq = -1; 47 freq = -1;
48 days = 0; 48 days = 0;
49 pos = 0; 49 pos = 0;
50 create = QDateTime::currentDateTime(); 50 create = QDateTime::currentDateTime();
51 hasEnd = FALSE; 51 hasEnd = FALSE;
52 end = QDate::currentDate(); 52 end = QDate::currentDate();
53 } 53 }
54 char days; // Q_UINT8 for 8 seven days;) 54 char days; // Q_UINT8 for 8 seven days;)
55 ORecur::RepeatType type; 55 OPimRecurrence::RepeatType type;
56 int freq; 56 int freq;
57 int pos; 57 int pos;
58 bool hasEnd : 1; 58 bool hasEnd : 1;
59 QDate end; 59 QDate end;
60 QDateTime create; 60 QDateTime create;
61 int rep; 61 int rep;
62 QString app; 62 QString app;
63 ExceptionList list; 63 ExceptionList list;
64 QDate start; 64 QDate start;
65}; 65};
66 66
67 67
68ORecur::ORecur() { 68OPimRecurrence::OPimRecurrence() {
69 data = new Data; 69 data = new Data;
70} 70}
71 71
72ORecur::ORecur( const QMap<int, QString>& map ) 72OPimRecurrence::OPimRecurrence( const QMap<int, QString>& map )
73{ 73{
74 ORecur(); 74 OPimRecurrence();
75 fromMap( map ); 75 fromMap( map );
76} 76}
77 77
78 78
79ORecur::ORecur( const ORecur& rec) 79OPimRecurrence::OPimRecurrence( const OPimRecurrence& rec)
80 : data( rec.data ) 80 : data( rec.data )
81{ 81{
82 data->ref(); 82 data->ref();
83} 83}
84 84
85 85
86ORecur::~ORecur() { 86OPimRecurrence::~OPimRecurrence() {
87 if ( data->deref() ) { 87 if ( data->deref() ) {
88 delete data; 88 delete data;
89 data = 0l; 89 data = 0l;
90 } 90 }
91} 91}
92 92
93 93
94void ORecur::deref() { 94void OPimRecurrence::deref() {
95 if ( data->deref() ) { 95 if ( data->deref() ) {
96 delete data; 96 delete data;
97 data = 0l; 97 data = 0l;
98 } 98 }
99} 99}
100 100
101 101
102bool ORecur::operator==( const ORecur& )const { 102bool OPimRecurrence::operator==( const OPimRecurrence& )const {
103 return false; 103 return false;
104} 104}
105 105
106 106
107ORecur &ORecur::operator=( const ORecur& re) { 107OPimRecurrence &OPimRecurrence::operator=( const OPimRecurrence& re) {
108 if ( *this == re ) return *this; 108 if ( *this == re ) return *this;
109 109
110 re.data->ref(); 110 re.data->ref();
111 deref(); 111 deref();
112 data = re.data; 112 data = re.data;
113 113
114 return *this; 114 return *this;
115} 115}
116 116
117 117
118bool ORecur::doesRecur()const { 118bool OPimRecurrence::doesRecur()const {
119 return !( type() == NoRepeat ); 119 return !( type() == NoRepeat );
120} 120}
121 121
122 122
123/* 123/*
124 * we try to be smart here 124 * we try to be smart here
125 * 125 *
126 */ 126 */
127bool ORecur::doesRecur( const QDate& date ) { 127bool OPimRecurrence::doesRecur( const QDate& date ) {
128 /* the day before the recurrance */ 128 /* the day before the recurrance */
129 QDate da = date.addDays(-1); 129 QDate da = date.addDays(-1);
130 130
131 QDate recur; 131 QDate recur;
132 if (!nextOcurrence( da, recur ) ) 132 if (!nextOcurrence( da, recur ) )
133 return false; 133 return false;
134 134
135 return (recur == date); 135 return (recur == date);
136} 136}
137 137
138 138
139// FIXME unuglify! 139// FIXME unuglify!
140// GPL from Datebookdb.cpp 140// GPL from Datebookdb.cpp
141// FIXME exception list! 141// FIXME exception list!
142bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { 142bool OPimRecurrence::nextOcurrence( const QDate& from, QDate& next ) {
143 bool stillLooking; 143 bool stillLooking;
144 stillLooking = p_nextOccurrence( from, next ); 144 stillLooking = p_nextOccurrence( from, next );
145 while ( stillLooking && data->list.contains(next) ) 145 while ( stillLooking && data->list.contains(next) )
146 stillLooking = p_nextOccurrence( next.addDays(1), next ); 146 stillLooking = p_nextOccurrence( next.addDays(1), next );
147 147
148 return stillLooking; 148 return stillLooking;
149} 149}
150 150
151 151
152bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { 152bool OPimRecurrence::p_nextOccurrence( const QDate& from, QDate& next ) {
153 153
154 // easy checks, first are we too far in the future or too far in the past? 154 // easy checks, first are we too far in the future or too far in the past?
155 QDate tmpDate; 155 QDate tmpDate;
156 int freq = frequency(); 156 int freq = frequency();
157 int diff, diff2, a; 157 int diff, diff2, a;
158 int iday, imonth, iyear; 158 int iday, imonth, iyear;
159 int dayOfWeek = 0; 159 int dayOfWeek = 0;
160 int firstOfWeek = 0; 160 int firstOfWeek = 0;
161 int weekOfMonth; 161 int weekOfMonth;
162 162
163 163
164 if (hasEndDate() && endDate() < from) 164 if (hasEndDate() && endDate() < from)
165 return FALSE; 165 return FALSE;
166 166
167 if (start() >= from ) { 167 if (start() >= from ) {
168 next = start(); 168 next = start();
169 return TRUE; 169 return TRUE;
170 } 170 }
171 171
172 switch ( type() ) { 172 switch ( type() ) {
173 case Weekly: 173 case Weekly:
174 /* weekly is just daily by 7 */ 174 /* weekly is just daily by 7 */
175 /* first convert the repeatPattern.Days() mask to the next 175 /* first convert the repeatPattern.Days() mask to the next
176 day of week valid after from */ 176 day of week valid after from */
177 dayOfWeek = from.dayOfWeek(); 177 dayOfWeek = from.dayOfWeek();
178 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ 178 dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */
179 179
180 /* this is done in case freq > 1 and from in week not 180 /* this is done in case freq > 1 and from in week not
181 for this round */ 181 for this round */
182 // firstOfWeek = 0; this is already done at decl. 182 // firstOfWeek = 0; this is already done at decl.
183 while(!((1 << firstOfWeek) & days() )) 183 while(!((1 << firstOfWeek) & days() ))
184 firstOfWeek++; 184 firstOfWeek++;
185 185
186 /* there is at least one 'day', or there would be no event */ 186 /* there is at least one 'day', or there would be no event */
187 while(!((1 << (dayOfWeek % 7)) & days() )) 187 while(!((1 << (dayOfWeek % 7)) & days() ))
188 dayOfWeek++; 188 dayOfWeek++;
189 189
190 dayOfWeek = dayOfWeek % 7; /* the actual day of week */ 190 dayOfWeek = dayOfWeek % 7; /* the actual day of week */
191 dayOfWeek -= start().dayOfWeek() -1; 191 dayOfWeek -= start().dayOfWeek() -1;
192 192
193 firstOfWeek = firstOfWeek % 7; /* the actual first of week */ 193 firstOfWeek = firstOfWeek % 7; /* the actual first of week */
194 firstOfWeek -= start().dayOfWeek() -1; 194 firstOfWeek -= start().dayOfWeek() -1;
195 195
196 // dayOfWeek may be negitive now 196 // dayOfWeek may be negitive now
197 // day of week is number of days to add to start day 197 // day of week is number of days to add to start day
198 198
199 freq *= 7; 199 freq *= 7;
200 // FALL-THROUGH !!!!! 200 // FALL-THROUGH !!!!!
201 case Daily: 201 case Daily:
202 // the add is for the possible fall through from weekly */ 202 // the add is for the possible fall through from weekly */
203 if(start().addDays(dayOfWeek) > from) { 203 if(start().addDays(dayOfWeek) > from) {
204 /* first week exception */ 204 /* first week exception */
205 next = QDate(start().addDays(dayOfWeek) ); 205 next = QDate(start().addDays(dayOfWeek) );
206 if ((next > endDate()) 206 if ((next > endDate())
207 && hasEndDate() ) 207 && hasEndDate() )
208 return FALSE; 208 return FALSE;
209 return TRUE; 209 return TRUE;
210 } 210 }
211 /* if from is middle of a non-week */ 211 /* if from is middle of a non-week */
212 212
213 diff = start().addDays(dayOfWeek).daysTo(from) % freq; 213 diff = start().addDays(dayOfWeek).daysTo(from) % freq;
214 diff2 = start().addDays(firstOfWeek).daysTo(from) % freq; 214 diff2 = start().addDays(firstOfWeek).daysTo(from) % freq;
215 215
216 if(diff != 0) 216 if(diff != 0)
217 diff = freq - diff; 217 diff = freq - diff;
218 if(diff2 != 0) 218 if(diff2 != 0)
219 diff2 = freq - diff2; 219 diff2 = freq - diff2;
220 diff = QMIN(diff, diff2); 220 diff = QMIN(diff, diff2);
221 221
222 next = QDate(from.addDays(diff)); 222 next = QDate(from.addDays(diff));
223 if ( (next > endDate()) 223 if ( (next > endDate())
224 && hasEndDate() ) 224 && hasEndDate() )
225 return FALSE; 225 return FALSE;
226 return TRUE; 226 return TRUE;
227 case MonthlyDay: 227 case MonthlyDay:
228 iday = from.day(); 228 iday = from.day();
229 iyear = from.year(); 229 iyear = from.year();
230 imonth = from.month(); 230 imonth = from.month();
231 /* find equivelent day of month for this month */ 231 /* find equivelent day of month for this month */
232 dayOfWeek = start().dayOfWeek(); 232 dayOfWeek = start().dayOfWeek();
233 weekOfMonth = (start().day() - 1) / 7; 233 weekOfMonth = (start().day() - 1) / 7;
234 234
235 /* work out when the next valid month is */ 235 /* work out when the next valid month is */
236 a = from.year() - start().year(); 236 a = from.year() - start().year();
237 a *= 12; 237 a *= 12;
238 a = a + (imonth - start().month()); 238 a = a + (imonth - start().month());
239 /* a is e.start()monthsFrom(from); */ 239 /* a is e.start()monthsFrom(from); */
240 if(a % freq) { 240 if(a % freq) {
241 a = freq - (a % freq); 241 a = freq - (a % freq);
242 imonth = from.month() + a; 242 imonth = from.month() + a;
243 if (imonth > 12) { 243 if (imonth > 12) {
244 imonth--; 244 imonth--;
245 iyear += imonth / 12; 245 iyear += imonth / 12;
246 imonth = imonth % 12; 246 imonth = imonth % 12;
247 imonth++; 247 imonth++;
248 } 248 }
249 } 249 }
250 /* imonth is now the first month after or on 250 /* imonth is now the first month after or on
251 from that matches the frequency given */ 251 from that matches the frequency given */
252 252
253 /* find for this month */ 253 /* find for this month */
254 tmpDate = QDate( iyear, imonth, 1 ); 254 tmpDate = QDate( iyear, imonth, 1 );
255 255
256 iday = 1; 256 iday = 1;
257 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; 257 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
258 iday += 7 * weekOfMonth; 258 iday += 7 * weekOfMonth;
259 while (iday > tmpDate.daysInMonth()) { 259 while (iday > tmpDate.daysInMonth()) {
260 imonth += freq; 260 imonth += freq;
261 if (imonth > 12) { 261 if (imonth > 12) {
262 imonth--; 262 imonth--;
263 iyear += imonth / 12; 263 iyear += imonth / 12;
264 imonth = imonth % 12; 264 imonth = imonth % 12;
265 imonth++; 265 imonth++;
266 } 266 }
267 tmpDate = QDate( iyear, imonth, 1 ); 267 tmpDate = QDate( iyear, imonth, 1 );
268 /* these loops could go for a while, check end case now */ 268 /* these loops could go for a while, check end case now */
269 if ((tmpDate > endDate()) && hasEndDate() ) 269 if ((tmpDate > endDate()) && hasEndDate() )
270 return FALSE; 270 return FALSE;
271 iday = 1; 271 iday = 1;
272 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; 272 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
273 iday += 7 * weekOfMonth; 273 iday += 7 * weekOfMonth;
274 } 274 }
275 tmpDate = QDate(iyear, imonth, iday); 275 tmpDate = QDate(iyear, imonth, iday);
276 276
277 if (tmpDate >= from) { 277 if (tmpDate >= from) {
278 next = tmpDate; 278 next = tmpDate;
279 if ((next > endDate() ) && hasEndDate() ) 279 if ((next > endDate() ) && hasEndDate() )
280 return FALSE; 280 return FALSE;
281 return TRUE; 281 return TRUE;
282 } 282 }
283 283
284 /* need to find the next iteration */ 284 /* need to find the next iteration */
285 do { 285 do {
286 imonth += freq; 286 imonth += freq;
287 if (imonth > 12) { 287 if (imonth > 12) {
288 imonth--; 288 imonth--;
289 iyear += imonth / 12; 289 iyear += imonth / 12;
290 imonth = imonth % 12; 290 imonth = imonth % 12;
291 imonth++; 291 imonth++;
292 } 292 }
293 tmpDate = QDate( iyear, imonth, 1 ); 293 tmpDate = QDate( iyear, imonth, 1 );
294 /* these loops could go for a while, check end case now */ 294 /* these loops could go for a while, check end case now */
295 if ((tmpDate > endDate()) && hasEndDate() ) 295 if ((tmpDate > endDate()) && hasEndDate() )
296 return FALSE; 296 return FALSE;
297 iday = 1; 297 iday = 1;
298 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7; 298 iday += (7 + dayOfWeek - tmpDate.dayOfWeek()) % 7;
299 iday += 7 * weekOfMonth; 299 iday += 7 * weekOfMonth;
300 } while (iday > tmpDate.daysInMonth()); 300 } while (iday > tmpDate.daysInMonth());
301 tmpDate = QDate(iyear, imonth, iday); 301 tmpDate = QDate(iyear, imonth, iday);
302 302
303 next = tmpDate; 303 next = tmpDate;
304 if ((next > endDate()) && hasEndDate() ) 304 if ((next > endDate()) && hasEndDate() )
305 return FALSE; 305 return FALSE;
306 return TRUE; 306 return TRUE;
307 case MonthlyDate: 307 case MonthlyDate:
308 iday = start().day(); 308 iday = start().day();
309 iyear = from.year(); 309 iyear = from.year();
310 imonth = from.month(); 310 imonth = from.month();
311 311
312 a = from.year() - start().year(); 312 a = from.year() - start().year();
313 a *= 12; 313 a *= 12;
314 a = a + (imonth - start().month()); 314 a = a + (imonth - start().month());
315 /* a is e.start()monthsFrom(from); */ 315 /* a is e.start()monthsFrom(from); */
316 if(a % freq) { 316 if(a % freq) {
317 a = freq - (a % freq); 317 a = freq - (a % freq);
318 imonth = from.month() + a; 318 imonth = from.month() + a;
319 if (imonth > 12) { 319 if (imonth > 12) {
320 imonth--; 320 imonth--;
321 iyear += imonth / 12; 321 iyear += imonth / 12;
322 imonth = imonth % 12; 322 imonth = imonth % 12;
323 imonth++; 323 imonth++;
324 } 324 }
325 } 325 }
326 /* imonth is now the first month after or on 326 /* imonth is now the first month after or on
327 from that matches the frequencey given */ 327 from that matches the frequencey given */
328 328
329 /* this could go for a while, worse case, 4*12 iterations, probably */ 329 /* this could go for a while, worse case, 4*12 iterations, probably */
330 while(!QDate::isValid(iyear, imonth, iday) ) { 330 while(!QDate::isValid(iyear, imonth, iday) ) {
331 imonth += freq; 331 imonth += freq;
332 if (imonth > 12) { 332 if (imonth > 12) {
333 imonth--; 333 imonth--;
334 iyear += imonth / 12; 334 iyear += imonth / 12;
335 imonth = imonth % 12; 335 imonth = imonth % 12;
336 imonth++; 336 imonth++;
337 } 337 }
338 /* these loops could go for a while, check end case now */ 338 /* these loops could go for a while, check end case now */
339 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) 339 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
340 return FALSE; 340 return FALSE;
341 } 341 }
342 342
343 if(QDate(iyear, imonth, iday) >= from) { 343 if(QDate(iyear, imonth, iday) >= from) {
344 /* done */ 344 /* done */
345 next = QDate(iyear, imonth, iday); 345 next = QDate(iyear, imonth, iday);
346 if ((next > endDate()) && hasEndDate() ) 346 if ((next > endDate()) && hasEndDate() )
347 return FALSE; 347 return FALSE;
348 return TRUE; 348 return TRUE;
349 } 349 }
350 350
351 /* ok, need to cycle */ 351 /* ok, need to cycle */
352 imonth += freq; 352 imonth += freq;
353 imonth--; 353 imonth--;
354 iyear += imonth / 12; 354 iyear += imonth / 12;
355 imonth = imonth % 12; 355 imonth = imonth % 12;
356 imonth++; 356 imonth++;
357 357
358 while(!QDate::isValid(iyear, imonth, iday) ) { 358 while(!QDate::isValid(iyear, imonth, iday) ) {
359 imonth += freq; 359 imonth += freq;
360 imonth--; 360 imonth--;
361 iyear += imonth / 12; 361 iyear += imonth / 12;
362 imonth = imonth % 12; 362 imonth = imonth % 12;
363 imonth++; 363 imonth++;
364 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() ) 364 if ((QDate(iyear, imonth, 1) > endDate()) && hasEndDate() )
365 return FALSE; 365 return FALSE;
366 } 366 }
367 367
368 next = QDate(iyear, imonth, iday); 368 next = QDate(iyear, imonth, iday);
369 if ((next > endDate()) && hasEndDate() ) 369 if ((next > endDate()) && hasEndDate() )
370 return FALSE; 370 return FALSE;
371 return TRUE; 371 return TRUE;
372 case Yearly: 372 case Yearly:
373 iday = start().day(); 373 iday = start().day();
374 imonth = start().month(); 374 imonth = start().month();
375 iyear = from.year(); // after all, we want to start in this year 375 iyear = from.year(); // after all, we want to start in this year
376 376
377 diff = 1; 377 diff = 1;
378 if(imonth == 2 && iday > 28) { 378 if(imonth == 2 && iday > 28) {
379 /* leap year, and it counts, calculate actual frequency */ 379 /* leap year, and it counts, calculate actual frequency */
380 if(freq % 4) 380 if(freq % 4)
381 if (freq % 2) 381 if (freq % 2)
382 freq = freq * 4; 382 freq = freq * 4;
383 else 383 else
384 freq = freq * 2; 384 freq = freq * 2;
385 /* else divides by 4 already, leave freq alone */ 385 /* else divides by 4 already, leave freq alone */
386 diff = 4; 386 diff = 4;
387 } 387 }
388 388
389 a = from.year() - start().year(); 389 a = from.year() - start().year();
390 if(a % freq) { 390 if(a % freq) {
391 a = freq - (a % freq); 391 a = freq - (a % freq);
392 iyear = iyear + a; 392 iyear = iyear + a;
393 } 393 }
394 394
395 /* under the assumption we won't hit one of the special not-leap years twice */ 395 /* under the assumption we won't hit one of the special not-leap years twice */
396 if(!QDate::isValid(iyear, imonth, iday)) { 396 if(!QDate::isValid(iyear, imonth, iday)) {
397 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ 397 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
398 iyear += freq; 398 iyear += freq;
399 } 399 }
400 400
401 if(QDate(iyear, imonth, iday) >= from) { 401 if(QDate(iyear, imonth, iday) >= from) {
402 next = QDate(iyear, imonth, iday); 402 next = QDate(iyear, imonth, iday);
403 403
404 if ((next > endDate()) && hasEndDate() ) 404 if ((next > endDate()) && hasEndDate() )
405 return FALSE; 405 return FALSE;
406 return TRUE; 406 return TRUE;
407 } 407 }
408 /* iyear == from.year(), need to advance again */ 408 /* iyear == from.year(), need to advance again */
409 iyear += freq; 409 iyear += freq;
410 /* under the assumption we won't hit one of the special not-leap years twice */ 410 /* under the assumption we won't hit one of the special not-leap years twice */
411 if(!QDate::isValid(iyear, imonth, iday)) { 411 if(!QDate::isValid(iyear, imonth, iday)) {
412 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ 412 /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */
413 iyear += freq; 413 iyear += freq;
414 } 414 }
415 415
416 next = QDate(iyear, imonth, iday); 416 next = QDate(iyear, imonth, iday);
417 if ((next > endDate()) && hasEndDate() ) 417 if ((next > endDate()) && hasEndDate() )
418 return FALSE; 418 return FALSE;
419 return TRUE; 419 return TRUE;
420 default: 420 default:
421 return FALSE; 421 return FALSE;
422 } 422 }
423} 423}
424 424
425 425
426ORecur::RepeatType ORecur::type()const{ 426OPimRecurrence::RepeatType OPimRecurrence::type()const{
427 return data->type; 427 return data->type;
428} 428}
429 429
430 430
431int ORecur::frequency()const { 431int OPimRecurrence::frequency()const {
432 return data->freq; 432 return data->freq;
433} 433}
434 434
435 435
436int ORecur::position()const { 436int OPimRecurrence::position()const {
437 return data->pos; 437 return data->pos;
438} 438}
439 439
440 440
441char ORecur::days() const{ 441char OPimRecurrence::days() const{
442 return data->days; 442 return data->days;
443} 443}
444 444
445 445
446bool ORecur::hasEndDate()const { 446bool OPimRecurrence::hasEndDate()const {
447 return data->hasEnd; 447 return data->hasEnd;
448} 448}
449 449
450 450
451QDate ORecur::endDate()const { 451QDate OPimRecurrence::endDate()const {
452 return data->end; 452 return data->end;
453} 453}
454 454
455 455
456QDate ORecur::start()const{ 456QDate OPimRecurrence::start()const{
457 return data->start; 457 return data->start;
458} 458}
459 459
460 460
461QDateTime ORecur::createdDateTime()const { 461QDateTime OPimRecurrence::createdDateTime()const {
462 return data->create; 462 return data->create;
463} 463}
464 464
465 465
466int ORecur::repetition()const { 466int OPimRecurrence::repetition()const {
467 return data->rep; 467 return data->rep;
468} 468}
469 469
470 470
471QString ORecur::service()const { 471QString OPimRecurrence::service()const {
472 return data->app; 472 return data->app;
473} 473}
474 474
475 475
476ORecur::ExceptionList& ORecur::exceptions() { 476OPimRecurrence::ExceptionList& OPimRecurrence::exceptions() {
477 return data->list; 477 return data->list;
478} 478}
479 479
480 480
481void ORecur::setType( const RepeatType& z) { 481void OPimRecurrence::setType( const RepeatType& z) {
482 checkOrModify(); 482 checkOrModify();
483 data->type = z; 483 data->type = z;
484} 484}
485 485
486 486
487void ORecur::setFrequency( int freq ) { 487void OPimRecurrence::setFrequency( int freq ) {
488 checkOrModify(); 488 checkOrModify();
489 data->freq = freq; 489 data->freq = freq;
490} 490}
491 491
492 492
493void ORecur::setPosition( int pos ) { 493void OPimRecurrence::setPosition( int pos ) {
494 checkOrModify(); 494 checkOrModify();
495 data->pos = pos; 495 data->pos = pos;
496} 496}
497 497
498 498
499void ORecur::setDays( char c ) { 499void OPimRecurrence::setDays( char c ) {
500 checkOrModify(); 500 checkOrModify();
501 data->days = c; 501 data->days = c;
502} 502}
503 503
504 504
505void ORecur::setEndDate( const QDate& dt) { 505void OPimRecurrence::setEndDate( const QDate& dt) {
506 checkOrModify(); 506 checkOrModify();
507 data->end = dt; 507 data->end = dt;
508} 508}
509 509
510 510
511void ORecur::setCreatedDateTime( const QDateTime& t) { 511void OPimRecurrence::setCreatedDateTime( const QDateTime& t) {
512 checkOrModify(); 512 checkOrModify();
513 data->create = t; 513 data->create = t;
514} 514}
515 515
516 516
517void ORecur::setHasEndDate( bool b) { 517void OPimRecurrence::setHasEndDate( bool b) {
518 checkOrModify(); 518 checkOrModify();
519 data->hasEnd = b; 519 data->hasEnd = b;
520} 520}
521 521
522 522
523void ORecur::setRepitition( int rep ) { 523void OPimRecurrence::setRepitition( int rep ) {
524 checkOrModify(); 524 checkOrModify();
525 data->rep = rep; 525 data->rep = rep;
526} 526}
527 527
528 528
529void ORecur::setService( const QString& app ) { 529void OPimRecurrence::setService( const QString& app ) {
530 checkOrModify(); 530 checkOrModify();
531 data->app = app; 531 data->app = app;
532} 532}
533 533
534 534
535void ORecur::setStart( const QDate& dt ) { 535void OPimRecurrence::setStart( const QDate& dt ) {
536 checkOrModify(); 536 checkOrModify();
537 data->start = dt; 537 data->start = dt;
538} 538}
539 539
540 540
541void ORecur::checkOrModify() { 541void OPimRecurrence::checkOrModify() {
542 if ( data->count != 1 ) { 542 if ( data->count != 1 ) {
543 data->deref(); 543 data->deref();
544 Data* d2 = new Data; 544 Data* d2 = new Data;
545 d2->days = data->days; 545 d2->days = data->days;
546 d2->type = data->type; 546 d2->type = data->type;
547 d2->freq = data->freq; 547 d2->freq = data->freq;
548 d2->pos = data->pos; 548 d2->pos = data->pos;
549 d2->hasEnd = data->hasEnd; 549 d2->hasEnd = data->hasEnd;
550 d2->end = data->end; 550 d2->end = data->end;
551 d2->create = data->create; 551 d2->create = data->create;
552 d2->rep = data->rep; 552 d2->rep = data->rep;
553 d2->app = data->app; 553 d2->app = data->app;
554 d2->list = data->list; 554 d2->list = data->list;
555 d2->start = data->start; 555 d2->start = data->start;
556 data = d2; 556 data = d2;
557 } 557 }
558} 558}
559 559
560 560
561QString ORecur::toString()const { 561QString OPimRecurrence::toString()const {
562 QString buf; 562 QString buf;
563 QMap<int, QString> recMap = toMap(); 563 QMap<int, QString> recMap = toMap();
564 564
565 buf += " rtype=\""; 565 buf += " rtype=\"";
566 buf += recMap[ORecur::RType]; 566 buf += recMap[OPimRecurrence::RType];
567 buf += "\""; 567 buf += "\"";
568 if (data->days > 0 ) 568 if (data->days > 0 )
569 buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; 569 buf += " rweekdays=\"" + recMap[OPimRecurrence::RWeekdays] + "\"";
570 if ( data->pos != 0 ) 570 if ( data->pos != 0 )
571 buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; 571 buf += " rposition=\"" + recMap[OPimRecurrence::RPosition] + "\"";
572 572
573 buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; 573 buf += " rfreq=\"" + recMap[OPimRecurrence::RFreq] + "\"";
574 buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; 574 buf += " rhasenddate=\"" + recMap[OPimRecurrence::RHasEndDate]+ "\"";
575 if ( data->hasEnd ) 575 if ( data->hasEnd )
576 buf += " enddt=\"" 576 buf += " enddt=\""
577 + recMap[ORecur::EndDate] 577 + recMap[OPimRecurrence::EndDate]
578 + "\""; 578 + "\"";
579 buf += " created=\"" + recMap[ORecur::Created] + "\""; 579 buf += " created=\"" + recMap[OPimRecurrence::Created] + "\"";
580 580
581 if ( data->list.isEmpty() ) return buf; 581 if ( data->list.isEmpty() ) return buf;
582 buf += " exceptions=\""; 582 buf += " exceptions=\"";
583 buf += recMap[ORecur::Exceptions]; 583 buf += recMap[OPimRecurrence::Exceptions];
584 buf += "\" "; 584 buf += "\" ";
585 585
586 return buf; 586 return buf;
587} 587}
588 588
589QString ORecur::rTypeString() const 589QString OPimRecurrence::rTypeString() const
590{ 590{
591 QString retString; 591 QString retString;
592 switch ( data->type ) { 592 switch ( data->type ) {
593 case ORecur::Daily: 593 case OPimRecurrence::Daily:
594 retString = "Daily"; 594 retString = "Daily";
595 break; 595 break;
596 case ORecur::Weekly: 596 case OPimRecurrence::Weekly:
597 retString = "Weekly"; 597 retString = "Weekly";
598 break; 598 break;
599 case ORecur::MonthlyDay: 599 case OPimRecurrence::MonthlyDay:
600 retString = "MonthlyDay"; 600 retString = "MonthlyDay";
601 break; 601 break;
602 case ORecur::MonthlyDate: 602 case OPimRecurrence::MonthlyDate:
603 retString = "MonthlyDate"; 603 retString = "MonthlyDate";
604 break; 604 break;
605 case ORecur::Yearly: 605 case OPimRecurrence::Yearly:
606 retString = "Yearly"; 606 retString = "Yearly";
607 break; 607 break;
608 default: 608 default:
609 retString = "NoRepeat"; 609 retString = "NoRepeat";
610 break; 610 break;
611 611
612 } 612 }
613 613
614 return retString; 614 return retString;
615} 615}
616 616
617QMap<QString, ORecur::RepeatType> ORecur::rTypeValueConvertMap() const 617QMap<QString, OPimRecurrence::RepeatType> OPimRecurrence::rTypeValueConvertMap() const
618{ 618{
619 QMap<QString, RepeatType> convertMap; 619 QMap<QString, RepeatType> convertMap;
620 620
621 convertMap.insert( QString( "Daily" ), ORecur::Daily ); 621 convertMap.insert( QString( "Daily" ), OPimRecurrence::Daily );
622 convertMap.insert( QString( "Weekly" ), ORecur::Weekly ); 622 convertMap.insert( QString( "Weekly" ), OPimRecurrence::Weekly );
623 convertMap.insert( QString( "MonthlyDay" ), ORecur::MonthlyDay ); 623 convertMap.insert( QString( "MonthlyDay" ), OPimRecurrence::MonthlyDay );
624 convertMap.insert( QString( "MonthlyDate" ), ORecur::MonthlyDate ); 624 convertMap.insert( QString( "MonthlyDate" ), OPimRecurrence::MonthlyDate );
625 convertMap.insert( QString( "Yearly" ), ORecur::Yearly ); 625 convertMap.insert( QString( "Yearly" ), OPimRecurrence::Yearly );
626 convertMap.insert( QString( "NoRepeat" ), ORecur::NoRepeat ); 626 convertMap.insert( QString( "NoRepeat" ), OPimRecurrence::NoRepeat );
627 627
628 return convertMap; 628 return convertMap;
629} 629}
630 630
631 631
632QMap<int, QString> ORecur::toMap() const 632QMap<int, QString> OPimRecurrence::toMap() const
633{ 633{
634 QMap<int, QString> retMap; 634 QMap<int, QString> retMap;
635 635
636 retMap.insert( ORecur::RType, rTypeString() ); 636 retMap.insert( OPimRecurrence::RType, rTypeString() );
637 retMap.insert( ORecur::RWeekdays, QString::number( static_cast<int>( data->days ) ) ); 637 retMap.insert( OPimRecurrence::RWeekdays, QString::number( static_cast<int>( data->days ) ) );
638 retMap.insert( ORecur::RPosition, QString::number(data->pos ) ); 638 retMap.insert( OPimRecurrence::RPosition, QString::number(data->pos ) );
639 retMap.insert( ORecur::RFreq, QString::number( data->freq ) ); 639 retMap.insert( OPimRecurrence::RFreq, QString::number( data->freq ) );
640 retMap.insert( ORecur::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) ); 640 retMap.insert( OPimRecurrence::RHasEndDate, QString::number( static_cast<int>( data->hasEnd ) ) );
641 if( data -> hasEnd ) 641 if( data -> hasEnd )
642 retMap.insert( ORecur::EndDate, QString::number( OTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) ); 642 retMap.insert( OPimRecurrence::EndDate, QString::number( OPimTimeZone::utc().fromUTCDateTime( QDateTime( data->end, QTime(12,0,0) ) ) ) );
643 retMap.insert( ORecur::Created, QString::number( OTimeZone::utc().fromUTCDateTime( data->create ) ) ); 643 retMap.insert( OPimRecurrence::Created, QString::number( OPimTimeZone::utc().fromUTCDateTime( data->create ) ) );
644 644
645 if ( data->list.isEmpty() ) return retMap; 645 if ( data->list.isEmpty() ) return retMap;
646 646
647 // save exceptions list here!! 647 // save exceptions list here!!
648 ExceptionList::ConstIterator it; 648 ExceptionList::ConstIterator it;
649 ExceptionList list = data->list; 649 ExceptionList list = data->list;
650 QString exceptBuf; 650 QString exceptBuf;
651 QDate date; 651 QDate date;
652 for ( it = list.begin(); it != list.end(); ++it ) { 652 for ( it = list.begin(); it != list.end(); ++it ) {
653 date = (*it); 653 date = (*it);
654 if ( it != list.begin() ) exceptBuf += " "; 654 if ( it != list.begin() ) exceptBuf += " ";
655 655
656 exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() ); 656 exceptBuf += QCString().sprintf("%04d%02d%02d", date.year(), date.month(), date.day() );
657 } 657 }
658 658
659 retMap.insert( ORecur::Exceptions, exceptBuf ); 659 retMap.insert( OPimRecurrence::Exceptions, exceptBuf );
660 660
661 return retMap; 661 return retMap;
662} 662}
663 663
664void ORecur::fromMap( const QMap<int, QString>& map ) 664void OPimRecurrence::fromMap( const QMap<int, QString>& map )
665{ 665{
666 QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap(); 666 QMap<QString, RepeatType> repTypeMap = rTypeValueConvertMap();
667 667
668 data -> type = repTypeMap[ map [ORecur::RType] ]; 668 data -> type = repTypeMap[ map [OPimRecurrence::RType] ];
669 data -> days = (char) map[ ORecur::RWeekdays ].toInt(); 669 data -> days = (char) map[ OPimRecurrence::RWeekdays ].toInt();
670 data -> pos = map[ ORecur::RPosition ].toInt(); 670 data -> pos = map[ OPimRecurrence::RPosition ].toInt();
671 data -> freq = map[ ORecur::RFreq ].toInt(); 671 data -> freq = map[ OPimRecurrence::RFreq ].toInt();
672 data -> hasEnd= map[ ORecur::RHasEndDate ].toInt() ? true : false; 672 data -> hasEnd= map[ OPimRecurrence::RHasEndDate ].toInt() ? true : false;
673 OTimeZone utc = OTimeZone::utc(); 673 OPimTimeZone utc = OPimTimeZone::utc();
674 if ( data -> hasEnd ){ 674 if ( data -> hasEnd ){
675 data -> end = utc.fromUTCDateTime( (time_t) map[ ORecur::EndDate ].toLong() ).date(); 675 data -> end = utc.fromUTCDateTime( (time_t) map[ OPimRecurrence::EndDate ].toLong() ).date();
676 } 676 }
677 data -> create = utc.fromUTCDateTime( (time_t) map[ ORecur::Created ].toLong() ).date(); 677 data -> create = utc.fromUTCDateTime( (time_t) map[ OPimRecurrence::Created ].toLong() ).date();
678 678
679#if 0 679#if 0
680 // FIXME: Exceptions currently not supported... 680 // FIXME: Exceptions currently not supported...
681 // Convert the list of exceptions from QString into ExceptionList 681 // Convert the list of exceptions from QString into ExceptionList
682 data -> list.clear(); 682 data -> list.clear();
683 QString exceptStr = map[ ORecur::Exceptions ]; 683 QString exceptStr = map[ OPimRecurrence::Exceptions ];
684 QStringList exceptList = QStringList::split( " ", exceptStr ); 684 QStringList exceptList = QStringList::split( " ", exceptStr );
685 ... 685 ...
686#endif 686#endif
687 687
688 688
689} 689}
690 690
691} 691}
diff --git a/libopie2/opiepim/core/orecur.h b/libopie2/opiepim/core/opimrecurrence.h
index 7808897..f186cfe 100644
--- a/libopie2/opiepim/core/orecur.h
+++ b/libopie2/opiepim/core/opimrecurrence.h
@@ -1,137 +1,137 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef ORECUR_H 30#ifndef ORECUR_H
31#define ORECUR_H 31#define ORECUR_H
32 32
33/* QT */ 33/* QT */
34#include <qdatetime.h> 34#include <qdatetime.h>
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36#include <qmap.h> 36#include <qmap.h>
37 37
38/* STD */ 38/* STD */
39#include <sys/types.h> 39#include <sys/types.h>
40 40
41namespace Opie { 41namespace Opie {
42/** 42/**
43 * Class to handle Recurrencies.. 43 * Class to handle Recurrencies..
44 */ 44 */
45 45
46class ORecur { 46class OPimRecurrence {
47 47
48 public: 48 public:
49 typedef QValueList<QDate> ExceptionList; 49 typedef QValueList<QDate> ExceptionList;
50 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay, 50 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
51 MonthlyDate, Yearly }; 51 MonthlyDate, Yearly };
52 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, 52 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
53 FRI = 0x10, SAT = 0x20, SUN = 0x40 }; 53 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
54 enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate, 54 enum Fields{ RType = 0, RWeekdays, RPosition, RFreq, RHasEndDate,
55 EndDate, Created, Exceptions }; 55 EndDate, Created, Exceptions };
56 56
57 ORecur(); 57 OPimRecurrence();
58 ORecur( const QMap<int, QString>& map ); 58 OPimRecurrence( const QMap<int, QString>& map );
59 ORecur( const ORecur& ); 59 OPimRecurrence( const OPimRecurrence& );
60 ~ORecur(); 60 ~OPimRecurrence();
61 61
62 ORecur &operator=( const ORecur& ); 62 OPimRecurrence &operator=( const OPimRecurrence& );
63 bool operator==(const ORecur& )const; 63 bool operator==(const OPimRecurrence& )const;
64 64
65 bool doesRecur()const; 65 bool doesRecur()const;
66 /* if it recurrs on that day */ 66 /* if it recurrs on that day */
67 bool doesRecur( const QDate& ); 67 bool doesRecur( const QDate& );
68 RepeatType type()const; 68 RepeatType type()const;
69 int frequency()const; 69 int frequency()const;
70 int position()const; 70 int position()const;
71 char days()const; 71 char days()const;
72 bool hasEndDate()const; 72 bool hasEndDate()const;
73 QDate start()const; 73 QDate start()const;
74 QDate endDate()const; 74 QDate endDate()const;
75 QDateTime createdDateTime()const; 75 QDateTime createdDateTime()const;
76 /** 76 /**
77 * starting on monday=0, sunday=6 77 * starting on monday=0, sunday=6
78 * for convience 78 * for convience
79 */ 79 */
80 bool repeatOnWeekDay( int day )const; 80 bool repeatOnWeekDay( int day )const;
81 81
82 /** 82 /**
83 * FromWhereToStart is not included!!! 83 * FromWhereToStart is not included!!!
84 */ 84 */
85 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate ); 85 bool nextOcurrence( const QDate& FromWhereToStart, QDate &recurDate );
86 86
87 /** 87 /**
88 * The module this ORecur belongs to 88 * The module this OPimRecurrence belongs to
89 */ 89 */
90 QString service()const; 90 QString service()const;
91 91
92 /* 92 /*
93 * reference to the exception list 93 * reference to the exception list
94 */ 94 */
95 ExceptionList &exceptions(); 95 ExceptionList &exceptions();
96 96
97 /** 97 /**
98 * the current repetition 98 * the current repetition
99 */ 99 */
100 int repetition()const; 100 int repetition()const;
101 101
102 void setType( const RepeatType& ); 102 void setType( const RepeatType& );
103 void setFrequency( int freq ); 103 void setFrequency( int freq );
104 void setPosition( int pos ); 104 void setPosition( int pos );
105 void setDays( char c); 105 void setDays( char c);
106 void setEndDate( const QDate& dt ); 106 void setEndDate( const QDate& dt );
107 void setStart( const QDate& dt ); 107 void setStart( const QDate& dt );
108 void setCreatedDateTime( const QDateTime& ); 108 void setCreatedDateTime( const QDateTime& );
109 void setHasEndDate( bool b ); 109 void setHasEndDate( bool b );
110 void setRepitition(int ); 110 void setRepitition(int );
111 111
112 void setService( const QString& ser ); 112 void setService( const QString& ser );
113 113
114 QMap<int, QString> toMap() const; 114 QMap<int, QString> toMap() const;
115 void fromMap( const QMap<int, QString>& map ); 115 void fromMap( const QMap<int, QString>& map );
116 116
117 /* almost internal */ 117 /* almost internal */
118 QString toString()const; 118 QString toString()const;
119 119
120 private: 120 private:
121 bool p_nextOccurrence( const QDate& from, QDate& next ); 121 bool p_nextOccurrence( const QDate& from, QDate& next );
122 void deref(); 122 void deref();
123 inline void checkOrModify(); 123 inline void checkOrModify();
124 124
125 /* Converts rType to String */ 125 /* Converts rType to String */
126 QString rTypeString() const; 126 QString rTypeString() const;
127 /* Returns a map to convert Stringname for RType to RepeatType */ 127 /* Returns a map to convert Stringname for RType to RepeatType */
128 QMap<QString, RepeatType> rTypeValueConvertMap() const; 128 QMap<QString, RepeatType> rTypeValueConvertMap() const;
129 129
130 class Data; 130 class Data;
131 Data* data; 131 Data* data;
132 class ORecurPrivate; 132 class OPimRecurrencePrivate;
133 ORecurPrivate *d; 133 OPimRecurrencePrivate *d;
134}; 134};
135 135
136} 136}
137#endif 137#endif
diff --git a/libopie2/opiepim/core/opimresolver.cpp b/libopie2/opiepim/core/opimresolver.cpp
index 73d7de1..eb6661a 100644
--- a/libopie2/opiepim/core/opimresolver.cpp
+++ b/libopie2/opiepim/core/opimresolver.cpp
@@ -1,231 +1,231 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimresolver.h" 30#include "opimresolver.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/ocontactaccess.h> 33#include <opie2/ocontactaccess.h>
34#include <opie2/otodoaccess.h> 34#include <opie2/otodoaccess.h>
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36 36
37/* QT */ 37/* QT */
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39 39
40namespace Opie { 40namespace Opie {
41 41
42OPimResolver* OPimResolver::m_self = 0l; 42OPimResolver* OPimResolver::m_self = 0l;
43 43
44OPimResolver::OPimResolver() { 44OPimResolver::OPimResolver() {
45 /* the built in channels */ 45 /* the built in channels */
46 m_builtIns << "Todolist" << "Addressbook" << "Datebook"; 46 m_builtIns << "Todolist" << "Addressbook" << "Datebook";
47} 47}
48OPimResolver* OPimResolver::self() { 48OPimResolver* OPimResolver::self() {
49 if (!m_self) 49 if (!m_self)
50 m_self = new OPimResolver(); 50 m_self = new OPimResolver();
51 51
52 return m_self; 52 return m_self;
53} 53}
54 54
55/* 55/*
56 * FIXME use a cache here too 56 * FIXME use a cache here too
57 */ 57 */
58OPimRecord* OPimResolver::record( const QString& service, int uid ) { 58OPimRecord* OPimResolver::record( const QString& service, int uid ) {
59 OPimRecord* rec = 0l; 59 OPimRecord* rec = 0l;
60 OPimBase* base = backend( service ); 60 OPimBase* base = backend( service );
61 61
62 if ( base ) 62 if ( base )
63 rec = base->record( uid ); 63 rec = base->record( uid );
64 delete base; 64 delete base;
65 65
66 return rec; 66 return rec;
67} 67}
68OPimRecord* OPimResolver::record( const QString& service ) { 68OPimRecord* OPimResolver::record( const QString& service ) {
69 return record( serviceId( service ) ); 69 return record( serviceId( service ) );
70} 70}
71OPimRecord* OPimResolver::record( int rtti ) { 71OPimRecord* OPimResolver::record( int rtti ) {
72 OPimRecord* rec = 0l; 72 OPimRecord* rec = 0l;
73 switch( rtti ) { 73 switch( rtti ) {
74 case 1: /* todolist */ 74 case 1: /* todolist */
75 rec = new OTodo(); 75 rec = new OPimTodo();
76 case 2: /* contact */ 76 case 2: /* contact */
77 rec = new OContact(); 77 rec = new OPimContact();
78 default: 78 default:
79 break; 79 break;
80 } 80 }
81 /* 81 /*
82 * FIXME resolve externally 82 * FIXME resolve externally
83 */ 83 */
84 if (!rec ) { 84 if (!rec ) {
85 ; 85 ;
86 } 86 }
87 return 0l; 87 return 0l;
88} 88}
89bool OPimResolver::isBuiltIn( const QString& str) const{ 89bool OPimResolver::isBuiltIn( const QString& str) const{
90 return m_builtIns.contains( str ); 90 return m_builtIns.contains( str );
91} 91}
92QCString OPimResolver::qcopChannel( enum BuiltIn& built)const { 92QCString OPimResolver::qcopChannel( enum BuiltIn& built)const {
93 QCString str("QPE/"); 93 QCString str("QPE/");
94 switch( built ) { 94 switch( built ) {
95 case TodoList: 95 case TodoList:
96 str += "Todolist"; 96 str += "Todolist";
97 break; 97 break;
98 case DateBook: 98 case DateBook:
99 str += "Datebook"; 99 str += "Datebook";
100 break; 100 break;
101 case AddressBook: 101 case AddressBook:
102 str += "Addressbook"; 102 str += "Addressbook";
103 break; 103 break;
104 default: 104 default:
105 break; 105 break;
106 } 106 }
107 107
108 return str; 108 return str;
109} 109}
110QCString OPimResolver::qcopChannel( const QString& service )const { 110QCString OPimResolver::qcopChannel( const QString& service )const {
111 QCString str("QPE/"); 111 QCString str("QPE/");
112 str += service.latin1(); 112 str += service.latin1();
113 return str; 113 return str;
114} 114}
115/* 115/*
116 * Implement services!! 116 * Implement services!!
117 * FIXME 117 * FIXME
118 */ 118 */
119QCString OPimResolver::applicationChannel( enum BuiltIn& built)const { 119QCString OPimResolver::applicationChannel( enum BuiltIn& built)const {
120 QCString str("QPE/Application/"); 120 QCString str("QPE/Application/");
121 switch( built ) { 121 switch( built ) {
122 case TodoList: 122 case TodoList:
123 str += "todolist"; 123 str += "todolist";
124 break; 124 break;
125 case DateBook: 125 case DateBook:
126 str += "datebook"; 126 str += "datebook";
127 break; 127 break;
128 case AddressBook: 128 case AddressBook:
129 str += "addressbook"; 129 str += "addressbook";
130 break; 130 break;
131 } 131 }
132 132
133 return str; 133 return str;
134} 134}
135QCString OPimResolver::applicationChannel( const QString& service )const { 135QCString OPimResolver::applicationChannel( const QString& service )const {
136 QCString str("QPE/Application/"); 136 QCString str("QPE/Application/");
137 137
138 if ( isBuiltIn( service ) ) { 138 if ( isBuiltIn( service ) ) {
139 if ( service == "Todolist" ) 139 if ( service == "Todolist" )
140 str += "todolist"; 140 str += "todolist";
141 else if ( service == "Datebook" ) 141 else if ( service == "Datebook" )
142 str += "datebook"; 142 str += "datebook";
143 else if ( service == "Addressbook" ) 143 else if ( service == "Addressbook" )
144 str += "addressbook"; 144 str += "addressbook";
145 }else 145 }else
146 ; // FIXME for additional stuff 146 ; // FIXME for additional stuff
147 147
148 return str; 148 return str;
149} 149}
150QStringList OPimResolver::services()const { 150QStringList OPimResolver::services()const {
151 return m_builtIns; 151 return m_builtIns;
152} 152}
153QString OPimResolver::serviceName( int rtti ) const{ 153QString OPimResolver::serviceName( int rtti ) const{
154 QString str; 154 QString str;
155 switch ( rtti ) { 155 switch ( rtti ) {
156 case TodoList: 156 case TodoList:
157 str = "Todolist"; 157 str = "Todolist";
158 break; 158 break;
159 case DateBook: 159 case DateBook:
160 str = "Datebook"; 160 str = "Datebook";
161 break; 161 break;
162 case AddressBook: 162 case AddressBook:
163 str = "Addressbook"; 163 str = "Addressbook";
164 break; 164 break;
165 default: 165 default:
166 break; 166 break;
167 } 167 }
168 return str; 168 return str;
169 // FIXME me for 3rd party 169 // FIXME me for 3rd party
170} 170}
171int OPimResolver::serviceId( const QString& service ) { 171int OPimResolver::serviceId( const QString& service ) {
172 int rtti = 0; 172 int rtti = 0;
173 if ( service == "Todolist" ) 173 if ( service == "Todolist" )
174 rtti = TodoList; 174 rtti = TodoList;
175 else if ( service == "Datebook" ) 175 else if ( service == "Datebook" )
176 rtti = DateBook; 176 rtti = DateBook;
177 else if ( service == "Addressbook" ) 177 else if ( service == "Addressbook" )
178 rtti = AddressBook; 178 rtti = AddressBook;
179 179
180 return rtti; 180 return rtti;
181} 181}
182/** 182/**
183 * check if the 'service' is registered and if so we'll 183 * check if the 'service' is registered and if so we'll
184 */ 184 */
185bool OPimResolver::add( const QString& service, const OPimRecord& rec) { 185bool OPimResolver::add( const QString& service, const OPimRecord& rec) {
186 if ( QCopChannel::isRegistered( applicationChannel( service ) ) ) { 186 if ( QCopChannel::isRegistered( applicationChannel( service ) ) ) {
187 QByteArray data; 187 QByteArray data;
188 QDataStream arg(data, IO_WriteOnly ); 188 QDataStream arg(data, IO_WriteOnly );
189 if ( rec.saveToStream( arg ) ) { 189 if ( rec.saveToStream( arg ) ) {
190 QCopEnvelope env( applicationChannel( service ), "add(int,QByteArray)" ); 190 QCopEnvelope env( applicationChannel( service ), "add(int,QByteArray)" );
191 env << rec.rtti(); 191 env << rec.rtti();
192 env << data; 192 env << data;
193 }else 193 }else
194 return false; 194 return false;
195 }else{ 195 }else{
196 OPimBase* base = backend( service ); 196 OPimBase* base = backend( service );
197 if (!base ) return false; 197 if (!base ) return false;
198 198
199 base->load(); 199 base->load();
200 base->add( rec ); 200 base->add( rec );
201 base->save(); 201 base->save();
202 delete base; 202 delete base;
203 } 203 }
204 204
205 return true; 205 return true;
206} 206}
207OPimBase* OPimResolver::backend( const QString& service ) { 207OPimBase* OPimResolver::backend( const QString& service ) {
208 return backend( serviceId( service ) ); 208 return backend( serviceId( service ) );
209} 209}
210OPimBase* OPimResolver::backend( int rtti ) { 210OPimBase* OPimResolver::backend( int rtti ) {
211 OPimBase* base = 0l; 211 OPimBase* base = 0l;
212 switch( rtti ) { 212 switch( rtti ) {
213 case TodoList: 213 case TodoList:
214 base = new OTodoAccess(); 214 base = new OPimTodoAccess();
215 break; 215 break;
216 case DateBook: 216 case DateBook:
217 break; 217 break;
218 case AddressBook: 218 case AddressBook:
219 base = new OContactAccess("Resolver"); 219 base = new OPimContactAccess("Resolver");
220 break; 220 break;
221 default: 221 default:
222 break; 222 break;
223 } 223 }
224 // FIXME for 3rd party 224 // FIXME for 3rd party
225 if (!base ) 225 if (!base )
226 ; 226 ;
227 227
228 return base; 228 return base;
229} 229}
230 230
231} 231}
diff --git a/libopie2/opiepim/core/opimresolver.h b/libopie2/opiepim/core/opimresolver.h
index dd6f07f..0a6dddf 100644
--- a/libopie2/opiepim/core/opimresolver.h
+++ b/libopie2/opiepim/core/opimresolver.h
@@ -1,125 +1,125 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIMRESOLVER_H 29#ifndef OPIMRESOLVER_H
30#define OPIMRESOLVER_H 30#define OPIMRESOLVER_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/otemplatebase.h> 33#include <opie2/opimtemplatebase.h>
34 34
35/* QT */ 35/* QT */
36#include <qstring.h> 36#include <qstring.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38 38
39namespace Opie { 39namespace Opie {
40/** 40/**
41 * OPimResolver is a MetaClass to access 41 * OPimResolver is a MetaClass to access
42 * available backends read only. 42 * available backends read only.
43 * It will be used to resolve uids + app names 43 * It will be used to resolve uids + app names
44 * to full informations 44 * to full informations
45 * to traverse through a list of alarms, reminders 45 * to traverse through a list of alarms, reminders
46 * to get access to built in PIM functionality 46 * to get access to built in PIM functionality
47 * and to more stuff 47 * and to more stuff
48 * THE PERFORMANCE will depend on THE BACKEND 48 * THE PERFORMANCE will depend on THE BACKEND
49 * USING XML is a waste of memory!!!!! 49 * USING XML is a waste of memory!!!!!
50 */ 50 */
51class OPimResolver { 51class OPimResolver {
52 52
53 public: 53 public:
54 enum BuiltIn { TodoList = 0, 54 enum BuiltIn { TodoList = 0,
55 DateBook, 55 DateBook,
56 AddressBook 56 AddressBook
57 }; 57 };
58 static OPimResolver* self(); 58 static OPimResolver* self();
59 59
60 60
61 /** 61 /**
62 * return a record for a uid 62 * return a record for a uid
63 * and an service 63 * and an service
64 * You've THE OWNERSHIP NOW! 64 * You've THE OWNERSHIP NOW!
65 */ 65 */
66 OPimRecord *record( const QString& service, int uid ); 66 OPimRecord *record( const QString& service, int uid );
67 67
68 /** 68 /**
69 * return the QCopChannel for service 69 * return the QCopChannel for service
70 * When we will use Qtopia Services it will be used here 70 * When we will use Qtopia Services it will be used here
71 */ 71 */
72 QCString qcopChannel( enum BuiltIn& )const; 72 QCString qcopChannel( enum BuiltIn& )const;
73 QCString qcopChannel( const QString& service )const; 73 QCString qcopChannel( const QString& service )const;
74 74
75 /** 75 /**
76 * The Application channel (QPE/Application/name) 76 * The Application channel (QPE/Application/name)
77 */ 77 */
78 QCString applicationChannel( enum BuiltIn& )const; 78 QCString applicationChannel( enum BuiltIn& )const;
79 QCString applicationChannel( const QString& service )const; 79 QCString applicationChannel( const QString& service )const;
80 80
81 /** 81 /**
82 * return a list of available services 82 * return a list of available services
83 */ 83 */
84 QStringList services()const; 84 QStringList services()const;
85 inline QString serviceName(int rrti )const; 85 inline QString serviceName(int rrti )const;
86 int serviceId( const QString& Service); 86 int serviceId( const QString& Service);
87 /** 87 /**
88 * add a record to a service... ;) 88 * add a record to a service... ;)
89 */ 89 */
90 bool add( const QString& service, const OPimRecord& ); 90 bool add( const QString& service, const OPimRecord& );
91 91
92 92
93 /** 93 /**
94 * record returns an empty record for a given service. 94 * record returns an empty record for a given service.
95 * Be sure to delete it!!! 95 * Be sure to delete it!!!
96 * 96 *
97 */ 97 */
98 OPimRecord* record( const QString& service ); 98 OPimRecord* record( const QString& service );
99 OPimRecord* record( int rtti ); 99 OPimRecord* record( int rtti );
100 100
101 /** 101 /**
102 * you can cast to your 102 * you can cast to your
103 */ 103 */
104 OPimBase* backend( const QString& service ); 104 OPimBase* backend( const QString& service );
105 OPimBase* backend( int rtti ); 105 OPimBase* backend( int rtti );
106 106
107 private: 107 private:
108 OPimResolver(); 108 OPimResolver();
109 void loadData(); 109 void loadData();
110 inline bool isBuiltIn( const QString& )const; 110 inline bool isBuiltIn( const QString& )const;
111 OPimRecord* recordExtern( const QString&, int ); 111 OPimRecord* recordExtern( const QString&, int );
112 OPimRecord* recordExtern( const QString& ); 112 OPimRecord* recordExtern( const QString& );
113 113
114 static OPimResolver* m_self; 114 static OPimResolver* m_self;
115 struct Data; 115 struct Data;
116 class Private; 116 class Private;
117 117
118 Data* data; 118 Data* data;
119 Private* d; 119 Private* d;
120 QStringList m_builtIns; 120 QStringList m_builtIns;
121}; 121};
122 122
123} 123}
124 124
125#endif 125#endif
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index 58cbfeb..58cbfeb 100644
--- a/libopie2/opiepim/core/otemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
diff --git a/libopie2/opiepim/core/otimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp
index e67715f..be21b1b 100644
--- a/libopie2/opiepim/core/otimezone.cpp
+++ b/libopie2/opiepim/core/opimtimezone.cpp
@@ -1,188 +1,188 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "otimezone.h" 30#include "opimtimezone.h"
31 31
32/* STD */ 32/* STD */
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include <sys/types.h> 35#include <sys/types.h>
36 36
37namespace Opie 37namespace Opie
38{ 38{
39 39
40QDateTime utcTime( time_t t ) 40QDateTime utcTime( time_t t )
41{ 41{
42 tm * broken = ::gmtime( &t ); 42 tm * broken = ::gmtime( &t );
43 QDateTime ret; 43 QDateTime ret;
44 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 44 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
45 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 45 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
46 return ret; 46 return ret;
47} 47}
48QDateTime utcTime( time_t t, const QString& zone ) 48QDateTime utcTime( time_t t, const QString& zone )
49{ 49{
50 QCString org = ::getenv( "TZ" ); 50 QCString org = ::getenv( "TZ" );
51#ifndef Q_OS_MACX // Following line causes bus errors on Mac 51#ifndef Q_OS_MACX // Following line causes bus errors on Mac
52 52
53 ::setenv( "TZ", zone.latin1(), true ); 53 ::setenv( "TZ", zone.latin1(), true );
54 ::tzset(); 54 ::tzset();
55 55
56 tm* broken = ::localtime( &t ); 56 tm* broken = ::localtime( &t );
57 ::setenv( "TZ", org, true ); 57 ::setenv( "TZ", org, true );
58#else 58#else
59#warning "Need a replacement for MacOSX!!" 59#warning "Need a replacement for MacOSX!!"
60 60
61 tm* broken = ::localtime( &t ); 61 tm* broken = ::localtime( &t );
62#endif 62#endif
63 63
64 QDateTime ret; 64 QDateTime ret;
65 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) ); 65 ret.setDate( QDate( broken->tm_year + 1900, broken->tm_mon + 1, broken->tm_mday ) );
66 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) ); 66 ret.setTime( QTime( broken->tm_hour, broken->tm_min, broken->tm_sec ) );
67 67
68 return ret; 68 return ret;
69} 69}
70time_t to_Time_t( const QDateTime& utc, const QString& str ) 70time_t to_Time_t( const QDateTime& utc, const QString& str )
71{ 71{
72 QDate d = utc.date(); 72 QDate d = utc.date();
73 QTime t = utc.time(); 73 QTime t = utc.time();
74 74
75 tm broken; 75 tm broken;
76 broken.tm_year = d.year() - 1900; 76 broken.tm_year = d.year() - 1900;
77 broken.tm_mon = d.month() - 1; 77 broken.tm_mon = d.month() - 1;
78 broken.tm_mday = d.day(); 78 broken.tm_mday = d.day();
79 broken.tm_hour = t.hour(); 79 broken.tm_hour = t.hour();
80 broken.tm_min = t.minute(); 80 broken.tm_min = t.minute();
81 broken.tm_sec = t.second(); 81 broken.tm_sec = t.second();
82 82
83 QCString org = ::getenv( "TZ" ); 83 QCString org = ::getenv( "TZ" );
84#ifndef Q_OS_MACX // Following line causes bus errors on Mac 84#ifndef Q_OS_MACX // Following line causes bus errors on Mac
85 85
86 ::setenv( "TZ", str.latin1(), true ); 86 ::setenv( "TZ", str.latin1(), true );
87 ::tzset(); 87 ::tzset();
88 88
89 time_t ti = ::mktime( &broken ); 89 time_t ti = ::mktime( &broken );
90 ::setenv( "TZ", org, true ); 90 ::setenv( "TZ", org, true );
91#else 91#else
92#warning "Need a replacement for MacOSX!!" 92#warning "Need a replacement for MacOSX!!"
93 93
94 time_t ti = ::mktime( &broken ); 94 time_t ti = ::mktime( &broken );
95#endif 95#endif
96 96
97 return ti; 97 return ti;
98} 98}
99} 99}
100 100
101namespace Opie 101namespace Opie
102{ 102{
103OTimeZone::OTimeZone( const ZoneName& zone ) 103OPimTimeZone::OPimTimeZone( const ZoneName& zone )
104 : m_name( zone ) 104 : m_name( zone )
105{} 105{}
106 106
107 107
108OTimeZone::~OTimeZone() 108OPimTimeZone::~OPimTimeZone()
109{} 109{}
110 110
111 111
112bool OTimeZone::isValid() const 112bool OPimTimeZone::isValid() const
113{ 113{
114 return !m_name.isEmpty(); 114 return !m_name.isEmpty();
115} 115}
116 116
117/* 117/*
118 * we will get the current timezone 118 * we will get the current timezone
119 * and ask it to convert to the timezone date 119 * and ask it to convert to the timezone date
120 */ 120 */
121QDateTime OTimeZone::toLocalDateTime( const QDateTime& dt ) 121QDateTime OPimTimeZone::toLocalDateTime( const QDateTime& dt )
122{ 122{
123 return OTimeZone::current().toDateTime( dt, *this ); 123 return OPimTimeZone::current().toDateTime( dt, *this );
124} 124}
125 125
126 126
127QDateTime OTimeZone::toUTCDateTime( const QDateTime& dt ) 127QDateTime OPimTimeZone::toUTCDateTime( const QDateTime& dt )
128{ 128{
129 return OTimeZone::utc().toDateTime( dt, *this ); 129 return OPimTimeZone::utc().toDateTime( dt, *this );
130} 130}
131 131
132 132
133QDateTime OTimeZone::fromUTCDateTime( time_t t ) 133QDateTime OPimTimeZone::fromUTCDateTime( time_t t )
134{ 134{
135 return utcTime( t ); 135 return utcTime( t );
136} 136}
137 137
138 138
139QDateTime OTimeZone::toDateTime( time_t t ) 139QDateTime OPimTimeZone::toDateTime( time_t t )
140{ 140{
141 return utcTime( t, m_name ); 141 return utcTime( t, m_name );
142} 142}
143 143
144 144
145/* 145/*
146 * convert dt to utc using zone.m_name 146 * convert dt to utc using zone.m_name
147 * convert utc -> timeZoneDT using this->m_name 147 * convert utc -> timeZoneDT using this->m_name
148 */ 148 */
149QDateTime OTimeZone::toDateTime( const QDateTime& dt, const OTimeZone& zone ) 149QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone )
150{ 150{
151 time_t utc = to_Time_t( dt, zone.m_name ); 151 time_t utc = to_Time_t( dt, zone.m_name );
152 qWarning( "%d %s", utc, zone.m_name.latin1() ); 152 qWarning( "%d %s", utc, zone.m_name.latin1() );
153 return utcTime( utc, m_name ); 153 return utcTime( utc, m_name );
154} 154}
155 155
156 156
157time_t OTimeZone::fromDateTime( const QDateTime& time ) 157time_t OPimTimeZone::fromDateTime( const QDateTime& time )
158{ 158{
159 return to_Time_t( time, m_name ); 159 return to_Time_t( time, m_name );
160} 160}
161 161
162 162
163time_t OTimeZone::fromUTCDateTime( const QDateTime& time ) 163time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time )
164{ 164{
165 return to_Time_t( time, "UTC" ); 165 return to_Time_t( time, "UTC" );
166} 166}
167 167
168 168
169OTimeZone OTimeZone::current() 169OPimTimeZone OPimTimeZone::current()
170{ 170{
171 QCString str = ::getenv( "TZ" ); 171 QCString str = ::getenv( "TZ" );
172 OTimeZone zone( str ); 172 OPimTimeZone zone( str );
173 return zone; 173 return zone;
174} 174}
175 175
176 176
177OTimeZone OTimeZone::utc() 177OPimTimeZone OPimTimeZone::utc()
178{ 178{
179 return OTimeZone( "UTC" ); 179 return OPimTimeZone( "UTC" );
180} 180}
181 181
182 182
183QString OTimeZone::timeZone() const 183QString OPimTimeZone::timeZone() const
184{ 184{
185 return m_name; 185 return m_name;
186} 186}
187 187
188} 188}
diff --git a/libopie2/opiepim/core/otimezone.h b/libopie2/opiepim/core/opimtimezone.h
index f0b4022..284e80f 100644
--- a/libopie2/opiepim/core/otimezone.h
+++ b/libopie2/opiepim/core/opimtimezone.h
@@ -1,107 +1,107 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OTIMEZONE_H 30#ifndef OTIMEZONE_H
31#define OTIMEZONE_H 31#define OTIMEZONE_H
32 32
33/* QT */ 33/* QT */
34#include <qdatetime.h> 34#include <qdatetime.h>
35 35
36/* STD */ 36/* STD */
37#include <time.h> 37#include <time.h>
38 38
39namespace Opie 39namespace Opie
40{ 40{
41/** 41/**
42 * A very primitive class to convert time 42 * A very primitive class to convert time
43 * from one timezone to another 43 * from one timezone to another
44 * and to localtime 44 * and to localtime
45 * and time_t 45 * and time_t
46 */ 46 */
47class OTimeZone { 47class OPimTimeZone {
48 48
49 public: 49 public:
50 typedef QString ZoneName; 50 typedef QString ZoneName;
51 OTimeZone( const ZoneName& = ZoneName::null ); 51 OPimTimeZone( const ZoneName& = ZoneName::null );
52 virtual ~OTimeZone(); // just in case. 52 virtual ~OPimTimeZone(); // just in case.
53 53
54 bool isValid()const; 54 bool isValid()const;
55 55
56 /** 56 /**
57 * converts the QDateTime to a DateTime 57 * converts the QDateTime to a DateTime
58 * in the local timezone 58 * in the local timezone
59 * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h 59 * if QDateTime is 25th Jan and takes place in Europe/Berlin at 12h
60 * and the current timezone is Europe/London the returned 60 * and the current timezone is Europe/London the returned
61 * time will be 11h. 61 * time will be 11h.
62 */ 62 */
63 QDateTime toLocalDateTime( const QDateTime& dt ); 63 QDateTime toLocalDateTime( const QDateTime& dt );
64 64
65 /** 65 /**
66 * converts the QDateTime to UTC time 66 * converts the QDateTime to UTC time
67 */ 67 */
68 QDateTime toUTCDateTime( const QDateTime& dt ); 68 QDateTime toUTCDateTime( const QDateTime& dt );
69 69
70 /** 70 /**
71 * reads the time_t into a QDateTime using UTC as timezone! 71 * reads the time_t into a QDateTime using UTC as timezone!
72 */ 72 */
73 QDateTime fromUTCDateTime( time_t ); 73 QDateTime fromUTCDateTime( time_t );
74 74
75 /** 75 /**
76 * converts the time_t to the time in the timezone 76 * converts the time_t to the time in the timezone
77 */ 77 */
78 QDateTime toDateTime( time_t ); 78 QDateTime toDateTime( time_t );
79 79
80 /** 80 /**
81 * converts the QDateTime from one timezone to this timeZone 81 * converts the QDateTime from one timezone to this timeZone
82 */ 82 */
83 QDateTime toDateTime( const QDateTime&, const OTimeZone& timeZone ); 83 QDateTime toDateTime( const QDateTime&, const OPimTimeZone& timeZone );
84 84
85 /** 85 /**
86 * converts the date time into a time_t. It takes the timezone into account 86 * converts the date time into a time_t. It takes the timezone into account
87 */ 87 */
88 time_t fromDateTime( const QDateTime& ); 88 time_t fromDateTime( const QDateTime& );
89 89
90 /** 90 /**
91 * converts the datetime with timezone UTC 91 * converts the datetime with timezone UTC
92 */ 92 */
93 time_t fromUTCDateTime( const QDateTime& ); 93 time_t fromUTCDateTime( const QDateTime& );
94 94
95 static OTimeZone current(); 95 static OPimTimeZone current();
96 static OTimeZone utc(); 96 static OPimTimeZone utc();
97 97
98 QString timeZone() const; 98 QString timeZone() const;
99 99
100 private: 100 private:
101 ZoneName m_name; 101 ZoneName m_name;
102 class Private; 102 class Private;
103 Private* d; 103 Private* d;
104}; 104};
105}; 105};
106 106
107#endif 107#endif
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index f534067..34df807 100644
--- a/libopie2/opiepim/otodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -1,712 +1,712 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "otodo.h" 30#include "opimtodo.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimstate.h> 33#include <opie2/opimstate.h>
34#include <opie2/orecur.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimmaintainer.h> 35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h> 36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include <qpe/palmtopuidgen.h> 38#include <qpe/palmtopuidgen.h>
39#include <qpe/stringutil.h> 39#include <qpe/stringutil.h>
40#include <qpe/palmtoprecord.h> 40#include <qpe/palmtoprecord.h>
41#include <qpe/stringutil.h> 41#include <qpe/stringutil.h>
42#include <qpe/categories.h> 42#include <qpe/categories.h>
43#include <qpe/categoryselect.h> 43#include <qpe/categoryselect.h>
44 44
45/* QT */ 45/* QT */
46#include <qobject.h> 46#include <qobject.h>
47#include <qshared.h> 47#include <qshared.h>
48 48
49namespace Opie 49namespace Opie
50{ 50{
51 51
52struct OTodo::OTodoData : public QShared 52struct OPimTodo::OPimTodoData : public QShared
53{ 53{
54 OTodoData() : QShared() 54 OPimTodoData() : QShared()
55 { 55 {
56 recur = 0; 56 recur = 0;
57 state = 0; 57 state = 0;
58 maintainer = 0; 58 maintainer = 0;
59 notifiers = 0; 59 notifiers = 0;
60 }; 60 };
61 ~OTodoData() 61 ~OPimTodoData()
62 { 62 {
63 delete recur; 63 delete recur;
64 delete maintainer; 64 delete maintainer;
65 delete notifiers; 65 delete notifiers;
66 } 66 }
67 67
68 QDate date; 68 QDate date;
69 bool isCompleted: 1; 69 bool isCompleted: 1;
70 bool hasDate: 1; 70 bool hasDate: 1;
71 int priority; 71 int priority;
72 QString desc; 72 QString desc;
73 QString sum; 73 QString sum;
74 QMap<QString, QString> extra; 74 QMap<QString, QString> extra;
75 ushort prog; 75 ushort prog;
76 OPimState *state; 76 OPimState *state;
77 ORecur *recur; 77 OPimRecurrence *recur;
78 OPimMaintainer *maintainer; 78 OPimMaintainer *maintainer;
79 QDate start; 79 QDate start;
80 QDate completed; 80 QDate completed;
81 OPimNotifyManager *notifiers; 81 OPimNotifyManager *notifiers;
82}; 82};
83 83
84 84
85OTodo::OTodo( const OTodo &event ) 85OPimTodo::OPimTodo( const OPimTodo &event )
86 : OPimRecord( event ), data( event.data ) 86 : OPimRecord( event ), data( event.data )
87{ 87{
88 data->ref(); 88 data->ref();
89 // qWarning("ref up"); 89 // qWarning("ref up");
90} 90}
91 91
92 92
93OTodo::~OTodo() 93OPimTodo::~OPimTodo()
94{ 94{
95 95
96 // qWarning("~OTodo " ); 96 // qWarning("~OPimTodo " );
97 if ( data->deref() ) 97 if ( data->deref() )
98 { 98 {
99 // qWarning("OTodo::dereffing"); 99 // qWarning("OPimTodo::dereffing");
100 delete data; 100 delete data;
101 data = 0l; 101 data = 0l;
102 } 102 }
103} 103}
104 104
105 105
106OTodo::OTodo( bool completed, int priority, 106OPimTodo::OPimTodo( bool completed, int priority,
107 const QArray<int> &category, 107 const QArray<int> &category,
108 const QString& summary, 108 const QString& summary,
109 const QString &description, 109 const QString &description,
110 ushort progress, 110 ushort progress,
111 bool hasDate, QDate date, int uid ) 111 bool hasDate, QDate date, int uid )
112 : OPimRecord( uid ) 112 : OPimRecord( uid )
113{ 113{
114 // qWarning("OTodoData " + summary); 114 // qWarning("OPimTodoData " + summary);
115 setCategories( category ); 115 setCategories( category );
116 116
117 data = new OTodoData; 117 data = new OPimTodoData;
118 118
119 data->date = date; 119 data->date = date;
120 data->isCompleted = completed; 120 data->isCompleted = completed;
121 data->hasDate = hasDate; 121 data->hasDate = hasDate;
122 data->priority = priority; 122 data->priority = priority;
123 data->sum = summary; 123 data->sum = summary;
124 data->prog = progress; 124 data->prog = progress;
125 data->desc = Qtopia::simplifyMultiLineSpace( description ); 125 data->desc = Qtopia::simplifyMultiLineSpace( description );
126} 126}
127 127
128 128
129OTodo::OTodo( bool completed, int priority, 129OPimTodo::OPimTodo( bool completed, int priority,
130 const QStringList &category, 130 const QStringList &category,
131 const QString& summary, 131 const QString& summary,
132 const QString &description, 132 const QString &description,
133 ushort progress, 133 ushort progress,
134 bool hasDate, QDate date, int uid ) 134 bool hasDate, QDate date, int uid )
135 : OPimRecord( uid ) 135 : OPimRecord( uid )
136{ 136{
137 // qWarning("OTodoData" + summary); 137 // qWarning("OPimTodoData" + summary);
138 setCategories( idsFromString( category.join( ";" ) ) ); 138 setCategories( idsFromString( category.join( ";" ) ) );
139 139
140 data = new OTodoData; 140 data = new OPimTodoData;
141 141
142 data->date = date; 142 data->date = date;
143 data->isCompleted = completed; 143 data->isCompleted = completed;
144 data->hasDate = hasDate; 144 data->hasDate = hasDate;
145 data->priority = priority; 145 data->priority = priority;
146 data->sum = summary; 146 data->sum = summary;
147 data->prog = progress; 147 data->prog = progress;
148 data->desc = Qtopia::simplifyMultiLineSpace( description ); 148 data->desc = Qtopia::simplifyMultiLineSpace( description );
149} 149}
150 150
151 151
152bool OTodo::match( const QRegExp &regExp ) const 152bool OPimTodo::match( const QRegExp &regExp ) const
153{ 153{
154 if ( QString::number( data->priority ).find( regExp ) != -1 ) 154 if ( QString::number( data->priority ).find( regExp ) != -1 )
155 { 155 {
156 setLastHitField( Priority ); 156 setLastHitField( Priority );
157 return true; 157 return true;
158 } 158 }
159 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) 159 else if ( data->hasDate && data->date.toString().find( regExp ) != -1 )
160 { 160 {
161 setLastHitField( HasDate ); 161 setLastHitField( HasDate );
162 return true; 162 return true;
163 } 163 }
164 else if ( data->desc.find( regExp ) != -1 ) 164 else if ( data->desc.find( regExp ) != -1 )
165 { 165 {
166 setLastHitField( Description ); 166 setLastHitField( Description );
167 return true; 167 return true;
168 } 168 }
169 else if ( data->sum.find( regExp ) != -1 ) 169 else if ( data->sum.find( regExp ) != -1 )
170 { 170 {
171 setLastHitField( Summary ); 171 setLastHitField( Summary );
172 return true; 172 return true;
173 } 173 }
174 return false; 174 return false;
175} 175}
176 176
177 177
178bool OTodo::isCompleted() const 178bool OPimTodo::isCompleted() const
179{ 179{
180 return data->isCompleted; 180 return data->isCompleted;
181} 181}
182 182
183 183
184bool OTodo::hasDueDate() const 184bool OPimTodo::hasDueDate() const
185{ 185{
186 return data->hasDate; 186 return data->hasDate;
187} 187}
188 188
189 189
190bool OTodo::hasStartDate() const 190bool OPimTodo::hasStartDate() const
191{ 191{
192 return data->start.isValid(); 192 return data->start.isValid();
193} 193}
194 194
195 195
196bool OTodo::hasCompletedDate() const 196bool OPimTodo::hasCompletedDate() const
197{ 197{
198 return data->completed.isValid(); 198 return data->completed.isValid();
199} 199}
200 200
201 201
202int OTodo::priority() const 202int OPimTodo::priority() const
203{ 203{
204 return data->priority; 204 return data->priority;
205} 205}
206 206
207 207
208QString OTodo::summary() const 208QString OPimTodo::summary() const
209{ 209{
210 return data->sum; 210 return data->sum;
211} 211}
212 212
213 213
214ushort OTodo::progress() const 214ushort OPimTodo::progress() const
215{ 215{
216 return data->prog; 216 return data->prog;
217} 217}
218 218
219 219
220QDate OTodo::dueDate() const 220QDate OPimTodo::dueDate() const
221{ 221{
222 return data->date; 222 return data->date;
223} 223}
224 224
225 225
226QDate OTodo::startDate() const 226QDate OPimTodo::startDate() const
227{ 227{
228 return data->start; 228 return data->start;
229} 229}
230 230
231 231
232QDate OTodo::completedDate() const 232QDate OPimTodo::completedDate() const
233{ 233{
234 return data->completed; 234 return data->completed;
235} 235}
236 236
237 237
238QString OTodo::description() const 238QString OPimTodo::description() const
239{ 239{
240 return data->desc; 240 return data->desc;
241} 241}
242 242
243 243
244bool OTodo::hasState() const 244bool OPimTodo::hasState() const
245{ 245{
246 if ( !data->state ) return false; 246 if ( !data->state ) return false;
247 return ( data->state->state() != OPimState::Undefined ); 247 return ( data->state->state() != OPimState::Undefined );
248} 248}
249 249
250 250
251OPimState OTodo::state() const 251OPimState OPimTodo::state() const
252{ 252{
253 if ( !data->state ) 253 if ( !data->state )
254 { 254 {
255 OPimState state; 255 OPimState state;
256 return state; 256 return state;
257 } 257 }
258 258
259 return ( *data->state ); 259 return ( *data->state );
260} 260}
261 261
262 262
263bool OTodo::hasRecurrence() const 263bool OPimTodo::hasRecurrence() const
264{ 264{
265 if ( !data->recur ) return false; 265 if ( !data->recur ) return false;
266 return data->recur->doesRecur(); 266 return data->recur->doesRecur();
267} 267}
268 268
269 269
270ORecur OTodo::recurrence() const 270OPimRecurrence OPimTodo::recurrence() const
271{ 271{
272 if ( !data->recur ) return ORecur(); 272 if ( !data->recur ) return OPimRecurrence();
273 273
274 return ( *data->recur ); 274 return ( *data->recur );
275} 275}
276 276
277 277
278bool OTodo::hasMaintainer() const 278bool OPimTodo::hasMaintainer() const
279{ 279{
280 if ( !data->maintainer ) return false; 280 if ( !data->maintainer ) return false;
281 281
282 return ( data->maintainer->mode() != OPimMaintainer::Undefined ); 282 return ( data->maintainer->mode() != OPimMaintainer::Undefined );
283} 283}
284 284
285 285
286OPimMaintainer OTodo::maintainer() const 286OPimMaintainer OPimTodo::maintainer() const
287{ 287{
288 if ( !data->maintainer ) return OPimMaintainer(); 288 if ( !data->maintainer ) return OPimMaintainer();
289 289
290 return ( *data->maintainer ); 290 return ( *data->maintainer );
291} 291}
292 292
293 293
294void OTodo::setCompleted( bool completed ) 294void OPimTodo::setCompleted( bool completed )
295{ 295{
296 changeOrModify(); 296 changeOrModify();
297 data->isCompleted = completed; 297 data->isCompleted = completed;
298} 298}
299 299
300 300
301void OTodo::setHasDueDate( bool hasDate ) 301void OPimTodo::setHasDueDate( bool hasDate )
302{ 302{
303 changeOrModify(); 303 changeOrModify();
304 data->hasDate = hasDate; 304 data->hasDate = hasDate;
305} 305}
306 306
307 307
308void OTodo::setDescription( const QString &desc ) 308void OPimTodo::setDescription( const QString &desc )
309{ 309{
310 // qWarning( "desc " + desc ); 310 // qWarning( "desc " + desc );
311 changeOrModify(); 311 changeOrModify();
312 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 312 data->desc = Qtopia::simplifyMultiLineSpace( desc );
313} 313}
314 314
315 315
316void OTodo::setSummary( const QString& sum ) 316void OPimTodo::setSummary( const QString& sum )
317{ 317{
318 changeOrModify(); 318 changeOrModify();
319 data->sum = sum; 319 data->sum = sum;
320} 320}
321 321
322 322
323void OTodo::setPriority( int prio ) 323void OPimTodo::setPriority( int prio )
324{ 324{
325 changeOrModify(); 325 changeOrModify();
326 data->priority = prio; 326 data->priority = prio;
327} 327}
328 328
329 329
330void OTodo::setDueDate( const QDate& date ) 330void OPimTodo::setDueDate( const QDate& date )
331{ 331{
332 changeOrModify(); 332 changeOrModify();
333 data->date = date; 333 data->date = date;
334} 334}
335 335
336 336
337void OTodo::setStartDate( const QDate& date ) 337void OPimTodo::setStartDate( const QDate& date )
338{ 338{
339 changeOrModify(); 339 changeOrModify();
340 data->start = date; 340 data->start = date;
341} 341}
342 342
343 343
344void OTodo::setCompletedDate( const QDate& date ) 344void OPimTodo::setCompletedDate( const QDate& date )
345{ 345{
346 changeOrModify(); 346 changeOrModify();
347 data->completed = date; 347 data->completed = date;
348} 348}
349 349
350 350
351void OTodo::setState( const OPimState& state ) 351void OPimTodo::setState( const OPimState& state )
352{ 352{
353 changeOrModify(); 353 changeOrModify();
354 if ( data->state ) 354 if ( data->state )
355 ( *data->state ) = state; 355 ( *data->state ) = state;
356 else 356 else
357 data->state = new OPimState( state ); 357 data->state = new OPimState( state );
358} 358}
359 359
360 360
361void OTodo::setRecurrence( const ORecur& rec ) 361void OPimTodo::setRecurrence( const OPimRecurrence& rec )
362{ 362{
363 changeOrModify(); 363 changeOrModify();
364 if ( data->recur ) 364 if ( data->recur )
365 ( *data->recur ) = rec; 365 ( *data->recur ) = rec;
366 else 366 else
367 data->recur = new ORecur( rec ); 367 data->recur = new OPimRecurrence( rec );
368} 368}
369 369
370 370
371void OTodo::setMaintainer( const OPimMaintainer& pim ) 371void OPimTodo::setMaintainer( const OPimMaintainer& pim )
372{ 372{
373 changeOrModify(); 373 changeOrModify();
374 374
375 if ( data->maintainer ) 375 if ( data->maintainer )
376 ( *data->maintainer ) = pim; 376 ( *data->maintainer ) = pim;
377 else 377 else
378 data->maintainer = new OPimMaintainer( pim ); 378 data->maintainer = new OPimMaintainer( pim );
379} 379}
380 380
381 381
382bool OTodo::isOverdue( ) 382bool OPimTodo::isOverdue( )
383{ 383{
384 if ( data->hasDate && !data->isCompleted ) 384 if ( data->hasDate && !data->isCompleted )
385 return QDate::currentDate() > data->date; 385 return QDate::currentDate() > data->date;
386 return false; 386 return false;
387} 387}
388 388
389 389
390void OTodo::setProgress( ushort progress ) 390void OPimTodo::setProgress( ushort progress )
391{ 391{
392 changeOrModify(); 392 changeOrModify();
393 data->prog = progress; 393 data->prog = progress;
394} 394}
395 395
396 396
397QString OTodo::toShortText() const 397QString OPimTodo::toShortText() const
398{ 398{
399 return summary(); 399 return summary();
400} 400}
401 401
402 402
403/*! 403/*!
404 Returns a richt text string 404 Returns a richt text string
405*/ 405*/
406QString OTodo::toRichText() const 406QString OPimTodo::toRichText() const
407{ 407{
408 QString text; 408 QString text;
409 QStringList catlist; 409 QStringList catlist;
410 410
411 // summary 411 // summary
412 text += "<b><h3><img src=\"todo/TodoList\"> "; 412 text += "<b><h3><img src=\"todo/TodoList\"> ";
413 if ( !summary().isEmpty() ) 413 if ( !summary().isEmpty() )
414 { 414 {
415 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); 415 text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" );
416 } 416 }
417 text += "</h3></b><br><hr><br>"; 417 text += "</h3></b><br><hr><br>";
418 418
419 // description 419 // description
420 if ( !description().isEmpty() ) 420 if ( !description().isEmpty() )
421 { 421 {
422 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; 422 text += "<b>" + QObject::tr( "Description:" ) + "</b><br>";
423 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; 423 text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>";
424 } 424 }
425 425
426 // priority 426 // priority
427 int priorityval = priority(); 427 int priorityval = priority();
428 text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + 428 text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" +
429 QString::number( priorityval ) + "\"> "; 429 QString::number( priorityval ) + "\"> ";
430 430
431 switch ( priorityval ) 431 switch ( priorityval )
432 { 432 {
433 case 1 : text += QObject::tr( "Very high" ); 433 case 1 : text += QObject::tr( "Very high" );
434 break; 434 break;
435 case 2 : text += QObject::tr( "High" ); 435 case 2 : text += QObject::tr( "High" );
436 break; 436 break;
437 case 3 : text += QObject::tr( "Normal" ); 437 case 3 : text += QObject::tr( "Normal" );
438 break; 438 break;
439 case 4 : text += QObject::tr( "Low" ); 439 case 4 : text += QObject::tr( "Low" );
440 break; 440 break;
441 case 5 : text += QObject::tr( "Very low" ); 441 case 5 : text += QObject::tr( "Very low" );
442 break; 442 break;
443 }; 443 };
444 text += "<br>"; 444 text += "<br>";
445 445
446 // progress 446 // progress
447 text += "<b>" + QObject::tr( "Progress:" ) + " </b>" 447 text += "<b>" + QObject::tr( "Progress:" ) + " </b>"
448 + QString::number( progress() ) + " %<br>"; 448 + QString::number( progress() ) + " %<br>";
449 449
450 // due date 450 // due date
451 if ( hasDueDate() ) 451 if ( hasDueDate() )
452 { 452 {
453 QDate dd = dueDate(); 453 QDate dd = dueDate();
454 int off = QDate::currentDate().daysTo( dd ); 454 int off = QDate::currentDate().daysTo( dd );
455 455
456 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; 456 text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\"";
457 if ( off < 0 ) 457 if ( off < 0 )
458 text += "#FF0000"; 458 text += "#FF0000";
459 else if ( off == 0 ) 459 else if ( off == 0 )
460 text += "#FFFF00"; 460 text += "#FFFF00";
461 else if ( off > 0 ) 461 else if ( off > 0 )
462 text += "#00FF00"; 462 text += "#00FF00";
463 463
464 text += "\">" + dd.toString() + "</font><br>"; 464 text += "\">" + dd.toString() + "</font><br>";
465 } 465 }
466 466
467 // categories 467 // categories
468 text += "<b>" + QObject::tr( "Category:" ) + "</b> "; 468 text += "<b>" + QObject::tr( "Category:" ) + "</b> ";
469 text += categoryNames( "Todo List" ).join( ", " ); 469 text += categoryNames( "Todo List" ).join( ", " );
470 text += "<br>"; 470 text += "<br>";
471 471
472 return text; 472 return text;
473} 473}
474 474
475 475
476bool OTodo::hasNotifiers() const 476bool OPimTodo::hasNotifiers() const
477{ 477{
478 if ( !data->notifiers ) return false; 478 if ( !data->notifiers ) return false;
479 return !data->notifiers->isEmpty(); 479 return !data->notifiers->isEmpty();
480} 480}
481 481
482 482
483OPimNotifyManager& OTodo::notifiers() 483OPimNotifyManager& OPimTodo::notifiers()
484{ 484{
485 if ( !data->notifiers ) 485 if ( !data->notifiers )
486 data->notifiers = new OPimNotifyManager; 486 data->notifiers = new OPimNotifyManager;
487 return ( *data->notifiers ); 487 return ( *data->notifiers );
488} 488}
489 489
490 490
491const OPimNotifyManager& OTodo::notifiers() const 491const OPimNotifyManager& OPimTodo::notifiers() const
492{ 492{
493 if ( !data->notifiers ) 493 if ( !data->notifiers )
494 data->notifiers = new OPimNotifyManager; 494 data->notifiers = new OPimNotifyManager;
495 495
496 return ( *data->notifiers ); 496 return ( *data->notifiers );
497} 497}
498 498
499 499
500bool OTodo::operator<( const OTodo &toDoEvent ) const 500bool OPimTodo::operator<( const OPimTodo &toDoEvent ) const
501{ 501{
502 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 502 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
503 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 503 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
504 if ( hasDueDate() && toDoEvent.hasDueDate() ) 504 if ( hasDueDate() && toDoEvent.hasDueDate() )
505 { 505 {
506 if ( dueDate() == toDoEvent.dueDate() ) 506 if ( dueDate() == toDoEvent.dueDate() )
507 { // let's the priority decide 507 { // let's the priority decide
508 return priority() < toDoEvent.priority(); 508 return priority() < toDoEvent.priority();
509 } 509 }
510 else 510 else
511 { 511 {
512 return dueDate() < toDoEvent.dueDate(); 512 return dueDate() < toDoEvent.dueDate();
513 } 513 }
514 } 514 }
515 return false; 515 return false;
516} 516}
517 517
518 518
519bool OTodo::operator<=( const OTodo &toDoEvent ) const 519bool OPimTodo::operator<=( const OPimTodo &toDoEvent ) const
520{ 520{
521 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 521 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
522 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true; 522 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true;
523 if ( hasDueDate() && toDoEvent.hasDueDate() ) 523 if ( hasDueDate() && toDoEvent.hasDueDate() )
524 { 524 {
525 if ( dueDate() == toDoEvent.dueDate() ) 525 if ( dueDate() == toDoEvent.dueDate() )
526 { // let's the priority decide 526 { // let's the priority decide
527 return priority() <= toDoEvent.priority(); 527 return priority() <= toDoEvent.priority();
528 } 528 }
529 else 529 else
530 { 530 {
531 return dueDate() <= toDoEvent.dueDate(); 531 return dueDate() <= toDoEvent.dueDate();
532 } 532 }
533 } 533 }
534 return true; 534 return true;
535} 535}
536 536
537 537
538bool OTodo::operator>( const OTodo &toDoEvent ) const 538bool OPimTodo::operator>( const OPimTodo &toDoEvent ) const
539{ 539{
540 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; 540 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false;
541 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 541 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
542 if ( hasDueDate() && toDoEvent.hasDueDate() ) 542 if ( hasDueDate() && toDoEvent.hasDueDate() )
543 { 543 {
544 if ( dueDate() == toDoEvent.dueDate() ) 544 if ( dueDate() == toDoEvent.dueDate() )
545 { // let's the priority decide 545 { // let's the priority decide
546 return priority() > toDoEvent.priority(); 546 return priority() > toDoEvent.priority();
547 } 547 }
548 else 548 else
549 { 549 {
550 return dueDate() > toDoEvent.dueDate(); 550 return dueDate() > toDoEvent.dueDate();
551 } 551 }
552 } 552 }
553 return false; 553 return false;
554} 554}
555 555
556 556
557bool OTodo::operator>=( const OTodo &toDoEvent ) const 557bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const
558{ 558{
559 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; 559 if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true;
560 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; 560 if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false;
561 if ( hasDueDate() && toDoEvent.hasDueDate() ) 561 if ( hasDueDate() && toDoEvent.hasDueDate() )
562 { 562 {
563 if ( dueDate() == toDoEvent.dueDate() ) 563 if ( dueDate() == toDoEvent.dueDate() )
564 { // let's the priority decide 564 { // let's the priority decide
565 return priority() > toDoEvent.priority(); 565 return priority() > toDoEvent.priority();
566 } 566 }
567 else 567 else
568 { 568 {
569 return dueDate() > toDoEvent.dueDate(); 569 return dueDate() > toDoEvent.dueDate();
570 } 570 }
571 } 571 }
572 return true; 572 return true;
573} 573}
574 574
575 575
576bool OTodo::operator==( const OTodo &toDoEvent ) const 576bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const
577{ 577{
578 if ( data->priority != toDoEvent.data->priority ) return false; 578 if ( data->priority != toDoEvent.data->priority ) return false;
579 if ( data->priority != toDoEvent.data->prog ) return false; 579 if ( data->priority != toDoEvent.data->prog ) return false;
580 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; 580 if ( data->isCompleted != toDoEvent.data->isCompleted ) return false;
581 if ( data->hasDate != toDoEvent.data->hasDate ) return false; 581 if ( data->hasDate != toDoEvent.data->hasDate ) return false;
582 if ( data->date != toDoEvent.data->date ) return false; 582 if ( data->date != toDoEvent.data->date ) return false;
583 if ( data->sum != toDoEvent.data->sum ) return false; 583 if ( data->sum != toDoEvent.data->sum ) return false;
584 if ( data->desc != toDoEvent.data->desc ) return false; 584 if ( data->desc != toDoEvent.data->desc ) return false;
585 if ( data->maintainer != toDoEvent.data->maintainer ) 585 if ( data->maintainer != toDoEvent.data->maintainer )
586 return false; 586 return false;
587 587
588 return OPimRecord::operator==( toDoEvent ); 588 return OPimRecord::operator==( toDoEvent );
589} 589}
590 590
591 591
592void OTodo::deref() 592void OPimTodo::deref()
593{ 593{
594 594
595 // qWarning("deref in ToDoEvent"); 595 // qWarning("deref in ToDoEvent");
596 if ( data->deref() ) 596 if ( data->deref() )
597 { 597 {
598 // qWarning("deleting"); 598 // qWarning("deleting");
599 delete data; 599 delete data;
600 data = 0; 600 data = 0;
601 } 601 }
602} 602}
603 603
604 604
605OTodo &OTodo::operator=( const OTodo &item ) 605OPimTodo &OPimTodo::operator=( const OPimTodo &item )
606{ 606{
607 if ( this == &item ) return * this; 607 if ( this == &item ) return * this;
608 608
609 OPimRecord::operator=( item ); 609 OPimRecord::operator=( item );
610 //qWarning("operator= ref "); 610 //qWarning("operator= ref ");
611 item.data->ref(); 611 item.data->ref();
612 deref(); 612 deref();
613 data = item.data; 613 data = item.data;
614 614
615 return *this; 615 return *this;
616} 616}
617 617
618 618
619QMap<int, QString> OTodo::toMap() const 619QMap<int, QString> OPimTodo::toMap() const
620{ 620{
621 QMap<int, QString> map; 621 QMap<int, QString> map;
622 622
623 map.insert( Uid, QString::number( uid() ) ); 623 map.insert( Uid, QString::number( uid() ) );
624 map.insert( Category, idsToString( categories() ) ); 624 map.insert( Category, idsToString( categories() ) );
625 map.insert( HasDate, QString::number( data->hasDate ) ); 625 map.insert( HasDate, QString::number( data->hasDate ) );
626 map.insert( Completed, QString::number( data->isCompleted ) ); 626 map.insert( Completed, QString::number( data->isCompleted ) );
627 map.insert( Description, data->desc ); 627 map.insert( Description, data->desc );
628 map.insert( Summary, data->sum ); 628 map.insert( Summary, data->sum );
629 map.insert( Priority, QString::number( data->priority ) ); 629 map.insert( Priority, QString::number( data->priority ) );
630 map.insert( DateDay, QString::number( data->date.day() ) ); 630 map.insert( DateDay, QString::number( data->date.day() ) );
631 map.insert( DateMonth, QString::number( data->date.month() ) ); 631 map.insert( DateMonth, QString::number( data->date.month() ) );
632 map.insert( DateYear, QString::number( data->date.year() ) ); 632 map.insert( DateYear, QString::number( data->date.year() ) );
633 map.insert( Progress, QString::number( data->prog ) ); 633 map.insert( Progress, QString::number( data->prog ) );
634 // map.insert( CrossReference, crossToString() ); 634 // map.insert( CrossReference, crossToString() );
635 /* FIXME!!! map.insert( State, ); 635 /* FIXME!!! map.insert( State, );
636 map.insert( Recurrence, ); 636 map.insert( Recurrence, );
637 map.insert( Reminders, ); 637 map.insert( Reminders, );
638 map. 638 map.
639 */ 639 */
640 return map; 640 return map;
641} 641}
642 642
643 643
644/** 644/**
645 * change or modify looks at the ref count and either 645 * change or modify looks at the ref count and either
646 * creates a new QShared Object or it can modify it 646 * creates a new QShared Object or it can modify it
647 * right in place 647 * right in place
648 */ 648 */
649void OTodo::changeOrModify() 649void OPimTodo::changeOrModify()
650{ 650{
651 if ( data->count != 1 ) 651 if ( data->count != 1 )
652 { 652 {
653 qWarning( "changeOrModify" ); 653 qWarning( "changeOrModify" );
654 data->deref(); 654 data->deref();
655 OTodoData* d2 = new OTodoData(); 655 OPimTodoData* d2 = new OPimTodoData();
656 copy( data, d2 ); 656 copy( data, d2 );
657 data = d2; 657 data = d2;
658 } 658 }
659} 659}
660 660
661 661
662// WATCHOUT 662// WATCHOUT
663/* 663/*
664 * if you add something to the Data struct 664 * if you add something to the Data struct
665 * be sure to copy it here 665 * be sure to copy it here
666 */ 666 */
667void OTodo::copy( OTodoData* src, OTodoData* dest ) 667void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest )
668{ 668{
669 dest->date = src->date; 669 dest->date = src->date;
670 dest->isCompleted = src->isCompleted; 670 dest->isCompleted = src->isCompleted;
671 dest->hasDate = src->hasDate; 671 dest->hasDate = src->hasDate;
672 dest->priority = src->priority; 672 dest->priority = src->priority;
673 dest->desc = src->desc; 673 dest->desc = src->desc;
674 dest->sum = src->sum; 674 dest->sum = src->sum;
675 dest->extra = src->extra; 675 dest->extra = src->extra;
676 dest->prog = src->prog; 676 dest->prog = src->prog;
677 677
678 if ( src->state ) 678 if ( src->state )
679 dest->state = new OPimState( *src->state ); 679 dest->state = new OPimState( *src->state );
680 680
681 if ( src->recur ) 681 if ( src->recur )
682 dest->recur = new ORecur( *src->recur ); 682 dest->recur = new OPimRecurrence( *src->recur );
683 683
684 if ( src->maintainer ) 684 if ( src->maintainer )
685 dest->maintainer = new OPimMaintainer( *src->maintainer ) 685 dest->maintainer = new OPimMaintainer( *src->maintainer )
686 ; 686 ;
687 dest->start = src->start; 687 dest->start = src->start;
688 dest->completed = src->completed; 688 dest->completed = src->completed;
689 689
690 if ( src->notifiers ) 690 if ( src->notifiers )
691 dest->notifiers = new OPimNotifyManager( *src->notifiers ); 691 dest->notifiers = new OPimNotifyManager( *src->notifiers );
692} 692}
693 693
694 694
695QString OTodo::type() const 695QString OPimTodo::type() const
696{ 696{
697 return QString::fromLatin1( "OTodo" ); 697 return QString::fromLatin1( "OPimTodo" );
698} 698}
699 699
700 700
701QString OTodo::recordField( int /*id*/ ) const 701QString OPimTodo::recordField( int /*id*/ ) const
702{ 702{
703 return QString::null; 703 return QString::null;
704} 704}
705 705
706 706
707int OTodo::rtti() 707int OPimTodo::rtti()
708{ 708{
709 return OPimResolver::TodoList; 709 return OPimResolver::TodoList;
710} 710}
711 711
712} 712}
diff --git a/libopie2/opiepim/otodo.h b/libopie2/opiepim/core/opimtodo.h
index 04dd269..5304180 100644
--- a/libopie2/opiepim/otodo.h
+++ b/libopie2/opiepim/core/opimtodo.h
@@ -1,320 +1,320 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef OTODOEVENT_H 30#ifndef OTODOEVENT_H
31#define OTODOEVENT_H 31#define OTODOEVENT_H
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/opimrecord.h> 34#include <opie2/opimrecord.h>
35#include <qpe/recordfields.h> 35#include <qpe/recordfields.h>
36#include <qpe/palmtopuidgen.h> 36#include <qpe/palmtopuidgen.h>
37 37
38/* QT */ 38/* QT */
39#include <qarray.h> 39#include <qarray.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qregexp.h> 41#include <qregexp.h>
42#include <qstringlist.h> 42#include <qstringlist.h>
43#include <qdatetime.h> 43#include <qdatetime.h>
44#include <qvaluelist.h> 44#include <qvaluelist.h>
45 45
46namespace Opie 46namespace Opie
47{ 47{
48 48
49class OPimState; 49class OPimState;
50class ORecur; 50class OPimRecurrence;
51class OPimMaintainer; 51class OPimMaintainer;
52class OPimNotifyManager; 52class OPimNotifyManager;
53class OTodo : public OPimRecord 53class OPimTodo : public OPimRecord
54{ 54{
55 public: 55 public:
56 typedef QValueList<OTodo> ValueList; 56 typedef QValueList<OPimTodo> ValueList;
57 enum RecordFields { 57 enum RecordFields {
58 Uid = Qtopia::UID_ID, 58 Uid = Qtopia::UID_ID,
59 Category = Qtopia::CATEGORY_ID, 59 Category = Qtopia::CATEGORY_ID,
60 HasDate, 60 HasDate,
61 Completed, 61 Completed,
62 Description, 62 Description,
63 Summary, 63 Summary,
64 Priority, 64 Priority,
65 DateDay, 65 DateDay,
66 DateMonth, 66 DateMonth,
67 DateYear, 67 DateYear,
68 Progress, 68 Progress,
69 CrossReference, 69 CrossReference,
70 State, 70 State,
71 Recurrence, 71 Recurrence,
72 Alarms, 72 Alarms,
73 Reminders, 73 Reminders,
74 Notifiers, 74 Notifiers,
75 Maintainer, 75 Maintainer,
76 StartDate, 76 StartDate,
77 CompletedDate 77 CompletedDate
78 }; 78 };
79 public: 79 public:
80 // priorities from Very low to very high 80 // priorities from Very low to very high
81 enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow }; 81 enum TaskPriority { VeryHigh = 1, High, Normal, Low, VeryLow };
82 82
83 /* Constructs a new ToDoEvent 83 /* Constructs a new ToDoEvent
84 @param completed Is the TodoEvent completed 84 @param completed Is the TodoEvent completed
85 @param priority What is the priority of this ToDoEvent 85 @param priority What is the priority of this ToDoEvent
86 @param category Which category does it belong( uid ) 86 @param category Which category does it belong( uid )
87 @param summary A small summary of the todo 87 @param summary A small summary of the todo
88 @param description What is this ToDoEvent about 88 @param description What is this ToDoEvent about
89 @param hasDate Does this Event got a deadline 89 @param hasDate Does this Event got a deadline
90 @param date what is the deadline? 90 @param date what is the deadline?
91 @param uid what is the UUID of this Event 91 @param uid what is the UUID of this Event
92 **/ 92 **/
93 OTodo( bool completed = false, int priority = Normal, 93 OPimTodo( bool completed = false, int priority = Normal,
94 const QStringList &category = QStringList(), 94 const QStringList &category = QStringList(),
95 const QString &summary = QString::null , 95 const QString &summary = QString::null ,
96 const QString &description = QString::null, 96 const QString &description = QString::null,
97 ushort progress = 0, 97 ushort progress = 0,
98 bool hasDate = false, QDate date = QDate::currentDate(), 98 bool hasDate = false, QDate date = QDate::currentDate(),
99 int uid = 0 /*empty*/ ); 99 int uid = 0 /*empty*/ );
100 100
101 OTodo( bool completed, int priority, 101 OPimTodo( bool completed, int priority,
102 const QArray<int>& category, 102 const QArray<int>& category,
103 const QString& summary = QString::null, 103 const QString& summary = QString::null,
104 const QString& description = QString::null, 104 const QString& description = QString::null,
105 ushort progress = 0, 105 ushort progress = 0,
106 bool hasDate = false, QDate date = QDate::currentDate(), 106 bool hasDate = false, QDate date = QDate::currentDate(),
107 int uid = 0 /* empty */ ); 107 int uid = 0 /* empty */ );
108 108
109 /** Copy c'tor 109 /** Copy c'tor
110 * 110 *
111 */ 111 */
112 OTodo( const OTodo & ); 112 OPimTodo( const OPimTodo & );
113 113
114 /** 114 /**
115 *destructor 115 *destructor
116 */ 116 */
117 ~OTodo(); 117 ~OPimTodo();
118 118
119 /** 119 /**
120 * Is this event completed? 120 * Is this event completed?
121 */ 121 */
122 bool isCompleted() const; 122 bool isCompleted() const;
123 123
124 /** 124 /**
125 * Does this Event have a deadline 125 * Does this Event have a deadline
126 */ 126 */
127 bool hasDueDate() const; 127 bool hasDueDate() const;
128 bool hasStartDate() const; 128 bool hasStartDate() const;
129 bool hasCompletedDate() const; 129 bool hasCompletedDate() const;
130 130
131 /** 131 /**
132 * What is the priority? 132 * What is the priority?
133 */ 133 */
134 int priority() const ; 134 int priority() const ;
135 135
136 /** 136 /**
137 * progress as ushort 0, 20, 40, 60, 80 or 100% 137 * progress as ushort 0, 20, 40, 60, 80 or 100%
138 */ 138 */
139 ushort progress() const; 139 ushort progress() const;
140 140
141 /** 141 /**
142 * The due Date 142 * The due Date
143 */ 143 */
144 QDate dueDate() const; 144 QDate dueDate() const;
145 145
146 /** 146 /**
147 * When did it start? 147 * When did it start?
148 */ 148 */
149 QDate startDate() const; 149 QDate startDate() const;
150 150
151 /** 151 /**
152 * When was it completed? 152 * When was it completed?
153 */ 153 */
154 QDate completedDate() const; 154 QDate completedDate() const;
155 155
156 /** 156 /**
157 * does it have a state? 157 * does it have a state?
158 */ 158 */
159 bool hasState() const; 159 bool hasState() const;
160 160
161 /** 161 /**
162 * What is the state of this OTodo? 162 * What is the state of this OPimTodo?
163 */ 163 */
164 OPimState state() const; 164 OPimState state() const;
165 165
166 /** 166 /**
167 * has recurrence? 167 * has recurrence?
168 */ 168 */
169 bool hasRecurrence() const; 169 bool hasRecurrence() const;
170 170
171 /** 171 /**
172 * the recurrance of this 172 * the recurrance of this
173 */ 173 */
174 ORecur recurrence() const; 174 OPimRecurrence recurrence() const;
175 175
176 /** 176 /**
177 * does this OTodo have a maintainer? 177 * does this OPimTodo have a maintainer?
178 */ 178 */
179 bool hasMaintainer() const; 179 bool hasMaintainer() const;
180 180
181 /** 181 /**
182 * the Maintainer of this OTodo 182 * the Maintainer of this OPimTodo
183 */ 183 */
184 OPimMaintainer maintainer() const; 184 OPimMaintainer maintainer() const;
185 185
186 /** 186 /**
187 * The description of the todo 187 * The description of the todo
188 */ 188 */
189 QString description() const; 189 QString description() const;
190 190
191 /** 191 /**
192 * A small summary of the todo 192 * A small summary of the todo
193 */ 193 */
194 QString summary() const; 194 QString summary() const;
195 195
196 /** 196 /**
197 * @reimplemented 197 * @reimplemented
198 * Return this todoevent in a RichText formatted QString 198 * Return this todoevent in a RichText formatted QString
199 */ 199 */
200 QString toRichText() const; 200 QString toRichText() const;
201 201
202 bool hasNotifiers() const; 202 bool hasNotifiers() const;
203 /* 203 /*
204 * FIXME check if the sharing is still fine!! -zecke 204 * FIXME check if the sharing is still fine!! -zecke
205 * ### CHECK If API is fine 205 * ### CHECK If API is fine
206 */ 206 */
207 /** 207 /**
208 * return a reference to our notifiers... 208 * return a reference to our notifiers...
209 */ 209 */
210 OPimNotifyManager &notifiers(); 210 OPimNotifyManager &notifiers();
211 211
212 /** 212 /**
213 * 213 *
214 */ 214 */
215 const OPimNotifyManager &notifiers() const; 215 const OPimNotifyManager &notifiers() const;
216 216
217 /** 217 /**
218 * reimplementations 218 * reimplementations
219 */ 219 */
220 QString type() const; 220 QString type() const;
221 QString toShortText() const; 221 QString toShortText() const;
222 QString recordField( int id ) const; 222 QString recordField( int id ) const;
223 223
224 /** 224 /**
225 * toMap puts all data into the map. int relates 225 * toMap puts all data into the map. int relates
226 * to ToDoEvent RecordFields enum 226 * to ToDoEvent RecordFields enum
227 */ 227 */
228 QMap<int, QString> toMap() const; 228 QMap<int, QString> toMap() const;
229 229
230 /** 230 /**
231 * Set if this Todo is completed 231 * Set if this Todo is completed
232 */ 232 */
233 void setCompleted( bool completed ); 233 void setCompleted( bool completed );
234 234
235 /** 235 /**
236 * set if this todo got an end data 236 * set if this todo got an end data
237 */ 237 */
238 void setHasDueDate( bool hasDate ); 238 void setHasDueDate( bool hasDate );
239 // FIXME we do not have these for start, completed 239 // FIXME we do not have these for start, completed
240 // cause we'll use the isNull() of QDate for figuring 240 // cause we'll use the isNull() of QDate for figuring
241 // out if it's has a date... 241 // out if it's has a date...
242 // decide what to do here? -zecke 242 // decide what to do here? -zecke
243 243
244 /** 244 /**
245 * Set the priority of the Todo 245 * Set the priority of the Todo
246 */ 246 */
247 void setPriority( int priority ); 247 void setPriority( int priority );
248 248
249 /** 249 /**
250 * Set the progress. 250 * Set the progress.
251 */ 251 */
252 void setProgress( ushort progress ); 252 void setProgress( ushort progress );
253 253
254 /** 254 /**
255 * set the end date 255 * set the end date
256 */ 256 */
257 void setDueDate( const QDate& date ); 257 void setDueDate( const QDate& date );
258 258
259 /** 259 /**
260 * set the start date 260 * set the start date
261 */ 261 */
262 void setStartDate( const QDate& date ); 262 void setStartDate( const QDate& date );
263 263
264 /** 264 /**
265 * set the completed date 265 * set the completed date
266 */ 266 */
267 void setCompletedDate( const QDate& date ); 267 void setCompletedDate( const QDate& date );
268 268
269 void setRecurrence( const ORecur& ); 269 void setRecurrence( const OPimRecurrence& );
270 270
271 void setDescription( const QString& ); 271 void setDescription( const QString& );
272 void setSummary( const QString& ); 272 void setSummary( const QString& );
273 273
274 /** 274 /**
275 * set the state of a Todo 275 * set the state of a Todo
276 * @param state State what the todo should take 276 * @param state State what the todo should take
277 */ 277 */
278 void setState( const OPimState& state ); 278 void setState( const OPimState& state );
279 279
280 /** 280 /**
281 * set the Maintainer Mode 281 * set the Maintainer Mode
282 */ 282 */
283 void setMaintainer( const OPimMaintainer& ); 283 void setMaintainer( const OPimMaintainer& );
284 284
285 bool isOverdue(); 285 bool isOverdue();
286 286
287 287
288 virtual bool match( const QRegExp &r ) const; 288 virtual bool match( const QRegExp &r ) const;
289 289
290 bool operator<( const OTodo &toDoEvent ) const; 290 bool operator<( const OPimTodo &toDoEvent ) const;
291 bool operator<=( const OTodo &toDoEvent ) const; 291 bool operator<=( const OPimTodo &toDoEvent ) const;
292 bool operator!=( const OTodo &toDoEvent ) const; 292 bool operator!=( const OPimTodo &toDoEvent ) const;
293 bool operator>( const OTodo &toDoEvent ) const; 293 bool operator>( const OPimTodo &toDoEvent ) const;
294 bool operator>=( const OTodo &toDoEvent ) const; 294 bool operator>=( const OPimTodo &toDoEvent ) const;
295 bool operator==( const OTodo &toDoEvent ) const; 295 bool operator==( const OPimTodo &toDoEvent ) const;
296 OTodo &operator=( const OTodo &toDoEvent ); 296 OPimTodo &operator=( const OPimTodo &toDoEvent );
297 297
298 static int rtti(); 298 static int rtti();
299 299
300 private: 300 private:
301 class OTodoPrivate; 301 class OPimTodoPrivate;
302 struct OTodoData; 302 struct OPimTodoData;
303 303
304 void deref(); 304 void deref();
305 inline void changeOrModify(); 305 inline void changeOrModify();
306 void copy( OTodoData* src, OTodoData* dest ); 306 void copy( OPimTodoData* src, OPimTodoData* dest );
307 OTodoPrivate *d; 307 OPimTodoPrivate *d;
308 OTodoData *data; 308 OPimTodoData *data;
309 309
310}; 310};
311 311
312 312
313inline bool OTodo::operator!=( const OTodo &toDoEvent ) const 313inline bool OPimTodo::operator!=( const OPimTodo &toDoEvent ) const
314{ 314{
315 return !( *this == toDoEvent ); 315 return !( *this == toDoEvent );
316} 316}
317 317
318} 318}
319 319
320#endif 320#endif
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index 2a3695d..83750d5 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -1,93 +1,93 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qdatetime.h> 29#include <qdatetime.h>
30 30
31#include <qpe/alarmserver.h> 31#include <qpe/alarmserver.h>
32 32
33// #include "otodoaccesssql.h" 33// #include "otodoaccesssql.h"
34#include <opie2/otodoaccess.h> 34#include <opie2/otodoaccess.h>
35#include <opie2/obackendfactory.h> 35#include <opie2/obackendfactory.h>
36 36
37namespace Opie { 37namespace Opie {
38OTodoAccess::OTodoAccess( OTodoAccessBackend* end, enum Access ) 38OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
39 : QObject(), OPimAccessTemplate<OTodo>( end ), m_todoBackEnd( end ) 39 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end )
40{ 40{
41// if (end == 0l ) 41// if (end == 0l )
42// m_todoBackEnd = new OTodoAccessBackendSQL( QString::null); 42// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null);
43 43
44 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! 44 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben !
45 if (end == 0l ) 45 if (end == 0l )
46 m_todoBackEnd = OBackendFactory<OTodoAccessBackend>::Default ("todo", QString::null); 46 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null);
47 47
48 setBackEnd( m_todoBackEnd ); 48 setBackEnd( m_todoBackEnd );
49} 49}
50OTodoAccess::~OTodoAccess() { 50OPimTodoAccess::~OPimTodoAccess() {
51// qWarning("~OTodoAccess"); 51// qWarning("~OPimTodoAccess");
52} 52}
53void OTodoAccess::mergeWith( const QValueList<OTodo>& list ) { 53void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) {
54 QValueList<OTodo>::ConstIterator it; 54 QValueList<OPimTodo>::ConstIterator it;
55 for ( it = list.begin(); it != list.end(); ++it ) { 55 for ( it = list.begin(); it != list.end(); ++it ) {
56 replace( (*it) ); 56 replace( (*it) );
57 } 57 }
58} 58}
59OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 59OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
60 const QDate& end, 60 const QDate& end,
61 bool includeNoDates ) { 61 bool includeNoDates ) {
62 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 62 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
63 63
64 List lis( ints, this ); 64 List lis( ints, this );
65 return lis; 65 return lis;
66} 66}
67OTodoAccess::List OTodoAccess::effectiveToDos( const QDate& start, 67OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
68 bool includeNoDates ) { 68 bool includeNoDates ) {
69 return effectiveToDos( start, QDate::currentDate(), 69 return effectiveToDos( start, QDate::currentDate(),
70 includeNoDates ); 70 includeNoDates );
71} 71}
72OTodoAccess::List OTodoAccess::overDue() { 72OPimTodoAccess::List OPimTodoAccess::overDue() {
73 List lis( m_todoBackEnd->overDue(), this ); 73 List lis( m_todoBackEnd->overDue(), this );
74 return lis; 74 return lis;
75} 75}
76/* sort order */ 76/* sort order */
77OTodoAccess::List OTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 77OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
78 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 78 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
79 filter, cat ); 79 filter, cat );
80 OTodoAccess::List list( ints, this ); 80 OPimTodoAccess::List list( ints, this );
81 return list; 81 return list;
82} 82}
83void OTodoAccess::removeAllCompleted() { 83void OPimTodoAccess::removeAllCompleted() {
84 m_todoBackEnd->removeAllCompleted(); 84 m_todoBackEnd->removeAllCompleted();
85} 85}
86QBitArray OTodoAccess::backendSupport( const QString& ) const{ 86QBitArray OPimTodoAccess::backendSupport( const QString& ) const{
87 return m_todoBackEnd->supports(); 87 return m_todoBackEnd->supports();
88} 88}
89bool OTodoAccess::backendSupports( int attr, const QString& ar) const{ 89bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{
90 return backendSupport(ar).testBit( attr ); 90 return backendSupport(ar).testBit( attr );
91} 91}
92 92
93} 93}
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h
index e13d277..51f3793 100644
--- a/libopie2/opiepim/core/otodoaccess.h
+++ b/libopie2/opiepim/core/otodoaccess.h
@@ -1,136 +1,136 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OPIE_TODO_ACCESS_H 29#ifndef OPIE_TODO_ACCESS_H
30#define OPIE_TODO_ACCESS_H 30#define OPIE_TODO_ACCESS_H
31 31
32#include <qobject.h> 32#include <qobject.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34 34
35#include <opie2/otodo.h> 35#include <opie2/opimtodo.h>
36#include <opie2/otodoaccessbackend.h> 36#include <opie2/otodoaccessbackend.h>
37#include <opie2/opimaccesstemplate.h> 37#include <opie2/opimaccesstemplate.h>
38 38
39namespace Opie { 39namespace Opie {
40 40
41/** 41/**
42 * OTodoAccess 42 * OPimTodoAccess
43 * the class to get access to 43 * the class to get access to
44 * the todolist 44 * the todolist
45 */ 45 */
46class OTodoAccess : public QObject, public OPimAccessTemplate<OTodo> { 46class OPimTodoAccess : public QObject, public OPimAccessTemplate<OPimTodo> {
47 Q_OBJECT 47 Q_OBJECT
48public: 48public:
49 enum SortOrder { Completed = 0, 49 enum SortOrder { Completed = 0,
50 Priority, 50 Priority,
51 Description, 51 Description,
52 Deadline }; 52 Deadline };
53 enum SortFilter{ Category =1, 53 enum SortFilter{ Category =1,
54 OnlyOverDue= 2, 54 OnlyOverDue= 2,
55 DoNotShowCompleted =4 }; 55 DoNotShowCompleted =4 };
56 /** 56 /**
57 * if you use 0l 57 * if you use 0l
58 * the default resource will be 58 * the default resource will be
59 * picked up 59 * picked up
60 */ 60 */
61 OTodoAccess( OTodoAccessBackend* = 0l, enum Access acc = Random ); 61 OPimTodoAccess( OPimTodoAccessBackend* = 0l, enum Access acc = Random );
62 ~OTodoAccess(); 62 ~OPimTodoAccess();
63 63
64 64
65 /* our functions here */ 65 /* our functions here */
66 /** 66 /**
67 * include todos from start to end 67 * include todos from start to end
68 * includeNoDates whether or not to include 68 * includeNoDates whether or not to include
69 * events with no dates 69 * events with no dates
70 */ 70 */
71 List effectiveToDos( const QDate& start, 71 List effectiveToDos( const QDate& start,
72 const QDate& end, 72 const QDate& end,
73 bool includeNoDates = true ); 73 bool includeNoDates = true );
74 74
75 /** 75 /**
76 * start 76 * start
77 * end date taken from the currentDate() 77 * end date taken from the currentDate()
78 */ 78 */
79 List effectiveToDos( const QDate& start, 79 List effectiveToDos( const QDate& start,
80 bool includeNoDates = true ); 80 bool includeNoDates = true );
81 81
82 82
83 /** 83 /**
84 * return overdue OTodos 84 * return overdue OPimTodos
85 */ 85 */
86 List overDue(); 86 List overDue();
87 87
88 /** 88 /**
89 * 89 *
90 */ 90 */
91 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ); 91 List sorted( bool ascending, int sortOrder, int sortFilter, int cat );
92 92
93 /** 93 /**
94 * merge a list of OTodos into 94 * merge a list of OPimTodos into
95 * the resource 95 * the resource
96 */ 96 */
97 void mergeWith( const QValueList<OTodo>& ); 97 void mergeWith( const QValueList<OPimTodo>& );
98 98
99 /** 99 /**
100 * delete all already completed items 100 * delete all already completed items
101 */ 101 */
102 void removeAllCompleted(); 102 void removeAllCompleted();
103 103
104 /** 104 /**
105 * request information about what a backend supports. 105 * request information about what a backend supports.
106 * Supports in the sense of beeing able to store. 106 * Supports in the sense of beeing able to store.
107 * This is related to the enum in OTodo 107 * This is related to the enum in OPimTodo
108 * 108 *
109 * @param backend Will be used in the future when we support multiple backend 109 * @param backend Will be used in the future when we support multiple backend
110 */ 110 */
111 QBitArray backendSupport( const QString& backend = QString::null )const; 111 QBitArray backendSupport( const QString& backend = QString::null )const;
112 112
113 /** 113 /**
114 * see above but for a specefic attribute. This method was added for convience 114 * see above but for a specefic attribute. This method was added for convience
115 * @param attr The attribute to be queried for 115 * @param attr The attribute to be queried for
116 * @param backend Will be used in the future when we support multiple backends 116 * @param backend Will be used in the future when we support multiple backends
117 */ 117 */
118 bool backendSupports( int attr, const QString& backend = QString::null )const; 118 bool backendSupports( int attr, const QString& backend = QString::null )const;
119signals: 119signals:
120 /** 120 /**
121 * if the OTodoAccess was changed 121 * if the OPimTodoAccess was changed
122 */ 122 */
123 void changed( const OTodoAccess* ); 123 void changed( const OPimTodoAccess* );
124 void changed( const OTodoAccess*, int uid ); 124 void changed( const OPimTodoAccess*, int uid );
125 void added( const OTodoAccess*, int uid ); 125 void added( const OPimTodoAccess*, int uid );
126 void removed( const OTodoAccess*, int uid ); 126 void removed( const OPimTodoAccess*, int uid );
127private: 127private:
128 int m_cat; 128 int m_cat;
129 OTodoAccessBackend* m_todoBackEnd; 129 OPimTodoAccessBackend* m_todoBackEnd;
130 class OTodoAccessPrivate; 130 class OPimTodoAccessPrivate;
131 OTodoAccessPrivate* d; 131 OPimTodoAccessPrivate* d;
132}; 132};
133 133
134} 134}
135 135
136#endif 136#endif
diff --git a/libopie2/opiepim/libopiepim2.control b/libopie2/opiepim/libopiepim2.control
index 1b419ad..b548b01 100644
--- a/libopie2/opiepim/libopiepim2.control
+++ b/libopie2/opiepim/libopiepim2.control
@@ -1,10 +1,10 @@
1Package: libopiepim2 1Package: libopiepim2
2Files: lib/libopiepim2.so.* 2Files: lib/libopiepim2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.2-$SUB_VERSION.2 7Version: 1.8.3-$SUB_VERSION.2
8Depends: libqpe1, libopiecore2 (1.8.2) 8Depends: libqpe1, libopiecore2 (>=1.8.0)
9Provides: libopiepim2 9Provides: libopiepim2
10Description: Opie library 2.0 PIM 10Description: Opie library 2.0 PIM
diff --git a/libopie2/opiepim/opiepim.pro b/libopie2/opiepim/opiepim.pro
index 82737f4..9a34e29 100644
--- a/libopie2/opiepim/opiepim.pro
+++ b/libopie2/opiepim/opiepim.pro
@@ -1,30 +1,27 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = ocontact.h ocontactfields.h opimrecord.h otodo.h opimnotify.h opimnotifymanager.h oevent.h 4HEADERS = opimcontact.h opimcontactfields.h opimrecord.h opimtodo.h opimnotify.h \
5 5 opimnotifymanager.h opimevent.h
6SOURCES = ocontact.cpp ocontactfields.cpp opimrecord.cpp otodo.cpp opimnotify.cpp \ 6
7 opimnotifymanager.cpp oevent.cpp 7SOURCES = opimcontact.cpp opimcontactfields.cpp opimrecord.cpp opimtodo.cpp opimnotify.cpp \
8 opimnotifymanager.cpp opimevent.cpp
8INTERFACES = 9INTERFACES =
9TARGET = opiepim2 10TARGET = opiepim2
10VERSION = 1.8.2 11VERSION = 1.8.3
11INCLUDEPATH += $(OPIEDIR)/include 12INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 13DEPENDPATH += $(OPIEDIR)/include
14LIBS += -lopiecore2
13 15
14include ( core/core.pro ) 16include ( core/core.pro )
15include ( core/backends/backends.pro ) 17include ( core/backends/backends.pro )
16include ( ui/ui.pro ) 18include ( ui/ui.pro )
17 19
18MOC_DIR = moc
19OBJECTS_DIR = obj
20
21
22!contains( platform, x11 ) { 20!contains( platform, x11 ) {
23 include ( $(OPIEDIR)/include.pro ) 21 include ( $(OPIEDIR)/include.pro )
24} 22}
25 23
26contains( platform, x11 ) { 24contains( platform, x11 ) {
27 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 25 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
28} 26}
29 27
30LIBS += -lopiecore2