author | alwin <alwin> | 2004-02-20 02:06:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-20 02:06:52 (UTC) |
commit | 55f4d502486e01927356908223622e435c975f7e (patch) (unidiff) | |
tree | 824b5c1e8992564677c4f39473bc108a32a2cf2a /libopie2/opiepim/backend | |
parent | 060b4fc7a3fd5c1b5f745167fe084f7486719b7e (diff) | |
download | opie-55f4d502486e01927356908223622e435c975f7e.zip opie-55f4d502486e01927356908223622e435c975f7e.tar.gz opie-55f4d502486e01927356908223622e435c975f7e.tar.bz2 |
moved the opie pim stuff to libopie2 - pim. Tried to resort them, may be someone should take a look for a better file order. but now all applications can start using libopiepim2 instead of libopie1-pim-stuff.
24 files changed, 815 insertions, 583 deletions
diff --git a/libopie2/opiepim/backend/backends.pro b/libopie2/opiepim/backend/backends.pro new file mode 100644 index 0000000..4231a00 --- a/dev/null +++ b/libopie2/opiepim/backend/backends.pro | |||
@@ -0,0 +1,31 @@ | |||
1 | SOURCES += core/backends/ocontactaccessbackend_sql.cpp \ | ||
2 | core/backends/ocontactaccessbackend_vcard.cpp \ | ||
3 | core/backends/ocontactaccessbackend_xml.cpp \ | ||
4 | core/backends/ocontactaccess.cpp \ | ||
5 | core/backends/odatebookaccessbackend.cpp \ | ||
6 | core/backends/odatebookaccessbackend_xml.cpp \ | ||
7 | core/backends/otodoaccessbackend.cpp \ | ||
8 | core/backends/otodoaccess.cpp \ | ||
9 | core/backends/otodoaccesssql.cpp \ | ||
10 | core/backends/otodoaccessvcal.cpp \ | ||
11 | core/backends/otodoaccessxml.cpp \ | ||
12 | core/backends/odatebookaccess.cpp \ | ||
13 | core/backends/odatebookaccessbackend_sql.cpp | ||
14 | |||
15 | HEADERS += core/backends/obackendfactory.h \ | ||
16 | core/backends/ocontactaccessbackend.h \ | ||
17 | core/backends/ocontactaccessbackend_sql.h \ | ||
18 | core/backends/ocontactaccessbackend_vcard.h \ | ||
19 | core/backends/ocontactaccessbackend_xml.h \ | ||
20 | core/backends/ocontactaccess.h \ | ||
21 | core/backends/odatebookaccessbackend.h \ | ||
22 | core/backends/odatebookaccessbackend_sql.h \ | ||
23 | core/backends/odatebookaccessbackend_xml.h \ | ||
24 | core/backends/opimaccessbackend.h \ | ||
25 | core/backends/opimaccesstemplate.h \ | ||
26 | core/backends/otodoaccessbackend.h \ | ||
27 | core/backends/otodoaccess.h \ | ||
28 | core/backends/otodoaccesssql.h \ | ||
29 | core/backends/otodoaccessvcal.h \ | ||
30 | core/backends/otodoaccessxml.h \ | ||
31 | core/backends/odatebookaccess.h | ||
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 761ab9a..346e2f5 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -1,121 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | This file is part of the Opie Project |
3 | * | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | * | 5 | .=l. |
6 | * ===================================================================== | 6 | .>+-= |
7 | *This program is free software; you can redistribute it and/or | 7 | _;:, .> :=|. This program is free software; you can |
8 | *modify it under the terms of the GNU Library General Public | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | * License as published by the Free Software Foundation; | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | * either version 2 of the License, or (at your option) any later | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | * version. | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
12 | * ===================================================================== | 30 | * ===================================================================== |
13 | * ToDo: Use plugins | 31 | * ToDo: Use plugins |
14 | * ===================================================================== | 32 | * ===================================================================== |
15 | * Version: $Id$ | ||
16 | * ===================================================================== | ||
17 | * History: | ||
18 | * $Log$ | ||
19 | * Revision 1.9 2003/12/22 10:19:26 eilers | ||
20 | * Finishing implementation of sql-backend for datebook. But I have to | ||
21 | * port the PIM datebook application to use it, before I could debug the | ||
22 | * whole stuff. | ||
23 | * Thus, PIM-Database backend is finished, but highly experimental. And some | ||
24 | * parts are still generic. For instance, the "queryByExample()" methods are | ||
25 | * not (or not fully) implemented. Todo: custom-entries not stored. | ||
26 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | ||
27 | * expression search in the database, which is not supported by sqlite ! | ||
28 | * Therefore we need either an extended sqlite or a workaround which would | ||
29 | * be very slow and memory consuming.. | ||
30 | * | ||
31 | * Revision 1.8 2003/09/22 14:31:16 eilers | ||
32 | * Added first experimental incarnation of sql-backend for addressbook. | ||
33 | * Some modifications to be able to compile the todo sql-backend. | ||
34 | * A lot of changes fill follow... | ||
35 | * | ||
36 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
37 | * Merging changes from BRANCH_1_0 to HEAD | ||
38 | * | ||
39 | * Revision 1.6.4.1 2003/06/30 14:34:19 eilers | ||
40 | * Patches from Zecke: | ||
41 | * Fixing and cleaning up extraMap handling | ||
42 | * Adding d_ptr for binary compatibility in the future | ||
43 | * | ||
44 | * Revision 1.6 2003/04/13 18:07:10 zecke | ||
45 | * More API doc | ||
46 | * QString -> const QString& | ||
47 | * QString = 0l -> QString::null | ||
48 | * | ||
49 | * Revision 1.5 2003/02/21 23:31:52 zecke | ||
50 | * Add XML datebookresource | ||
51 | * -clean up todoaccessxml header | ||
52 | * -implement some more stuff in the oeven tester | ||
53 | * -extend DefaultFactory to not crash and to use datebook | ||
54 | * | ||
55 | * -reading of OEvents is working nicely.. saving will be added | ||
56 | * tomorrow | ||
57 | * -fix spelling in ODateBookAcces | ||
58 | * | ||
59 | * Revision 1.4 2002/10/14 15:55:18 eilers | ||
60 | * Redeactivate SQL.. ;) | ||
61 | * | ||
62 | * Revision 1.3 2002/10/10 17:08:58 zecke | ||
63 | * The Cache is finally in place | ||
64 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | ||
65 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... | ||
66 | * I still have to fully implement read ahead | ||
67 | * This change is bic but sc | ||
68 | * | ||
69 | * Revision 1.2 2002/10/08 09:27:36 eilers | ||
70 | * Fixed libopie.pro to include the new pim-API. | ||
71 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | ||
72 | * compile itself would need to install libsqlite, libopiesql... | ||
73 | * Therefore, the backend currently uses XML only.. | ||
74 | * | ||
75 | * Revision 1.1 2002/10/07 17:35:01 eilers | ||
76 | * added OBackendFactory for advanced backend access | ||
77 | * | ||
78 | * | ||
79 | * ===================================================================== | ||
80 | */ | 33 | */ |
81 | #ifndef OPIE_BACKENDFACTORY_H_ | 34 | #ifndef OPIE_BACKENDFACTORY_H_ |
82 | #define OPIE_BACKENDFACTORY_H_ | 35 | #define OPIE_BACKENDFACTORY_H_ |
83 | 36 | ||
84 | #include <qstring.h> | 37 | #include <qstring.h> |
85 | #include <qasciidict.h> | 38 | #include <qasciidict.h> |
86 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
87 | 40 | ||
88 | #include "otodoaccessxml.h" | 41 | #include <opie2/otodoaccessxml.h> |
89 | #include "ocontactaccessbackend_xml.h" | 42 | #include <opie2/ocontactaccessbackend_xml.h> |
90 | #include "odatebookaccessbackend_xml.h" | 43 | #include <opie2/odatebookaccessbackend_xml.h> |
91 | 44 | ||
92 | #ifdef __USE_SQL | 45 | #ifdef __USE_SQL |
93 | #include "otodoaccesssql.h" | 46 | #include <opie2/otodoaccesssql.h> |
94 | #include "ocontactaccessbackend_sql.h" | 47 | #include <opie2/ocontactaccessbackend_sql.h> |
95 | #include "odatebookaccessbackend_sql.h" | 48 | #include <opie2/odatebookaccessbackend_sql.h> |
96 | #endif | 49 | #endif |
97 | 50 | ||
51 | namespace Opie { | ||
52 | |||
98 | class OBackendPrivate; | 53 | class OBackendPrivate; |
99 | 54 | ||
100 | /** | 55 | /** |
101 | * 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 |
102 | * 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 |
103 | * 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 |
104 | * to recompile.# | 59 | * to recompile.# |
105 | * 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 |
106 | * | 61 | * |
107 | * <pre> | 62 | * <pre> |
108 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | 63 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); |
109 | * backend->load(); | 64 | * backend->load(); |
110 | * </pre> | 65 | * </pre> |
111 | * | 66 | * |
112 | * @author Stefan Eilers | 67 | * @author Stefan Eilers |
113 | * @version 0.1 | 68 | * @version 0.1 |
114 | */ | 69 | */ |
115 | template<class T> | 70 | template<class T> |
116 | class OBackendFactory | 71 | class OBackendFactory |
117 | { | 72 | { |
118 | public: | 73 | public: |
119 | OBackendFactory() {}; | 74 | OBackendFactory() {}; |
120 | 75 | ||
121 | enum BACKENDS { | 76 | enum BACKENDS { |
@@ -169,26 +124,27 @@ class OBackendFactory | |||
169 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); | 124 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); |
170 | #endif | 125 | #endif |
171 | 126 | ||
172 | return (T*) new OContactAccessBackend_XML( appName ); | 127 | return (T*) new OContactAccessBackend_XML( appName ); |
173 | case DATE: | 128 | case DATE: |
174 | #ifdef __USE_SQL | 129 | #ifdef __USE_SQL |
175 | if ( backend == "sql" ) | 130 | if ( backend == "sql" ) |
176 | return (T*) new ODateBookAccessBackend_SQL(""); | 131 | return (T*) new ODateBookAccessBackend_SQL(""); |
177 | #else | 132 | #else |
178 | if ( backend == "sql" ) | 133 | if ( backend == "sql" ) |
179 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); | 134 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); |
180 | #endif | 135 | #endif |
181 | 136 | ||
182 | return (T*) new ODateBookAccessBackend_XML( appName ); | 137 | return (T*) new ODateBookAccessBackend_XML( appName ); |
183 | default: | 138 | default: |
184 | return NULL; | 139 | return NULL; |
185 | } | 140 | } |
186 | 141 | ||
187 | 142 | ||
188 | } | 143 | } |
189 | private: | 144 | private: |
190 | OBackendPrivate* d; | 145 | OBackendPrivate* d; |
191 | }; | 146 | }; |
192 | 147 | ||
148 | } | ||
193 | 149 | ||
194 | #endif | 150 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h index 0eac6dc..6113cea 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend.h | |||
@@ -1,88 +1,71 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | /** | 29 | /** |
2 | * The class responsible for managing a backend. | 30 | * The class responsible for managing a backend. |
3 | * The implementation of this abstract class contains | 31 | * The implementation of this abstract class contains |
4 | * the complete database handling. | 32 | * the complete database handling. |
5 | * | 33 | * |
6 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 34 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
7 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) | 35 | * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) |
8 | * | 36 | * |
9 | * ===================================================================== | ||
10 | *This program is free software; you can redistribute it and/or | ||
11 | *modify it under the terms of the GNU Library General Public | ||
12 | * License as published by the Free Software Foundation; | ||
13 | * either version 2 of the License, or (at your option) any later | ||
14 | * version. | ||
15 | * ===================================================================== | ||
16 | * ToDo: Define enum for query settings | ||
17 | * ===================================================================== | ||
18 | * Version: $Id$ | ||
19 | * ===================================================================== | ||
20 | * History: | ||
21 | * $Log$ | ||
22 | * Revision 1.7 2004/02/19 02:05:37 zecke | ||
23 | * Add notes for API fixes and BC stuff | ||
24 | * | ||
25 | * Revision 1.6 2003/08/01 12:30:16 eilers | ||
26 | * Merging changes from BRANCH_1_0 to HEAD | ||
27 | * | ||
28 | * Revision 1.5.4.1 2003/06/30 14:34:19 eilers | ||
29 | * Patches from Zecke: | ||
30 | * Fixing and cleaning up extraMap handling | ||
31 | * Adding d_ptr for binary compatibility in the future | ||
32 | * | ||
33 | * Revision 1.5 2003/04/13 18:07:10 zecke | ||
34 | * More API doc | ||
35 | * QString -> const QString& | ||
36 | * QString = 0l -> QString::null | ||
37 | * | ||
38 | * Revision 1.4 2002/11/13 14:14:51 eilers | ||
39 | * Added sorted for Contacts.. | ||
40 | * | ||
41 | * Revision 1.3 2002/11/01 15:10:42 eilers | ||
42 | * Added regExp-search in database for all fields in a contact. | ||
43 | * | ||
44 | * Revision 1.2 2002/10/07 17:34:24 eilers | ||
45 | * added OBackendFactory for advanced backend access | ||
46 | * | ||
47 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
48 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
49 | * please do not expect that anything is working ! | ||
50 | * I will debug that stuff in the next time .. | ||
51 | * Please read README_COMPILE for compiling ! | ||
52 | * | ||
53 | * ===================================================================== | ||
54 | * | ||
55 | */ | 37 | */ |
56 | 38 | ||
57 | #ifndef _OCONTACTACCESSBACKEND_H_ | 39 | #ifndef _OCONTACTACCESSBACKEND_H_ |
58 | #define _OCONTACTACCESSBACKEND_H_ | 40 | #define _OCONTACTACCESSBACKEND_H_ |
59 | 41 | ||
60 | #include "ocontact.h" | 42 | #include <opie2/ocontact.h> |
61 | #include "opimaccessbackend.h" | 43 | #include <opie2/opimaccessbackend.h> |
62 | 44 | ||
63 | #include <qregexp.h> | 45 | #include <qregexp.h> |
64 | 46 | ||
47 | namespace Opie { | ||
65 | /** | 48 | /** |
66 | * This class represents the interface of all Contact Backends. | 49 | * This class represents the interface of all Contact Backends. |
67 | * Derivates of this class will be used to access the contacts. | 50 | * Derivates of this class will be used to access the contacts. |
68 | * 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 |
69 | * if you want to provide your own storage. | 52 | * if you want to provide your own storage. |
70 | * 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! |
71 | * | 54 | * |
72 | * @see OContactAccessBackend_VCard | 55 | * @see OContactAccessBackend_VCard |
73 | * @see OContactAccessBackend_XML | 56 | * @see OContactAccessBackend_XML |
74 | */ | 57 | */ |
75 | class OContactAccessBackend: public OPimAccessBackend<OContact> { | 58 | class OContactAccessBackend: public OPimAccessBackend<OContact> { |
76 | public: | 59 | public: |
77 | /** | 60 | /** |
78 | * @todo make non line in regard to BC guide of KDE | 61 | * @todo make non line in regard to BC guide of KDE |
79 | */ | 62 | */ |
80 | OContactAccessBackend() {} | 63 | OContactAccessBackend() {} |
81 | /** | 64 | /** |
82 | * @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 |
83 | */ | 66 | */ |
84 | virtual ~OContactAccessBackend() {} | 67 | virtual ~OContactAccessBackend() {} |
85 | 68 | ||
86 | 69 | ||
87 | /** | 70 | /** |
88 | * Return if database was changed externally. | 71 | * Return if database was changed externally. |
@@ -104,25 +87,28 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> { | |||
104 | /** | 87 | /** |
105 | * Return all possible settings. | 88 | * Return all possible settings. |
106 | * @return All settings provided by the current backend | 89 | * @return All settings provided by the current backend |
107 | * (i.e.: query_WildCards & query_IgnoreCase) | 90 | * (i.e.: query_WildCards & query_IgnoreCase) |
108 | */ | 91 | */ |
109 | virtual const uint querySettings() = 0; | 92 | virtual const uint querySettings() = 0; |
110 | 93 | ||
111 | /** | 94 | /** |
112 | * Check whether settings are correct. | 95 | * Check whether settings are correct. |
113 | * @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. |
114 | */ | 97 | */ |
115 | virtual bool hasQuerySettings (uint querySettings) const = 0; | 98 | virtual bool hasQuerySettings (uint querySettings) const = 0; |
116 | 99 | ||
117 | /** | 100 | /** |
118 | * FIXME!!! | 101 | * FIXME!!! |
119 | * 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 |
120 | */ | 103 | */ |
121 | 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; |
122 | 105 | ||
123 | 106 | ||
124 | private: | 107 | private: |
125 | class Private; | 108 | class Private; |
126 | Private *d; | 109 | Private *d; |
127 | }; | 110 | }; |
111 | |||
112 | } | ||
113 | |||
128 | #endif | 114 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp index a5be4c8..d0c8052 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | |||
@@ -1,108 +1,97 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * SQL Backend for the OPIE-Contact Database. | 30 | * SQL Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * ===================================================================== | ||
13 | * Version: $Id$ | ||
14 | * ===================================================================== | ||
15 | * History: | ||
16 | * $Log$ | ||
17 | * Revision 1.4 2003/12/22 10:19:26 eilers | ||
18 | * Finishing implementation of sql-backend for datebook. But I have to | ||
19 | * port the PIM datebook application to use it, before I could debug the | ||
20 | * whole stuff. | ||
21 | * Thus, PIM-Database backend is finished, but highly experimental. And some | ||
22 | * parts are still generic. For instance, the "queryByExample()" methods are | ||
23 | * not (or not fully) implemented. Todo: custom-entries not stored. | ||
24 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | ||
25 | * expression search in the database, which is not supported by sqlite ! | ||
26 | * Therefore we need either an extended sqlite or a workaround which would | ||
27 | * be very slow and memory consuming.. | ||
28 | * | ||
29 | * Revision 1.3 2003/12/08 15:18:10 eilers | ||
30 | * Committing unfinished sql implementation before merging to libopie2 starts.. | ||
31 | * | ||
32 | * Revision 1.2 2003/09/29 07:44:26 eilers | ||
33 | * Improvement of PIM-SQL Databases, but search queries are still limited. | ||
34 | * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space. | ||
35 | * Todo: Started to add new attributes. Some type conversions missing. | ||
36 | * | ||
37 | * Revision 1.1 2003/09/22 14:31:16 eilers | ||
38 | * Added first experimental incarnation of sql-backend for addressbook. | ||
39 | * Some modifications to be able to compile the todo sql-backend. | ||
40 | * A lot of changes fill follow... | ||
41 | * | ||
42 | */ | 31 | */ |
43 | 32 | ||
44 | #include "ocontactaccessbackend_sql.h" | 33 | #include "ocontactaccessbackend_sql.h" |
45 | 34 | ||
46 | #include <qarray.h> | 35 | #include <qarray.h> |
47 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
48 | #include <qstringlist.h> | 37 | #include <qstringlist.h> |
49 | 38 | ||
50 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
51 | #include <qpe/recordfields.h> | 40 | #include <qpe/recordfields.h> |
52 | 41 | ||
53 | #include <opie/ocontactfields.h> | 42 | #include <opie2/ocontactfields.h> |
54 | #include <opie/oconversion.h> | 43 | #include <opie2/oconversion.h> |
55 | #include <opie2/osqldriver.h> | 44 | #include <opie2/osqldriver.h> |
56 | #include <opie2/osqlresult.h> | 45 | #include <opie2/osqlresult.h> |
57 | #include <opie2/osqlmanager.h> | 46 | #include <opie2/osqlmanager.h> |
58 | #include <opie2/osqlquery.h> | 47 | #include <opie2/osqlquery.h> |
59 | 48 | ||
60 | 49 | ||
61 | 50 | ||
62 | 51 | ||
63 | // 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 |
64 | // vertical like "uid, type, value". | 53 | // vertical like "uid, type, value". |
65 | // DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! | 54 | // DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! |
66 | #define __STORE_HORIZONTAL_ | 55 | #define __STORE_HORIZONTAL_ |
67 | 56 | ||
68 | // 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 |
69 | // 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, |
70 | // which is faster.. | 59 | // which is faster.. |
71 | // 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.. |
72 | // 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) |
73 | #define __USE_SUPERFAST_LOADQUERY | 62 | #define __USE_SUPERFAST_LOADQUERY |
74 | 63 | ||
75 | 64 | ||
76 | /* | 65 | /* |
77 | * Implementation of used query types | 66 | * Implementation of used query types |
78 | * CREATE query | 67 | * CREATE query |
79 | * LOAD query | 68 | * LOAD query |
80 | * INSERT | 69 | * INSERT |
81 | * REMOVE | 70 | * REMOVE |
82 | * CLEAR | 71 | * CLEAR |
83 | */ | 72 | */ |
84 | namespace { | 73 | namespace Opie { |
85 | /** | 74 | /** |
86 | * CreateQuery for the Todolist Table | 75 | * CreateQuery for the Todolist Table |
87 | */ | 76 | */ |
88 | class CreateQuery : public OSQLQuery { | 77 | class CreateQuery : public OSQLQuery { |
89 | public: | 78 | public: |
90 | CreateQuery(); | 79 | CreateQuery(); |
91 | ~CreateQuery(); | 80 | ~CreateQuery(); |
92 | QString query()const; | 81 | QString query()const; |
93 | }; | 82 | }; |
94 | 83 | ||
95 | /** | 84 | /** |
96 | * Clears (delete) a Table | 85 | * Clears (delete) a Table |
97 | */ | 86 | */ |
98 | class ClearQuery : public OSQLQuery { | 87 | class ClearQuery : public OSQLQuery { |
99 | public: | 88 | public: |
100 | ClearQuery(); | 89 | ClearQuery(); |
101 | ~ClearQuery(); | 90 | ~ClearQuery(); |
102 | QString query()const; | 91 | QString query()const; |
103 | 92 | ||
104 | }; | 93 | }; |
105 | 94 | ||
106 | 95 | ||
107 | /** | 96 | /** |
108 | * LoadQuery | 97 | * LoadQuery |
@@ -447,48 +436,50 @@ namespace { | |||
447 | 436 | ||
448 | FindCustomQuery::FindCustomQuery(int uid) | 437 | FindCustomQuery::FindCustomQuery(int uid) |
449 | : OSQLQuery(), m_uid( uid ) { | 438 | : OSQLQuery(), m_uid( uid ) { |
450 | } | 439 | } |
451 | FindCustomQuery::FindCustomQuery(const QArray<int>& ints) | 440 | FindCustomQuery::FindCustomQuery(const QArray<int>& ints) |
452 | : OSQLQuery(), m_uids( ints ){ | 441 | : OSQLQuery(), m_uids( ints ){ |
453 | } | 442 | } |
454 | FindCustomQuery::~FindCustomQuery() { | 443 | FindCustomQuery::~FindCustomQuery() { |
455 | } | 444 | } |
456 | QString FindCustomQuery::query()const{ | 445 | QString FindCustomQuery::query()const{ |
457 | // if ( m_uids.count() == 0 ) | 446 | // if ( m_uids.count() == 0 ) |
458 | return single(); | 447 | return single(); |
459 | } | 448 | } |
460 | QString FindCustomQuery::single()const{ | 449 | QString FindCustomQuery::single()const{ |
461 | QString qu = "select uid, type, value from custom_data where uid = "; | 450 | QString qu = "select uid, type, value from custom_data where uid = "; |
462 | qu += QString::number(m_uid); | 451 | qu += QString::number(m_uid); |
463 | return qu; | 452 | return qu; |
464 | } | 453 | } |
465 | 454 | ||
466 | }; | 455 | }; |
467 | 456 | ||
468 | 457 | ||
469 | /* --------------------------------------------------------------------------- */ | 458 | /* --------------------------------------------------------------------------- */ |
470 | 459 | ||
460 | namespace Opie { | ||
461 | |||
471 | OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */, | 462 | OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */, |
472 | const QString& filename ): | 463 | const QString& filename ): |
473 | OContactAccessBackend(), m_changed(false), m_driver( NULL ) | 464 | OContactAccessBackend(), m_changed(false), m_driver( NULL ) |
474 | { | 465 | { |
475 | qWarning("C'tor OContactAccessBackend_SQL starts"); | 466 | qWarning("C'tor OContactAccessBackend_SQL starts"); |
476 | QTime t; | 467 | QTime t; |
477 | t.start(); | 468 | t.start(); |
478 | 469 | ||
479 | /* Expecting to access the default filename if nothing else is set */ | 470 | /* Expecting to access the default filename if nothing else is set */ |
480 | if ( filename.isEmpty() ){ | 471 | if ( filename.isEmpty() ){ |
481 | m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); | 472 | m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); |
482 | } else | 473 | } else |
483 | m_fileName = filename; | 474 | m_fileName = filename; |
484 | 475 | ||
485 | // Get the standart sql-driver from the OSQLManager.. | 476 | // Get the standart sql-driver from the OSQLManager.. |
486 | OSQLManager man; | 477 | OSQLManager man; |
487 | m_driver = man.standard(); | 478 | m_driver = man.standard(); |
488 | m_driver->setUrl( m_fileName ); | 479 | m_driver->setUrl( m_fileName ); |
489 | 480 | ||
490 | load(); | 481 | load(); |
491 | 482 | ||
492 | qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() ); | 483 | qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() ); |
493 | } | 484 | } |
494 | 485 | ||
@@ -919,24 +910,26 @@ QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) cons | |||
919 | { | 910 | { |
920 | QTime t; | 911 | QTime t; |
921 | t.start(); | 912 | t.start(); |
922 | 913 | ||
923 | QMap<QString, QString> customMap; | 914 | QMap<QString, QString> customMap; |
924 | 915 | ||
925 | FindCustomQuery query( uid ); | 916 | FindCustomQuery query( uid ); |
926 | OSQLResult res_custom = m_driver->query( &query ); | 917 | OSQLResult res_custom = m_driver->query( &query ); |
927 | 918 | ||
928 | if ( res_custom.state() == OSQLResult::Failure ) { | 919 | if ( res_custom.state() == OSQLResult::Failure ) { |
929 | qWarning("OSQLResult::Failure in find query !!"); | 920 | qWarning("OSQLResult::Failure in find query !!"); |
930 | QMap<QString, QString> empty; | 921 | QMap<QString, QString> empty; |
931 | return empty; | 922 | return empty; |
932 | } | 923 | } |
933 | 924 | ||
934 | OSQLResultItem::ValueList list = res_custom.results(); | 925 | OSQLResultItem::ValueList list = res_custom.results(); |
935 | OSQLResultItem::ValueList::Iterator it = list.begin(); | 926 | OSQLResultItem::ValueList::Iterator it = list.begin(); |
936 | for ( ; it != list.end(); ++it ) { | 927 | for ( ; it != list.end(); ++it ) { |
937 | customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); | 928 | customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); |
938 | } | 929 | } |
939 | 930 | ||
940 | qWarning("RequestCustom needed: %d ms", t.elapsed() ); | 931 | qWarning("RequestCustom needed: %d ms", t.elapsed() ); |
941 | return customMap; | 932 | return customMap; |
942 | } | 933 | } |
934 | |||
935 | } | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h index b8f1d8d..55b95fd 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h | |||
@@ -1,66 +1,72 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * SQL Backend for the OPIE-Contact Database. | 30 | * SQL Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * | ||
13 | * | ||
14 | * ===================================================================== | ||
15 | * Version: $Id$ | ||
16 | * ===================================================================== | ||
17 | * History: | ||
18 | * $Log$ | ||
19 | * Revision 1.2 2003/12/08 15:18:11 eilers | ||
20 | * Committing unfinished sql implementation before merging to libopie2 starts.. | ||
21 | * | ||
22 | * Revision 1.1 2003/09/22 14:31:16 eilers | ||
23 | * Added first experimental incarnation of sql-backend for addressbook. | ||
24 | * Some modifications to be able to compile the todo sql-backend. | ||
25 | * A lot of changes fill follow... | ||
26 | * | ||
27 | * | ||
28 | */ | 31 | */ |
29 | 32 | ||
30 | #ifndef _OContactAccessBackend_SQL_ | 33 | #ifndef _OContactAccessBackend_SQL_ |
31 | #define _OContactAccessBackend_SQL_ | 34 | #define _OContactAccessBackend_SQL_ |
32 | 35 | ||
33 | #include "ocontactaccessbackend.h" | 36 | #include <opie2/ocontactaccessbackend.h> |
34 | #include "ocontactaccess.h" | 37 | #include <opie2/ocontactaccess.h> |
35 | 38 | ||
36 | #include <qlist.h> | 39 | #include <qlist.h> |
37 | #include <qdict.h> | 40 | #include <qdict.h> |
38 | 41 | ||
42 | /* aren't in namespace Opie yet - alwin */ | ||
39 | class OSQLDriver; | 43 | class OSQLDriver; |
40 | class OSQLResult; | 44 | class OSQLResult; |
41 | class OSQLResultItem; | 45 | class OSQLResultItem; |
42 | 46 | ||
47 | namespace Opie { | ||
48 | |||
43 | /* the default xml implementation */ | 49 | /* the default xml implementation */ |
44 | /** | 50 | /** |
45 | * This class is the SQL implementation of a Contact backend | 51 | * This class is the SQL implementation of a Contact backend |
46 | * it does implement everything available for OContact. | 52 | * it does implement everything available for OContact. |
47 | * @see OPimAccessBackend for more information of available methods | 53 | * @see OPimAccessBackend for more information of available methods |
48 | */ | 54 | */ |
49 | class OContactAccessBackend_SQL : public OContactAccessBackend { | 55 | class OContactAccessBackend_SQL : public OContactAccessBackend { |
50 | public: | 56 | public: |
51 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); | 57 | OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); |
52 | 58 | ||
53 | ~OContactAccessBackend_SQL (); | 59 | ~OContactAccessBackend_SQL (); |
54 | 60 | ||
55 | bool save(); | 61 | bool save(); |
56 | 62 | ||
57 | bool load (); | 63 | bool load (); |
58 | 64 | ||
59 | void clear (); | 65 | void clear (); |
60 | 66 | ||
61 | bool wasChangedExternally(); | 67 | bool wasChangedExternally(); |
62 | 68 | ||
63 | QArray<int> allRecords() const; | 69 | QArray<int> allRecords() const; |
64 | 70 | ||
65 | OContact find ( int uid ) const; | 71 | OContact find ( int uid ) const; |
66 | // FIXME: Add lookahead-cache support ! | 72 | // FIXME: Add lookahead-cache support ! |
@@ -77,25 +83,27 @@ class OContactAccessBackend_SQL : public OContactAccessBackend { | |||
77 | 83 | ||
78 | // Currently only asc implemented.. | 84 | // Currently only asc implemented.. |
79 | QArray<int> sorted( bool asc, int , int , int ); | 85 | QArray<int> sorted( bool asc, int , int , int ); |
80 | bool add ( const OContact &newcontact ); | 86 | bool add ( const OContact &newcontact ); |
81 | 87 | ||
82 | bool replace ( const OContact &contact ); | 88 | bool replace ( const OContact &contact ); |
83 | 89 | ||
84 | bool remove ( int uid ); | 90 | bool remove ( int uid ); |
85 | bool reload(); | 91 | bool reload(); |
86 | 92 | ||
87 | private: | 93 | private: |
88 | QArray<int> extractUids( OSQLResult& res ) const; | 94 | QArray<int> extractUids( OSQLResult& res ) const; |
89 | QMap<int, QString> requestNonCustom( int uid ) const; | 95 | QMap<int, QString> requestNonCustom( int uid ) const; |
90 | QMap<QString, QString> requestCustom( int uid ) const; | 96 | QMap<QString, QString> requestCustom( int uid ) const; |
91 | void update(); | 97 | void update(); |
92 | 98 | ||
93 | protected: | 99 | protected: |
94 | bool m_changed; | 100 | bool m_changed; |
95 | QString m_fileName; | 101 | QString m_fileName; |
96 | QArray<int> m_uids; | 102 | QArray<int> m_uids; |
97 | 103 | ||
98 | OSQLDriver* m_driver; | 104 | OSQLDriver* m_driver; |
99 | }; | 105 | }; |
100 | 106 | ||
107 | } | ||
108 | |||
101 | #endif | 109 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index b60c5be..f85cf38 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -1,122 +1,65 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * VCard Backend for the OPIE-Contact Database. | 30 | * VCard Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
6 | * | ||
7 | * ===================================================================== | ||
8 | *This program is free software; you can redistribute it and/or | ||
9 | *modify it under the terms of the GNU Library General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2 of the License, or (at your option) any later version. | ||
12 | * ===================================================================== | ||
13 | * ToDo: | ||
14 | * | ||
15 | * ===================================================================== | ||
16 | * Version: $Id$ | ||
17 | * ===================================================================== | ||
18 | * History: | ||
19 | * $Log$ | ||
20 | * Revision 1.11 2003/08/01 12:30:16 eilers | ||
21 | * Merging changes from BRANCH_1_0 to HEAD | ||
22 | * | ||
23 | * Revision 1.10.4.3 2003/07/23 08:54:37 eilers | ||
24 | * Default email was added to the list of all emails, which already contains | ||
25 | * the default email.. | ||
26 | * This closes bug #1045 | ||
27 | * | ||
28 | * Revision 1.10.4.2 2003/07/23 08:44:45 eilers | ||
29 | * Importing of Notes in vcard files wasn't implemented. | ||
30 | * Closes bug #1044 | ||
31 | * | ||
32 | * Revision 1.10.4.1 2003/06/02 13:37:49 eilers | ||
33 | * Fixing memory leak | ||
34 | * | ||
35 | * Revision 1.10 2003/04/13 18:07:10 zecke | ||
36 | * More API doc | ||
37 | * QString -> const QString& | ||
38 | * QString = 0l -> QString::null | ||
39 | * | ||
40 | * Revision 1.9 2003/03/21 10:33:09 eilers | ||
41 | * Merged speed optimized xml backend for contacts to main. | ||
42 | * Added QDateTime to querybyexample. For instance, it is now possible to get | ||
43 | * all Birthdays/Anniversaries between two dates. This should be used | ||
44 | * to show all birthdays in the datebook.. | ||
45 | * This change is sourcecode backward compatible but you have to upgrade | ||
46 | * the binaries for today-addressbook. | ||
47 | * | ||
48 | * Revision 1.8 2003/02/21 16:52:49 zecke | ||
49 | * -Remove old Todo classes they're deprecated and today I already using the | ||
50 | * new API | ||
51 | * -Guard against self assignment in OTodo | ||
52 | * -Add test apps for OPIM | ||
53 | * -Opiefied Event classes | ||
54 | * -Added TimeZone handling and pinning of TimeZones to OEvent | ||
55 | * -Adjust ORecur and the widget to better timezone behaviour | ||
56 | * | ||
57 | * Revision 1.7 2003/02/16 22:25:46 zecke | ||
58 | * 0000276 Fix for that bug.. or better temp workaround | ||
59 | * A Preferred Number is HOME|VOICE | ||
60 | * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test | ||
61 | * triggers both | ||
62 | * and the cell phone number overrides the other entries.. | ||
63 | * | ||
64 | * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the | ||
65 | * number | ||
66 | * | ||
67 | * The right and final fix would be to reorder the if statement to make it | ||
68 | * if else based and the less common thing put to the bottom | ||
69 | * | ||
70 | * OTodoAccessVcal fix the date for beaming | ||
71 | * | ||
72 | * Revision 1.6 2003/01/13 15:49:31 eilers | ||
73 | * Fixing crash when businesscard.vcf is missing.. | ||
74 | * | ||
75 | * Revision 1.5 2002/12/07 13:26:22 eilers | ||
76 | * Fixing bug in storing anniversary.. | ||
77 | * | ||
78 | * Revision 1.4 2002/11/13 14:14:51 eilers | ||
79 | * Added sorted for Contacts.. | ||
80 | * | ||
81 | * Revision 1.3 2002/11/11 16:41:09 kergoth | ||
82 | * no default arguments in implementation | ||
83 | * | ||
84 | * Revision 1.2 2002/11/10 15:41:53 eilers | ||
85 | * Bugfixes.. | ||
86 | * | ||
87 | * Revision 1.1 2002/11/09 14:34:52 eilers | ||
88 | * Added VCard Backend. | ||
89 | * | ||
90 | */ | 31 | */ |
91 | #include "ocontactaccessbackend_vcard.h" | 32 | #include <opie2/ocontactaccessbackend_vcard.h> |
92 | #include "../../library/backend/vobject_p.h" | 33 | #include "../../../../library/backend/vobject_p.h" |
93 | #include "../../library/backend/qfiledirect_p.h" | 34 | #include "../../../../library/backend/qfiledirect_p.h" |
94 | 35 | ||
95 | #include <qpe/timeconversion.h> | 36 | #include <qpe/timeconversion.h> |
96 | 37 | ||
97 | #include <qfile.h> | 38 | #include <qfile.h> |
98 | 39 | ||
40 | namespace Opie { | ||
41 | |||
99 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): | 42 | OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): |
100 | m_dirty( false ), | 43 | m_dirty( false ), |
101 | m_file( filename ) | 44 | m_file( filename ) |
102 | { | 45 | { |
103 | load(); | 46 | load(); |
104 | } | 47 | } |
105 | 48 | ||
106 | 49 | ||
107 | bool OContactAccessBackend_VCard::load () | 50 | bool OContactAccessBackend_VCard::load () |
108 | { | 51 | { |
109 | m_map.clear(); | 52 | m_map.clear(); |
110 | m_dirty = false; | 53 | m_dirty = false; |
111 | 54 | ||
112 | VObject* obj = 0l; | 55 | VObject* obj = 0l; |
113 | 56 | ||
114 | if ( QFile::exists(m_file) ){ | 57 | if ( QFile::exists(m_file) ){ |
115 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 58 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
116 | if ( !obj ) | 59 | if ( !obj ) |
117 | return false; | 60 | return false; |
118 | }else{ | 61 | }else{ |
119 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 62 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
120 | return false; | 63 | return false; |
121 | } | 64 | } |
122 | 65 | ||
@@ -623,24 +566,26 @@ QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) | |||
623 | } | 566 | } |
624 | int y = datestr.left( monthPos ).toInt(); | 567 | int y = datestr.left( monthPos ).toInt(); |
625 | 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(); |
626 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); | 569 | int d = datestr.mid( dayPos + sep_ignore ).toInt(); |
627 | 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); |
628 | QDate date ( y,m,d ); | 571 | QDate date ( y,m,d ); |
629 | return date; | 572 | return date; |
630 | } | 573 | } |
631 | 574 | ||
632 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 575 | VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
633 | { | 576 | { |
634 | VObject *ret = 0; | 577 | VObject *ret = 0; |
635 | if ( o && !value.isEmpty() ) | 578 | if ( o && !value.isEmpty() ) |
636 | ret = addPropValue( o, prop, value.latin1() ); | 579 | ret = addPropValue( o, prop, value.latin1() ); |
637 | return ret; | 580 | return ret; |
638 | } | 581 | } |
639 | 582 | ||
640 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) | 583 | VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) |
641 | { | 584 | { |
642 | VObject *ret = 0; | 585 | VObject *ret = 0; |
643 | if ( o ) | 586 | if ( o ) |
644 | ret = addProp( o, prop ); | 587 | ret = addProp( o, prop ); |
645 | return ret; | 588 | return ret; |
646 | } | 589 | } |
590 | |||
591 | } | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h index 712d769..11be027 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h | |||
@@ -1,96 +1,85 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * VCard Backend for the OPIE-Contact Database. | 30 | * VCard Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
5 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
6 | * | ||
7 | * ===================================================================== | ||
8 | *This program is free software; you can redistribute it and/or | ||
9 | *modify it under the terms of the GNU Library General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2 of the License, or (at your option) any later version. | ||
12 | * ===================================================================== | ||
13 | * ToDo: | ||
14 | * | ||
15 | * ===================================================================== | ||
16 | * Version: $Id$ | ||
17 | * ===================================================================== | ||
18 | * History: | ||
19 | * $Log$ | ||
20 | * Revision 1.6 2003/04/13 18:07:10 zecke | ||
21 | * More API doc | ||
22 | * QString -> const QString& | ||
23 | * QString = 0l -> QString::null | ||
24 | * | ||
25 | * Revision 1.5 2003/03/21 10:33:09 eilers | ||
26 | * Merged speed optimized xml backend for contacts to main. | ||
27 | * Added QDateTime to querybyexample. For instance, it is now possible to get | ||
28 | * all Birthdays/Anniversaries between two dates. This should be used | ||
29 | * to show all birthdays in the datebook.. | ||
30 | * This change is sourcecode backward compatible but you have to upgrade | ||
31 | * the binaries for today-addressbook. | ||
32 | * | ||
33 | * Revision 1.4 2002/12/07 13:26:22 eilers | ||
34 | * Fixing bug in storing anniversary.. | ||
35 | * | ||
36 | * Revision 1.3 2002/11/13 14:14:51 eilers | ||
37 | * Added sorted for Contacts.. | ||
38 | * | ||
39 | * Revision 1.2 2002/11/10 15:41:53 eilers | ||
40 | * Bugfixes.. | ||
41 | * | ||
42 | * Revision 1.1 2002/11/09 14:34:52 eilers | ||
43 | * Added VCard Backend. | ||
44 | * | ||
45 | */ | 31 | */ |
46 | #ifndef __OCONTACTACCESSBACKEND_VCARD_H_ | 32 | #ifndef __OCONTACTACCESSBACKEND_VCARD_H_ |
47 | #define __OCONTACTACCESSBACKEND_VCARD_H_ | 33 | #define __OCONTACTACCESSBACKEND_VCARD_H_ |
48 | 34 | ||
49 | #include <opie/ocontact.h> | 35 | #include <opie2/ocontact.h> |
50 | 36 | ||
51 | #include "ocontactaccessbackend.h" | 37 | #include <opie2/ocontactaccessbackend.h> |
52 | 38 | ||
53 | class VObject; | 39 | class VObject; |
54 | 40 | ||
41 | namespace Opie { | ||
55 | /** | 42 | /** |
56 | * This is the vCard 2.1 implementation of the Contact Storage | 43 | * This is the vCard 2.1 implementation of the Contact Storage |
57 | * @see OContactAccessBackend_XML | 44 | * @see OContactAccessBackend_XML |
58 | * @see OPimAccessBackend | 45 | * @see OPimAccessBackend |
59 | */ | 46 | */ |
60 | class OContactAccessBackend_VCard : public OContactAccessBackend { | 47 | class OContactAccessBackend_VCard : public OContactAccessBackend { |
61 | public: | 48 | public: |
62 | OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); | 49 | OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); |
63 | 50 | ||
64 | bool load (); | 51 | bool load (); |
65 | bool reload(); | 52 | bool reload(); |
66 | bool save(); | 53 | bool save(); |
67 | void clear (); | 54 | void clear (); |
68 | 55 | ||
69 | bool add ( const OContact& newcontact ); | 56 | bool add ( const OContact& newcontact ); |
70 | bool remove ( int uid ); | 57 | bool remove ( int uid ); |
71 | bool replace ( const OContact& contact ); | 58 | bool replace ( const OContact& contact ); |
72 | 59 | ||
73 | OContact find ( int uid ) const; | 60 | OContact find ( int uid ) const; |
74 | QArray<int> allRecords() const; | 61 | QArray<int> allRecords() const; |
75 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); | 62 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); |
76 | QArray<int> matchRegexp( const QRegExp &r ) const; | 63 | QArray<int> matchRegexp( const QRegExp &r ) const; |
77 | 64 | ||
78 | const uint querySettings(); | 65 | const uint querySettings(); |
79 | bool hasQuerySettings (uint querySettings) const; | 66 | bool hasQuerySettings (uint querySettings) const; |
80 | QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); | 67 | QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); |
81 | bool wasChangedExternally(); | 68 | bool wasChangedExternally(); |
82 | 69 | ||
83 | private: | 70 | private: |
84 | OContact parseVObject( VObject* obj ); | 71 | OContact parseVObject( VObject* obj ); |
85 | VObject* createVObject( const OContact& c ); | 72 | VObject* createVObject( const OContact& c ); |
86 | QString convDateToVCardDate( const QDate& c ) const; | 73 | QString convDateToVCardDate( const QDate& c ) const; |
87 | QDate convVCardDateToDate( const QString& datestr ); | 74 | QDate convVCardDateToDate( const QString& datestr ); |
88 | VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); | 75 | VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); |
89 | VObject *safeAddProp( VObject* o, const char* prop); | 76 | VObject *safeAddProp( VObject* o, const char* prop); |
90 | 77 | ||
91 | bool m_dirty : 1; | 78 | bool m_dirty : 1; |
92 | QString m_file; | 79 | QString m_file; |
93 | QMap<int, OContact> m_map; | 80 | QMap<int, OContact> m_map; |
94 | }; | 81 | }; |
95 | 82 | ||
83 | } | ||
84 | |||
96 | #endif | 85 | #endif |
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index aae7fca..4c3da0c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -1,150 +1,80 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * XML Backend for the OPIE-Contact Database. | 30 | * XML Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * | ||
13 | * ===================================================================== | ||
14 | * Version: $Id$ | ||
15 | * ===================================================================== | ||
16 | * History: | ||
17 | * $Log$ | ||
18 | * Revision 1.9 2003/09/22 14:31:16 eilers | ||
19 | * Added first experimental incarnation of sql-backend for addressbook. | ||
20 | * Some modifications to be able to compile the todo sql-backend. | ||
21 | * A lot of changes fill follow... | ||
22 | * | ||
23 | * Revision 1.8 2003/08/30 15:28:26 eilers | ||
24 | * Removed some unimportant debug output which causes slow down.. | ||
25 | * | ||
26 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
27 | * Merging changes from BRANCH_1_0 to HEAD | ||
28 | * | ||
29 | * Revision 1.6 2003/07/07 16:19:47 eilers | ||
30 | * Fixing serious bug in hasQuerySettings() | ||
31 | * | ||
32 | * Revision 1.5 2003/04/13 18:07:10 zecke | ||
33 | * More API doc | ||
34 | * QString -> const QString& | ||
35 | * QString = 0l -> QString::null | ||
36 | * | ||
37 | * Revision 1.4 2003/03/21 14:32:54 mickeyl | ||
38 | * g++ compliance fix: default arguments belong into the declaration, but not the definition | ||
39 | * | ||
40 | * Revision 1.3 2003/03/21 12:26:28 eilers | ||
41 | * Fixing small bug: If we search a birthday from today to today, it returned | ||
42 | * every contact .. | ||
43 | * | ||
44 | * Revision 1.2 2003/03/21 10:33:09 eilers | ||
45 | * Merged speed optimized xml backend for contacts to main. | ||
46 | * Added QDateTime to querybyexample. For instance, it is now possible to get | ||
47 | * all Birthdays/Anniversaries between two dates. This should be used | ||
48 | * to show all birthdays in the datebook.. | ||
49 | * This change is sourcecode backward compatible but you have to upgrade | ||
50 | * the binaries for today-addressbook. | ||
51 | * | ||
52 | * Revision 1.1.2.2 2003/02/11 12:17:28 eilers | ||
53 | * Speed optimization. Removed the sequential search loops. | ||
54 | * | ||
55 | * Revision 1.1.2.1 2003/02/10 15:31:38 eilers | ||
56 | * Writing offsets to debug output.. | ||
57 | * | ||
58 | * Revision 1.1 2003/02/09 15:05:01 eilers | ||
59 | * Nothing happened.. Just some cleanup before I will start.. | ||
60 | * | ||
61 | * Revision 1.12 2003/01/03 16:58:03 eilers | ||
62 | * Reenable debug output | ||
63 | * | ||
64 | * Revision 1.11 2003/01/03 12:31:28 eilers | ||
65 | * Bugfix for calculating data diffs.. | ||
66 | * | ||
67 | * Revision 1.10 2003/01/02 14:27:12 eilers | ||
68 | * Improved query by example: Search by date is possible.. First step | ||
69 | * for a today plugin for birthdays.. | ||
70 | * | ||
71 | * Revision 1.9 2002/12/08 12:48:57 eilers | ||
72 | * Moved journal-enum from ocontact into i the xml-backend.. | ||
73 | * | ||
74 | * Revision 1.8 2002/11/14 17:04:24 eilers | ||
75 | * Sorting will now work if fullname is identical on some entries | ||
76 | * | ||
77 | * Revision 1.7 2002/11/13 15:02:46 eilers | ||
78 | * Small Bug in sorted fixed | ||
79 | * | ||
80 | * Revision 1.6 2002/11/13 14:14:51 eilers | ||
81 | * Added sorted for Contacts.. | ||
82 | * | ||
83 | * Revision 1.5 2002/11/01 15:10:42 eilers | ||
84 | * Added regExp-search in database for all fields in a contact. | ||
85 | * | ||
86 | * Revision 1.4 2002/10/16 10:52:40 eilers | ||
87 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
88 | * | ||
89 | * Revision 1.3 2002/10/14 16:21:54 eilers | ||
90 | * Some minor interface updates | ||
91 | * | ||
92 | * Revision 1.2 2002/10/07 17:34:24 eilers | ||
93 | * added OBackendFactory for advanced backend access | ||
94 | * | ||
95 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
96 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
97 | * please do not expect that anything is working ! | ||
98 | * I will debug that stuff in the next time .. | ||
99 | * Please read README_COMPILE for compiling ! | ||
100 | * | ||
101 | * | ||
102 | */ | 31 | */ |
103 | 32 | ||
104 | #include "ocontactaccessbackend_xml.h" | 33 | #include <opie2/ocontactaccessbackend_xml.h> |
105 | 34 | ||
106 | #include <qasciidict.h> | 35 | #include <qasciidict.h> |
107 | #include <qdatetime.h> | 36 | #include <qdatetime.h> |
108 | #include <qfile.h> | 37 | #include <qfile.h> |
109 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
110 | #include <qregexp.h> | 39 | #include <qregexp.h> |
111 | #include <qarray.h> | 40 | #include <qarray.h> |
112 | #include <qmap.h> | 41 | #include <qmap.h> |
113 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
114 | 43 | ||
115 | #include <qpe/global.h> | 44 | #include <qpe/global.h> |
116 | 45 | ||
117 | #include <opie/xmltree.h> | 46 | #include <opie/xmltree.h> |
118 | #include "ocontactaccessbackend.h" | 47 | #include <opie2/ocontactaccessbackend.h> |
119 | #include "ocontactaccess.h" | 48 | #include <opie2/ocontactaccess.h> |
120 | 49 | ||
121 | #include <stdlib.h> | 50 | #include <stdlib.h> |
122 | #include <errno.h> | 51 | #include <errno.h> |
123 | 52 | ||
124 | using namespace Opie; | 53 | using namespace Opie; |
125 | 54 | ||
126 | 55 | ||
56 | namespace Opie { | ||
127 | OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): | 57 | OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): |
128 | m_changed( false ) | 58 | m_changed( false ) |
129 | { | 59 | { |
130 | // Just m_contactlist should call delete if an entry | 60 | // Just m_contactlist should call delete if an entry |
131 | // is removed. | 61 | // is removed. |
132 | m_contactList.setAutoDelete( true ); | 62 | m_contactList.setAutoDelete( true ); |
133 | m_uidToContact.setAutoDelete( false ); | 63 | m_uidToContact.setAutoDelete( false ); |
134 | 64 | ||
135 | m_appName = appname; | 65 | m_appName = appname; |
136 | 66 | ||
137 | /* Set journalfile name ... */ | 67 | /* Set journalfile name ... */ |
138 | m_journalName = getenv("HOME"); | 68 | m_journalName = getenv("HOME"); |
139 | m_journalName +="/.abjournal" + appname; | 69 | m_journalName +="/.abjournal" + appname; |
140 | 70 | ||
141 | /* Expecting to access the default filename if nothing else is set */ | 71 | /* Expecting to access the default filename if nothing else is set */ |
142 | if ( filename.isEmpty() ){ | 72 | if ( filename.isEmpty() ){ |
143 | m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); | 73 | m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); |
144 | } else | 74 | } else |
145 | m_fileName = filename; | 75 | m_fileName = filename; |
146 | 76 | ||
147 | /* Load Database now */ | 77 | /* Load Database now */ |
148 | load (); | 78 | load (); |
149 | } | 79 | } |
150 | 80 | ||
@@ -797,24 +727,25 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt, | |||
797 | // 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 |
798 | // get a XML-File which is readable by our parser. | 728 | // get a XML-File which is readable by our parser. |
799 | // This is just a cheat, but better than rewrite the parser. | 729 | // This is just a cheat, but better than rewrite the parser. |
800 | if ( created ){ | 730 | if ( created ){ |
801 | buf = "<Contacts>"; | 731 | buf = "<Contacts>"; |
802 | QCString cstr = buf.utf8(); | 732 | QCString cstr = buf.utf8(); |
803 | f.writeBlock( cstr.data(), cstr.length() ); | 733 | f.writeBlock( cstr.data(), cstr.length() ); |
804 | } | 734 | } |
805 | 735 | ||
806 | buf = "<Contact "; | 736 | buf = "<Contact "; |
807 | cnt.save( buf ); | 737 | cnt.save( buf ); |
808 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | 738 | buf += " action=\"" + QString::number( (int)action ) + "\" "; |
809 | buf += "/>\n"; | 739 | buf += "/>\n"; |
810 | QCString cstr = buf.utf8(); | 740 | QCString cstr = buf.utf8(); |
811 | f.writeBlock( cstr.data(), cstr.length() ); | 741 | f.writeBlock( cstr.data(), cstr.length() ); |
812 | } | 742 | } |
813 | 743 | ||
814 | void OContactAccessBackend_XML::removeJournal() | 744 | void OContactAccessBackend_XML::removeJournal() |
815 | { | 745 | { |
816 | QFile f ( m_journalName ); | 746 | QFile f ( m_journalName ); |
817 | if ( f.exists() ) | 747 | if ( f.exists() ) |
818 | f.remove(); | 748 | f.remove(); |
819 | } | 749 | } |
820 | 750 | ||
751 | } | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h index a0cae4d..f439c4c 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h | |||
@@ -1,120 +1,66 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * XML Backend for the OPIE-Contact Database. | 30 | * XML Backend for the OPIE-Contact Database. |
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * ToDo: XML-Backend: Automatic reload if something was changed... | ||
13 | * File Locking to protect against concurrent access | ||
14 | * | ||
15 | * | ||
16 | * ===================================================================== | ||
17 | * Version: $Id$ | ||
18 | * ===================================================================== | ||
19 | * History: | ||
20 | * $Log$ | ||
21 | * Revision 1.15 2003/09/22 14:31:16 eilers | ||
22 | * Added first experimental incarnation of sql-backend for addressbook. | ||
23 | * Some modifications to be able to compile the todo sql-backend. | ||
24 | * A lot of changes fill follow... | ||
25 | * | ||
26 | * Revision 1.14 2003/04/13 18:07:10 zecke | ||
27 | * More API doc | ||
28 | * QString -> const QString& | ||
29 | * QString = 0l -> QString::null | ||
30 | * | ||
31 | * Revision 1.13 2003/03/21 10:33:09 eilers | ||
32 | * Merged speed optimized xml backend for contacts to main. | ||
33 | * Added QDateTime to querybyexample. For instance, it is now possible to get | ||
34 | * all Birthdays/Anniversaries between two dates. This should be used | ||
35 | * to show all birthdays in the datebook.. | ||
36 | * This change is sourcecode backward compatible but you have to upgrade | ||
37 | * the binaries for today-addressbook. | ||
38 | * | ||
39 | * Revision 1.12.2.2 2003/02/11 12:17:28 eilers | ||
40 | * Speed optimization. Removed the sequential search loops. | ||
41 | * | ||
42 | * Revision 1.12.2.1 2003/02/09 15:05:01 eilers | ||
43 | * Nothing happened.. Just some cleanup before I will start.. | ||
44 | * | ||
45 | * Revision 1.12 2003/01/03 16:58:03 eilers | ||
46 | * Reenable debug output | ||
47 | * | ||
48 | * Revision 1.11 2003/01/03 12:31:28 eilers | ||
49 | * Bugfix for calculating data diffs.. | ||
50 | * | ||
51 | * Revision 1.10 2003/01/02 14:27:12 eilers | ||
52 | * Improved query by example: Search by date is possible.. First step | ||
53 | * for a today plugin for birthdays.. | ||
54 | * | ||
55 | * Revision 1.9 2002/12/08 12:48:57 eilers | ||
56 | * Moved journal-enum from ocontact into i the xml-backend.. | ||
57 | * | ||
58 | * Revision 1.8 2002/11/14 17:04:24 eilers | ||
59 | * Sorting will now work if fullname is identical on some entries | ||
60 | * | ||
61 | * Revision 1.7 2002/11/13 15:02:46 eilers | ||
62 | * Small Bug in sorted fixed | ||
63 | * | ||
64 | * Revision 1.6 2002/11/13 14:14:51 eilers | ||
65 | * Added sorted for Contacts.. | ||
66 | * | ||
67 | * Revision 1.5 2002/11/01 15:10:42 eilers | ||
68 | * Added regExp-search in database for all fields in a contact. | ||
69 | * | ||
70 | * Revision 1.4 2002/10/16 10:52:40 eilers | ||
71 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
72 | * | ||
73 | * Revision 1.3 2002/10/14 16:21:54 eilers | ||
74 | * Some minor interface updates | ||
75 | * | ||
76 | * Revision 1.2 2002/10/07 17:34:24 eilers | ||
77 | * added OBackendFactory for advanced backend access | ||
78 | * | ||
79 | * Revision 1.1 2002/09/27 17:11:44 eilers | ||
80 | * Added API for accessing the Contact-Database ! It is compiling, but | ||
81 | * please do not expect that anything is working ! | ||
82 | * I will debug that stuff in the next time .. | ||
83 | * Please read README_COMPILE for compiling ! | ||
84 | * | ||
85 | * | ||
86 | */ | 31 | */ |
87 | 32 | ||
88 | #ifndef _OContactAccessBackend_XML_ | 33 | #ifndef _OContactAccessBackend_XML_ |
89 | #define _OContactAccessBackend_XML_ | 34 | #define _OContactAccessBackend_XML_ |
90 | 35 | ||
91 | #include "ocontactaccessbackend.h" | 36 | #include <opie2/ocontactaccessbackend.h> |
92 | #include "ocontactaccess.h" | 37 | #include <opie2/ocontactaccess.h> |
93 | 38 | ||
94 | #include <qlist.h> | 39 | #include <qlist.h> |
95 | #include <qdict.h> | 40 | #include <qdict.h> |
96 | 41 | ||
42 | namespace Opie { | ||
97 | /* the default xml implementation */ | 43 | /* the default xml implementation */ |
98 | /** | 44 | /** |
99 | * This class is the XML implementation of a Contact backend | 45 | * This class is the XML implementation of a Contact backend |
100 | * it does implement everything available for OContact. | 46 | * it does implement everything available for OContact. |
101 | * @see OPimAccessBackend for more information of available methods | 47 | * @see OPimAccessBackend for more information of available methods |
102 | */ | 48 | */ |
103 | class OContactAccessBackend_XML : public OContactAccessBackend { | 49 | class OContactAccessBackend_XML : public OContactAccessBackend { |
104 | public: | 50 | public: |
105 | OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); | 51 | OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); |
106 | 52 | ||
107 | bool save(); | 53 | bool save(); |
108 | 54 | ||
109 | bool load (); | 55 | bool load (); |
110 | 56 | ||
111 | void clear (); | 57 | void clear (); |
112 | 58 | ||
113 | bool wasChangedExternally(); | 59 | bool wasChangedExternally(); |
114 | 60 | ||
115 | QArray<int> allRecords() const; | 61 | QArray<int> allRecords() const; |
116 | 62 | ||
117 | OContact find ( int uid ) const; | 63 | OContact find ( int uid ) const; |
118 | 64 | ||
119 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); | 65 | QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); |
120 | 66 | ||
@@ -136,25 +82,27 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
136 | private: | 82 | private: |
137 | 83 | ||
138 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | 84 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; |
139 | 85 | ||
140 | void addContact_p( const OContact &newcontact ); | 86 | void addContact_p( const OContact &newcontact ); |
141 | 87 | ||
142 | /* This function loads the xml-database and the journalfile */ | 88 | /* This function loads the xml-database and the journalfile */ |
143 | bool load( const QString filename, bool isJournal ); | 89 | bool load( const QString filename, bool isJournal ); |
144 | 90 | ||
145 | 91 | ||
146 | void updateJournal( const OContact& cnt, journal_action action ); | 92 | void updateJournal( const OContact& cnt, journal_action action ); |
147 | void removeJournal(); | 93 | void removeJournal(); |
148 | 94 | ||
149 | protected: | 95 | protected: |
150 | bool m_changed; | 96 | bool m_changed; |
151 | QString m_journalName; | 97 | QString m_journalName; |
152 | QString m_fileName; | 98 | QString m_fileName; |
153 | QString m_appName; | 99 | QString m_appName; |
154 | QList<OContact> m_contactList; | 100 | QList<OContact> m_contactList; |
155 | QDateTime m_readtime; | 101 | QDateTime m_readtime; |
156 | 102 | ||
157 | QDict<OContact> m_uidToContact; | 103 | QDict<OContact> m_uidToContact; |
158 | }; | 104 | }; |
159 | 105 | ||
106 | } | ||
107 | |||
160 | #endif | 108 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp index f0c5d65..9bf4bf0 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp | |||
@@ -1,29 +1,59 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <qtl.h> | 29 | #include <qtl.h> |
2 | 30 | ||
3 | #include "orecur.h" | 31 | #include <opie2/orecur.h> |
4 | 32 | ||
5 | #include "odatebookaccessbackend.h" | 33 | #include <opie2/odatebookaccessbackend.h> |
34 | |||
35 | using namespace Opie; | ||
6 | 36 | ||
7 | namespace { | 37 | namespace { |
8 | /* 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 */ |
9 | void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, | 39 | void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events, |
10 | const QDate& from, const QDate& to ) { | 40 | const QDate& from, const QDate& to ) { |
11 | QDateTime dtStart, dtEnd; | 41 | QDateTime dtStart, dtEnd; |
12 | 42 | ||
13 | for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { | 43 | for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) { |
14 | dtStart = (*it).startDateTime(); | 44 | dtStart = (*it).startDateTime(); |
15 | dtEnd = (*it).endDateTime(); | 45 | dtEnd = (*it).endDateTime(); |
16 | 46 | ||
17 | /* | 47 | /* |
18 | * If in range | 48 | * If in range |
19 | */ | 49 | */ |
20 | if (dtStart.date() >= from && dtEnd.date() <= to ) { | 50 | if (dtStart.date() >= from && dtEnd.date() <= to ) { |
21 | OEffectiveEvent eff; | 51 | OEffectiveEvent eff; |
22 | eff.setEvent( (*it) ); | 52 | eff.setEvent( (*it) ); |
23 | eff.setDate( dtStart.date() ); | 53 | eff.setDate( dtStart.date() ); |
24 | eff.setStartTime( dtStart.time() ); | 54 | eff.setStartTime( dtStart.time() ); |
25 | 55 | ||
26 | /* if not on the same day */ | 56 | /* if not on the same day */ |
27 | if ( dtStart.date() != dtEnd.date() ) | 57 | if ( dtStart.date() != dtEnd.date() ) |
28 | eff.setEndTime( QTime(23, 59, 0 ) ); | 58 | eff.setEndTime( QTime(23, 59, 0 ) ); |
29 | else | 59 | else |
@@ -98,48 +128,50 @@ namespace { | |||
98 | OEffectiveEvent tmpEff = eff; | 128 | OEffectiveEvent tmpEff = eff; |
99 | tmpEff.setEvent( (*it) ); | 129 | tmpEff.setEvent( (*it) ); |
100 | if ( sub_it != startDate ) | 130 | if ( sub_it != startDate ) |
101 | tmpEff.setStartTime( QTime(0, 0, 0 ) ); | 131 | tmpEff.setStartTime( QTime(0, 0, 0 ) ); |
102 | if ( sub_it != endDate ) | 132 | if ( sub_it != endDate ) |
103 | tmpEff.setEndTime( QTime( 23, 59, 59 ) ); | 133 | tmpEff.setEndTime( QTime( 23, 59, 59 ) ); |
104 | 134 | ||
105 | tmpEff.setDate( sub_it ); | 135 | tmpEff.setDate( sub_it ); |
106 | tmpEff.setEffectiveDates( startDate, endDate ); | 136 | tmpEff.setEffectiveDates( startDate, endDate ); |
107 | tmpList.append( tmpEff ); | 137 | tmpList.append( tmpEff ); |
108 | 138 | ||
109 | sub_it = sub_it.addDays( 1 ); | 139 | sub_it = sub_it.addDays( 1 ); |
110 | } | 140 | } |
111 | itDate = endDate; | 141 | itDate = endDate; |
112 | }else { | 142 | }else { |
113 | eff.setEvent( (*it) ); | 143 | eff.setEvent( (*it) ); |
114 | tmpList.append( eff ); | 144 | tmpList.append( eff ); |
115 | itDate = repeat.addDays( 1 ); | 145 | itDate = repeat.addDays( 1 ); |
116 | } | 146 | } |
117 | } | 147 | } |
118 | } | 148 | } |
119 | } | 149 | } |
120 | } | 150 | } |
121 | 151 | ||
152 | namespace Opie { | ||
153 | |||
122 | ODateBookAccessBackend::ODateBookAccessBackend() | 154 | ODateBookAccessBackend::ODateBookAccessBackend() |
123 | : OPimAccessBackend<OEvent>() | 155 | : OPimAccessBackend<OEvent>() |
124 | { | 156 | { |
125 | 157 | ||
126 | } | 158 | } |
127 | ODateBookAccessBackend::~ODateBookAccessBackend() { | 159 | ODateBookAccessBackend::~ODateBookAccessBackend() { |
128 | 160 | ||
129 | } | 161 | } |
130 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, | 162 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from, |
131 | const QDate& to ) { | 163 | const QDate& to ) { |
132 | OEffectiveEvent::ValueList tmpList; | 164 | OEffectiveEvent::ValueList tmpList; |
133 | OEvent::ValueList list = directNonRepeats(); | 165 | OEvent::ValueList list = directNonRepeats(); |
134 | 166 | ||
135 | events( tmpList, list, from, to ); | 167 | events( tmpList, list, from, to ); |
136 | repeat( tmpList, directRawRepeats(),from,to ); | 168 | repeat( tmpList, directRawRepeats(),from,to ); |
137 | 169 | ||
138 | list = directRawRepeats(); // Useless, isn't it ? (eilers) | 170 | list = directRawRepeats(); // Useless, isn't it ? (eilers) |
139 | 171 | ||
140 | qHeapSort( tmpList ); | 172 | qHeapSort( tmpList ); |
141 | return tmpList; | 173 | return tmpList; |
142 | } | 174 | } |
143 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { | 175 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) { |
144 | OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); | 176 | OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() ); |
145 | OEffectiveEvent::ValueList::Iterator it; | 177 | OEffectiveEvent::ValueList::Iterator it; |
@@ -159,24 +191,26 @@ OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( | |||
159 | const QDate& to ) { | 191 | const QDate& to ) { |
160 | OEffectiveEvent::ValueList tmpList; | 192 | OEffectiveEvent::ValueList tmpList; |
161 | OEvent::ValueList list = directNonRepeats(); | 193 | OEvent::ValueList list = directNonRepeats(); |
162 | 194 | ||
163 | events( tmpList, list, from, to ); | 195 | events( tmpList, list, from, to ); |
164 | 196 | ||
165 | qHeapSort( tmpList ); | 197 | qHeapSort( tmpList ); |
166 | return tmpList; | 198 | return tmpList; |
167 | } | 199 | } |
168 | 200 | ||
169 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { | 201 | OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) { |
170 | OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); | 202 | OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() ); |
171 | OEffectiveEvent::ValueList::Iterator it; | 203 | OEffectiveEvent::ValueList::Iterator it; |
172 | 204 | ||
173 | OEffectiveEvent::ValueList tmpList; | 205 | OEffectiveEvent::ValueList tmpList; |
174 | QDateTime dtTmp; | 206 | QDateTime dtTmp; |
175 | for ( it = day.begin(); it != day.end(); ++it ) { | 207 | for ( it = day.begin(); it != day.end(); ++it ) { |
176 | dtTmp = QDateTime( (*it).date(), (*it).startTime() ); | 208 | dtTmp = QDateTime( (*it).date(), (*it).startTime() ); |
177 | if ( QABS(dt.secsTo(dtTmp) ) < 60 ) | 209 | if ( QABS(dt.secsTo(dtTmp) ) < 60 ) |
178 | tmpList.append( (*it) ); | 210 | tmpList.append( (*it) ); |
179 | } | 211 | } |
180 | 212 | ||
181 | return tmpList; | 213 | return tmpList; |
182 | } | 214 | } |
215 | |||
216 | } | ||
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h index 3472ab3..6853670 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend.h | |||
@@ -1,32 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H | 30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_H |
3 | 31 | ||
4 | #include <qarray.h> | 32 | #include <qarray.h> |
5 | 33 | ||
6 | #include "opimaccessbackend.h" | 34 | #include <opie2/opimaccessbackend.h> |
7 | #include "oevent.h" | 35 | #include <opie2/oevent.h> |
8 | 36 | ||
37 | namespace Opie { | ||
9 | /** | 38 | /** |
10 | * This class is the interface to the storage of Events. | 39 | * This class is the interface to the storage of Events. |
11 | * @see OPimAccessBackend | 40 | * @see OPimAccessBackend |
12 | * | 41 | * |
13 | */ | 42 | */ |
14 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { | 43 | class ODateBookAccessBackend : public OPimAccessBackend<OEvent> { |
15 | public: | 44 | public: |
16 | typedef int UID; | 45 | typedef int UID; |
17 | 46 | ||
18 | /** | 47 | /** |
19 | * c'tor without parameter | 48 | * c'tor without parameter |
20 | */ | 49 | */ |
21 | ODateBookAccessBackend(); | 50 | ODateBookAccessBackend(); |
22 | ~ODateBookAccessBackend(); | 51 | ~ODateBookAccessBackend(); |
23 | 52 | ||
24 | /** | 53 | /** |
25 | * This method should return a list of UIDs containing | 54 | * This method should return a list of UIDs containing |
26 | * all events. No filter should be applied | 55 | * all events. No filter should be applied |
27 | * @return list of events | 56 | * @return list of events |
28 | */ | 57 | */ |
29 | virtual QArray<UID> rawEvents()const = 0; | 58 | virtual QArray<UID> rawEvents()const = 0; |
30 | 59 | ||
31 | /** | 60 | /** |
32 | * This method should return a list of UIDs containing | 61 | * This method should return a list of UIDs containing |
@@ -66,25 +95,27 @@ public: | |||
66 | * this is an overloaded member function | 95 | * this is an overloaded member function |
67 | * @see effectiveEvents( const QDate& from, const QDate& to ) | 96 | * @see effectiveEvents( const QDate& from, const QDate& to ) |
68 | */ | 97 | */ |
69 | virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ); | 98 | virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ); |
70 | 99 | ||
71 | /** | 100 | /** |
72 | * 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 |
73 | * 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 |
74 | * yourself | 103 | * yourself |
75 | */ | 104 | */ |
76 | virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ); | 105 | virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ); |
77 | 106 | ||
78 | /** | 107 | /** |
79 | * this is an overloaded member function | 108 | * this is an overloaded member function |
80 | * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) | 109 | * @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) |
81 | */ | 110 | */ |
82 | virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ); | 111 | virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ); |
83 | 112 | ||
84 | private: | 113 | private: |
85 | class Private; | 114 | class Private; |
86 | Private *d; | 115 | Private *d; |
87 | 116 | ||
88 | }; | 117 | }; |
89 | 118 | ||
119 | } | ||
120 | |||
90 | #endif | 121 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp index 756f405..e79696c 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp | |||
@@ -1,76 +1,73 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | /* | ||
2 | * SQL Backend for the OPIE-Calender Database. | 30 | * SQL Backend for the OPIE-Calender Database. |
3 | * | 31 | * |
4 | * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2 of the License, or (at your option) any later version. | ||
11 | * ===================================================================== | ||
12 | * ===================================================================== | ||
13 | * Version: $Id$ | ||
14 | * ===================================================================== | ||
15 | * History: | ||
16 | * $Log$ | ||
17 | * Revision 1.3 2003/12/22 11:41:39 eilers | ||
18 | * Fixing stupid bug, found by sourcode review.. | ||
19 | * | ||
20 | * Revision 1.2 2003/12/22 10:19:26 eilers | ||
21 | * Finishing implementation of sql-backend for datebook. But I have to | ||
22 | * port the PIM datebook application to use it, before I could debug the | ||
23 | * whole stuff. | ||
24 | * Thus, PIM-Database backend is finished, but highly experimental. And some | ||
25 | * parts are still generic. For instance, the "queryByExample()" methods are | ||
26 | * not (or not fully) implemented. Todo: custom-entries not stored. | ||
27 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | ||
28 | * expression search in the database, which is not supported by sqlite ! | ||
29 | * Therefore we need either an extended sqlite or a workaround which would | ||
30 | * be very slow and memory consuming.. | ||
31 | * | ||
32 | * Revision 1.1 2003/12/08 15:18:12 eilers | ||
33 | * Committing unfinished sql implementation before merging to libopie2 starts.. | ||
34 | * | ||
35 | * | ||
36 | */ | 32 | */ |
37 | 33 | ||
38 | #include <stdio.h> | 34 | #include <stdio.h> |
39 | #include <stdlib.h> | 35 | #include <stdlib.h> |
40 | 36 | ||
41 | #include <qarray.h> | 37 | #include <qarray.h> |
42 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
43 | 39 | ||
44 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
45 | 41 | ||
46 | #include <opie2/osqldriver.h> | 42 | #include <opie2/osqldriver.h> |
47 | #include <opie2/osqlmanager.h> | 43 | #include <opie2/osqlmanager.h> |
48 | #include <opie2/osqlquery.h> | 44 | #include <opie2/osqlquery.h> |
49 | 45 | ||
50 | #include "orecur.h" | 46 | #include <opie2/orecur.h> |
51 | #include "odatebookaccessbackend_sql.h" | 47 | #include <opie2/odatebookaccessbackend_sql.h> |
52 | 48 | ||
49 | namespace Opie { | ||
53 | 50 | ||
54 | 51 | ||
55 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , | 52 | ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , |
56 | const QString& fileName ) | 53 | const QString& fileName ) |
57 | : ODateBookAccessBackend(), m_driver( NULL ) | 54 | : ODateBookAccessBackend(), m_driver( NULL ) |
58 | { | 55 | { |
59 | m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; | 56 | m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; |
60 | 57 | ||
61 | // Get the standart sql-driver from the OSQLManager.. | 58 | // Get the standart sql-driver from the OSQLManager.. |
62 | OSQLManager man; | 59 | OSQLManager man; |
63 | m_driver = man.standard(); | 60 | m_driver = man.standard(); |
64 | m_driver->setUrl( m_fileName ); | 61 | m_driver->setUrl( m_fileName ); |
65 | 62 | ||
66 | initFields(); | 63 | initFields(); |
67 | 64 | ||
68 | load(); | 65 | load(); |
69 | } | 66 | } |
70 | 67 | ||
71 | ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { | 68 | ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { |
72 | if( m_driver ) | 69 | if( m_driver ) |
73 | delete m_driver; | 70 | delete m_driver; |
74 | } | 71 | } |
75 | 72 | ||
76 | void ODateBookAccessBackend_SQL::initFields() | 73 | void ODateBookAccessBackend_SQL::initFields() |
@@ -344,24 +341,26 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const | |||
344 | } | 341 | } |
345 | 342 | ||
346 | /* ===== Private Functions ========================================== */ | 343 | /* ===== Private Functions ========================================== */ |
347 | 344 | ||
348 | QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const | 345 | QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const |
349 | { | 346 | { |
350 | qWarning("extractUids"); | 347 | qWarning("extractUids"); |
351 | QTime t; | 348 | QTime t; |
352 | t.start(); | 349 | t.start(); |
353 | OSQLResultItem::ValueList list = res.results(); | 350 | OSQLResultItem::ValueList list = res.results(); |
354 | OSQLResultItem::ValueList::Iterator it; | 351 | OSQLResultItem::ValueList::Iterator it; |
355 | QArray<int> ints(list.count() ); | 352 | QArray<int> ints(list.count() ); |
356 | qWarning(" count = %d", list.count() ); | 353 | qWarning(" count = %d", list.count() ); |
357 | 354 | ||
358 | int i = 0; | 355 | int i = 0; |
359 | for (it = list.begin(); it != list.end(); ++it ) { | 356 | for (it = list.begin(); it != list.end(); ++it ) { |
360 | ints[i] = (*it).data("uid").toInt(); | 357 | ints[i] = (*it).data("uid").toInt(); |
361 | i++; | 358 | i++; |
362 | } | 359 | } |
363 | qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); | 360 | qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); |
364 | 361 | ||
365 | return ints; | 362 | return ints; |
366 | 363 | ||
367 | } | 364 | } |
365 | |||
366 | } | ||
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h index f39e154..89939ef 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h | |||
@@ -1,34 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H | 30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H |
3 | 31 | ||
4 | #include <qmap.h> | 32 | #include <qmap.h> |
5 | #include <opie2/osqlresult.h> | 33 | #include <opie2/osqlresult.h> |
6 | 34 | ||
7 | #include "odatebookaccessbackend.h" | 35 | #include <opie2/odatebookaccessbackend.h> |
8 | 36 | ||
9 | class OSQLDriver; | 37 | class OSQLDriver; |
10 | 38 | ||
39 | namespace Opie { | ||
11 | /** | 40 | /** |
12 | * This is the default SQL implementation for DateBoook SQL storage | 41 | * This is the default SQL implementation for DateBoook SQL storage |
13 | * It fully implements the interface | 42 | * It fully implements the interface |
14 | * @see ODateBookAccessBackend | 43 | * @see ODateBookAccessBackend |
15 | * @see OPimAccessBackend | 44 | * @see OPimAccessBackend |
16 | */ | 45 | */ |
17 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { | 46 | class ODateBookAccessBackend_SQL : public ODateBookAccessBackend { |
18 | public: | 47 | public: |
19 | ODateBookAccessBackend_SQL( const QString& appName, | 48 | ODateBookAccessBackend_SQL( const QString& appName, |
20 | const QString& fileName = QString::null); | 49 | const QString& fileName = QString::null); |
21 | ~ODateBookAccessBackend_SQL(); | 50 | ~ODateBookAccessBackend_SQL(); |
22 | 51 | ||
23 | bool load(); | 52 | bool load(); |
24 | bool reload(); | 53 | bool reload(); |
25 | bool save(); | 54 | bool save(); |
26 | 55 | ||
27 | QArray<int> allRecords()const; | 56 | QArray<int> allRecords()const; |
28 | QArray<int> matchRegexp(const QRegExp &r) const; | 57 | QArray<int> matchRegexp(const QRegExp &r) const; |
29 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 58 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); |
30 | OEvent find( int uid )const; | 59 | OEvent find( int uid )const; |
31 | void clear(); | 60 | void clear(); |
32 | bool add( const OEvent& ev ); | 61 | bool add( const OEvent& ev ); |
33 | bool remove( int uid ); | 62 | bool remove( int uid ); |
34 | bool replace( const OEvent& ev ); | 63 | bool replace( const OEvent& ev ); |
@@ -38,25 +67,27 @@ public: | |||
38 | QArray<UID> nonRepeats()const; | 67 | QArray<UID> nonRepeats()const; |
39 | 68 | ||
40 | OEvent::ValueList directNonRepeats(); | 69 | OEvent::ValueList directNonRepeats(); |
41 | OEvent::ValueList directRawRepeats(); | 70 | OEvent::ValueList directRawRepeats(); |
42 | 71 | ||
43 | private: | 72 | private: |
44 | bool loadFile(); | 73 | bool loadFile(); |
45 | QString m_fileName; | 74 | QString m_fileName; |
46 | QArray<int> m_uids; | 75 | QArray<int> m_uids; |
47 | 76 | ||
48 | QMap<int, QString> m_fieldMap; | 77 | QMap<int, QString> m_fieldMap; |
49 | QMap<QString, int> m_reverseFieldMap; | 78 | QMap<QString, int> m_reverseFieldMap; |
50 | 79 | ||
51 | OSQLDriver* m_driver; | 80 | OSQLDriver* m_driver; |
52 | 81 | ||
53 | class Private; | 82 | class Private; |
54 | Private *d; | 83 | Private *d; |
55 | 84 | ||
56 | void initFields(); | 85 | void initFields(); |
57 | void update(); | 86 | void update(); |
58 | QArray<int> extractUids( OSQLResult& res ) const; | 87 | QArray<int> extractUids( OSQLResult& res ) const; |
59 | 88 | ||
60 | }; | 89 | }; |
61 | 90 | ||
91 | } | ||
92 | |||
62 | #endif | 93 | #endif |
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp index 929d004..0ebda98 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp | |||
@@ -1,47 +1,77 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <errno.h> | 29 | #include <errno.h> |
2 | #include <fcntl.h> | 30 | #include <fcntl.h> |
3 | 31 | ||
4 | #include <stdio.h> | 32 | #include <stdio.h> |
5 | #include <stdlib.h> | 33 | #include <stdlib.h> |
6 | 34 | ||
7 | #include <sys/types.h> | 35 | #include <sys/types.h> |
8 | #include <sys/mman.h> | 36 | #include <sys/mman.h> |
9 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
10 | 38 | ||
11 | #include <unistd.h> | 39 | #include <unistd.h> |
12 | 40 | ||
13 | #include <qasciidict.h> | 41 | #include <qasciidict.h> |
14 | #include <qfile.h> | 42 | #include <qfile.h> |
15 | 43 | ||
16 | #include <qtopia/global.h> | 44 | #include <qtopia/global.h> |
17 | #include <qtopia/stringutil.h> | 45 | #include <qtopia/stringutil.h> |
18 | #include <qtopia/timeconversion.h> | 46 | #include <qtopia/timeconversion.h> |
19 | 47 | ||
20 | #include "opimnotifymanager.h" | 48 | #include <opie2/opimnotifymanager.h> |
21 | #include "orecur.h" | 49 | #include <opie2/orecur.h> |
22 | #include "otimezone.h" | 50 | #include <opie2/otimezone.h> |
23 | #include "odatebookaccessbackend_xml.h" | 51 | #include <opie2/odatebookaccessbackend_xml.h> |
52 | |||
53 | using namespace Opie; | ||
24 | 54 | ||
25 | namespace { | 55 | namespace { |
26 | // FROM TT again | 56 | // FROM TT again |
27 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 57 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
28 | { | 58 | { |
29 | char needleChar; | 59 | char needleChar; |
30 | char haystackChar; | 60 | char haystackChar; |
31 | if (!needle || !haystack || !hLen || !nLen) | 61 | if (!needle || !haystack || !hLen || !nLen) |
32 | return 0; | 62 | return 0; |
33 | 63 | ||
34 | const char* hsearch = haystack; | 64 | const char* hsearch = haystack; |
35 | 65 | ||
36 | if ((needleChar = *needle++) != 0) { | 66 | if ((needleChar = *needle++) != 0) { |
37 | nLen--; //(to make up for needle++) | 67 | nLen--; //(to make up for needle++) |
38 | do { | 68 | do { |
39 | do { | 69 | do { |
40 | if ((haystackChar = *hsearch++) == 0) | 70 | if ((haystackChar = *hsearch++) == 0) |
41 | return (0); | 71 | return (0); |
42 | if (hsearch >= haystack + hLen) | 72 | if (hsearch >= haystack + hLen) |
43 | return (0); | 73 | return (0); |
44 | } while (haystackChar != needleChar); | 74 | } while (haystackChar != needleChar); |
45 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 75 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
46 | hsearch--; | 76 | hsearch--; |
47 | } | 77 | } |
@@ -145,48 +175,49 @@ namespace { | |||
145 | } | 175 | } |
146 | 176 | ||
147 | // skip custom writing | 177 | // skip custom writing |
148 | } | 178 | } |
149 | 179 | ||
150 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { | 180 | inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) { |
151 | QMap<int, OEvent>::ConstIterator it; | 181 | QMap<int, OEvent>::ConstIterator it; |
152 | QString buf; | 182 | QString buf; |
153 | QCString str; | 183 | QCString str; |
154 | int total_written; | 184 | int total_written; |
155 | for ( it = list.begin(); it != list.end(); ++it ) { | 185 | for ( it = list.begin(); it != list.end(); ++it ) { |
156 | buf = "<event"; | 186 | buf = "<event"; |
157 | save( it.data(), buf ); | 187 | save( it.data(), buf ); |
158 | buf += " />\n"; | 188 | buf += " />\n"; |
159 | str = buf.utf8(); | 189 | str = buf.utf8(); |
160 | 190 | ||
161 | total_written = file.writeBlock(str.data(), str.length() ); | 191 | total_written = file.writeBlock(str.data(), str.length() ); |
162 | if ( total_written != int(str.length() ) ) | 192 | if ( total_written != int(str.length() ) ) |
163 | return false; | 193 | return false; |
164 | } | 194 | } |
165 | return true; | 195 | return true; |
166 | } | 196 | } |
167 | } | 197 | } |
168 | 198 | ||
199 | namespace Opie { | ||
169 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , | 200 | ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , |
170 | const QString& fileName ) | 201 | const QString& fileName ) |
171 | : ODateBookAccessBackend() { | 202 | : ODateBookAccessBackend() { |
172 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; | 203 | m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; |
173 | m_changed = false; | 204 | m_changed = false; |
174 | } | 205 | } |
175 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { | 206 | ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { |
176 | } | 207 | } |
177 | bool ODateBookAccessBackend_XML::load() { | 208 | bool ODateBookAccessBackend_XML::load() { |
178 | return loadFile(); | 209 | return loadFile(); |
179 | } | 210 | } |
180 | bool ODateBookAccessBackend_XML::reload() { | 211 | bool ODateBookAccessBackend_XML::reload() { |
181 | clear(); | 212 | clear(); |
182 | return load(); | 213 | return load(); |
183 | } | 214 | } |
184 | bool ODateBookAccessBackend_XML::save() { | 215 | bool ODateBookAccessBackend_XML::save() { |
185 | if (!m_changed) return true; | 216 | if (!m_changed) return true; |
186 | 217 | ||
187 | int total_written; | 218 | int total_written; |
188 | QString strFileNew = m_name + ".new"; | 219 | QString strFileNew = m_name + ".new"; |
189 | 220 | ||
190 | QFile f( strFileNew ); | 221 | QFile f( strFileNew ); |
191 | if (!f.open( IO_WriteOnly | IO_Raw ) ) return false; | 222 | if (!f.open( IO_WriteOnly | IO_Raw ) ) return false; |
192 | 223 | ||
@@ -589,24 +620,26 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val | |||
589 | e.setTimeZone( value ); | 620 | e.setTimeZone( value ); |
590 | break; | 621 | break; |
591 | default: | 622 | default: |
592 | break; | 623 | break; |
593 | } | 624 | } |
594 | } | 625 | } |
595 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const | 626 | QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const |
596 | { | 627 | { |
597 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); | 628 | QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() ); |
598 | uint arraycounter = 0; | 629 | uint arraycounter = 0; |
599 | QMap<int, OEvent>::ConstIterator it; | 630 | QMap<int, OEvent>::ConstIterator it; |
600 | 631 | ||
601 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) | 632 | for ( it = m_raw.begin(); it != m_raw.end(); ++it ) |
602 | if ( it.data().match( r ) ) | 633 | if ( it.data().match( r ) ) |
603 | m_currentQuery[arraycounter++] = it.data().uid(); | 634 | m_currentQuery[arraycounter++] = it.data().uid(); |
604 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) | 635 | for ( it = m_rep.begin(); it != m_rep.end(); ++it ) |
605 | if ( it.data().match( r ) ) | 636 | if ( it.data().match( r ) ) |
606 | m_currentQuery[arraycounter++] = it.data().uid(); | 637 | m_currentQuery[arraycounter++] = it.data().uid(); |
607 | 638 | ||
608 | // Shrink to fit.. | 639 | // Shrink to fit.. |
609 | m_currentQuery.resize(arraycounter); | 640 | m_currentQuery.resize(arraycounter); |
610 | 641 | ||
611 | return m_currentQuery; | 642 | return m_currentQuery; |
612 | } | 643 | } |
644 | |||
645 | } | ||
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h index a5cc0fc..29f5f4f 100644 --- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h +++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h | |||
@@ -1,55 +1,86 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 29 | #ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
2 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H | 30 | #define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H |
3 | 31 | ||
4 | #include <qmap.h> | 32 | #include <qmap.h> |
5 | 33 | ||
6 | #include "odatebookaccessbackend.h" | 34 | #include <opie2/odatebookaccessbackend.h> |
7 | 35 | ||
36 | namespace Opie { | ||
8 | /** | 37 | /** |
9 | * This is the default XML implementation for DateBoook XML storage | 38 | * This is the default XML implementation for DateBoook XML storage |
10 | * It fully implements the interface | 39 | * It fully implements the interface |
11 | * @see ODateBookAccessBackend | 40 | * @see ODateBookAccessBackend |
12 | * @see OPimAccessBackend | 41 | * @see OPimAccessBackend |
13 | */ | 42 | */ |
14 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { | 43 | class ODateBookAccessBackend_XML : public ODateBookAccessBackend { |
15 | public: | 44 | public: |
16 | ODateBookAccessBackend_XML( const QString& appName, | 45 | ODateBookAccessBackend_XML( const QString& appName, |
17 | const QString& fileName = QString::null); | 46 | const QString& fileName = QString::null); |
18 | ~ODateBookAccessBackend_XML(); | 47 | ~ODateBookAccessBackend_XML(); |
19 | 48 | ||
20 | bool load(); | 49 | bool load(); |
21 | bool reload(); | 50 | bool reload(); |
22 | bool save(); | 51 | bool save(); |
23 | 52 | ||
24 | QArray<int> allRecords()const; | 53 | QArray<int> allRecords()const; |
25 | QArray<int> matchRegexp(const QRegExp &r) const; | 54 | QArray<int> matchRegexp(const QRegExp &r) const; |
26 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); | 55 | QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() ); |
27 | OEvent find( int uid )const; | 56 | OEvent find( int uid )const; |
28 | void clear(); | 57 | void clear(); |
29 | bool add( const OEvent& ev ); | 58 | bool add( const OEvent& ev ); |
30 | bool remove( int uid ); | 59 | bool remove( int uid ); |
31 | bool replace( const OEvent& ev ); | 60 | bool replace( const OEvent& ev ); |
32 | 61 | ||
33 | QArray<UID> rawEvents()const; | 62 | QArray<UID> rawEvents()const; |
34 | QArray<UID> rawRepeats()const; | 63 | QArray<UID> rawRepeats()const; |
35 | QArray<UID> nonRepeats()const; | 64 | QArray<UID> nonRepeats()const; |
36 | 65 | ||
37 | OEvent::ValueList directNonRepeats(); | 66 | OEvent::ValueList directNonRepeats(); |
38 | OEvent::ValueList directRawRepeats(); | 67 | OEvent::ValueList directRawRepeats(); |
39 | 68 | ||
40 | private: | 69 | private: |
41 | bool m_changed :1 ; | 70 | bool m_changed :1 ; |
42 | bool loadFile(); | 71 | bool loadFile(); |
43 | inline void finalizeRecord( OEvent& ev ); | 72 | inline void finalizeRecord( OEvent& ev ); |
44 | inline void setField( OEvent&, int field, const QString& val ); | 73 | inline void setField( OEvent&, int field, const QString& val ); |
45 | QString m_name; | 74 | QString m_name; |
46 | QMap<int, OEvent> m_raw; | 75 | QMap<int, OEvent> m_raw; |
47 | QMap<int, OEvent> m_rep; | 76 | QMap<int, OEvent> m_rep; |
48 | 77 | ||
49 | struct Data; | 78 | struct Data; |
50 | Data* data; | 79 | Data* data; |
51 | class Private; | 80 | class Private; |
52 | Private *d; | 81 | Private *d; |
53 | }; | 82 | }; |
54 | 83 | ||
84 | } | ||
85 | |||
55 | #endif | 86 | #endif |
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index fd264fc..505358e 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -1,34 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 29 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 30 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 31 | ||
4 | #include <qarray.h> | 32 | #include <qarray.h> |
5 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
6 | 34 | ||
7 | #include <opie/otemplatebase.h> | 35 | #include <opie2/otemplatebase.h> |
8 | #include <opie/opimrecord.h> | 36 | #include <opie2/opimrecord.h> |
9 | 37 | ||
10 | 38 | ||
39 | namespace Opie { | ||
11 | class OPimAccessBackendPrivate; | 40 | class OPimAccessBackendPrivate; |
12 | /** | 41 | /** |
13 | * OPimAccessBackend is the base class | 42 | * OPimAccessBackend is the base class |
14 | * for all private backends | 43 | * for all private backends |
15 | * it operates on OPimRecord as the base class | 44 | * it operates on OPimRecord as the base class |
16 | * and it's responsible for fast manipulating | 45 | * and it's responsible for fast manipulating |
17 | * the resource the implementation takes care | 46 | * the resource the implementation takes care |
18 | * of | 47 | * of |
19 | */ | 48 | */ |
20 | template <class T = OPimRecord> | 49 | template <class T = OPimRecord> |
21 | class OPimAccessBackend { | 50 | class OPimAccessBackend { |
22 | public: | 51 | public: |
23 | typedef OTemplateBase<T> Frontend; | 52 | typedef OTemplateBase<T> Frontend; |
24 | 53 | ||
25 | /** The access hint from the frontend */ | 54 | /** The access hint from the frontend */ |
26 | OPimAccessBackend(int access = 0); | 55 | OPimAccessBackend(int access = 0); |
27 | virtual ~OPimAccessBackend(); | 56 | virtual ~OPimAccessBackend(); |
28 | 57 | ||
29 | /** | 58 | /** |
30 | * load the resource | 59 | * load the resource |
31 | */ | 60 | */ |
32 | virtual bool load() = 0; | 61 | virtual bool load() = 0; |
33 | 62 | ||
34 | /** | 63 | /** |
@@ -136,25 +165,28 @@ void OPimAccessBackend<T>::cache( const T& t )const { | |||
136 | m_front->cache( t ); | 165 | m_front->cache( t ); |
137 | } | 166 | } |
138 | template <class T> | 167 | template <class T> |
139 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 168 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
140 | if (m_front ) | 169 | if (m_front ) |
141 | m_front->setSaneCacheSize( size ); | 170 | m_front->setSaneCacheSize( size ); |
142 | } | 171 | } |
143 | template <class T> | 172 | template <class T> |
144 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 173 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
145 | uint, typename Frontend::CacheDirection )const { | 174 | uint, typename Frontend::CacheDirection )const { |
146 | return find( uid ); | 175 | return find( uid ); |
147 | } | 176 | } |
148 | template <class T> | 177 | template <class T> |
149 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 178 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
150 | m_read = count; | 179 | m_read = count; |
151 | } | 180 | } |
152 | template <class T> | 181 | template <class T> |
153 | uint OPimAccessBackend<T>::readAhead()const { | 182 | uint OPimAccessBackend<T>::readAhead()const { |
154 | return m_read; | 183 | return m_read; |
155 | } | 184 | } |
156 | template <class T> | 185 | template <class T> |
157 | int OPimAccessBackend<T>::access()const { | 186 | int OPimAccessBackend<T>::access()const { |
158 | return m_acc; | 187 | return m_acc; |
159 | } | 188 | } |
189 | |||
190 | } | ||
191 | |||
160 | #endif | 192 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp index baaeecc..d27f5ef 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.cpp +++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp | |||
@@ -1,10 +1,41 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | 29 | ||
2 | #include "otodoaccessbackend.h" | 30 | #include <opie2/otodoaccessbackend.h> |
3 | 31 | ||
32 | namespace Opie { | ||
4 | OTodoAccessBackend::OTodoAccessBackend() | 33 | OTodoAccessBackend::OTodoAccessBackend() |
5 | : OPimAccessBackend<OTodo>() | 34 | : OPimAccessBackend<OTodo>() |
6 | { | 35 | { |
7 | } | 36 | } |
8 | OTodoAccessBackend::~OTodoAccessBackend() { | 37 | OTodoAccessBackend::~OTodoAccessBackend() { |
9 | 38 | ||
10 | } | 39 | } |
40 | |||
41 | } | ||
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h index 6be95bc..54b52cc 100644 --- a/libopie2/opiepim/backend/otodoaccessbackend.h +++ b/libopie2/opiepim/backend/otodoaccessbackend.h | |||
@@ -1,28 +1,59 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_TODO_ACCESS_BACKEND_H | 29 | #ifndef OPIE_TODO_ACCESS_BACKEND_H |
2 | #define OPIE_TODO_ACCESS_BACKEND_H | 30 | #define OPIE_TODO_ACCESS_BACKEND_H |
3 | 31 | ||
4 | #include <qbitarray.h> | 32 | #include <qbitarray.h> |
5 | 33 | ||
6 | #include "otodo.h" | 34 | #include <opie2/otodo.h> |
7 | #include "opimaccessbackend.h" | 35 | #include <opie2/opimaccessbackend.h> |
8 | 36 | ||
37 | namespace Opie { | ||
9 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { | 38 | class OTodoAccessBackend : public OPimAccessBackend<OTodo> { |
10 | public: | 39 | public: |
11 | OTodoAccessBackend(); | 40 | OTodoAccessBackend(); |
12 | ~OTodoAccessBackend(); | 41 | ~OTodoAccessBackend(); |
13 | virtual QArray<int> effectiveToDos( const QDate& start, | 42 | virtual QArray<int> effectiveToDos( const QDate& start, |
14 | const QDate& end, | 43 | const QDate& end, |
15 | bool includeNoDates ) = 0; | 44 | bool includeNoDates ) = 0; |
16 | virtual QArray<int> overDue() = 0; | 45 | virtual QArray<int> overDue() = 0; |
17 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 46 | virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
18 | int cat ) = 0; | 47 | int cat ) = 0; |
19 | virtual void removeAllCompleted() = 0; | 48 | virtual void removeAllCompleted() = 0; |
20 | virtual QBitArray supports()const = 0; | 49 | virtual QBitArray supports()const = 0; |
21 | 50 | ||
22 | private: | 51 | private: |
23 | class Private; | 52 | class Private; |
24 | Private *d; | 53 | Private *d; |
25 | 54 | ||
26 | }; | 55 | }; |
27 | 56 | ||
57 | } | ||
58 | |||
28 | #endif | 59 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp index 3764c7e..944f82a 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.cpp +++ b/libopie2/opiepim/backend/otodoaccesssql.cpp | |||
@@ -1,39 +1,68 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | 29 | ||
2 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
3 | 31 | ||
4 | #include <qpe/global.h> | 32 | #include <qpe/global.h> |
5 | 33 | ||
6 | #include <opie2/osqldriver.h> | 34 | #include <opie2/osqldriver.h> |
7 | #include <opie2/osqlresult.h> | 35 | #include <opie2/osqlresult.h> |
8 | #include <opie2/osqlmanager.h> | 36 | #include <opie2/osqlmanager.h> |
9 | #include <opie2/osqlquery.h> | 37 | #include <opie2/osqlquery.h> |
10 | 38 | ||
11 | #include "otodoaccesssql.h" | 39 | #include <opie2/otodoaccesssql.h> |
12 | #include "opimstate.h" | 40 | #include <opie2/opimstate.h> |
13 | #include "opimnotifymanager.h" | 41 | #include <opie2/opimnotifymanager.h> |
14 | #include "orecur.h" | 42 | #include <opie2/orecur.h> |
15 | 43 | ||
44 | using namespace Opie; | ||
16 | /* | 45 | /* |
17 | * first some query | 46 | * first some query |
18 | * CREATE query | 47 | * CREATE query |
19 | * LOAD query | 48 | * LOAD query |
20 | * INSERT | 49 | * INSERT |
21 | * REMOVE | 50 | * REMOVE |
22 | * CLEAR | 51 | * CLEAR |
23 | */ | 52 | */ |
24 | namespace { | 53 | namespace { |
25 | /** | 54 | /** |
26 | * CreateQuery for the Todolist Table | 55 | * CreateQuery for the Todolist Table |
27 | */ | 56 | */ |
28 | class CreateQuery : public OSQLQuery { | 57 | class CreateQuery : public OSQLQuery { |
29 | public: | 58 | public: |
30 | CreateQuery(); | 59 | CreateQuery(); |
31 | ~CreateQuery(); | 60 | ~CreateQuery(); |
32 | QString query()const; | 61 | QString query()const; |
33 | }; | 62 | }; |
34 | 63 | ||
35 | /** | 64 | /** |
36 | * LoadQuery | 65 | * LoadQuery |
37 | * this one queries for all uids | 66 | * this one queries for all uids |
38 | */ | 67 | */ |
39 | class LoadQuery : public OSQLQuery { | 68 | class LoadQuery : public OSQLQuery { |
@@ -277,48 +306,50 @@ namespace { | |||
277 | 306 | ||
278 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) | 307 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) |
279 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} | 308 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} |
280 | EffQuery::~EffQuery() {} | 309 | EffQuery::~EffQuery() {} |
281 | QString EffQuery::query()const { | 310 | QString EffQuery::query()const { |
282 | return m_inc ? with() : out(); | 311 | return m_inc ? with() : out(); |
283 | } | 312 | } |
284 | QString EffQuery::with()const { | 313 | QString EffQuery::with()const { |
285 | QString str; | 314 | QString str; |
286 | 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' ") |
287 | .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() ) |
288 | .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() ); |
289 | return str; | 318 | return str; |
290 | } | 319 | } |
291 | QString EffQuery::out()const { | 320 | QString EffQuery::out()const { |
292 | QString str; | 321 | QString str; |
293 | 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'") |
294 | .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() ) |
295 | .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() ); |
296 | 325 | ||
297 | return str; | 326 | return str; |
298 | } | 327 | } |
299 | }; | 328 | }; |
300 | 329 | ||
330 | |||
331 | namespace Opie { | ||
301 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) | 332 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) |
302 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) | 333 | : OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true) |
303 | { | 334 | { |
304 | QString fi = file; | 335 | QString fi = file; |
305 | if ( fi.isEmpty() ) | 336 | if ( fi.isEmpty() ) |
306 | fi = Global::applicationFileName( "todolist", "todolist.db" ); | 337 | fi = Global::applicationFileName( "todolist", "todolist.db" ); |
307 | OSQLManager man; | 338 | OSQLManager man; |
308 | m_driver = man.standard(); | 339 | m_driver = man.standard(); |
309 | m_driver->setUrl(fi); | 340 | m_driver->setUrl(fi); |
310 | // fillDict(); | 341 | // fillDict(); |
311 | } | 342 | } |
312 | 343 | ||
313 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ | 344 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ |
314 | if( m_driver ) | 345 | if( m_driver ) |
315 | delete m_driver; | 346 | delete m_driver; |
316 | } | 347 | } |
317 | 348 | ||
318 | bool OTodoAccessBackendSQL::load(){ | 349 | bool OTodoAccessBackendSQL::load(){ |
319 | if (!m_driver->open() ) | 350 | if (!m_driver->open() ) |
320 | return false; | 351 | return false; |
321 | 352 | ||
322 | CreateQuery creat; | 353 | CreateQuery creat; |
323 | OSQLResult res = m_driver->query(&creat ); | 354 | OSQLResult res = m_driver->query(&creat ); |
324 | 355 | ||
@@ -670,24 +701,26 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const | |||
670 | return empty; | 701 | return empty; |
671 | } | 702 | } |
672 | QBitArray OTodoAccessBackendSQL::supports()const { | 703 | QBitArray OTodoAccessBackendSQL::supports()const { |
673 | 704 | ||
674 | return sup(); | 705 | return sup(); |
675 | } | 706 | } |
676 | 707 | ||
677 | QBitArray OTodoAccessBackendSQL::sup() const{ | 708 | QBitArray OTodoAccessBackendSQL::sup() const{ |
678 | 709 | ||
679 | QBitArray ar( OTodo::CompletedDate + 1 ); | 710 | QBitArray ar( OTodo::CompletedDate + 1 ); |
680 | ar.fill( true ); | 711 | ar.fill( true ); |
681 | ar[OTodo::CrossReference] = false; | 712 | ar[OTodo::CrossReference] = false; |
682 | ar[OTodo::State ] = false; | 713 | ar[OTodo::State ] = false; |
683 | ar[OTodo::Reminders] = false; | 714 | ar[OTodo::Reminders] = false; |
684 | ar[OTodo::Notifiers] = false; | 715 | ar[OTodo::Notifiers] = false; |
685 | ar[OTodo::Maintainer] = false; | 716 | ar[OTodo::Maintainer] = false; |
686 | 717 | ||
687 | return ar; | 718 | return ar; |
688 | } | 719 | } |
689 | 720 | ||
690 | void OTodoAccessBackendSQL::removeAllCompleted(){ | 721 | void OTodoAccessBackendSQL::removeAllCompleted(){ |
691 | #warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! | 722 | #warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !! |
692 | 723 | ||
693 | } | 724 | } |
725 | |||
726 | } | ||
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h index 1c55567..1a6f614 100644 --- a/libopie2/opiepim/backend/otodoaccesssql.h +++ b/libopie2/opiepim/backend/otodoaccesssql.h | |||
@@ -1,56 +1,88 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_PIM_ACCESS_SQL_H | 29 | #ifndef OPIE_PIM_ACCESS_SQL_H |
2 | #define OPIE_PIM_ACCESS_SQL_H | 30 | #define OPIE_PIM_ACCESS_SQL_H |
3 | 31 | ||
4 | #include <qasciidict.h> | 32 | #include <qasciidict.h> |
5 | 33 | ||
6 | #include "otodoaccessbackend.h" | 34 | #include <opie2/otodoaccessbackend.h> |
7 | 35 | ||
8 | class OSQLDriver; | 36 | class OSQLDriver; |
9 | class OSQLResult; | 37 | class OSQLResult; |
10 | class OSQLResultItem; | 38 | class OSQLResultItem; |
39 | |||
40 | namespace Opie { | ||
41 | |||
11 | class OTodoAccessBackendSQL : public OTodoAccessBackend { | 42 | class OTodoAccessBackendSQL : public OTodoAccessBackend { |
12 | public: | 43 | public: |
13 | OTodoAccessBackendSQL( const QString& file ); | 44 | OTodoAccessBackendSQL( const QString& file ); |
14 | ~OTodoAccessBackendSQL(); | 45 | ~OTodoAccessBackendSQL(); |
15 | 46 | ||
16 | bool load(); | 47 | bool load(); |
17 | bool reload(); | 48 | bool reload(); |
18 | bool save(); | 49 | bool save(); |
19 | QArray<int> allRecords()const; | 50 | QArray<int> allRecords()const; |
20 | 51 | ||
21 | QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); | 52 | QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() ); |
22 | OTodo find(int uid)const; | 53 | OTodo find(int uid)const; |
23 | OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; | 54 | OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; |
24 | void clear(); | 55 | void clear(); |
25 | bool add( const OTodo& t ); | 56 | bool add( const OTodo& t ); |
26 | bool remove( int uid ); | 57 | bool remove( int uid ); |
27 | bool replace( const OTodo& t ); | 58 | bool replace( const OTodo& t ); |
28 | 59 | ||
29 | QArray<int> overDue(); | 60 | QArray<int> overDue(); |
30 | QArray<int> effectiveToDos( const QDate& start, | 61 | QArray<int> effectiveToDos( const QDate& start, |
31 | const QDate& end, bool includeNoDates ); | 62 | const QDate& end, bool includeNoDates ); |
32 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); | 63 | QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat ); |
33 | 64 | ||
34 | QBitArray supports()const; | 65 | QBitArray supports()const; |
35 | QArray<int> matchRegexp( const QRegExp &r ) const; | 66 | QArray<int> matchRegexp( const QRegExp &r ) const; |
36 | void removeAllCompleted(); | 67 | void removeAllCompleted(); |
37 | 68 | ||
38 | 69 | ||
39 | private: | 70 | private: |
40 | void update()const; | 71 | void update()const; |
41 | void fillDict(); | 72 | void fillDict(); |
42 | inline bool date( QDate& date, const QString& )const; | 73 | inline bool date( QDate& date, const QString& )const; |
43 | inline OTodo todo( const OSQLResult& )const; | 74 | inline OTodo todo( const OSQLResult& )const; |
44 | inline OTodo todo( OSQLResultItem& )const; | 75 | inline OTodo todo( OSQLResultItem& )const; |
45 | inline QArray<int> uids( const OSQLResult& )const; | 76 | inline QArray<int> uids( const OSQLResult& )const; |
46 | OTodo todo( int uid )const; | 77 | OTodo todo( int uid )const; |
47 | QBitArray sup() const; | 78 | QBitArray sup() const; |
48 | 79 | ||
49 | QAsciiDict<int> m_dict; | 80 | QAsciiDict<int> m_dict; |
50 | OSQLDriver* m_driver; | 81 | OSQLDriver* m_driver; |
51 | QArray<int> m_uids; | 82 | QArray<int> m_uids; |
52 | bool m_dirty : 1; | 83 | bool m_dirty : 1; |
53 | }; | 84 | }; |
54 | 85 | ||
86 | } | ||
55 | 87 | ||
56 | #endif | 88 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index 6415952..e364ee2 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -1,31 +1,61 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <qfile.h> | 29 | #include <qfile.h> |
2 | 30 | ||
3 | #include <qtopia/private/vobject_p.h> | 31 | #include <qtopia/private/vobject_p.h> |
4 | #include <qtopia/timeconversion.h> | 32 | #include <qtopia/timeconversion.h> |
5 | #include <qtopia/private/qfiledirect_p.h> | 33 | #include <qtopia/private/qfiledirect_p.h> |
6 | 34 | ||
7 | #include "otodoaccessvcal.h" | 35 | #include <opie2/otodoaccessvcal.h> |
36 | |||
37 | using namespace Opie; | ||
8 | 38 | ||
9 | namespace { | 39 | namespace { |
10 | static OTodo eventByVObj( VObject *obj ){ | 40 | static OTodo eventByVObj( VObject *obj ){ |
11 | OTodo event; | 41 | OTodo event; |
12 | VObject *ob; | 42 | VObject *ob; |
13 | QCString name; | 43 | QCString name; |
14 | // no uid, attendees, ... and no fun | 44 | // no uid, attendees, ... and no fun |
15 | // description | 45 | // description |
16 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
17 | name = vObjectStringZValue( ob ); | 47 | name = vObjectStringZValue( ob ); |
18 | #if 0 | 48 | #if 0 |
19 | event.setDescription( name ); | 49 | event.setDescription( name ); |
20 | #else | 50 | #else |
21 | event.setSummary( name ); | 51 | event.setSummary( name ); |
22 | #endif | 52 | #endif |
23 | } | 53 | } |
24 | // summary | 54 | // summary |
25 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { | 55 | if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) { |
26 | name = vObjectStringZValue( ob ); | 56 | name = vObjectStringZValue( ob ); |
27 | #if 0 | 57 | #if 0 |
28 | event.setSummary( name ); | 58 | event.setSummary( name ); |
29 | #else | 59 | #else |
30 | event.setDescription( name ); | 60 | event.setDescription( name ); |
31 | #endif | 61 | #endif |
@@ -86,48 +116,49 @@ namespace { | |||
86 | 116 | ||
87 | // There seems a misrepresentation between summary in otodoevent | 117 | // There seems a misrepresentation between summary in otodoevent |
88 | // and summary in vcard. | 118 | // and summary in vcard. |
89 | // The same with description.. | 119 | // The same with description.. |
90 | // Description is summary and vice versa.. Argh.. (eilers) | 120 | // Description is summary and vice versa.. Argh.. (eilers) |
91 | 121 | ||
92 | 122 | ||
93 | addPropValue( task, VCDescriptionProp, | 123 | addPropValue( task, VCDescriptionProp, |
94 | event.description().local8Bit() ); | 124 | event.description().local8Bit() ); |
95 | 125 | ||
96 | addPropValue( task, VCSummaryProp, | 126 | addPropValue( task, VCSummaryProp, |
97 | event.summary().local8Bit() ); | 127 | event.summary().local8Bit() ); |
98 | 128 | ||
99 | #else | 129 | #else |
100 | addPropValue( task, VCDescriptionProp, | 130 | addPropValue( task, VCDescriptionProp, |
101 | event.summary().local8Bit() ); | 131 | event.summary().local8Bit() ); |
102 | 132 | ||
103 | addPropValue( task, VCSummaryProp, | 133 | addPropValue( task, VCSummaryProp, |
104 | event.description().local8Bit() ); | 134 | event.description().local8Bit() ); |
105 | #endif | 135 | #endif |
106 | return task; | 136 | return task; |
107 | }; | 137 | }; |
108 | } | 138 | } |
109 | 139 | ||
140 | namespace Opie { | ||
110 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) | 141 | OTodoAccessVCal::OTodoAccessVCal( const QString& path ) |
111 | : m_dirty(false), m_file( path ) | 142 | : m_dirty(false), m_file( path ) |
112 | { | 143 | { |
113 | } | 144 | } |
114 | OTodoAccessVCal::~OTodoAccessVCal() { | 145 | OTodoAccessVCal::~OTodoAccessVCal() { |
115 | } | 146 | } |
116 | bool OTodoAccessVCal::load() { | 147 | bool OTodoAccessVCal::load() { |
117 | m_map.clear(); | 148 | m_map.clear(); |
118 | m_dirty = false; | 149 | m_dirty = false; |
119 | 150 | ||
120 | VObject* vcal = 0l; | 151 | VObject* vcal = 0l; |
121 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 152 | vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
122 | if (!vcal ) | 153 | if (!vcal ) |
123 | return false; | 154 | return false; |
124 | 155 | ||
125 | // Iterate over the list | 156 | // Iterate over the list |
126 | VObjectIterator it; | 157 | VObjectIterator it; |
127 | VObject* vobj; | 158 | VObject* vobj; |
128 | 159 | ||
129 | initPropIterator(&it, vcal); | 160 | initPropIterator(&it, vcal); |
130 | 161 | ||
131 | while( moreIteration( &it ) ) { | 162 | while( moreIteration( &it ) ) { |
132 | vobj = ::nextVObject( &it ); | 163 | vobj = ::nextVObject( &it ); |
133 | QCString name = ::vObjectName( vobj ); | 164 | QCString name = ::vObjectName( vobj ); |
@@ -226,24 +257,26 @@ QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& , | |||
226 | QArray<int> OTodoAccessVCal::overDue() { | 257 | QArray<int> OTodoAccessVCal::overDue() { |
227 | QArray<int> ar(0); | 258 | QArray<int> ar(0); |
228 | return ar; | 259 | return ar; |
229 | } | 260 | } |
230 | QBitArray OTodoAccessVCal::supports()const { | 261 | QBitArray OTodoAccessVCal::supports()const { |
231 | static QBitArray ar = sup(); | 262 | static QBitArray ar = sup(); |
232 | 263 | ||
233 | return ar; | 264 | return ar; |
234 | } | 265 | } |
235 | QBitArray OTodoAccessVCal::sup() { | 266 | QBitArray OTodoAccessVCal::sup() { |
236 | QBitArray ar ( OTodo::CompletedDate +1 ); | 267 | QBitArray ar ( OTodo::CompletedDate +1 ); |
237 | ar.fill( true ); | 268 | ar.fill( true ); |
238 | 269 | ||
239 | ar[OTodo::CrossReference] = false; | 270 | ar[OTodo::CrossReference] = false; |
240 | ar[OTodo::State ] = false; | 271 | ar[OTodo::State ] = false; |
241 | ar[OTodo::Reminders] = false; | 272 | ar[OTodo::Reminders] = false; |
242 | ar[OTodo::Notifiers] = false; | 273 | ar[OTodo::Notifiers] = false; |
243 | ar[OTodo::Maintainer] = false; | 274 | ar[OTodo::Maintainer] = false; |
244 | ar[OTodo::Progress] = false; | 275 | ar[OTodo::Progress] = false; |
245 | ar[OTodo::Alarms ] = false; | 276 | ar[OTodo::Alarms ] = false; |
246 | ar[OTodo::Recurrence] = false; | 277 | ar[OTodo::Recurrence] = false; |
247 | 278 | ||
248 | return ar; | 279 | return ar; |
249 | } | 280 | } |
281 | |||
282 | } | ||
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h index 2b17147..f9323fb 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.h +++ b/libopie2/opiepim/backend/otodoaccessvcal.h | |||
@@ -1,40 +1,72 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_OTODO_ACCESS_VCAL_H | 29 | #ifndef OPIE_OTODO_ACCESS_VCAL_H |
2 | #define OPIE_OTODO_ACCESS_VCAL_H | 30 | #define OPIE_OTODO_ACCESS_VCAL_H |
3 | 31 | ||
4 | #include "otodoaccessbackend.h" | 32 | #include <opie2/otodoaccessbackend.h> |
33 | |||
34 | namespace Opie { | ||
5 | 35 | ||
6 | class OTodoAccessVCal : public OTodoAccessBackend { | 36 | class OTodoAccessVCal : public OTodoAccessBackend { |
7 | public: | 37 | public: |
8 | OTodoAccessVCal(const QString& ); | 38 | OTodoAccessVCal(const QString& ); |
9 | ~OTodoAccessVCal(); | 39 | ~OTodoAccessVCal(); |
10 | 40 | ||
11 | bool load(); | 41 | bool load(); |
12 | bool reload(); | 42 | bool reload(); |
13 | bool save(); | 43 | bool save(); |
14 | 44 | ||
15 | QArray<int> allRecords()const; | 45 | QArray<int> allRecords()const; |
16 | QArray<int> matchRegexp(const QRegExp &r) const; | 46 | QArray<int> matchRegexp(const QRegExp &r) const; |
17 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); | 47 | QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() ); |
18 | QArray<int> effectiveToDos( const QDate& start, | 48 | QArray<int> effectiveToDos( const QDate& start, |
19 | const QDate& end, | 49 | const QDate& end, |
20 | bool includeNoDates ); | 50 | bool includeNoDates ); |
21 | QArray<int> overDue(); | 51 | QArray<int> overDue(); |
22 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, | 52 | QArray<int> sorted( bool asc, int sortOrder, int sortFilter, |
23 | int cat ); | 53 | int cat ); |
24 | OTodo find(int uid)const; | 54 | OTodo find(int uid)const; |
25 | void clear(); | 55 | void clear(); |
26 | bool add( const OTodo& ); | 56 | bool add( const OTodo& ); |
27 | bool remove( int uid ); | 57 | bool remove( int uid ); |
28 | bool replace( const OTodo& ); | 58 | bool replace( const OTodo& ); |
29 | 59 | ||
30 | void removeAllCompleted(); | 60 | void removeAllCompleted(); |
31 | virtual QBitArray supports()const; | 61 | virtual QBitArray supports()const; |
32 | 62 | ||
33 | private: | 63 | private: |
34 | static QBitArray sup(); | 64 | static QBitArray sup(); |
35 | bool m_dirty : 1; | 65 | bool m_dirty : 1; |
36 | QString m_file; | 66 | QString m_file; |
37 | QMap<int, OTodo> m_map; | 67 | QMap<int, OTodo> m_map; |
38 | }; | 68 | }; |
39 | 69 | ||
70 | } | ||
71 | |||
40 | #endif | 72 | #endif |
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp index 4a5cb33..2d50ecd 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.cpp +++ b/libopie2/opiepim/backend/otodoaccessxml.cpp | |||
@@ -1,92 +1,123 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #include <errno.h> | 29 | #include <errno.h> |
2 | #include <fcntl.h> | 30 | #include <fcntl.h> |
3 | 31 | ||
4 | #include <sys/mman.h> | 32 | #include <sys/mman.h> |
5 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
6 | #include <sys/types.h> | 34 | #include <sys/types.h> |
7 | 35 | ||
8 | #include <unistd.h> | 36 | #include <unistd.h> |
9 | 37 | ||
10 | 38 | ||
11 | #include <qfile.h> | 39 | #include <qfile.h> |
12 | #include <qvector.h> | 40 | #include <qvector.h> |
13 | 41 | ||
14 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
15 | #include <qpe/stringutil.h> | 43 | #include <qpe/stringutil.h> |
16 | #include <qpe/timeconversion.h> | 44 | #include <qpe/timeconversion.h> |
17 | 45 | ||
18 | #include "oconversion.h" | 46 | #include <opie2/oconversion.h> |
19 | #include "opimstate.h" | 47 | #include <opie2/opimstate.h> |
20 | #include "otimezone.h" | 48 | #include <opie2/otimezone.h> |
21 | #include "opimnotifymanager.h" | 49 | #include <opie2/opimnotifymanager.h> |
22 | #include "orecur.h" | 50 | #include <opie2/orecur.h> |
23 | #include "otodoaccessxml.h" | 51 | #include <opie2/otodoaccessxml.h> |
52 | |||
53 | using namespace Opie; | ||
24 | 54 | ||
25 | namespace { | 55 | namespace { |
26 | time_t rp_end; | 56 | time_t rp_end; |
27 | ORecur* rec; | 57 | ORecur* rec; |
28 | ORecur *recur() { | 58 | ORecur *recur() { |
29 | if (!rec ) rec = new ORecur; | 59 | if (!rec ) rec = new ORecur; |
30 | return rec; | 60 | return rec; |
31 | } | 61 | } |
32 | int snd; | 62 | int snd; |
33 | enum MoreAttributes { | 63 | enum MoreAttributes { |
34 | FRType = OTodo::CompletedDate + 2, | 64 | FRType = OTodo::CompletedDate + 2, |
35 | FRWeekdays, | 65 | FRWeekdays, |
36 | FRPosition, | 66 | FRPosition, |
37 | FRFreq, | 67 | FRFreq, |
38 | FRHasEndDate, | 68 | FRHasEndDate, |
39 | FREndDate, | 69 | FREndDate, |
40 | FRStart, | 70 | FRStart, |
41 | FREnd | 71 | FREnd |
42 | }; | 72 | }; |
43 | // FROM TT again | 73 | // FROM TT again |
44 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) | 74 | char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) |
45 | { | 75 | { |
46 | char needleChar; | 76 | char needleChar; |
47 | char haystackChar; | 77 | char haystackChar; |
48 | if (!needle || !haystack || !hLen || !nLen) | 78 | if (!needle || !haystack || !hLen || !nLen) |
49 | return 0; | 79 | return 0; |
50 | 80 | ||
51 | const char* hsearch = haystack; | 81 | const char* hsearch = haystack; |
52 | 82 | ||
53 | if ((needleChar = *needle++) != 0) { | 83 | if ((needleChar = *needle++) != 0) { |
54 | nLen--; //(to make up for needle++) | 84 | nLen--; //(to make up for needle++) |
55 | do { | 85 | do { |
56 | do { | 86 | do { |
57 | if ((haystackChar = *hsearch++) == 0) | 87 | if ((haystackChar = *hsearch++) == 0) |
58 | return (0); | 88 | return (0); |
59 | if (hsearch >= haystack + hLen) | 89 | if (hsearch >= haystack + hLen) |
60 | return (0); | 90 | return (0); |
61 | } while (haystackChar != needleChar); | 91 | } while (haystackChar != needleChar); |
62 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); | 92 | } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); |
63 | hsearch--; | 93 | hsearch--; |
64 | } | 94 | } |
65 | return ((char *)hsearch); | 95 | return ((char *)hsearch); |
66 | } | 96 | } |
67 | } | 97 | } |
68 | 98 | ||
99 | namespace Opie { | ||
69 | 100 | ||
70 | OTodoAccessXML::OTodoAccessXML( const QString& appName, | 101 | OTodoAccessXML::OTodoAccessXML( const QString& appName, |
71 | const QString& fileName ) | 102 | const QString& fileName ) |
72 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) | 103 | : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) |
73 | { | 104 | { |
74 | if (!fileName.isEmpty() ) | 105 | if (!fileName.isEmpty() ) |
75 | m_file = fileName; | 106 | m_file = fileName; |
76 | else | 107 | else |
77 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); | 108 | m_file = Global::applicationFileName( "todolist", "todolist.xml" ); |
78 | } | 109 | } |
79 | OTodoAccessXML::~OTodoAccessXML() { | 110 | OTodoAccessXML::~OTodoAccessXML() { |
80 | 111 | ||
81 | } | 112 | } |
82 | bool OTodoAccessXML::load() { | 113 | bool OTodoAccessXML::load() { |
83 | rec = 0; | 114 | rec = 0; |
84 | m_opened = true; | 115 | m_opened = true; |
85 | m_changed = false; | 116 | m_changed = false; |
86 | /* initialize dict */ | 117 | /* initialize dict */ |
87 | /* | 118 | /* |
88 | * UPDATE dict if you change anything!!! | 119 | * UPDATE dict if you change anything!!! |
89 | */ | 120 | */ |
90 | QAsciiDict<int> dict(26); | 121 | QAsciiDict<int> dict(26); |
91 | dict.setAutoDelete( TRUE ); | 122 | dict.setAutoDelete( TRUE ); |
92 | dict.insert("Categories" , new int(OTodo::Category) ); | 123 | dict.insert("Categories" , new int(OTodo::Category) ); |
@@ -853,24 +884,26 @@ QBitArray OTodoAccessXML::sup() { | |||
853 | ar[OTodo::CrossReference] = false; | 884 | ar[OTodo::CrossReference] = false; |
854 | ar[OTodo::State ] = false; | 885 | ar[OTodo::State ] = false; |
855 | ar[OTodo::Reminders] = false; | 886 | ar[OTodo::Reminders] = false; |
856 | ar[OTodo::Notifiers] = false; | 887 | ar[OTodo::Notifiers] = false; |
857 | ar[OTodo::Maintainer] = false; | 888 | ar[OTodo::Maintainer] = false; |
858 | 889 | ||
859 | return ar; | 890 | return ar; |
860 | } | 891 | } |
861 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const | 892 | QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const |
862 | { | 893 | { |
863 | QArray<int> m_currentQuery( m_events.count() ); | 894 | QArray<int> m_currentQuery( m_events.count() ); |
864 | uint arraycounter = 0; | 895 | uint arraycounter = 0; |
865 | 896 | ||
866 | QMap<int, OTodo>::ConstIterator it; | 897 | QMap<int, OTodo>::ConstIterator it; |
867 | for (it = m_events.begin(); it != m_events.end(); ++it ) { | 898 | for (it = m_events.begin(); it != m_events.end(); ++it ) { |
868 | if ( it.data().match( r ) ) | 899 | if ( it.data().match( r ) ) |
869 | m_currentQuery[arraycounter++] = it.data().uid(); | 900 | m_currentQuery[arraycounter++] = it.data().uid(); |
870 | 901 | ||
871 | } | 902 | } |
872 | // Shrink to fit.. | 903 | // Shrink to fit.. |
873 | m_currentQuery.resize(arraycounter); | 904 | m_currentQuery.resize(arraycounter); |
874 | 905 | ||
875 | return m_currentQuery; | 906 | return m_currentQuery; |
876 | } | 907 | } |
908 | |||
909 | } | ||
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h index e4850a1..d634398 100644 --- a/libopie2/opiepim/backend/otodoaccessxml.h +++ b/libopie2/opiepim/backend/otodoaccessxml.h | |||
@@ -1,60 +1,89 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_TODO_ACCESS_XML_H | 29 | #ifndef OPIE_TODO_ACCESS_XML_H |
2 | #define OPIE_TODO_ACCESS_XML_H | 30 | #define OPIE_TODO_ACCESS_XML_H |
3 | 31 | ||
4 | #include <qasciidict.h> | 32 | #include <qasciidict.h> |
5 | #include <qmap.h> | 33 | #include <qmap.h> |
6 | 34 | ||
7 | #include "otodoaccessbackend.h" | 35 | #include <opie2/otodoaccessbackend.h> |
8 | 36 | ||
9 | namespace Opie { | 37 | namespace Opie { |
10 | class XMLElement; | 38 | class XMLElement; |
11 | }; | ||
12 | 39 | ||
13 | class OTodoAccessXML : public OTodoAccessBackend { | 40 | class OTodoAccessXML : public OTodoAccessBackend { |
14 | public: | 41 | public: |
15 | /** | 42 | /** |
16 | * fileName if Empty we will use the default path | 43 | * fileName if Empty we will use the default path |
17 | */ | 44 | */ |
18 | OTodoAccessXML( const QString& appName, | 45 | OTodoAccessXML( const QString& appName, |
19 | const QString& fileName = QString::null ); | 46 | const QString& fileName = QString::null ); |
20 | ~OTodoAccessXML(); | 47 | ~OTodoAccessXML(); |
21 | 48 | ||
22 | bool load(); | 49 | bool load(); |
23 | bool reload(); | 50 | bool reload(); |
24 | bool save(); | 51 | bool save(); |
25 | 52 | ||
26 | QArray<int> allRecords()const; | 53 | QArray<int> allRecords()const; |
27 | QArray<int> matchRegexp(const QRegExp &r) const; | 54 | QArray<int> matchRegexp(const QRegExp &r) const; |
28 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); | 55 | QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() ); |
29 | OTodo find( int uid )const; | 56 | OTodo find( int uid )const; |
30 | void clear(); | 57 | void clear(); |
31 | bool add( const OTodo& ); | 58 | bool add( const OTodo& ); |
32 | bool remove( int uid ); | 59 | bool remove( int uid ); |
33 | void removeAllCompleted(); | 60 | void removeAllCompleted(); |
34 | bool replace( const OTodo& ); | 61 | bool replace( const OTodo& ); |
35 | 62 | ||
36 | /* our functions */ | 63 | /* our functions */ |
37 | QArray<int> effectiveToDos( const QDate& start, | 64 | QArray<int> effectiveToDos( const QDate& start, |
38 | const QDate& end, | 65 | const QDate& end, |
39 | bool includeNoDates ); | 66 | bool includeNoDates ); |
40 | QArray<int> overDue(); | 67 | QArray<int> overDue(); |
41 | QArray<int> sorted( bool asc, int sortOrder, | 68 | QArray<int> sorted( bool asc, int sortOrder, |
42 | int sortFilter, int cat ); | 69 | int sortFilter, int cat ); |
43 | QBitArray supports()const; | 70 | QBitArray supports()const; |
44 | private: | 71 | private: |
45 | static QBitArray sup(); | 72 | static QBitArray sup(); |
46 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); | 73 | void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& ); |
47 | QString toString( const OTodo& )const; | 74 | QString toString( const OTodo& )const; |
48 | QString toString( const QArray<int>& ints ) const; | 75 | QString toString( const QArray<int>& ints ) const; |
49 | QMap<int, OTodo> m_events; | 76 | QMap<int, OTodo> m_events; |
50 | QString m_file; | 77 | QString m_file; |
51 | QString m_app; | 78 | QString m_app; |
52 | bool m_opened : 1; | 79 | bool m_opened : 1; |
53 | bool m_changed : 1; | 80 | bool m_changed : 1; |
54 | class OTodoAccessXMLPrivate; | 81 | class OTodoAccessXMLPrivate; |
55 | OTodoAccessXMLPrivate* d; | 82 | OTodoAccessXMLPrivate* d; |
56 | int m_year, m_month, m_day; | 83 | int m_year, m_month, m_day; |
57 | 84 | ||
58 | }; | 85 | }; |
59 | 86 | ||
87 | }; | ||
88 | |||
60 | #endif | 89 | #endif |