-rw-r--r-- | library/backend/categories.cpp | 319 | ||||
-rw-r--r-- | library/backend/contact.cpp | 526 | ||||
-rw-r--r-- | library/backend/contact.h | 102 | ||||
-rw-r--r-- | library/backend/event.cpp | 501 | ||||
-rw-r--r-- | library/backend/event.h | 173 | ||||
-rw-r--r-- | library/backend/palmtoprecord.cpp | 42 | ||||
-rw-r--r-- | library/backend/palmtoprecord.h | 33 | ||||
-rw-r--r-- | library/backend/palmtopuidgen.h | 26 | ||||
-rw-r--r-- | library/backend/qfiledirect_p.h | 20 | ||||
-rw-r--r-- | library/backend/qpcglobal.h | 9 | ||||
-rw-r--r-- | library/backend/recordfields.h | 24 | ||||
-rw-r--r-- | library/backend/stringutil.cpp | 415 | ||||
-rw-r--r-- | library/backend/stringutil.h | 57 | ||||
-rw-r--r-- | library/backend/task.cpp | 167 | ||||
-rw-r--r-- | library/backend/task.h | 21 | ||||
-rw-r--r-- | library/backend/timeconversion.cpp | 237 | ||||
-rw-r--r-- | library/backend/timeconversion.h | 45 | ||||
-rw-r--r-- | library/backend/vcc.y | 103 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 167 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 104 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 4 |
21 files changed, 2048 insertions, 1047 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index 6e011c4..e37b3b9 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp | |||
@@ -1,48 +1,65 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** in the packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | 13 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | #include "categories.h" | 20 | #include <qtopia/categories.h> |
21 | #include <qtopia/stringutil.h> | ||
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcstring.h> | 23 | #include <qcstring.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | #include "stringutil.h" | ||
26 | 25 | ||
27 | using namespace Qtopia; | 26 | using namespace Qtopia; |
28 | 27 | ||
29 | /*********************************************************** | 28 | /*********************************************************** |
30 | * | 29 | * |
31 | * CategoryGroup | 30 | * CategoryGroup |
32 | * | 31 | * |
33 | **********************************************************/ | 32 | **********************************************************/ |
34 | 33 | ||
35 | #ifdef PALMTOPCENTER | 34 | #ifdef PALMTOPCENTER |
36 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); | 35 | UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter ); |
37 | #else | 36 | #else |
38 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); | 37 | UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); |
39 | #endif | 38 | #endif |
40 | 39 | ||
40 | /*! \class CategoryGroup categories.h | ||
41 | \brief Helper class that is used by Categories | ||
42 | |||
43 | CategoryGroup is a group of categories that is associated with an | ||
44 | application or global set. Mainly it defines a map of ids to | ||
45 | category labels and category labels to ids. Lookups can be done with | ||
46 | labels or unique idenifiers. | ||
47 | |||
48 | \ingroup qtopiaemb | ||
49 | \ingroup qtopiadesktop | ||
50 | \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 | ||
51 | \sa Categories::appGroupMap(), Categories::globalGroup() | ||
52 | */ | ||
53 | |||
54 | /*! Add \a label and return the UID. If failure, then 0 is returned. Note | ||
55 | that All and Unfiled are reserved labels. | ||
56 | \internal | ||
57 | */ | ||
41 | int CategoryGroup::add( const QString &label ) | 58 | int CategoryGroup::add( const QString &label ) |
42 | { | 59 | { |
43 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 60 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
44 | return 0; | 61 | return 0; |
45 | 62 | ||
46 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 63 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
47 | if ( findIt != mLabelIdMap.end() ) | 64 | if ( findIt != mLabelIdMap.end() ) |
48 | return 0; | 65 | return 0; |
@@ -53,117 +70,133 @@ int CategoryGroup::add( const QString &label ) | |||
53 | 70 | ||
54 | void CategoryGroup::insert( int uid, const QString &label ) | 71 | void CategoryGroup::insert( int uid, const QString &label ) |
55 | { | 72 | { |
56 | uidGen().store( uid ); | 73 | uidGen().store( uid ); |
57 | mIdLabelMap[uid] = label; | 74 | mIdLabelMap[uid] = label; |
58 | mLabelIdMap[label] = uid; | 75 | mLabelIdMap[label] = uid; |
59 | } | 76 | } |
60 | 77 | ||
78 | /*! \internal | ||
79 | */ | ||
61 | bool CategoryGroup::add( int uid, const QString &label ) | 80 | bool CategoryGroup::add( int uid, const QString &label ) |
62 | { | 81 | { |
63 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) | 82 | if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) |
64 | return FALSE; | 83 | return FALSE; |
65 | 84 | ||
66 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 85 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
67 | if ( labelIt != mLabelIdMap.end() ) | 86 | if ( labelIt != mLabelIdMap.end() ) |
68 | return FALSE; | 87 | return FALSE; |
69 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 88 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
70 | if ( idIt != mIdLabelMap.end() ) | 89 | if ( idIt != mIdLabelMap.end() ) |
71 | return FALSE; | 90 | return FALSE; |
72 | insert( uid, label ); | 91 | insert( uid, label ); |
73 | return TRUE; | 92 | return TRUE; |
74 | } | 93 | } |
75 | 94 | ||
95 | /*! Returns TRUE if \a label was removed from the group, FALSE if not. | ||
96 | \internal | ||
97 | */ | ||
76 | bool CategoryGroup::remove( const QString &label ) | 98 | bool CategoryGroup::remove( const QString &label ) |
77 | { | 99 | { |
78 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); | 100 | QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); |
79 | if ( findIt == mLabelIdMap.end() ) | 101 | if ( findIt == mLabelIdMap.end() ) |
80 | return FALSE; | 102 | return FALSE; |
81 | 103 | ||
82 | mIdLabelMap.remove( *findIt ); | 104 | mIdLabelMap.remove( *findIt ); |
83 | mLabelIdMap.remove( findIt ); | 105 | mLabelIdMap.remove( findIt ); |
84 | 106 | ||
85 | return TRUE; | 107 | return TRUE; |
86 | } | 108 | } |
87 | 109 | ||
110 | /*! Returns TRUE if \a uid was removed from the group, FALSE if not. | ||
111 | \internal | ||
112 | */ | ||
88 | bool CategoryGroup::remove( int uid ) | 113 | bool CategoryGroup::remove( int uid ) |
89 | { | 114 | { |
90 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); | 115 | QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); |
91 | if ( idIt == mIdLabelMap.end() ) | 116 | if ( idIt == mIdLabelMap.end() ) |
92 | return FALSE; | 117 | return FALSE; |
93 | 118 | ||
94 | mLabelIdMap.remove( *idIt ); | 119 | mLabelIdMap.remove( *idIt ); |
95 | mIdLabelMap.remove( idIt ); | 120 | mIdLabelMap.remove( idIt ); |
96 | 121 | ||
97 | return TRUE; | 122 | return TRUE; |
98 | } | 123 | } |
99 | 124 | ||
125 | /*! \internal | ||
126 | */ | ||
100 | bool CategoryGroup::rename( int uid, const QString &newLabel ) | 127 | bool CategoryGroup::rename( int uid, const QString &newLabel ) |
101 | { | 128 | { |
102 | if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) | 129 | if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) |
103 | return FALSE; | 130 | return FALSE; |
104 | 131 | ||
105 | QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid ); | 132 | QMap<int, QString>::Iterator idIt = mIdLabelMap.find( uid ); |
106 | if ( idIt == mIdLabelMap.end() ) | 133 | if ( idIt == mIdLabelMap.end() ) |
107 | return FALSE; | 134 | return FALSE; |
108 | 135 | ||
109 | mLabelIdMap.remove( *idIt ); | 136 | mLabelIdMap.remove( *idIt ); |
110 | mLabelIdMap[newLabel] = uid; | 137 | mLabelIdMap[newLabel] = uid; |
111 | *idIt = newLabel; | 138 | *idIt = newLabel; |
112 | 139 | ||
113 | return TRUE; | 140 | return TRUE; |
114 | } | 141 | } |
115 | 142 | ||
143 | /*! \internal | ||
144 | */ | ||
116 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) | 145 | bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) |
117 | { | 146 | { |
118 | return rename( id(oldLabel), newLabel ); | 147 | return rename( id(oldLabel), newLabel ); |
119 | } | 148 | } |
120 | 149 | ||
150 | /*! Returns TRUE if \a uid is stored in this group, FALSE if not. */ | ||
121 | bool CategoryGroup::contains(int uid) const | 151 | bool CategoryGroup::contains(int uid) const |
122 | { | 152 | { |
123 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); | 153 | return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); |
124 | } | 154 | } |
125 | 155 | ||
156 | /*! Returns TRUE if \a label is stored in this group, FALSE if not. */ | ||
126 | bool CategoryGroup::contains(const QString &label) const | 157 | bool CategoryGroup::contains(const QString &label) const |
127 | { | 158 | { |
128 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); | 159 | return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); |
129 | } | 160 | } |
130 | 161 | ||
131 | /** Returns label associated with the uid or QString::null if | 162 | /*! Returns label associated with the \a uid or QString::null if |
132 | * not found | 163 | not found |
133 | */ | 164 | */ |
134 | const QString &CategoryGroup::label(int uid) const | 165 | const QString &CategoryGroup::label(int uid) const |
135 | { | 166 | { |
136 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); | 167 | QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); |
137 | if ( idIt == mIdLabelMap.end() ) | 168 | if ( idIt == mIdLabelMap.end() ) |
138 | return QString::null; | 169 | return QString::null; |
139 | return *idIt; | 170 | return *idIt; |
140 | } | 171 | } |
141 | 172 | ||
142 | /** Returns the uid associated with label or 0 if not found */ | 173 | /*! Returns the uid associated with \a label or 0 if not found */ |
143 | int CategoryGroup::id(const QString &label) const | 174 | int CategoryGroup::id(const QString &label) const |
144 | { | 175 | { |
145 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); | 176 | QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); |
146 | if ( labelIt == mLabelIdMap.end() ) | 177 | if ( labelIt == mLabelIdMap.end() ) |
147 | return 0; | 178 | return 0; |
148 | return *labelIt; | 179 | return *labelIt; |
149 | } | 180 | } |
150 | 181 | ||
182 | /*! Returns a list of all labels stored in this group. */ | ||
151 | QStringList CategoryGroup::labels() const | 183 | QStringList CategoryGroup::labels() const |
152 | { | 184 | { |
153 | QStringList labels; | 185 | QStringList labels; |
154 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 186 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
155 | it != mIdLabelMap.end(); ++it ) | 187 | it != mIdLabelMap.end(); ++it ) |
156 | labels += *it; | 188 | labels += *it; |
157 | // ### I don't think this is the place for this... | 189 | // ### I don't think this is the place for this... |
158 | // labels.sort(); | 190 | // labels.sort(); |
159 | return labels; | 191 | return labels; |
160 | } | 192 | } |
161 | 193 | ||
194 | /*! Returns a list of all labels associated with the \a catids */ | ||
162 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const | 195 | QStringList CategoryGroup::labels(const QArray<int> &catids ) const |
163 | { | 196 | { |
164 | QStringList labels; | 197 | QStringList labels; |
165 | if ( catids.count() == 0 ) | 198 | if ( catids.count() == 0 ) |
166 | return labels; | 199 | return labels; |
167 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); | 200 | for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); |
168 | it != mIdLabelMap.end(); ++it ) | 201 | it != mIdLabelMap.end(); ++it ) |
169 | if ( catids.find( it.key() ) != -1 ) | 202 | if ( catids.find( it.key() ) != -1 ) |
@@ -172,18 +205,58 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const | |||
172 | } | 205 | } |
173 | 206 | ||
174 | /*********************************************************** | 207 | /*********************************************************** |
175 | * | 208 | * |
176 | * Categories | 209 | * Categories |
177 | * | 210 | * |
178 | **********************************************************/ | 211 | **********************************************************/ |
179 | 212 | ||
180 | /** Add the category name as long as it doesn't already exist locally | 213 | /*! |
181 | * or globally. Return TRUE if added, FALSE if conflicts. | 214 | \class Categories categories.h |
215 | \brief The Categories class is a database that groups categories and maps ids to names. | ||
216 | |||
217 | The Categories class is the low level Categories accessor class. To | ||
218 | add a category menu and filter for your application, see CategoryMenu. | ||
219 | |||
220 | The Categories class allows the developer to add, remove, and rename | ||
221 | categories. Categories can be created for an individual application | ||
222 | such as Todo List or to be used for all applications. Categories | ||
223 | that can be used by all applications are called global | ||
224 | categories. Each PalmtopRecord subclass stores categories as an | ||
225 | QArray<int> using PalmtopRecord::setCategories() and | ||
226 | PalmtopRecord::categories(). This allows each record to be assigned | ||
227 | to multiple categories. This also allows the user to rename a | ||
228 | category and for it to update automatically in all records. | ||
229 | |||
230 | This class provides several methods to convert between a category id | ||
231 | and it's associated string such as id(), ids(), label() and labels(). A | ||
232 | helper class called CategoryGroup is used to access categories of a | ||
233 | single application group, such as Todo List. Global categories can | ||
234 | also be accessed via CategoryGroup objects. See appGroupMap() and | ||
235 | globalGroup() for the appropriate accessor methods. | ||
236 | |||
237 | Categories are stored in an xml file in the Settings directory | ||
238 | (Categories.xml). A global function called categoryFileName() will | ||
239 | return to appropriate QString file location to be passed to load() | ||
240 | and save() for the master categories database. | ||
241 | |||
242 | \ingroup qtopiaemb | ||
243 | \ingroup qtopiadesktop | ||
244 | \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 | ||
245 | \sa CategoryGroup, CategoryMenu | ||
246 | */ | ||
247 | |||
248 | |||
249 | /*! | ||
250 | Add the category name as long as it doesn't already exist locally or | ||
251 | globally. The \a uid is assigned to the category if successfully | ||
252 | added. Return \a uid if added, 0 if conflicts (error). | ||
253 | |||
254 | \internal | ||
182 | */ | 255 | */ |
183 | int Categories::addCategory( const QString &appname, | 256 | int Categories::addCategory( const QString &appname, |
184 | const QString &catname, | 257 | const QString &catname, |
185 | int uid ) | 258 | int uid ) |
186 | { | 259 | { |
187 | if ( mGlobalCats.contains(catname) ) | 260 | if ( mGlobalCats.contains(catname) ) |
188 | return 0; | 261 | return 0; |
189 | 262 | ||
@@ -199,16 +272,21 @@ int Categories::addCategory( const QString &appname, | |||
199 | } | 272 | } |
200 | 273 | ||
201 | CategoryGroup &cats = *appIt; | 274 | CategoryGroup &cats = *appIt; |
202 | cats.add( uid, catname ); | 275 | cats.add( uid, catname ); |
203 | emit categoryAdded( *this, appname, uid ); | 276 | emit categoryAdded( *this, appname, uid ); |
204 | return uid; | 277 | return uid; |
205 | } | 278 | } |
206 | 279 | ||
280 | /*! | ||
281 | Add the category name as long as it doesn't already exist locally or | ||
282 | globally. Return UID if added, 0 if conflicts (error). | ||
283 | */ | ||
284 | |||
207 | int Categories::addCategory( const QString &appname, | 285 | int Categories::addCategory( const QString &appname, |
208 | const QString &catname ) | 286 | const QString &catname ) |
209 | { | 287 | { |
210 | if ( mGlobalCats.contains(catname) ) | 288 | if ( mGlobalCats.contains(catname) ) |
211 | return 0; | 289 | return 0; |
212 | 290 | ||
213 | QMap< QString, CategoryGroup >::Iterator | 291 | QMap< QString, CategoryGroup >::Iterator |
214 | appIt = mAppCats.find( appname ); | 292 | appIt = mAppCats.find( appname ); |
@@ -224,35 +302,46 @@ int Categories::addCategory( const QString &appname, | |||
224 | CategoryGroup &cats = *appIt; | 302 | CategoryGroup &cats = *appIt; |
225 | int uid = cats.add( catname ); | 303 | int uid = cats.add( catname ); |
226 | if ( !uid ) | 304 | if ( !uid ) |
227 | return 0; | 305 | return 0; |
228 | emit categoryAdded( *this, appname, uid ); | 306 | emit categoryAdded( *this, appname, uid ); |
229 | return uid; | 307 | return uid; |
230 | } | 308 | } |
231 | 309 | ||
310 | /*! | ||
311 | \internal | ||
312 | */ | ||
232 | int Categories::addGlobalCategory( const QString &catname, int uid ) | 313 | int Categories::addGlobalCategory( const QString &catname, int uid ) |
233 | { | 314 | { |
234 | mGlobalCats.add( uid, catname ); | 315 | mGlobalCats.add( uid, catname ); |
235 | emit categoryAdded( *this, QString::null, uid ); | 316 | emit categoryAdded( *this, QString::null, uid ); |
236 | return uid; | 317 | return uid; |
237 | } | 318 | } |
238 | 319 | ||
320 | /*! | ||
321 | Add the global category \a catname while checking that it doesn't | ||
322 | already exist globally. Return UID if added, 0 if conflicts. | ||
323 | |||
324 | \sa addCategory() | ||
325 | */ | ||
239 | int Categories::addGlobalCategory( const QString &catname ) | 326 | int Categories::addGlobalCategory( const QString &catname ) |
240 | { | 327 | { |
241 | int uid = mGlobalCats.add( catname ); | 328 | int uid = mGlobalCats.add( catname ); |
242 | if ( !uid ) | 329 | if ( !uid ) |
243 | return 0; | 330 | return 0; |
244 | emit categoryAdded( *this, QString::null, uid ); | 331 | emit categoryAdded( *this, QString::null, uid ); |
245 | return uid; | 332 | return uid; |
246 | } | 333 | } |
247 | 334 | ||
248 | /** Removes the category from the application; if it is not found | 335 | /*! |
249 | * in the application, then it attempts to remove it from | 336 | |
250 | * the global list | 337 | Removes the \a catname from the application group. If it is not |
338 | found in the application group and \a checkGlobal is TRUE, then it | ||
339 | attempts to remove it from the global list | ||
251 | */ | 340 | */ |
252 | bool Categories::removeCategory( const QString &appname, | 341 | bool Categories::removeCategory( const QString &appname, |
253 | const QString &catname, | 342 | const QString &catname, |
254 | bool checkGlobal ) | 343 | bool checkGlobal ) |
255 | { | 344 | { |
256 | QMap< QString, CategoryGroup >::Iterator | 345 | QMap< QString, CategoryGroup >::Iterator |
257 | appIt = mAppCats.find( appname ); | 346 | appIt = mAppCats.find( appname ); |
258 | if ( appIt != mAppCats.end() ) { | 347 | if ( appIt != mAppCats.end() ) { |
@@ -263,65 +352,78 @@ bool Categories::removeCategory( const QString &appname, | |||
263 | return TRUE; | 352 | return TRUE; |
264 | } | 353 | } |
265 | } | 354 | } |
266 | if ( !checkGlobal ) | 355 | if ( !checkGlobal ) |
267 | return FALSE; | 356 | return FALSE; |
268 | return removeGlobalCategory( catname ); | 357 | return removeGlobalCategory( catname ); |
269 | } | 358 | } |
270 | 359 | ||
360 | |||
361 | /*! | ||
362 | Removes the \a uid from the application group \a appname. Returns TRUE | ||
363 | if success, FALSE if not found. | ||
364 | */ | ||
271 | bool Categories::removeCategory( const QString &appname, int uid ) | 365 | bool Categories::removeCategory( const QString &appname, int uid ) |
272 | { | 366 | { |
273 | QMap< QString, CategoryGroup >::Iterator | 367 | QMap< QString, CategoryGroup >::Iterator |
274 | appIt = mAppCats.find( appname ); | 368 | appIt = mAppCats.find( appname ); |
275 | if ( appIt != mAppCats.end() ) { | 369 | if ( appIt != mAppCats.end() ) { |
276 | CategoryGroup &cats = *appIt; | 370 | CategoryGroup &cats = *appIt; |
277 | if ( cats.remove( uid ) ) { | 371 | if ( cats.remove( uid ) ) { |
278 | emit categoryRemoved( *this, appname, uid ); | 372 | emit categoryRemoved( *this, appname, uid ); |
279 | return TRUE; | 373 | return TRUE; |
280 | } | 374 | } |
281 | } | 375 | } |
282 | return FALSE; | 376 | return FALSE; |
283 | } | 377 | } |
284 | 378 | ||
379 | /*! | ||
380 | Removes the global category \a catname. Returns TRUE | ||
381 | if success, FALSE if not found. | ||
382 | */ | ||
285 | bool Categories::removeGlobalCategory( const QString &catname ) | 383 | bool Categories::removeGlobalCategory( const QString &catname ) |
286 | { | 384 | { |
287 | int uid = mGlobalCats.id( catname ); | 385 | int uid = mGlobalCats.id( catname ); |
288 | if ( mGlobalCats.remove( uid ) ) { | 386 | if ( mGlobalCats.remove( uid ) ) { |
289 | emit categoryRemoved( *this, QString::null, uid ); | 387 | emit categoryRemoved( *this, QString::null, uid ); |
290 | return TRUE; | 388 | return TRUE; |
291 | } | 389 | } |
292 | return FALSE; | 390 | return FALSE; |
293 | } | 391 | } |
294 | 392 | ||
295 | 393 | /*! | |
394 | Removes the global category \a uid. Returns TRUE | ||
395 | if success, FALSE if not found. | ||
396 | */ | ||
296 | bool Categories::removeGlobalCategory( int uid ) | 397 | bool Categories::removeGlobalCategory( int uid ) |
297 | { | 398 | { |
298 | if ( mGlobalCats.remove( uid ) ) { | 399 | if ( mGlobalCats.remove( uid ) ) { |
299 | emit categoryRemoved( *this, QString::null, uid ); | 400 | emit categoryRemoved( *this, QString::null, uid ); |
300 | return TRUE; | 401 | return TRUE; |
301 | } | 402 | } |
302 | return FALSE; | 403 | return FALSE; |
303 | } | 404 | } |
304 | 405 | ||
305 | /** Returns the sorted list of all categories that are associated with | 406 | /*! |
306 | * the app. If includeGlobal parameter is TRUE then the returned | 407 | Returns the sorted list of all categories that are associated with |
307 | * categories will include the global category items. | 408 | the \a app. If \a includeGlobal is TRUE then the returned |
409 | categories will include the global category items. | ||
308 | */ | 410 | */ |
309 | QStringList Categories::labels( const QString &app, | 411 | QStringList Categories::labels( const QString &app, |
310 | bool includeGlobal, | 412 | bool includeGlobal, |
311 | ExtraLabels extra ) const | 413 | ExtraLabels extra ) const |
312 | { | 414 | { |
313 | QMap< QString, CategoryGroup >::ConstIterator | 415 | QMap< QString, CategoryGroup >::ConstIterator |
314 | appIt = mAppCats.find( app ); | 416 | appIt = mAppCats.find( app ); |
315 | QStringList cats; | 417 | QStringList cats; |
316 | 418 | ||
317 | if ( appIt != mAppCats.end() ) | 419 | if ( appIt != mAppCats.end() ) |
318 | cats += (*appIt).labels(); | 420 | cats += (*appIt).labels(); |
319 | else qDebug("Categories::labels didn't find app %s", app.latin1() ); | 421 | //else qDebug("Categories::labels didn't find app %s", app.latin1() ); |
320 | if ( includeGlobal ) | 422 | if ( includeGlobal ) |
321 | cats += mGlobalCats.labels(); | 423 | cats += mGlobalCats.labels(); |
322 | 424 | ||
323 | cats.sort(); | 425 | cats.sort(); |
324 | switch ( extra ) { | 426 | switch ( extra ) { |
325 | case NoExtra: break; | 427 | case NoExtra: break; |
326 | case AllUnfiled: | 428 | case AllUnfiled: |
327 | cats.append( tr("All") ); | 429 | cats.append( tr("All") ); |
@@ -333,31 +435,40 @@ QStringList Categories::labels( const QString &app, | |||
333 | case UnfiledLabel: | 435 | case UnfiledLabel: |
334 | cats.append( tr("Unfiled") ); | 436 | cats.append( tr("Unfiled") ); |
335 | break; | 437 | break; |
336 | } | 438 | } |
337 | 439 | ||
338 | return cats; | 440 | return cats; |
339 | } | 441 | } |
340 | 442 | ||
443 | /*! | ||
444 | Returns the label associated with the id | ||
445 | */ | ||
341 | QString Categories::label( const QString &app, int id ) const | 446 | QString Categories::label( const QString &app, int id ) const |
342 | { | 447 | { |
343 | if ( mGlobalCats.contains( id ) ) | 448 | if ( mGlobalCats.contains( id ) ) |
344 | return mGlobalCats.label( id ); | 449 | return mGlobalCats.label( id ); |
345 | QMap< QString, CategoryGroup >::ConstIterator | 450 | QMap< QString, CategoryGroup >::ConstIterator |
346 | appIt = mAppCats.find( app ); | 451 | appIt = mAppCats.find( app ); |
347 | if ( appIt == mAppCats.end() ) | 452 | if ( appIt == mAppCats.end() ) |
348 | return QString::null; | 453 | return QString::null; |
349 | return (*appIt).label( id ); | 454 | return (*appIt).label( id ); |
350 | } | 455 | } |
351 | 456 | ||
352 | /** Returns a single string associated with the cat ids for display in | 457 | /*! |
353 | * a combobox or any area that requires one string. If catids are empty | 458 | Returns a single string associated with \a catids for display in a |
354 | * then "Unfiled" will be returned. If multiple categories are assigned | 459 | combobox or any area that requires one string. If \a catids are empty |
355 | * the first cat id is shown with " (multi)" appended to the string. | 460 | then "Unfiled" will be returned. If multiple categories are |
461 | assigned then the behavior depends on the DisplaySingle type. | ||
462 | |||
463 | If \a display is set to ShowMulti then " (multi)" appended to the | ||
464 | first string. If \a display is set to ShowAll, then a space | ||
465 | seperated string is returned with all categories. If ShowFirst is | ||
466 | set, the just the first string is returned. | ||
356 | */ | 467 | */ |
357 | QString Categories::displaySingle( const QString &app, | 468 | QString Categories::displaySingle( const QString &app, |
358 | const QArray<int> &catids, | 469 | const QArray<int> &catids, |
359 | DisplaySingle display ) const | 470 | DisplaySingle display ) const |
360 | { | 471 | { |
361 | QStringList strs = labels( app, catids ); | 472 | QStringList strs = labels( app, catids ); |
362 | if ( !strs.count() ) | 473 | if ( !strs.count() ) |
363 | return tr("Unfiled"); | 474 | return tr("Unfiled"); |
@@ -375,16 +486,21 @@ QString Categories::displaySingle( const QString &app, | |||
375 | r = strs.join(" "); | 486 | r = strs.join(" "); |
376 | break; | 487 | break; |
377 | } | 488 | } |
378 | } | 489 | } |
379 | else r = strs.first(); | 490 | else r = strs.first(); |
380 | return r; | 491 | return r; |
381 | } | 492 | } |
382 | 493 | ||
494 | /*! | ||
495 | |||
496 | Returns all ids associated with the application CategoryGroup \a app | ||
497 | and the passed in \a labels in that group. | ||
498 | */ | ||
383 | QArray<int> Categories::ids( const QString &app, const QStringList &labels) const | 499 | QArray<int> Categories::ids( const QString &app, const QStringList &labels) const |
384 | { | 500 | { |
385 | QArray<int> results; | 501 | QArray<int> results; |
386 | QStringList::ConstIterator it; | 502 | QStringList::ConstIterator it; |
387 | int i; | 503 | int i; |
388 | 504 | ||
389 | for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { | 505 | for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { |
390 | int value = id( app, *it ); | 506 | int value = id( app, *it ); |
@@ -392,29 +508,39 @@ QArray<int> Categories::ids( const QString &app, const QStringList &labels) cons | |||
392 | int tmp = results.size(); | 508 | int tmp = results.size(); |
393 | results.resize( tmp + 1 ); | 509 | results.resize( tmp + 1 ); |
394 | results[ tmp ] = value; | 510 | results[ tmp ] = value; |
395 | } | 511 | } |
396 | } | 512 | } |
397 | return results; | 513 | return results; |
398 | } | 514 | } |
399 | 515 | ||
516 | /*! | ||
517 | Returns the id associated with the app. If the id is not found in the | ||
518 | application CategoryGroup, then it searches the global CategoryGroup. | ||
519 | If it is not found it either, 0 is returned. | ||
520 | */ | ||
400 | int Categories::id( const QString &app, const QString &cat ) const | 521 | int Categories::id( const QString &app, const QString &cat ) const |
401 | { | 522 | { |
402 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) | 523 | if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) |
403 | return 0; | 524 | return 0; |
404 | int uid = mGlobalCats.id( cat ); | 525 | int uid = mGlobalCats.id( cat ); |
405 | if ( uid != 0 ) | 526 | if ( uid != 0 ) |
406 | return uid; | 527 | return uid; |
407 | return mAppCats[app].id( cat ); | 528 | return mAppCats[app].id( cat ); |
408 | } | 529 | } |
409 | 530 | ||
410 | 531 | ||
411 | /** Return TRUE if renaming succeeded; FALSE if app name not found, | 532 | /*! |
412 | * or if there was a name conflict | 533 | Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName |
534 | is not found, or if \a newName conflicts with an existing category | ||
535 | in the CategoryGroup. | ||
536 | |||
537 | It will first search the CategoryGroup associated with \a appname | ||
538 | and if not found it will try to replace in global CategoryGroup. | ||
413 | */ | 539 | */ |
414 | bool Categories::renameCategory( const QString &appname, | 540 | bool Categories::renameCategory( const QString &appname, |
415 | const QString &oldName, | 541 | const QString &oldName, |
416 | const QString &newName ) | 542 | const QString &newName ) |
417 | { | 543 | { |
418 | QMap< QString, CategoryGroup >::Iterator | 544 | QMap< QString, CategoryGroup >::Iterator |
419 | appIt = mAppCats.find( appname ); | 545 | appIt = mAppCats.find( appname ); |
420 | 546 | ||
@@ -424,27 +550,37 @@ bool Categories::renameCategory( const QString &appname, | |||
424 | if ( id != 0 && cats.rename( id, newName ) ) { | 550 | if ( id != 0 && cats.rename( id, newName ) ) { |
425 | emit categoryRenamed( *this, appname, id ); | 551 | emit categoryRenamed( *this, appname, id ); |
426 | return TRUE; | 552 | return TRUE; |
427 | } | 553 | } |
428 | } | 554 | } |
429 | return renameGlobalCategory( oldName, newName ); | 555 | return renameGlobalCategory( oldName, newName ); |
430 | } | 556 | } |
431 | 557 | ||
558 | /*! | ||
559 | Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName | ||
560 | is not found, or if \a newName conflicts with an existing category | ||
561 | in the CategoryGroup. This function will only rename categories found | ||
562 | in the global CategoryGroup. | ||
563 | */ | ||
432 | bool Categories::renameGlobalCategory( const QString &oldName, | 564 | bool Categories::renameGlobalCategory( const QString &oldName, |
433 | const QString &newName ) | 565 | const QString &newName ) |
434 | { | 566 | { |
435 | int uid = mGlobalCats.id( oldName ); | 567 | int uid = mGlobalCats.id( oldName ); |
436 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { | 568 | if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { |
437 | emit categoryRenamed( *this, QString::null, uid ); | 569 | emit categoryRenamed( *this, QString::null, uid ); |
438 | return TRUE; | 570 | return TRUE; |
439 | } | 571 | } |
440 | return FALSE; | 572 | return FALSE; |
441 | } | 573 | } |
442 | 574 | ||
575 | /*! | ||
576 | Changes the grouping of a category. If a category was global and \a global | ||
577 | is set to TRUE, then the \a catname will be moved to the \a appname group. | ||
578 | */ | ||
443 | void Categories::setGlobal( const QString &appname, | 579 | void Categories::setGlobal( const QString &appname, |
444 | const QString &catname, | 580 | const QString &catname, |
445 | bool global ) | 581 | bool global ) |
446 | { | 582 | { |
447 | // if in global and should be in app; then move it | 583 | // if in global and should be in app; then move it |
448 | if ( mGlobalCats.contains( catname ) && !global ) { | 584 | if ( mGlobalCats.contains( catname ) && !global ) { |
449 | mGlobalCats.remove( catname ); | 585 | mGlobalCats.remove( catname ); |
450 | addCategory( appname, catname ); | 586 | addCategory( appname, catname ); |
@@ -453,49 +589,63 @@ void Categories::setGlobal( const QString &appname, | |||
453 | 589 | ||
454 | // if in app and should be in global, then move it | 590 | // if in app and should be in global, then move it |
455 | if ( !global ) | 591 | if ( !global ) |
456 | return; | 592 | return; |
457 | if ( removeCategory( appname, catname, FALSE ) ) | 593 | if ( removeCategory( appname, catname, FALSE ) ) |
458 | addGlobalCategory( catname ); | 594 | addGlobalCategory( catname ); |
459 | } | 595 | } |
460 | 596 | ||
597 | /*! | ||
598 | Returns TRUE if the \a catname is in the global CategoryGroup, FALSE if not. | ||
599 | */ | ||
461 | bool Categories::isGlobal( const QString &catname ) const | 600 | bool Categories::isGlobal( const QString &catname ) const |
462 | { | 601 | { |
463 | return mGlobalCats.contains( catname ); | 602 | return mGlobalCats.contains( catname ); |
464 | } | 603 | } |
465 | 604 | ||
466 | 605 | ||
467 | /** Returns true if the catname is associated with any application | 606 | /*! |
607 | Returns true if the \a catname is associated with any CategoryGroup, | ||
608 | including global. | ||
468 | */ | 609 | */ |
469 | bool Categories::exists( const QString &catname ) const | 610 | bool Categories::exists( const QString &catname ) const |
470 | { | 611 | { |
471 | if ( isGlobal(catname) ) | 612 | if ( isGlobal(catname) ) |
472 | return TRUE; | 613 | return TRUE; |
473 | 614 | ||
474 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) | 615 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) |
475 | if ( exists( appsIt.key(), catname ) ) | 616 | if ( exists( appsIt.key(), catname ) ) |
476 | return TRUE; | 617 | return TRUE; |
477 | 618 | ||
478 | return FALSE; | 619 | return FALSE; |
479 | } | 620 | } |
480 | 621 | ||
622 | /*! | ||
623 | Returns TRUE if the \a catname is associated with the \a appname | ||
624 | CategoryGroup, FALSE if not found. | ||
625 | */ | ||
481 | bool Categories::exists( const QString &appname, | 626 | bool Categories::exists( const QString &appname, |
482 | const QString &catname) const | 627 | const QString &catname) const |
483 | { | 628 | { |
484 | QMap< QString, CategoryGroup >::ConstIterator | 629 | QMap< QString, CategoryGroup >::ConstIterator |
485 | appIt = mAppCats.find( appname ); | 630 | appIt = mAppCats.find( appname ); |
486 | 631 | ||
487 | if ( appIt == mAppCats.end() ) | 632 | if ( appIt == mAppCats.end() ) |
488 | return FALSE; | 633 | return FALSE; |
489 | 634 | ||
490 | return (*appIt).contains( catname ); | 635 | return (*appIt).contains( catname ); |
491 | } | 636 | } |
492 | 637 | ||
638 | /*! | ||
639 | Saves the Categories database to the \a fname. See categoryFileName() | ||
640 | for the default file name string used for the shared category database. | ||
493 | 641 | ||
642 | Returns FALSE if there is error writing the file or TRUE on success. | ||
643 | */ | ||
494 | bool Categories::save( const QString &fname ) const | 644 | bool Categories::save( const QString &fname ) const |
495 | { | 645 | { |
496 | QString strNewFile = fname + ".new"; | 646 | QString strNewFile = fname + ".new"; |
497 | QFile f( strNewFile ); | 647 | QFile f( strNewFile ); |
498 | QString out; | 648 | QString out; |
499 | int total_written; | 649 | int total_written; |
500 | 650 | ||
501 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { | 651 | if ( !f.open( IO_WriteOnly|IO_Raw ) ) { |
@@ -529,26 +679,35 @@ bool Categories::save( const QString &fname ) const | |||
529 | total_written = f.writeBlock( cstr.data(), cstr.length() ); | 679 | total_written = f.writeBlock( cstr.data(), cstr.length() ); |
530 | if ( total_written != int(cstr.length()) ) { | 680 | if ( total_written != int(cstr.length()) ) { |
531 | f.close(); | 681 | f.close(); |
532 | QFile::remove( strNewFile ); | 682 | QFile::remove( strNewFile ); |
533 | return FALSE; | 683 | return FALSE; |
534 | } | 684 | } |
535 | f.close(); | 685 | f.close(); |
536 | 686 | ||
687 | #ifdef Q_OS_WIN32 | ||
688 | QFile::remove( fname ); | ||
689 | #endif | ||
537 | if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { | 690 | if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { |
538 | qWarning( "problem renaming file %s to %s", | 691 | qWarning( "problem renaming file %s to %s", |
539 | strNewFile.latin1(), fname.latin1()); | 692 | strNewFile.latin1(), fname.latin1()); |
540 | // remove the tmp file... | 693 | // remove the tmp file... |
541 | QFile::remove( strNewFile ); | 694 | QFile::remove( strNewFile ); |
542 | } | 695 | } |
543 | 696 | ||
544 | return TRUE; | 697 | return TRUE; |
545 | } | 698 | } |
546 | 699 | ||
700 | /*! | ||
701 | Loads the Categories database using \a fname. See categoryFileName() | ||
702 | for the default file name string used for the shared category database. | ||
703 | |||
704 | Returns FALSE if there is error reading the file or TRUE on success. | ||
705 | */ | ||
547 | bool Categories::load( const QString &fname ) | 706 | bool Categories::load( const QString &fname ) |
548 | { | 707 | { |
549 | QFile file( fname ); | 708 | QFile file( fname ); |
550 | if ( !file.open( IO_ReadOnly ) ) { | 709 | if ( !file.open( IO_ReadOnly ) ) { |
551 | qWarning("Unable to open %s", fname.latin1()); | 710 | qWarning("Unable to open %s", fname.latin1()); |
552 | 711 | ||
553 | addGlobalCategory(tr("Business")); | 712 | addGlobalCategory(tr("Business")); |
554 | addGlobalCategory(tr("Personal")); | 713 | addGlobalCategory(tr("Personal")); |
@@ -614,22 +773,29 @@ bool Categories::load( const QString &fname ) | |||
614 | mGlobalCats.add( id.toInt(), name ); | 773 | mGlobalCats.add( id.toInt(), name ); |
615 | else | 774 | else |
616 | mAppCats[ app ].add( id.toInt(), name ); | 775 | mAppCats[ app ].add( id.toInt(), name ); |
617 | } | 776 | } |
618 | 777 | ||
619 | return TRUE; | 778 | return TRUE; |
620 | } | 779 | } |
621 | 780 | ||
781 | /*! | ||
782 | Clear the categories in memory. Equivelent to creating an empty Categories | ||
783 | object. | ||
784 | */ | ||
622 | void Categories::clear() | 785 | void Categories::clear() |
623 | { | 786 | { |
624 | mGlobalCats.clear(); | 787 | mGlobalCats.clear(); |
625 | mAppCats.clear(); | 788 | mAppCats.clear(); |
626 | } | 789 | } |
627 | 790 | ||
791 | /*! | ||
792 | Dump the contents to standard out. Used for debugging only. | ||
793 | */ | ||
628 | void Categories::dump() const | 794 | void Categories::dump() const |
629 | { | 795 | { |
630 | qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); | 796 | qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); |
631 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { | 797 | for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { |
632 | const QString &app = appsIt.key(); | 798 | const QString &app = appsIt.key(); |
633 | QStringList appcats = (*appsIt).labels(); | 799 | QStringList appcats = (*appsIt).labels(); |
634 | qDebug("\tapp = %s\tcategories = %s", app.latin1(), | 800 | qDebug("\tapp = %s\tcategories = %s", app.latin1(), |
635 | appcats.join(", ").latin1() ); | 801 | appcats.join(", ").latin1() ); |
@@ -670,8 +836,101 @@ void CheckedListView::setChecked( const QStringList &checked ) | |||
670 | if ( !showingChecked ) { | 836 | if ( !showingChecked ) { |
671 | ensureItemVisible( i ); | 837 | ensureItemVisible( i ); |
672 | showingChecked = TRUE; | 838 | showingChecked = TRUE; |
673 | } | 839 | } |
674 | } | 840 | } |
675 | else | 841 | else |
676 | i->setOn( FALSE ); | 842 | i->setOn( FALSE ); |
677 | } | 843 | } |
844 | |||
845 | /*! \fn Categories &Categories::operator= ( const Categories &c ) | ||
846 | |||
847 | Performs deep copy. | ||
848 | */ | ||
849 | |||
850 | |||
851 | /*! \fn QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const | ||
852 | |||
853 | Returns list of labels associated with the application and catids | ||
854 | */ | ||
855 | |||
856 | /*! \fn QStringList Categories::globalCategories() const | ||
857 | |||
858 | Returns list of all global category labels | ||
859 | */ | ||
860 | |||
861 | /*! \fn const QMap<QString, CategoryGroup> &Categories::appGroupMap() const | ||
862 | |||
863 | Returns a map of application names to CategoryGroup. The CategoryGroup | ||
864 | class defines a map of ids to category labels and category labels to ids. | ||
865 | */ | ||
866 | |||
867 | /*! \fn const CategoryGroup &Categories::globalGroup() const | ||
868 | |||
869 | Returns the global CategoryGroup. The CategoryGroup | ||
870 | class defines a map of ids to category labels and category labels to ids. | ||
871 | */ | ||
872 | |||
873 | /*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid) | ||
874 | |||
875 | Emitted if a category is added. | ||
876 | |||
877 | \a cats is a const reference to this object | ||
878 | \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global | ||
879 | \a uid is the unique identifier associated with the added category | ||
880 | */ | ||
881 | |||
882 | /*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname, | ||
883 | int uid) | ||
884 | |||
885 | Emitted if removed category is removed. | ||
886 | |||
887 | \a cats is a const reference to this object | ||
888 | \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup | ||
889 | \a uid is the unique identifier associated with the removed category | ||
890 | */ | ||
891 | |||
892 | |||
893 | /*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname, | ||
894 | int uid) | ||
895 | |||
896 | Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats | ||
897 | object. | ||
898 | |||
899 | \a cats is a const reference to this object | ||
900 | \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup | ||
901 | \a uid is the unique identifier associated with the renamed category | ||
902 | */ | ||
903 | |||
904 | /*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 ) | ||
905 | |||
906 | Constructor for an empty Categories object. | ||
907 | */ | ||
908 | |||
909 | /*! \fn Categories::Categories( const Categories ©From ) | ||
910 | |||
911 | Deep copy constructor | ||
912 | */ | ||
913 | |||
914 | /*! \fn Categories::~Categories() | ||
915 | |||
916 | Empty destructor. Call save() before destruction if there are changes | ||
917 | that need to be saved. | ||
918 | */ | ||
919 | |||
920 | /*! \fn CategoryGroup::clear() | ||
921 | \internal | ||
922 | */ | ||
923 | |||
924 | /*! \fn const QMap<int, QString> &CategoryGroup::idMap() const | ||
925 | |||
926 | Returns a const reference to the id to label QMap | ||
927 | */ | ||
928 | |||
929 | /*! \fn CategoryGroup::CategoryGroup() | ||
930 | \internal | ||
931 | */ | ||
932 | |||
933 | /*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c) | ||
934 | \internal | ||
935 | */ | ||
936 | |||
diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index b10b19a..3f4934a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -29,49 +29,427 @@ | |||
29 | 29 | ||
30 | #include <qobject.h> | 30 | #include <qobject.h> |
31 | #include <qregexp.h> | 31 | #include <qregexp.h> |
32 | #include <qstylesheet.h> | 32 | #include <qstylesheet.h> |
33 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | 36 | ||
37 | /*! | ||
38 | \class Contact contact.h | ||
39 | \brief The Contact class holds the data of an address book entry. | ||
40 | |||
41 | This data includes information the name of the person, contact | ||
42 | information, and business information such as deparment and job title. | ||
43 | |||
44 | \ingroup qtopiaemb | ||
45 | \ingroup qtopiadesktop | ||
46 | */ | ||
47 | |||
37 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); | 48 | Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); |
38 | 49 | ||
50 | /*! | ||
51 | Creates a new, empty contact. | ||
52 | */ | ||
39 | Contact::Contact() | 53 | Contact::Contact() |
40 | : Record(), mMap(), d( 0 ) | 54 | : Record(), mMap(), d( 0 ) |
41 | { | 55 | { |
42 | } | 56 | } |
43 | 57 | ||
58 | /*! | ||
59 | \internal | ||
60 | Creates a new contact. The properties of the contact are | ||
61 | set from \a fromMap. | ||
62 | */ | ||
44 | Contact::Contact( const QMap<int, QString> &fromMap ) : | 63 | Contact::Contact( const QMap<int, QString> &fromMap ) : |
45 | Record(), mMap( fromMap ), d( 0 ) | 64 | Record(), mMap( fromMap ), d( 0 ) |
46 | { | 65 | { |
47 | QString cats = mMap[ Qtopia::AddressCategory ]; | 66 | QString cats = mMap[ Qtopia::AddressCategory ]; |
48 | if ( !cats.isEmpty() ) | 67 | if ( !cats.isEmpty() ) |
49 | setCategories( idsFromString( cats ) ); | 68 | setCategories( idsFromString( cats ) ); |
50 | QString uidStr = find( Qtopia::AddressUid ); | 69 | QString uidStr = find( Qtopia::AddressUid ); |
70 | |||
51 | if ( uidStr.isEmpty() ) | 71 | if ( uidStr.isEmpty() ) |
52 | setUid( uidGen().generate() ); | 72 | setUid( uidGen().generate() ); |
53 | else | 73 | else |
54 | setUid( uidStr.toInt() ); | 74 | setUid( uidStr.toInt() ); |
75 | |||
76 | if ( !uidStr.isEmpty() ) | ||
77 | setUid( uidStr.toInt() ); | ||
55 | } | 78 | } |
56 | 79 | ||
80 | /*! | ||
81 | Destroys a contact. | ||
82 | */ | ||
57 | Contact::~Contact() | 83 | Contact::~Contact() |
58 | { | 84 | { |
59 | } | 85 | } |
60 | 86 | ||
87 | /*! \fn void Contact::setTitle( const QString &str ) | ||
88 | Sets the title of the contact to \a str. | ||
89 | */ | ||
90 | |||
91 | /*! \fn void Contact::setFirstName( const QString &str ) | ||
92 | Sets the first name of the contact to \a str. | ||
93 | */ | ||
94 | |||
95 | /*! \fn void Contact::setMiddleName( const QString &str ) | ||
96 | Sets the middle name of the contact to \a str. | ||
97 | */ | ||
98 | |||
99 | /*! \fn void Contact::setLastName( const QString &str ) | ||
100 | Sets the last name of the contact to \a str. | ||
101 | */ | ||
102 | |||
103 | /*! \fn void Contact::setSuffix( const QString &str ) | ||
104 | Sets the suffix of the contact to \a str. | ||
105 | */ | ||
106 | |||
107 | /*! \fn void Contact::setFileAs( const QString &str ) | ||
108 | Sets the contact to filed as \a str. | ||
109 | */ | ||
110 | |||
111 | /*! \fn void Contact::setDefaultEmail( const QString &str ) | ||
112 | Sets the default email of the contact to \a str. | ||
113 | */ | ||
114 | |||
115 | /*! \fn void Contact::setHomeStreet( const QString &str ) | ||
116 | Sets the home street address of the contact to \a str. | ||
117 | */ | ||
118 | |||
119 | /*! \fn void Contact::setHomeCity( const QString &str ) | ||
120 | Sets the home city of the contact to \a str. | ||
121 | */ | ||
122 | |||
123 | /*! \fn void Contact::setHomeState( const QString &str ) | ||
124 | Sets the home state of the contact to \a str. | ||
125 | */ | ||
126 | |||
127 | /*! \fn void Contact::setHomeZip( const QString &str ) | ||
128 | Sets the home zip code of the contact to \a str. | ||
129 | */ | ||
130 | |||
131 | /*! \fn void Contact::setHomeCountry( const QString &str ) | ||
132 | Sets the home country of the contact to \a str. | ||
133 | */ | ||
134 | |||
135 | /*! \fn void Contact::setHomePhone( const QString &str ) | ||
136 | Sets the home phone number of the contact to \a str. | ||
137 | */ | ||
138 | |||
139 | /*! \fn void Contact::setHomeFax( const QString &str ) | ||
140 | Sets the home fax number of the contact to \a str. | ||
141 | */ | ||
142 | |||
143 | /*! \fn void Contact::setHomeMobile( const QString &str ) | ||
144 | Sets the home mobile phone number of the contact to \a str. | ||
145 | */ | ||
146 | |||
147 | /*! \fn void Contact::setHomeWebpage( const QString &str ) | ||
148 | Sets the home webpage of the contact to \a str. | ||
149 | */ | ||
150 | |||
151 | /*! \fn void Contact::setCompany( const QString &str ) | ||
152 | Sets the company for contact to \a str. | ||
153 | */ | ||
154 | |||
155 | /*! \fn void Contact::setJobTitle( const QString &str ) | ||
156 | Sets the job title of the contact to \a str. | ||
157 | */ | ||
158 | |||
159 | /*! \fn void Contact::setDepartment( const QString &str ) | ||
160 | Sets the department for contact to \a str. | ||
161 | */ | ||
162 | |||
163 | /*! \fn void Contact::setOffice( const QString &str ) | ||
164 | Sets the office for contact to \a str. | ||
165 | */ | ||
166 | |||
167 | /*! \fn void Contact::setBusinessStreet( const QString &str ) | ||
168 | Sets the business street address of the contact to \a str. | ||
169 | */ | ||
170 | |||
171 | /*! \fn void Contact::setBusinessCity( const QString &str ) | ||
172 | Sets the business city of the contact to \a str. | ||
173 | */ | ||
174 | |||
175 | /*! \fn void Contact::setBusinessState( const QString &str ) | ||
176 | Sets the business state of the contact to \a str. | ||
177 | */ | ||
178 | |||
179 | /*! \fn void Contact::setBusinessZip( const QString &str ) | ||
180 | Sets the business zip code of the contact to \a str. | ||
181 | */ | ||
182 | |||
183 | /*! \fn void Contact::setBusinessCountry( const QString &str ) | ||
184 | Sets the business country of the contact to \a str. | ||
185 | */ | ||
186 | |||
187 | /*! \fn void Contact::setBusinessPhone( const QString &str ) | ||
188 | Sets the business phone number of the contact to \a str. | ||
189 | */ | ||
190 | |||
191 | /*! \fn void Contact::setBusinessFax( const QString &str ) | ||
192 | Sets the business fax number of the contact to \a str. | ||
193 | */ | ||
194 | |||
195 | /*! \fn void Contact::setBusinessMobile( const QString &str ) | ||
196 | Sets the business mobile phone number of the contact to \a str. | ||
197 | */ | ||
198 | |||
199 | /*! \fn void Contact::setBusinessPager( const QString &str ) | ||
200 | Sets the business pager number of the contact to \a str. | ||
201 | */ | ||
202 | |||
203 | /*! \fn void Contact::setBusinessWebpage( const QString &str ) | ||
204 | Sets the business webpage of the contact to \a str. | ||
205 | */ | ||
206 | |||
207 | /*! \fn void Contact::setProfession( const QString &str ) | ||
208 | Sets the profession of the contact to \a str. | ||
209 | */ | ||
210 | |||
211 | /*! \fn void Contact::setAssistant( const QString &str ) | ||
212 | Sets the assistant of the contact to \a str. | ||
213 | */ | ||
214 | |||
215 | /*! \fn void Contact::setManager( const QString &str ) | ||
216 | Sets the manager of the contact to \a str. | ||
217 | */ | ||
218 | |||
219 | /*! \fn void Contact::setSpouse( const QString &str ) | ||
220 | Sets the spouse of the contact to \a str. | ||
221 | */ | ||
222 | |||
223 | /*! \fn void Contact::setGender( const QString &str ) | ||
224 | Sets the gender of the contact to \a str. | ||
225 | */ | ||
226 | |||
227 | /*! \fn void Contact::setBirthday( const QString &str ) | ||
228 | Sets the birthday for the contact to \a str. | ||
229 | */ | ||
230 | |||
231 | /*! \fn void Contact::setAnniversary( const QString &str ) | ||
232 | Sets the anniversary of the contact to \a str. | ||
233 | */ | ||
234 | |||
235 | /*! \fn void Contact::setNickname( const QString &str ) | ||
236 | Sets the nickname of the contact to \a str. | ||
237 | */ | ||
238 | |||
239 | /*! \fn void Contact::setNotes( const QString &str ) | ||
240 | Sets the notes about the contact to \a str. | ||
241 | */ | ||
242 | |||
243 | /*! \fn QString Contact::title() const | ||
244 | Returns the title of the contact. | ||
245 | */ | ||
246 | |||
247 | /*! \fn QString Contact::firstName() const | ||
248 | Returns the first name of the contact. | ||
249 | */ | ||
250 | |||
251 | /*! \fn QString Contact::middleName() const | ||
252 | Returns the middle name of the contact. | ||
253 | */ | ||
254 | |||
255 | /*! \fn QString Contact::lastName() const | ||
256 | Returns the last name of the contact. | ||
257 | */ | ||
258 | |||
259 | /*! \fn QString Contact::suffix() const | ||
260 | Returns the suffix of the contact. | ||
261 | */ | ||
262 | |||
263 | /*! \fn QString Contact::fileAs() const | ||
264 | Returns the string the contact is filed as. | ||
265 | */ | ||
266 | |||
267 | /*! \fn QString Contact::defaultEmail() const | ||
268 | Returns the default email address of the contact. | ||
269 | */ | ||
270 | |||
271 | /*! \fn QString Contact::emails() const | ||
272 | Returns the list of email address for a contact separated by ';'s in a single | ||
273 | string. | ||
274 | */ | ||
275 | |||
276 | /*! \fn QString Contact::homeStreet() const | ||
277 | Returns the home street address of the contact. | ||
278 | */ | ||
279 | |||
280 | /*! \fn QString Contact::homeCity() const | ||
281 | Returns the home city of the contact. | ||
282 | */ | ||
283 | |||
284 | /*! \fn QString Contact::homeState() const | ||
285 | Returns the home state of the contact. | ||
286 | */ | ||
287 | |||
288 | /*! \fn QString Contact::homeZip() const | ||
289 | Returns the home zip of the contact. | ||
290 | */ | ||
291 | |||
292 | /*! \fn QString Contact::homeCountry() const | ||
293 | Returns the home country of the contact. | ||
294 | */ | ||
295 | |||
296 | /*! \fn QString Contact::homePhone() const | ||
297 | Returns the home phone number of the contact. | ||
298 | */ | ||
299 | |||
300 | /*! \fn QString Contact::homeFax() const | ||
301 | Returns the home fax number of the contact. | ||
302 | */ | ||
303 | |||
304 | /*! \fn QString Contact::homeMobile() const | ||
305 | Returns the home mobile number of the contact. | ||
306 | */ | ||
307 | |||
308 | /*! \fn QString Contact::homeWebpage() const | ||
309 | Returns the home webpage of the contact. | ||
310 | */ | ||
311 | |||
312 | /*! \fn QString Contact::company() const | ||
313 | Returns the company for the contact. | ||
314 | */ | ||
315 | |||
316 | /*! \fn QString Contact::department() const | ||
317 | Returns the department for the contact. | ||
318 | */ | ||
319 | |||
320 | /*! \fn QString Contact::office() const | ||
321 | Returns the office for the contact. | ||
322 | */ | ||
323 | |||
324 | /*! \fn QString Contact::jobTitle() const | ||
325 | Returns the job title of the contact. | ||
326 | */ | ||
327 | |||
328 | /*! \fn QString Contact::profession() const | ||
329 | Returns the profession of the contact. | ||
330 | */ | ||
331 | |||
332 | /*! \fn QString Contact::assistant() const | ||
333 | Returns the assistant of the contact. | ||
334 | */ | ||
335 | |||
336 | /*! \fn QString Contact::manager() const | ||
337 | Returns the manager of the contact. | ||
338 | */ | ||
339 | |||
340 | /*! \fn QString Contact::businessStreet() const | ||
341 | Returns the business street address of the contact. | ||
342 | */ | ||
343 | |||
344 | /*! \fn QString Contact::businessCity() const | ||
345 | Returns the business city of the contact. | ||
346 | */ | ||
347 | |||
348 | /*! \fn QString Contact::businessState() const | ||
349 | Returns the business state of the contact. | ||
350 | */ | ||
351 | |||
352 | /*! \fn QString Contact::businessZip() const | ||
353 | Returns the business zip of the contact. | ||
354 | */ | ||
355 | |||
356 | /*! \fn QString Contact::businessCountry() const | ||
357 | Returns the business country of the contact. | ||
358 | */ | ||
359 | |||
360 | /*! \fn QString Contact::businessPhone() const | ||
361 | Returns the business phone number of the contact. | ||
362 | */ | ||
363 | |||
364 | /*! \fn QString Contact::businessFax() const | ||
365 | Returns the business fax number of the contact. | ||
366 | */ | ||
367 | |||
368 | /*! \fn QString Contact::businessMobile() const | ||
369 | Returns the business mobile number of the contact. | ||
370 | */ | ||
371 | |||
372 | /*! \fn QString Contact::businessPager() const | ||
373 | Returns the business pager number of the contact. | ||
374 | */ | ||
375 | |||
376 | /*! \fn QString Contact::businessWebpage() const | ||
377 | Returns the business webpage of the contact. | ||
378 | */ | ||
379 | |||
380 | /*! \fn QString Contact::spouse() const | ||
381 | Returns the spouse of the contact. | ||
382 | */ | ||
383 | |||
384 | /*! \fn QString Contact::gender() const | ||
385 | Returns the gender of the contact. | ||
386 | */ | ||
387 | |||
388 | /*! \fn QString Contact::birthday() const | ||
389 | Returns the birthday of the contact. | ||
390 | */ | ||
391 | |||
392 | /*! \fn QString Contact::anniversary() const | ||
393 | Returns the anniversary of the contact. | ||
394 | */ | ||
395 | |||
396 | /*! \fn QString Contact::nickname() const | ||
397 | Returns the nickname of the contact. | ||
398 | */ | ||
399 | |||
400 | /*! \fn QString Contact::children() const | ||
401 | Returns the children of the contact. | ||
402 | */ | ||
403 | |||
404 | /*! \fn QString Contact::notes() const | ||
405 | Returns the notes relating to the the contact. | ||
406 | */ | ||
407 | |||
408 | /*! \fn QString Contact::groups() const | ||
409 | \internal | ||
410 | Returns the groups for the contact. | ||
411 | */ | ||
412 | |||
413 | /*! \fn QStringList Contact::groupList() const | ||
414 | \internal | ||
415 | */ | ||
416 | |||
417 | /*! \fn QString Contact::field(int) const | ||
418 | \internal | ||
419 | */ | ||
420 | |||
421 | /*! \fn void Contact::saveJournal( journal_action, const QString & = QString::null ) | ||
422 | \internal | ||
423 | */ | ||
424 | |||
425 | /*! \fn void Contact::setUid( int id ) | ||
426 | \internal | ||
427 | Sets the uid for this record to \a id. | ||
428 | */ | ||
429 | |||
430 | /*! \enum Contact::journal_action | ||
431 | \internal | ||
432 | */ | ||
433 | |||
434 | /*! | ||
435 | \internal | ||
436 | */ | ||
61 | QMap<int, QString> Contact::toMap() const | 437 | QMap<int, QString> Contact::toMap() const |
62 | { | 438 | { |
63 | QMap<int, QString> map = mMap; | 439 | QMap<int, QString> map = mMap; |
64 | map.insert( Qtopia::AddressCategory, idsToString( categories() )); | 440 | QString cats = idsToString( categories() ); |
441 | if ( !cats.isEmpty() ) | ||
442 | map.insert( Qtopia::AddressCategory, cats ); | ||
65 | return map; | 443 | return map; |
66 | } | 444 | } |
67 | 445 | ||
68 | /*! | 446 | /*! |
69 | Returns a rich text formatted QString of the Contact. | 447 | Returns a rich text formatted QString representing the contents the contact. |
70 | */ | 448 | */ |
71 | QString Contact::toRichText() const | 449 | QString Contact::toRichText() const |
72 | { | 450 | { |
73 | QString text; | 451 | QString text; |
74 | QString value, comp, state; | 452 | QString value, comp, state; |
75 | 453 | ||
76 | // name, jobtitle and company | 454 | // name, jobtitle and company |
77 | if ( !(value = fullName()).isEmpty() ) | 455 | if ( !(value = fullName()).isEmpty() ) |
@@ -226,39 +604,51 @@ QString Contact::toRichText() const | |||
226 | //QString tmp = Qtopia::escapeString(value); | 604 | //QString tmp = Qtopia::escapeString(value); |
227 | QString tmp = QStyleSheet::convertFromPlainText(value); | 605 | QString tmp = QStyleSheet::convertFromPlainText(value); |
228 | //tmp.replace( reg, "<br>" ); | 606 | //tmp.replace( reg, "<br>" ); |
229 | text += "<br>" + tmp + "<br>"; | 607 | text += "<br>" + tmp + "<br>"; |
230 | } | 608 | } |
231 | return text; | 609 | return text; |
232 | } | 610 | } |
233 | 611 | ||
612 | /*! | ||
613 | \internal | ||
614 | */ | ||
234 | void Contact::insert( int key, const QString &v ) | 615 | void Contact::insert( int key, const QString &v ) |
235 | { | 616 | { |
236 | QString value = v.stripWhiteSpace(); | 617 | QString value = v.stripWhiteSpace(); |
237 | if ( value.isEmpty() ) | 618 | if ( value.isEmpty() ) |
238 | mMap.remove( key ); | 619 | mMap.remove( key ); |
239 | else | 620 | else |
240 | mMap.insert( key, value ); | 621 | mMap.insert( key, value ); |
241 | } | 622 | } |
242 | 623 | ||
624 | /*! | ||
625 | \internal | ||
626 | */ | ||
243 | void Contact::replace( int key, const QString & v ) | 627 | void Contact::replace( int key, const QString & v ) |
244 | { | 628 | { |
245 | QString value = v.stripWhiteSpace(); | 629 | QString value = v.stripWhiteSpace(); |
246 | if ( value.isEmpty() ) | 630 | if ( value.isEmpty() ) |
247 | mMap.remove( key ); | 631 | mMap.remove( key ); |
248 | else | 632 | else |
249 | mMap.replace( key, value ); | 633 | mMap.replace( key, value ); |
250 | } | 634 | } |
251 | 635 | ||
636 | /*! | ||
637 | \internal | ||
638 | */ | ||
252 | QString Contact::find( int key ) const | 639 | QString Contact::find( int key ) const |
253 | { | 640 | { |
254 | return mMap[key]; | 641 | return mMap[key]; |
255 | } | 642 | } |
256 | 643 | ||
644 | /*! | ||
645 | \internal | ||
646 | */ | ||
257 | QString Contact::displayAddress( const QString &street, | 647 | QString Contact::displayAddress( const QString &street, |
258 | const QString &city, | 648 | const QString &city, |
259 | const QString &state, | 649 | const QString &state, |
260 | const QString &zip, | 650 | const QString &zip, |
261 | const QString &country ) const | 651 | const QString &country ) const |
262 | { | 652 | { |
263 | QString s = street; | 653 | QString s = street; |
264 | if ( !street.isEmpty() ) | 654 | if ( !street.isEmpty() ) |
@@ -271,30 +661,39 @@ QString Contact::displayAddress( const QString &street, | |||
271 | s += " "; | 661 | s += " "; |
272 | s += zip; | 662 | s += zip; |
273 | if ( !country.isEmpty() && !s.isEmpty() ) | 663 | if ( !country.isEmpty() && !s.isEmpty() ) |
274 | s += "\n"; | 664 | s += "\n"; |
275 | s += country; | 665 | s += country; |
276 | return s; | 666 | return s; |
277 | } | 667 | } |
278 | 668 | ||
669 | /*! | ||
670 | \internal | ||
671 | */ | ||
279 | QString Contact::displayBusinessAddress() const | 672 | QString Contact::displayBusinessAddress() const |
280 | { | 673 | { |
281 | return displayAddress( businessStreet(), businessCity(), | 674 | return displayAddress( businessStreet(), businessCity(), |
282 | businessState(), businessZip(), | 675 | businessState(), businessZip(), |
283 | businessCountry() ); | 676 | businessCountry() ); |
284 | } | 677 | } |
285 | 678 | ||
679 | /*! | ||
680 | \internal | ||
681 | */ | ||
286 | QString Contact::displayHomeAddress() const | 682 | QString Contact::displayHomeAddress() const |
287 | { | 683 | { |
288 | return displayAddress( homeStreet(), homeCity(), | 684 | return displayAddress( homeStreet(), homeCity(), |
289 | homeState(), homeZip(), | 685 | homeState(), homeZip(), |
290 | homeCountry() ); | 686 | homeCountry() ); |
291 | } | 687 | } |
292 | 688 | ||
689 | /*! | ||
690 | Returns the full name of the contact | ||
691 | */ | ||
293 | QString Contact::fullName() const | 692 | QString Contact::fullName() const |
294 | { | 693 | { |
295 | QString title = find( Qtopia::Title ); | 694 | QString title = find( Qtopia::Title ); |
296 | QString firstName = find( Qtopia::FirstName ); | 695 | QString firstName = find( Qtopia::FirstName ); |
297 | QString middleName = find( Qtopia::MiddleName ); | 696 | QString middleName = find( Qtopia::MiddleName ); |
298 | QString lastName = find( Qtopia::LastName ); | 697 | QString lastName = find( Qtopia::LastName ); |
299 | QString suffix = find( Qtopia::Suffix ); | 698 | QString suffix = find( Qtopia::Suffix ); |
300 | 699 | ||
@@ -317,26 +716,72 @@ QString Contact::fullName() const | |||
317 | if ( !suffix.isEmpty() ) { | 716 | if ( !suffix.isEmpty() ) { |
318 | if ( !name.isEmpty() ) | 717 | if ( !name.isEmpty() ) |
319 | name += " "; | 718 | name += " "; |
320 | name += suffix; | 719 | name += suffix; |
321 | } | 720 | } |
322 | return name.simplifyWhiteSpace(); | 721 | return name.simplifyWhiteSpace(); |
323 | } | 722 | } |
324 | 723 | ||
724 | /*! | ||
725 | Returns a list of the names of the children of the contact. | ||
726 | */ | ||
325 | QStringList Contact::childrenList() const | 727 | QStringList Contact::childrenList() const |
326 | { | 728 | { |
327 | return QStringList::split( " ", find( Qtopia::Children ) ); | 729 | return QStringList::split( " ", find( Qtopia::Children ) ); |
328 | } | 730 | } |
329 | 731 | ||
732 | /*! \fn void Contact::insertEmail( const QString &email ) | ||
733 | |||
734 | Insert \a email into the email list. Ensures \a email can only be added | ||
735 | once. If there is no default email address set, it sets it to the \a email. | ||
736 | */ | ||
737 | |||
738 | /*! \fn void Contact::removeEmail( const QString &email ) | ||
739 | |||
740 | Removes the \a email from the email list. If the default email was \a email, | ||
741 | then the default email address is assigned to the first email in the | ||
742 | email list | ||
743 | */ | ||
744 | |||
745 | /*! \fn void Contact::clearEmails() | ||
746 | |||
747 | Clears the email list. | ||
748 | */ | ||
749 | |||
750 | /*! \fn void Contact::insertEmails( const QStringList &emailList ) | ||
751 | |||
752 | Appends the \a emailList to the exiting email list | ||
753 | */ | ||
754 | |||
755 | /*! | ||
756 | Returns a list of email addresses belonging to the contact, including | ||
757 | the default email address. | ||
758 | */ | ||
330 | QStringList Contact::emailList() const | 759 | QStringList Contact::emailList() const |
331 | { | 760 | { |
332 | return QStringList::split( ";", find( Qtopia::Emails ) ); | 761 | QString emailStr = emails(); |
762 | |||
763 | QStringList r; | ||
764 | if ( !emailStr.isEmpty() ) { | ||
765 | qDebug(" emailstr "); | ||
766 | QStringList l = QStringList::split( emailSeparator(), emailStr ); | ||
767 | for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) | ||
768 | r += (*it).simplifyWhiteSpace(); | ||
769 | } | ||
770 | |||
771 | return r; | ||
333 | } | 772 | } |
334 | 773 | ||
774 | /*! | ||
775 | \overload | ||
776 | |||
777 | Generates the string for the contact to be filed as from the first, | ||
778 | middle and last name of the contact. | ||
779 | */ | ||
335 | void Contact::setFileAs() | 780 | void Contact::setFileAs() |
336 | { | 781 | { |
337 | QString lastName, firstName, middleName, fileas; | 782 | QString lastName, firstName, middleName, fileas; |
338 | 783 | ||
339 | lastName = find( Qtopia::LastName ); | 784 | lastName = find( Qtopia::LastName ); |
340 | firstName = find( Qtopia::FirstName ); | 785 | firstName = find( Qtopia::FirstName ); |
341 | middleName = find( Qtopia::MiddleName ); | 786 | middleName = find( Qtopia::MiddleName ); |
342 | if ( !lastName.isEmpty() && !firstName.isEmpty() | 787 | if ( !lastName.isEmpty() && !firstName.isEmpty() |
@@ -348,16 +793,20 @@ void Contact::setFileAs() | |||
348 | !middleName.isEmpty() ) | 793 | !middleName.isEmpty() ) |
349 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) | 794 | fileas = firstName + ( firstName.isEmpty() ? "" : " " ) |
350 | + middleName + ( middleName.isEmpty() ? "" : " " ) | 795 | + middleName + ( middleName.isEmpty() ? "" : " " ) |
351 | + lastName; | 796 | + lastName; |
352 | 797 | ||
353 | replace( Qtopia::FileAs, fileas ); | 798 | replace( Qtopia::FileAs, fileas ); |
354 | } | 799 | } |
355 | 800 | ||
801 | /*! | ||
802 | \internal | ||
803 | Appends the contact information to \a buf. | ||
804 | */ | ||
356 | void Contact::save( QString &buf ) const | 805 | void Contact::save( QString &buf ) const |
357 | { | 806 | { |
358 | static const QStringList SLFIELDS = fields(); | 807 | static const QStringList SLFIELDS = fields(); |
359 | // I'm expecting "<Contact " in front of this... | 808 | // I'm expecting "<Contact " in front of this... |
360 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); | 809 | for ( QMap<int, QString>::ConstIterator it = mMap.begin(); |
361 | it != mMap.end(); ++it ) { | 810 | it != mMap.end(); ++it ) { |
362 | const QString &value = it.data(); | 811 | const QString &value = it.data(); |
363 | int key = it.key(); | 812 | int key = it.key(); |
@@ -372,16 +821,20 @@ void Contact::save( QString &buf ) const | |||
372 | } | 821 | } |
373 | buf += customToXml(); | 822 | buf += customToXml(); |
374 | if ( categories().count() > 0 ) | 823 | if ( categories().count() > 0 ) |
375 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; | 824 | buf += "Categories=\"" + idsToString( categories() ) + "\" "; |
376 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; | 825 | buf += "Uid=\"" + QString::number( uid() ) + "\" "; |
377 | // You need to close this yourself | 826 | // You need to close this yourself |
378 | } | 827 | } |
379 | 828 | ||
829 | /*! | ||
830 | \internal | ||
831 | Returns the list of fields belonging to a contact | ||
832 | */ | ||
380 | QStringList Contact::fields() | 833 | QStringList Contact::fields() |
381 | { | 834 | { |
382 | QStringList list; | 835 | QStringList list; |
383 | 836 | ||
384 | list.append( "Title" ); // Not Used! | 837 | list.append( "Title" ); // Not Used! |
385 | list.append( "FirstName" ); | 838 | list.append( "FirstName" ); |
386 | list.append( "MiddleName" ); | 839 | list.append( "MiddleName" ); |
387 | list.append( "LastName" ); | 840 | list.append( "LastName" ); |
@@ -430,16 +883,20 @@ QStringList Contact::fields() | |||
430 | list.append( "Children" ); | 883 | list.append( "Children" ); |
431 | 884 | ||
432 | list.append( "Notes" ); | 885 | list.append( "Notes" ); |
433 | list.append( "Groups" ); | 886 | list.append( "Groups" ); |
434 | 887 | ||
435 | return list; | 888 | return list; |
436 | } | 889 | } |
437 | 890 | ||
891 | /*! | ||
892 | \internal | ||
893 | Returns a translated list of field names for a contact. | ||
894 | */ | ||
438 | QStringList Contact::trfields() | 895 | QStringList Contact::trfields() |
439 | { | 896 | { |
440 | QStringList list; | 897 | QStringList list; |
441 | 898 | ||
442 | list.append( QObject::tr( "Name Title") ); | 899 | list.append( QObject::tr( "Name Title") ); |
443 | list.append( QObject::tr( "First Name" ) ); | 900 | list.append( QObject::tr( "First Name" ) ); |
444 | list.append( QObject::tr( "Middle Name" ) ); | 901 | list.append( QObject::tr( "Middle Name" ) ); |
445 | list.append( QObject::tr( "Last Name" ) ); | 902 | list.append( QObject::tr( "Last Name" ) ); |
@@ -488,45 +945,61 @@ QStringList Contact::trfields() | |||
488 | list.append( QObject::tr( "Children" ) ); | 945 | list.append( QObject::tr( "Children" ) ); |
489 | 946 | ||
490 | list.append( QObject::tr( "Notes" ) ); | 947 | list.append( QObject::tr( "Notes" ) ); |
491 | list.append( QObject::tr( "Groups" ) ); | 948 | list.append( QObject::tr( "Groups" ) ); |
492 | 949 | ||
493 | return list; | 950 | return list; |
494 | } | 951 | } |
495 | 952 | ||
496 | void Contact::setEmails( const QString &v ) | 953 | /*! |
954 | Sets the list of email address for contact to those contained in \a str. | ||
955 | Email address should be separated by ';'s. | ||
956 | */ | ||
957 | void Contact::setEmails( const QString &str ) | ||
497 | { | 958 | { |
498 | replace( Qtopia::Emails, v ); | 959 | replace( Qtopia::Emails, str ); |
499 | if ( v.isEmpty() ) | 960 | if ( str.isEmpty() ) |
500 | setDefaultEmail( QString::null ); | 961 | setDefaultEmail( QString::null ); |
501 | } | 962 | } |
502 | 963 | ||
503 | void Contact::setChildren( const QString &v ) | 964 | /*! |
965 | Sets the list of children for the contact to those contained in \a str. | ||
966 | */ | ||
967 | void Contact::setChildren( const QString &str ) | ||
504 | { | 968 | { |
505 | replace( Qtopia::Children, v ); | 969 | replace( Qtopia::Children, str ); |
506 | } | 970 | } |
507 | 971 | ||
508 | // vcard conversion code | 972 | // vcard conversion code |
973 | /*! | ||
974 | \internal | ||
975 | */ | ||
509 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 976 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
510 | { | 977 | { |
511 | VObject *ret = 0; | 978 | VObject *ret = 0; |
512 | if ( o && !value.isEmpty() ) | 979 | if ( o && !value.isEmpty() ) |
513 | ret = addPropValue( o, prop, value.latin1() ); | 980 | ret = addPropValue( o, prop, value.latin1() ); |
514 | return ret; | 981 | return ret; |
515 | } | 982 | } |
516 | 983 | ||
984 | /*! | ||
985 | \internal | ||
986 | */ | ||
517 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 987 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
518 | { | 988 | { |
519 | VObject *ret = 0; | 989 | VObject *ret = 0; |
520 | if ( o ) | 990 | if ( o ) |
521 | ret = addProp( o, prop ); | 991 | ret = addProp( o, prop ); |
522 | return ret; | 992 | return ret; |
523 | } | 993 | } |
524 | 994 | ||
995 | /*! | ||
996 | \internal | ||
997 | */ | ||
525 | static VObject *createVObject( const Contact &c ) | 998 | static VObject *createVObject( const Contact &c ) |
526 | { | 999 | { |
527 | VObject *vcard = newVObject( VCCardProp ); | 1000 | VObject *vcard = newVObject( VCCardProp ); |
528 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); | 1001 | safeAddPropValue( vcard, VCVersionProp, "2.1" ); |
529 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); | 1002 | safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); |
530 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); | 1003 | safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); |
531 | 1004 | ||
532 | // full name | 1005 | // full name |
@@ -617,22 +1090,23 @@ static VObject *createVObject( const Contact &c ) | |||
617 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); | 1090 | safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); |
618 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); | 1091 | safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); |
619 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); | 1092 | safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); |
620 | 1093 | ||
621 | return vcard; | 1094 | return vcard; |
622 | } | 1095 | } |
623 | 1096 | ||
624 | 1097 | ||
1098 | /*! | ||
1099 | \internal | ||
1100 | */ | ||
625 | static Contact parseVObject( VObject *obj ) | 1101 | static Contact parseVObject( VObject *obj ) |
626 | { | 1102 | { |
627 | Contact c; | 1103 | Contact c; |
628 | 1104 | ||
629 | bool haveDefaultEmail = FALSE; | ||
630 | |||
631 | VObjectIterator it; | 1105 | VObjectIterator it; |
632 | initPropIterator( &it, obj ); | 1106 | initPropIterator( &it, obj ); |
633 | while( moreIteration( &it ) ) { | 1107 | while( moreIteration( &it ) ) { |
634 | VObject *o = nextVObject( &it ); | 1108 | VObject *o = nextVObject( &it ); |
635 | QCString name = vObjectName( o ); | 1109 | QCString name = vObjectName( o ); |
636 | QCString value = vObjectStringZValue( o ); | 1110 | QCString value = vObjectStringZValue( o ); |
637 | if ( name == VCNameProp ) { | 1111 | if ( name == VCNameProp ) { |
638 | VObjectIterator nit; | 1112 | VObjectIterator nit; |
@@ -762,24 +1236,17 @@ static Contact parseVObject( VObject *obj ) | |||
762 | QCString name = vObjectTypeInfo( o ); | 1236 | QCString name = vObjectTypeInfo( o ); |
763 | if ( name != VCInternetProp && name != VCHomeProp && | 1237 | if ( name != VCInternetProp && name != VCHomeProp && |
764 | name != VCWorkProp && | 1238 | name != VCWorkProp && |
765 | name != VCPreferredProp ) | 1239 | name != VCPreferredProp ) |
766 | // ### preffered should map to default email | 1240 | // ### preffered should map to default email |
767 | valid = FALSE; | 1241 | valid = FALSE; |
768 | } | 1242 | } |
769 | if ( valid ) { | 1243 | if ( valid ) { |
770 | if ( haveDefaultEmail ) { | 1244 | c.insertEmail( email ); |
771 | QString str = c.emails(); | ||
772 | if ( !str.isEmpty() ) | ||
773 | str += ","+email; | ||
774 | c.setEmails( str ); | ||
775 | } else { | ||
776 | c.setDefaultEmail( email ); | ||
777 | } | ||
778 | } | 1245 | } |
779 | } | 1246 | } |
780 | else if ( name == VCURLProp ) { | 1247 | else if ( name == VCURLProp ) { |
781 | VObjectIterator nit; | 1248 | VObjectIterator nit; |
782 | initPropIterator( &nit, o ); | 1249 | initPropIterator( &nit, o ); |
783 | while( moreIteration( &nit ) ) { | 1250 | while( moreIteration( &nit ) ) { |
784 | VObject *o = nextVObject( &nit ); | 1251 | VObject *o = nextVObject( &nit ); |
785 | QCString name = vObjectTypeInfo( o ); | 1252 | QCString name = vObjectTypeInfo( o ); |
@@ -846,16 +1313,19 @@ static Contact parseVObject( VObject *obj ) | |||
846 | } | 1313 | } |
847 | } | 1314 | } |
848 | #endif | 1315 | #endif |
849 | } | 1316 | } |
850 | c.setFileAs(); | 1317 | c.setFileAs(); |
851 | return c; | 1318 | return c; |
852 | } | 1319 | } |
853 | 1320 | ||
1321 | /*! | ||
1322 | Writes the list of \a contacts as a set of VCards to the file \a filename. | ||
1323 | */ | ||
854 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) | 1324 | void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) |
855 | { | 1325 | { |
856 | QFileDirect f( filename.utf8().data() ); | 1326 | QFileDirect f( filename.utf8().data() ); |
857 | if ( !f.open( IO_WriteOnly ) ) { | 1327 | if ( !f.open( IO_WriteOnly ) ) { |
858 | qWarning("Unable to open vcard write"); | 1328 | qWarning("Unable to open vcard write"); |
859 | return; | 1329 | return; |
860 | } | 1330 | } |
861 | 1331 | ||
@@ -863,32 +1333,37 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co | |||
863 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1333 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
864 | VObject *obj = createVObject( *it ); | 1334 | VObject *obj = createVObject( *it ); |
865 | writeVObject(f.directHandle() , obj ); | 1335 | writeVObject(f.directHandle() , obj ); |
866 | cleanVObject( obj ); | 1336 | cleanVObject( obj ); |
867 | } | 1337 | } |
868 | cleanStrTbl(); | 1338 | cleanStrTbl(); |
869 | } | 1339 | } |
870 | 1340 | ||
1341 | /*! | ||
1342 | writes \a contact as a VCard to the file \a filename. | ||
1343 | */ | ||
871 | void Contact::writeVCard( const QString &filename, const Contact &contact) | 1344 | void Contact::writeVCard( const QString &filename, const Contact &contact) |
872 | { | 1345 | { |
873 | QFileDirect f( filename.utf8().data() ); | 1346 | QFileDirect f( filename.utf8().data() ); |
874 | if ( !f.open( IO_WriteOnly ) ) { | 1347 | if ( !f.open( IO_WriteOnly ) ) { |
875 | qWarning("Unable to open vcard write"); | 1348 | qWarning("Unable to open vcard write"); |
876 | return; | 1349 | return; |
877 | } | 1350 | } |
878 | 1351 | ||
879 | VObject *obj = createVObject( contact ); | 1352 | VObject *obj = createVObject( contact ); |
880 | writeVObject( f.directHandle() , obj ); | 1353 | writeVObject( f.directHandle() , obj ); |
881 | cleanVObject( obj ); | 1354 | cleanVObject( obj ); |
882 | 1355 | ||
883 | cleanStrTbl(); | 1356 | cleanStrTbl(); |
884 | } | 1357 | } |
885 | 1358 | ||
886 | 1359 | /*! | |
1360 | Returns the set of contacts read as VCards from the file \a filename. | ||
1361 | */ | ||
887 | QValueList<Contact> Contact::readVCard( const QString &filename ) | 1362 | QValueList<Contact> Contact::readVCard( const QString &filename ) |
888 | { | 1363 | { |
889 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1364 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
890 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1365 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
891 | 1366 | ||
892 | qDebug("vobject = %p", obj ); | 1367 | qDebug("vobject = %p", obj ); |
893 | 1368 | ||
894 | QValueList<Contact> contacts; | 1369 | QValueList<Contact> contacts; |
@@ -899,21 +1374,30 @@ QValueList<Contact> Contact::readVCard( const QString &filename ) | |||
899 | VObject *t = obj; | 1374 | VObject *t = obj; |
900 | obj = nextVObjectInList(obj); | 1375 | obj = nextVObjectInList(obj); |
901 | cleanVObject( t ); | 1376 | cleanVObject( t ); |
902 | } | 1377 | } |
903 | 1378 | ||
904 | return contacts; | 1379 | return contacts; |
905 | } | 1380 | } |
906 | 1381 | ||
1382 | /*! | ||
1383 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
1384 | Otherwise returns FALSE. | ||
1385 | */ | ||
907 | bool Contact::match( const QString ®exp ) const | 1386 | bool Contact::match( const QString ®exp ) const |
908 | { | 1387 | { |
909 | return match(QRegExp(regexp)); | 1388 | return match(QRegExp(regexp)); |
910 | } | 1389 | } |
911 | 1390 | ||
1391 | /*! | ||
1392 | \overload | ||
1393 | Returns TRUE if the contact matches the regular expression \a regexp. | ||
1394 | Otherwise returns FALSE. | ||
1395 | */ | ||
912 | bool Contact::match( const QRegExp &r ) const | 1396 | bool Contact::match( const QRegExp &r ) const |
913 | { | 1397 | { |
914 | bool match; | 1398 | bool match; |
915 | match = false; | 1399 | match = false; |
916 | QMap<int, QString>::ConstIterator it; | 1400 | QMap<int, QString>::ConstIterator it; |
917 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1401 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
918 | if ( (*it).find( r ) > -1 ) { | 1402 | if ( (*it).find( r ) > -1 ) { |
919 | match = true; | 1403 | match = true; |
diff --git a/library/backend/contact.h b/library/backend/contact.h index a74cbbe..4999430 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -16,24 +16,24 @@ | |||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __CONTACT_H__ | 21 | #ifndef __CONTACT_H__ |
22 | #define __CONTACT_H__ | 22 | #define __CONTACT_H__ |
23 | 23 | ||
24 | #include <qpe/palmtoprecord.h> | 24 | #include <qtopia/private/palmtoprecord.h> |
25 | #include <qpe/recordfields.h> | 25 | #include <qtopia/private/recordfields.h> |
26 | 26 | ||
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | 28 | ||
29 | #if defined(QPC_TEMPLATEDLL) | 29 | #if defined(QPC_TEMPLATEDLL) |
30 | // MOC_SKIP_BEGIN | 30 | // MOC_SKIP_BEGIN |
31 | template class QPC_EXPORT QMap<int, QString>; | 31 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
32 | // MOC_SKIP_END | 32 | // MOC_SKIP_END |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | class ContactPrivate; | 35 | class ContactPrivate; |
36 | class QPC_EXPORT Contact : public Qtopia::Record | 36 | class QPC_EXPORT Contact : public Qtopia::Record |
37 | { | 37 | { |
38 | friend class DataSet; | 38 | friend class DataSet; |
39 | public: | 39 | public: |
@@ -51,19 +51,22 @@ public: | |||
51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 51 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 52 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 53 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 54 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 55 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
56 | void setFileAs(); | 56 | void setFileAs(); |
57 | 57 | ||
58 | // default email address | 58 | // default email address |
59 | void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } | 59 | void setDefaultEmail( const QString &v ); |
60 | // the emails should be seperated by a semicolon | 60 | // inserts email to list and ensure's doesn't already exist |
61 | void setEmails( const QString &v ); | 61 | void insertEmail( const QString &v ); |
62 | void removeEmail( const QString &v ); | ||
63 | void clearEmails(); | ||
64 | void insertEmails( const QStringList &v ); | ||
62 | 65 | ||
63 | // home | 66 | // home |
64 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 67 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
65 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 68 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
66 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 69 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
67 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 70 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
68 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 71 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
69 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 72 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
@@ -118,17 +121,16 @@ public: | |||
118 | QString firstName() const { return find( Qtopia::FirstName ); } | 121 | QString firstName() const { return find( Qtopia::FirstName ); } |
119 | QString middleName() const { return find( Qtopia::MiddleName ); } | 122 | QString middleName() const { return find( Qtopia::MiddleName ); } |
120 | QString lastName() const { return find( Qtopia::LastName ); } | 123 | QString lastName() const { return find( Qtopia::LastName ); } |
121 | QString suffix() const { return find( Qtopia::Suffix ); } | 124 | QString suffix() const { return find( Qtopia::Suffix ); } |
122 | QString fileAs() const { return find( Qtopia::FileAs ); } | 125 | QString fileAs() const { return find( Qtopia::FileAs ); } |
123 | 126 | ||
124 | 127 | ||
125 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 128 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
126 | QString emails() const { return find( Qtopia::Emails ); } | ||
127 | QStringList emailList() const; | 129 | QStringList emailList() const; |
128 | 130 | ||
129 | // home | 131 | // home |
130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 132 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
131 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 133 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
132 | QString homeState() const { return find( Qtopia::HomeState ); } | 134 | QString homeState() const { return find( Qtopia::HomeState ); } |
133 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 135 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 136 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
@@ -197,26 +199,108 @@ public: | |||
197 | // journaling... | 199 | // journaling... |
198 | void saveJournal( journal_action action, const QString &key = QString::null ); | 200 | void saveJournal( journal_action action, const QString &key = QString::null ); |
199 | void save( QString &buf ) const; | 201 | void save( QString &buf ) const; |
200 | 202 | ||
201 | void setUid( int i ) | 203 | void setUid( int i ) |
202 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 204 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
203 | 205 | ||
204 | private: | 206 | private: |
207 | friend class AbEditor; | ||
205 | friend class AbTable; | 208 | friend class AbTable; |
209 | friend class AddressBookAccessPrivate; | ||
210 | friend class XMLIO; | ||
211 | |||
212 | QString emailSeparator() const { return " "; } | ||
213 | // the emails should be seperated by a comma | ||
214 | void setEmails( const QString &v ); | ||
215 | QString emails() const { return find( Qtopia::Emails ); } | ||
216 | |||
206 | void insert( int key, const QString &value ); | 217 | void insert( int key, const QString &value ); |
207 | void replace( int key, const QString &value ); | 218 | void replace( int key, const QString &value ); |
208 | QString find( int key ) const; | 219 | QString find( int key ) const; |
209 | 220 | ||
210 | QString displayAddress( const QString &street, | 221 | QString displayAddress( const QString &street, |
211 | const QString &city, | 222 | const QString &city, |
212 | const QString &state, | 223 | const QString &state, |
213 | const QString &zip, | 224 | const QString &zip, |
214 | const QString &country ) const; | 225 | const QString &country ) const; |
215 | 226 | ||
216 | Qtopia::UidGen &uidGen() { return sUidGen; } | 227 | Qtopia::UidGen &uidGen() { return sUidGen; } |
217 | static Qtopia::UidGen sUidGen; | 228 | static Qtopia::UidGen sUidGen; |
218 | QMap<int, QString> mMap; | 229 | QMap<int, QString> mMap; |
219 | ContactPrivate *d; | 230 | ContactPrivate *d; |
220 | }; | 231 | }; |
221 | 232 | ||
233 | // these methods are inlined to keep binary compatability with Qtopia 1.5 | ||
234 | inline void Contact::insertEmail( const QString &v ) | ||
235 | { | ||
236 | //qDebug("insertEmail %s", v.latin1()); | ||
237 | QString e = v.simplifyWhiteSpace(); | ||
238 | QString def = defaultEmail(); | ||
239 | |||
240 | // if no default, set it as the default email and don't insert | ||
241 | if ( def.isEmpty() ) { | ||
242 | setDefaultEmail( e ); // will insert into the list for us | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | // otherwise, insert assuming doesn't already exist | ||
247 | QString emailsStr = find( Qtopia::Emails ); | ||
248 | if ( emailsStr.contains( e )) | ||
249 | return; | ||
250 | if ( !emailsStr.isEmpty() ) | ||
251 | emailsStr += emailSeparator(); | ||
252 | emailsStr += e; | ||
253 | replace( Qtopia::Emails, emailsStr ); | ||
254 | } | ||
255 | |||
256 | inline void Contact::removeEmail( const QString &v ) | ||
257 | { | ||
258 | QString e = v.simplifyWhiteSpace(); | ||
259 | QString def = defaultEmail(); | ||
260 | QString emailsStr = find( Qtopia::Emails ); | ||
261 | QStringList emails = emailList(); | ||
262 | |||
263 | // otherwise, must first contain it | ||
264 | if ( !emailsStr.contains( e ) ) | ||
265 | return; | ||
266 | |||
267 | // remove it | ||
268 | //qDebug(" removing email from list %s", e.latin1()); | ||
269 | emails.remove( e ); | ||
270 | // reset the string | ||
271 | emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator | ||
272 | replace( Qtopia::Emails, emailsStr ); | ||
273 | |||
274 | // if default, then replace the default email with the first one | ||
275 | if ( def == e ) { | ||
276 | //qDebug("removeEmail is default; setting new default"); | ||
277 | if ( !emails.count() ) | ||
278 | clearEmails(); | ||
279 | else // setDefaultEmail will remove e from the list | ||
280 | setDefaultEmail( emails.first() ); | ||
281 | } | ||
282 | } | ||
283 | inline void Contact::clearEmails() | ||
284 | { | ||
285 | mMap.remove( Qtopia::DefaultEmail ); | ||
286 | mMap.remove( Qtopia::Emails ); | ||
287 | } | ||
288 | inline void Contact::setDefaultEmail( const QString &v ) | ||
289 | { | ||
290 | QString e = v.simplifyWhiteSpace(); | ||
291 | |||
292 | //qDebug("Contact::setDefaultEmail %s", e.latin1()); | ||
293 | replace( Qtopia::DefaultEmail, e ); | ||
294 | |||
295 | if ( !e.isEmpty() ) | ||
296 | insertEmail( e ); | ||
297 | |||
298 | } | ||
299 | |||
300 | inline void Contact::insertEmails( const QStringList &v ) | ||
301 | { | ||
302 | for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) | ||
303 | insertEmail( *it ); | ||
304 | } | ||
305 | |||
222 | #endif | 306 | #endif |
diff --git a/library/backend/event.cpp b/library/backend/event.cpp index 50a663d..7110717 100644 --- a/library/backend/event.cpp +++ b/library/backend/event.cpp | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -15,19 +15,19 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "event.h" | 21 | #include "event.h" |
22 | #include "qfiledirect_p.h" | 22 | #include "qfiledirect_p.h" |
23 | #include <qpe/timeconversion.h> | 23 | #include <qtopia/timeconversion.h> |
24 | #include <qpe/stringutil.h> | 24 | #include <qtopia/stringutil.h> |
25 | #include <qpe/recordfields.h> | 25 | #include <qtopia/private/recordfields.h> |
26 | #include <qbuffer.h> | 26 | #include <qbuffer.h> |
27 | #include <time.h> | 27 | #include <time.h> |
28 | #include "vobject_p.h" | 28 | #include "vobject_p.h" |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | using namespace Qtopia; | 32 | using namespace Qtopia; |
33 | 33 | ||
@@ -66,28 +66,280 @@ static void write( QString& buf, const Event::RepeatPattern &r ) | |||
66 | buf += " enddt=\"" | 66 | buf += " enddt=\"" |
67 | + QString::number( r.endDateUTC ? r.endDateUTC : time( 0 ) ) | 67 | + QString::number( r.endDateUTC ? r.endDateUTC : time( 0 ) ) |
68 | + "\""; | 68 | + "\""; |
69 | buf += " created=\"" + QString::number( r.createTime ) + "\""; | 69 | buf += " created=\"" + QString::number( r.createTime ) + "\""; |
70 | } | 70 | } |
71 | 71 | ||
72 | Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); | 72 | Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); |
73 | 73 | ||
74 | /*! | ||
75 | \class Event event.h | ||
76 | \brief The Event class holds the data of a calendar event. | ||
77 | |||
78 | This data includes descriptive data of the event and schedualing information. | ||
79 | |||
80 | \ingroup qtopiaemb | ||
81 | \ingroup qtopiadesktop | ||
82 | */ | ||
83 | |||
84 | /*! | ||
85 | \class Event::RepeatPattern | ||
86 | \class The Event::RepeatPattern class is internal. | ||
87 | \internal | ||
88 | */ | ||
89 | |||
90 | /*! | ||
91 | \enum Event::Days | ||
92 | \internal | ||
93 | */ | ||
94 | |||
95 | /*! | ||
96 | \enum Event::Type | ||
97 | \internal | ||
98 | */ | ||
99 | |||
100 | /*! | ||
101 | \enum Event::SoundTypeChoice | ||
102 | |||
103 | This enum type defines what kind of sound is made when an alarm occurs | ||
104 | for an event. The currently defined types are: | ||
105 | |||
106 | <ul> | ||
107 | <li>\c Silent - No sound is produced. | ||
108 | <li>\c Loud - A loud sound is produced. | ||
109 | </ul> | ||
110 | */ | ||
111 | |||
112 | /*! | ||
113 | \fn bool Event::operator<( const Event & ) const | ||
114 | \internal | ||
115 | */ | ||
116 | |||
117 | /*! | ||
118 | \fn bool Event::operator<=( const Event & ) const | ||
119 | \internal | ||
120 | */ | ||
121 | |||
122 | /*! | ||
123 | \fn bool Event::operator!=( const Event & ) const | ||
124 | \internal | ||
125 | */ | ||
126 | |||
127 | /*! | ||
128 | \fn bool Event::operator>( const Event & ) const | ||
129 | \internal | ||
130 | */ | ||
131 | |||
132 | /*! | ||
133 | \fn bool Event::operator>=( const Event & ) const | ||
134 | \internal | ||
135 | */ | ||
136 | |||
137 | /*! | ||
138 | \enum Event::RepeatType | ||
139 | |||
140 | This enum defines how a event will repeat, if at all. | ||
141 | |||
142 | <ul> | ||
143 | <li>\c NoRepeat - Event does not repeat. | ||
144 | <li>\c Daily - Event occurs every n days. | ||
145 | <li>\c Weekly - Event occurs every n weeks. | ||
146 | <li>\c MonthlyDay - Event occurs every n months. Event will always occur in | ||
147 | the same week and same day of week as the first event. | ||
148 | <li>\c MonthlyDate - Event occurs every n months. Event will always occur | ||
149 | on the same day of the month as the first event. | ||
150 | <li>\c Yearly - Event occurs every n years. | ||
151 | </ul> | ||
152 | */ | ||
153 | |||
154 | /*! | ||
155 | \fn bool Event::isAllDay() const | ||
156 | |||
157 | Returns TRUE if the event is an all day event. Otherwise returns FALSE. | ||
158 | */ | ||
159 | |||
160 | /*! | ||
161 | \fn void Event::setAllDay(bool allday) | ||
162 | |||
163 | If \a allday is TRUE, will set the event to be an all day event. | ||
164 | Otherwise sets the event to not be an all day event. | ||
165 | |||
166 | \warning This function may affect the start and end times of the event. | ||
167 | */ | ||
168 | |||
169 | /*! | ||
170 | \fn QDateTime Event::start() const | ||
171 | |||
172 | Returns the start date and time of the first occurance of the event. | ||
173 | */ | ||
174 | |||
175 | /*! | ||
176 | \fn QDateTime Event::end() const | ||
177 | |||
178 | Returns the end date and time of the first occurance of the event. | ||
179 | */ | ||
180 | |||
181 | /*! | ||
182 | \fn time_t Event::startTime() const | ||
183 | \internal | ||
184 | */ | ||
185 | |||
186 | /*! | ||
187 | \fn time_t Event::endTime() const | ||
188 | \internal | ||
189 | */ | ||
190 | |||
191 | /*! | ||
192 | \fn void Event::setAlarm(int delay, SoundTypeChoice s) | ||
193 | |||
194 | Sets the alarm delay of the event to \a delay and the sound type of the | ||
195 | alarm to \a s. | ||
196 | */ | ||
197 | |||
198 | /*! | ||
199 | \fn void Event::clearAlarm() | ||
200 | |||
201 | Clears the alarm for the event. | ||
202 | */ | ||
203 | |||
204 | /*! | ||
205 | \fn int Event::alarmDelay() const | ||
206 | |||
207 | Returns the delay in minutes between the alarm for an event and the | ||
208 | start of the event. | ||
209 | */ | ||
210 | |||
211 | /*! | ||
212 | \fn Event::RepeatType Event::repeatType() const | ||
213 | |||
214 | Returns the repeat pattern type for the event. | ||
215 | |||
216 | \sa frequency() | ||
217 | */ | ||
218 | |||
219 | /*! | ||
220 | \fn int Event::weekOffset() const | ||
221 | |||
222 | Returns the number of weeks from the start of the month that this event | ||
223 | occurs. | ||
224 | */ | ||
225 | |||
226 | /*! | ||
227 | \fn QDate Event::repeatTill() const | ||
228 | |||
229 | Returns the date that the event will continue to repeat until. If the event | ||
230 | repeats forever the value returned is undefined. | ||
231 | |||
232 | \sa repeatForever() | ||
233 | */ | ||
234 | |||
235 | /*! | ||
236 | \fn bool Event::repeatForever() const | ||
237 | |||
238 | Returns FALSE if there is a date set for the event to continue until. | ||
239 | Otherwise returns TRUE. | ||
240 | */ | ||
241 | |||
242 | /*! | ||
243 | \fn bool Event::doRepeat() const | ||
244 | \internal | ||
245 | */ | ||
246 | |||
247 | /*! | ||
248 | \fn bool Event::repeatOnWeekDay(int day) const | ||
249 | |||
250 | Returns TRUE if the event has a RepeatType of Weekly and is set to occur on | ||
251 | \a day each week. Otherwise returns FALSE. | ||
252 | |||
253 | \sa QDate::dayName() | ||
254 | */ | ||
255 | |||
256 | /*! | ||
257 | \fn void Event::setRepeatOnWeekDay(int day, bool enable) | ||
258 | |||
259 | If \a enable is TRUE then sets the event to occur on \a day each week. | ||
260 | Otherwise sets the event not to occur on \a day. | ||
261 | |||
262 | \warning this function is only relavent for a event with RepeatType of | ||
263 | Weekly. | ||
264 | |||
265 | \sa QDate::dayName() | ||
266 | */ | ||
267 | |||
268 | /*! | ||
269 | \fn int Event::frequency() const | ||
270 | |||
271 | Returns how often the event repeats. | ||
272 | |||
273 | \sa repeatType() | ||
274 | */ | ||
275 | |||
276 | /*! | ||
277 | \fn void Event::setRepeatType(RepeatType t) | ||
278 | |||
279 | Sets the repeat pattern type of the event to \a t. | ||
280 | |||
281 | \sa setFrequency() | ||
282 | */ | ||
283 | |||
284 | /*! | ||
285 | \fn void Event::setFrequency(int n) | ||
286 | |||
287 | Sets how often the event occurs with in its repeat pattern. | ||
288 | |||
289 | \sa setRepeatType() | ||
290 | */ | ||
291 | |||
292 | /*! | ||
293 | \fn void Event::setRepeatTill(const QDate &d) | ||
294 | |||
295 | Sets the event to repeat until \a d. | ||
296 | */ | ||
297 | |||
298 | /*! | ||
299 | \fn void Event::setRepeatForever(bool enable) | ||
300 | |||
301 | If \a enable is TRUE, sets the event to repeat forever. Otherwise | ||
302 | sets the event to stop repeating at some date. | ||
303 | |||
304 | \warning This function may affect the specific date the event will repeat | ||
305 | till. | ||
306 | */ | ||
307 | |||
308 | /*! | ||
309 | \fn bool Event::match(const QRegExp &r) const | ||
310 | |||
311 | Returns TRUE if the event matches the regular expression \a r. | ||
312 | Otherwise returns FALSE. | ||
313 | */ | ||
314 | |||
315 | /*! | ||
316 | \fn char Event::day(int) | ||
317 | \internal | ||
318 | */ | ||
319 | |||
320 | /*! | ||
321 | Creates a new, empty event. | ||
322 | */ | ||
74 | Event::Event() : Record() | 323 | Event::Event() : Record() |
75 | { | 324 | { |
76 | startUTC = endUTC = time( 0 ); | 325 | startUTC = endUTC = time( 0 ); |
77 | typ = Normal; | 326 | typ = Normal; |
78 | hAlarm = FALSE; | 327 | hAlarm = FALSE; |
79 | hRepeat = FALSE; | 328 | hRepeat = FALSE; |
80 | aMinutes = 0; | 329 | aMinutes = 0; |
81 | aSound = Silent; | 330 | aSound = Silent; |
82 | pattern.type = NoRepeat; | 331 | pattern.type = NoRepeat; |
83 | pattern.frequency = -1; | 332 | pattern.frequency = -1; |
84 | } | 333 | } |
85 | 334 | ||
335 | /*! | ||
336 | \internal | ||
337 | */ | ||
86 | Event::Event( const QMap<int, QString> &map ) | 338 | Event::Event( const QMap<int, QString> &map ) |
87 | { | 339 | { |
88 | setDescription( map[DatebookDescription] ); | 340 | setDescription( map[DatebookDescription] ); |
89 | setLocation( map[Location] ); | 341 | setLocation( map[Location] ); |
90 | setCategories( idsFromString( map[DatebookCategory] ) ); | 342 | setCategories( idsFromString( map[DatebookCategory] ) ); |
91 | setTimeZone( map[TimeZone] ); | 343 | setTimeZone( map[TimeZone] ); |
92 | setNotes( map[Note] ); | 344 | setNotes( map[Note] ); |
93 | setStart( TimeConversion::fromUTC( map[StartDateTime].toUInt() ) ); | 345 | setStart( TimeConversion::fromUTC( map[StartDateTime].toUInt() ) ); |
@@ -101,66 +353,91 @@ Event::Event( const QMap<int, QString> &map ) | |||
101 | p.days = map[ RepeatPatternDays ].toInt(); | 353 | p.days = map[ RepeatPatternDays ].toInt(); |
102 | p.hasEndDate = map[ RepeatPatternHasEndDate ].toInt(); | 354 | p.hasEndDate = map[ RepeatPatternHasEndDate ].toInt(); |
103 | p.endDateUTC = map[ RepeatPatternEndDate ].toUInt(); | 355 | p.endDateUTC = map[ RepeatPatternEndDate ].toUInt(); |
104 | setRepeat( p ); | 356 | setRepeat( p ); |
105 | 357 | ||
106 | setUid( map[ DatebookUid ].toInt() ); | 358 | setUid( map[ DatebookUid ].toInt() ); |
107 | } | 359 | } |
108 | 360 | ||
361 | /*! | ||
362 | Destroys an event. | ||
363 | */ | ||
109 | Event::~Event() | 364 | Event::~Event() |
110 | { | 365 | { |
111 | } | 366 | } |
112 | 367 | ||
368 | /*! | ||
369 | \internal | ||
370 | */ | ||
113 | int Event::week( const QDate& date ) | 371 | int Event::week( const QDate& date ) |
114 | { | 372 | { |
115 | // Calculates the week this date is in within that | 373 | // Calculates the week this date is in within that |
116 | // month. Equals the "row" is is in in the month view | 374 | // month. Equals the "row" is is in in the month view |
117 | int week = 1; | 375 | int week = 1; |
118 | QDate tmp( date.year(), date.month(), 1 ); | 376 | QDate tmp( date.year(), date.month(), 1 ); |
119 | 377 | ||
120 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) | 378 | if ( date.dayOfWeek() < tmp.dayOfWeek() ) |
121 | ++week; | 379 | ++week; |
122 | 380 | ||
123 | week += ( date.day() - 1 ) / 7; | 381 | week += ( date.day() - 1 ) / 7; |
124 | return week; | 382 | return week; |
125 | } | 383 | } |
126 | 384 | ||
385 | /*! | ||
386 | \internal | ||
387 | */ | ||
127 | int Event::occurrence( const QDate& date ) | 388 | int Event::occurrence( const QDate& date ) |
128 | { | 389 | { |
129 | // calculates the number of occurrances of this day of the | 390 | // calculates the number of occurrances of this day of the |
130 | // week till the given date (e.g 3rd Wednesday of the month) | 391 | // week till the given date (e.g 3rd Wednesday of the month) |
131 | return ( date.day() - 1 ) / 7 + 1; | 392 | return ( date.day() - 1 ) / 7 + 1; |
132 | } | 393 | } |
133 | 394 | ||
395 | /*! | ||
396 | \internal | ||
397 | */ | ||
134 | int Event::dayOfWeek( char day ) | 398 | int Event::dayOfWeek( char day ) |
135 | { | 399 | { |
136 | int dayOfWeek = 1; | 400 | int dayOfWeek = 1; |
137 | char i = Event::MON; | 401 | char i = Event::MON; |
138 | while ( !( i & day ) && i <= Event::SUN ) { | 402 | while ( !( i & day ) && i <= Event::SUN ) { |
139 | i <<= 1; | 403 | i <<= 1; |
140 | ++dayOfWeek; | 404 | ++dayOfWeek; |
141 | } | 405 | } |
142 | return dayOfWeek; | 406 | return dayOfWeek; |
143 | } | 407 | } |
144 | 408 | ||
409 | /*! | ||
410 | \internal | ||
411 | */ | ||
145 | int Event::monthDiff( const QDate& first, const QDate& second ) | 412 | int Event::monthDiff( const QDate& first, const QDate& second ) |
146 | { | 413 | { |
147 | return ( second.year() - first.year() ) * 12 + | 414 | return ( second.year() - first.year() ) * 12 + |
148 | second.month() - first.month(); | 415 | second.month() - first.month(); |
149 | } | 416 | } |
150 | 417 | ||
418 | /*! | ||
419 | \internal | ||
420 | */ | ||
151 | QMap<int, QString> Event::toMap() const | 421 | QMap<int, QString> Event::toMap() const |
152 | { | 422 | { |
153 | QMap<int, QString> m; | 423 | QMap<int, QString> m; |
424 | |||
425 | if ( !description().isEmpty() ) | ||
154 | m.insert( DatebookDescription, description() ); | 426 | m.insert( DatebookDescription, description() ); |
427 | if ( !location().isEmpty() ) | ||
155 | m.insert ( Location, location() ); | 428 | m.insert ( Location, location() ); |
429 | if ( categories().count() ) | ||
156 | m.insert ( DatebookCategory, idsToString( categories() ) ); | 430 | m.insert ( DatebookCategory, idsToString( categories() ) ); |
431 | if ( !timeZone().isEmpty() ) | ||
157 | m.insert ( TimeZone, timeZone() ); | 432 | m.insert ( TimeZone, timeZone() ); |
433 | if ( !notes().isEmpty() ) | ||
158 | m.insert ( Note, notes() ); | 434 | m.insert ( Note, notes() ); |
435 | |||
159 | m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); | 436 | m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); |
160 | m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); | 437 | m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); |
161 | m.insert ( DatebookType, QString::number( (int)type() ) ); | 438 | m.insert ( DatebookType, QString::number( (int)type() ) ); |
162 | m.insert ( HasAlarm, ( hasAlarm() ? "1" : "0" ) ); | 439 | m.insert ( HasAlarm, ( hasAlarm() ? "1" : "0" ) ); |
163 | m.insert ( SoundType, QString::number( (int)alarmSound() ) ); | 440 | m.insert ( SoundType, QString::number( (int)alarmSound() ) ); |
164 | m.insert ( AlarmTime, QString::number( alarmTime() ) ); | 441 | m.insert ( AlarmTime, QString::number( alarmTime() ) ); |
165 | m.insert ( RepeatPatternType, QString::number( static_cast<int>( repeatPattern().type ) ) ); | 442 | m.insert ( RepeatPatternType, QString::number( static_cast<int>( repeatPattern().type ) ) ); |
166 | m.insert ( RepeatPatternFrequency, QString::number( repeatPattern().frequency ) ); | 443 | m.insert ( RepeatPatternFrequency, QString::number( repeatPattern().frequency ) ); |
@@ -169,185 +446,271 @@ QMap<int, QString> Event::toMap() const | |||
169 | m.insert ( RepeatPatternHasEndDate, QString::number( static_cast<int>( repeatPattern().hasEndDate ) ) ); | 446 | m.insert ( RepeatPatternHasEndDate, QString::number( static_cast<int>( repeatPattern().hasEndDate ) ) ); |
170 | m.insert ( RepeatPatternEndDate, QString::number( repeatPattern().endDateUTC ) ); | 447 | m.insert ( RepeatPatternEndDate, QString::number( repeatPattern().endDateUTC ) ); |
171 | 448 | ||
172 | m.insert( DatebookUid, QString::number( uid()) ); | 449 | m.insert( DatebookUid, QString::number( uid()) ); |
173 | 450 | ||
174 | return m; | 451 | return m; |
175 | } | 452 | } |
176 | 453 | ||
454 | /*! | ||
455 | \internal | ||
456 | */ | ||
177 | void Event::setRepeat( const RepeatPattern &p ) | 457 | void Event::setRepeat( const RepeatPattern &p ) |
178 | { | 458 | { |
179 | setRepeat( p.type != NoRepeat, p ); | 459 | setRepeat( p.type != NoRepeat, p ); |
180 | } | 460 | } |
181 | 461 | ||
462 | /*! | ||
463 | Sets the description of the event to \a s. | ||
464 | */ | ||
182 | void Event::setDescription( const QString &s ) | 465 | void Event::setDescription( const QString &s ) |
183 | { | 466 | { |
184 | descript = s; | 467 | descript = s; |
185 | } | 468 | } |
186 | 469 | ||
470 | /*! | ||
471 | Sets the location of the event to \a s. | ||
472 | */ | ||
187 | void Event::setLocation( const QString &s ) | 473 | void Event::setLocation( const QString &s ) |
188 | { | 474 | { |
189 | locat = s; | 475 | locat = s; |
190 | } | 476 | } |
191 | 477 | ||
192 | // void Event::setCategory( const QString &s ) | 478 | // void Event::setCategory( const QString &s ) |
193 | // { | 479 | // { |
194 | // categ = s; | 480 | // categ = s; |
195 | // } | 481 | // } |
196 | 482 | ||
483 | /*! | ||
484 | \internal | ||
485 | */ | ||
197 | void Event::setType( Type t ) | 486 | void Event::setType( Type t ) |
198 | { | 487 | { |
199 | typ = t; | 488 | typ = t; |
200 | } | 489 | } |
201 | 490 | ||
491 | /*! | ||
492 | Sets the start date and time of the first or only occurance of this event | ||
493 | to the date and time \a d. \a d should be in local time. | ||
494 | */ | ||
202 | void Event::setStart( const QDateTime &d ) | 495 | void Event::setStart( const QDateTime &d ) |
203 | { | 496 | { |
204 | startUTC = TimeConversion::toUTC( d ); | 497 | startUTC = TimeConversion::toUTC( d ); |
205 | } | 498 | } |
206 | 499 | ||
500 | /*! | ||
501 | \internal | ||
502 | */ | ||
207 | void Event::setStart( time_t time ) | 503 | void Event::setStart( time_t time ) |
208 | { | 504 | { |
209 | startUTC = time; | 505 | startUTC = time; |
210 | } | 506 | } |
211 | 507 | ||
508 | /*! | ||
509 | Sets the end date and time of the first or only occurance of this event | ||
510 | to the date and time \a d. \a d should be in local time. | ||
511 | */ | ||
212 | void Event::setEnd( const QDateTime &d ) | 512 | void Event::setEnd( const QDateTime &d ) |
213 | { | 513 | { |
214 | endUTC = TimeConversion::toUTC( d ); | 514 | endUTC = TimeConversion::toUTC( d ); |
215 | } | 515 | } |
216 | 516 | ||
517 | /*! | ||
518 | \internal | ||
519 | */ | ||
217 | void Event::setEnd( time_t time ) | 520 | void Event::setEnd( time_t time ) |
218 | { | 521 | { |
219 | endUTC = time; | 522 | endUTC = time; |
220 | } | 523 | } |
221 | 524 | ||
525 | /*! | ||
526 | \internal | ||
527 | */ | ||
222 | void Event::setTimeZone( const QString &z ) | 528 | void Event::setTimeZone( const QString &z ) |
223 | { | 529 | { |
224 | tz = z; | 530 | tz = z; |
225 | } | 531 | } |
226 | 532 | ||
533 | /*! | ||
534 | \internal | ||
535 | */ | ||
227 | void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) | 536 | void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) |
228 | { | 537 | { |
229 | hAlarm = b; | 538 | hAlarm = b; |
230 | aMinutes = minutes; | 539 | aMinutes = minutes; |
231 | aSound = s; | 540 | aSound = s; |
232 | } | 541 | } |
233 | 542 | ||
543 | /*! | ||
544 | \internal | ||
545 | */ | ||
234 | void Event::setRepeat( bool b, const RepeatPattern &p ) | 546 | void Event::setRepeat( bool b, const RepeatPattern &p ) |
235 | { | 547 | { |
236 | hRepeat = b; | 548 | hRepeat = b; |
237 | pattern = p; | 549 | pattern = p; |
238 | } | 550 | } |
239 | 551 | ||
552 | /*! | ||
553 | Sets the notes for the event to \a n. | ||
554 | */ | ||
240 | void Event::setNotes( const QString &n ) | 555 | void Event::setNotes( const QString &n ) |
241 | { | 556 | { |
242 | note = n; | 557 | note = n; |
243 | } | 558 | } |
244 | 559 | ||
560 | /*! | ||
561 | Returns the description of the event. | ||
562 | */ | ||
245 | const QString &Event::description() const | 563 | const QString &Event::description() const |
246 | { | 564 | { |
247 | return descript; | 565 | return descript; |
248 | } | 566 | } |
249 | 567 | ||
568 | /*! | ||
569 | Returns the location of the event. | ||
570 | */ | ||
250 | const QString &Event::location() const | 571 | const QString &Event::location() const |
251 | { | 572 | { |
252 | return locat; | 573 | return locat; |
253 | } | 574 | } |
254 | 575 | ||
255 | // QString Event::category() const | 576 | // QString Event::category() const |
256 | // { | 577 | // { |
257 | // return categ; | 578 | // return categ; |
258 | // } | 579 | // } |
259 | 580 | ||
581 | /*! | ||
582 | \internal | ||
583 | */ | ||
260 | Event::Type Event::type() const | 584 | Event::Type Event::type() const |
261 | { | 585 | { |
262 | return typ; | 586 | return typ; |
263 | } | 587 | } |
264 | 588 | ||
589 | /*! | ||
590 | \internal | ||
591 | */ | ||
265 | QDateTime Event::start( bool actual ) const | 592 | QDateTime Event::start( bool actual ) const |
266 | { | 593 | { |
267 | QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); | 594 | QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); |
268 | 595 | ||
269 | if ( actual && typ == AllDay ) { | 596 | if ( actual && typ == AllDay ) { |
270 | QTime t = dt.time(); | 597 | QTime t = dt.time(); |
271 | t.setHMS( 0, 0, 0 ); | 598 | t.setHMS( 0, 0, 0 ); |
272 | dt.setTime( t ); | 599 | dt.setTime( t ); |
273 | } | 600 | } |
274 | return dt; | 601 | return dt; |
275 | } | 602 | } |
276 | 603 | ||
604 | /*! | ||
605 | \internal | ||
606 | */ | ||
277 | QDateTime Event::end( bool actual ) const | 607 | QDateTime Event::end( bool actual ) const |
278 | { | 608 | { |
279 | QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); | 609 | QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); |
280 | 610 | ||
281 | if ( actual && typ == AllDay ) { | 611 | if ( actual && typ == AllDay ) { |
282 | QTime t = dt.time(); | 612 | QTime t = dt.time(); |
283 | t.setHMS( 23, 59, 59 ); | 613 | t.setHMS( 23, 59, 59 ); |
284 | dt.setTime( t ); | 614 | dt.setTime( t ); |
285 | } | 615 | } |
286 | return dt; | 616 | return dt; |
287 | } | 617 | } |
288 | 618 | ||
619 | /*! | ||
620 | \internal | ||
621 | */ | ||
289 | const QString &Event::timeZone() const | 622 | const QString &Event::timeZone() const |
290 | { | 623 | { |
291 | return tz; | 624 | return tz; |
292 | } | 625 | } |
293 | 626 | ||
627 | /*! | ||
628 | \internal | ||
629 | */ | ||
294 | bool Event::hasAlarm() const | 630 | bool Event::hasAlarm() const |
295 | { | 631 | { |
296 | return hAlarm; | 632 | return hAlarm; |
297 | } | 633 | } |
298 | 634 | ||
635 | /*! | ||
636 | \internal | ||
637 | */ | ||
299 | int Event::alarmTime() const | 638 | int Event::alarmTime() const |
300 | { | 639 | { |
301 | return aMinutes; | 640 | return aMinutes; |
302 | } | 641 | } |
303 | 642 | ||
643 | /*! | ||
644 | Returns the sound type for the alarm of this event. | ||
645 | */ | ||
304 | Event::SoundTypeChoice Event::alarmSound() const | 646 | Event::SoundTypeChoice Event::alarmSound() const |
305 | { | 647 | { |
306 | return aSound; | 648 | return aSound; |
307 | } | 649 | } |
308 | 650 | ||
651 | /*! | ||
652 | \internal | ||
653 | */ | ||
309 | bool Event::hasRepeat() const | 654 | bool Event::hasRepeat() const |
310 | { | 655 | { |
311 | return doRepeat(); | 656 | return doRepeat(); |
312 | } | 657 | } |
313 | 658 | ||
659 | /*! | ||
660 | \internal | ||
661 | */ | ||
314 | const Event::RepeatPattern &Event::repeatPattern() const | 662 | const Event::RepeatPattern &Event::repeatPattern() const |
315 | { | 663 | { |
316 | return pattern; | 664 | return pattern; |
317 | } | 665 | } |
318 | 666 | ||
667 | /*! | ||
668 | \internal | ||
669 | */ | ||
319 | Event::RepeatPattern &Event::repeatPattern() | 670 | Event::RepeatPattern &Event::repeatPattern() |
320 | { | 671 | { |
321 | return pattern; | 672 | return pattern; |
322 | } | 673 | } |
323 | 674 | ||
675 | /*! | ||
676 | Returns the notes for the event. | ||
677 | */ | ||
324 | const QString &Event::notes() const | 678 | const QString &Event::notes() const |
325 | { | 679 | { |
326 | return note; | 680 | return note; |
327 | } | 681 | } |
328 | 682 | ||
683 | /*! | ||
684 | \internal | ||
685 | */ | ||
329 | bool Event::operator==( const Event &e ) const | 686 | bool Event::operator==( const Event &e ) const |
330 | { | 687 | { |
688 | if ( uid() && e.uid() == uid() ) | ||
689 | return TRUE; | ||
331 | return ( e.descript == descript && | 690 | return ( e.descript == descript && |
332 | e.locat == locat && | 691 | e.locat == locat && |
333 | e.categ == categ && | 692 | e.categ == categ && |
334 | e.typ == typ && | 693 | e.typ == typ && |
335 | e.startUTC == startUTC && | 694 | e.startUTC == startUTC && |
336 | e.endUTC == endUTC && | 695 | e.endUTC == endUTC && |
337 | e.tz == tz && | 696 | e.tz == tz && |
338 | e.hAlarm == hAlarm && | 697 | e.hAlarm == hAlarm && |
339 | e.aMinutes == aMinutes && | 698 | e.aMinutes == aMinutes && |
340 | e.aSound == aSound && | 699 | e.aSound == aSound && |
341 | e.hRepeat == hRepeat && | 700 | e.hRepeat == hRepeat && |
342 | e.pattern == pattern && | 701 | e.pattern == pattern && |
343 | e.note == note ); | 702 | e.note == note ); |
344 | } | 703 | } |
345 | 704 | ||
705 | /*! | ||
706 | \internal | ||
707 | Appends the contact information to \a buf. | ||
708 | */ | ||
346 | void Event::save( QString& buf ) | 709 | void Event::save( QString& buf ) |
347 | { | 710 | { |
348 | buf += " description=\"" + Qtopia::escapeString(descript) + "\""; | 711 | buf += " description=\"" + Qtopia::escapeString(descript) + "\""; |
349 | if ( !locat.isEmpty() ) | 712 | if ( !locat.isEmpty() ) |
350 | buf += " location=\"" + Qtopia::escapeString(locat) + "\""; | 713 | buf += " location=\"" + Qtopia::escapeString(locat) + "\""; |
351 | // save the categoies differently.... | 714 | // save the categoies differently.... |
352 | QString strCats = idsToString( categories() ); | 715 | QString strCats = idsToString( categories() ); |
353 | buf += " categories=\"" + Qtopia::escapeString(strCats) + "\""; | 716 | buf += " categories=\"" + Qtopia::escapeString(strCats) + "\""; |
@@ -373,67 +736,103 @@ void Event::save( QString& buf ) | |||
373 | + QString::number( endUTC ) | 736 | + QString::number( endUTC ) |
374 | + "\""; | 737 | + "\""; |
375 | 738 | ||
376 | if ( !note.isEmpty() ) | 739 | if ( !note.isEmpty() ) |
377 | buf += " note=\"" + Qtopia::escapeString( note ) + "\""; | 740 | buf += " note=\"" + Qtopia::escapeString( note ) + "\""; |
378 | buf += customToXml(); | 741 | buf += customToXml(); |
379 | } | 742 | } |
380 | 743 | ||
744 | /*! | ||
745 | \internal | ||
746 | */ | ||
381 | bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const | 747 | bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const |
382 | { | 748 | { |
383 | // *sigh* | 749 | // *sigh* |
384 | return ( type == right.type | 750 | return ( type == right.type |
385 | && frequency == right.frequency | 751 | && frequency == right.frequency |
386 | && position == right.position | 752 | && position == right.position |
387 | && days == right.days | 753 | && days == right.days |
388 | && hasEndDate == right.hasEndDate | 754 | && hasEndDate == right.hasEndDate |
389 | && endDateUTC == right.endDateUTC | 755 | && endDateUTC == right.endDateUTC |
390 | && createTime == right.createTime ); | 756 | && createTime == right.createTime ); |
391 | } | 757 | } |
392 | 758 | ||
759 | /*! | ||
760 | \class EffectiveEvent | ||
761 | \brief The EffectiveEvent class the data for a single occurance of an event. | ||
762 | |||
763 | This class describes the event for a single occurance of it. For example if | ||
764 | an Event occurs every week, the effective event might represent the third | ||
765 | occurance of this Event. | ||
766 | |||
767 | \ingroup qtopiaemb | ||
768 | \ingroup qtopiadesktop | ||
769 | \warning This class will be phased out in Qtopia 3.x | ||
770 | */ | ||
771 | |||
772 | /*! | ||
773 | \enum EffectiveEvent::Position | ||
774 | \internal | ||
775 | */ | ||
776 | |||
777 | /*! | ||
778 | \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &) | ||
779 | \internal | ||
780 | */ | ||
393 | 781 | ||
394 | class EffectiveEventPrivate | 782 | class EffectiveEventPrivate |
395 | { | 783 | { |
396 | public: | 784 | public: |
397 | //currently the existence of the d pointer means multi-day repeating, | 785 | //currently the existence of the d pointer means multi-day repeating, |
398 | //msut be changed if we use the d pointer for anything else. | 786 | //msut be changed if we use the d pointer for anything else. |
399 | QDate startDate; | 787 | QDate startDate; |
400 | QDate endDate; | 788 | QDate endDate; |
401 | }; | 789 | }; |
402 | 790 | ||
403 | 791 | /*! | |
792 | \internal | ||
793 | */ | ||
404 | EffectiveEvent::EffectiveEvent() | 794 | EffectiveEvent::EffectiveEvent() |
405 | { | 795 | { |
406 | mDate = QDate::currentDate(); | 796 | mDate = QDate::currentDate(); |
407 | mStart = mEnd = QTime::currentTime(); | 797 | mStart = mEnd = QTime::currentTime(); |
408 | d = 0; | 798 | d = 0; |
409 | } | 799 | } |
410 | 800 | ||
801 | /*! | ||
802 | \internal | ||
803 | */ | ||
411 | EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) | 804 | EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) |
412 | { | 805 | { |
413 | mEvent = e; | 806 | mEvent = e; |
414 | mDate = date; | 807 | mDate = date; |
415 | if ( pos & Start ) | 808 | if ( pos & Start ) |
416 | mStart = e.start( TRUE ).time(); | 809 | mStart = e.start( TRUE ).time(); |
417 | else | 810 | else |
418 | mStart = QTime( 0, 0, 0 ); | 811 | mStart = QTime( 0, 0, 0 ); |
419 | 812 | ||
420 | if ( pos & End ) | 813 | if ( pos & End ) |
421 | mEnd = e.end( TRUE ).time(); | 814 | mEnd = e.end( TRUE ).time(); |
422 | else | 815 | else |
423 | mEnd = QTime( 23, 59, 59 ); | 816 | mEnd = QTime( 23, 59, 59 ); |
424 | d = 0; | 817 | d = 0; |
425 | } | 818 | } |
426 | 819 | ||
820 | /*! | ||
821 | \internal | ||
822 | */ | ||
427 | EffectiveEvent::~EffectiveEvent() | 823 | EffectiveEvent::~EffectiveEvent() |
428 | { | 824 | { |
429 | delete d; | 825 | delete d; |
430 | } | 826 | } |
431 | 827 | ||
828 | /*! | ||
829 | \internal | ||
830 | */ | ||
432 | EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) | 831 | EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) |
433 | { | 832 | { |
434 | d = 0; | 833 | d = 0; |
435 | *this = e; | 834 | *this = e; |
436 | } | 835 | } |
437 | 836 | ||
438 | EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) | 837 | EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) |
439 | { | 838 | { |
@@ -456,148 +855,214 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) | |||
456 | 855 | ||
457 | } | 856 | } |
458 | 857 | ||
459 | // QString EffectiveEvent::category() const | 858 | // QString EffectiveEvent::category() const |
460 | // { | 859 | // { |
461 | // return mEvent.category(); | 860 | // return mEvent.category(); |
462 | // } | 861 | // } |
463 | 862 | ||
863 | /*! | ||
864 | Returns the description of the event for this effective event. | ||
865 | */ | ||
464 | const QString &EffectiveEvent::description( ) const | 866 | const QString &EffectiveEvent::description( ) const |
465 | { | 867 | { |
466 | return mEvent.description(); | 868 | return mEvent.description(); |
467 | } | 869 | } |
468 | 870 | ||
871 | /*! | ||
872 | \internal | ||
873 | */ | ||
469 | const QString &EffectiveEvent::location( ) const | 874 | const QString &EffectiveEvent::location( ) const |
470 | { | 875 | { |
471 | return mEvent.location(); | 876 | return mEvent.location(); |
472 | } | 877 | } |
473 | 878 | ||
879 | /*! | ||
880 | \internal | ||
881 | */ | ||
474 | const QString &EffectiveEvent::notes() const | 882 | const QString &EffectiveEvent::notes() const |
475 | { | 883 | { |
476 | return mEvent.notes(); | 884 | return mEvent.notes(); |
477 | } | 885 | } |
478 | 886 | ||
887 | /*! | ||
888 | Returns the event associated with this effective event. | ||
889 | */ | ||
479 | const Event &EffectiveEvent::event() const | 890 | const Event &EffectiveEvent::event() const |
480 | { | 891 | { |
481 | return mEvent; | 892 | return mEvent; |
482 | } | 893 | } |
483 | 894 | ||
895 | /*! | ||
896 | \internal | ||
897 | */ | ||
484 | const QTime &EffectiveEvent::end() const | 898 | const QTime &EffectiveEvent::end() const |
485 | { | 899 | { |
486 | return mEnd; | 900 | return mEnd; |
487 | } | 901 | } |
488 | 902 | ||
903 | /*! | ||
904 | \internal | ||
905 | */ | ||
489 | const QTime &EffectiveEvent::start() const | 906 | const QTime &EffectiveEvent::start() const |
490 | { | 907 | { |
491 | return mStart; | 908 | return mStart; |
492 | } | 909 | } |
493 | 910 | ||
911 | /*! | ||
912 | Returns the date the effective event occurs on. | ||
913 | */ | ||
494 | const QDate &EffectiveEvent::date() const | 914 | const QDate &EffectiveEvent::date() const |
495 | { | 915 | { |
496 | return mDate; | 916 | return mDate; |
497 | } | 917 | } |
498 | 918 | ||
919 | /*! | ||
920 | \internal | ||
921 | */ | ||
499 | int EffectiveEvent::length() const | 922 | int EffectiveEvent::length() const |
500 | { | 923 | { |
501 | return (mEnd.hour() * 60 - mStart.hour() * 60) | 924 | return (mEnd.hour() * 60 - mStart.hour() * 60) |
502 | + QABS(mStart.minute() - mEnd.minute() ); | 925 | + QABS(mStart.minute() - mEnd.minute() ); |
503 | } | 926 | } |
504 | 927 | ||
928 | /*! | ||
929 | \internal | ||
930 | */ | ||
505 | void EffectiveEvent::setDate( const QDate &dt ) | 931 | void EffectiveEvent::setDate( const QDate &dt ) |
506 | { | 932 | { |
507 | mDate = dt; | 933 | mDate = dt; |
508 | } | 934 | } |
509 | 935 | ||
936 | /*! | ||
937 | \internal | ||
938 | */ | ||
510 | void EffectiveEvent::setStart( const QTime &start ) | 939 | void EffectiveEvent::setStart( const QTime &start ) |
511 | { | 940 | { |
512 | mStart = start; | 941 | mStart = start; |
513 | } | 942 | } |
514 | 943 | ||
944 | /*! | ||
945 | \internal | ||
946 | */ | ||
515 | void EffectiveEvent::setEnd( const QTime &end ) | 947 | void EffectiveEvent::setEnd( const QTime &end ) |
516 | { | 948 | { |
517 | mEnd = end; | 949 | mEnd = end; |
518 | } | 950 | } |
519 | 951 | ||
952 | /*! | ||
953 | \internal | ||
954 | */ | ||
520 | void EffectiveEvent::setEvent( Event e ) | 955 | void EffectiveEvent::setEvent( Event e ) |
521 | { | 956 | { |
522 | mEvent = e; | 957 | mEvent = e; |
523 | } | 958 | } |
524 | 959 | ||
960 | /*! | ||
961 | \internal | ||
962 | */ | ||
525 | bool EffectiveEvent::operator<( const EffectiveEvent &e ) const | 963 | bool EffectiveEvent::operator<( const EffectiveEvent &e ) const |
526 | { | 964 | { |
527 | if ( mDate < e.date() ) | 965 | if ( mDate < e.date() ) |
528 | return TRUE; | 966 | return TRUE; |
529 | if ( mDate == e.date() ) | 967 | if ( mDate == e.date() ) |
530 | return ( mStart < e.start() ); | 968 | return ( mStart < e.start() ); |
531 | else | 969 | else |
532 | return FALSE; | 970 | return FALSE; |
533 | } | 971 | } |
534 | 972 | ||
973 | /*! | ||
974 | \internal | ||
975 | */ | ||
535 | bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const | 976 | bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const |
536 | { | 977 | { |
537 | return (mDate <= e.date() ); | 978 | return (mDate <= e.date() ); |
538 | } | 979 | } |
539 | 980 | ||
981 | /*! | ||
982 | \internal | ||
983 | */ | ||
540 | bool EffectiveEvent::operator==( const EffectiveEvent &e ) const | 984 | bool EffectiveEvent::operator==( const EffectiveEvent &e ) const |
541 | { | 985 | { |
542 | return ( mDate == e.date() | 986 | return ( mDate == e.date() |
543 | && mStart == e.start() | 987 | && mStart == e.start() |
544 | && mEnd == e.end() | 988 | && mEnd == e.end() |
545 | && mEvent == e.event() ); | 989 | && mEvent == e.event() ); |
546 | } | 990 | } |
547 | 991 | ||
992 | /*! | ||
993 | \internal | ||
994 | */ | ||
548 | bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const | 995 | bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const |
549 | { | 996 | { |
550 | return !(*this == e); | 997 | return !(*this == e); |
551 | } | 998 | } |
552 | 999 | ||
1000 | /*! | ||
1001 | \internal | ||
1002 | */ | ||
553 | bool EffectiveEvent::operator>( const EffectiveEvent &e ) const | 1003 | bool EffectiveEvent::operator>( const EffectiveEvent &e ) const |
554 | { | 1004 | { |
555 | return !(*this <= e ); | 1005 | return !(*this <= e ); |
556 | } | 1006 | } |
557 | 1007 | ||
1008 | /*! | ||
1009 | \internal | ||
1010 | */ | ||
558 | bool EffectiveEvent::operator>=(const EffectiveEvent &e) const | 1011 | bool EffectiveEvent::operator>=(const EffectiveEvent &e) const |
559 | { | 1012 | { |
560 | return !(*this < e); | 1013 | return !(*this < e); |
561 | } | 1014 | } |
562 | 1015 | ||
1016 | /*! | ||
1017 | \internal | ||
1018 | */ | ||
563 | void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) | 1019 | void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) |
564 | { | 1020 | { |
565 | if ( !from.isValid() ) { | 1021 | if ( !from.isValid() ) { |
566 | delete d; | 1022 | delete d; |
567 | d = 0; | 1023 | d = 0; |
568 | return; | 1024 | return; |
569 | } | 1025 | } |
570 | if ( !d ) | 1026 | if ( !d ) |
571 | d = new EffectiveEventPrivate; | 1027 | d = new EffectiveEventPrivate; |
572 | d->startDate = from; | 1028 | d->startDate = from; |
573 | d->endDate = to; | 1029 | d->endDate = to; |
574 | } | 1030 | } |
575 | 1031 | ||
1032 | /*! | ||
1033 | \internal | ||
1034 | */ | ||
576 | QDate EffectiveEvent::startDate() const | 1035 | QDate EffectiveEvent::startDate() const |
577 | { | 1036 | { |
578 | if ( d ) | 1037 | if ( d ) |
579 | return d->startDate; | 1038 | return d->startDate; |
580 | else if ( mEvent.hasRepeat() ) | 1039 | else if ( mEvent.hasRepeat() ) |
581 | return mDate; // single day, since multi-day should have a d pointer | 1040 | return mDate; // single day, since multi-day should have a d pointer |
582 | else | 1041 | else |
583 | return mEvent.start().date(); | 1042 | return mEvent.start().date(); |
584 | } | 1043 | } |
585 | 1044 | ||
1045 | /*! | ||
1046 | \internal | ||
1047 | */ | ||
586 | QDate EffectiveEvent::endDate() const | 1048 | QDate EffectiveEvent::endDate() const |
587 | { | 1049 | { |
588 | if ( d ) | 1050 | if ( d ) |
589 | return d->endDate; | 1051 | return d->endDate; |
590 | else if ( mEvent.hasRepeat() ) | 1052 | else if ( mEvent.hasRepeat() ) |
591 | return mDate; // single day, since multi-day should have a d pointer | 1053 | return mDate; // single day, since multi-day should have a d pointer |
592 | else | 1054 | else |
593 | return mEvent.end().date(); | 1055 | return mEvent.end().date(); |
594 | } | 1056 | } |
595 | 1057 | ||
1058 | /*! | ||
1059 | \internal | ||
1060 | */ | ||
596 | int EffectiveEvent::size() const | 1061 | int EffectiveEvent::size() const |
597 | { | 1062 | { |
598 | return ( mEnd.hour() - mStart.hour() ) * 3600 | 1063 | return ( mEnd.hour() - mStart.hour() ) * 3600 |
599 | + (mEnd.minute() - mStart.minute() * 60 | 1064 | + (mEnd.minute() - mStart.minute() * 60 |
600 | + mEnd.second() - mStart.second() ); | 1065 | + mEnd.second() - mStart.second() ); |
601 | } | 1066 | } |
602 | 1067 | ||
603 | 1068 | ||
@@ -735,51 +1200,71 @@ static Event parseVObject( VObject *obj ) | |||
735 | if ( haveAlarm ) { | 1200 | if ( haveAlarm ) { |
736 | int minutes = alarmTime.secsTo( e.start() ) / 60; | 1201 | int minutes = alarmTime.secsTo( e.start() ) / 60; |
737 | e.setAlarm( TRUE, minutes, soundType ); | 1202 | e.setAlarm( TRUE, minutes, soundType ); |
738 | } | 1203 | } |
739 | return e; | 1204 | return e; |
740 | } | 1205 | } |
741 | 1206 | ||
742 | 1207 | ||
743 | 1208 | /*! | |
1209 | Writes the list of \a events as a set of VCards to the file \a filename. | ||
1210 | */ | ||
744 | void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) | 1211 | void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) |
745 | { | 1212 | { |
1213 | |||
746 | QFileDirect f( filename.utf8().data() ); | 1214 | QFileDirect f( filename.utf8().data() ); |
1215 | |||
747 | if ( !f.open( IO_WriteOnly ) ) { | 1216 | if ( !f.open( IO_WriteOnly ) ) { |
1217 | |||
748 | qWarning("Unable to open vcard write"); | 1218 | qWarning("Unable to open vcard write"); |
1219 | |||
749 | return; | 1220 | return; |
1221 | |||
750 | } | 1222 | } |
751 | 1223 | ||
1224 | |||
752 | QValueList<Event>::ConstIterator it; | 1225 | QValueList<Event>::ConstIterator it; |
753 | for( it = events.begin(); it != events.end(); ++it ) { | 1226 | for( it = events.begin(); it != events.end(); ++it ) { |
754 | VObject *obj = createVObject( *it ); | 1227 | VObject *obj = createVObject( *it ); |
755 | writeVObject( f.directHandle() , obj ); | 1228 | writeVObject( f.directHandle() , obj ); |
756 | cleanVObject( obj ); | 1229 | cleanVObject( obj ); |
757 | } | 1230 | } |
758 | 1231 | ||
1232 | |||
759 | cleanStrTbl(); | 1233 | cleanStrTbl(); |
760 | } | 1234 | } |
761 | 1235 | ||
1236 | /*! | ||
1237 | Writes \a event as a VCard to the file \a filename. | ||
1238 | */ | ||
762 | void Event::writeVCalendar( const QString &filename, const Event &event) | 1239 | void Event::writeVCalendar( const QString &filename, const Event &event) |
763 | { | 1240 | { |
1241 | |||
764 | QFileDirect f( filename.utf8().data() ); | 1242 | QFileDirect f( filename.utf8().data() ); |
1243 | |||
765 | if ( !f.open( IO_WriteOnly ) ) { | 1244 | if ( !f.open( IO_WriteOnly ) ) { |
1245 | |||
766 | qWarning("Unable to open vcard write"); | 1246 | qWarning("Unable to open vcard write"); |
1247 | |||
767 | return; | 1248 | return; |
1249 | |||
768 | } | 1250 | } |
769 | 1251 | ||
1252 | |||
770 | VObject *obj = createVObject( event ); | 1253 | VObject *obj = createVObject( event ); |
771 | writeVObject( f.directHandle() , obj ); | 1254 | writeVObject( f.directHandle() , obj ); |
772 | cleanVObject( obj ); | 1255 | cleanVObject( obj ); |
773 | 1256 | ||
774 | cleanStrTbl(); | 1257 | cleanStrTbl(); |
775 | } | 1258 | } |
776 | 1259 | ||
777 | 1260 | /*! | |
1261 | Returns the set of events read as VCards from the file \a filename. | ||
1262 | */ | ||
778 | QValueList<Event> Event::readVCalendar( const QString &filename ) | 1263 | QValueList<Event> Event::readVCalendar( const QString &filename ) |
779 | { | 1264 | { |
780 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1265 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
781 | 1266 | ||
782 | QValueList<Event> events; | 1267 | QValueList<Event> events; |
783 | 1268 | ||
784 | while ( obj ) { | 1269 | while ( obj ) { |
785 | QCString name = vObjectName( obj ); | 1270 | QCString name = vObjectName( obj ); |
diff --git a/library/backend/event.h b/library/backend/event.h index 277aadd..7fe41a5 100644 --- a/library/backend/event.h +++ b/library/backend/event.h | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -18,32 +18,41 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __EVENT_H__ | 21 | #ifndef __EVENT_H__ |
22 | #define __EVENT_H__ | 22 | #define __EVENT_H__ |
23 | 23 | ||
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | #include <qvaluelist.h> | 25 | #include <qvaluelist.h> |
26 | #include <qcolor.h> | ||
26 | 27 | ||
27 | #ifdef PALMTOPCENTER | 28 | #ifdef PALMTOPCENTER |
28 | #include <qpc/qsorter.h> | 29 | #include <qpc/qsorter.h> |
29 | #endif | 30 | #endif |
30 | #include <qpe/palmtoprecord.h> | 31 | #include <qtopia/private/palmtoprecord.h> |
31 | 32 | ||
32 | #include <qpe/timeconversion.h> | 33 | #include <qpe/timeconversion.h> |
33 | 34 | ||
35 | static const QColor colorNormal = QColor(255, 0 , 0 ); | ||
36 | static const QColor colorRepeat = QColor(0 , 0 , 255); | ||
37 | static const QColor colorNormalLight = QColor(255, 220, 220); | ||
38 | static const QColor colorRepeatLight = QColor(200, 200, 255); | ||
39 | |||
34 | class EventPrivate; | 40 | class EventPrivate; |
35 | class QPC_EXPORT Event : public Qtopia::Record | 41 | class QPC_EXPORT Event : public Qtopia::Record |
36 | { | 42 | { |
37 | public: | 43 | public: |
38 | enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, | 44 | enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, |
39 | MonthlyDate, Yearly }; | 45 | MonthlyDate, Yearly }; |
46 | |||
47 | // Don't use this. | ||
40 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, | 48 | enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, |
41 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; | 49 | FRI = 0x10, SAT = 0x20, SUN = 0x40 }; |
50 | // Don't use this. | ||
42 | struct QPC_EXPORT RepeatPattern | 51 | struct QPC_EXPORT RepeatPattern |
43 | { | 52 | { |
44 | RepeatPattern() { | 53 | RepeatPattern() { |
45 | type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1; | 54 | type = NoRepeat; frequency = -1; days = 0; position = 0; createTime = -1; |
46 | hasEndDate = FALSE; endDateUTC = 0; } | 55 | hasEndDate = FALSE; endDateUTC = 0; } |
47 | bool operator ==( const RepeatPattern &right ) const; | 56 | bool operator ==( const RepeatPattern &right ) const; |
48 | 57 | ||
49 | RepeatType type; | 58 | RepeatType type; |
@@ -65,70 +74,99 @@ public: | |||
65 | 74 | ||
66 | static void writeVCalendar( const QString &filename, const QValueList<Event> &events); | 75 | static void writeVCalendar( const QString &filename, const QValueList<Event> &events); |
67 | static void writeVCalendar( const QString &filename, const Event &event); | 76 | static void writeVCalendar( const QString &filename, const Event &event); |
68 | static QValueList<Event> readVCalendar( const QString &filename ); | 77 | static QValueList<Event> readVCalendar( const QString &filename ); |
69 | 78 | ||
70 | enum Type { Normal, AllDay }; | 79 | enum Type { Normal, AllDay }; |
71 | enum SoundTypeChoice { Silent, Loud }; | 80 | enum SoundTypeChoice { Silent, Loud }; |
72 | 81 | ||
82 | // Don't use these, there are essentially meaningless. | ||
73 | bool operator<( const Event &e1) const { return start() < e1.start(); }; | 83 | bool operator<( const Event &e1) const { return start() < e1.start(); }; |
74 | bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; | 84 | bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; |
75 | bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; | 85 | bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; |
76 | bool operator>( const Event &e1 ) const { return start() > e1.start(); }; | 86 | bool operator>( const Event &e1 ) const { return start() > e1.start(); }; |
77 | bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; | 87 | bool operator>=(const Event &e1 ) const { return start() >= e1.start(); }; |
78 | bool operator==( const Event &e ) const; | 88 | bool operator==( const Event &e ) const; |
79 | 89 | ||
80 | void setDescription( const QString &s ); | 90 | void setDescription( const QString &s ); |
81 | const QString &description() const; | 91 | const QString &description() const; |
82 | 92 | ||
83 | void setLocation( const QString &s ); | 93 | void setLocation( const QString &s ); |
84 | const QString &location() const; | 94 | const QString &location() const; |
85 | 95 | ||
86 | void setType( Type t ); | 96 | void setNotes( const QString &n ); |
87 | Type type() const; | 97 | const QString ¬es() const; |
98 | |||
99 | void setType( Type t ); // Don't use me. | ||
100 | Type type() const; // Don't use me. | ||
101 | |||
102 | void setAllDay(bool); | ||
103 | bool isAllDay() const; | ||
104 | |||
88 | void setStart( const QDateTime &d ); | 105 | void setStart( const QDateTime &d ); |
89 | void setStart( time_t time ); | 106 | void setStart( time_t time ); // don't use me. |
90 | QDateTime start( bool actual = FALSE ) const; | 107 | QDateTime start( ) const; |
91 | time_t startTime() const { return startUTC; } | 108 | QDateTime start( bool actual ) const; // don't use me. |
109 | time_t startTime() const { return startUTC; } // don't use me. | ||
92 | void setEnd( const QDateTime &e ); | 110 | void setEnd( const QDateTime &e ); |
93 | void setEnd( time_t time ); | 111 | void setEnd( time_t time ); // don't use me |
94 | QDateTime end( bool actual = FALSE ) const; | 112 | QDateTime end( ) const; |
95 | time_t endTime() const { return endUTC; } | 113 | QDateTime end( bool actual ) const; // don't use me. |
114 | time_t endTime() const { return endUTC; } // don't use me. | ||
96 | void setTimeZone( const QString & ); | 115 | void setTimeZone( const QString & ); |
97 | const QString &timeZone() const; | 116 | const QString &timeZone() const; |
98 | void setAlarm( bool b, int minutes, SoundTypeChoice ); | 117 | void setAlarm( int minutes, SoundTypeChoice ); |
118 | void clearAlarm(); | ||
119 | void setAlarm( bool b, int minutes, SoundTypeChoice ); // Don't use me. | ||
99 | bool hasAlarm() const; | 120 | bool hasAlarm() const; |
100 | int alarmTime() const; | 121 | int alarmDelay() const; |
122 | int alarmTime() const; // Don't use me. | ||
101 | SoundTypeChoice alarmSound() const; | 123 | SoundTypeChoice alarmSound() const; |
124 | |||
125 | RepeatType repeatType() const; | ||
126 | int frequency() const; | ||
127 | int weekOffset() const; | ||
128 | QDate repeatTill() const; | ||
129 | bool repeatForever() const; | ||
130 | bool repeatOnWeekDay(int day) const; | ||
131 | |||
132 | void setRepeatType(RepeatType); | ||
133 | void setFrequency(int); | ||
134 | void setRepeatTill(const QDate &); | ||
135 | void setRepeatForever(bool); | ||
136 | void setRepeatOnWeekDay(int day, bool enable); | ||
137 | |||
138 | // Don't use any of these. | ||
102 | void setRepeat( bool b, const RepeatPattern &p ); | 139 | void setRepeat( bool b, const RepeatPattern &p ); |
103 | void setRepeat( const RepeatPattern &p ); | 140 | void setRepeat( const RepeatPattern &p ); |
104 | bool hasRepeat() const; | 141 | bool hasRepeat() const; |
105 | const RepeatPattern &repeatPattern() const; | 142 | const RepeatPattern &repeatPattern() const; |
106 | RepeatPattern &repeatPattern(); | 143 | RepeatPattern &repeatPattern(); |
107 | void setNotes( const QString &n ); | ||
108 | const QString ¬es() const; | ||
109 | bool doRepeat() const { return pattern.type != NoRepeat; } | 144 | bool doRepeat() const { return pattern.type != NoRepeat; } |
110 | 145 | ||
111 | void save( QString& buf ); | 146 | void save( QString& buf ); |
112 | //void load( Node *n ); | 147 | //void load( Node *n ); |
113 | 148 | ||
149 | bool match( const QRegExp &r ) const; | ||
150 | |||
151 | // Don't use these either. Functionality will be moved elsewhere. | ||
152 | |||
114 | // helper function to calculate the week of the given date | 153 | // helper function to calculate the week of the given date |
115 | static int week( const QDate& date ); | 154 | static int week( const QDate& date ); |
116 | // calculates the number of occurrences of the week day of | 155 | // calculates the number of occurrences of the week day of |
117 | // the given date from the start of the month | 156 | // the given date from the start of the month |
118 | static int occurrence( const QDate& date ); | 157 | static int occurrence( const QDate& date ); |
119 | // returns a proper days-char for a given dayOfWeek() | 158 | // returns a proper days-char for a given dayOfWeek() |
120 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } | 159 | static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } |
121 | // returns the dayOfWeek for the *first* day it finds (ignores | 160 | // returns the dayOfWeek for the *first* day it finds (ignores |
122 | // any further days!). Returns 1 (Monday) if there isn't any day found | 161 | // any further days!). Returns 1 (Monday) if there isn't any day found |
123 | static int dayOfWeek( char day ); | 162 | static int dayOfWeek( char day ); |
124 | // returns the difference of months from first to second. | 163 | // returns the difference of months from first to second. |
125 | static int monthDiff( const QDate& first, const QDate& second ); | 164 | static int monthDiff( const QDate& first, const QDate& second ); |
126 | bool match( const QRegExp &r ) const; | ||
127 | 165 | ||
128 | private: | 166 | private: |
129 | Qtopia::UidGen &uidGen() { return sUidGen; } | 167 | Qtopia::UidGen &uidGen() { return sUidGen; } |
130 | static Qtopia::UidGen sUidGen; | 168 | static Qtopia::UidGen sUidGen; |
131 | 169 | ||
132 | QString descript, locat, categ; | 170 | QString descript, locat, categ; |
133 | Type typ : 4; | 171 | Type typ : 4; |
134 | bool startTimeDirty : 1; | 172 | bool startTimeDirty : 1; |
@@ -206,16 +244,119 @@ private: | |||
206 | class EffectiveEventPrivate *d; | 244 | class EffectiveEventPrivate *d; |
207 | Event mEvent; | 245 | Event mEvent; |
208 | QDate mDate; | 246 | QDate mDate; |
209 | QTime mStart, | 247 | QTime mStart, |
210 | mEnd; | 248 | mEnd; |
211 | 249 | ||
212 | }; | 250 | }; |
213 | 251 | ||
252 | inline void Event::setAlarm( int minutes, SoundTypeChoice s ) | ||
253 | { | ||
254 | setAlarm(TRUE, minutes, s); | ||
255 | } | ||
256 | |||
257 | inline void Event::clearAlarm() | ||
258 | { | ||
259 | setAlarm(FALSE, 0, Silent); | ||
260 | } | ||
261 | |||
262 | inline int Event::alarmDelay() const | ||
263 | { | ||
264 | return alarmTime(); | ||
265 | } | ||
266 | |||
267 | inline void Event::setAllDay(bool enable) | ||
268 | { | ||
269 | if (enable) | ||
270 | setType(AllDay); | ||
271 | else | ||
272 | setType(Normal); | ||
273 | }; | ||
274 | |||
275 | inline bool Event::isAllDay() const | ||
276 | { | ||
277 | return type() == AllDay; | ||
278 | } | ||
279 | |||
280 | inline Event::RepeatType Event::repeatType() const | ||
281 | { | ||
282 | return repeatPattern().type; | ||
283 | } | ||
284 | |||
285 | inline int Event::frequency() const | ||
286 | { | ||
287 | return repeatPattern().frequency; | ||
288 | } | ||
289 | |||
290 | inline int Event::weekOffset() const | ||
291 | { | ||
292 | if (start().date().day() == 1) | ||
293 | return 1; | ||
294 | return (start().date().day() - 1) / 7 + 1; | ||
295 | } | ||
296 | |||
297 | inline QDate Event::repeatTill() const | ||
298 | { | ||
299 | return repeatPattern().endDate(); | ||
300 | } | ||
301 | |||
302 | inline bool Event::repeatForever() const | ||
303 | { | ||
304 | return !repeatPattern().hasEndDate; | ||
305 | } | ||
306 | |||
307 | inline void Event::setRepeatType(RepeatType t) | ||
308 | { | ||
309 | pattern.type = t; | ||
310 | } | ||
311 | |||
312 | inline void Event::setFrequency(int f) | ||
313 | { | ||
314 | pattern.frequency = f; | ||
315 | } | ||
316 | |||
317 | inline void Event::setRepeatTill(const QDate &d) | ||
318 | { | ||
319 | pattern.setEndDate(d); | ||
320 | pattern.hasEndDate = TRUE; | ||
321 | } | ||
322 | |||
323 | inline void Event::setRepeatForever(bool b) | ||
324 | { | ||
325 | if (!b == pattern.hasEndDate) | ||
326 | return; | ||
327 | if (!b && !pattern.hasEndDate) | ||
328 | pattern.setEndDate(end().date()); | ||
329 | pattern.hasEndDate = !b; | ||
330 | } | ||
331 | |||
332 | inline bool Event::repeatOnWeekDay(int day) const | ||
333 | { | ||
334 | if (pattern.type != Weekly) | ||
335 | return FALSE; | ||
336 | return ( (1 << (day - 1)) & pattern.days ) != 0; | ||
337 | } | ||
338 | |||
339 | inline void Event::setRepeatOnWeekDay(int day, bool enable) | ||
340 | { | ||
341 | if ( repeatOnWeekDay( day ) != enable ) | ||
342 | pattern.days ^= 1 << (day - 1); | ||
343 | } | ||
344 | |||
345 | inline QDateTime Event::start( ) const | ||
346 | { | ||
347 | return start(FALSE); | ||
348 | } | ||
349 | |||
350 | inline QDateTime Event::end( ) const | ||
351 | { | ||
352 | return end(FALSE); | ||
353 | } | ||
354 | |||
214 | #ifdef PALMTOPCENTER | 355 | #ifdef PALMTOPCENTER |
215 | class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> | 356 | class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> |
216 | { | 357 | { |
217 | public: | 358 | public: |
218 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const | 359 | int compare( const EffectiveEvent& a, const EffectiveEvent& b ) const |
219 | { | 360 | { |
220 | return a.size() - b.size(); | 361 | return a.size() - b.size(); |
221 | } | 362 | } |
diff --git a/library/backend/palmtoprecord.cpp b/library/backend/palmtoprecord.cpp index 0d57699..3cfa874 100644 --- a/library/backend/palmtoprecord.cpp +++ b/library/backend/palmtoprecord.cpp | |||
@@ -1,34 +1,45 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** in the packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | 13 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | #include "palmtoprecord.h" | 20 | #include <qtopia/private/palmtoprecord.h> |
22 | #include "stringutil.h" | 21 | #include <qtopia/stringutil.h> |
23 | #include <qstringlist.h> | 22 | #include <qstringlist.h> |
24 | 23 | ||
24 | /*! \class Qtopia::PalmtopRecord palmtoprecord.h | ||
25 | \brief The Qtopia::PalmtopRecord class is the base class for all PIM records. | ||
26 | |||
27 | Provides unique id and category support for all PIM records. | ||
28 | |||
29 | \ingroup qtopiaemb | ||
30 | \ingroup qtopiadesktop | ||
31 | */ | ||
32 | |||
33 | |||
25 | namespace Qtopia { | 34 | namespace Qtopia { |
26 | 35 | ||
36 | |||
37 | |||
27 | Record &Record::operator=( const Record &c ) | 38 | Record &Record::operator=( const Record &c ) |
28 | { | 39 | { |
29 | mUid = c.mUid; | 40 | mUid = c.mUid; |
30 | mCats = c.mCats; | 41 | mCats = c.mCats; |
31 | customMap = c.customMap; | 42 | customMap = c.customMap; |
32 | return *this; | 43 | return *this; |
33 | } | 44 | } |
34 | 45 | ||
@@ -36,18 +47,21 @@ void Record::setCategories( int single ) | |||
36 | { | 47 | { |
37 | if ( single == 0 ) | 48 | if ( single == 0 ) |
38 | return; | 49 | return; |
39 | mCats.resize(1); | 50 | mCats.resize(1); |
40 | mCats[0] = single; | 51 | mCats[0] = single; |
41 | } | 52 | } |
42 | 53 | ||
43 | // convenience methods provided for loading and saving to xml | 54 | // convenience methods provided for loading and saving to xml |
44 | QString Record::idsToString( const QArray<int> &cats ) | 55 | QString Record::idsToString( const QArray<int> &catsUnsorted ) |
45 | { | 56 | { |
57 | QArray<int> cats = catsUnsorted; | ||
58 | cats.sort(); | ||
59 | |||
46 | QString str; | 60 | QString str; |
47 | for ( uint i = 0; i < cats.size(); i++ ) | 61 | for ( uint i = 0; i < cats.size(); i++ ) |
48 | if ( i == 0 ) | 62 | if ( i == 0 ) |
49 | str = QString::number( cats[int(i)] ); | 63 | str = QString::number( cats[int(i)] ); |
50 | else | 64 | else |
51 | str += ";" + QString::number( cats[int(i)] ); | 65 | str += ";" + QString::number( cats[int(i)] ); |
52 | 66 | ||
53 | return str; | 67 | return str; |
@@ -79,40 +93,40 @@ QString Record::customField( const QString &key) const | |||
79 | return QString::null; | 93 | return QString::null; |
80 | } | 94 | } |
81 | 95 | ||
82 | /*! | 96 | /*! |
83 | Sets the string stored for the custom field \a key to \a value. | 97 | Sets the string stored for the custom field \a key to \a value. |
84 | */ | 98 | */ |
85 | void Record::setCustomField( const QString &key, const QString &value) | 99 | void Record::setCustomField( const QString &key, const QString &value) |
86 | { | 100 | { |
87 | qWarning("setting custom " + key + " to " + value); | 101 | // qWarning("setting custom " + key + " to " + value); |
88 | if (customMap.contains(key)) | 102 | if (customMap.contains(key)) |
89 | customMap.replace(key, value); | 103 | customMap.replace(key, value); |
90 | else | 104 | else |
91 | customMap.insert(key, value); | 105 | customMap.insert(key, value); |
92 | 106 | ||
93 | qWarning(QString("custom size %1").arg(customMap.count())); | 107 | // qWarning(QString("custom size %1").arg(customMap.count())); |
94 | } | 108 | } |
95 | 109 | ||
96 | /*! | 110 | /*! |
97 | Removes the custom field \a key. | 111 | Removes the custom field \a key. |
98 | */ | 112 | */ |
99 | void Record::removeCustomField(const QString &key) | 113 | void Record::removeCustomField(const QString &key) |
100 | { | 114 | { |
101 | customMap.remove(key); | 115 | customMap.remove(key); |
102 | } | 116 | } |
103 | 117 | ||
104 | QString Record::customToXml() const | 118 | QString Record::customToXml() const |
105 | { | 119 | { |
106 | //qWarning(QString("writing custom %1").arg(customMap.count())); | 120 | //qWarning(QString("writing custom %1").arg(customMap.count())); |
107 | QString buf(" "); | 121 | QString buf(" "); |
108 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); | 122 | for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); |
109 | cit != customMap.end(); ++cit) { | 123 | cit != customMap.end(); ++cit) { |
110 | qWarning(".ITEM."); | 124 | // qWarning(".ITEM."); |
111 | buf += cit.key(); | 125 | buf += cit.key(); |
112 | buf += "=\""; | 126 | buf += "=\""; |
113 | buf += escapeString(cit.data()); | 127 | buf += escapeString(cit.data()); |
114 | buf += "\" "; | 128 | buf += "\" "; |
115 | } | 129 | } |
116 | return buf; | 130 | return buf; |
117 | } | 131 | } |
118 | 132 | ||
diff --git a/library/backend/palmtoprecord.h b/library/backend/palmtoprecord.h index 0372011..72f7d1c 100644 --- a/library/backend/palmtoprecord.h +++ b/library/backend/palmtoprecord.h | |||
@@ -1,41 +1,38 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** in the packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | 13 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | |||
22 | #ifndef QTPALMTOP_RECORD_H | 20 | #ifndef QTPALMTOP_RECORD_H |
23 | #define QTPALMTOP_RECORD_H | 21 | #define QTPALMTOP_RECORD_H |
24 | |||
25 | #include <qglobal.h> | 22 | #include <qglobal.h> |
26 | #include "qpcglobal.h" | 23 | #include "qpcglobal.h" |
27 | #include "palmtopuidgen.h" | 24 | #include "palmtopuidgen.h" |
28 | #include <qarray.h> | 25 | #include <qarray.h> |
29 | #include <qmap.h> | 26 | #include <qmap.h> |
30 | 27 | ||
31 | #if defined(QPC_TEMPLATEDLL) | 28 | #if defined(QPC_TEMPLATEDLL) |
32 | // MOC_SKIP_BEGIN | 29 | // MOC_SKIP_BEGIN |
33 | template class QPC_EXPORT QMap<QString, QString>; | 30 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>; |
34 | // MOC_SKIP_END | 31 | // MOC_SKIP_END |
35 | #endif | 32 | #endif |
36 | 33 | ||
37 | class QRegExp; | 34 | class QRegExp; |
38 | namespace Qtopia { | 35 | namespace Qtopia { |
39 | 36 | ||
40 | class RecordPrivate; | 37 | class RecordPrivate; |
41 | class QPC_EXPORT Record | 38 | class QPC_EXPORT Record |
@@ -44,20 +41,27 @@ public: | |||
44 | Record() : mUid(0), mCats() { } | 41 | Record() : mUid(0), mCats() { } |
45 | Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { } | 42 | Record( const Record &c ) :mUid( c.mUid ), mCats ( c.mCats ), customMap(c.customMap) { } |
46 | virtual ~Record() { } | 43 | virtual ~Record() { } |
47 | 44 | ||
48 | Record &operator=( const Record &c ); | 45 | Record &operator=( const Record &c ); |
49 | 46 | ||
50 | virtual bool match( const QRegExp & ) const { return FALSE; } | 47 | virtual bool match( const QRegExp & ) const { return FALSE; } |
51 | 48 | ||
52 | void setCategories( const QArray<int> &v ) { mCats = v; } | 49 | void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); } |
53 | void setCategories( int single ); | 50 | void setCategories( int single ); |
54 | const QArray<int> &categories() const { return mCats; } | 51 | const QArray<int> &categories() const { return mCats; } |
55 | 52 | ||
53 | void reassignCategoryId( int oldId, int newId ) | ||
54 | { | ||
55 | int index = mCats.find( oldId ); | ||
56 | if ( index >= 0 ) | ||
57 | mCats[index] = newId; | ||
58 | } | ||
59 | |||
56 | int uid() const { return mUid; }; | 60 | int uid() const { return mUid; }; |
57 | virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); } | 61 | virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); } |
58 | bool isValidUid() const { return mUid != 0; } | 62 | bool isValidUid() const { return mUid != 0; } |
59 | void assignUid() { setUid( uidGen().generate() ); } | 63 | void assignUid() { setUid( uidGen().generate() ); } |
60 | 64 | ||
61 | virtual QString customField(const QString &) const; | 65 | virtual QString customField(const QString &) const; |
62 | virtual void setCustomField(const QString &, const QString &); | 66 | virtual void setCustomField(const QString &, const QString &); |
63 | virtual void removeCustomField(const QString &); | 67 | virtual void removeCustomField(const QString &); |
@@ -72,23 +76,20 @@ public: | |||
72 | // convenience methods provided for loading and saving to xml | 76 | // convenience methods provided for loading and saving to xml |
73 | static QArray<int> idsFromString( const QString &str ); | 77 | static QArray<int> idsFromString( const QString &str ); |
74 | 78 | ||
75 | // for debugging | 79 | // for debugging |
76 | static void dump( const QMap<int, QString> &map ); | 80 | static void dump( const QMap<int, QString> &map ); |
77 | 81 | ||
78 | protected: | 82 | protected: |
79 | virtual UidGen &uidGen() = 0; | 83 | virtual UidGen &uidGen() = 0; |
80 | |||
81 | virtual QString customToXml() const; | 84 | virtual QString customToXml() const; |
82 | |||
83 | private: | 85 | private: |
84 | int mUid; | 86 | int mUid; |
85 | QArray<int> mCats; | 87 | QArray<int> mCats; |
86 | |||
87 | QMap<QString, QString> customMap; | 88 | QMap<QString, QString> customMap; |
88 | |||
89 | RecordPrivate *d; | 89 | RecordPrivate *d; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | #endif | 94 | #endif |
95 | |||
diff --git a/library/backend/palmtopuidgen.h b/library/backend/palmtopuidgen.h index 1a16681..c3fbcb9 100644 --- a/library/backend/palmtopuidgen.h +++ b/library/backend/palmtopuidgen.h | |||
@@ -1,38 +1,38 @@ | |||
1 | #ifndef QTPALMTOP_UIDGEN_H | ||
2 | #define QTPALMTOP_UIDGEN_H | ||
3 | /********************************************************************** | 1 | /********************************************************************** |
4 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
5 | ** | 3 | ** |
6 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
7 | ** | 5 | ** |
8 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** This file may be distributed and/or modified under the terms of the |
9 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** GNU General Public License version 2 as published by the Free Software |
10 | ** provided with the Software. | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | ||
11 | ** | 10 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** PURPOSE. | ||
15 | ** | 13 | ** |
16 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
17 | ** Agreements. | ||
18 | ** | 15 | ** |
19 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
20 | ** not clear to you. | 17 | ** not clear to you. |
21 | ** | 18 | ** |
22 | **********************************************************************/ | 19 | **********************************************************************/ |
23 | 20 | ||
21 | #ifndef QTPALMTOP_UIDGEN_H | ||
22 | #define QTPALMTOP_UIDGEN_H | ||
23 | |||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #include <qmap.h> | 25 | #include <qmap.h> |
26 | #include "qpcglobal.h" | 26 | #include "qpcglobal.h" |
27 | 27 | ||
28 | #if defined(QPC_TEMPLATEDLL) | 28 | #if defined(QPC_TEMPLATEDLL) |
29 | // MOC_SKIP_BEGIN | 29 | // MOC_SKIP_BEGIN |
30 | template class QPC_EXPORT QMap< int, bool >; | 30 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap< int, bool >; |
31 | // MOC_SKIP_END | 31 | // MOC_SKIP_END |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | namespace Qtopia { | 34 | namespace Qtopia { |
35 | 35 | ||
36 | 36 | ||
37 | class QPC_EXPORT UidGen | 37 | class QPC_EXPORT UidGen |
38 | { | 38 | { |
diff --git a/library/backend/qfiledirect_p.h b/library/backend/qfiledirect_p.h index 3ade622..976c69f 100644 --- a/library/backend/qfiledirect_p.h +++ b/library/backend/qfiledirect_p.h | |||
@@ -1,37 +1,35 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** provided with the Software. | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | ||
9 | ** | 10 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** PURPOSE. | ||
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** Agreements. | ||
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | 20 | ||
22 | #ifndef QFILE_DIRECT_H | 21 | #ifndef QFILE_DIRECT_H |
23 | #define QFILE_DIRECT_H | 22 | #define QFILE_DIRECT_H |
24 | #include <qfile.h> | 23 | #include <qfile.h> |
25 | #include <qpe/qpcglobal.h> | 24 | #include <qtopia/private/qpcglobal.h> |
26 | 25 | ||
27 | class QPC_EXPORT QFileDirect : public QFile | 26 | class QPC_EXPORT QFileDirect : public QFile |
28 | { | 27 | { |
29 | public: | 28 | public: |
30 | QFileDirect() : QFile() { } | 29 | QFileDirect() : QFile() { } |
31 | QFileDirect( const QString &name ) : QFile(name) { } | 30 | QFileDirect( const QString &name ) : QFile(name) { } |
32 | 31 | ||
33 | FILE *directHandle() { return fh; } | 32 | FILE *directHandle() { return fh; } |
34 | }; | 33 | }; |
35 | 34 | ||
36 | #endif | 35 | #endif |
37 | |||
diff --git a/library/backend/qpcglobal.h b/library/backend/qpcglobal.h index 0d60272..7b71f06 100644 --- a/library/backend/qpcglobal.h +++ b/library/backend/qpcglobal.h | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** Licensees holding valid Qtopia Developer license may use this |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** file in accordance with the Qtopia Developer License Agreement |
8 | ** provided with the Software. | 8 | ** provided with the Software. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
12 | ** PURPOSE. | 12 | ** PURPOSE. |
@@ -17,30 +17,33 @@ | |||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef QPC_GLOBAL_H | 22 | #ifndef QPC_GLOBAL_H |
23 | #define QPC_GLOBAL_H | 23 | #define QPC_GLOBAL_H |
24 | 24 | ||
25 | #if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER) | ||
26 | #include <qglobal.h> | 25 | #include <qglobal.h> |
26 | |||
27 | #if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER) | ||
27 | // # if defined(QT_NODLL) | 28 | // # if defined(QT_NODLL) |
28 | //# undef QPC_MAKEDLL | 29 | //# undef QPC_MAKEDLL |
29 | //# undef QPC_DLL | 30 | //# undef QPC_DLL |
30 | # if defined(QPC_MAKEDLL)/* create a Qt DLL library */ | 31 | # if defined(QPC_MAKEDLL)/* create a Qt DLL library */ |
31 | # if defined(QPC_DLL) | 32 | # if defined(QPC_DLL) |
32 | # undef QPC_DLL | 33 | # undef QPC_DLL |
33 | # endif | 34 | # endif |
34 | # define QPC_EXPORT __declspec(dllexport) | 35 | # define QPC_EXPORT __declspec(dllexport) |
36 | # define QPC_TEMPLATEEXTERN | ||
35 | # define QPC_TEMPLATEDLL | 37 | # define QPC_TEMPLATEDLL |
36 | # undef QPC_DISABLE_COPY/* avoid unresolved externals */ | 38 | # undef QPC_DISABLE_COPY/* avoid unresolved externals */ |
37 | # elif defined(QPC_DLL) /* use a Qt DLL library */ | 39 | # elif defined(QPC_DLL) /* use a Qt DLL library */ |
38 | # define QPC_EXPORT __declspec(dllimport) | 40 | # define QPC_EXPORT __declspec(dllimport) |
41 | # define QPC_TEMPLATEEXTERN extern | ||
39 | # define QPC_TEMPLATEDLL | 42 | # define QPC_TEMPLATEDLL |
40 | # undef QPC_DISABLE_COPY/* avoid unresolved externals */ | 43 | # undef QPC_DISABLE_COPY/* avoid unresolved externals */ |
41 | # endif | 44 | # endif |
42 | #else | 45 | #else |
43 | # undef QPC_MAKEDLL /* ignore these for other platforms */ | 46 | # undef QPC_MAKEDLL /* ignore these for other platforms */ |
44 | # undef QPC_DLL | 47 | # undef QPC_DLL |
45 | #endif | 48 | #endif |
46 | #endif | 49 | #endif |
diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h index 4196c8b..1167ed3 100644 --- a/library/backend/recordfields.h +++ b/library/backend/recordfields.h | |||
@@ -1,23 +1,22 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** Licensees holding valid Qtopia Developer license may use this | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** file in accordance with the Qtopia Developer License Agreement | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** provided with the Software. | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | ||
9 | ** | 10 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** PURPOSE. | ||
13 | ** | 13 | ** |
14 | ** email sales@trolltech.com for information about Qtopia License | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** Agreements. | ||
16 | ** | 15 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 17 | ** not clear to you. |
19 | ** | 18 | ** |
20 | **********************************************************************/ | 19 | **********************************************************************/ |
21 | #ifndef QPC_RECORD_FIELDS_H | 20 | #ifndef QPC_RECORD_FIELDS_H |
22 | #define QPC_RECORD_FIELDS_H | 21 | #define QPC_RECORD_FIELDS_H |
23 | #include "qpcglobal.h" | 22 | #include "qpcglobal.h" |
@@ -83,19 +82,20 @@ namespace Qtopia | |||
83 | Gender, | 82 | Gender, |
84 | Birthday, | 83 | Birthday, |
85 | Anniversary, | 84 | Anniversary, |
86 | Nickname, | 85 | Nickname, |
87 | Children, | 86 | Children, |
88 | 87 | ||
89 | // other | 88 | // other |
90 | Notes, | 89 | Notes, |
91 | Groups | ||
92 | 90 | ||
93 | ,rid, | 91 | // used for internal record keeping, not for end user. |
92 | Groups, | ||
93 | rid, | ||
94 | rinfo | 94 | rinfo |
95 | }; | 95 | }; |
96 | 96 | ||
97 | // dataset = "todolist" | 97 | // dataset = "todolist" |
98 | enum TaskFields { | 98 | enum TaskFields { |
99 | TaskUid = UID_ID, | 99 | TaskUid = UID_ID, |
100 | TaskCategory = CATEGORY_ID, | 100 | TaskCategory = CATEGORY_ID, |
101 | 101 | ||
diff --git a/library/backend/stringutil.cpp b/library/backend/stringutil.cpp deleted file mode 100644 index df58f54..0000000 --- a/library/backend/stringutil.cpp +++ b/dev/null | |||
@@ -1,415 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free | ||
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | ||
9 | ** in the packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | ||
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | ||
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | |||
22 | #include "stringutil.h" | ||
23 | #include <qregexp.h> | ||
24 | #include <qstringlist.h> | ||
25 | |||
26 | namespace Qtopia | ||
27 | { | ||
28 | |||
29 | |||
30 | |||
31 | /* | ||
32 | Very, very simple Latin-1 only collation guaranteed to displease anyone | ||
33 | who actually uses the non-ASCII characters. | ||
34 | */ | ||
35 | |||
36 | static const char collationHack[] = { | ||
37 | 0x00, //C-@ | ||
38 | 0x01, //C-A | ||
39 | 0x02, //C-B | ||
40 | 0x03, //C-C | ||
41 | 0x04, //C-D | ||
42 | 0x05, //C-E | ||
43 | 0x06, //C-F | ||
44 | 0x07, //C-G | ||
45 | 0x08, //C-H | ||
46 | 0x09, //C-I | ||
47 | 0x0a, //C-J | ||
48 | 0x0b, //C-K | ||
49 | 0x0c, //C-L | ||
50 | 0x0d, //C-M | ||
51 | 0x0e, //C-N | ||
52 | 0x0f, //C-O | ||
53 | 0x10, //C-P | ||
54 | 0x11, //C-Q | ||
55 | 0x12, //C-R | ||
56 | 0x13, //C-S | ||
57 | 0x14, //C-T | ||
58 | 0x15, //C-U | ||
59 | 0x16, //C-V | ||
60 | 0x17, //C-W | ||
61 | 0x18, //C-X | ||
62 | 0x19, //C-Y | ||
63 | 0x1a, //C-Z | ||
64 | 0x1b, //C-[ | ||
65 | 0x1c, //C-\ | ||
66 | 0x1d, //C-] | ||
67 | 0x1e, //C-^ | ||
68 | 0x1f, //C-_ | ||
69 | ' ', // | ||
70 | '!', //! | ||
71 | '"', //" | ||
72 | '#', //# | ||
73 | '$', //$ | ||
74 | '%', //% | ||
75 | '&', //& | ||
76 | '\'', //' | ||
77 | '(', //( | ||
78 | ')', //) | ||
79 | '*', //* | ||
80 | '+', //+ | ||
81 | ',', //, | ||
82 | '-', //- | ||
83 | '.', //. | ||
84 | '/', /// | ||
85 | 0x80, //0 | ||
86 | 0x81, //1 | ||
87 | 0x82, //2 | ||
88 | 0x83, //3 | ||
89 | 0x84, //4 | ||
90 | 0x85, //5 | ||
91 | 0x86, //6 | ||
92 | 0x87, //7 | ||
93 | 0x88, //8 | ||
94 | 0x89, //9 | ||
95 | ':', //: | ||
96 | ';', //; | ||
97 | '<', //< | ||
98 | '=', //= | ||
99 | '>', //> | ||
100 | '?', //? | ||
101 | '@', //@ | ||
102 | 'A', //A | ||
103 | 'B', //B | ||
104 | 'C', //C | ||
105 | 'D', //D | ||
106 | 'E', //E | ||
107 | 'F', //F | ||
108 | 'G', //G | ||
109 | 'H', //H | ||
110 | 'I', //I | ||
111 | 'J', //J | ||
112 | 'K', //K | ||
113 | 'L', //L | ||
114 | 'M', //M | ||
115 | 'N', //N | ||
116 | 'O', //O | ||
117 | 'P', //P | ||
118 | 'Q', //Q | ||
119 | 'R', //R | ||
120 | 'S', //S | ||
121 | 'T', //T | ||
122 | 'U', //U | ||
123 | 'V', //V | ||
124 | 'W', //W | ||
125 | 'X', //X | ||
126 | 'Y', //Y | ||
127 | 'Z', //Z | ||
128 | '[', //[ | ||
129 | '\\', //\ | ||
130 | ']', //] | ||
131 | '^', //^ | ||
132 | '_', //_ | ||
133 | '`', //` | ||
134 | 'A', //a | ||
135 | 'B', //b | ||
136 | 'C', //c | ||
137 | 'D', //d | ||
138 | 'E', //e | ||
139 | 'F', //f | ||
140 | 'G', //g | ||
141 | 'H', //h | ||
142 | 'I', //i | ||
143 | 'J', //j | ||
144 | 'K', //k | ||
145 | 'L', //l | ||
146 | 'M', //m | ||
147 | 'N', //n | ||
148 | 'O', //o | ||
149 | 'P', //p | ||
150 | 'Q', //q | ||
151 | 'R', //r | ||
152 | 'S', //s | ||
153 | 'T', //t | ||
154 | 'U', //u | ||
155 | 'V', //v | ||
156 | 'W', //w | ||
157 | 'X', //x | ||
158 | 'Y', //y | ||
159 | 'Z', //z | ||
160 | '{', //{ | ||
161 | '|', //| | ||
162 | '}', //} | ||
163 | '~', //~ | ||
164 | '', // | ||
165 | 0x80, //C-M-@ | ||
166 | 0x81, //C-M-A | ||
167 | 0x82, //C-M-B | ||
168 | 0x83, //C-M-C | ||
169 | 0x84, //C-M-D | ||
170 | 0x85, //C-M-E | ||
171 | 0x86, //C-M-F | ||
172 | 0x87, //C-M-G | ||
173 | 0x88, //C-M-H | ||
174 | 0x89, //C-M-I | ||
175 | 0x8a, //C-M-J | ||
176 | 0x8b, //C-M-K | ||
177 | 0x8c, //C-M-L | ||
178 | 0x8d, //C-M-M | ||
179 | 0x8e, //C-M-N | ||
180 | 0x8f, //C-M-O | ||
181 | 0x90, //C-M-P | ||
182 | 0x91, //C-M-Q | ||
183 | 0x92, //C-M-R | ||
184 | 0x93, //C-M-S | ||
185 | 0x94, //C-M-T | ||
186 | 0x95, //C-M-U | ||
187 | 0x96, //C-M-V | ||
188 | 0x97, //C-M-W | ||
189 | 0x98, //C-M-X | ||
190 | 0x99, //C-M-Y | ||
191 | 0x9a, //C-M-Z | ||
192 | 0x9b, //C-M-[ | ||
193 | 0x9c, //C-M-\ | ||
194 | 0x9d, //C-M-] | ||
195 | 0x9e, //C-M-^ | ||
196 | 0x9f, //C-M-_ | ||
197 | ' ', // | ||
198 | '¡', //¡ | ||
199 | '¢', //¢ | ||
200 | '£', //£ | ||
201 | '¤', //¤ | ||
202 | '¥', //¥ | ||
203 | '¦', //¦ | ||
204 | '§', //§ | ||
205 | '¨', //¨ | ||
206 | '©', //© | ||
207 | 'A', //ª | ||
208 | '«', //« | ||
209 | '¬', //¬ | ||
210 | '', // | ||
211 | '®', //® | ||
212 | '¯', //¯ | ||
213 | 'O', //° | ||
214 | '±', //± | ||
215 | '²', //² | ||
216 | '³', //³ | ||
217 | '´', //´ | ||
218 | 'µ', //µ | ||
219 | 'P', //¶ | ||
220 | '·', //· | ||
221 | '¸', //¸ | ||
222 | '¹', //¹ | ||
223 | 'O', //º | ||
224 | '»', //» | ||
225 | '¼', //¼ | ||
226 | '½', //½ | ||
227 | '¾', //¾ | ||
228 | '¿', //¿ | ||
229 | 'A', //À | ||
230 | 'A', //Á | ||
231 | 'A', //Â | ||
232 | 'A', //Ã | ||
233 | 'A', //Ä | ||
234 | 'A', //Å | ||
235 | 'A', //Æ | ||
236 | 'C', //Ç | ||
237 | 'E', //È | ||
238 | 'E', //É | ||
239 | 'E', //Ê | ||
240 | 'E', //Ë | ||
241 | 'I', //Ì | ||
242 | 'I', //Í | ||
243 | 'I', //Î | ||
244 | 'I', //Ï | ||
245 | 'D', //Ð | ||
246 | 'N', //Ñ | ||
247 | 'O', //Ò | ||
248 | 'O', //Ó | ||
249 | 'O', //Ô | ||
250 | 'O', //Õ | ||
251 | 'O', //Ö | ||
252 | '×', //× | ||
253 | 'O', //Ø | ||
254 | 'U', //Ù | ||
255 | 'U', //Ú | ||
256 | 'U', //Û | ||
257 | 'U', //Ü | ||
258 | 'Y', //Ý | ||
259 | 'T', //Þ | ||
260 | 'S', //ß | ||
261 | 'A', //à | ||
262 | 'A', //á | ||
263 | 'A', //â | ||
264 | 'A', //ã | ||
265 | 'A', //ä | ||
266 | 'A', //å | ||
267 | 'A', //æ | ||
268 | 'C', //ç | ||
269 | 'E', //è | ||
270 | 'E', //é | ||
271 | 'E', //ê | ||
272 | 'E', //ë | ||
273 | 'I', //ì | ||
274 | 'I', //í | ||
275 | 'I', //î | ||
276 | 'I', //ï | ||
277 | 'D', //ð | ||
278 | 'N', //ñ | ||
279 | 'O', //ò | ||
280 | 'O', //ó | ||
281 | 'O', //ô | ||
282 | 'O', //õ | ||
283 | 'O', //ö | ||
284 | '÷', //÷ | ||
285 | 'O', //ø | ||
286 | 'U', //ù | ||
287 | 'U', //ú | ||
288 | 'U', //û | ||
289 | 'U', //ü | ||
290 | 'Y', //ý | ||
291 | 'T', //þ | ||
292 | 'Y', //ÿ | ||
293 | }; | ||
294 | |||
295 | |||
296 | |||
297 | |||
298 | |||
299 | static void hackString ( QString &s ) | ||
300 | { | ||
301 | int len = s.length(); | ||
302 | const QChar* uc = s.unicode(); | ||
303 | for ( int i = 0; i < len; i++ ) { | ||
304 | if ( !uc++->row() ) | ||
305 | s[i] = collationHack[s[i].cell()]; | ||
306 | } | ||
307 | } | ||
308 | |||
309 | QString buildSortKey( const QString & s ) | ||
310 | { | ||
311 | QString res = s; | ||
312 | hackString( res ); | ||
313 | return res; | ||
314 | } | ||
315 | |||
316 | QString buildSortKey( const QString & s1, const QString & s2 ) | ||
317 | { | ||
318 | QString res = s1 + QChar( '\0' ) + s2; | ||
319 | hackString( res ); | ||
320 | return res; | ||
321 | } | ||
322 | |||
323 | QString buildSortKey( const QString & s1, const QString & s2, | ||
324 | const QString & s3 ) | ||
325 | { | ||
326 | QString res = s1 + QChar( '\0' ) + s2 + QChar( '\0' ) + s3; | ||
327 | hackString( res ); | ||
328 | return res; | ||
329 | } | ||
330 | |||
331 | static inline QChar coll( QChar u ) | ||
332 | { | ||
333 | return u.row() ? u : QChar(collationHack[ u.cell() ]); | ||
334 | } | ||
335 | |||
336 | |||
337 | int compare( const QString & s1, const QString & s2 ) | ||
338 | { | ||
339 | const QChar* u1 = s1.unicode(); | ||
340 | const QChar* u2 = s2.unicode(); | ||
341 | |||
342 | if ( u1 == u2 ) | ||
343 | return 0; | ||
344 | if ( u1 == 0 ) | ||
345 | return 1; | ||
346 | if ( u2 == 0 ) | ||
347 | return -1; | ||
348 | int l=QMIN(s1.length(),s2.length()); | ||
349 | while ( l-- && coll(*u1) == coll(*u2) ) | ||
350 | u1++,u2++; | ||
351 | if ( l==-1 ) | ||
352 | return ( s1.length()-s2.length() ); | ||
353 | return u1->unicode() - u2->unicode(); | ||
354 | } | ||
355 | |||
356 | QString simplifyMultiLineSpace( const QString &multiLine ) | ||
357 | { | ||
358 | QString result; | ||
359 | QStringList lines = QStringList::split("\n", multiLine); | ||
360 | for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { | ||
361 | if ( it != lines.begin() ) | ||
362 | result += "\n"; | ||
363 | result += (*it).simplifyWhiteSpace(); | ||
364 | } | ||
365 | return result; | ||
366 | } | ||
367 | |||
368 | QString escapeString( const QString& plain ) | ||
369 | { | ||
370 | QString tmp(plain); | ||
371 | int pos = tmp.length(); | ||
372 | const QChar *uc = plain.unicode(); | ||
373 | while ( pos-- ) { | ||
374 | unsigned char ch = uc[pos].latin1(); | ||
375 | if ( ch == '&' ) | ||
376 | tmp.replace( pos, 1, "&" ); | ||
377 | else if ( ch == '<' ) | ||
378 | tmp.replace( pos, 1, "<" ); | ||
379 | else if ( ch == '>' ) | ||
380 | tmp.replace( pos, 1, ">" ); | ||
381 | else if ( ch == '\"' ) | ||
382 | tmp.replace( pos, 1, """ ); | ||
383 | } | ||
384 | return tmp; | ||
385 | } | ||
386 | |||
387 | QString plainString( const char* escaped, unsigned int length ) | ||
388 | { | ||
389 | return plainString( QString::fromUtf8( escaped, length ) ); | ||
390 | } | ||
391 | |||
392 | QString plainString( const QCString& string ) | ||
393 | { | ||
394 | // We first have to pass it through a ::fromUtf8() | ||
395 | return plainString( string.data(), string.length() ); | ||
396 | } | ||
397 | |||
398 | QString plainString( const QString& string ) | ||
399 | { | ||
400 | QString tmp( string ); | ||
401 | int pos = -1; | ||
402 | while ( (pos = tmp.find( "&", pos +1 ) ) != -1 ) { | ||
403 | if ( tmp.find( "&", pos ) == pos ) | ||
404 | tmp.replace( pos, 5, "&" ); | ||
405 | else if ( tmp.find( "<", pos ) == pos ) | ||
406 | tmp.replace( pos, 4, "<" ); | ||
407 | else if( tmp.find( ">", pos ) == pos ) | ||
408 | tmp.replace( pos, 4, ">" ); | ||
409 | else if ( tmp.find( """, pos ) == pos ) | ||
410 | tmp.replace( pos, 6, "\"" ); | ||
411 | } | ||
412 | return tmp; | ||
413 | } | ||
414 | |||
415 | } // namespace QPC | ||
diff --git a/library/backend/stringutil.h b/library/backend/stringutil.h deleted file mode 100644 index e9daf70..0000000 --- a/library/backend/stringutil.h +++ b/dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free | ||
8 | ** Software Foundation and appearing in the file LICENSE.GPL included | ||
9 | ** in the packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING | ||
12 | ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A | ||
13 | ** PARTICULAR PURPOSE. | ||
14 | ** | ||
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
16 | ** | ||
17 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
18 | ** not clear to you. | ||
19 | ** | ||
20 | **********************************************************************/ | ||
21 | |||
22 | |||
23 | #ifndef QTPALMTOP_stringutil_h__ | ||
24 | #define QTPALMTOP_stringutil_h__ | ||
25 | |||
26 | #include <qstring.h> | ||
27 | #include "qpcglobal.h" | ||
28 | |||
29 | namespace Qtopia | ||
30 | { | ||
31 | |||
32 | // Simplifies white space within each line but keeps the new line characters | ||
33 | QString QPC_EXPORT simplifyMultiLineSpace( const QString &multiLine ); | ||
34 | |||
35 | // Creates a QString which doesn't contain any "dangerous" | ||
36 | // characters (i.e. <, >, &, ") | ||
37 | QString QPC_EXPORT escapeString( const QString& plain ); | ||
38 | |||
39 | // Takes a UTF-8!! string and removes all the XML thingies (entities?) | ||
40 | // from the string and also calls fromUtf8() on it... so make sure | ||
41 | // to pass a QCString/const char* with UTF-8 data only | ||
42 | QString QPC_EXPORT plainString( const char* escaped, unsigned int length ); | ||
43 | QString QPC_EXPORT plainString( const QCString& string ); | ||
44 | |||
45 | QString QPC_EXPORT plainString( const QString& string ); | ||
46 | |||
47 | |||
48 | // collation functions | ||
49 | int compare( const QString & s1, const QString & s2 ); | ||
50 | QString buildSortKey( const QString & s ); | ||
51 | QString buildSortKey( const QString & s1, const QString & s2 ); | ||
52 | QString buildSortKey( const QString & s1, const QString & s2, | ||
53 | const QString & s3 ); | ||
54 | |||
55 | } | ||
56 | |||
57 | #endif | ||
diff --git a/library/backend/task.cpp b/library/backend/task.cpp index f0a38f1..a00adb3 100644 --- a/library/backend/task.cpp +++ b/library/backend/task.cpp | |||
@@ -1,85 +1,200 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/task.h> | 21 | #include "task.h" |
22 | #include <qregexp.h> | 22 | #include "recordfields.h" |
23 | #include <qstring.h> | ||
24 | #include <qpe/recordfields.h> | ||
25 | #include "vobject_p.h" | 23 | #include "vobject_p.h" |
26 | #include "timeconversion.h" | ||
27 | #include "qfiledirect_p.h" | 24 | #include "qfiledirect_p.h" |
28 | 25 | ||
26 | #include <qtopia/timeconversion.h> | ||
27 | |||
28 | #include <qregexp.h> | ||
29 | #include <qstring.h> | ||
30 | |||
29 | #include <stdio.h> | 31 | #include <stdio.h> |
30 | 32 | ||
31 | using namespace Qtopia; | 33 | using namespace Qtopia; |
32 | UidGen Task::sUidGen( UidGen::Qtopia ); | 34 | UidGen Task::sUidGen( UidGen::Qtopia ); |
33 | 35 | ||
36 | /*! | ||
37 | \class Task | ||
38 | \brief The Task class holds the data of a todo entry. | ||
39 | |||
40 | This data includes the priority of the task, a description, an optional due | ||
41 | date, and whether the task is completed or not. | ||
42 | |||
43 | \ingroup qtopiaemb | ||
44 | \ingroup qtopiadesktop | ||
45 | */ | ||
46 | |||
47 | /*! | ||
48 | Creates a new, empty task. | ||
49 | */ | ||
34 | Task::Task() : Record(), mDue( FALSE ), | 50 | Task::Task() : Record(), mDue( FALSE ), |
35 | mDueDate( QDate::currentDate() ), | 51 | mDueDate( QDate::currentDate() ), |
36 | mCompleted( FALSE ), mPriority( 3 ), mDesc() | 52 | mCompleted( FALSE ), mPriority( 3 ), mDesc() |
37 | { | 53 | { |
38 | } | 54 | } |
39 | 55 | ||
56 | /*! | ||
57 | \fn void Task::setPriority( int priority ) | ||
58 | |||
59 | Sets the priority of the task to \a priority. | ||
60 | */ | ||
61 | |||
62 | /*! | ||
63 | \fn int Task::priority() const | ||
64 | |||
65 | Returns the priority of the task. | ||
66 | */ | ||
67 | |||
68 | /*! | ||
69 | \fn void Task::setDescription( const QString &description ) | ||
70 | |||
71 | Sets the description of the task to \a description. | ||
72 | */ | ||
73 | |||
74 | /*! | ||
75 | \fn const QString &Task::description() const | ||
76 | |||
77 | Returns the description of the task. | ||
78 | */ | ||
79 | |||
80 | /*! | ||
81 | \fn void Task::setDueDate( const QDate &date, bool hasDue ) | ||
82 | |||
83 | \internal | ||
84 | If \a hasDue is TRUE sets the due date of the task to \a date. | ||
85 | Otherwise clears the due date of the task. | ||
86 | */ | ||
87 | |||
88 | /*! | ||
89 | \fn void Task::setDueDate( const QDate &date ) | ||
90 | |||
91 | Sets the due date of the task to \a date. | ||
92 | */ | ||
93 | |||
94 | /*! | ||
95 | \fn void Task::clearDueDate( ) | ||
96 | |||
97 | Clears the due date of the task. | ||
98 | */ | ||
99 | |||
100 | /*! | ||
101 | \fn void Task::setCompleted( bool b ) | ||
102 | |||
103 | If \a b is TRUE marks the task as completed. Otherwise marks the task as | ||
104 | uncompleted. | ||
105 | */ | ||
106 | |||
107 | /*! | ||
108 | \fn bool Task::isCompleted() const | ||
109 | |||
110 | Returns TRUE if the task is completed. Otherwise returns FALSE. | ||
111 | */ | ||
112 | |||
113 | /*! | ||
114 | \fn const QDate &Task::dueDate() const | ||
115 | |||
116 | Returns the due date of the task. | ||
117 | */ | ||
118 | |||
119 | /*! | ||
120 | \fn bool Task::hasDueDate() const | ||
121 | |||
122 | Returns TRUE if there is a due date set for the task. Otherwise returns | ||
123 | FALSE. | ||
124 | */ | ||
125 | |||
126 | /*! | ||
127 | \fn void Task::setHasDueDate( bool b ) | ||
128 | |||
129 | \internal | ||
130 | Just don't ask. I really can't justify the function. | ||
131 | */ | ||
132 | |||
133 | |||
134 | /*! | ||
135 | \internal | ||
136 | Creates a new task. The properties of the task are set from \a m. | ||
137 | */ | ||
138 | |||
40 | Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), | 139 | Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), |
41 | mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() | 140 | mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() |
42 | { | 141 | { |
43 | //qDebug("Task::Task fromMap"); | 142 | //qDebug("Task::Task fromMap"); |
44 | //dump( m ); | 143 | //dump( m ); |
45 | for ( QMap<int,QString>::ConstIterator it = m.begin(); it != m.end();++it ) | 144 | for ( QMap<int,QString>::ConstIterator it = m.begin(); it != m.end();++it ) |
46 | switch ( (TaskFields) it.key() ) { | 145 | switch ( (TaskFields) it.key() ) { |
47 | case HasDate: if ( *it == "1" ) mDue = TRUE; break; | 146 | case HasDate: if ( *it == "1" ) mDue = TRUE; break; |
48 | case Completed: setCompleted( *it == "1" ); break; | 147 | case Completed: setCompleted( *it == "1" ); break; |
49 | case TaskCategory: setCategories( idsFromString( *it ) ); break; | 148 | case TaskCategory: setCategories( idsFromString( *it ) ); break; |
50 | case TaskDescription: setDescription( *it ); break; | 149 | case TaskDescription: setDescription( *it ); break; |
51 | case Priority: setPriority( (*it).toInt() ); break; | 150 | case Priority: setPriority( (*it).toInt() ); break; |
52 | case Date: mDueDate = TimeConversion::fromString( (*it) ); break; | 151 | case Date: mDueDate = TimeConversion::fromString( (*it) ); break; |
53 | case TaskUid: setUid( (*it).toInt() ); break; | 152 | case TaskUid: setUid( (*it).toInt() ); break; |
54 | default: break; | 153 | case TaskRid: |
154 | case TaskRinfo: | ||
155 | break; | ||
55 | } | 156 | } |
56 | } | 157 | } |
57 | 158 | ||
159 | /*! | ||
160 | Destroys a task. | ||
161 | */ | ||
58 | Task::~Task() | 162 | Task::~Task() |
59 | { | 163 | { |
60 | } | 164 | } |
61 | 165 | ||
166 | /*! | ||
167 | \internal | ||
168 | Returns the task as a map of field ids to property values. | ||
169 | */ | ||
62 | QMap<int, QString> Task::toMap() const | 170 | QMap<int, QString> Task::toMap() const |
63 | { | 171 | { |
64 | QMap<int, QString> m; | 172 | QMap<int, QString> m; |
65 | m.insert( HasDate, hasDueDate() ? "1" : "0" ); | 173 | m.insert( HasDate, hasDueDate() ? "1" : "0" ); |
66 | m.insert( Completed, isCompleted() ? "1" : "0" ); | 174 | m.insert( Completed, isCompleted() ? "1" : "0" ); |
175 | if ( categories().count() ) | ||
67 | m.insert( TaskCategory, idsToString( categories() ) ); | 176 | m.insert( TaskCategory, idsToString( categories() ) ); |
177 | if ( !description().isEmpty() ) | ||
68 | m.insert( TaskDescription, description() ); | 178 | m.insert( TaskDescription, description() ); |
69 | m.insert( Priority, QString::number( priority() ) ); | 179 | m.insert( Priority, QString::number( priority() ) ); |
180 | if ( hasDueDate() ) | ||
70 | m.insert( Date, TimeConversion::toString( dueDate() ) ); | 181 | m.insert( Date, TimeConversion::toString( dueDate() ) ); |
71 | m.insert( TaskUid, QString::number(uid()) ); | 182 | m.insert( TaskUid, QString::number(uid()) ); |
72 | 183 | ||
73 | //qDebug("Task::toMap"); | 184 | //qDebug("Task::toMap"); |
74 | //dump( m ); | 185 | //dump( m ); |
75 | return m; | 186 | return m; |
76 | } | 187 | } |
77 | 188 | ||
189 | /*! | ||
190 | \internal | ||
191 | Appends the task information to \a buf. | ||
192 | */ | ||
78 | void Task::save( QString& buf ) const | 193 | void Task::save( QString& buf ) const |
79 | { | 194 | { |
80 | buf += " Completed=\""; | 195 | buf += " Completed=\""; |
81 | // qDebug( "writing %d", complete ); | 196 | // qDebug( "writing %d", complete ); |
82 | buf += QString::number( (int)mCompleted ); | 197 | buf += QString::number( (int)mCompleted ); |
83 | buf += "\""; | 198 | buf += "\""; |
84 | buf += " HasDate=\""; | 199 | buf += " HasDate=\""; |
85 | // qDebug( "writing %d", ); | 200 | // qDebug( "writing %d", ); |
@@ -112,64 +227,79 @@ void Task::save( QString& buf ) const | |||
112 | buf += customToXml(); | 227 | buf += customToXml(); |
113 | // qDebug ("writing uid %d", uid() ); | 228 | // qDebug ("writing uid %d", uid() ); |
114 | buf += " Uid=\""; | 229 | buf += " Uid=\""; |
115 | buf += QString::number( uid() ); | 230 | buf += QString::number( uid() ); |
116 | // terminate it in the application... | 231 | // terminate it in the application... |
117 | buf += "\""; | 232 | buf += "\""; |
118 | } | 233 | } |
119 | 234 | ||
120 | bool Task::match ( const QRegExp &r ) const | 235 | /*! |
236 | Returns TRUE if the task matches the regular expressions \a regexp. | ||
237 | Otherwise returns FALSE. | ||
238 | */ | ||
239 | bool Task::match ( const QRegExp ®exp ) const | ||
121 | { | 240 | { |
122 | // match on priority, description on due date... | 241 | // match on priority, description on due date... |
123 | bool match; | 242 | bool match; |
124 | match = false; | 243 | match = false; |
125 | if ( QString::number( mPriority ).find( r ) > -1 ) | 244 | if ( QString::number( mPriority ).find( regexp ) > -1 ) |
126 | match = true; | 245 | match = true; |
127 | else if ( mDue && mDueDate.toString().find( r ) > -1 ) | 246 | else if ( mDue && mDueDate.toString().find( regexp ) > -1 ) |
128 | match = true; | 247 | match = true; |
129 | else if ( mDesc.find( r ) > -1 ) | 248 | else if ( mDesc.find( regexp ) > -1 ) |
130 | match = true; | 249 | match = true; |
131 | return match; | 250 | return match; |
132 | } | 251 | } |
133 | 252 | ||
253 | /*! | ||
254 | \internal | ||
255 | */ | ||
134 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) | 256 | static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) |
135 | { | 257 | { |
136 | VObject *ret = 0; | 258 | VObject *ret = 0; |
137 | if ( o && !value.isEmpty() ) | 259 | if ( o && !value.isEmpty() ) |
138 | ret = addPropValue( o, prop, value.latin1() ); | 260 | ret = addPropValue( o, prop, value.latin1() ); |
139 | return ret; | 261 | return ret; |
140 | } | 262 | } |
141 | 263 | ||
264 | /*! | ||
265 | \internal | ||
266 | */ | ||
142 | static inline VObject *safeAddProp( VObject *o, const char *prop) | 267 | static inline VObject *safeAddProp( VObject *o, const char *prop) |
143 | { | 268 | { |
144 | VObject *ret = 0; | 269 | VObject *ret = 0; |
145 | if ( o ) | 270 | if ( o ) |
146 | ret = addProp( o, prop ); | 271 | ret = addProp( o, prop ); |
147 | return ret; | 272 | return ret; |
148 | } | 273 | } |
149 | 274 | ||
150 | 275 | ||
276 | /*! | ||
277 | \internal | ||
278 | */ | ||
151 | static VObject *createVObject( const Task &t ) | 279 | static VObject *createVObject( const Task &t ) |
152 | { | 280 | { |
153 | VObject *vcal = newVObject( VCCalProp ); | 281 | VObject *vcal = newVObject( VCCalProp ); |
154 | safeAddPropValue( vcal, VCVersionProp, "1.0" ); | 282 | safeAddPropValue( vcal, VCVersionProp, "1.0" ); |
155 | VObject *task = safeAddProp( vcal, VCTodoProp ); | 283 | VObject *task = safeAddProp( vcal, VCTodoProp ); |
156 | 284 | ||
157 | if ( t.hasDueDate() ) | 285 | if ( t.hasDueDate() ) |
158 | safeAddPropValue( task, VCDueProp, TimeConversion::toISO8601( t.dueDate() ) ); | 286 | safeAddPropValue( task, VCDueProp, TimeConversion::toISO8601( t.dueDate() ) ); |
159 | safeAddPropValue( task, VCDescriptionProp, t.description() ); | 287 | safeAddPropValue( task, VCDescriptionProp, t.description() ); |
160 | if ( t.isCompleted() ) | 288 | if ( t.isCompleted() ) |
161 | safeAddPropValue( task, VCStatusProp, "COMPLETED" ); | 289 | safeAddPropValue( task, VCStatusProp, "COMPLETED" ); |
162 | safeAddPropValue( task, VCPriorityProp, QString::number( t.priority() ) ); | 290 | safeAddPropValue( task, VCPriorityProp, QString::number( t.priority() ) ); |
163 | 291 | ||
164 | return vcal; | 292 | return vcal; |
165 | } | 293 | } |
166 | 294 | ||
167 | 295 | /*! | |
296 | \internal | ||
297 | */ | ||
168 | static Task parseVObject( VObject *obj ) | 298 | static Task parseVObject( VObject *obj ) |
169 | { | 299 | { |
170 | Task t; | 300 | Task t; |
171 | 301 | ||
172 | VObjectIterator it; | 302 | VObjectIterator it; |
173 | initPropIterator( &it, obj ); | 303 | initPropIterator( &it, obj ); |
174 | while( moreIteration( &it ) ) { | 304 | while( moreIteration( &it ) ) { |
175 | VObject *o = nextVObject( &it ); | 305 | VObject *o = nextVObject( &it ); |
@@ -202,17 +332,19 @@ static Task parseVObject( VObject *obj ) | |||
202 | } | 332 | } |
203 | #endif | 333 | #endif |
204 | } | 334 | } |
205 | 335 | ||
206 | return t; | 336 | return t; |
207 | } | 337 | } |
208 | 338 | ||
209 | 339 | ||
210 | 340 | /*! | |
341 | Writes the list of \a tasks as a set of VCards to the file \a filename. | ||
342 | */ | ||
211 | void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) | 343 | void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) |
212 | { | 344 | { |
213 | QFileDirect f( filename.utf8().data() ); | 345 | QFileDirect f( filename.utf8().data() ); |
214 | if ( !f.open( IO_WriteOnly ) ) { | 346 | if ( !f.open( IO_WriteOnly ) ) { |
215 | qWarning("Unable to open vcard write"); | 347 | qWarning("Unable to open vcard write"); |
216 | return; | 348 | return; |
217 | } | 349 | } |
218 | 350 | ||
@@ -221,32 +353,37 @@ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &task | |||
221 | VObject *obj = createVObject( *it ); | 353 | VObject *obj = createVObject( *it ); |
222 | writeVObject(f.directHandle() , obj ); | 354 | writeVObject(f.directHandle() , obj ); |
223 | cleanVObject( obj ); | 355 | cleanVObject( obj ); |
224 | } | 356 | } |
225 | 357 | ||
226 | cleanStrTbl(); | 358 | cleanStrTbl(); |
227 | } | 359 | } |
228 | 360 | ||
361 | /*! | ||
362 | Writes \a task as a VCard to the file \a filename. | ||
363 | */ | ||
229 | void Task::writeVCalendar( const QString &filename, const Task &task) | 364 | void Task::writeVCalendar( const QString &filename, const Task &task) |
230 | { | 365 | { |
231 | QFileDirect f( filename.utf8().data() ); | 366 | QFileDirect f( filename.utf8().data() ); |
232 | if ( !f.open( IO_WriteOnly ) ) { | 367 | if ( !f.open( IO_WriteOnly ) ) { |
233 | qWarning("Unable to open vcard write"); | 368 | qWarning("Unable to open vcard write"); |
234 | return; | 369 | return; |
235 | } | 370 | } |
236 | 371 | ||
237 | VObject *obj = createVObject( task ); | 372 | VObject *obj = createVObject( task ); |
238 | writeVObject(f.directHandle() , obj ); | 373 | writeVObject(f.directHandle() , obj ); |
239 | cleanVObject( obj ); | 374 | cleanVObject( obj ); |
240 | 375 | ||
241 | cleanStrTbl(); | 376 | cleanStrTbl(); |
242 | } | 377 | } |
243 | 378 | ||
244 | 379 | /*! | |
380 | Returns the set of tasks read as VCards from the file \a filename. | ||
381 | */ | ||
245 | QValueList<Task> Task::readVCalendar( const QString &filename ) | 382 | QValueList<Task> Task::readVCalendar( const QString &filename ) |
246 | { | 383 | { |
247 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 384 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
248 | 385 | ||
249 | QValueList<Task> tasks; | 386 | QValueList<Task> tasks; |
250 | 387 | ||
251 | while ( obj ) { | 388 | while ( obj ) { |
252 | QCString name = vObjectName( obj ); | 389 | QCString name = vObjectName( obj ); |
diff --git a/library/backend/task.h b/library/backend/task.h index 6f383b8..091f2e9 100644 --- a/library/backend/task.h +++ b/library/backend/task.h | |||
@@ -1,12 +1,12 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
@@ -15,18 +15,18 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __TASK_H__ | 20 | #ifndef __TASK_H__ |
21 | #define __TASK_H__ | 21 | #define __TASK_H__ |
22 | 22 | ||
23 | #include <qpe/palmtoprecord.h> | 23 | #include <qtopia/private/palmtoprecord.h> |
24 | #include <qpe/stringutil.h> | 24 | #include <qtopia/stringutil.h> |
25 | 25 | ||
26 | #include <qvaluelist.h> | 26 | #include <qvaluelist.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | 28 | ||
29 | class TaskPrivate; | 29 | class TaskPrivate; |
30 | class QPC_EXPORT Task : public Qtopia::Record | 30 | class QPC_EXPORT Task : public Qtopia::Record |
31 | { | 31 | { |
32 | public: | 32 | public: |
@@ -35,31 +35,39 @@ public: | |||
35 | ~Task(); | 35 | ~Task(); |
36 | 36 | ||
37 | QMap<int, QString> toMap() const; | 37 | QMap<int, QString> toMap() const; |
38 | 38 | ||
39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); | 39 | static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); |
40 | static void writeVCalendar( const QString &filename, const Task &task); | 40 | static void writeVCalendar( const QString &filename, const Task &task); |
41 | static QValueList<Task> readVCalendar( const QString &filename ); | 41 | static QValueList<Task> readVCalendar( const QString &filename ); |
42 | 42 | ||
43 | enum PriorityValue { VeryHigh=1, High, Normal, Low, VeryLow }; | ||
44 | |||
43 | void setPriority( int priority ) { mPriority = priority; } | 45 | void setPriority( int priority ) { mPriority = priority; } |
44 | int priority() const { return mPriority; } | 46 | int priority() const { return mPriority; } |
45 | 47 | ||
46 | // void setCategory( const QString& category ) | 48 | // void setCategory( const QString& category ) |
47 | // { mCategory = category.stripWhiteSpace(); } | 49 | // { mCategory = category.stripWhiteSpace(); } |
48 | // const QString &category() const { return mCategory; } | 50 | // const QString &category() const { return mCategory; } |
49 | 51 | ||
50 | void setDescription( const QString& description ) | 52 | void setDescription( const QString& description ) |
51 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } | 53 | { mDesc = Qtopia::simplifyMultiLineSpace(description); } |
52 | const QString &description() const { return mDesc; } | 54 | const QString &description() const { return mDesc; } |
53 | 55 | ||
56 | // Use THESE functions | ||
57 | void setDueDate( const QDate &date); | ||
58 | void clearDueDate(); | ||
59 | |||
60 | // Instead of these functions. | ||
54 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } | 61 | void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } |
62 | void setHasDueDate( bool b ) { mDue = b; } | ||
63 | |||
55 | const QDate &dueDate() const { return mDueDate; } | 64 | const QDate &dueDate() const { return mDueDate; } |
56 | bool hasDueDate() const { return mDue; } | 65 | bool hasDueDate() const { return mDue; } |
57 | void setHasDueDate( bool b ) { mDue = b; } | ||
58 | 66 | ||
59 | void setCompleted( bool b ) { mCompleted = b; } | 67 | void setCompleted( bool b ) { mCompleted = b; } |
60 | bool isCompleted() const { return mCompleted; } | 68 | bool isCompleted() const { return mCompleted; } |
61 | 69 | ||
62 | void save( QString& buf ) const; | 70 | void save( QString& buf ) const; |
63 | bool match( const QRegExp &r ) const; | 71 | bool match( const QRegExp &r ) const; |
64 | 72 | ||
65 | private: | 73 | private: |
@@ -73,9 +81,12 @@ private: | |||
73 | QString mDesc; | 81 | QString mDesc; |
74 | TaskPrivate *d; | 82 | TaskPrivate *d; |
75 | // ADDITION | 83 | // ADDITION |
76 | int recordId; | 84 | int recordId; |
77 | int recordInfo; | 85 | int recordInfo; |
78 | // | 86 | // |
79 | }; | 87 | }; |
80 | 88 | ||
89 | // MUST be inline. (forwards compatability). | ||
90 | inline void Task::setDueDate( const QDate &date) { setDueDate(date, date.isValid()); } | ||
91 | inline void Task::clearDueDate() { setHasDueDate( FALSE ); } | ||
81 | #endif | 92 | #endif |
diff --git a/library/backend/timeconversion.cpp b/library/backend/timeconversion.cpp deleted file mode 100644 index a4a2547..0000000 --- a/library/backend/timeconversion.cpp +++ b/dev/null | |||
@@ -1,237 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qglobal.h> | ||
22 | #include "timeconversion.h" | ||
23 | #include <qregexp.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | QString TimeConversion::toString( const QDate &d ) | ||
27 | { | ||
28 | QString r = QString::number( d.day() ) + "." + | ||
29 | QString::number( d.month() ) + "." + | ||
30 | QString::number( d.year() ); | ||
31 | //qDebug("TimeConversion::toString %s", r.latin1()); | ||
32 | return r; | ||
33 | } | ||
34 | |||
35 | QDate TimeConversion::fromString( const QString &datestr ) | ||
36 | { | ||
37 | int monthPos = datestr.find('.'); | ||
38 | int yearPos = datestr.find('.', monthPos+1 ); | ||
39 | if ( monthPos == -1 || yearPos == -1 ) { | ||
40 | qDebug("fromString didn't find . in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, yearPos ); | ||
41 | return QDate(); | ||
42 | } | ||
43 | int d = datestr.left( monthPos ).toInt(); | ||
44 | int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); | ||
45 | int y = datestr.mid( yearPos+1 ).toInt(); | ||
46 | QDate date ( y,m,d ); | ||
47 | //qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, yearPos); | ||
48 | return date; | ||
49 | } | ||
50 | |||
51 | time_t TimeConversion::toUTC( const QDateTime& dt ) | ||
52 | { | ||
53 | time_t tmp; | ||
54 | struct tm *lt; | ||
55 | |||
56 | #if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) | ||
57 | _tzset(); | ||
58 | #else | ||
59 | tzset(); | ||
60 | #endif | ||
61 | |||
62 | // get a tm structure from the system to get the correct tz_name | ||
63 | tmp = time( 0 ); | ||
64 | lt = localtime( &tmp ); | ||
65 | |||
66 | lt->tm_sec = dt.time().second(); | ||
67 | lt->tm_min = dt.time().minute(); | ||
68 | lt->tm_hour = dt.time().hour(); | ||
69 | lt->tm_mday = dt.date().day(); | ||
70 | lt->tm_mon = dt.date().month() - 1; // 0-11 instead of 1-12 | ||
71 | lt->tm_year = dt.date().year() - 1900; // year - 1900 | ||
72 | //lt->tm_wday = dt.date().dayOfWeek(); ignored anyway | ||
73 | //lt->tm_yday = dt.date().dayOfYear(); ignored anyway | ||
74 | lt->tm_wday = -1; | ||
75 | lt->tm_yday = -1; | ||
76 | // tm_isdst negative -> mktime will find out about DST | ||
77 | lt->tm_isdst = -1; | ||
78 | // keep tm_zone and tm_gmtoff | ||
79 | tmp = mktime( lt ); | ||
80 | return tmp; | ||
81 | } | ||
82 | |||
83 | QDateTime TimeConversion::fromUTC( time_t time ) | ||
84 | { | ||
85 | struct tm *lt; | ||
86 | |||
87 | #if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) | ||
88 | _tzset(); | ||
89 | #else | ||
90 | tzset(); | ||
91 | #endif | ||
92 | lt = localtime( &time ); | ||
93 | QDateTime dt; | ||
94 | dt.setDate( QDate( lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday ) ); | ||
95 | dt.setTime( QTime( lt->tm_hour, lt->tm_min, lt->tm_sec ) ); | ||
96 | return dt; | ||
97 | } | ||
98 | |||
99 | |||
100 | int TimeConversion::secsTo( const QDateTime &from, const QDateTime &to ) | ||
101 | { | ||
102 | return toUTC( to ) - toUTC( from ); | ||
103 | } | ||
104 | |||
105 | QCString TimeConversion::toISO8601( const QDate &d ) | ||
106 | { | ||
107 | time_t tmp = toUTC( d ); | ||
108 | struct tm *utc = gmtime( &tmp ); | ||
109 | |||
110 | QCString str; | ||
111 | str.sprintf("%04d%02d%02d", (utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday ); | ||
112 | return str; | ||
113 | } | ||
114 | |||
115 | QCString TimeConversion::toISO8601( const QDateTime &dt ) | ||
116 | { | ||
117 | time_t tmp = toUTC( dt ); | ||
118 | struct tm *utc = gmtime( &tmp ); | ||
119 | |||
120 | QCString str; | ||
121 | str.sprintf("%04d%02d%02dT%02d%02d%02dZ", | ||
122 | (utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday, | ||
123 | utc->tm_hour, utc->tm_min, utc->tm_sec ); | ||
124 | return str; | ||
125 | } | ||
126 | |||
127 | QDateTime TimeConversion::fromISO8601( const QCString &s ) | ||
128 | { | ||
129 | |||
130 | #if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) | ||
131 | _tzset(); | ||
132 | #else | ||
133 | tzset(); | ||
134 | #endif | ||
135 | |||
136 | struct tm *thetime = new tm; | ||
137 | |||
138 | QCString str = s.copy(); | ||
139 | str.replace(QRegExp("-"), "" ); | ||
140 | str.replace(QRegExp(":"), "" ); | ||
141 | str.stripWhiteSpace(); | ||
142 | str = str.lower(); | ||
143 | |||
144 | int i = str.find( "t" ); | ||
145 | QCString date; | ||
146 | QCString timestr; | ||
147 | if ( i != -1 ) { | ||
148 | date = str.left( i ); | ||
149 | timestr = str.mid( i+1 ); | ||
150 | } else { | ||
151 | date = str; | ||
152 | } | ||
153 | |||
154 | // qDebug("--- parsing ISO time---"); | ||
155 | thetime->tm_year = 100; | ||
156 | thetime->tm_mon = 0; | ||
157 | thetime->tm_mday = 0; | ||
158 | thetime->tm_hour = 0; | ||
159 | thetime->tm_min = 0; | ||
160 | thetime->tm_sec = 0; | ||
161 | |||
162 | // qDebug("date = %s", date.data() ); | ||
163 | |||
164 | switch( date.length() ) { | ||
165 | case 8: | ||
166 | thetime->tm_mday = date.right( 2 ).toInt(); | ||
167 | case 6: | ||
168 | thetime->tm_mon = date.mid( 4, 2 ).toInt() - 1; | ||
169 | case 4: | ||
170 | thetime->tm_year = date.left( 4 ).toInt(); | ||
171 | thetime->tm_year -= 1900; | ||
172 | break; | ||
173 | default: | ||
174 | break; | ||
175 | } | ||
176 | |||
177 | int tzoff = 0; | ||
178 | bool inLocalTime = FALSE; | ||
179 | if ( timestr.find( 'z' ) == (int)timestr.length() - 1 ) | ||
180 | // UTC | ||
181 | timestr = timestr.left( timestr.length() -1 ); | ||
182 | else { | ||
183 | int plus = timestr.find( "+" ); | ||
184 | int minus = timestr.find( "-" ); | ||
185 | if ( plus != -1 || minus != -1 ) { | ||
186 | // have a timezone offset | ||
187 | plus = (plus != -1) ? plus : minus; | ||
188 | QCString off = timestr.mid( plus ); | ||
189 | timestr = timestr.left( plus ); | ||
190 | |||
191 | int tzoffhour = 0; | ||
192 | int tzoffmin = 0; | ||
193 | switch( off.length() ) { | ||
194 | case 5: | ||
195 | tzoffmin = off.mid(3).toInt(); | ||
196 | case 3: | ||
197 | tzoffhour = off.left(3).toInt(); | ||
198 | default: | ||
199 | break; | ||
200 | } | ||
201 | tzoff = 60*tzoffhour + tzoffmin; | ||
202 | } else | ||
203 | inLocalTime = TRUE; | ||
204 | } | ||
205 | |||
206 | // get the time: | ||
207 | switch( timestr.length() ) { | ||
208 | case 6: | ||
209 | thetime->tm_sec = timestr.mid( 4 ).toInt(); | ||
210 | case 4: | ||
211 | thetime->tm_min = timestr.mid( 2, 2 ).toInt(); | ||
212 | case 2: | ||
213 | thetime->tm_hour = timestr.left( 2 ).toInt(); | ||
214 | default: | ||
215 | break; | ||
216 | } | ||
217 | |||
218 | int tzloc = 0; | ||
219 | time_t tmp = time( 0 ); | ||
220 | if ( !inLocalTime ) { | ||
221 | // have to get the offset between gmt and local time | ||
222 | struct tm *lt = localtime( &tmp ); | ||
223 | tzloc = mktime( lt ); | ||
224 | struct tm *ut = gmtime( &tmp ); | ||
225 | tzloc -= mktime( ut ); | ||
226 | } | ||
227 | // qDebug("time: %d %d %d, tzloc=%d, tzoff=%d", thetime->tm_hour, thetime->tm_min, thetime->tm_sec, | ||
228 | // tzloc, tzoff ); | ||
229 | |||
230 | tmp = mktime( thetime ); | ||
231 | tmp += 60*(-tzloc + tzoff); | ||
232 | |||
233 | delete thetime; | ||
234 | |||
235 | return fromUTC( tmp ); | ||
236 | } | ||
237 | |||
diff --git a/library/backend/timeconversion.h b/library/backend/timeconversion.h deleted file mode 100644 index 1724812..0000000 --- a/library/backend/timeconversion.h +++ b/dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef __timeconversion_h__ | ||
22 | #define __timeconversion_h__ | ||
23 | |||
24 | #include <time.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <qdatetime.h> | ||
27 | |||
28 | #include <qpe/qpcglobal.h> | ||
29 | |||
30 | class QPC_EXPORT TimeConversion | ||
31 | { | ||
32 | public: | ||
33 | static QString toString( const QDate &d ); | ||
34 | static QDate fromString( const QString &datestr ); | ||
35 | |||
36 | static time_t toUTC( const QDateTime& dt ); | ||
37 | static QDateTime fromUTC( time_t time ); | ||
38 | static int secsTo( const QDateTime &from, const QDateTime &to ); | ||
39 | |||
40 | static QCString toISO8601( const QDate & ); | ||
41 | static QCString toISO8601( const QDateTime & ); | ||
42 | static QDateTime fromISO8601( const QCString & ); | ||
43 | }; | ||
44 | |||
45 | #endif // __timeconversion_h__ | ||
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index e326a64..5bcf0cb 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y | |||
@@ -512,17 +512,17 @@ static void lexPopMode(int top) | |||
512 | 512 | ||
513 | static int lexWithinMode(enum LexMode mode) { | 513 | static int lexWithinMode(enum LexMode mode) { |
514 | unsigned long i; | 514 | unsigned long i; |
515 | for (i=0;i<lexBuf.lexModeStackTop;i++) | 515 | for (i=0;i<lexBuf.lexModeStackTop;i++) |
516 | if (mode == lexBuf.lexModeStack[i]) return 1; | 516 | if (mode == lexBuf.lexModeStack[i]) return 1; |
517 | return 0; | 517 | return 0; |
518 | } | 518 | } |
519 | 519 | ||
520 | static char lexGetc_() | 520 | static int lexGetc_() |
521 | { | 521 | { |
522 | /* get next char from input, no buffering. */ | 522 | /* get next char from input, no buffering. */ |
523 | if (lexBuf.curPos == lexBuf.inputLen) | 523 | if (lexBuf.curPos == lexBuf.inputLen) |
524 | return EOF; | 524 | return EOF; |
525 | else if (lexBuf.inputString) | 525 | else if (lexBuf.inputString) |
526 | return *(lexBuf.inputString + lexBuf.curPos++); | 526 | return *(lexBuf.inputString + lexBuf.curPos++); |
527 | else { | 527 | else { |
528 | #ifdef INCLUDEMFC | 528 | #ifdef INCLUDEMFC |
@@ -926,70 +926,79 @@ static int match_begin_end_name(int end) { | |||
926 | DBG_(("db: begin/end %d\n", token)); | 926 | DBG_(("db: begin/end %d\n", token)); |
927 | return token; | 927 | return token; |
928 | } | 928 | } |
929 | return 0; | 929 | return 0; |
930 | } | 930 | } |
931 | 931 | ||
932 | static char* lexGetQuotedPrintable() | 932 | static char* lexGetQuotedPrintable() |
933 | { | 933 | { |
934 | char cur; | 934 | int c; |
935 | 935 | lexSkipWhite(); | |
936 | c = lexLookahead(); | ||
936 | lexClearToken(); | 937 | lexClearToken(); |
937 | do { | 938 | |
938 | cur = lexGetc(); | 939 | while (c != EOF && c != ';') { |
939 | switch (cur) { | 940 | if (c == '\n') { |
940 | case '=': { | 941 | // break, leave '\n' on remaining chars. |
941 | int c = 0; | ||
942 | int next[2]; | ||
943 | int i; | ||
944 | for (i = 0; i < 2; i++) { | ||
945 | next[i] = lexGetc(); | ||
946 | if (next[i] >= '0' && next[i] <= '9') | ||
947 | c = c * 16 + next[i] - '0'; | ||
948 | else if (next[i] >= 'A' && next[i] <= 'F') | ||
949 | c = c * 16 + next[i] - 'A' + 10; | ||
950 | else | ||
951 | break; | 942 | break; |
943 | } else if (c == '=') { | ||
944 | int cur = 0; | ||
945 | int next; | ||
946 | |||
947 | lexSkipLookahead(); // skip '=' | ||
948 | next = lexLookahead(); | ||
949 | |||
950 | if (next == '\n') { | ||
951 | // skip and only skip the \n | ||
952 | lexSkipLookahead(); | ||
953 | c = lexLookahead(); | ||
954 | ++mime_lineNum; // aid in error reporting | ||
955 | continue; | ||
956 | } else if (next >= '0' && next <= '9') { | ||
957 | cur = next - '0'; | ||
958 | } else if (next >= 'A' && next <= 'F') { | ||
959 | cur = next - 'A' + 10; | ||
960 | } else { | ||
961 | // we have been sent buggy stuff. doesn't matter | ||
962 | // what we do so long as we keep going. | ||
963 | // should probably spit an error here | ||
964 | c = lexLookahead(); | ||
965 | continue; | ||
952 | } | 966 | } |
953 | if (i == 0) { | 967 | |
954 | /* single '=' follow by LINESEP is continuation sign? */ | 968 | lexSkipLookahead(); // skip A-Z0-9 |
955 | if (next[0] == '\n') { | 969 | next = lexLookahead(); |
956 | ++mime_lineNum; | 970 | |
957 | } | 971 | cur = cur * 16; |
958 | else { | 972 | // this time really just expecting 0-9A-F |
959 | lexPushLookaheadc('='); | 973 | if (next >= '0' && next <= '9') { |
960 | goto EndString; | 974 | cur += next - '0'; |
961 | } | 975 | } else if (next >= 'A' && next <= 'F') { |
976 | cur += next - 'A' + 10; | ||
977 | } else { | ||
978 | // we have been sent buggy stuff. doesn't matter | ||
979 | // what we do so long as we keep going. | ||
980 | // should probably spit an error here | ||
981 | c = lexLookahead(); | ||
982 | continue; | ||
962 | } | 983 | } |
963 | else if (i == 1) { | 984 | |
964 | lexPushLookaheadc(next[1]); | 985 | // got a valid escaped =. append it. |
965 | lexPushLookaheadc(next[0]); | 986 | lexSkipLookahead(); // skip second 0-9A-F |
966 | lexAppendc('='); | 987 | lexAppendc(cur); |
967 | } else { | 988 | } else { |
968 | lexAppendc(c); | 989 | lexSkipLookahead(); // skip whatever we just read. |
990 | lexAppendc(c); // and append it. | ||
969 | } | 991 | } |
970 | break; | 992 | c = lexLookahead(); |
971 | } /* '=' */ | ||
972 | case '\n': { | ||
973 | lexPushLookaheadc('\n'); | ||
974 | goto EndString; | ||
975 | } | 993 | } |
976 | case (char)EOF: | ||
977 | break; | ||
978 | default: | ||
979 | lexAppendc(cur); | ||
980 | break; | ||
981 | } /* switch */ | ||
982 | } while (cur != (char)EOF); | ||
983 | |||
984 | EndString: | ||
985 | lexAppendc(0); | 994 | lexAppendc(0); |
986 | return lexStr(); | 995 | return c==EOF?0:lexStr(); |
987 | } /* LexQuotedPrintable */ | 996 | } |
988 | 997 | ||
989 | static int yylex() { | 998 | static int yylex() { |
990 | 999 | ||
991 | int lexmode = LEXMODE(); | 1000 | int lexmode = LEXMODE(); |
992 | if (lexmode == L_VALUES) { | 1001 | if (lexmode == L_VALUES) { |
993 | int c = lexGetc(); | 1002 | int c = lexGetc(); |
994 | if (c == ';') { | 1003 | if (c == ';') { |
995 | DBG_(("db: SEMICOLON\n")); | 1004 | DBG_(("db: SEMICOLON\n")); |
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp index cb24631..19a108f 100644 --- a/library/backend/vcc_yacc.cpp +++ b/library/backend/vcc_yacc.cpp | |||
@@ -1,19 +1,44 @@ | |||
1 | #ifndef lint | 1 | #ifndef lint |
2 | static char yysccsid[] = "@(#)yaccpar1.9 (Berkeley) 02/21/93"; | 2 | /*static char yysccsid[] = "from: @(#)yaccpar1.9 (Berkeley) 02/21/93";*/ |
3 | static char yyrcsid[] = "$Id$"; | ||
3 | #endif | 4 | #endif |
4 | #define YYBYACC 1 | 5 | #define YYBYACC 1 |
5 | #define YYMAJOR 1 | 6 | #define YYMAJOR 1 |
6 | #define YYMINOR 9 | 7 | #define YYMINOR 9 |
7 | #define yyclearin (yychar=(-1)) | 8 | #define yyclearin (yychar=(-1)) |
8 | #define yyerrok (yyerrflag=0) | 9 | #define yyerrok (yyerrflag=0) |
9 | #define YYRECOVERING (yyerrflag!=0) | 10 | #define YYRECOVERING (yyerrflag!=0) |
10 | #define YYPREFIX "yy" | 11 | #define yyparse vccparse |
11 | #line 1 "vcc.y" | 12 | #define yylex vcclex |
13 | #define yyerror vccerror | ||
14 | #define yychar vccchar | ||
15 | #define yyval vccval | ||
16 | #define yylval vcclval | ||
17 | #define yydebug vccdebug | ||
18 | #define yynerrs vccnerrs | ||
19 | #define yyerrflag vccerrflag | ||
20 | #define yyss vccss | ||
21 | #define yyssp vccssp | ||
22 | #define yyvs vccvs | ||
23 | #define yyvsp vccvsp | ||
24 | #define yylhs vcclhs | ||
25 | #define yylen vcclen | ||
26 | #define yydefred vccdefred | ||
27 | #define yydgoto vccdgoto | ||
28 | #define yysindex vccsindex | ||
29 | #define yyrindex vccrindex | ||
30 | #define yygindex vccgindex | ||
31 | #define yytable vcctable | ||
32 | #define yycheck vcccheck | ||
33 | #define yyname vccname | ||
34 | #define yyrule vccrule | ||
35 | #define YYPREFIX "vcc" | ||
36 | #line 1 "backend/vcc.y" | ||
12 | 37 | ||
13 | 38 | ||
14 | /*************************************************************************** | 39 | /*************************************************************************** |
15 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | 40 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International |
16 | Business Machines Corporation and Siemens Rolm Communications Inc. | 41 | Business Machines Corporation and Siemens Rolm Communications Inc. |
17 | 42 | ||
18 | For purposes of this license notice, the term Licensors shall mean, | 43 | For purposes of this license notice, the term Licensors shall mean, |
19 | collectively, Apple Computer, Inc., AT&T Corp., International | 44 | collectively, Apple Computer, Inc., AT&T Corp., International |
@@ -68,16 +93,17 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
68 | #endif | 93 | #endif |
69 | 94 | ||
70 | /**** External Functions ****/ | 95 | /**** External Functions ****/ |
71 | 96 | ||
72 | /* assign local name to parser variables and functions so that | 97 | /* assign local name to parser variables and functions so that |
73 | we can use more than one yacc based parser. | 98 | we can use more than one yacc based parser. |
74 | */ | 99 | */ |
75 | 100 | ||
101 | #if 0 | ||
76 | #define yyparse mime_parse | 102 | #define yyparse mime_parse |
77 | #define yylex mime_lex | 103 | #define yylex mime_lex |
78 | #define yyerror mime_error | 104 | #define yyerror mime_error |
79 | #define yychar mime_char | 105 | #define yychar mime_char |
80 | /* #define p_yyval p_mime_val */ | 106 | /* #define p_yyval p_mime_val */ |
81 | #undef yyval | 107 | #undef yyval |
82 | #define yyval mime_yyval | 108 | #define yyval mime_yyval |
83 | /* #define p_yylval p_mime_lval */ | 109 | /* #define p_yylval p_mime_lval */ |
@@ -100,16 +126,17 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
100 | #define yytable mime_table | 126 | #define yytable mime_table |
101 | #define yycheck mime_check | 127 | #define yycheck mime_check |
102 | #define yyname mime_name | 128 | #define yyname mime_name |
103 | #define yyrule mime_rule | 129 | #define yyrule mime_rule |
104 | #ifdef YYPREFIX | 130 | #ifdef YYPREFIX |
105 | #undef YYPREFIX | 131 | #undef YYPREFIX |
106 | #endif | 132 | #endif |
107 | #define YYPREFIX "mime_" | 133 | #define YYPREFIX "mime_" |
134 | #endif | ||
108 | 135 | ||
109 | 136 | ||
110 | #ifndef _NO_LINE_FOLDING | 137 | #ifndef _NO_LINE_FOLDING |
111 | #define _SUPPORT_LINE_FOLDING 1 | 138 | #define _SUPPORT_LINE_FOLDING 1 |
112 | #endif | 139 | #endif |
113 | 140 | ||
114 | /* undef below if compile with MFC */ | 141 | /* undef below if compile with MFC */ |
115 | /* #define INCLUDEMFC 1 */ | 142 | /* #define INCLUDEMFC 1 */ |
@@ -123,30 +150,27 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
123 | #include <string.h> | 150 | #include <string.h> |
124 | #ifndef __MWERKS__ | 151 | #ifndef __MWERKS__ |
125 | #include <stdlib.h> | 152 | #include <stdlib.h> |
126 | #endif | 153 | #endif |
127 | #include <stdio.h> | 154 | #include <stdio.h> |
128 | #include <stdlib.h> | 155 | #include <stdlib.h> |
129 | #include <ctype.h> | 156 | #include <ctype.h> |
130 | 157 | ||
131 | #ifdef PALMTOPCENTER | 158 | /*#ifdef PALMTOPCENTER */ |
132 | #include <qpe/vobject_p.h> | 159 | /*#include <qpe/vobject_p.h> */ |
133 | #include <qpe/qfiledirect_p.h> | 160 | /*#else */ |
134 | #else | ||
135 | #include "vobject_p.h" | 161 | #include "vobject_p.h" |
136 | #include "qfiledirect_p.h" | 162 | /*#endif */ |
137 | #endif | ||
138 | 163 | ||
139 | /**** Types, Constants ****/ | 164 | /**** Types, Constants ****/ |
140 | 165 | ||
141 | #define YYDEBUG 0/* 1 to compile in some debugging code */ | 166 | #define YYDEBUG 0/* 1 to compile in some debugging code */ |
142 | #define MAXTOKEN 256/* maximum token (line) length */ | 167 | #define MAXTOKEN 256/* maximum token (line) length */ |
143 | #define YYSTACKSIZE 100/* ~unref ? | 168 | #define YYSTACKSIZE 100/* ~unref ? */ |
144 | */ | ||
145 | #define MAXLEVEL 10/* max # of nested objects parseable */ | 169 | #define MAXLEVEL 10/* max # of nested objects parseable */ |
146 | /* (includes outermost) */ | 170 | /* (includes outermost) */ |
147 | 171 | ||
148 | 172 | ||
149 | /**** Global Variables ****/ | 173 | /**** Global Variables ****/ |
150 | int mime_lineNum, mime_numErrors; /* yyerror() can use these */ | 174 | int mime_lineNum, mime_numErrors; /* yyerror() can use these */ |
151 | static VObject* vObjList; | 175 | static VObject* vObjList; |
152 | static VObject *curProp; | 176 | static VObject *curProp; |
@@ -183,24 +207,26 @@ enum LexMode { | |||
183 | static int pushVObject(const char *prop); | 207 | static int pushVObject(const char *prop); |
184 | static VObject* popVObject(); | 208 | static VObject* popVObject(); |
185 | static void lexPopMode(int top); | 209 | static void lexPopMode(int top); |
186 | static int lexWithinMode(enum LexMode mode); | 210 | static int lexWithinMode(enum LexMode mode); |
187 | static void lexPushMode(enum LexMode mode); | 211 | static void lexPushMode(enum LexMode mode); |
188 | static void enterProps(const char *s); | 212 | static void enterProps(const char *s); |
189 | static void enterAttr(const char *s1, const char *s2); | 213 | static void enterAttr(const char *s1, const char *s2); |
190 | static void enterValues(const char *value); | 214 | static void enterValues(const char *value); |
215 | #define mime_error yyerror | ||
216 | void mime_error(char *s); | ||
191 | void mime_error_(char *s); | 217 | void mime_error_(char *s); |
192 | 218 | ||
193 | #line 185 "vcc.y" | 219 | #line 189 "backend/vcc.y" |
194 | typedef union { | 220 | typedef union { |
195 | char *str; | 221 | char *str; |
196 | VObject *vobj; | 222 | VObject *vobj; |
197 | } YYSTYPE; | 223 | } YYSTYPE; |
198 | #line 196 "y.tab.c" | 224 | #line 225 "y.tab.c" |
199 | #define EQ 257 | 225 | #define EQ 257 |
200 | #define COLON 258 | 226 | #define COLON 258 |
201 | #define DOT 259 | 227 | #define DOT 259 |
202 | #define SEMICOLON 260 | 228 | #define SEMICOLON 260 |
203 | #define SPACE 261 | 229 | #define SPACE 261 |
204 | #define HTAB 262 | 230 | #define HTAB 262 |
205 | #define LINESEP 263 | 231 | #define LINESEP 263 |
206 | #define NEWLINE 264 | 232 | #define NEWLINE 264 |
@@ -210,103 +236,103 @@ typedef union { | |||
210 | #define END_VCAL 268 | 236 | #define END_VCAL 268 |
211 | #define BEGIN_VEVENT 269 | 237 | #define BEGIN_VEVENT 269 |
212 | #define END_VEVENT 270 | 238 | #define END_VEVENT 270 |
213 | #define BEGIN_VTODO 271 | 239 | #define BEGIN_VTODO 271 |
214 | #define END_VTODO 272 | 240 | #define END_VTODO 272 |
215 | #define ID 273 | 241 | #define ID 273 |
216 | #define STRING 274 | 242 | #define STRING 274 |
217 | #define YYERRCODE 256 | 243 | #define YYERRCODE 256 |
218 | short yylhs[] = { -1, | 244 | short vcclhs[] = { -1, |
219 | 0, 6, 6, 5, 5, 8, 3, 9, 3, 7, | 245 | 0, 6, 6, 5, 5, 8, 3, 9, 3, 7, |
220 | 7, 13, 10, 10, 15, 11, 11, 14, 14, 16, | 246 | 7, 13, 10, 10, 15, 11, 11, 14, 14, 16, |
221 | 17, 17, 1, 18, 12, 12, 2, 2, 20, 4, | 247 | 17, 17, 1, 18, 12, 12, 2, 2, 20, 4, |
222 | 21, 4, 19, 19, 22, 22, 22, 25, 23, 26, | 248 | 21, 4, 19, 19, 22, 22, 22, 25, 23, 26, |
223 | 23, 27, 24, 28, 24, | 249 | 23, 27, 24, 28, 24, |
224 | }; | 250 | }; |
225 | short yylen[] = { 2, | 251 | short vcclen[] = { 2, |
226 | 1, 2, 1, 1, 1, 0, 4, 0, 3, 2, | 252 | 1, 2, 1, 1, 1, 0, 4, 0, 3, 2, |
227 | 1, 0, 5, 1, 0, 3, 1, 2, 1, 2, | 253 | 1, 0, 5, 1, 0, 3, 1, 2, 1, 2, |
228 | 1, 3, 1, 0, 4, 1, 1, 0, 0, 4, | 254 | 1, 3, 1, 0, 4, 1, 1, 0, 0, 4, |
229 | 0, 3, 2, 1, 1, 1, 1, 0, 4, 0, | 255 | 0, 3, 2, 1, 1, 1, 1, 0, 4, 0, |
230 | 3, 0, 4, 0, 3, | 256 | 3, 0, 4, 0, 3, |
231 | }; | 257 | }; |
232 | short yydefred[] = { 0, | 258 | short vccdefred[] = { 0, |
233 | 0, 0, 0, 4, 5, 3, 0, 0, 0, 0, | 259 | 0, 0, 0, 4, 5, 3, 0, 0, 0, 0, |
234 | 0, 2, 14, 23, 0, 0, 11, 0, 9, 0, | 260 | 0, 2, 14, 23, 0, 0, 11, 0, 9, 0, |
235 | 0, 0, 0, 34, 35, 36, 32, 0, 7, 10, | 261 | 0, 0, 0, 34, 35, 36, 32, 0, 7, 10, |
236 | 12, 0, 0, 0, 0, 30, 33, 0, 0, 19, | 262 | 12, 0, 0, 0, 0, 30, 33, 0, 0, 19, |
237 | 0, 0, 41, 0, 45, 0, 20, 18, 27, 0, | 263 | 0, 0, 41, 0, 45, 0, 20, 18, 27, 0, |
238 | 0, 39, 43, 0, 24, 13, 22, 0, 25, | 264 | 0, 39, 43, 0, 24, 13, 22, 0, 25, |
239 | }; | 265 | }; |
240 | short yydgoto[] = { 3, | 266 | short vccdgoto[] = { 3, |
241 | 15, 50, 4, 5, 6, 7, 22, 8, 9, 17, | 267 | 15, 50, 4, 5, 6, 7, 22, 8, 9, 17, |
242 | 18, 51, 41, 39, 28, 40, 47, 58, 23, 10, | 268 | 18, 51, 41, 39, 28, 40, 47, 58, 23, 10, |
243 | 11, 24, 25, 26, 32, 33, 34, 35, | 269 | 11, 24, 25, 26, 32, 33, 34, 35, |
244 | }; | 270 | }; |
245 | short yysindex[] = { -262, | 271 | short vccsindex[] = { -262, |
246 | 0, 0, 0, 0, 0, 0, -262, -252, -219, -249, | 272 | 0, 0, 0, 0, 0, 0, -262, -252, -219, -249, |
247 | -256, 0, 0, 0, 0, -227, 0, -242, 0, 0, | 273 | -256, 0, 0, 0, 0, -227, 0, -242, 0, 0, |
248 | 0, -252, -254, 0, 0, 0, 0, -208, 0, 0, | 274 | 0, -252, -254, 0, 0, 0, 0, -208, 0, 0, |
249 | 0, -252, -228, -252, -213, 0, 0, -212, -208, 0, | 275 | 0, -252, -228, -252, -213, 0, 0, -212, -208, 0, |
250 | -214, -233, 0, -224, 0, -195, 0, 0, 0, -197, | 276 | -214, -233, 0, -224, 0, -195, 0, 0, 0, -197, |
251 | -199, 0, 0, -212, 0, 0, 0, -214, 0, | 277 | -199, 0, 0, -212, 0, 0, 0, -214, 0, |
252 | }; | 278 | }; |
253 | short yyrindex[] = { 0, | 279 | short vccrindex[] = { 0, |
254 | -222, -238, 0, 0, 0, 0, 65, 0, 0, 0, | 280 | -222, -238, 0, 0, 0, 0, 65, 0, 0, 0, |
255 | 0, 0, 0, 0, -215, 0, 0, 0, 0, -220, | 281 | 0, 0, 0, 0, -215, 0, 0, 0, 0, -220, |
256 | -218, -260, 0, 0, 0, 0, 0, 0, 0, 0, | 282 | -218, -260, 0, 0, 0, 0, 0, 0, 0, 0, |
257 | 0, 0, 0, 0, 0, 0, 0, 0, -192, 0, | 283 | 0, 0, 0, 0, 0, 0, 0, 0, -192, 0, |
258 | -250, 0, 0, 0, 0, -202, 0, 0, 0, -196, | 284 | -250, 0, 0, 0, 0, -202, 0, 0, 0, -196, |
259 | 0, 0, 0, 0, 0, 0, 0, -250, 0, | 285 | 0, 0, 0, 0, 0, 0, 0, -250, 0, |
260 | }; | 286 | }; |
261 | short yygindex[] = { 0, | 287 | short vccgindex[] = { 0, |
262 | 3, 0, 0, 0, 61, 0, -7, 0, 0, -16, | 288 | 3, 0, 0, 0, 61, 0, -7, 0, 0, -16, |
263 | 0, 11, 0, 0, 0, 31, 0, 0, 0, 0, | 289 | 0, 11, 0, 0, 0, 31, 0, 0, 0, 0, |
264 | 0, 48, 0, 0, 0, 0, 0, 0, | 290 | 0, 48, 0, 0, 0, 0, 0, 0, |
265 | }; | 291 | }; |
266 | #define YYTABLESIZE 71 | 292 | #define YYTABLESIZE 71 |
267 | short yytable[] = { 30, | 293 | short vcctable[] = { 30, |
268 | 16, 13, 1, 13, 2, 30, 13, 37, 37, 28, | 294 | 16, 13, 1, 13, 2, 30, 13, 37, 37, 28, |
269 | 37, 27, 28, 36, 20, 31, 21, 29, 14, 20, | 295 | 37, 27, 28, 36, 20, 31, 21, 29, 14, 20, |
270 | 14, 21, 13, 14, 42, 30, 44, 30, 13, 31, | 296 | 14, 21, 13, 14, 42, 30, 44, 30, 13, 31, |
271 | 29, 13, 29, 6, 29, 38, 52, 42, 29, 14, | 297 | 29, 13, 29, 6, 29, 38, 52, 42, 29, 14, |
272 | 46, 43, 17, 8, 15, 14, 19, 53, 14, 40, | 298 | 46, 43, 17, 8, 15, 14, 19, 53, 14, 40, |
273 | 6, 38, 38, 44, 42, 21, 57, 21, 45, 49, | 299 | 6, 38, 38, 44, 42, 21, 57, 21, 45, 49, |
274 | 14, 54, 55, 56, 1, 16, 26, 12, 59, 48, | 300 | 14, 54, 55, 56, 1, 16, 26, 12, 59, 48, |
275 | 37, | 301 | 37, |
276 | }; | 302 | }; |
277 | short yycheck[] = { 16, | 303 | short vcccheck[] = { 16, |
278 | 8, 256, 265, 256, 267, 22, 256, 268, 269, 260, | 304 | 8, 256, 265, 256, 267, 22, 256, 268, 269, 260, |
279 | 271, 268, 263, 268, 269, 258, 271, 256, 273, 269, | 305 | 271, 268, 263, 268, 269, 258, 271, 256, 273, 269, |
280 | 273, 271, 256, 273, 32, 42, 34, 44, 256, 268, | 306 | 273, 271, 256, 273, 32, 42, 34, 44, 256, 268, |
281 | 269, 256, 271, 256, 273, 256, 270, 256, 266, 273, | 307 | 269, 256, 271, 256, 273, 256, 270, 256, 266, 273, |
282 | 38, 270, 258, 266, 260, 273, 266, 272, 273, 270, | 308 | 38, 270, 258, 266, 260, 273, 266, 272, 273, 270, |
283 | 273, 260, 273, 272, 273, 258, 54, 260, 272, 274, | 309 | 273, 260, 273, 272, 273, 258, 54, 260, 272, 274, |
284 | 273, 257, 260, 263, 0, 258, 263, 7, 58, 39, | 310 | 273, 257, 260, 263, 0, 258, 263, 7, 58, 39, |
285 | 23, | 311 | 23, |
286 | }; | 312 | }; |
287 | #define YYFINAL 3 | 313 | #define YYFINAL 3 |
288 | #ifndef YYDEBUG | 314 | #ifndef YYDEBUG |
289 | #define YYDEBUG 0 | 315 | #define YYDEBUG 0 |
290 | #endif | 316 | #endif |
291 | #define YYMAXTOKEN 274 | 317 | #define YYMAXTOKEN 274 |
292 | #if YYDEBUG | 318 | #if YYDEBUG |
293 | char *yyname[] = { | 319 | char *vccname[] = { |
294 | "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 320 | "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
295 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 321 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
296 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 322 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
297 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 323 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
298 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 324 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
299 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | 325 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
300 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"EQ","COLON","DOT","SEMICOLON", | 326 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"EQ","COLON","DOT","SEMICOLON", |
301 | "SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL", | 327 | "SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL", |
302 | "END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING", | 328 | "END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING", |
303 | }; | 329 | }; |
304 | char *yyrule[] = { | 330 | char *vccrule[] = { |
305 | "$accept : mime", | 331 | "$accept : mime", |
306 | "mime : vobjects", | 332 | "mime : vobjects", |
307 | "vobjects : vobjects vobject", | 333 | "vobjects : vobjects vobject", |
308 | "vobjects : vobject", | 334 | "vobjects : vobject", |
309 | "vobject : vcard", | 335 | "vobject : vcard", |
310 | "vobject : vcal", | 336 | "vobject : vcal", |
311 | "$$1 :", | 337 | "$$1 :", |
312 | "vcard : BEGIN_VCARD $$1 items END_VCARD", | 338 | "vcard : BEGIN_VCARD $$1 items END_VCARD", |
@@ -367,17 +393,17 @@ int yyerrflag; | |||
367 | int yychar; | 393 | int yychar; |
368 | short *yyssp; | 394 | short *yyssp; |
369 | YYSTYPE *yyvsp; | 395 | YYSTYPE *yyvsp; |
370 | YYSTYPE yyval; | 396 | YYSTYPE yyval; |
371 | YYSTYPE yylval; | 397 | YYSTYPE yylval; |
372 | short yyss[YYSTACKSIZE]; | 398 | short yyss[YYSTACKSIZE]; |
373 | YYSTYPE yyvs[YYSTACKSIZE]; | 399 | YYSTYPE yyvs[YYSTACKSIZE]; |
374 | #define yystacksize YYSTACKSIZE | 400 | #define yystacksize YYSTACKSIZE |
375 | #line 378 "vcc.y" | 401 | #line 382 "backend/vcc.y" |
376 | 402 | ||
377 | /*------------------------------------*/ | 403 | /*------------------------------------*/ |
378 | static int pushVObject(const char *prop) | 404 | static int pushVObject(const char *prop) |
379 | { | 405 | { |
380 | VObject *newObj; | 406 | VObject *newObj; |
381 | if (ObjStackTop == MAXLEVEL) | 407 | if (ObjStackTop == MAXLEVEL) |
382 | return FALSE; | 408 | return FALSE; |
383 | 409 | ||
@@ -506,17 +532,17 @@ static void lexPopMode(int top) | |||
506 | 532 | ||
507 | static int lexWithinMode(enum LexMode mode) { | 533 | static int lexWithinMode(enum LexMode mode) { |
508 | unsigned long i; | 534 | unsigned long i; |
509 | for (i=0;i<lexBuf.lexModeStackTop;i++) | 535 | for (i=0;i<lexBuf.lexModeStackTop;i++) |
510 | if (mode == lexBuf.lexModeStack[i]) return 1; | 536 | if (mode == lexBuf.lexModeStack[i]) return 1; |
511 | return 0; | 537 | return 0; |
512 | } | 538 | } |
513 | 539 | ||
514 | static char lexGetc_() | 540 | static int lexGetc_() |
515 | { | 541 | { |
516 | /* get next char from input, no buffering. */ | 542 | /* get next char from input, no buffering. */ |
517 | if (lexBuf.curPos == lexBuf.inputLen) | 543 | if (lexBuf.curPos == lexBuf.inputLen) |
518 | return EOF; | 544 | return EOF; |
519 | else if (lexBuf.inputString) | 545 | else if (lexBuf.inputString) |
520 | return *(lexBuf.inputString + lexBuf.curPos++); | 546 | return *(lexBuf.inputString + lexBuf.curPos++); |
521 | else { | 547 | else { |
522 | #ifdef INCLUDEMFC | 548 | #ifdef INCLUDEMFC |
@@ -920,17 +946,17 @@ static int match_begin_end_name(int end) { | |||
920 | DBG_(("db: begin/end %d\n", token)); | 946 | DBG_(("db: begin/end %d\n", token)); |
921 | return token; | 947 | return token; |
922 | } | 948 | } |
923 | return 0; | 949 | return 0; |
924 | } | 950 | } |
925 | 951 | ||
926 | static char* lexGetQuotedPrintable() | 952 | static char* lexGetQuotedPrintable() |
927 | { | 953 | { |
928 | char cur; | 954 | int cur; |
929 | 955 | ||
930 | lexClearToken(); | 956 | lexClearToken(); |
931 | do { | 957 | do { |
932 | cur = lexGetc(); | 958 | cur = lexGetc(); |
933 | switch (cur) { | 959 | switch (cur) { |
934 | case '=': { | 960 | case '=': { |
935 | int c = 0; | 961 | int c = 0; |
936 | int next[2]; | 962 | int next[2]; |
@@ -962,23 +988,23 @@ static char* lexGetQuotedPrintable() | |||
962 | lexAppendc(c); | 988 | lexAppendc(c); |
963 | } | 989 | } |
964 | break; | 990 | break; |
965 | } /* '=' */ | 991 | } /* '=' */ |
966 | case '\n': { | 992 | case '\n': { |
967 | lexPushLookaheadc('\n'); | 993 | lexPushLookaheadc('\n'); |
968 | goto EndString; | 994 | goto EndString; |
969 | } | 995 | } |
970 | case (char)EOF: | 996 | case (int)EOF: |
971 | break; | 997 | break; |
972 | default: | 998 | default: |
973 | lexAppendc(cur); | 999 | lexAppendc(cur); |
974 | break; | 1000 | break; |
975 | } /* switch */ | 1001 | } /* switch */ |
976 | } while (cur != (char)EOF); | 1002 | } while (cur != (int)EOF); |
977 | 1003 | ||
978 | EndString: | 1004 | EndString: |
979 | lexAppendc(0); | 1005 | lexAppendc(0); |
980 | return lexStr(); | 1006 | return lexStr(); |
981 | } /* LexQuotedPrintable */ | 1007 | } /* LexQuotedPrintable */ |
982 | 1008 | ||
983 | static int yylex() { | 1009 | static int yylex() { |
984 | 1010 | ||
@@ -1145,23 +1171,28 @@ VObject* Parse_MIME_FromFile(FILE *file) | |||
1145 | if (!(result = Parse_MIMEHelper())) { | 1171 | if (!(result = Parse_MIMEHelper())) { |
1146 | fseek(file,startPos,SEEK_SET); | 1172 | fseek(file,startPos,SEEK_SET); |
1147 | } | 1173 | } |
1148 | return result; | 1174 | return result; |
1149 | } | 1175 | } |
1150 | 1176 | ||
1151 | DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) | 1177 | DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) |
1152 | { | 1178 | { |
1153 | QFileDirect f( fname ); | 1179 | FILE *fp = fopen(fname,"r"); |
1154 | if ( !f.open( IO_ReadOnly ) ) { | 1180 | if (fp) { |
1155 | qWarning("Unable to open mime for reading %s", fname); | 1181 | VObject* o = Parse_MIME_FromFile(fp); |
1182 | fclose(fp); | ||
1183 | return o; | ||
1184 | } | ||
1185 | else { | ||
1186 | char msg[80]; | ||
1187 | sprintf(msg, "can't open file '%s' for reading\n", fname); | ||
1188 | mime_error_(msg); | ||
1156 | return 0; | 1189 | return 0; |
1157 | } | 1190 | } |
1158 | |||
1159 | return Parse_MIME_FromFile( f.directHandle() ); | ||
1160 | } | 1191 | } |
1161 | 1192 | ||
1162 | #endif | 1193 | #endif |
1163 | 1194 | ||
1164 | /*-------------------------------------*/ | 1195 | /*-------------------------------------*/ |
1165 | 1196 | ||
1166 | static MimeErrorHandler mimeErrorHandler; | 1197 | static MimeErrorHandler mimeErrorHandler; |
1167 | 1198 | ||
@@ -1181,23 +1212,27 @@ void mime_error(char *s) | |||
1181 | 1212 | ||
1182 | void mime_error_(char *s) | 1213 | void mime_error_(char *s) |
1183 | { | 1214 | { |
1184 | if (mimeErrorHandler) { | 1215 | if (mimeErrorHandler) { |
1185 | mimeErrorHandler(s); | 1216 | mimeErrorHandler(s); |
1186 | } | 1217 | } |
1187 | } | 1218 | } |
1188 | 1219 | ||
1189 | #line 1192 "y.tab.c" | 1220 | #line 1221 "y.tab.c" |
1190 | #define YYABORT goto yyabort | 1221 | #define YYABORT goto yyabort |
1191 | #define YYREJECT goto yyabort | 1222 | #define YYREJECT goto yyabort |
1192 | #define YYACCEPT goto yyaccept | 1223 | #define YYACCEPT goto yyaccept |
1193 | #define YYERROR goto yyerrlab | 1224 | #define YYERROR goto yyerrlab |
1194 | int | 1225 | int |
1226 | #if defined(__STDC__) | ||
1227 | yyparse(void) | ||
1228 | #else | ||
1195 | yyparse() | 1229 | yyparse() |
1230 | #endif | ||
1196 | { | 1231 | { |
1197 | register int yym, yyn, yystate; | 1232 | register int yym, yyn, yystate; |
1198 | #if YYDEBUG | 1233 | #if YYDEBUG |
1199 | register char *yys; | 1234 | register char *yys; |
1200 | extern char *getenv(); | 1235 | extern char *getenv(); |
1201 | 1236 | ||
1202 | if (yys = getenv("YYDEBUG")) | 1237 | if (yys = getenv("YYDEBUG")) |
1203 | { | 1238 | { |
@@ -1211,17 +1246,17 @@ yyparse() | |||
1211 | yyerrflag = 0; | 1246 | yyerrflag = 0; |
1212 | yychar = (-1); | 1247 | yychar = (-1); |
1213 | 1248 | ||
1214 | yyssp = yyss; | 1249 | yyssp = yyss; |
1215 | yyvsp = yyvs; | 1250 | yyvsp = yyvs; |
1216 | *yyssp = yystate = 0; | 1251 | *yyssp = yystate = 0; |
1217 | 1252 | ||
1218 | yyloop: | 1253 | yyloop: |
1219 | if (yyn = yydefred[yystate]) goto yyreduce; | 1254 | if ((yyn = yydefred[yystate]) != 0) goto yyreduce; |
1220 | if (yychar < 0) | 1255 | if (yychar < 0) |
1221 | { | 1256 | { |
1222 | if ((yychar = yylex()) < 0) yychar = 0; | 1257 | if ((yychar = yylex()) < 0) yychar = 0; |
1223 | #if YYDEBUG | 1258 | #if YYDEBUG |
1224 | if (yydebug) | 1259 | if (yydebug) |
1225 | { | 1260 | { |
1226 | yys = 0; | 1261 | yys = 0; |
1227 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; | 1262 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; |
@@ -1251,20 +1286,16 @@ yyloop: | |||
1251 | } | 1286 | } |
1252 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && | 1287 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && |
1253 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar) | 1288 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar) |
1254 | { | 1289 | { |
1255 | yyn = yytable[yyn]; | 1290 | yyn = yytable[yyn]; |
1256 | goto yyreduce; | 1291 | goto yyreduce; |
1257 | } | 1292 | } |
1258 | if (yyerrflag) goto yyinrecovery; | 1293 | if (yyerrflag) goto yyinrecovery; |
1259 | #ifdef lint | ||
1260 | goto yynewerror; | ||
1261 | #endif | ||
1262 | yynewerror: | ||
1263 | yyerror("syntax error"); | 1294 | yyerror("syntax error"); |
1264 | #ifdef lint | 1295 | #ifdef lint |
1265 | goto yyerrlab; | 1296 | goto yyerrlab; |
1266 | #endif | 1297 | #endif |
1267 | yyerrlab: | 1298 | yyerrlab: |
1268 | ++yynerrs; | 1299 | ++yynerrs; |
1269 | yyinrecovery: | 1300 | yyinrecovery: |
1270 | if (yyerrflag < 3) | 1301 | if (yyerrflag < 3) |
@@ -1323,175 +1354,175 @@ yyreduce: | |||
1323 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", | 1354 | printf("%sdebug: state %d, reducing by rule %d (%s)\n", |
1324 | YYPREFIX, yystate, yyn, yyrule[yyn]); | 1355 | YYPREFIX, yystate, yyn, yyrule[yyn]); |
1325 | #endif | 1356 | #endif |
1326 | yym = yylen[yyn]; | 1357 | yym = yylen[yyn]; |
1327 | yyval = yyvsp[1-yym]; | 1358 | yyval = yyvsp[1-yym]; |
1328 | switch (yyn) | 1359 | switch (yyn) |
1329 | { | 1360 | { |
1330 | case 2: | 1361 | case 2: |
1331 | #line 217 "vcc.y" | 1362 | #line 221 "backend/vcc.y" |
1332 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } | 1363 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } |
1333 | break; | 1364 | break; |
1334 | case 3: | 1365 | case 3: |
1335 | #line 219 "vcc.y" | 1366 | #line 223 "backend/vcc.y" |
1336 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } | 1367 | { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } |
1337 | break; | 1368 | break; |
1338 | case 6: | 1369 | case 6: |
1339 | #line 228 "vcc.y" | 1370 | #line 232 "backend/vcc.y" |
1340 | { | 1371 | { |
1341 | lexPushMode(L_VCARD); | 1372 | lexPushMode(L_VCARD); |
1342 | if (!pushVObject(VCCardProp)) YYERROR; | 1373 | if (!pushVObject(VCCardProp)) YYERROR; |
1343 | } | 1374 | } |
1344 | break; | 1375 | break; |
1345 | case 7: | 1376 | case 7: |
1346 | #line 233 "vcc.y" | 1377 | #line 237 "backend/vcc.y" |
1347 | { | 1378 | { |
1348 | lexPopMode(0); | 1379 | lexPopMode(0); |
1349 | yyval.vobj = popVObject(); | 1380 | yyval.vobj = popVObject(); |
1350 | } | 1381 | } |
1351 | break; | 1382 | break; |
1352 | case 8: | 1383 | case 8: |
1353 | #line 238 "vcc.y" | 1384 | #line 242 "backend/vcc.y" |
1354 | { | 1385 | { |
1355 | lexPushMode(L_VCARD); | 1386 | lexPushMode(L_VCARD); |
1356 | if (!pushVObject(VCCardProp)) YYERROR; | 1387 | if (!pushVObject(VCCardProp)) YYERROR; |
1357 | } | 1388 | } |
1358 | break; | 1389 | break; |
1359 | case 9: | 1390 | case 9: |
1360 | #line 243 "vcc.y" | 1391 | #line 247 "backend/vcc.y" |
1361 | { | 1392 | { |
1362 | lexPopMode(0); | 1393 | lexPopMode(0); |
1363 | yyval.vobj = popVObject(); | 1394 | yyval.vobj = popVObject(); |
1364 | } | 1395 | } |
1365 | break; | 1396 | break; |
1366 | case 12: | 1397 | case 12: |
1367 | #line 254 "vcc.y" | 1398 | #line 258 "backend/vcc.y" |
1368 | { | 1399 | { |
1369 | lexPushMode(L_VALUES); | 1400 | lexPushMode(L_VALUES); |
1370 | } | 1401 | } |
1371 | break; | 1402 | break; |
1372 | case 13: | 1403 | case 13: |
1373 | #line 258 "vcc.y" | 1404 | #line 262 "backend/vcc.y" |
1374 | { | 1405 | { |
1375 | if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) | 1406 | if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) |
1376 | lexPopMode(0); | 1407 | lexPopMode(0); |
1377 | lexPopMode(0); | 1408 | lexPopMode(0); |
1378 | } | 1409 | } |
1379 | break; | 1410 | break; |
1380 | case 15: | 1411 | case 15: |
1381 | #line 267 "vcc.y" | 1412 | #line 271 "backend/vcc.y" |
1382 | { | 1413 | { |
1383 | enterProps(yyvsp[0].str); | 1414 | enterProps(yyvsp[0].str); |
1384 | } | 1415 | } |
1385 | break; | 1416 | break; |
1386 | case 17: | 1417 | case 17: |
1387 | #line 272 "vcc.y" | 1418 | #line 276 "backend/vcc.y" |
1388 | { | 1419 | { |
1389 | enterProps(yyvsp[0].str); | 1420 | enterProps(yyvsp[0].str); |
1390 | } | 1421 | } |
1391 | break; | 1422 | break; |
1392 | case 21: | 1423 | case 21: |
1393 | #line 285 "vcc.y" | 1424 | #line 289 "backend/vcc.y" |
1394 | { | 1425 | { |
1395 | enterAttr(yyvsp[0].str,0); | 1426 | enterAttr(yyvsp[0].str,0); |
1396 | } | 1427 | } |
1397 | break; | 1428 | break; |
1398 | case 22: | 1429 | case 22: |
1399 | #line 289 "vcc.y" | 1430 | #line 293 "backend/vcc.y" |
1400 | { | 1431 | { |
1401 | enterAttr(yyvsp[-2].str,yyvsp[0].str); | 1432 | enterAttr(yyvsp[-2].str,yyvsp[0].str); |
1402 | 1433 | ||
1403 | } | 1434 | } |
1404 | break; | 1435 | break; |
1405 | case 24: | 1436 | case 24: |
1406 | #line 298 "vcc.y" | 1437 | #line 302 "backend/vcc.y" |
1407 | { enterValues(yyvsp[-1].str); } | 1438 | { enterValues(yyvsp[-1].str); } |
1408 | break; | 1439 | break; |
1409 | case 26: | 1440 | case 26: |
1410 | #line 300 "vcc.y" | 1441 | #line 304 "backend/vcc.y" |
1411 | { enterValues(yyvsp[0].str); } | 1442 | { enterValues(yyvsp[0].str); } |
1412 | break; | 1443 | break; |
1413 | case 28: | 1444 | case 28: |
1414 | #line 305 "vcc.y" | 1445 | #line 309 "backend/vcc.y" |
1415 | { yyval.str = 0; } | 1446 | { yyval.str = 0; } |
1416 | break; | 1447 | break; |
1417 | case 29: | 1448 | case 29: |
1418 | #line 310 "vcc.y" | 1449 | #line 314 "backend/vcc.y" |
1419 | { if (!pushVObject(VCCalProp)) YYERROR; } | 1450 | { if (!pushVObject(VCCalProp)) YYERROR; } |
1420 | break; | 1451 | break; |
1421 | case 30: | 1452 | case 30: |
1422 | #line 313 "vcc.y" | 1453 | #line 317 "backend/vcc.y" |
1423 | { yyval.vobj = popVObject(); } | 1454 | { yyval.vobj = popVObject(); } |
1424 | break; | 1455 | break; |
1425 | case 31: | 1456 | case 31: |
1426 | #line 315 "vcc.y" | 1457 | #line 319 "backend/vcc.y" |
1427 | { if (!pushVObject(VCCalProp)) YYERROR; } | 1458 | { if (!pushVObject(VCCalProp)) YYERROR; } |
1428 | break; | 1459 | break; |
1429 | case 32: | 1460 | case 32: |
1430 | #line 317 "vcc.y" | 1461 | #line 321 "backend/vcc.y" |
1431 | { yyval.vobj = popVObject(); } | 1462 | { yyval.vobj = popVObject(); } |
1432 | break; | 1463 | break; |
1433 | case 38: | 1464 | case 38: |
1434 | #line 332 "vcc.y" | 1465 | #line 336 "backend/vcc.y" |
1435 | { | 1466 | { |
1436 | lexPushMode(L_VEVENT); | 1467 | lexPushMode(L_VEVENT); |
1437 | if (!pushVObject(VCEventProp)) YYERROR; | 1468 | if (!pushVObject(VCEventProp)) YYERROR; |
1438 | } | 1469 | } |
1439 | break; | 1470 | break; |
1440 | case 39: | 1471 | case 39: |
1441 | #line 338 "vcc.y" | 1472 | #line 342 "backend/vcc.y" |
1442 | { | 1473 | { |
1443 | lexPopMode(0); | 1474 | lexPopMode(0); |
1444 | popVObject(); | 1475 | popVObject(); |
1445 | } | 1476 | } |
1446 | break; | 1477 | break; |
1447 | case 40: | 1478 | case 40: |
1448 | #line 343 "vcc.y" | 1479 | #line 347 "backend/vcc.y" |
1449 | { | 1480 | { |
1450 | lexPushMode(L_VEVENT); | 1481 | lexPushMode(L_VEVENT); |
1451 | if (!pushVObject(VCEventProp)) YYERROR; | 1482 | if (!pushVObject(VCEventProp)) YYERROR; |
1452 | } | 1483 | } |
1453 | break; | 1484 | break; |
1454 | case 41: | 1485 | case 41: |
1455 | #line 348 "vcc.y" | 1486 | #line 352 "backend/vcc.y" |
1456 | { | 1487 | { |
1457 | lexPopMode(0); | 1488 | lexPopMode(0); |
1458 | popVObject(); | 1489 | popVObject(); |
1459 | } | 1490 | } |
1460 | break; | 1491 | break; |
1461 | case 42: | 1492 | case 42: |
1462 | #line 356 "vcc.y" | 1493 | #line 360 "backend/vcc.y" |
1463 | { | 1494 | { |
1464 | lexPushMode(L_VTODO); | 1495 | lexPushMode(L_VTODO); |
1465 | if (!pushVObject(VCTodoProp)) YYERROR; | 1496 | if (!pushVObject(VCTodoProp)) YYERROR; |
1466 | } | 1497 | } |
1467 | break; | 1498 | break; |
1468 | case 43: | 1499 | case 43: |
1469 | #line 362 "vcc.y" | 1500 | #line 366 "backend/vcc.y" |
1470 | { | 1501 | { |
1471 | lexPopMode(0); | 1502 | lexPopMode(0); |
1472 | popVObject(); | 1503 | popVObject(); |
1473 | } | 1504 | } |
1474 | break; | 1505 | break; |
1475 | case 44: | 1506 | case 44: |
1476 | #line 367 "vcc.y" | 1507 | #line 371 "backend/vcc.y" |
1477 | { | 1508 | { |
1478 | lexPushMode(L_VTODO); | 1509 | lexPushMode(L_VTODO); |
1479 | if (!pushVObject(VCTodoProp)) YYERROR; | 1510 | if (!pushVObject(VCTodoProp)) YYERROR; |
1480 | } | 1511 | } |
1481 | break; | 1512 | break; |
1482 | case 45: | 1513 | case 45: |
1483 | #line 372 "vcc.y" | 1514 | #line 376 "backend/vcc.y" |
1484 | { | 1515 | { |
1485 | lexPopMode(0); | 1516 | lexPopMode(0); |
1486 | popVObject(); | 1517 | popVObject(); |
1487 | } | 1518 | } |
1488 | break; | 1519 | break; |
1489 | #line 1492 "y.tab.c" | 1520 | #line 1521 "y.tab.c" |
1490 | } | 1521 | } |
1491 | yyssp -= yym; | 1522 | yyssp -= yym; |
1492 | yystate = *yyssp; | 1523 | yystate = *yyssp; |
1493 | yyvsp -= yym; | 1524 | yyvsp -= yym; |
1494 | yym = yylhs[yyn]; | 1525 | yym = yylhs[yyn]; |
1495 | if (yystate == 0 && yym == 0) | 1526 | if (yystate == 0 && yym == 0) |
1496 | { | 1527 | { |
1497 | #if YYDEBUG | 1528 | #if YYDEBUG |
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index 9c2ba3b..e6f6b78 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -1000,29 +1000,104 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) | |||
1000 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); | 1000 | appendsOFile(fp, ((cur >= len)?"\n" :(numQuads==MAXQUADS-1?"\n" : ""))); |
1001 | numQuads = (numQuads + 1) % MAXQUADS; | 1001 | numQuads = (numQuads + 1) % MAXQUADS; |
1002 | } | 1002 | } |
1003 | appendcOFile(fp,'\n'); | 1003 | appendcOFile(fp,'\n'); |
1004 | 1004 | ||
1005 | return 1; | 1005 | return 1; |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | static const char *replaceChar(unsigned char c) | ||
1009 | { | ||
1010 | if (c == '\n') { | ||
1011 | return "=0A=\n"; | ||
1012 | } else if ( | ||
1013 | (c >= 'A' && c <= 'Z') | ||
1014 | || | ||
1015 | (c >= 'a' && c <= 'z') | ||
1016 | || | ||
1017 | (c >= '0' && c <= '9') | ||
1018 | || | ||
1019 | (c >= '\'' && c <= ')') | ||
1020 | || | ||
1021 | (c >= '+' && c <= '-') | ||
1022 | || | ||
1023 | (c == '/') | ||
1024 | || | ||
1025 | (c == '?') | ||
1026 | || | ||
1027 | (c == ' ')) | ||
1028 | { | ||
1029 | return 0; | ||
1030 | } | ||
1031 | |||
1032 | static char trans[4]; | ||
1033 | trans[0] = '='; | ||
1034 | trans[3] = '\0'; | ||
1035 | int rem = c % 16; | ||
1036 | int div = c / 16; | ||
1037 | |||
1038 | if (div < 10) | ||
1039 | trans[1] = '0' + div; | ||
1040 | else | ||
1041 | trans[1] = 'A' + (div - 10); | ||
1042 | |||
1043 | if (rem < 10) | ||
1044 | trans[2] = '0' + rem; | ||
1045 | else | ||
1046 | trans[2] = 'A' + (rem - 10); | ||
1047 | |||
1048 | return trans; | ||
1049 | } | ||
1050 | |||
1008 | static void writeQPString(OFile *fp, const char *s) | 1051 | static void writeQPString(OFile *fp, const char *s) |
1009 | { | 1052 | { |
1053 | /* | ||
1054 | only A-Z, 0-9 and | ||
1055 | "'" (ASCII code 39) | ||
1056 | "(" (ASCII code 40) | ||
1057 | ")" (ASCII code 41) | ||
1058 | "+" (ASCII code 43) | ||
1059 | "," (ASCII code 44) | ||
1060 | "-" (ASCII code 45) | ||
1061 | "/" (ASCII code 47) | ||
1062 | "?" (ASCII code 63) | ||
1063 | |||
1064 | should remain un-encoded. | ||
1065 | '=' needs to be encoded as it is the escape character. | ||
1066 | ';' needs to be as it is a field separator. | ||
1067 | |||
1068 | */ | ||
1010 | const char *p = s; | 1069 | const char *p = s; |
1011 | while (*p) { | 1070 | while (*p) { |
1012 | if (*p == '\n') { | 1071 | const char *rep = replaceChar(*p); |
1013 | if (p[1]) appendsOFile(fp,"=0A="); | 1072 | if (rep) |
1014 | } | 1073 | appendsOFile(fp, rep); |
1074 | else | ||
1015 | appendcOFile(fp,*p); | 1075 | appendcOFile(fp,*p); |
1016 | p++; | 1076 | p++; |
1017 | } | 1077 | } |
1018 | } | 1078 | } |
1019 | 1079 | ||
1020 | 1080 | static bool includesUnprintable(VObject *o) | |
1081 | { | ||
1082 | if (o) { | ||
1083 | if (VALUE_TYPE(o) == VCVT_STRINGZ) { | ||
1084 | const char *p = STRINGZ_VALUE_OF(o); | ||
1085 | if (p) { | ||
1086 | while (*p) { | ||
1087 | if (replaceChar(*p)) | ||
1088 | return TRUE; | ||
1089 | p++; | ||
1090 | } | ||
1091 | } | ||
1092 | } | ||
1093 | } | ||
1094 | return FALSE; | ||
1095 | } | ||
1021 | 1096 | ||
1022 | static void writeVObject_(OFile *fp, VObject *o); | 1097 | static void writeVObject_(OFile *fp, VObject *o); |
1023 | 1098 | ||
1024 | static void writeValue(OFile *fp, VObject *o, unsigned long size) | 1099 | static void writeValue(OFile *fp, VObject *o, unsigned long size) |
1025 | { | 1100 | { |
1026 | if (o == 0) return; | 1101 | if (o == 0) return; |
1027 | switch (VALUE_TYPE(o)) { | 1102 | switch (VALUE_TYPE(o)) { |
1028 | case VCVT_STRINGZ: { | 1103 | case VCVT_STRINGZ: { |
@@ -1054,16 +1129,20 @@ static void writeValue(OFile *fp, VObject *o, unsigned long size) | |||
1054 | } | 1129 | } |
1055 | 1130 | ||
1056 | static void writeAttrValue(OFile *fp, VObject *o) | 1131 | static void writeAttrValue(OFile *fp, VObject *o) |
1057 | { | 1132 | { |
1058 | if (NAME_OF(o)) { | 1133 | if (NAME_OF(o)) { |
1059 | struct PreDefProp *pi; | 1134 | struct PreDefProp *pi; |
1060 | pi = lookupPropInfo(NAME_OF(o)); | 1135 | pi = lookupPropInfo(NAME_OF(o)); |
1061 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; | 1136 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; |
1137 | if ( includesUnprintable(o) ) { | ||
1138 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | ||
1139 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1140 | } | ||
1062 | appendcOFile(fp,';'); | 1141 | appendcOFile(fp,';'); |
1063 | appendsOFile(fp,NAME_OF(o)); | 1142 | appendsOFile(fp,NAME_OF(o)); |
1064 | } | 1143 | } |
1065 | else | 1144 | else |
1066 | appendcOFile(fp,';'); | 1145 | appendcOFile(fp,';'); |
1067 | if (VALUE_TYPE(o)) { | 1146 | if (VALUE_TYPE(o)) { |
1068 | appendcOFile(fp,'='); | 1147 | appendcOFile(fp,'='); |
1069 | writeValue(fp,o,0); | 1148 | writeValue(fp,o,0); |
@@ -1117,33 +1196,50 @@ static void writeProp(OFile *fp, VObject *o) | |||
1117 | s = NAME_OF(eachProp); | 1196 | s = NAME_OF(eachProp); |
1118 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) | 1197 | if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) |
1119 | writeAttrValue(fp,eachProp); | 1198 | writeAttrValue(fp,eachProp); |
1120 | } | 1199 | } |
1121 | if (fields_) { | 1200 | if (fields_) { |
1122 | int i = 0, n = 0; | 1201 | int i = 0, n = 0; |
1123 | const char** fields = fields_; | 1202 | const char** fields = fields_; |
1124 | /* output prop as fields */ | 1203 | /* output prop as fields */ |
1204 | bool printable = TRUE; | ||
1205 | while (*fields && printable) { | ||
1206 | VObject *t = isAPropertyOf(o,*fields); | ||
1207 | if (includesUnprintable(t)) | ||
1208 | printable = FALSE; | ||
1209 | fields++; | ||
1210 | } | ||
1211 | fields = fields_; | ||
1212 | if (!printable) { | ||
1213 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | ||
1214 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1215 | } | ||
1125 | appendcOFile(fp,':'); | 1216 | appendcOFile(fp,':'); |
1126 | while (*fields) { | 1217 | while (*fields) { |
1127 | VObject *t = isAPropertyOf(o,*fields); | 1218 | VObject *t = isAPropertyOf(o,*fields); |
1128 | i++; | 1219 | i++; |
1129 | if (t) n = i; | 1220 | if (t) n = i; |
1130 | fields++; | 1221 | fields++; |
1131 | } | 1222 | } |
1132 | fields = fields_; | 1223 | fields = fields_; |
1133 | for (i=0;i<n;i++) { | 1224 | for (i=0;i<n;i++) { |
1134 | writeValue(fp,isAPropertyOf(o,*fields),0); | 1225 | writeValue(fp,isAPropertyOf(o,*fields),0); |
1135 | fields++; | 1226 | fields++; |
1136 | if (i<(n-1)) appendcOFile(fp,';'); | 1227 | if (i<(n-1)) appendcOFile(fp,';'); |
1137 | } | 1228 | } |
1138 | } | 1229 | } |
1139 | } | 1230 | } |
1140 | 1231 | ||
1232 | |||
1141 | if (VALUE_TYPE(o)) { | 1233 | if (VALUE_TYPE(o)) { |
1234 | if ( includesUnprintable(o) ) { | ||
1235 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | ||
1236 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1237 | } | ||
1142 | unsigned long size = 0; | 1238 | unsigned long size = 0; |
1143 | VObject *p = isAPropertyOf(o,VCDataSizeProp); | 1239 | VObject *p = isAPropertyOf(o,VCDataSizeProp); |
1144 | if (p) size = LONG_VALUE_OF(p); | 1240 | if (p) size = LONG_VALUE_OF(p); |
1145 | appendcOFile(fp,':'); | 1241 | appendcOFile(fp,':'); |
1146 | writeValue(fp,o,size); | 1242 | writeValue(fp,o,size); |
1147 | } | 1243 | } |
1148 | 1244 | ||
1149 | appendcOFile(fp,'\n'); | 1245 | appendcOFile(fp,'\n'); |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index a0d921e..0d0a2a8 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -69,16 +69,18 @@ which accompanied this distribution. | |||
69 | 69 | ||
70 | Also visit: | 70 | Also visit: |
71 | 71 | ||
72 | http://www.versit.com | 72 | http://www.versit.com |
73 | http://www.ralden.com | 73 | http://www.ralden.com |
74 | 74 | ||
75 | */ | 75 | */ |
76 | 76 | ||
77 | // No tr() anywhere in this file | ||
78 | |||
77 | 79 | ||
78 | #ifndef __VOBJECT_H__ | 80 | #ifndef __VOBJECT_H__ |
79 | #define __VOBJECT_H__ 1 | 81 | #define __VOBJECT_H__ 1 |
80 | 82 | ||
81 | #include <qstring.h> | 83 | #include <qstring.h> |
82 | 84 | ||
83 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" | 85 | #define vCardClipboardFormat "+//ISBN 1-887687-00-9::versit::PDI//vCard" |
84 | #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar" | 86 | #define vCalendarClipboardFormat"+//ISBN 1-887687-00-9::versit::PDI//vCalendar" |
@@ -137,17 +139,17 @@ For example: | |||
137 | #define VCBusinessRoleProp "ROLE" | 139 | #define VCBusinessRoleProp "ROLE" |
138 | #define VCCalProp "VCALENDAR" | 140 | #define VCCalProp "VCALENDAR" |
139 | #define VCCaptionProp "CAP" | 141 | #define VCCaptionProp "CAP" |
140 | #define VCCardProp "VCARD" | 142 | #define VCCardProp "VCARD" |
141 | #define VCCarProp "CAR" | 143 | #define VCCarProp "CAR" |
142 | #define VCCategoriesProp "CATEGORIES" | 144 | #define VCCategoriesProp "CATEGORIES" |
143 | #define VCCellularProp "CELL" | 145 | #define VCCellularProp "CELL" |
144 | #define VCCGMProp "CGM" | 146 | #define VCCGMProp "CGM" |
145 | #define VCCharSetProp "CS" | 147 | #define VCCharSetProp "CHARSET" |
146 | #define VCCIDProp "CID" | 148 | #define VCCIDProp "CID" |
147 | #define VCCISProp "CIS" | 149 | #define VCCISProp "CIS" |
148 | #define VCCityProp "L" | 150 | #define VCCityProp "L" |
149 | #define VCClassProp "CLASS" | 151 | #define VCClassProp "CLASS" |
150 | #define VCCommentProp "NOTE" | 152 | #define VCCommentProp "NOTE" |
151 | #define VCCompletedProp "COMPLETED" | 153 | #define VCCompletedProp "COMPLETED" |
152 | #define VCContentIDProp "CONTENT-ID" | 154 | #define VCContentIDProp "CONTENT-ID" |
153 | #define VCCountryNameProp "C" | 155 | #define VCCountryNameProp "C" |