summaryrefslogtreecommitdiff
path: root/library/backend
authorzecke <zecke>2002-09-10 12:09:49 (UTC)
committer zecke <zecke>2002-09-10 12:09:49 (UTC)
commit6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff)
tree6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/backend
parentd10cddb3c9ce75bc90b14add14bc133737fe35aa (diff)
downloadopie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2
Qtopia1-6 merge
still to test bic changes to be resolved more changes to be made?
Diffstat (limited to 'library/backend') (more/less context) (show whitespace changes)
-rw-r--r--library/backend/categories.cpp319
-rw-r--r--library/backend/contact.cpp526
-rw-r--r--library/backend/contact.h102
-rw-r--r--library/backend/event.cpp501
-rw-r--r--library/backend/event.h173
-rw-r--r--library/backend/palmtoprecord.cpp42
-rw-r--r--library/backend/palmtoprecord.h33
-rw-r--r--library/backend/palmtopuidgen.h26
-rw-r--r--library/backend/qfiledirect_p.h20
-rw-r--r--library/backend/qpcglobal.h9
-rw-r--r--library/backend/recordfields.h24
-rw-r--r--library/backend/stringutil.cpp415
-rw-r--r--library/backend/stringutil.h57
-rw-r--r--library/backend/task.cpp167
-rw-r--r--library/backend/task.h21
-rw-r--r--library/backend/timeconversion.cpp237
-rw-r--r--library/backend/timeconversion.h45
-rw-r--r--library/backend/vcc.y103
-rw-r--r--library/backend/vcc_yacc.cpp167
-rw-r--r--library/backend/vobject.cpp104
-rw-r--r--library/backend/vobject_p.h4
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,14 +1,13 @@
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**
@@ -20,3 +19,4 @@
20**********************************************************************/ 19**********************************************************************/
21#include "categories.h" 20#include <qtopia/categories.h>
21#include <qtopia/stringutil.h>
22#include <qfile.h> 22#include <qfile.h>
@@ -24,3 +24,2 @@
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include "stringutil.h"
26 25
@@ -40,2 +39,20 @@ UidGen CategoryGroup::sUidGen( UidGen::Qtopia );
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*/
41int CategoryGroup::add( const QString &label ) 58int CategoryGroup::add( const QString &label )
@@ -60,2 +77,4 @@ void CategoryGroup::insert( int uid, const QString &label )
60 77
78/*! \internal
79 */
61bool CategoryGroup::add( int uid, const QString &label ) 80bool CategoryGroup::add( int uid, const QString &label )
@@ -75,2 +94,5 @@ bool CategoryGroup::add( int uid, const QString &label )
75 94
95/*! Returns TRUE if \a label was removed from the group, FALSE if not.
96 \internal
97 */
76bool CategoryGroup::remove( const QString &label ) 98bool CategoryGroup::remove( const QString &label )
@@ -87,2 +109,5 @@ bool CategoryGroup::remove( const QString &label )
87 109
110/*! Returns TRUE if \a uid was removed from the group, FALSE if not.
111 \internal
112 */
88bool CategoryGroup::remove( int uid ) 113bool CategoryGroup::remove( int uid )
@@ -99,2 +124,4 @@ bool CategoryGroup::remove( int uid )
99 124
125/*! \internal
126 */
100bool CategoryGroup::rename( int uid, const QString &newLabel ) 127bool CategoryGroup::rename( int uid, const QString &newLabel )
@@ -115,2 +142,4 @@ bool CategoryGroup::rename( int uid, const QString &newLabel )
115 142
143/*! \internal
144 */
116bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) 145bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel )
@@ -120,2 +149,3 @@ bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel )
120 149
150/*! Returns TRUE if \a uid is stored in this group, FALSE if not. */
121bool CategoryGroup::contains(int uid) const 151bool CategoryGroup::contains(int uid) const
@@ -125,2 +155,3 @@ bool CategoryGroup::contains(int uid) const
125 155
156/*! Returns TRUE if \a label is stored in this group, FALSE if not. */
126bool CategoryGroup::contains(const QString &label) const 157bool CategoryGroup::contains(const QString &label) const
@@ -130,4 +161,4 @@ bool CategoryGroup::contains(const QString &label) const
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 */
@@ -141,3 +172,3 @@ const QString &CategoryGroup::label(int uid) const
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 */
143int CategoryGroup::id(const QString &label) const 174int CategoryGroup::id(const QString &label) const
@@ -150,2 +181,3 @@ int CategoryGroup::id(const QString &label) const
150 181
182/*! Returns a list of all labels stored in this group. */
151QStringList CategoryGroup::labels() const 183QStringList CategoryGroup::labels() const
@@ -161,2 +193,3 @@ QStringList CategoryGroup::labels() const
161 193
194/*! Returns a list of all labels associated with the \a catids */
162QStringList CategoryGroup::labels(const QArray<int> &catids ) const 195QStringList CategoryGroup::labels(const QArray<int> &catids ) const
@@ -179,4 +212,44 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const
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 */
@@ -206,2 +279,7 @@ int Categories::addCategory( const QString &appname,
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
207int Categories::addCategory( const QString &appname, 285int Categories::addCategory( const QString &appname,
@@ -231,2 +309,5 @@ int Categories::addCategory( const QString &appname,
231 309
310/*!
311 \internal
312*/
232int Categories::addGlobalCategory( const QString &catname, int uid ) 313int Categories::addGlobalCategory( const QString &catname, int uid )
@@ -238,2 +319,8 @@ int Categories::addGlobalCategory( const QString &catname, int uid )
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 */
239int Categories::addGlobalCategory( const QString &catname ) 326int Categories::addGlobalCategory( const QString &catname )
@@ -247,5 +334,7 @@ int Categories::addGlobalCategory( const QString &catname )
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 */
@@ -270,2 +359,7 @@ bool Categories::removeCategory( const QString &appname,
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*/
271bool Categories::removeCategory( const QString &appname, int uid ) 365bool Categories::removeCategory( const QString &appname, int uid )
@@ -284,2 +378,6 @@ bool Categories::removeCategory( const QString &appname, int uid )
284 378
379/*!
380 Removes the global category \a catname. Returns TRUE
381 if success, FALSE if not found.
382*/
285bool Categories::removeGlobalCategory( const QString &catname ) 383bool Categories::removeGlobalCategory( const QString &catname )
@@ -294,3 +392,6 @@ bool Categories::removeGlobalCategory( const QString &catname )
294 392
295 393/*!
394 Removes the global category \a uid. Returns TRUE
395 if success, FALSE if not found.
396*/
296bool Categories::removeGlobalCategory( int uid ) 397bool Categories::removeGlobalCategory( int uid )
@@ -304,5 +405,6 @@ bool Categories::removeGlobalCategory( int uid )
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 */
@@ -318,3 +420,3 @@ QStringList Categories::labels( const QString &app,
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 )
@@ -340,2 +442,5 @@ QStringList Categories::labels( const QString &app,
340 442
443/*!
444 Returns the label associated with the id
445*/
341QString Categories::label( const QString &app, int id ) const 446QString Categories::label( const QString &app, int id ) const
@@ -351,6 +456,12 @@ QString Categories::label( const QString &app, int id ) const
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 */
@@ -382,2 +493,7 @@ QString Categories::displaySingle( const QString &app,
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*/
383QArray<int> Categories::ids( const QString &app, const QStringList &labels) const 499QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
@@ -399,2 +515,7 @@ QArray<int> Categories::ids( const QString &app, const QStringList &labels) cons
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*/
400int Categories::id( const QString &app, const QString &cat ) const 521int Categories::id( const QString &app, const QString &cat ) const
@@ -410,4 +531,9 @@ int Categories::id( const QString &app, const QString &cat ) const
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 */
@@ -431,2 +557,8 @@ bool Categories::renameCategory( const QString &appname,
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 */
432bool Categories::renameGlobalCategory( const QString &oldName, 564bool Categories::renameGlobalCategory( const QString &oldName,
@@ -442,2 +574,6 @@ bool Categories::renameGlobalCategory( const QString &oldName,
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*/
443void Categories::setGlobal( const QString &appname, 579void Categories::setGlobal( const QString &appname,
@@ -460,2 +596,5 @@ void Categories::setGlobal( const QString &appname,
460 596
597/*!
598 Returns TRUE if the \a catname is in the global CategoryGroup, FALSE if not.
599*/
461bool Categories::isGlobal( const QString &catname ) const 600bool Categories::isGlobal( const QString &catname ) const
@@ -466,3 +605,5 @@ bool Categories::isGlobal( const QString &catname ) const
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 */
@@ -480,2 +621,6 @@ bool Categories::exists( const QString &catname ) const
480 621
622/*!
623 Returns TRUE if the \a catname is associated with the \a appname
624 CategoryGroup, FALSE if not found.
625 */
481bool Categories::exists( const QString &appname, 626bool Categories::exists( const QString &appname,
@@ -492,3 +637,8 @@ bool Categories::exists( const QString &appname,
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 */
494bool Categories::save( const QString &fname ) const 644bool Categories::save( const QString &fname ) const
@@ -536,2 +686,5 @@ bool Categories::save( const QString &fname ) const
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 ) {
@@ -546,2 +699,8 @@ bool Categories::save( const QString &fname ) const
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 */
547bool Categories::load( const QString &fname ) 706bool Categories::load( const QString &fname )
@@ -621,2 +780,6 @@ bool Categories::load( const QString &fname )
621 780
781/*!
782 Clear the categories in memory. Equivelent to creating an empty Categories
783 object.
784*/
622void Categories::clear() 785void Categories::clear()
@@ -627,2 +790,5 @@ void Categories::clear()
627 790
791/*!
792 Dump the contents to standard out. Used for debugging only.
793*/
628void Categories::dump() const 794void Categories::dump() const
@@ -677 +843,94 @@ void CheckedListView::setChecked( const QStringList &checked )
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 &copyFrom )
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,5 +1,5 @@
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**
@@ -36,4 +36,18 @@
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
37Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); 48Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia );
38 49
50/*!
51 Creates a new, empty contact.
52*/
39Contact::Contact() 53Contact::Contact()
@@ -43,2 +57,7 @@ Contact::Contact()
43 57
58/*!
59 \internal
60 Creates a new contact. The properties of the contact are
61 set from \a fromMap.
62*/
44Contact::Contact( const QMap<int, QString> &fromMap ) : 63Contact::Contact( const QMap<int, QString> &fromMap ) :
@@ -50,2 +69,3 @@ Contact::Contact( const QMap<int, QString> &fromMap ) :
50 QString uidStr = find( Qtopia::AddressUid ); 69 QString uidStr = find( Qtopia::AddressUid );
70
51 if ( uidStr.isEmpty() ) 71 if ( uidStr.isEmpty() )
@@ -54,4 +74,10 @@ Contact::Contact( const QMap<int, QString> &fromMap ) :
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*/
57Contact::~Contact() 83Contact::~Contact()
@@ -60,2 +86,352 @@ Contact::~Contact()
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*/
61QMap<int, QString> Contact::toMap() const 437QMap<int, QString> Contact::toMap() const
@@ -63,3 +439,5 @@ QMap<int, QString> Contact::toMap() const
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;
@@ -68,3 +446,3 @@ QMap<int, QString> Contact::toMap() const
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*/
@@ -233,2 +611,5 @@ QString Contact::toRichText() const
233 611
612/*!
613 \internal
614*/
234void Contact::insert( int key, const QString &v ) 615void Contact::insert( int key, const QString &v )
@@ -242,2 +623,5 @@ void Contact::insert( int key, const QString &v )
242 623
624/*!
625 \internal
626*/
243void Contact::replace( int key, const QString & v ) 627void Contact::replace( int key, const QString & v )
@@ -251,2 +635,5 @@ void Contact::replace( int key, const QString & v )
251 635
636/*!
637 \internal
638*/
252QString Contact::find( int key ) const 639QString Contact::find( int key ) const
@@ -256,2 +643,5 @@ QString Contact::find( int key ) const
256 643
644/*!
645 \internal
646*/
257QString Contact::displayAddress( const QString &street, 647QString Contact::displayAddress( const QString &street,
@@ -278,2 +668,5 @@ QString Contact::displayAddress( const QString &street,
278 668
669/*!
670 \internal
671*/
279QString Contact::displayBusinessAddress() const 672QString Contact::displayBusinessAddress() const
@@ -285,2 +678,5 @@ QString Contact::displayBusinessAddress() const
285 678
679/*!
680 \internal
681*/
286QString Contact::displayHomeAddress() const 682QString Contact::displayHomeAddress() const
@@ -292,2 +688,5 @@ QString Contact::displayHomeAddress() const
292 688
689/*!
690 Returns the full name of the contact
691*/
293QString Contact::fullName() const 692QString Contact::fullName() const
@@ -324,2 +723,5 @@ QString Contact::fullName() const
324 723
724/*!
725 Returns a list of the names of the children of the contact.
726*/
325QStringList Contact::childrenList() const 727QStringList Contact::childrenList() const
@@ -329,7 +731,50 @@ QStringList Contact::childrenList() const
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*/
330QStringList Contact::emailList() const 759QStringList 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*/
335void Contact::setFileAs() 780void Contact::setFileAs()
@@ -355,2 +800,6 @@ void Contact::setFileAs()
355 800
801/*!
802 \internal
803 Appends the contact information to \a buf.
804*/
356void Contact::save( QString &buf ) const 805void Contact::save( QString &buf ) const
@@ -379,2 +828,6 @@ void Contact::save( QString &buf ) const
379 828
829/*!
830 \internal
831 Returns the list of fields belonging to a contact
832*/
380QStringList Contact::fields() 833QStringList Contact::fields()
@@ -437,2 +890,6 @@ QStringList Contact::fields()
437 890
891/*!
892 \internal
893 Returns a translated list of field names for a contact.
894*/
438QStringList Contact::trfields() 895QStringList Contact::trfields()
@@ -495,6 +952,10 @@ QStringList Contact::trfields()
495 952
496void 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*/
957void 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 );
@@ -502,5 +963,8 @@ void Contact::setEmails( const QString &v )
502 963
503void Contact::setChildren( const QString &v ) 964/*!
965 Sets the list of children for the contact to those contained in \a str.
966*/
967void Contact::setChildren( const QString &str )
504{ 968{
505 replace( Qtopia::Children, v ); 969 replace( Qtopia::Children, str );
506} 970}
@@ -508,2 +972,5 @@ void Contact::setChildren( const QString &v )
508// vcard conversion code 972// vcard conversion code
973/*!
974 \internal
975*/
509static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 976static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
@@ -516,2 +983,5 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt
516 983
984/*!
985 \internal
986*/
517static inline VObject *safeAddProp( VObject *o, const char *prop) 987static inline VObject *safeAddProp( VObject *o, const char *prop)
@@ -524,2 +994,5 @@ static inline VObject *safeAddProp( VObject *o, const char *prop)
524 994
995/*!
996 \internal
997*/
525static VObject *createVObject( const Contact &c ) 998static VObject *createVObject( const Contact &c )
@@ -624,2 +1097,5 @@ static VObject *createVObject( const Contact &c )
624 1097
1098/*!
1099 \internal
1100*/
625static Contact parseVObject( VObject *obj ) 1101static Contact parseVObject( VObject *obj )
@@ -628,4 +1104,2 @@ static Contact parseVObject( VObject *obj )
628 1104
629 bool haveDefaultEmail = FALSE;
630
631 VObjectIterator it; 1105 VObjectIterator it;
@@ -769,10 +1243,3 @@ static Contact parseVObject( VObject *obj )
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 }
@@ -853,2 +1320,5 @@ static Contact parseVObject( VObject *obj )
853 1320
1321/*!
1322 Writes the list of \a contacts as a set of VCards to the file \a filename.
1323*/
854void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) 1324void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts)
@@ -870,2 +1340,5 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co
870 1340
1341/*!
1342 writes \a contact as a VCard to the file \a filename.
1343*/
871void Contact::writeVCard( const QString &filename, const Contact &contact) 1344void Contact::writeVCard( const QString &filename, const Contact &contact)
@@ -885,3 +1358,5 @@ void Contact::writeVCard( const QString &filename, const Contact &contact)
885 1358
886 1359/*!
1360 Returns the set of contacts read as VCards from the file \a filename.
1361*/
887QValueList<Contact> Contact::readVCard( const QString &filename ) 1362QValueList<Contact> Contact::readVCard( const QString &filename )
@@ -906,2 +1381,6 @@ QValueList<Contact> Contact::readVCard( const QString &filename )
906 1381
1382/*!
1383 Returns TRUE if the contact matches the regular expression \a regexp.
1384 Otherwise returns FALSE.
1385*/
907bool Contact::match( const QString &regexp ) const 1386bool Contact::match( const QString &regexp ) const
@@ -911,2 +1390,7 @@ bool Contact::match( const QString &regexp ) const
911 1390
1391/*!
1392 \overload
1393 Returns TRUE if the contact matches the regular expression \a regexp.
1394 Otherwise returns FALSE.
1395*/
912bool Contact::match( const QRegExp &r ) const 1396bool Contact::match( const QRegExp &r ) const
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,5 +1,5 @@
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**
@@ -23,4 +23,4 @@
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
@@ -30,3 +30,3 @@
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
@@ -58,5 +58,8 @@ public:
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
@@ -125,3 +128,2 @@ public:
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;
@@ -204,3 +206,12 @@ public:
204private: 206private:
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 );
@@ -221,2 +232,75 @@ private:
221 232
233// these methods are inlined to keep binary compatability with Qtopia 1.5
234inline 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
256inline 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}
283inline void Contact::clearEmails()
284{
285 mMap.remove( Qtopia::DefaultEmail );
286 mMap.remove( Qtopia::Emails );
287}
288inline 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
300inline 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,5 +1,5 @@
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**
@@ -22,5 +22,5 @@
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>
@@ -73,2 +73,251 @@ 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*/
74Event::Event() : Record() 323Event::Event() : Record()
@@ -85,2 +334,5 @@ Event::Event() : Record()
85 334
335/*!
336 \internal
337*/
86Event::Event( const QMap<int, QString> &map ) 338Event::Event( const QMap<int, QString> &map )
@@ -108,2 +360,5 @@ Event::Event( const QMap<int, QString> &map )
108 360
361/*!
362 Destroys an event.
363*/
109Event::~Event() 364Event::~Event()
@@ -112,2 +367,5 @@ Event::~Event()
112 367
368/*!
369 \internal
370*/
113int Event::week( const QDate& date ) 371int Event::week( const QDate& date )
@@ -126,2 +384,5 @@ int Event::week( const QDate& date )
126 384
385/*!
386 \internal
387*/
127int Event::occurrence( const QDate& date ) 388int Event::occurrence( const QDate& date )
@@ -133,2 +394,5 @@ int Event::occurrence( const QDate& date )
133 394
395/*!
396 \internal
397*/
134int Event::dayOfWeek( char day ) 398int Event::dayOfWeek( char day )
@@ -144,2 +408,5 @@ int Event::dayOfWeek( char day )
144 408
409/*!
410 \internal
411*/
145int Event::monthDiff( const QDate& first, const QDate& second ) 412int Event::monthDiff( const QDate& first, const QDate& second )
@@ -150,2 +417,5 @@ int Event::monthDiff( const QDate& first, const QDate& second )
150 417
418/*!
419 \internal
420*/
151QMap<int, QString> Event::toMap() const 421QMap<int, QString> Event::toMap() const
@@ -153,7 +423,14 @@ QMap<int, QString> Event::toMap() const
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() ) ) );
@@ -176,2 +453,5 @@ QMap<int, QString> Event::toMap() const
176 453
454/*!
455 \internal
456*/
177void Event::setRepeat( const RepeatPattern &p ) 457void Event::setRepeat( const RepeatPattern &p )
@@ -181,2 +461,5 @@ void Event::setRepeat( const RepeatPattern &p )
181 461
462/*!
463 Sets the description of the event to \a s.
464*/
182void Event::setDescription( const QString &s ) 465void Event::setDescription( const QString &s )
@@ -186,2 +469,5 @@ void Event::setDescription( const QString &s )
186 469
470/*!
471 Sets the location of the event to \a s.
472*/
187void Event::setLocation( const QString &s ) 473void Event::setLocation( const QString &s )
@@ -196,2 +482,5 @@ void Event::setLocation( const QString &s )
196 482
483/*!
484 \internal
485*/
197void Event::setType( Type t ) 486void Event::setType( Type t )
@@ -201,2 +490,6 @@ void Event::setType( Type t )
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*/
202void Event::setStart( const QDateTime &d ) 495void Event::setStart( const QDateTime &d )
@@ -206,2 +499,5 @@ void Event::setStart( const QDateTime &d )
206 499
500/*!
501 \internal
502*/
207void Event::setStart( time_t time ) 503void Event::setStart( time_t time )
@@ -211,2 +507,6 @@ void Event::setStart( time_t time )
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*/
212void Event::setEnd( const QDateTime &d ) 512void Event::setEnd( const QDateTime &d )
@@ -216,2 +516,5 @@ void Event::setEnd( const QDateTime &d )
216 516
517/*!
518 \internal
519*/
217void Event::setEnd( time_t time ) 520void Event::setEnd( time_t time )
@@ -221,2 +524,5 @@ void Event::setEnd( time_t time )
221 524
525/*!
526 \internal
527*/
222void Event::setTimeZone( const QString &z ) 528void Event::setTimeZone( const QString &z )
@@ -226,2 +532,5 @@ void Event::setTimeZone( const QString &z )
226 532
533/*!
534 \internal
535*/
227void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) 536void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
@@ -233,2 +542,5 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
233 542
543/*!
544 \internal
545*/
234void Event::setRepeat( bool b, const RepeatPattern &p ) 546void Event::setRepeat( bool b, const RepeatPattern &p )
@@ -239,2 +551,5 @@ void Event::setRepeat( bool b, const RepeatPattern &p )
239 551
552/*!
553 Sets the notes for the event to \a n.
554*/
240void Event::setNotes( const QString &n ) 555void Event::setNotes( const QString &n )
@@ -244,2 +559,5 @@ void Event::setNotes( const QString &n )
244 559
560/*!
561 Returns the description of the event.
562*/
245const QString &Event::description() const 563const QString &Event::description() const
@@ -249,2 +567,5 @@ const QString &Event::description() const
249 567
568/*!
569 Returns the location of the event.
570*/
250const QString &Event::location() const 571const QString &Event::location() const
@@ -259,2 +580,5 @@ const QString &Event::location() const
259 580
581/*!
582 \internal
583*/
260Event::Type Event::type() const 584Event::Type Event::type() const
@@ -264,2 +588,5 @@ Event::Type Event::type() const
264 588
589/*!
590 \internal
591*/
265QDateTime Event::start( bool actual ) const 592QDateTime Event::start( bool actual ) const
@@ -276,2 +603,5 @@ QDateTime Event::start( bool actual ) const
276 603
604/*!
605 \internal
606*/
277QDateTime Event::end( bool actual ) const 607QDateTime Event::end( bool actual ) const
@@ -288,2 +618,5 @@ QDateTime Event::end( bool actual ) const
288 618
619/*!
620 \internal
621*/
289const QString &Event::timeZone() const 622const QString &Event::timeZone() const
@@ -293,2 +626,5 @@ const QString &Event::timeZone() const
293 626
627/*!
628 \internal
629*/
294bool Event::hasAlarm() const 630bool Event::hasAlarm() const
@@ -298,2 +634,5 @@ bool Event::hasAlarm() const
298 634
635/*!
636 \internal
637*/
299int Event::alarmTime() const 638int Event::alarmTime() const
@@ -303,2 +642,5 @@ int Event::alarmTime() const
303 642
643/*!
644 Returns the sound type for the alarm of this event.
645*/
304Event::SoundTypeChoice Event::alarmSound() const 646Event::SoundTypeChoice Event::alarmSound() const
@@ -308,2 +650,5 @@ Event::SoundTypeChoice Event::alarmSound() const
308 650
651/*!
652 \internal
653*/
309bool Event::hasRepeat() const 654bool Event::hasRepeat() const
@@ -313,2 +658,5 @@ bool Event::hasRepeat() const
313 658
659/*!
660 \internal
661*/
314const Event::RepeatPattern &Event::repeatPattern() const 662const Event::RepeatPattern &Event::repeatPattern() const
@@ -318,2 +666,5 @@ const Event::RepeatPattern &Event::repeatPattern() const
318 666
667/*!
668 \internal
669*/
319Event::RepeatPattern &Event::repeatPattern() 670Event::RepeatPattern &Event::repeatPattern()
@@ -323,2 +674,5 @@ Event::RepeatPattern &Event::repeatPattern()
323 674
675/*!
676 Returns the notes for the event.
677*/
324const QString &Event::notes() const 678const QString &Event::notes() const
@@ -328,4 +682,9 @@ const QString &Event::notes() const
328 682
683/*!
684 \internal
685*/
329bool Event::operator==( const Event &e ) const 686bool 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 &&
@@ -345,2 +704,6 @@ bool Event::operator==( const Event &e ) const
345 704
705/*!
706 \internal
707 Appends the contact information to \a buf.
708*/
346void Event::save( QString& buf ) 709void Event::save( QString& buf )
@@ -380,2 +743,5 @@ void Event::save( QString& buf )
380 743
744/*!
745 \internal
746*/
381bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const 747bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
@@ -392,2 +758,24 @@ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
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
@@ -402,3 +790,5 @@ public:
402 790
403 791/*!
792 \internal
793*/
404EffectiveEvent::EffectiveEvent() 794EffectiveEvent::EffectiveEvent()
@@ -410,2 +800,5 @@ EffectiveEvent::EffectiveEvent()
410 800
801/*!
802 \internal
803*/
411EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) 804EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos )
@@ -426,2 +819,5 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos
426 819
820/*!
821 \internal
822*/
427EffectiveEvent::~EffectiveEvent() 823EffectiveEvent::~EffectiveEvent()
@@ -431,2 +827,5 @@ EffectiveEvent::~EffectiveEvent()
431 827
828/*!
829 \internal
830*/
432EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) 831EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
@@ -463,2 +862,5 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
463 862
863/*!
864 Returns the description of the event for this effective event.
865*/
464const QString &EffectiveEvent::description( ) const 866const QString &EffectiveEvent::description( ) const
@@ -468,2 +870,5 @@ const QString &EffectiveEvent::description( ) const
468 870
871/*!
872\internal
873*/
469const QString &EffectiveEvent::location( ) const 874const QString &EffectiveEvent::location( ) const
@@ -473,2 +878,5 @@ const QString &EffectiveEvent::location( ) const
473 878
879/*!
880\internal
881*/
474const QString &EffectiveEvent::notes() const 882const QString &EffectiveEvent::notes() const
@@ -478,2 +886,5 @@ const QString &EffectiveEvent::notes() const
478 886
887/*!
888 Returns the event associated with this effective event.
889*/
479const Event &EffectiveEvent::event() const 890const Event &EffectiveEvent::event() const
@@ -483,2 +894,5 @@ const Event &EffectiveEvent::event() const
483 894
895/*!
896 \internal
897*/
484const QTime &EffectiveEvent::end() const 898const QTime &EffectiveEvent::end() const
@@ -488,2 +902,5 @@ const QTime &EffectiveEvent::end() const
488 902
903/*!
904 \internal
905*/
489const QTime &EffectiveEvent::start() const 906const QTime &EffectiveEvent::start() const
@@ -493,2 +910,5 @@ const QTime &EffectiveEvent::start() const
493 910
911/*!
912 Returns the date the effective event occurs on.
913*/
494const QDate &EffectiveEvent::date() const 914const QDate &EffectiveEvent::date() const
@@ -498,2 +918,5 @@ const QDate &EffectiveEvent::date() const
498 918
919/*!
920 \internal
921*/
499int EffectiveEvent::length() const 922int EffectiveEvent::length() const
@@ -504,2 +927,5 @@ int EffectiveEvent::length() const
504 927
928/*!
929 \internal
930*/
505void EffectiveEvent::setDate( const QDate &dt ) 931void EffectiveEvent::setDate( const QDate &dt )
@@ -509,2 +935,5 @@ void EffectiveEvent::setDate( const QDate &dt )
509 935
936/*!
937 \internal
938*/
510void EffectiveEvent::setStart( const QTime &start ) 939void EffectiveEvent::setStart( const QTime &start )
@@ -514,2 +943,5 @@ void EffectiveEvent::setStart( const QTime &start )
514 943
944/*!
945 \internal
946*/
515void EffectiveEvent::setEnd( const QTime &end ) 947void EffectiveEvent::setEnd( const QTime &end )
@@ -519,2 +951,5 @@ void EffectiveEvent::setEnd( const QTime &end )
519 951
952/*!
953 \internal
954*/
520void EffectiveEvent::setEvent( Event e ) 955void EffectiveEvent::setEvent( Event e )
@@ -524,2 +959,5 @@ void EffectiveEvent::setEvent( Event e )
524 959
960/*!
961 \internal
962*/
525bool EffectiveEvent::operator<( const EffectiveEvent &e ) const 963bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
@@ -534,2 +972,5 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
534 972
973/*!
974 \internal
975*/
535bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const 976bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
@@ -539,2 +980,5 @@ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
539 980
981/*!
982 \internal
983*/
540bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 984bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
@@ -547,2 +991,5 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
547 991
992/*!
993 \internal
994*/
548bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const 995bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
@@ -552,2 +999,5 @@ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
552 999
1000/*!
1001 \internal
1002*/
553bool EffectiveEvent::operator>( const EffectiveEvent &e ) const 1003bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
@@ -557,2 +1007,5 @@ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
557 1007
1008/*!
1009 \internal
1010*/
558bool EffectiveEvent::operator>=(const EffectiveEvent &e) const 1011bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
@@ -562,2 +1015,5 @@ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
562 1015
1016/*!
1017 \internal
1018*/
563void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) 1019void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
@@ -575,2 +1031,5 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
575 1031
1032/*!
1033 \internal
1034*/
576QDate EffectiveEvent::startDate() const 1035QDate EffectiveEvent::startDate() const
@@ -585,2 +1044,5 @@ QDate EffectiveEvent::startDate() const
585 1044
1045/*!
1046 \internal
1047*/
586QDate EffectiveEvent::endDate() const 1048QDate EffectiveEvent::endDate() const
@@ -595,2 +1057,5 @@ QDate EffectiveEvent::endDate() const
595 1057
1058/*!
1059 \internal
1060*/
596int EffectiveEvent::size() const 1061int EffectiveEvent::size() const
@@ -742,11 +1207,19 @@ static Event parseVObject( VObject *obj )
742 1207
743 1208/*!
1209 Writes the list of \a events as a set of VCards to the file \a filename.
1210*/
744void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) 1211void 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;
@@ -758,2 +1231,3 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev
758 1231
1232
759 cleanStrTbl(); 1233 cleanStrTbl();
@@ -761,10 +1235,19 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev
761 1235
1236/*!
1237 Writes \a event as a VCard to the file \a filename.
1238*/
762void Event::writeVCalendar( const QString &filename, const Event &event) 1239void 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 );
@@ -776,3 +1259,5 @@ void Event::writeVCalendar( const QString &filename, const Event &event)
776 1259
777 1260/*!
1261 Returns the set of events read as VCards from the file \a filename.
1262*/
778QValueList<Event> Event::readVCalendar( const QString &filename ) 1263QValueList<Event> Event::readVCalendar( const QString &filename )
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,5 +1,5 @@
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**
@@ -25,2 +25,3 @@
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qcolor.h>
26 27
@@ -29,3 +30,3 @@
29#endif 30#endif
30#include <qpe/palmtoprecord.h> 31#include <qtopia/private/palmtoprecord.h>
31 32
@@ -33,2 +34,7 @@
33 34
35static const QColor colorNormal = QColor(255, 0 , 0 );
36static const QColor colorRepeat = QColor(0 , 0 , 255);
37static const QColor colorNormalLight = QColor(255, 220, 220);
38static const QColor colorRepeatLight = QColor(200, 200, 255);
39
34class EventPrivate; 40class EventPrivate;
@@ -39,4 +45,7 @@ public:
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
@@ -72,2 +81,3 @@ public:
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(); };
@@ -85,18 +95,45 @@ public:
85 95
86 void setType( Type t ); 96 void setNotes( const QString &n );
87 Type type() const; 97 const QString &notes() 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 );
@@ -106,4 +143,2 @@ public:
106 RepeatPattern &repeatPattern(); 143 RepeatPattern &repeatPattern();
107 void setNotes( const QString &n );
108 const QString &notes() const;
109 bool doRepeat() const { return pattern.type != NoRepeat; } 144 bool doRepeat() const { return pattern.type != NoRepeat; }
@@ -113,2 +148,6 @@ public:
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
@@ -125,3 +164,2 @@ public:
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
@@ -213,2 +251,105 @@ private:
213 251
252inline void Event::setAlarm( int minutes, SoundTypeChoice s )
253{
254 setAlarm(TRUE, minutes, s);
255}
256
257inline void Event::clearAlarm()
258{
259 setAlarm(FALSE, 0, Silent);
260}
261
262inline int Event::alarmDelay() const
263{
264 return alarmTime();
265}
266
267inline void Event::setAllDay(bool enable)
268{
269 if (enable)
270 setType(AllDay);
271 else
272 setType(Normal);
273};
274
275inline bool Event::isAllDay() const
276{
277 return type() == AllDay;
278}
279
280inline Event::RepeatType Event::repeatType() const
281{
282 return repeatPattern().type;
283}
284
285inline int Event::frequency() const
286{
287 return repeatPattern().frequency;
288}
289
290inline int Event::weekOffset() const
291{
292 if (start().date().day() == 1)
293 return 1;
294 return (start().date().day() - 1) / 7 + 1;
295}
296
297inline QDate Event::repeatTill() const
298{
299 return repeatPattern().endDate();
300}
301
302inline bool Event::repeatForever() const
303{
304 return !repeatPattern().hasEndDate;
305}
306
307inline void Event::setRepeatType(RepeatType t)
308{
309 pattern.type = t;
310}
311
312inline void Event::setFrequency(int f)
313{
314 pattern.frequency = f;
315}
316
317inline void Event::setRepeatTill(const QDate &d)
318{
319 pattern.setEndDate(d);
320 pattern.hasEndDate = TRUE;
321}
322
323inline 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
332inline 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
339inline void Event::setRepeatOnWeekDay(int day, bool enable)
340{
341 if ( repeatOnWeekDay( day ) != enable )
342 pattern.days ^= 1 << (day - 1);
343}
344
345inline QDateTime Event::start( ) const
346{
347 return start(FALSE);
348}
349
350inline QDateTime Event::end( ) const
351{
352 return end(FALSE);
353}
354
214#ifdef PALMTOPCENTER 355#ifdef PALMTOPCENTER
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,14 +1,13 @@
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**
@@ -20,8 +19,20 @@
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
25namespace Qtopia { 34namespace Qtopia {
26 35
36
37
27Record &Record::operator=( const Record &c ) 38Record &Record::operator=( const Record &c )
@@ -43,4 +54,7 @@ void Record::setCategories( int single )
43// convenience methods provided for loading and saving to xml 54// convenience methods provided for loading and saving to xml
44QString Record::idsToString( const QArray<int> &cats ) 55QString Record::idsToString( const QArray<int> &catsUnsorted )
45{ 56{
57 QArray<int> cats = catsUnsorted;
58 cats.sort();
59
46 QString str; 60 QString str;
@@ -86,3 +100,3 @@ 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))
@@ -92,3 +106,3 @@ void Record::setCustomField( const QString &key, const QString &value)
92 106
93 qWarning(QString("custom size %1").arg(customMap.count())); 107// qWarning(QString("custom size %1").arg(customMap.count()));
94} 108}
@@ -109,3 +123,3 @@ QString Record::customToXml() const
109 cit != customMap.end(); ++cit) { 123 cit != customMap.end(); ++cit) {
110 qWarning(".ITEM."); 124 // qWarning(".ITEM.");
111 buf += cit.key(); 125 buf += cit.key();
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,14 +1,13 @@
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**
@@ -20,6 +19,4 @@
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>
@@ -32,3 +29,3 @@
32// MOC_SKIP_BEGIN 29// MOC_SKIP_BEGIN
33template class QPC_EXPORT QMap<QString, QString>; 30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>;
34// MOC_SKIP_END 31// MOC_SKIP_END
@@ -51,3 +48,3 @@ public:
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 );
@@ -55,2 +52,9 @@ public:
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; };
@@ -79,5 +83,3 @@ protected:
79 virtual UidGen &uidGen() = 0; 83 virtual UidGen &uidGen() = 0;
80
81 virtual QString customToXml() const; 84 virtual QString customToXml() const;
82
83private: 85private:
@@ -85,5 +87,3 @@ private:
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;
@@ -94 +94,2 @@ private:
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,18 +1,15 @@
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**
@@ -23,2 +20,5 @@
23 20
21#ifndef QTPALMTOP_UIDGEN_H
22#define QTPALMTOP_UIDGEN_H
23
24#include <time.h> 24#include <time.h>
@@ -29,3 +29,3 @@
29// MOC_SKIP_BEGIN 29// MOC_SKIP_BEGIN
30template class QPC_EXPORT QMap< int, bool >; 30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap< int, bool >;
31// MOC_SKIP_END 31// MOC_SKIP_END
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,3 +1,3 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
@@ -5,12 +5,11 @@
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**
@@ -24,3 +23,3 @@
24#include <qfile.h> 23#include <qfile.h>
25#include <qpe/qpcglobal.h> 24#include <qtopia/private/qpcglobal.h>
26 25
@@ -36,2 +35 @@ public:
36#endif #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,5 +1,5 @@
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**
@@ -24,4 +24,5 @@
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)
@@ -34,2 +35,3 @@
34# define QPC_EXPORT __declspec(dllexport) 35# define QPC_EXPORT __declspec(dllexport)
36# define QPC_TEMPLATEEXTERN
35# define QPC_TEMPLATEDLL 37# define QPC_TEMPLATEDLL
@@ -38,2 +40,3 @@
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
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,16 +1,15 @@
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**
@@ -90,5 +89,6 @@ namespace Qtopia
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
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
26namespace 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
36static const char collationHack[] = {
370x00, //C-@
380x01, //C-A
390x02, //C-B
400x03, //C-C
410x04, //C-D
420x05, //C-E
430x06, //C-F
440x07, //C-G
450x08, //C-H
460x09, //C-I
470x0a, //C-J
480x0b, //C-K
490x0c, //C-L
500x0d, //C-M
510x0e, //C-N
520x0f, //C-O
530x10, //C-P
540x11, //C-Q
550x12, //C-R
560x13, //C-S
570x14, //C-T
580x15, //C-U
590x16, //C-V
600x17, //C-W
610x18, //C-X
620x19, //C-Y
630x1a, //C-Z
640x1b, //C-[
650x1c, //C-\
660x1d, //C-]
670x1e, //C-^
680x1f, //C-_
69' ', //
70'!', //!
71'"', //"
72'#', //#
73'$', //$
74'%', //%
75'&', //&
76'\'', //'
77'(', //(
78')', //)
79'*', //*
80'+', //+
81',', //,
82'-', //-
83'.', //.
84'/', ///
850x80, //0
860x81, //1
870x82, //2
880x83, //3
890x84, //4
900x85, //5
910x86, //6
920x87, //7
930x88, //8
940x89, //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'', //
1650x80, //C-M-@
1660x81, //C-M-A
1670x82, //C-M-B
1680x83, //C-M-C
1690x84, //C-M-D
1700x85, //C-M-E
1710x86, //C-M-F
1720x87, //C-M-G
1730x88, //C-M-H
1740x89, //C-M-I
1750x8a, //C-M-J
1760x8b, //C-M-K
1770x8c, //C-M-L
1780x8d, //C-M-M
1790x8e, //C-M-N
1800x8f, //C-M-O
1810x90, //C-M-P
1820x91, //C-M-Q
1830x92, //C-M-R
1840x93, //C-M-S
1850x94, //C-M-T
1860x95, //C-M-U
1870x96, //C-M-V
1880x97, //C-M-W
1890x98, //C-M-X
1900x99, //C-M-Y
1910x9a, //C-M-Z
1920x9b, //C-M-[
1930x9c, //C-M-\
1940x9d, //C-M-]
1950x9e, //C-M-^
1960x9f, //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
299static 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
309QString buildSortKey( const QString & s )
310{
311 QString res = s;
312 hackString( res );
313 return res;
314}
315
316QString buildSortKey( const QString & s1, const QString & s2 )
317{
318 QString res = s1 + QChar( '\0' ) + s2;
319 hackString( res );
320 return res;
321}
322
323QString 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
331static inline QChar coll( QChar u )
332{
333 return u.row() ? u : QChar(collationHack[ u.cell() ]);
334}
335
336
337int 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
356QString 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
368QString 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, "&amp;" );
377 else if ( ch == '<' )
378 tmp.replace( pos, 1, "&lt;" );
379 else if ( ch == '>' )
380 tmp.replace( pos, 1, "&gt;" );
381 else if ( ch == '\"' )
382 tmp.replace( pos, 1, "&quot;" );
383 }
384 return tmp;
385}
386
387QString plainString( const char* escaped, unsigned int length )
388{
389 return plainString( QString::fromUtf8( escaped, length ) );
390}
391
392QString plainString( const QCString& string )
393{
394 // We first have to pass it through a ::fromUtf8()
395 return plainString( string.data(), string.length() );
396}
397
398QString 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( "&amp;", pos ) == pos )
404 tmp.replace( pos, 5, "&" );
405 else if ( tmp.find( "&lt;", pos ) == pos )
406 tmp.replace( pos, 4, "<" );
407 else if( tmp.find( "&gt;", pos ) == pos )
408 tmp.replace( pos, 4, ">" );
409 else if ( tmp.find( "&quot;", 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
29namespace Qtopia
30{
31
32// Simplifies white space within each line but keeps the new line characters
33QString QPC_EXPORT simplifyMultiLineSpace( const QString &multiLine );
34
35// Creates a QString which doesn't contain any "dangerous"
36// characters (i.e. <, >, &, ")
37QString 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
42QString QPC_EXPORT plainString( const char* escaped, unsigned int length );
43QString QPC_EXPORT plainString( const QCString& string );
44
45QString QPC_EXPORT plainString( const QString& string );
46
47
48// collation functions
49int compare( const QString & s1, const QString & s2 );
50QString buildSortKey( const QString & s );
51QString buildSortKey( const QString & s1, const QString & s2 );
52QString 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,5 +1,5 @@
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**
@@ -20,10 +20,12 @@
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>
@@ -33,2 +35,16 @@ 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*/
34Task::Task() : Record(), mDue( FALSE ), 50Task::Task() : Record(), mDue( FALSE ),
@@ -39,2 +55,85 @@ mCompleted( FALSE ), mPriority( 3 ), mDesc()
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
40Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), 139Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ),
@@ -53,3 +152,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
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 }
@@ -57,2 +158,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
57 158
159/*!
160 Destroys a task.
161*/
58Task::~Task() 162Task::~Task()
@@ -61,2 +165,6 @@ Task::~Task()
61 165
166/*!
167 \internal
168 Returns the task as a map of field ids to property values.
169*/
62QMap<int, QString> Task::toMap() const 170QMap<int, QString> Task::toMap() const
@@ -66,5 +174,8 @@ QMap<int, QString> Task::toMap() const
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() ) );
@@ -77,2 +188,6 @@ QMap<int, QString> Task::toMap() const
77 188
189/*!
190 \internal
191 Appends the task information to \a buf.
192*/
78void Task::save( QString& buf ) const 193void Task::save( QString& buf ) const
@@ -119,3 +234,7 @@ void Task::save( QString& buf ) const
119 234
120bool Task::match ( const QRegExp &r ) const 235/*!
236 Returns TRUE if the task matches the regular expressions \a regexp.
237 Otherwise returns FALSE.
238*/
239bool Task::match ( const QRegExp &regexp ) const
121{ 240{
@@ -124,7 +243,7 @@ bool Task::match ( const QRegExp &r ) const
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;
@@ -133,2 +252,5 @@ bool Task::match ( const QRegExp &r ) const
133 252
253/*!
254 \internal
255*/
134static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 256static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
@@ -141,2 +263,5 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt
141 263
264/*!
265 \internal
266*/
142static inline VObject *safeAddProp( VObject *o, const char *prop) 267static inline VObject *safeAddProp( VObject *o, const char *prop)
@@ -150,2 +275,5 @@ static inline VObject *safeAddProp( VObject *o, const char *prop)
150 275
276/*!
277 \internal
278*/
151static VObject *createVObject( const Task &t ) 279static VObject *createVObject( const Task &t )
@@ -166,3 +294,5 @@ static VObject *createVObject( const Task &t )
166 294
167 295/*!
296 \internal
297*/
168static Task parseVObject( VObject *obj ) 298static Task parseVObject( VObject *obj )
@@ -209,3 +339,5 @@ static Task parseVObject( VObject *obj )
209 339
210 340/*!
341 Writes the list of \a tasks as a set of VCards to the file \a filename.
342*/
211void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) 343void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks)
@@ -228,2 +360,5 @@ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &task
228 360
361/*!
362 Writes \a task as a VCard to the file \a filename.
363*/
229void Task::writeVCalendar( const QString &filename, const Task &task) 364void Task::writeVCalendar( const QString &filename, const Task &task)
@@ -243,3 +378,5 @@ void Task::writeVCalendar( const QString &filename, const Task &task)
243 378
244 379/*!
380 Returns the set of tasks read as VCards from the file \a filename.
381*/
245QValueList<Task> Task::readVCalendar( const QString &filename ) 382QValueList<Task> Task::readVCalendar( const QString &filename )
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,5 +1,5 @@
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**
@@ -22,4 +22,4 @@
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
@@ -42,2 +42,4 @@ public:
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; }
@@ -53,6 +55,12 @@ public:
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
@@ -80,2 +88,5 @@ private:
80 88
89// MUST be inline. (forwards compatability).
90inline void Task::setDueDate( const QDate &date) { setDueDate(date, date.isValid()); }
91inline 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
26QString 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
35QDate 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
51time_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
83QDateTime 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
100int TimeConversion::secsTo( const QDateTime &from, const QDateTime &to )
101{
102 return toUTC( to ) - toUTC( from );
103}
104
105QCString 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
115QCString 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
127QDateTime 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
30class QPC_EXPORT TimeConversion
31{
32public:
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
@@ -519,3 +519,3 @@ static int lexWithinMode(enum LexMode mode) {
519 519
520static char lexGetc_() 520static int lexGetc_()
521 { 521 {
@@ -933,56 +933,65 @@ 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
984EndString:
985 lexAppendc(0); 994 lexAppendc(0);
986 return lexStr(); 995 return c==EOF?0:lexStr();
987 } /* LexQuotedPrintable */ 996}
988 997
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,3 +1,4 @@
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";*/
3static char yyrcsid[] = "$Id$";
3#endif 4#endif
@@ -9,4 +10,28 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
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
@@ -75,2 +100,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
75 100
101#if 0
76#define yyparse mime_parse 102#define yyparse mime_parse
@@ -107,2 +133,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
107#define YYPREFIX "mime_" 133#define YYPREFIX "mime_"
134#endif
108 135
@@ -130,9 +157,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
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
@@ -142,4 +167,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
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 */
@@ -190,5 +214,7 @@ static void enterAttr(const char *s1, const char *s2);
190static void enterValues(const char *value); 214static void enterValues(const char *value);
215#define mime_error yyerror
216void mime_error(char *s);
191void mime_error_(char *s); 217void mime_error_(char *s);
192 218
193#line 185 "vcc.y" 219#line 189 "backend/vcc.y"
194typedef union { 220typedef union {
@@ -197,3 +223,3 @@ typedef union {
197 } YYSTYPE; 223 } YYSTYPE;
198#line 196 "y.tab.c" 224#line 225 "y.tab.c"
199#define EQ 257 225#define EQ 257
@@ -217,3 +243,3 @@ typedef union {
217#define YYERRCODE 256 243#define YYERRCODE 256
218short yylhs[] = { -1, 244short vcclhs[] = { -1,
219 0, 6, 6, 5, 5, 8, 3, 9, 3, 7, 245 0, 6, 6, 5, 5, 8, 3, 9, 3, 7,
@@ -224,3 +250,3 @@ short yylhs[] = { -1,
224}; 250};
225short yylen[] = { 2, 251short vcclen[] = { 2,
226 1, 2, 1, 1, 1, 0, 4, 0, 3, 2, 252 1, 2, 1, 1, 1, 0, 4, 0, 3, 2,
@@ -231,3 +257,3 @@ short yylen[] = { 2,
231}; 257};
232short yydefred[] = { 0, 258short vccdefred[] = { 0,
233 0, 0, 0, 4, 5, 3, 0, 0, 0, 0, 259 0, 0, 0, 4, 5, 3, 0, 0, 0, 0,
@@ -239,3 +265,3 @@ short yydefred[] = { 0,
239}; 265};
240short yydgoto[] = { 3, 266short vccdgoto[] = { 3,
241 15, 50, 4, 5, 6, 7, 22, 8, 9, 17, 267 15, 50, 4, 5, 6, 7, 22, 8, 9, 17,
@@ -244,3 +270,3 @@ short yydgoto[] = { 3,
244}; 270};
245short yysindex[] = { -262, 271short vccsindex[] = { -262,
246 0, 0, 0, 0, 0, 0, -262, -252, -219, -249, 272 0, 0, 0, 0, 0, 0, -262, -252, -219, -249,
@@ -252,3 +278,3 @@ short yysindex[] = { -262,
252}; 278};
253short yyrindex[] = { 0, 279short vccrindex[] = { 0,
254 -222, -238, 0, 0, 0, 0, 65, 0, 0, 0, 280 -222, -238, 0, 0, 0, 0, 65, 0, 0, 0,
@@ -260,3 +286,3 @@ short yyrindex[] = { 0,
260}; 286};
261short yygindex[] = { 0, 287short vccgindex[] = { 0,
262 3, 0, 0, 0, 61, 0, -7, 0, 0, -16, 288 3, 0, 0, 0, 61, 0, -7, 0, 0, -16,
@@ -266,3 +292,3 @@ short yygindex[] = { 0,
266#define YYTABLESIZE 71 292#define YYTABLESIZE 71
267short yytable[] = { 30, 293short vcctable[] = { 30,
268 16, 13, 1, 13, 2, 30, 13, 37, 37, 28, 294 16, 13, 1, 13, 2, 30, 13, 37, 37, 28,
@@ -276,3 +302,3 @@ short yytable[] = { 30,
276}; 302};
277short yycheck[] = { 16, 303short vcccheck[] = { 16,
278 8, 256, 265, 256, 267, 22, 256, 268, 269, 260, 304 8, 256, 265, 256, 267, 22, 256, 268, 269, 260,
@@ -292,3 +318,3 @@ short yycheck[] = { 16,
292#if YYDEBUG 318#if YYDEBUG
293char *yyname[] = { 319char *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,
@@ -303,3 +329,3 @@ char *yyname[] = {
303}; 329};
304char *yyrule[] = { 330char *vccrule[] = {
305"$accept : mime", 331"$accept : mime",
@@ -374,3 +400,3 @@ YYSTYPE yyvs[YYSTACKSIZE];
374#define yystacksize YYSTACKSIZE 400#define yystacksize YYSTACKSIZE
375#line 378 "vcc.y" 401#line 382 "backend/vcc.y"
376 402
@@ -513,3 +539,3 @@ static int lexWithinMode(enum LexMode mode) {
513 539
514static char lexGetc_() 540static int lexGetc_()
515 { 541 {
@@ -927,3 +953,3 @@ static char* lexGetQuotedPrintable()
927 { 953 {
928 char cur; 954 int cur;
929 955
@@ -969,3 +995,3 @@ static char* lexGetQuotedPrintable()
969 } 995 }
970 case (char)EOF: 996 case (int)EOF:
971 break; 997 break;
@@ -975,3 +1001,3 @@ static char* lexGetQuotedPrintable()
975 } /* switch */ 1001 } /* switch */
976 } while (cur != (char)EOF); 1002 } while (cur != (int)EOF);
977 1003
@@ -1152,9 +1178,14 @@ 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 }
@@ -1188,3 +1219,3 @@ void mime_error_(char *s)
1188 1219
1189#line 1192 "y.tab.c" 1220#line 1221 "y.tab.c"
1190#define YYABORT goto yyabort 1221#define YYABORT goto yyabort
@@ -1194,3 +1225,7 @@ void mime_error_(char *s)
1194int 1225int
1226#if defined(__STDC__)
1227yyparse(void)
1228#else
1195yyparse() 1229yyparse()
1230#endif
1196{ 1231{
@@ -1218,3 +1253,3 @@ yyparse()
1218yyloop: 1253yyloop:
1219 if (yyn = yydefred[yystate]) goto yyreduce; 1254 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
1220 if (yychar < 0) 1255 if (yychar < 0)
@@ -1258,6 +1293,2 @@ yyloop:
1258 if (yyerrflag) goto yyinrecovery; 1293 if (yyerrflag) goto yyinrecovery;
1259#ifdef lint
1260 goto yynewerror;
1261#endif
1262yynewerror:
1263 yyerror("syntax error"); 1294 yyerror("syntax error");
@@ -1330,3 +1361,3 @@ yyreduce:
1330case 2: 1361case 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; }
@@ -1334,3 +1365,3 @@ break;
1334case 3: 1365case 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; }
@@ -1338,3 +1369,3 @@ break;
1338case 6: 1369case 6:
1339#line 228 "vcc.y" 1370#line 232 "backend/vcc.y"
1340{ 1371{
@@ -1345,3 +1376,3 @@ break;
1345case 7: 1376case 7:
1346#line 233 "vcc.y" 1377#line 237 "backend/vcc.y"
1347{ 1378{
@@ -1352,3 +1383,3 @@ break;
1352case 8: 1383case 8:
1353#line 238 "vcc.y" 1384#line 242 "backend/vcc.y"
1354{ 1385{
@@ -1359,3 +1390,3 @@ break;
1359case 9: 1390case 9:
1360#line 243 "vcc.y" 1391#line 247 "backend/vcc.y"
1361{ 1392{
@@ -1366,3 +1397,3 @@ break;
1366case 12: 1397case 12:
1367#line 254 "vcc.y" 1398#line 258 "backend/vcc.y"
1368{ 1399{
@@ -1372,3 +1403,3 @@ break;
1372case 13: 1403case 13:
1373#line 258 "vcc.y" 1404#line 262 "backend/vcc.y"
1374{ 1405{
@@ -1380,3 +1411,3 @@ break;
1380case 15: 1411case 15:
1381#line 267 "vcc.y" 1412#line 271 "backend/vcc.y"
1382{ 1413{
@@ -1386,3 +1417,3 @@ break;
1386case 17: 1417case 17:
1387#line 272 "vcc.y" 1418#line 276 "backend/vcc.y"
1388{ 1419{
@@ -1392,3 +1423,3 @@ break;
1392case 21: 1423case 21:
1393#line 285 "vcc.y" 1424#line 289 "backend/vcc.y"
1394{ 1425{
@@ -1398,3 +1429,3 @@ break;
1398case 22: 1429case 22:
1399#line 289 "vcc.y" 1430#line 293 "backend/vcc.y"
1400{ 1431{
@@ -1405,3 +1436,3 @@ break;
1405case 24: 1436case 24:
1406#line 298 "vcc.y" 1437#line 302 "backend/vcc.y"
1407{ enterValues(yyvsp[-1].str); } 1438{ enterValues(yyvsp[-1].str); }
@@ -1409,3 +1440,3 @@ break;
1409case 26: 1440case 26:
1410#line 300 "vcc.y" 1441#line 304 "backend/vcc.y"
1411{ enterValues(yyvsp[0].str); } 1442{ enterValues(yyvsp[0].str); }
@@ -1413,3 +1444,3 @@ break;
1413case 28: 1444case 28:
1414#line 305 "vcc.y" 1445#line 309 "backend/vcc.y"
1415{ yyval.str = 0; } 1446{ yyval.str = 0; }
@@ -1417,3 +1448,3 @@ break;
1417case 29: 1448case 29:
1418#line 310 "vcc.y" 1449#line 314 "backend/vcc.y"
1419{ if (!pushVObject(VCCalProp)) YYERROR; } 1450{ if (!pushVObject(VCCalProp)) YYERROR; }
@@ -1421,3 +1452,3 @@ break;
1421case 30: 1452case 30:
1422#line 313 "vcc.y" 1453#line 317 "backend/vcc.y"
1423{ yyval.vobj = popVObject(); } 1454{ yyval.vobj = popVObject(); }
@@ -1425,3 +1456,3 @@ break;
1425case 31: 1456case 31:
1426#line 315 "vcc.y" 1457#line 319 "backend/vcc.y"
1427{ if (!pushVObject(VCCalProp)) YYERROR; } 1458{ if (!pushVObject(VCCalProp)) YYERROR; }
@@ -1429,3 +1460,3 @@ break;
1429case 32: 1460case 32:
1430#line 317 "vcc.y" 1461#line 321 "backend/vcc.y"
1431{ yyval.vobj = popVObject(); } 1462{ yyval.vobj = popVObject(); }
@@ -1433,3 +1464,3 @@ break;
1433case 38: 1464case 38:
1434#line 332 "vcc.y" 1465#line 336 "backend/vcc.y"
1435{ 1466{
@@ -1440,3 +1471,3 @@ break;
1440case 39: 1471case 39:
1441#line 338 "vcc.y" 1472#line 342 "backend/vcc.y"
1442{ 1473{
@@ -1447,3 +1478,3 @@ break;
1447case 40: 1478case 40:
1448#line 343 "vcc.y" 1479#line 347 "backend/vcc.y"
1449{ 1480{
@@ -1454,3 +1485,3 @@ break;
1454case 41: 1485case 41:
1455#line 348 "vcc.y" 1486#line 352 "backend/vcc.y"
1456{ 1487{
@@ -1461,3 +1492,3 @@ break;
1461case 42: 1492case 42:
1462#line 356 "vcc.y" 1493#line 360 "backend/vcc.y"
1463{ 1494{
@@ -1468,3 +1499,3 @@ break;
1468case 43: 1499case 43:
1469#line 362 "vcc.y" 1500#line 366 "backend/vcc.y"
1470{ 1501{
@@ -1475,3 +1506,3 @@ break;
1475case 44: 1506case 44:
1476#line 367 "vcc.y" 1507#line 371 "backend/vcc.y"
1477{ 1508{
@@ -1482,3 +1513,3 @@ break;
1482case 45: 1513case 45:
1483#line 372 "vcc.y" 1514#line 376 "backend/vcc.y"
1484{ 1515{
@@ -1488,3 +1519,3 @@ case 45:
1488break; 1519break;
1489#line 1492 "y.tab.c" 1520#line 1521 "y.tab.c"
1490 } 1521 }
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
@@ -1007,9 +1007,69 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
1007 1007
1008static 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
1008static void writeQPString(OFile *fp, const char *s) 1051static 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);
@@ -1019,3 +1079,18 @@ static void writeQPString(OFile *fp, const char *s)
1019 1079
1020 1080static 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
@@ -1061,2 +1136,6 @@ static void writeAttrValue(OFile *fp, VObject *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,';');
@@ -1124,2 +1203,14 @@ static void writeProp(OFile *fp, VObject *o)
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,':');
@@ -1140,3 +1231,8 @@ static void writeProp(OFile *fp, VObject *o)
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;
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
@@ -76,2 +76,4 @@ which accompanied this distribution.
76 76
77// No tr() anywhere in this file
78
77 79
@@ -144,3 +146,3 @@ For example:
144 #define VCCGMProp "CGM" 146 #define VCCGMProp "CGM"
145 #define VCCharSetProp "CS" 147 #define VCCharSetProp "CHARSET"
146 #define VCCIDProp "CID" 148 #define VCCIDProp "CID"