author | eilers <eilers> | 2004-05-23 17:11:01 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-05-23 17:11:01 (UTC) |
commit | 3025eab185d9e4237c37b4a193fbb20a4dbe504e (patch) (unidiff) | |
tree | a6d4ee84122cdcd207d77c16b7449b432df6096a | |
parent | 29c68e4c0b10bf31cab3520737d042978d3eb4c0 (diff) | |
download | opie-3025eab185d9e4237c37b4a193fbb20a4dbe504e.zip opie-3025eab185d9e4237c37b4a193fbb20a4dbe504e.tar.gz opie-3025eab185d9e4237c37b4a193fbb20a4dbe504e.tar.bz2 |
Changes in Backendfactory: Now providing VCARD/VCAL backends if available
Changing API: Default now gets a OPimGlobal::PimType as first param instead of QString.
-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 98 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiepim/core/odatebookaccess.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimglobal.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/otodoaccess.cpp | 3 |
5 files changed, 63 insertions, 46 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 4bedbef..c8a4627 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -1,208 +1,222 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: Use plugins | 31 | * ToDo: Use plugins |
32 | * ===================================================================== | 32 | * ===================================================================== |
33 | */ | 33 | */ |
34 | #ifndef OPIE_BACKENDFACTORY_H_ | 34 | #ifndef OPIE_BACKENDFACTORY_H_ |
35 | #define OPIE_BACKENDFACTORY_H_ | 35 | #define OPIE_BACKENDFACTORY_H_ |
36 | 36 | ||
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qasciidict.h> | 38 | #include <qasciidict.h> |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | 40 | ||
41 | #include <opie2/opimaccessbackend.h> | ||
41 | #include <opie2/opimglobal.h> | 42 | #include <opie2/opimglobal.h> |
42 | #include <opie2/otodoaccessxml.h> | 43 | #include <opie2/otodoaccessxml.h> |
44 | #include <opie2/otodoaccessvcal.h> | ||
43 | #include <opie2/ocontactaccessbackend_xml.h> | 45 | #include <opie2/ocontactaccessbackend_xml.h> |
46 | #include <opie2/ocontactaccessbackend_vcard.h> | ||
44 | #include <opie2/odatebookaccessbackend_xml.h> | 47 | #include <opie2/odatebookaccessbackend_xml.h> |
45 | 48 | ||
46 | #ifdef __USE_SQL | 49 | #ifdef __USE_SQL |
47 | #include <opie2/otodoaccesssql.h> | 50 | #include <opie2/otodoaccesssql.h> |
48 | #include <opie2/ocontactaccessbackend_sql.h> | 51 | #include <opie2/ocontactaccessbackend_sql.h> |
49 | #include <opie2/odatebookaccessbackend_sql.h> | 52 | #include <opie2/odatebookaccessbackend_sql.h> |
50 | #endif | 53 | #endif |
51 | 54 | ||
52 | using namespace Opie; | 55 | using namespace Opie; |
53 | using namespace Opie::Pim; | 56 | using namespace Opie::Pim; |
54 | 57 | ||
55 | namespace Opie { | 58 | namespace Opie { |
56 | 59 | ||
57 | class OBackendPrivate; | 60 | class OBackendPrivate; |
58 | 61 | ||
59 | /** | 62 | /** |
60 | * This class is our factory. It will give us the default implementations | 63 | * This class is our factory. It will give us the default implementations |
61 | * of at least Todolist, Contacts and Datebook. In the future this class will | 64 | * of at least Todolist, Contacts and Datebook. In the future this class will |
62 | * allow users to switch the backend with ( XML->SQLite ) without the need | 65 | * allow users to switch the backend with ( XML->SQLite ) without the need |
63 | * to recompile.# | 66 | * to recompile.# |
64 | * This class - as the whole PIM Api - is making use of templates | 67 | * This class - as the whole PIM Api - is making use of templates |
65 | * | 68 | * |
66 | * <pre> | 69 | * <pre> |
67 | * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null ); | 70 | * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null ); |
68 | * backend->load(); | 71 | * backend->load(); |
69 | * </pre> | 72 | * </pre> |
70 | * | 73 | * |
71 | * @author Stefan Eilers | 74 | * @author Stefan Eilers |
72 | * @version 0.1 | 75 | * @version 0.1 |
73 | */ | 76 | */ |
74 | template<class T> | 77 | template<class T> |
75 | class OBackendFactory | 78 | class OBackendFactory |
76 | { | 79 | { |
77 | public: | 80 | public: |
78 | OBackendFactory() {}; | 81 | OBackendFactory() {}; |
79 | 82 | ||
80 | /** | 83 | /** |
81 | * Returns a selected backend implementation | 84 | * Returns a selected backend implementation |
82 | * @param type the type of the backend | 85 | * @param type the type of the backend |
83 | * @param database the type of the used database | 86 | * @param database the type of the used database |
84 | * @param appName The name of your application. It will be passed on to the backend. | 87 | * @param appName The name of your application. It will be passed on to the backend. |
88 | * @param filename Filename of the database file if you don't want to access the default | ||
85 | */ | 89 | */ |
86 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, | 90 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, |
87 | const QString& appName ){ | 91 | const QString& appName, const QString& filename = QString::null ){ |
88 | qWarning("Selected backend for %d is: %d", type, database ); | 92 | qWarning("Selected backend for %d is: %d", type, database ); |
89 | // If we should use the dafult database style, we have to request it | 93 | // If we should use the dafult database style, we have to request it |
90 | OPimGlobal::DatabaseStyle used_database = database; | 94 | OPimGlobal::DatabaseStyle use_database = database; |
91 | if ( database == OPimGlobal::DEFAULT ){ | 95 | if ( use_database == OPimGlobal::DEFAULT ){ |
92 | used_database = defaultDB( type ); | 96 | use_database = defaultDB( type ); |
93 | } | 97 | } |
94 | 98 | ||
95 | |||
96 | switch ( type ){ | 99 | switch ( type ){ |
97 | case OPimGlobal::TODOLIST: | 100 | case OPimGlobal::TODOLIST: |
101 | |||
102 | switch ( use_database ){ | ||
103 | default: // Use SQL if something weird is given. | ||
104 | // Fall through !! | ||
105 | case OPimGlobal::SQL: | ||
98 | #ifdef __USE_SQL | 106 | #ifdef __USE_SQL |
99 | if ( used_database == OPimGlobal::SQL ) | 107 | return (T*) new OPimTodoAccessBackendSQL( filename ); |
100 | return (T*) new OPimTodoAccessBackendSQL(""); | 108 | break; |
101 | #else | 109 | #else |
102 | if ( used_database == OPimGlobal::SQL ) | ||
103 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); | 110 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); |
111 | // Fall through !! | ||
104 | #endif | 112 | #endif |
105 | 113 | case OPimGlobal::XML: | |
106 | return (T*) new OPimTodoAccessXML( appName ); | 114 | return (T*) new OPimTodoAccessXML( appName, filename ); |
115 | break; | ||
116 | case OPimGlobal::VCARD: | ||
117 | return (T*) new OPimTodoAccessVCal( filename ); | ||
118 | break; | ||
119 | } | ||
107 | case OPimGlobal::CONTACTLIST: | 120 | case OPimGlobal::CONTACTLIST: |
121 | switch ( use_database ){ | ||
122 | default: // Use SQL if something weird is given. | ||
123 | // Fall through !! | ||
124 | case OPimGlobal::SQL: | ||
108 | #ifdef __USE_SQL | 125 | #ifdef __USE_SQL |
109 | if ( used_database == OPimGlobal::SQL ) | 126 | return (T*) new OPimContactAccessBackend_SQL( appName, filename ); |
110 | return (T*) new OPimContactAccessBackend_SQL(""); | 127 | break; |
111 | #else | 128 | #else |
112 | if ( used_database == OPimGlobal::SQL ) | ||
113 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); | 129 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); |
130 | // Fall through !! | ||
114 | #endif | 131 | #endif |
115 | 132 | case OPimGlobal::XML: | |
116 | return (T*) new OPimContactAccessBackend_XML( appName ); | 133 | return (T*) new OPimContactAccessBackend_XML( appName, filename ); |
134 | break; | ||
135 | case OPimGlobal::VCARD: | ||
136 | return (T*) new OPimContactAccessBackend_VCard( appName, filename ); | ||
137 | break; | ||
138 | } | ||
117 | case OPimGlobal::DATEBOOK: | 139 | case OPimGlobal::DATEBOOK: |
140 | switch ( use_database ){ | ||
141 | default: // Use SQL if something weird is given. | ||
142 | // Fall through !! | ||
143 | case OPimGlobal::SQL: | ||
118 | #ifdef __USE_SQL | 144 | #ifdef __USE_SQL |
119 | if ( used_database == OPimGlobal::SQL ) | 145 | return (T*) new ODateBookAccessBackend_SQL( appName, filename ); |
120 | return (T*) new ODateBookAccessBackend_SQL(""); | 146 | break; |
121 | #else | 147 | #else |
122 | if ( used_database == OPimGlobal::SQL ) | 148 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); |
123 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); | 149 | // Fall through !! |
124 | #endif | 150 | #endif |
125 | 151 | case OPimGlobal::XML: | |
126 | return (T*) new ODateBookAccessBackend_XML( appName ); | 152 | return (T*) new ODateBookAccessBackend_XML( appName, filename ); |
153 | break; | ||
154 | case OPimGlobal::VCARD: | ||
155 | qWarning("OBackendFactory:: VCal Backend for DATEBOOK not implemented!"); | ||
156 | return (T*) NULL; | ||
157 | break; | ||
158 | } | ||
127 | default: | 159 | default: |
128 | return (T*) NULL; | 160 | return (T*) NULL; |
129 | } | 161 | } |
130 | 162 | ||
131 | |||
132 | } | 163 | } |
133 | 164 | ||
134 | /** | 165 | /** |
135 | * Returns the style of the default database which is used to contact PIM data. | 166 | * Returns the style of the default database which is used to contact PIM data. |
136 | * @param type the type of the backend | 167 | * @param type the type of the backend |
137 | * @see OPimGlobal | 168 | * @see OPimGlobal |
138 | */ | 169 | */ |
139 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ | 170 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ |
140 | QString group_name; | 171 | QString group_name; |
141 | switch ( type ){ | 172 | switch ( type ){ |
142 | case OPimGlobal::TODOLIST: | 173 | case OPimGlobal::TODOLIST: |
143 | group_name = "todo"; | 174 | group_name = "todo"; |
144 | break; | 175 | break; |
145 | case OPimGlobal::CONTACTLIST: | 176 | case OPimGlobal::CONTACTLIST: |
146 | group_name = "contact"; | 177 | group_name = "contact"; |
147 | break; | 178 | break; |
148 | case OPimGlobal::DATEBOOK: | 179 | case OPimGlobal::DATEBOOK: |
149 | group_name = "datebook"; | 180 | group_name = "datebook"; |
150 | break; | 181 | break; |
151 | default: | 182 | default: |
152 | group_name = "unknown"; | 183 | group_name = "unknown"; |
153 | } | 184 | } |
154 | 185 | ||
155 | Config config( "pimaccess" ); | 186 | Config config( "pimaccess" ); |
156 | config.setGroup ( group_name ); | 187 | config.setGroup ( group_name ); |
157 | QString db_String = config.readEntry( "usebackend", "xml" ); | 188 | QString db_String = config.readEntry( "usebackend", "xml" ); |
158 | 189 | ||
159 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); | 190 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); |
160 | dictDbTypes.setAutoDelete( TRUE ); | 191 | dictDbTypes.setAutoDelete( TRUE ); |
161 | 192 | ||
162 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); | 193 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); |
163 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); | 194 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); |
164 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); | 195 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); |
165 | 196 | ||
166 | int* db_find = dictDbTypes[ db_String ]; | 197 | int* db_find = dictDbTypes[ db_String ]; |
167 | 198 | ||
168 | if ( !db_find ) | 199 | if ( !db_find ) |
169 | return OPimGlobal::UNKNOWN; | 200 | return OPimGlobal::UNKNOWN; |
170 | 201 | ||
171 | return (OPimGlobal::DatabaseStyle) *db_find; | 202 | return (OPimGlobal::DatabaseStyle) *db_find; |
172 | } | 203 | } |
173 | 204 | ||
174 | 205 | ||
175 | /** | 206 | /** |
176 | * Returns the default backend implementation for backendName. Which one is used, is defined | 207 | * Returns the default backend implementation for backendName. Which one is used, is defined |
177 | * by the configfile "pimaccess.conf". | 208 | * by the configfile "pimaccess.conf". |
178 | * @param backendName the type of the backend (use "todo", "contact" or "datebook" ) | 209 | * @param type The type of the backend (@see OPimGlobal()) |
179 | * @param appName The name of your application. It will be passed on to the backend | 210 | * @param appName The name of your application. It will be passed on to the backend |
180 | */ | 211 | */ |
181 | static T* defaultBackend( const QString backendName, const QString& appName ){ | 212 | static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ |
182 | 213 | return create( type, OPimGlobal::DEFAULT, appName ); | |
183 | QAsciiDict<int> dictBackends( OPimGlobal::_END_PimType ); | ||
184 | dictBackends.setAutoDelete ( TRUE ); | ||
185 | |||
186 | dictBackends.insert( "todo", new int (OPimGlobal::TODOLIST) ); | ||
187 | dictBackends.insert( "contact", new int (OPimGlobal::CONTACTLIST) ); | ||
188 | dictBackends.insert( "datebook", new int(OPimGlobal::DATEBOOK) ); | ||
189 | |||
190 | int* backend_find = dictBackends[ backendName ]; | ||
191 | if ( !backend_find ) return NULL; | ||
192 | |||
193 | OPimGlobal::DatabaseStyle style = defaultDB( static_cast<OPimGlobal::PimType>( *backend_find ) ); | ||
194 | |||
195 | qDebug( "OBackendFactory::Default -> Backend is %s, Database is %d", backendName.latin1(), | ||
196 | style ); | ||
197 | |||
198 | return create( (OPimGlobal::PimType) *backend_find, style, appName ); | ||
199 | |||
200 | } | 214 | } |
201 | private: | 215 | private: |
202 | OBackendPrivate* d; | 216 | OBackendPrivate* d; |
203 | 217 | ||
204 | }; | 218 | }; |
205 | 219 | ||
206 | } | 220 | } |
207 | 221 | ||
208 | #endif | 222 | #endif |
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index 417a954..a372267 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -1,132 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
32 | * | 32 | * |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
37 | #include "obackendfactory.h" | 37 | #include "obackendfactory.h" |
38 | 38 | ||
39 | #include <qasciidict.h> | 39 | #include <qasciidict.h> |
40 | #include <qdatetime.h> | 40 | #include <qdatetime.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qlist.h> | 43 | #include <qlist.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | //#include <qpe/qcopenvelope_qws.h> | 46 | //#include <qpe/qcopenvelope_qws.h> |
47 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
48 | 48 | ||
49 | #include <errno.h> | 49 | #include <errno.h> |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include <opie2/ocontactaccessbackend_xml.h> | 54 | #include <opie2/ocontactaccessbackend_xml.h> |
55 | #include <opie2/opimresolver.h> | 55 | #include <opie2/opimresolver.h> |
56 | #include <opie2/opimglobal.h> | ||
56 | 57 | ||
57 | namespace Opie { | 58 | namespace Opie { |
58 | 59 | ||
59 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 60 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , |
60 | OPimContactAccessBackend* end, bool autosync ): | 61 | OPimContactAccessBackend* end, bool autosync ): |
61 | OPimAccessTemplate<OPimContact>( end ) | 62 | OPimAccessTemplate<OPimContact>( end ) |
62 | { | 63 | { |
63 | /* take care of the backend. If there is no one defined, we | 64 | /* take care of the backend. If there is no one defined, we |
64 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 65 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
65 | */ | 66 | */ |
66 | if( end == 0 ) { | 67 | if( end == 0 ) { |
67 | qWarning ("Using BackendFactory !"); | 68 | qWarning ("Using BackendFactory !"); |
68 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( "contact", appname ); | 69 | end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); |
69 | } | 70 | } |
70 | // Set backend locally and in template | 71 | // Set backend locally and in template |
71 | m_backEnd = end; | 72 | m_backEnd = end; |
72 | OPimAccessTemplate<OPimContact>::setBackEnd (end); | 73 | OPimAccessTemplate<OPimContact>::setBackEnd (end); |
73 | 74 | ||
74 | 75 | ||
75 | /* Connect signal of external db change to function */ | 76 | /* Connect signal of external db change to function */ |
76 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 77 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
77 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 78 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
78 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 79 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
79 | if ( autosync ){ | 80 | if ( autosync ){ |
80 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 81 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
81 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), | 82 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
82 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); | 83 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | } | 87 | } |
87 | OPimContactAccess::~OPimContactAccess () | 88 | OPimContactAccess::~OPimContactAccess () |
88 | { | 89 | { |
89 | /* The user may forget to save the changed database, therefore try to | 90 | /* The user may forget to save the changed database, therefore try to |
90 | * do it for him.. | 91 | * do it for him.. |
91 | */ | 92 | */ |
92 | save(); | 93 | save(); |
93 | // delete m_backEnd; is done by template.. | 94 | // delete m_backEnd; is done by template.. |
94 | } | 95 | } |
95 | 96 | ||
96 | 97 | ||
97 | bool OPimContactAccess::save () | 98 | bool OPimContactAccess::save () |
98 | { | 99 | { |
99 | /* If the database was changed externally, we could not save the | 100 | /* If the database was changed externally, we could not save the |
100 | * Data. This will remove added items which is unacceptable ! | 101 | * Data. This will remove added items which is unacceptable ! |
101 | * Therefore: Reload database and merge the data... | 102 | * Therefore: Reload database and merge the data... |
102 | */ | 103 | */ |
103 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) | 104 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) |
104 | reload(); | 105 | reload(); |
105 | 106 | ||
106 | bool status = OPimAccessTemplate<OPimContact>::save(); | 107 | bool status = OPimAccessTemplate<OPimContact>::save(); |
107 | if ( !status ) return false; | 108 | if ( !status ) return false; |
108 | 109 | ||
109 | /* Now tell everyone that new data is available. | 110 | /* Now tell everyone that new data is available. |
110 | */ | 111 | */ |
111 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 112 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
112 | 113 | ||
113 | return true; | 114 | return true; |
114 | } | 115 | } |
115 | 116 | ||
116 | const uint OPimContactAccess::querySettings() | 117 | const uint OPimContactAccess::querySettings() |
117 | { | 118 | { |
118 | return ( m_backEnd->querySettings() ); | 119 | return ( m_backEnd->querySettings() ); |
119 | } | 120 | } |
120 | 121 | ||
121 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | 122 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const |
122 | { | 123 | { |
123 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 124 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
124 | } | 125 | } |
125 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 126 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
126 | { | 127 | { |
127 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 128 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
128 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); | 129 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); |
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
132 | bool OPimContactAccess::wasChangedExternally()const | 133 | bool OPimContactAccess::wasChangedExternally()const |
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp index 5f471cf..440ee0a 100644 --- a/libopie2/opiepim/core/odatebookaccess.cpp +++ b/libopie2/opiepim/core/odatebookaccess.cpp | |||
@@ -1,109 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <opie2/obackendfactory.h> | 29 | #include <opie2/obackendfactory.h> |
30 | #include <opie2/odatebookaccess.h> | 30 | #include <opie2/odatebookaccess.h> |
31 | #include <opie2/opimresolver.h> | 31 | #include <opie2/opimresolver.h> |
32 | #include <opie2/opimglobal.h> | ||
32 | 33 | ||
33 | namespace Opie { | 34 | namespace Opie { |
34 | /** | 35 | /** |
35 | * Simple constructor | 36 | * Simple constructor |
36 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation | 37 | * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation |
37 | * will be used! | 38 | * will be used! |
38 | * @param back The backend to be used or 0 for the default backend | 39 | * @param back The backend to be used or 0 for the default backend |
39 | * @param ac What kind of access is intended | 40 | * @param ac What kind of access is intended |
40 | */ | 41 | */ |
41 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) | 42 | ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) |
42 | : OPimAccessTemplate<OPimEvent>( back ) | 43 | : OPimAccessTemplate<OPimEvent>( back ) |
43 | { | 44 | { |
44 | if (!back ) | 45 | if (!back ) |
45 | back = OBackendFactory<ODateBookAccessBackend>::defaultBackend("datebook", QString::null ); | 46 | back = OBackendFactory<ODateBookAccessBackend>::defaultBackend( OPimGlobal::DATEBOOK, QString::null ); |
46 | 47 | ||
47 | m_backEnd = back; | 48 | m_backEnd = back; |
48 | setBackEnd( m_backEnd ); | 49 | setBackEnd( m_backEnd ); |
49 | } | 50 | } |
50 | ODateBookAccess::~ODateBookAccess() { | 51 | ODateBookAccess::~ODateBookAccess() { |
51 | } | 52 | } |
52 | 53 | ||
53 | /** | 54 | /** |
54 | * @return all events available | 55 | * @return all events available |
55 | */ | 56 | */ |
56 | ODateBookAccess::List ODateBookAccess::rawEvents()const { | 57 | ODateBookAccess::List ODateBookAccess::rawEvents()const { |
57 | QArray<int> ints = m_backEnd->rawEvents(); | 58 | QArray<int> ints = m_backEnd->rawEvents(); |
58 | 59 | ||
59 | List lis( ints, this ); | 60 | List lis( ints, this ); |
60 | return lis; | 61 | return lis; |
61 | } | 62 | } |
62 | 63 | ||
63 | /** | 64 | /** |
64 | * @return all repeating events | 65 | * @return all repeating events |
65 | */ | 66 | */ |
66 | ODateBookAccess::List ODateBookAccess::rawRepeats()const { | 67 | ODateBookAccess::List ODateBookAccess::rawRepeats()const { |
67 | QArray<int> ints = m_backEnd->rawRepeats(); | 68 | QArray<int> ints = m_backEnd->rawRepeats(); |
68 | 69 | ||
69 | List lis( ints, this ); | 70 | List lis( ints, this ); |
70 | return lis; | 71 | return lis; |
71 | } | 72 | } |
72 | 73 | ||
73 | /** | 74 | /** |
74 | * @return all non repeating events | 75 | * @return all non repeating events |
75 | */ | 76 | */ |
76 | ODateBookAccess::List ODateBookAccess::nonRepeats()const { | 77 | ODateBookAccess::List ODateBookAccess::nonRepeats()const { |
77 | QArray<int> ints = m_backEnd->nonRepeats(); | 78 | QArray<int> ints = m_backEnd->nonRepeats(); |
78 | 79 | ||
79 | List lis( ints, this ); | 80 | List lis( ints, this ); |
80 | return lis; | 81 | return lis; |
81 | } | 82 | } |
82 | 83 | ||
83 | /** | 84 | /** |
84 | * @return dates in the time span between from and to | 85 | * @return dates in the time span between from and to |
85 | * @param from Include all events from... | 86 | * @param from Include all events from... |
86 | * @param to Include all events to... | 87 | * @param to Include all events to... |
87 | */ | 88 | */ |
88 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { | 89 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { |
89 | return m_backEnd->effectiveEvents( from, to ); | 90 | return m_backEnd->effectiveEvents( from, to ); |
90 | } | 91 | } |
91 | /** | 92 | /** |
92 | * @return all events at a given datetime | 93 | * @return all events at a given datetime |
93 | */ | 94 | */ |
94 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { | 95 | OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { |
95 | return m_backEnd->effectiveEvents( start ); | 96 | return m_backEnd->effectiveEvents( start ); |
96 | } | 97 | } |
97 | 98 | ||
98 | /** | 99 | /** |
99 | * @return non repeating dates in the time span between from and to | 100 | * @return non repeating dates in the time span between from and to |
100 | * @param from Include all events from... | 101 | * @param from Include all events from... |
101 | * @param to Include all events to... | 102 | * @param to Include all events to... |
102 | */ | 103 | */ |
103 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { | 104 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { |
104 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); | 105 | return m_backEnd->effectiveNonRepeatingEvents( from, to ); |
105 | } | 106 | } |
106 | /** | 107 | /** |
107 | * @return all non repeating events at a given datetime | 108 | * @return all non repeating events at a given datetime |
108 | */ | 109 | */ |
109 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { | 110 | OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { |
diff --git a/libopie2/opiepim/core/opimglobal.h b/libopie2/opiepim/core/opimglobal.h index d56c9be..efd455c 100644 --- a/libopie2/opiepim/core/opimglobal.h +++ b/libopie2/opiepim/core/opimglobal.h | |||
@@ -1,64 +1,64 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #ifndef __OPIMGLOBAL_H_ | 29 | #ifndef __OPIMGLOBAL_H_ |
30 | #define __OPIMGLOBAL_H_ | 30 | #define __OPIMGLOBAL_H_ |
31 | 31 | ||
32 | namespace Opie{ | 32 | namespace Opie{ |
33 | namespace Pim{ | 33 | namespace Pim{ |
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Contains global types and enums for the PIM-API | 37 | * Contains global types and enums for the PIM-API |
38 | */ | 38 | */ |
39 | class OPimGlobal{ | 39 | class OPimGlobal{ |
40 | public: | 40 | public: |
41 | enum PimType { | 41 | enum PimType { |
42 | TODOLIST, | 42 | TODOLIST, |
43 | CONTACTLIST, | 43 | CONTACTLIST, |
44 | DATEBOOK, | 44 | DATEBOOK, |
45 | _END_PimType | 45 | _END_PimType |
46 | }; | 46 | }; |
47 | 47 | ||
48 | enum DatabaseStyle { | 48 | enum DatabaseStyle { |
49 | DEFAULT, // Use default Database | 49 | DEFAULT, // Use default Database |
50 | UNKNOWN, // Unknown database style | 50 | UNKNOWN, // Unknown database style |
51 | XML, | 51 | XML, |
52 | SQL, | 52 | SQL, |
53 | VCARD, | 53 | VCARD, // Also used for VCARD ! |
54 | _END_DatabaseStyle | 54 | _END_DatabaseStyle |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | }; | 58 | }; |
59 | 59 | ||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | #endif | 64 | #endif |
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp index 87a211f..c4adbbd 100644 --- a/libopie2/opiepim/core/otodoaccess.cpp +++ b/libopie2/opiepim/core/otodoaccess.cpp | |||
@@ -1,100 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | 30 | ||
31 | #include <qpe/alarmserver.h> | 31 | #include <qpe/alarmserver.h> |
32 | 32 | ||
33 | // #include "otodoaccesssql.h" | 33 | // #include "otodoaccesssql.h" |
34 | #include <opie2/otodoaccess.h> | 34 | #include <opie2/otodoaccess.h> |
35 | #include <opie2/obackendfactory.h> | 35 | #include <opie2/obackendfactory.h> |
36 | #include <opie2/opimresolver.h> | 36 | #include <opie2/opimresolver.h> |
37 | #include <opie2/opimglobal.h> | ||
37 | 38 | ||
38 | namespace Opie { | 39 | namespace Opie { |
39 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) | 40 | OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) |
40 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) | 41 | : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) |
41 | { | 42 | { |
42 | // if (end == 0l ) | 43 | // if (end == 0l ) |
43 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); | 44 | // m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); |
44 | 45 | ||
45 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! | 46 | // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! |
46 | if (end == 0l ) | 47 | if (end == 0l ) |
47 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend ("todo", QString::null); | 48 | m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend (OPimGlobal::TODOLIST, QString::null); |
48 | 49 | ||
49 | setBackEnd( m_todoBackEnd ); | 50 | setBackEnd( m_todoBackEnd ); |
50 | } | 51 | } |
51 | OPimTodoAccess::~OPimTodoAccess() { | 52 | OPimTodoAccess::~OPimTodoAccess() { |
52 | // qWarning("~OPimTodoAccess"); | 53 | // qWarning("~OPimTodoAccess"); |
53 | } | 54 | } |
54 | void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { | 55 | void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { |
55 | QValueList<OPimTodo>::ConstIterator it; | 56 | QValueList<OPimTodo>::ConstIterator it; |
56 | for ( it = list.begin(); it != list.end(); ++it ) { | 57 | for ( it = list.begin(); it != list.end(); ++it ) { |
57 | replace( (*it) ); | 58 | replace( (*it) ); |
58 | } | 59 | } |
59 | } | 60 | } |
60 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | 61 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, |
61 | const QDate& end, | 62 | const QDate& end, |
62 | bool includeNoDates ) { | 63 | bool includeNoDates ) { |
63 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); | 64 | QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); |
64 | 65 | ||
65 | List lis( ints, this ); | 66 | List lis( ints, this ); |
66 | return lis; | 67 | return lis; |
67 | } | 68 | } |
68 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, | 69 | OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, |
69 | bool includeNoDates ) { | 70 | bool includeNoDates ) { |
70 | return effectiveToDos( start, QDate::currentDate(), | 71 | return effectiveToDos( start, QDate::currentDate(), |
71 | includeNoDates ); | 72 | includeNoDates ); |
72 | } | 73 | } |
73 | OPimTodoAccess::List OPimTodoAccess::overDue() { | 74 | OPimTodoAccess::List OPimTodoAccess::overDue() { |
74 | List lis( m_todoBackEnd->overDue(), this ); | 75 | List lis( m_todoBackEnd->overDue(), this ); |
75 | return lis; | 76 | return lis; |
76 | } | 77 | } |
77 | /* sort order */ | 78 | /* sort order */ |
78 | OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { | 79 | OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { |
79 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, | 80 | QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, |
80 | filter, cat ); | 81 | filter, cat ); |
81 | OPimTodoAccess::List list( ints, this ); | 82 | OPimTodoAccess::List list( ints, this ); |
82 | return list; | 83 | return list; |
83 | } | 84 | } |
84 | void OPimTodoAccess::removeAllCompleted() { | 85 | void OPimTodoAccess::removeAllCompleted() { |
85 | m_todoBackEnd->removeAllCompleted(); | 86 | m_todoBackEnd->removeAllCompleted(); |
86 | } | 87 | } |
87 | QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ | 88 | QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ |
88 | return m_todoBackEnd->supports(); | 89 | return m_todoBackEnd->supports(); |
89 | } | 90 | } |
90 | bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ | 91 | bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ |
91 | return backendSupport(ar).testBit( attr ); | 92 | return backendSupport(ar).testBit( attr ); |
92 | } | 93 | } |
93 | 94 | ||
94 | 95 | ||
95 | int OPimTodoAccess::rtti() const | 96 | int OPimTodoAccess::rtti() const |
96 | { | 97 | { |
97 | return OPimResolver::TodoList; | 98 | return OPimResolver::TodoList; |
98 | } | 99 | } |
99 | 100 | ||
100 | } | 101 | } |