summaryrefslogtreecommitdiff
path: root/library/backend
Unidiff
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,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** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free 7** GNU General Public License version 2 as published by the Free Software
8** Software Foundation and appearing in the file LICENSE.GPL included 8** Foundation and appearing in the file LICENSE.GPL included in the
9** in the packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** PARTICULAR PURPOSE.
14** 13**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 15**
@@ -18,11 +17,11 @@
18** not clear to you. 17** not clear to you.
19** 18**
20**********************************************************************/ 19**********************************************************************/
21#include "categories.h" 20#include <qtopia/categories.h>
21#include <qtopia/stringutil.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qcstring.h> 23#include <qcstring.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25#include "stringutil.h"
26 25
27using namespace Qtopia; 26using namespace Qtopia;
28 27
@@ -38,6 +37,24 @@ UidGen CategoryGroup::sUidGen( UidGen::PalmtopCenter );
38UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); 37UidGen CategoryGroup::sUidGen( UidGen::Qtopia );
39#endif 38#endif
40 39
40/*! \class CategoryGroup categories.h
41 \brief Helper class that is used by Categories
42
43 CategoryGroup is a group of categories that is associated with an
44 application or global set. Mainly it defines a map of ids to
45 category labels and category labels to ids. Lookups can be done with
46 labels or unique idenifiers.
47
48 \ingroup qtopiaemb
49 \ingroup qtopiadesktop
50 \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3
51 \sa Categories::appGroupMap(), Categories::globalGroup()
52 */
53
54/*! Add \a label and return the UID. If failure, then 0 is returned. Note
55 that All and Unfiled are reserved labels.
56 \internal
57*/
41int CategoryGroup::add( const QString &label ) 58int CategoryGroup::add( const QString &label )
42{ 59{
43 if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) 60 if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") )
@@ -58,6 +75,8 @@ void CategoryGroup::insert( int uid, const QString &label )
58 mLabelIdMap[label] = uid; 75 mLabelIdMap[label] = uid;
59} 76}
60 77
78/*! \internal
79 */
61bool CategoryGroup::add( int uid, const QString &label ) 80bool CategoryGroup::add( int uid, const QString &label )
62{ 81{
63 if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") ) 82 if ( label == QObject::tr("All") || label == QObject::tr("Unfiled") )
@@ -73,6 +92,9 @@ bool CategoryGroup::add( int uid, const QString &label )
73 return TRUE; 92 return TRUE;
74} 93}
75 94
95/*! Returns TRUE if \a label was removed from the group, FALSE if not.
96 \internal
97 */
76bool CategoryGroup::remove( const QString &label ) 98bool CategoryGroup::remove( const QString &label )
77{ 99{
78 QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label ); 100 QMap<QString,int>::Iterator findIt = mLabelIdMap.find( label );
@@ -85,6 +107,9 @@ bool CategoryGroup::remove( const QString &label )
85 return TRUE; 107 return TRUE;
86} 108}
87 109
110/*! Returns TRUE if \a uid was removed from the group, FALSE if not.
111 \internal
112 */
88bool CategoryGroup::remove( int uid ) 113bool CategoryGroup::remove( int uid )
89{ 114{
90 QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid ); 115 QMap<int,QString>::Iterator idIt = mIdLabelMap.find( uid );
@@ -97,6 +122,8 @@ bool CategoryGroup::remove( int uid )
97 return TRUE; 122 return TRUE;
98} 123}
99 124
125/*! \internal
126 */
100bool CategoryGroup::rename( int uid, const QString &newLabel ) 127bool CategoryGroup::rename( int uid, const QString &newLabel )
101{ 128{
102 if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") ) 129 if ( newLabel == QObject::tr("All") || newLabel == QObject::tr("Unfiled") )
@@ -113,23 +140,27 @@ bool CategoryGroup::rename( int uid, const QString &newLabel )
113 return TRUE; 140 return TRUE;
114} 141}
115 142
143/*! \internal
144 */
116bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) 145bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel )
117{ 146{
118 return rename( id(oldLabel), newLabel ); 147 return rename( id(oldLabel), newLabel );
119} 148}
120 149
150/*! Returns TRUE if \a uid is stored in this group, FALSE if not. */
121bool CategoryGroup::contains(int uid) const 151bool CategoryGroup::contains(int uid) const
122{ 152{
123 return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() ); 153 return ( mIdLabelMap.find( uid ) != mIdLabelMap.end() );
124} 154}
125 155
156/*! Returns TRUE if \a label is stored in this group, FALSE if not. */
126bool CategoryGroup::contains(const QString &label) const 157bool CategoryGroup::contains(const QString &label) const
127{ 158{
128 return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); 159 return ( mLabelIdMap.find( label ) != mLabelIdMap.end() );
129} 160}
130 161
131/** Returns label associated with the uid or QString::null if 162/*! Returns label associated with the \a uid or QString::null if
132 * not found 163 not found
133 */ 164 */
134const QString &CategoryGroup::label(int uid) const 165const QString &CategoryGroup::label(int uid) const
135{ 166{
@@ -139,7 +170,7 @@ const QString &CategoryGroup::label(int uid) const
139 return *idIt; 170 return *idIt;
140} 171}
141 172
142/** Returns the uid associated with label or 0 if not found */ 173/*! Returns the uid associated with \a label or 0 if not found */
143int CategoryGroup::id(const QString &label) const 174int CategoryGroup::id(const QString &label) const
144{ 175{
145 QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); 176 QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label );
@@ -148,6 +179,7 @@ int CategoryGroup::id(const QString &label) const
148 return *labelIt; 179 return *labelIt;
149} 180}
150 181
182/*! Returns a list of all labels stored in this group. */
151QStringList CategoryGroup::labels() const 183QStringList CategoryGroup::labels() const
152{ 184{
153 QStringList labels; 185 QStringList labels;
@@ -159,6 +191,7 @@ QStringList CategoryGroup::labels() const
159 return labels; 191 return labels;
160} 192}
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
163{ 196{
164 QStringList labels; 197 QStringList labels;
@@ -177,8 +210,48 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const
177 * 210 *
178 **********************************************************/ 211 **********************************************************/
179 212
180/** Add the category name as long as it doesn't already exist locally 213/*!
181 * or globally. Return TRUE if added, FALSE if conflicts. 214 \class Categories categories.h
215 \brief The Categories class is a database that groups categories and maps ids to names.
216
217 The Categories class is the low level Categories accessor class. To
218 add a category menu and filter for your application, see CategoryMenu.
219
220 The Categories class allows the developer to add, remove, and rename
221 categories. Categories can be created for an individual application
222 such as Todo List or to be used for all applications. Categories
223 that can be used by all applications are called global
224 categories. Each PalmtopRecord subclass stores categories as an
225 QArray<int> using PalmtopRecord::setCategories() and
226 PalmtopRecord::categories(). This allows each record to be assigned
227 to multiple categories. This also allows the user to rename a
228 category and for it to update automatically in all records.
229
230 This class provides several methods to convert between a category id
231 and it's associated string such as id(), ids(), label() and labels(). A
232 helper class called CategoryGroup is used to access categories of a
233 single application group, such as Todo List. Global categories can
234 also be accessed via CategoryGroup objects. See appGroupMap() and
235 globalGroup() for the appropriate accessor methods.
236
237 Categories are stored in an xml file in the Settings directory
238 (Categories.xml). A global function called categoryFileName() will
239 return to appropriate QString file location to be passed to load()
240 and save() for the master categories database.
241
242 \ingroup qtopiaemb
243 \ingroup qtopiadesktop
244 \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3
245 \sa CategoryGroup, CategoryMenu
246*/
247
248
249/*!
250 Add the category name as long as it doesn't already exist locally or
251 globally. The \a uid is assigned to the category if successfully
252 added. Return \a uid if added, 0 if conflicts (error).
253
254 \internal
182 */ 255 */
183int Categories::addCategory( const QString &appname, 256int Categories::addCategory( const QString &appname,
184 const QString &catname, 257 const QString &catname,
@@ -204,6 +277,11 @@ int Categories::addCategory( const QString &appname,
204 return uid; 277 return uid;
205} 278}
206 279
280/*!
281 Add the category name as long as it doesn't already exist locally or
282 globally. Return UID if added, 0 if conflicts (error).
283*/
284
207int Categories::addCategory( const QString &appname, 285int Categories::addCategory( const QString &appname,
208 const QString &catname ) 286 const QString &catname )
209{ 287{
@@ -229,6 +307,9 @@ int Categories::addCategory( const QString &appname,
229 return uid; 307 return uid;
230} 308}
231 309
310/*!
311 \internal
312*/
232int Categories::addGlobalCategory( const QString &catname, int uid ) 313int Categories::addGlobalCategory( const QString &catname, int uid )
233{ 314{
234 mGlobalCats.add( uid, catname ); 315 mGlobalCats.add( uid, catname );
@@ -236,6 +317,12 @@ int Categories::addGlobalCategory( const QString &catname, int uid )
236 return uid; 317 return uid;
237} 318}
238 319
320/*!
321 Add the global category \a catname while checking that it doesn't
322 already exist globally. Return UID if added, 0 if conflicts.
323
324 \sa addCategory()
325 */
239int Categories::addGlobalCategory( const QString &catname ) 326int Categories::addGlobalCategory( const QString &catname )
240{ 327{
241 int uid = mGlobalCats.add( catname ); 328 int uid = mGlobalCats.add( catname );
@@ -245,9 +332,11 @@ int Categories::addGlobalCategory( const QString &catname )
245 return uid; 332 return uid;
246} 333}
247 334
248/** Removes the category from the application; if it is not found 335/*!
249 * in the application, then it attempts to remove it from 336
250 * the global list 337 Removes the \a catname from the application group. If it is not
338 found in the application group and \a checkGlobal is TRUE, then it
339 attempts to remove it from the global list
251 */ 340 */
252bool Categories::removeCategory( const QString &appname, 341bool Categories::removeCategory( const QString &appname,
253 const QString &catname, 342 const QString &catname,
@@ -268,6 +357,11 @@ bool Categories::removeCategory( const QString &appname,
268 return removeGlobalCategory( catname ); 357 return removeGlobalCategory( catname );
269} 358}
270 359
360
361/*!
362 Removes the \a uid from the application group \a appname. Returns TRUE
363 if success, FALSE if not found.
364*/
271bool Categories::removeCategory( const QString &appname, int uid ) 365bool Categories::removeCategory( const QString &appname, int uid )
272{ 366{
273 QMap< QString, CategoryGroup >::Iterator 367 QMap< QString, CategoryGroup >::Iterator
@@ -282,6 +376,10 @@ bool Categories::removeCategory( const QString &appname, int uid )
282 return FALSE; 376 return FALSE;
283} 377}
284 378
379/*!
380 Removes the global category \a catname. Returns TRUE
381 if success, FALSE if not found.
382*/
285bool Categories::removeGlobalCategory( const QString &catname ) 383bool Categories::removeGlobalCategory( const QString &catname )
286{ 384{
287 int uid = mGlobalCats.id( catname ); 385 int uid = mGlobalCats.id( catname );
@@ -292,7 +390,10 @@ bool Categories::removeGlobalCategory( const QString &catname )
292 return FALSE; 390 return FALSE;
293} 391}
294 392
295 393/*!
394 Removes the global category \a uid. Returns TRUE
395 if success, FALSE if not found.
396*/
296bool Categories::removeGlobalCategory( int uid ) 397bool Categories::removeGlobalCategory( int uid )
297{ 398{
298 if ( mGlobalCats.remove( uid ) ) { 399 if ( mGlobalCats.remove( uid ) ) {
@@ -302,9 +403,10 @@ bool Categories::removeGlobalCategory( int uid )
302 return FALSE; 403 return FALSE;
303} 404}
304 405
305/** Returns the sorted list of all categories that are associated with 406/*!
306 * the app. If includeGlobal parameter is TRUE then the returned 407 Returns the sorted list of all categories that are associated with
307 * categories will include the global category items. 408 the \a app. If \a includeGlobal is TRUE then the returned
409 categories will include the global category items.
308 */ 410 */
309QStringList Categories::labels( const QString &app, 411QStringList Categories::labels( const QString &app,
310 bool includeGlobal, 412 bool includeGlobal,
@@ -316,7 +418,7 @@ QStringList Categories::labels( const QString &app,
316 418
317 if ( appIt != mAppCats.end() ) 419 if ( appIt != mAppCats.end() )
318 cats += (*appIt).labels(); 420 cats += (*appIt).labels();
319 else qDebug("Categories::labels didn't find app %s", app.latin1() ); 421 //else qDebug("Categories::labels didn't find app %s", app.latin1() );
320 if ( includeGlobal ) 422 if ( includeGlobal )
321 cats += mGlobalCats.labels(); 423 cats += mGlobalCats.labels();
322 424
@@ -338,6 +440,9 @@ QStringList Categories::labels( const QString &app,
338 return cats; 440 return cats;
339} 441}
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
342{ 447{
343 if ( mGlobalCats.contains( id ) ) 448 if ( mGlobalCats.contains( id ) )
@@ -349,10 +454,16 @@ QString Categories::label( const QString &app, int id ) const
349 return (*appIt).label( id ); 454 return (*appIt).label( id );
350} 455}
351 456
352/** Returns a single string associated with the cat ids for display in 457/*!
353 * a combobox or any area that requires one string. If catids are empty 458 Returns a single string associated with \a catids for display in a
354 * then "Unfiled" will be returned. If multiple categories are assigned 459 combobox or any area that requires one string. If \a catids are empty
355 * the first cat id is shown with " (multi)" appended to the string. 460 then "Unfiled" will be returned. If multiple categories are
461 assigned then the behavior depends on the DisplaySingle type.
462
463 If \a display is set to ShowMulti then " (multi)" appended to the
464 first string. If \a display is set to ShowAll, then a space
465 seperated string is returned with all categories. If ShowFirst is
466 set, the just the first string is returned.
356 */ 467 */
357QString Categories::displaySingle( const QString &app, 468QString Categories::displaySingle( const QString &app,
358 const QArray<int> &catids, 469 const QArray<int> &catids,
@@ -380,6 +491,11 @@ QString Categories::displaySingle( const QString &app,
380 return r; 491 return r;
381} 492}
382 493
494/*!
495
496 Returns all ids associated with the application CategoryGroup \a app
497 and the passed in \a labels in that group.
498*/
383QArray<int> Categories::ids( const QString &app, const QStringList &labels) const 499QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
384{ 500{
385 QArray<int> results; 501 QArray<int> results;
@@ -397,6 +513,11 @@ QArray<int> Categories::ids( const QString &app, const QStringList &labels) cons
397 return results; 513 return results;
398} 514}
399 515
516/*!
517 Returns the id associated with the app. If the id is not found in the
518 application CategoryGroup, then it searches the global CategoryGroup.
519 If it is not found it either, 0 is returned.
520*/
400int Categories::id( const QString &app, const QString &cat ) const 521int Categories::id( const QString &app, const QString &cat ) const
401{ 522{
402 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) 523 if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) )
@@ -408,8 +529,13 @@ int Categories::id( const QString &app, const QString &cat ) const
408} 529}
409 530
410 531
411/** Return TRUE if renaming succeeded; FALSE if app name not found, 532/*!
412 * or if there was a name conflict 533 Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName
534 is not found, or if \a newName conflicts with an existing category
535 in the CategoryGroup.
536
537 It will first search the CategoryGroup associated with \a appname
538 and if not found it will try to replace in global CategoryGroup.
413 */ 539 */
414bool Categories::renameCategory( const QString &appname, 540bool Categories::renameCategory( const QString &appname,
415 const QString &oldName, 541 const QString &oldName,
@@ -429,6 +555,12 @@ bool Categories::renameCategory( const QString &appname,
429 return renameGlobalCategory( oldName, newName ); 555 return renameGlobalCategory( oldName, newName );
430} 556}
431 557
558/*!
559 Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName
560 is not found, or if \a newName conflicts with an existing category
561 in the CategoryGroup. This function will only rename categories found
562 in the global CategoryGroup.
563 */
432bool Categories::renameGlobalCategory( const QString &oldName, 564bool Categories::renameGlobalCategory( const QString &oldName,
433 const QString &newName ) 565 const QString &newName )
434{ 566{
@@ -440,6 +572,10 @@ bool Categories::renameGlobalCategory( const QString &oldName,
440 return FALSE; 572 return FALSE;
441} 573}
442 574
575/*!
576 Changes the grouping of a category. If a category was global and \a global
577 is set to TRUE, then the \a catname will be moved to the \a appname group.
578*/
443void Categories::setGlobal( const QString &appname, 579void Categories::setGlobal( const QString &appname,
444 const QString &catname, 580 const QString &catname,
445 bool global ) 581 bool global )
@@ -458,13 +594,18 @@ void Categories::setGlobal( const QString &appname,
458 addGlobalCategory( catname ); 594 addGlobalCategory( catname );
459} 595}
460 596
597/*!
598 Returns TRUE if the \a catname is in the global CategoryGroup, FALSE if not.
599*/
461bool Categories::isGlobal( const QString &catname ) const 600bool Categories::isGlobal( const QString &catname ) const
462{ 601{
463 return mGlobalCats.contains( catname ); 602 return mGlobalCats.contains( catname );
464} 603}
465 604
466 605
467/** Returns true if the catname is associated with any application 606/*!
607 Returns true if the \a catname is associated with any CategoryGroup,
608 including global.
468 */ 609 */
469bool Categories::exists( const QString &catname ) const 610bool Categories::exists( const QString &catname ) const
470{ 611{
@@ -478,6 +619,10 @@ bool Categories::exists( const QString &catname ) const
478 return FALSE; 619 return FALSE;
479} 620}
480 621
622/*!
623 Returns TRUE if the \a catname is associated with the \a appname
624 CategoryGroup, FALSE if not found.
625 */
481bool Categories::exists( const QString &appname, 626bool Categories::exists( const QString &appname,
482 const QString &catname) const 627 const QString &catname) const
483{ 628{
@@ -490,7 +635,12 @@ bool Categories::exists( const QString &appname,
490 return (*appIt).contains( catname ); 635 return (*appIt).contains( catname );
491} 636}
492 637
638/*!
639 Saves the Categories database to the \a fname. See categoryFileName()
640 for the default file name string used for the shared category database.
493 641
642 Returns FALSE if there is error writing the file or TRUE on success.
643 */
494bool Categories::save( const QString &fname ) const 644bool Categories::save( const QString &fname ) const
495{ 645{
496 QString strNewFile = fname + ".new"; 646 QString strNewFile = fname + ".new";
@@ -534,6 +684,9 @@ bool Categories::save( const QString &fname ) const
534 } 684 }
535 f.close(); 685 f.close();
536 686
687#ifdef Q_OS_WIN32
688 QFile::remove( fname );
689#endif
537 if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { 690 if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) {
538 qWarning( "problem renaming file %s to %s", 691 qWarning( "problem renaming file %s to %s",
539 strNewFile.latin1(), fname.latin1()); 692 strNewFile.latin1(), fname.latin1());
@@ -544,6 +697,12 @@ bool Categories::save( const QString &fname ) const
544 return TRUE; 697 return TRUE;
545} 698}
546 699
700/*!
701 Loads the Categories database using \a fname. See categoryFileName()
702 for the default file name string used for the shared category database.
703
704 Returns FALSE if there is error reading the file or TRUE on success.
705 */
547bool Categories::load( const QString &fname ) 706bool Categories::load( const QString &fname )
548{ 707{
549 QFile file( fname ); 708 QFile file( fname );
@@ -619,12 +778,19 @@ bool Categories::load( const QString &fname )
619 return TRUE; 778 return TRUE;
620} 779}
621 780
781/*!
782 Clear the categories in memory. Equivelent to creating an empty Categories
783 object.
784*/
622void Categories::clear() 785void Categories::clear()
623{ 786{
624 mGlobalCats.clear(); 787 mGlobalCats.clear();
625 mAppCats.clear(); 788 mAppCats.clear();
626} 789}
627 790
791/*!
792 Dump the contents to standard out. Used for debugging only.
793*/
628void Categories::dump() const 794void Categories::dump() const
629{ 795{
630 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() ); 796 qDebug("\tglobal categories = %s", mGlobalCats.labels().join(", ").latin1() );
@@ -675,3 +841,96 @@ void CheckedListView::setChecked( const QStringList &checked )
675 else 841 else
676 i->setOn( FALSE ); 842 i->setOn( FALSE );
677} 843}
844
845/*! \fn Categories &Categories::operator= ( const Categories &c )
846
847 Performs deep copy.
848 */
849
850
851/*! \fn QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const
852
853 Returns list of labels associated with the application and catids
854*/
855
856/*! \fn QStringList Categories::globalCategories() const
857
858 Returns list of all global category labels
859*/
860
861/*! \fn const QMap<QString, CategoryGroup> &Categories::appGroupMap() const
862
863 Returns a map of application names to CategoryGroup. The CategoryGroup
864 class defines a map of ids to category labels and category labels to ids.
865*/
866
867/*! \fn const CategoryGroup &Categories::globalGroup() const
868
869 Returns the global CategoryGroup. The CategoryGroup
870 class defines a map of ids to category labels and category labels to ids.
871*/
872
873/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid)
874
875 Emitted if a category is added.
876
877 \a cats is a const reference to this object
878 \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global
879 \a uid is the unique identifier associated with the added category
880 */
881
882/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname,
883 int uid)
884
885 Emitted if removed category is removed.
886
887 \a cats is a const reference to this object
888 \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup
889 \a uid is the unique identifier associated with the removed category
890*/
891
892
893/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname,
894 int uid)
895
896 Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats
897 object.
898
899 \a cats is a const reference to this object
900 \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup
901 \a uid is the unique identifier associated with the renamed category
902*/
903
904/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 )
905
906 Constructor for an empty Categories object.
907*/
908
909/*! \fn Categories::Categories( const Categories &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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -34,13 +34,32 @@
34 34
35#include <stdio.h> 35#include <stdio.h>
36 36
37/*!
38 \class Contact contact.h
39 \brief The Contact class holds the data of an address book entry.
40
41 This data includes information the name of the person, contact
42 information, and business information such as deparment and job title.
43
44 \ingroup qtopiaemb
45 \ingroup qtopiadesktop
46*/
47
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()
40 : Record(), mMap(), d( 0 ) 54 : Record(), mMap(), d( 0 )
41{ 55{
42} 56}
43 57
58/*!
59 \internal
60 Creates a new contact. The properties of the contact are
61 set from \a fromMap.
62*/
44Contact::Contact( const QMap<int, QString> &fromMap ) : 63Contact::Contact( const QMap<int, QString> &fromMap ) :
45 Record(), mMap( fromMap ), d( 0 ) 64 Record(), mMap( fromMap ), d( 0 )
46{ 65{
@@ -48,25 +67,384 @@ Contact::Contact( const QMap<int, QString> &fromMap ) :
48 if ( !cats.isEmpty() ) 67 if ( !cats.isEmpty() )
49 setCategories( idsFromString( cats ) ); 68 setCategories( idsFromString( cats ) );
50 QString uidStr = find( Qtopia::AddressUid ); 69 QString uidStr = find( Qtopia::AddressUid );
70
51 if ( uidStr.isEmpty() ) 71 if ( uidStr.isEmpty() )
52 setUid( uidGen().generate() ); 72 setUid( uidGen().generate() );
53 else 73 else
54 setUid( uidStr.toInt() ); 74 setUid( uidStr.toInt() );
75
76 if ( !uidStr.isEmpty() )
77 setUid( uidStr.toInt() );
55} 78}
56 79
80/*!
81 Destroys a contact.
82*/
57Contact::~Contact() 83Contact::~Contact()
58{ 84{
59} 85}
60 86
87/*! \fn void Contact::setTitle( const QString &str )
88 Sets the title of the contact to \a str.
89*/
90
91/*! \fn void Contact::setFirstName( const QString &str )
92 Sets the first name of the contact to \a str.
93*/
94
95/*! \fn void Contact::setMiddleName( const QString &str )
96 Sets the middle name of the contact to \a str.
97*/
98
99/*! \fn void Contact::setLastName( const QString &str )
100 Sets the last name of the contact to \a str.
101*/
102
103/*! \fn void Contact::setSuffix( const QString &str )
104 Sets the suffix of the contact to \a str.
105*/
106
107/*! \fn void Contact::setFileAs( const QString &str )
108 Sets the contact to filed as \a str.
109*/
110
111/*! \fn void Contact::setDefaultEmail( const QString &str )
112 Sets the default email of the contact to \a str.
113*/
114
115/*! \fn void Contact::setHomeStreet( const QString &str )
116 Sets the home street address of the contact to \a str.
117*/
118
119/*! \fn void Contact::setHomeCity( const QString &str )
120 Sets the home city of the contact to \a str.
121*/
122
123/*! \fn void Contact::setHomeState( const QString &str )
124 Sets the home state of the contact to \a str.
125*/
126
127/*! \fn void Contact::setHomeZip( const QString &str )
128 Sets the home zip code of the contact to \a str.
129*/
130
131/*! \fn void Contact::setHomeCountry( const QString &str )
132 Sets the home country of the contact to \a str.
133*/
134
135/*! \fn void Contact::setHomePhone( const QString &str )
136 Sets the home phone number of the contact to \a str.
137*/
138
139/*! \fn void Contact::setHomeFax( const QString &str )
140 Sets the home fax number of the contact to \a str.
141*/
142
143/*! \fn void Contact::setHomeMobile( const QString &str )
144 Sets the home mobile phone number of the contact to \a str.
145*/
146
147/*! \fn void Contact::setHomeWebpage( const QString &str )
148 Sets the home webpage of the contact to \a str.
149*/
150
151/*! \fn void Contact::setCompany( const QString &str )
152 Sets the company for contact to \a str.
153*/
154
155/*! \fn void Contact::setJobTitle( const QString &str )
156 Sets the job title of the contact to \a str.
157*/
158
159/*! \fn void Contact::setDepartment( const QString &str )
160 Sets the department for contact to \a str.
161*/
162
163/*! \fn void Contact::setOffice( const QString &str )
164 Sets the office for contact to \a str.
165*/
166
167/*! \fn void Contact::setBusinessStreet( const QString &str )
168 Sets the business street address of the contact to \a str.
169*/
170
171/*! \fn void Contact::setBusinessCity( const QString &str )
172 Sets the business city of the contact to \a str.
173*/
174
175/*! \fn void Contact::setBusinessState( const QString &str )
176 Sets the business state of the contact to \a str.
177*/
178
179/*! \fn void Contact::setBusinessZip( const QString &str )
180 Sets the business zip code of the contact to \a str.
181*/
182
183/*! \fn void Contact::setBusinessCountry( const QString &str )
184 Sets the business country of the contact to \a str.
185*/
186
187/*! \fn void Contact::setBusinessPhone( const QString &str )
188 Sets the business phone number of the contact to \a str.
189*/
190
191/*! \fn void Contact::setBusinessFax( const QString &str )
192 Sets the business fax number of the contact to \a str.
193*/
194
195/*! \fn void Contact::setBusinessMobile( const QString &str )
196 Sets the business mobile phone number of the contact to \a str.
197*/
198
199/*! \fn void Contact::setBusinessPager( const QString &str )
200 Sets the business pager number of the contact to \a str.
201*/
202
203/*! \fn void Contact::setBusinessWebpage( const QString &str )
204 Sets the business webpage of the contact to \a str.
205*/
206
207/*! \fn void Contact::setProfession( const QString &str )
208 Sets the profession of the contact to \a str.
209*/
210
211/*! \fn void Contact::setAssistant( const QString &str )
212 Sets the assistant of the contact to \a str.
213*/
214
215/*! \fn void Contact::setManager( const QString &str )
216 Sets the manager of the contact to \a str.
217*/
218
219/*! \fn void Contact::setSpouse( const QString &str )
220 Sets the spouse of the contact to \a str.
221*/
222
223/*! \fn void Contact::setGender( const QString &str )
224 Sets the gender of the contact to \a str.
225*/
226
227/*! \fn void Contact::setBirthday( const QString &str )
228 Sets the birthday for the contact to \a str.
229*/
230
231/*! \fn void Contact::setAnniversary( const QString &str )
232 Sets the anniversary of the contact to \a str.
233*/
234
235/*! \fn void Contact::setNickname( const QString &str )
236 Sets the nickname of the contact to \a str.
237*/
238
239/*! \fn void Contact::setNotes( const QString &str )
240 Sets the notes about the contact to \a str.
241*/
242
243/*! \fn QString Contact::title() const
244 Returns the title of the contact.
245*/
246
247/*! \fn QString Contact::firstName() const
248 Returns the first name of the contact.
249*/
250
251/*! \fn QString Contact::middleName() const
252 Returns the middle name of the contact.
253*/
254
255/*! \fn QString Contact::lastName() const
256 Returns the last name of the contact.
257*/
258
259/*! \fn QString Contact::suffix() const
260 Returns the suffix of the contact.
261*/
262
263/*! \fn QString Contact::fileAs() const
264 Returns the string the contact is filed as.
265*/
266
267/*! \fn QString Contact::defaultEmail() const
268 Returns the default email address of the contact.
269*/
270
271/*! \fn QString Contact::emails() const
272 Returns the list of email address for a contact separated by ';'s in a single
273 string.
274*/
275
276/*! \fn QString Contact::homeStreet() const
277 Returns the home street address of the contact.
278*/
279
280/*! \fn QString Contact::homeCity() const
281 Returns the home city of the contact.
282*/
283
284/*! \fn QString Contact::homeState() const
285 Returns the home state of the contact.
286*/
287
288/*! \fn QString Contact::homeZip() const
289 Returns the home zip of the contact.
290*/
291
292/*! \fn QString Contact::homeCountry() const
293 Returns the home country of the contact.
294*/
295
296/*! \fn QString Contact::homePhone() const
297 Returns the home phone number of the contact.
298*/
299
300/*! \fn QString Contact::homeFax() const
301 Returns the home fax number of the contact.
302*/
303
304/*! \fn QString Contact::homeMobile() const
305 Returns the home mobile number of the contact.
306*/
307
308/*! \fn QString Contact::homeWebpage() const
309 Returns the home webpage of the contact.
310*/
311
312/*! \fn QString Contact::company() const
313 Returns the company for the contact.
314*/
315
316/*! \fn QString Contact::department() const
317 Returns the department for the contact.
318*/
319
320/*! \fn QString Contact::office() const
321 Returns the office for the contact.
322*/
323
324/*! \fn QString Contact::jobTitle() const
325 Returns the job title of the contact.
326*/
327
328/*! \fn QString Contact::profession() const
329 Returns the profession of the contact.
330*/
331
332/*! \fn QString Contact::assistant() const
333 Returns the assistant of the contact.
334*/
335
336/*! \fn QString Contact::manager() const
337 Returns the manager of the contact.
338*/
339
340/*! \fn QString Contact::businessStreet() const
341 Returns the business street address of the contact.
342*/
343
344/*! \fn QString Contact::businessCity() const
345 Returns the business city of the contact.
346*/
347
348/*! \fn QString Contact::businessState() const
349 Returns the business state of the contact.
350*/
351
352/*! \fn QString Contact::businessZip() const
353 Returns the business zip of the contact.
354*/
355
356/*! \fn QString Contact::businessCountry() const
357 Returns the business country of the contact.
358*/
359
360/*! \fn QString Contact::businessPhone() const
361 Returns the business phone number of the contact.
362*/
363
364/*! \fn QString Contact::businessFax() const
365 Returns the business fax number of the contact.
366*/
367
368/*! \fn QString Contact::businessMobile() const
369 Returns the business mobile number of the contact.
370*/
371
372/*! \fn QString Contact::businessPager() const
373 Returns the business pager number of the contact.
374*/
375
376/*! \fn QString Contact::businessWebpage() const
377 Returns the business webpage of the contact.
378*/
379
380/*! \fn QString Contact::spouse() const
381 Returns the spouse of the contact.
382*/
383
384/*! \fn QString Contact::gender() const
385 Returns the gender of the contact.
386*/
387
388/*! \fn QString Contact::birthday() const
389 Returns the birthday of the contact.
390*/
391
392/*! \fn QString Contact::anniversary() const
393 Returns the anniversary of the contact.
394*/
395
396/*! \fn QString Contact::nickname() const
397 Returns the nickname of the contact.
398*/
399
400/*! \fn QString Contact::children() const
401 Returns the children of the contact.
402*/
403
404/*! \fn QString Contact::notes() const
405 Returns the notes relating to the the contact.
406*/
407
408/*! \fn QString Contact::groups() const
409 \internal
410 Returns the groups for the contact.
411*/
412
413/*! \fn QStringList Contact::groupList() const
414 \internal
415*/
416
417/*! \fn QString Contact::field(int) const
418 \internal
419*/
420
421/*! \fn void Contact::saveJournal( journal_action, const QString & = QString::null )
422 \internal
423*/
424
425/*! \fn void Contact::setUid( int id )
426 \internal
427 Sets the uid for this record to \a id.
428*/
429
430/*! \enum Contact::journal_action
431 \internal
432*/
433
434/*!
435 \internal
436*/
61QMap<int, QString> Contact::toMap() const 437QMap<int, QString> Contact::toMap() const
62{ 438{
63 QMap<int, QString> map = mMap; 439 QMap<int, QString> map = mMap;
64 map.insert( Qtopia::AddressCategory, idsToString( categories() )); 440 QString cats = idsToString( categories() );
441 if ( !cats.isEmpty() )
442 map.insert( Qtopia::AddressCategory, cats );
65 return map; 443 return map;
66} 444}
67 445
68/*! 446/*!
69 Returns a rich text formatted QString of the Contact. 447 Returns a rich text formatted QString representing the contents the contact.
70*/ 448*/
71QString Contact::toRichText() const 449QString Contact::toRichText() const
72{ 450{
@@ -231,6 +609,9 @@ QString Contact::toRichText() const
231 return text; 609 return text;
232} 610}
233 611
612/*!
613 \internal
614*/
234void Contact::insert( int key, const QString &v ) 615void Contact::insert( int key, const QString &v )
235{ 616{
236 QString value = v.stripWhiteSpace(); 617 QString value = v.stripWhiteSpace();
@@ -240,6 +621,9 @@ void Contact::insert( int key, const QString &v )
240 mMap.insert( key, value ); 621 mMap.insert( key, value );
241} 622}
242 623
624/*!
625 \internal
626*/
243void Contact::replace( int key, const QString & v ) 627void Contact::replace( int key, const QString & v )
244{ 628{
245 QString value = v.stripWhiteSpace(); 629 QString value = v.stripWhiteSpace();
@@ -249,11 +633,17 @@ void Contact::replace( int key, const QString & v )
249 mMap.replace( key, value ); 633 mMap.replace( key, value );
250} 634}
251 635
636/*!
637 \internal
638*/
252QString Contact::find( int key ) const 639QString Contact::find( int key ) const
253{ 640{
254 return mMap[key]; 641 return mMap[key];
255} 642}
256 643
644/*!
645 \internal
646*/
257QString Contact::displayAddress( const QString &street, 647QString Contact::displayAddress( const QString &street,
258 const QString &city, 648 const QString &city,
259 const QString &state, 649 const QString &state,
@@ -276,6 +666,9 @@ QString Contact::displayAddress( const QString &street,
276 return s; 666 return s;
277} 667}
278 668
669/*!
670 \internal
671*/
279QString Contact::displayBusinessAddress() const 672QString Contact::displayBusinessAddress() const
280{ 673{
281 return displayAddress( businessStreet(), businessCity(), 674 return displayAddress( businessStreet(), businessCity(),
@@ -283,6 +676,9 @@ QString Contact::displayBusinessAddress() const
283 businessCountry() ); 676 businessCountry() );
284} 677}
285 678
679/*!
680 \internal
681*/
286QString Contact::displayHomeAddress() const 682QString Contact::displayHomeAddress() const
287{ 683{
288 return displayAddress( homeStreet(), homeCity(), 684 return displayAddress( homeStreet(), homeCity(),
@@ -290,6 +686,9 @@ QString Contact::displayHomeAddress() const
290 homeCountry() ); 686 homeCountry() );
291} 687}
292 688
689/*!
690 Returns the full name of the contact
691*/
293QString Contact::fullName() const 692QString Contact::fullName() const
294{ 693{
295 QString title = find( Qtopia::Title ); 694 QString title = find( Qtopia::Title );
@@ -322,16 +721,62 @@ QString Contact::fullName() const
322 return name.simplifyWhiteSpace(); 721 return name.simplifyWhiteSpace();
323} 722}
324 723
724/*!
725 Returns a list of the names of the children of the contact.
726*/
325QStringList Contact::childrenList() const 727QStringList Contact::childrenList() const
326{ 728{
327 return QStringList::split( " ", find( Qtopia::Children ) ); 729 return QStringList::split( " ", find( Qtopia::Children ) );
328} 730}
329 731
732/*! \fn void Contact::insertEmail( const QString &email )
733
734 Insert \a email into the email list. Ensures \a email can only be added
735 once. If there is no default email address set, it sets it to the \a email.
736*/
737
738/*! \fn void Contact::removeEmail( const QString &email )
739
740 Removes the \a email from the email list. If the default email was \a email,
741 then the default email address is assigned to the first email in the
742 email list
743*/
744
745/*! \fn void Contact::clearEmails()
746
747 Clears the email list.
748 */
749
750/*! \fn void Contact::insertEmails( const QStringList &emailList )
751
752 Appends the \a emailList to the exiting email list
753 */
754
755/*!
756 Returns a list of email addresses belonging to the contact, including
757 the default email address.
758*/
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()
336{ 781{
337 QString lastName, firstName, middleName, fileas; 782 QString lastName, firstName, middleName, fileas;
@@ -353,6 +798,10 @@ void Contact::setFileAs()
353 replace( Qtopia::FileAs, fileas ); 798 replace( Qtopia::FileAs, fileas );
354} 799}
355 800
801/*!
802 \internal
803 Appends the contact information to \a buf.
804*/
356void Contact::save( QString &buf ) const 805void Contact::save( QString &buf ) const
357{ 806{
358 static const QStringList SLFIELDS = fields(); 807 static const QStringList SLFIELDS = fields();
@@ -377,6 +826,10 @@ void Contact::save( QString &buf ) const
377 // You need to close this yourself 826 // You need to close this yourself
378} 827}
379 828
829/*!
830 \internal
831 Returns the list of fields belonging to a contact
832*/
380QStringList Contact::fields() 833QStringList Contact::fields()
381{ 834{
382 QStringList list; 835 QStringList list;
@@ -435,6 +888,10 @@ QStringList Contact::fields()
435 return list; 888 return list;
436} 889}
437 890
891/*!
892 \internal
893 Returns a translated list of field names for a contact.
894*/
438QStringList Contact::trfields() 895QStringList Contact::trfields()
439{ 896{
440 QStringList list; 897 QStringList list;
@@ -493,19 +950,29 @@ QStringList Contact::trfields()
493 return list; 950 return list;
494} 951}
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 );
501} 962}
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}
507 971
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 )
510{ 977{
511 VObject *ret = 0; 978 VObject *ret = 0;
@@ -514,6 +981,9 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt
514 return ret; 981 return ret;
515} 982}
516 983
984/*!
985 \internal
986*/
517static inline VObject *safeAddProp( VObject *o, const char *prop) 987static inline VObject *safeAddProp( VObject *o, const char *prop)
518{ 988{
519 VObject *ret = 0; 989 VObject *ret = 0;
@@ -522,6 +992,9 @@ static inline VObject *safeAddProp( VObject *o, const char *prop)
522 return ret; 992 return ret;
523} 993}
524 994
995/*!
996 \internal
997*/
525static VObject *createVObject( const Contact &c ) 998static VObject *createVObject( const Contact &c )
526{ 999{
527 VObject *vcard = newVObject( VCCardProp ); 1000 VObject *vcard = newVObject( VCCardProp );
@@ -622,12 +1095,13 @@ static VObject *createVObject( const Contact &c )
622} 1095}
623 1096
624 1097
1098/*!
1099 \internal
1100*/
625static Contact parseVObject( VObject *obj ) 1101static Contact parseVObject( VObject *obj )
626{ 1102{
627 Contact c; 1103 Contact c;
628 1104
629 bool haveDefaultEmail = FALSE;
630
631 VObjectIterator it; 1105 VObjectIterator it;
632 initPropIterator( &it, obj ); 1106 initPropIterator( &it, obj );
633 while( moreIteration( &it ) ) { 1107 while( moreIteration( &it ) ) {
@@ -767,14 +1241,7 @@ static Contact parseVObject( VObject *obj )
767 valid = FALSE; 1241 valid = FALSE;
768 } 1242 }
769 if ( valid ) { 1243 if ( valid ) {
770 if ( haveDefaultEmail ) { 1244 c.insertEmail( email );
771 QString str = c.emails();
772 if ( !str.isEmpty() )
773 str += ","+email;
774 c.setEmails( str );
775 } else {
776 c.setDefaultEmail( email );
777 }
778 } 1245 }
779 } 1246 }
780 else if ( name == VCURLProp ) { 1247 else if ( name == VCURLProp ) {
@@ -851,6 +1318,9 @@ static Contact parseVObject( VObject *obj )
851 return c; 1318 return c;
852} 1319}
853 1320
1321/*!
1322 Writes the list of \a contacts as a set of VCards to the file \a filename.
1323*/
854void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) 1324void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts)
855{ 1325{
856 QFileDirect f( filename.utf8().data() ); 1326 QFileDirect f( filename.utf8().data() );
@@ -868,6 +1338,9 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co
868 cleanStrTbl(); 1338 cleanStrTbl();
869} 1339}
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)
872{ 1345{
873 QFileDirect f( filename.utf8().data() ); 1346 QFileDirect f( filename.utf8().data() );
@@ -883,7 +1356,9 @@ void Contact::writeVCard( const QString &filename, const Contact &contact)
883 cleanStrTbl(); 1356 cleanStrTbl();
884} 1357}
885 1358
886 1359/*!
1360 Returns the set of contacts read as VCards from the file \a filename.
1361*/
887QValueList<Contact> Contact::readVCard( const QString &filename ) 1362QValueList<Contact> Contact::readVCard( const QString &filename )
888{ 1363{
889 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); 1364 qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() );
@@ -904,11 +1379,20 @@ QValueList<Contact> Contact::readVCard( const QString &filename )
904 return contacts; 1379 return contacts;
905} 1380}
906 1381
1382/*!
1383 Returns TRUE if the contact matches the regular expression \a regexp.
1384 Otherwise returns FALSE.
1385*/
907bool Contact::match( const QString &regexp ) const 1386bool Contact::match( const QString &regexp ) const
908{ 1387{
909 return match(QRegExp(regexp)); 1388 return match(QRegExp(regexp));
910} 1389}
911 1390
1391/*!
1392 \overload
1393 Returns TRUE if the contact matches the regular expression \a regexp.
1394 Otherwise returns FALSE.
1395*/
912bool Contact::match( const QRegExp &r ) const 1396bool Contact::match( const QRegExp &r ) const
913{ 1397{
914 bool match; 1398 bool match;
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -21,14 +21,14 @@
21#ifndef __CONTACT_H__ 21#ifndef __CONTACT_H__
22#define __CONTACT_H__ 22#define __CONTACT_H__
23 23
24#include <qpe/palmtoprecord.h> 24#include <qtopia/private/palmtoprecord.h>
25#include <qpe/recordfields.h> 25#include <qtopia/private/recordfields.h>
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#if defined(QPC_TEMPLATEDLL) 29#if defined(QPC_TEMPLATEDLL)
30// MOC_SKIP_BEGIN 30// MOC_SKIP_BEGIN
31template class QPC_EXPORT QMap<int, QString>; 31QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
32// MOC_SKIP_END 32// MOC_SKIP_END
33#endif 33#endif
34 34
@@ -56,9 +56,12 @@ public:
56 void setFileAs(); 56 void setFileAs();
57 57
58 // default email address 58 // default email address
59 void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } 59 void setDefaultEmail( const QString &v );
60 // the emails should be seperated by a semicolon 60 // inserts email to list and ensure's doesn't already exist
61 void setEmails( const QString &v ); 61 void insertEmail( const QString &v );
62 void removeEmail( const QString &v );
63 void clearEmails();
64 void insertEmails( const QStringList &v );
62 65
63 // home 66 // home
64 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } 67 void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); }
@@ -123,7 +126,6 @@ public:
123 126
124 // email 127 // email
125 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } 128 QString defaultEmail() const { return find( Qtopia::DefaultEmail ); }
126 QString emails() const { return find( Qtopia::Emails ); }
127 QStringList emailList() const; 129 QStringList emailList() const;
128 130
129 // home 131 // home
@@ -202,7 +204,16 @@ public:
202{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } 204{ Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); }
203 205
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 );
207 void replace( int key, const QString &value ); 218 void replace( int key, const QString &value );
208 QString find( int key ) const; 219 QString find( int key ) const;
@@ -219,4 +230,77 @@ private:
219 ContactPrivate *d; 230 ContactPrivate *d;
220}; 231};
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -20,9 +20,9 @@
20 20
21#include "event.h" 21#include "event.h"
22#include "qfiledirect_p.h" 22#include "qfiledirect_p.h"
23#include <qpe/timeconversion.h> 23#include <qtopia/timeconversion.h>
24#include <qpe/stringutil.h> 24#include <qtopia/stringutil.h>
25#include <qpe/recordfields.h> 25#include <qtopia/private/recordfields.h>
26#include <qbuffer.h> 26#include <qbuffer.h>
27#include <time.h> 27#include <time.h>
28#include "vobject_p.h" 28#include "vobject_p.h"
@@ -71,6 +71,255 @@ static void write( QString& buf, const Event::RepeatPattern &r )
71 71
72Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); 72Qtopia::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()
75{ 324{
76 startUTC = endUTC = time( 0 ); 325 startUTC = endUTC = time( 0 );
@@ -83,6 +332,9 @@ Event::Event() : Record()
83 pattern.frequency = -1; 332 pattern.frequency = -1;
84} 333}
85 334
335/*!
336 \internal
337*/
86Event::Event( const QMap<int, QString> &map ) 338Event::Event( const QMap<int, QString> &map )
87{ 339{
88 setDescription( map[DatebookDescription] ); 340 setDescription( map[DatebookDescription] );
@@ -106,10 +358,16 @@ Event::Event( const QMap<int, QString> &map )
106 setUid( map[ DatebookUid ].toInt() ); 358 setUid( map[ DatebookUid ].toInt() );
107} 359}
108 360
361/*!
362 Destroys an event.
363*/
109Event::~Event() 364Event::~Event()
110{ 365{
111} 366}
112 367
368/*!
369 \internal
370*/
113int Event::week( const QDate& date ) 371int Event::week( const QDate& date )
114{ 372{
115 // Calculates the week this date is in within that 373 // Calculates the week this date is in within that
@@ -124,6 +382,9 @@ int Event::week( const QDate& date )
124 return week; 382 return week;
125} 383}
126 384
385/*!
386 \internal
387*/
127int Event::occurrence( const QDate& date ) 388int Event::occurrence( const QDate& date )
128{ 389{
129 // calculates the number of occurrances of this day of the 390 // calculates the number of occurrances of this day of the
@@ -131,6 +392,9 @@ int Event::occurrence( const QDate& date )
131 return ( date.day() - 1 ) / 7 + 1; 392 return ( date.day() - 1 ) / 7 + 1;
132} 393}
133 394
395/*!
396 \internal
397*/
134int Event::dayOfWeek( char day ) 398int Event::dayOfWeek( char day )
135{ 399{
136 int dayOfWeek = 1; 400 int dayOfWeek = 1;
@@ -142,20 +406,33 @@ int Event::dayOfWeek( char day )
142 return dayOfWeek; 406 return dayOfWeek;
143} 407}
144 408
409/*!
410 \internal
411*/
145int Event::monthDiff( const QDate& first, const QDate& second ) 412int Event::monthDiff( const QDate& first, const QDate& second )
146{ 413{
147 return ( second.year() - first.year() ) * 12 + 414 return ( second.year() - first.year() ) * 12 +
148 second.month() - first.month(); 415 second.month() - first.month();
149} 416}
150 417
418/*!
419 \internal
420*/
151QMap<int, QString> Event::toMap() const 421QMap<int, QString> Event::toMap() const
152{ 422{
153 QMap<int, QString> m; 423 QMap<int, QString> m;
424
425 if ( !description().isEmpty() )
154 m.insert( DatebookDescription, description() ); 426 m.insert( DatebookDescription, description() );
427 if ( !location().isEmpty() )
155 m.insert ( Location, location() ); 428 m.insert ( Location, location() );
429 if ( categories().count() )
156 m.insert ( DatebookCategory, idsToString( categories() ) ); 430 m.insert ( DatebookCategory, idsToString( categories() ) );
431 if ( !timeZone().isEmpty() )
157 m.insert ( TimeZone, timeZone() ); 432 m.insert ( TimeZone, timeZone() );
433 if ( !notes().isEmpty() )
158 m.insert ( Note, notes() ); 434 m.insert ( Note, notes() );
435
159 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); 436 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) );
160 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); 437 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) );
161 m.insert ( DatebookType, QString::number( (int)type() ) ); 438 m.insert ( DatebookType, QString::number( (int)type() ) );
@@ -174,16 +451,25 @@ QMap<int, QString> Event::toMap() const
174 return m; 451 return m;
175} 452}
176 453
454/*!
455 \internal
456*/
177void Event::setRepeat( const RepeatPattern &p ) 457void Event::setRepeat( const RepeatPattern &p )
178{ 458{
179 setRepeat( p.type != NoRepeat, p ); 459 setRepeat( p.type != NoRepeat, p );
180} 460}
181 461
462/*!
463 Sets the description of the event to \a s.
464*/
182void Event::setDescription( const QString &s ) 465void Event::setDescription( const QString &s )
183{ 466{
184 descript = s; 467 descript = s;
185} 468}
186 469
470/*!
471 Sets the location of the event to \a s.
472*/
187void Event::setLocation( const QString &s ) 473void Event::setLocation( const QString &s )
188{ 474{
189 locat = s; 475 locat = s;
@@ -194,36 +480,59 @@ void Event::setLocation( const QString &s )
194// categ = s; 480// categ = s;
195// } 481// }
196 482
483/*!
484 \internal
485*/
197void Event::setType( Type t ) 486void Event::setType( Type t )
198{ 487{
199 typ = t; 488 typ = t;
200} 489}
201 490
491/*!
492 Sets the start date and time of the first or only occurance of this event
493 to the date and time \a d. \a d should be in local time.
494*/
202void Event::setStart( const QDateTime &d ) 495void Event::setStart( const QDateTime &d )
203{ 496{
204 startUTC = TimeConversion::toUTC( d ); 497 startUTC = TimeConversion::toUTC( d );
205} 498}
206 499
500/*!
501 \internal
502*/
207void Event::setStart( time_t time ) 503void Event::setStart( time_t time )
208{ 504{
209 startUTC = time; 505 startUTC = time;
210} 506}
211 507
508/*!
509 Sets the end date and time of the first or only occurance of this event
510 to the date and time \a d. \a d should be in local time.
511*/
212void Event::setEnd( const QDateTime &d ) 512void Event::setEnd( const QDateTime &d )
213{ 513{
214 endUTC = TimeConversion::toUTC( d ); 514 endUTC = TimeConversion::toUTC( d );
215} 515}
216 516
517/*!
518 \internal
519*/
217void Event::setEnd( time_t time ) 520void Event::setEnd( time_t time )
218{ 521{
219 endUTC = time; 522 endUTC = time;
220} 523}
221 524
525/*!
526 \internal
527*/
222void Event::setTimeZone( const QString &z ) 528void Event::setTimeZone( const QString &z )
223{ 529{
224 tz = z; 530 tz = z;
225} 531}
226 532
533/*!
534 \internal
535*/
227void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) 536void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
228{ 537{
229 hAlarm = b; 538 hAlarm = b;
@@ -231,22 +540,34 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
231 aSound = s; 540 aSound = s;
232} 541}
233 542
543/*!
544 \internal
545*/
234void Event::setRepeat( bool b, const RepeatPattern &p ) 546void Event::setRepeat( bool b, const RepeatPattern &p )
235{ 547{
236 hRepeat = b; 548 hRepeat = b;
237 pattern = p; 549 pattern = p;
238} 550}
239 551
552/*!
553 Sets the notes for the event to \a n.
554*/
240void Event::setNotes( const QString &n ) 555void Event::setNotes( const QString &n )
241{ 556{
242 note = n; 557 note = n;
243} 558}
244 559
560/*!
561 Returns the description of the event.
562*/
245const QString &Event::description() const 563const QString &Event::description() const
246{ 564{
247 return descript; 565 return descript;
248} 566}
249 567
568/*!
569 Returns the location of the event.
570*/
250const QString &Event::location() const 571const QString &Event::location() const
251{ 572{
252 return locat; 573 return locat;
@@ -257,11 +578,17 @@ const QString &Event::location() const
257// return categ; 578// return categ;
258// } 579// }
259 580
581/*!
582 \internal
583*/
260Event::Type Event::type() const 584Event::Type Event::type() const
261{ 585{
262 return typ; 586 return typ;
263} 587}
264 588
589/*!
590 \internal
591*/
265QDateTime Event::start( bool actual ) const 592QDateTime Event::start( bool actual ) const
266{ 593{
267 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); 594 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime();
@@ -274,6 +601,9 @@ QDateTime Event::start( bool actual ) const
274 return dt; 601 return dt;
275} 602}
276 603
604/*!
605 \internal
606*/
277QDateTime Event::end( bool actual ) const 607QDateTime Event::end( bool actual ) const
278{ 608{
279 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); 609 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime();
@@ -286,48 +616,77 @@ QDateTime Event::end( bool actual ) const
286 return dt; 616 return dt;
287} 617}
288 618
619/*!
620 \internal
621*/
289const QString &Event::timeZone() const 622const QString &Event::timeZone() const
290{ 623{
291 return tz; 624 return tz;
292} 625}
293 626
627/*!
628 \internal
629*/
294bool Event::hasAlarm() const 630bool Event::hasAlarm() const
295{ 631{
296 return hAlarm; 632 return hAlarm;
297} 633}
298 634
635/*!
636 \internal
637*/
299int Event::alarmTime() const 638int Event::alarmTime() const
300{ 639{
301 return aMinutes; 640 return aMinutes;
302} 641}
303 642
643/*!
644 Returns the sound type for the alarm of this event.
645*/
304Event::SoundTypeChoice Event::alarmSound() const 646Event::SoundTypeChoice Event::alarmSound() const
305{ 647{
306 return aSound; 648 return aSound;
307} 649}
308 650
651/*!
652 \internal
653*/
309bool Event::hasRepeat() const 654bool Event::hasRepeat() const
310{ 655{
311 return doRepeat(); 656 return doRepeat();
312} 657}
313 658
659/*!
660 \internal
661*/
314const Event::RepeatPattern &Event::repeatPattern() const 662const Event::RepeatPattern &Event::repeatPattern() const
315{ 663{
316 return pattern; 664 return pattern;
317} 665}
318 666
667/*!
668 \internal
669*/
319Event::RepeatPattern &Event::repeatPattern() 670Event::RepeatPattern &Event::repeatPattern()
320{ 671{
321 return pattern; 672 return pattern;
322} 673}
323 674
675/*!
676 Returns the notes for the event.
677*/
324const QString &Event::notes() const 678const QString &Event::notes() const
325{ 679{
326 return note; 680 return note;
327} 681}
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 &&
332 e.locat == locat && 691 e.locat == locat &&
333 e.categ == categ && 692 e.categ == categ &&
@@ -343,6 +702,10 @@ bool Event::operator==( const Event &e ) const
343 e.note == note ); 702 e.note == note );
344} 703}
345 704
705/*!
706 \internal
707 Appends the contact information to \a buf.
708*/
346void Event::save( QString& buf ) 709void Event::save( QString& buf )
347{ 710{
348 buf += " description=\"" + Qtopia::escapeString(descript) + "\""; 711 buf += " description=\"" + Qtopia::escapeString(descript) + "\"";
@@ -378,6 +741,9 @@ void Event::save( QString& buf )
378 buf += customToXml(); 741 buf += customToXml();
379} 742}
380 743
744/*!
745 \internal
746*/
381bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const 747bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
382{ 748{
383 // *sigh* 749 // *sigh*
@@ -390,6 +756,28 @@ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
390 && createTime == right.createTime ); 756 && createTime == right.createTime );
391} 757}
392 758
759/*!
760 \class EffectiveEvent
761 \brief The EffectiveEvent class the data for a single occurance of an event.
762
763 This class describes the event for a single occurance of it. For example if
764 an Event occurs every week, the effective event might represent the third
765 occurance of this Event.
766
767 \ingroup qtopiaemb
768 \ingroup qtopiadesktop
769 \warning This class will be phased out in Qtopia 3.x
770*/
771
772/*!
773 \enum EffectiveEvent::Position
774 \internal
775*/
776
777/*!
778 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &)
779 \internal
780*/
393 781
394class EffectiveEventPrivate 782class EffectiveEventPrivate
395{ 783{
@@ -400,7 +788,9 @@ public:
400 QDate endDate; 788 QDate endDate;
401}; 789};
402 790
403 791/*!
792 \internal
793*/
404EffectiveEvent::EffectiveEvent() 794EffectiveEvent::EffectiveEvent()
405{ 795{
406 mDate = QDate::currentDate(); 796 mDate = QDate::currentDate();
@@ -408,6 +798,9 @@ EffectiveEvent::EffectiveEvent()
408 d = 0; 798 d = 0;
409} 799}
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 )
412{ 805{
413 mEvent = e; 806 mEvent = e;
@@ -424,11 +817,17 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos
424 d = 0; 817 d = 0;
425} 818}
426 819
820/*!
821 \internal
822*/
427EffectiveEvent::~EffectiveEvent() 823EffectiveEvent::~EffectiveEvent()
428{ 824{
429 delete d; 825 delete d;
430} 826}
431 827
828/*!
829 \internal
830*/
432EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) 831EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
433{ 832{
434 d = 0; 833 d = 0;
@@ -461,67 +860,106 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
461// return mEvent.category(); 860// return mEvent.category();
462// } 861// }
463 862
863/*!
864 Returns the description of the event for this effective event.
865*/
464const QString &EffectiveEvent::description( ) const 866const QString &EffectiveEvent::description( ) const
465{ 867{
466 return mEvent.description(); 868 return mEvent.description();
467} 869}
468 870
871/*!
872\internal
873*/
469const QString &EffectiveEvent::location( ) const 874const QString &EffectiveEvent::location( ) const
470{ 875{
471 return mEvent.location(); 876 return mEvent.location();
472} 877}
473 878
879/*!
880\internal
881*/
474const QString &EffectiveEvent::notes() const 882const QString &EffectiveEvent::notes() const
475{ 883{
476 return mEvent.notes(); 884 return mEvent.notes();
477} 885}
478 886
887/*!
888 Returns the event associated with this effective event.
889*/
479const Event &EffectiveEvent::event() const 890const Event &EffectiveEvent::event() const
480{ 891{
481 return mEvent; 892 return mEvent;
482} 893}
483 894
895/*!
896 \internal
897*/
484const QTime &EffectiveEvent::end() const 898const QTime &EffectiveEvent::end() const
485{ 899{
486 return mEnd; 900 return mEnd;
487} 901}
488 902
903/*!
904 \internal
905*/
489const QTime &EffectiveEvent::start() const 906const QTime &EffectiveEvent::start() const
490{ 907{
491 return mStart; 908 return mStart;
492} 909}
493 910
911/*!
912 Returns the date the effective event occurs on.
913*/
494const QDate &EffectiveEvent::date() const 914const QDate &EffectiveEvent::date() const
495{ 915{
496 return mDate; 916 return mDate;
497} 917}
498 918
919/*!
920 \internal
921*/
499int EffectiveEvent::length() const 922int EffectiveEvent::length() const
500{ 923{
501 return (mEnd.hour() * 60 - mStart.hour() * 60) 924 return (mEnd.hour() * 60 - mStart.hour() * 60)
502 + QABS(mStart.minute() - mEnd.minute() ); 925 + QABS(mStart.minute() - mEnd.minute() );
503} 926}
504 927
928/*!
929 \internal
930*/
505void EffectiveEvent::setDate( const QDate &dt ) 931void EffectiveEvent::setDate( const QDate &dt )
506{ 932{
507 mDate = dt; 933 mDate = dt;
508} 934}
509 935
936/*!
937 \internal
938*/
510void EffectiveEvent::setStart( const QTime &start ) 939void EffectiveEvent::setStart( const QTime &start )
511{ 940{
512 mStart = start; 941 mStart = start;
513} 942}
514 943
944/*!
945 \internal
946*/
515void EffectiveEvent::setEnd( const QTime &end ) 947void EffectiveEvent::setEnd( const QTime &end )
516{ 948{
517 mEnd = end; 949 mEnd = end;
518} 950}
519 951
952/*!
953 \internal
954*/
520void EffectiveEvent::setEvent( Event e ) 955void EffectiveEvent::setEvent( Event e )
521{ 956{
522 mEvent = e; 957 mEvent = e;
523} 958}
524 959
960/*!
961 \internal
962*/
525bool EffectiveEvent::operator<( const EffectiveEvent &e ) const 963bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
526{ 964{
527 if ( mDate < e.date() ) 965 if ( mDate < e.date() )
@@ -532,11 +970,17 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
532 return FALSE; 970 return FALSE;
533} 971}
534 972
973/*!
974 \internal
975*/
535bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const 976bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
536{ 977{
537 return (mDate <= e.date() ); 978 return (mDate <= e.date() );
538} 979}
539 980
981/*!
982 \internal
983*/
540bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 984bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
541{ 985{
542 return ( mDate == e.date() 986 return ( mDate == e.date()
@@ -545,21 +989,33 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
545 && mEvent == e.event() ); 989 && mEvent == e.event() );
546} 990}
547 991
992/*!
993 \internal
994*/
548bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const 995bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
549{ 996{
550 return !(*this == e); 997 return !(*this == e);
551} 998}
552 999
1000/*!
1001 \internal
1002*/
553bool EffectiveEvent::operator>( const EffectiveEvent &e ) const 1003bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
554{ 1004{
555 return !(*this <= e ); 1005 return !(*this <= e );
556} 1006}
557 1007
1008/*!
1009 \internal
1010*/
558bool EffectiveEvent::operator>=(const EffectiveEvent &e) const 1011bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
559{ 1012{
560 return !(*this < e); 1013 return !(*this < e);
561} 1014}
562 1015
1016/*!
1017 \internal
1018*/
563void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) 1019void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
564{ 1020{
565 if ( !from.isValid() ) { 1021 if ( !from.isValid() ) {
@@ -573,6 +1029,9 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
573 d->endDate = to; 1029 d->endDate = to;
574} 1030}
575 1031
1032/*!
1033 \internal
1034*/
576QDate EffectiveEvent::startDate() const 1035QDate EffectiveEvent::startDate() const
577{ 1036{
578 if ( d ) 1037 if ( d )
@@ -583,6 +1042,9 @@ QDate EffectiveEvent::startDate() const
583 return mEvent.start().date(); 1042 return mEvent.start().date();
584} 1043}
585 1044
1045/*!
1046 \internal
1047*/
586QDate EffectiveEvent::endDate() const 1048QDate EffectiveEvent::endDate() const
587{ 1049{
588 if ( d ) 1050 if ( d )
@@ -593,6 +1055,9 @@ QDate EffectiveEvent::endDate() const
593 return mEvent.end().date(); 1055 return mEvent.end().date();
594} 1056}
595 1057
1058/*!
1059 \internal
1060*/
596int EffectiveEvent::size() const 1061int EffectiveEvent::size() const
597{ 1062{
598 return ( mEnd.hour() - mStart.hour() ) * 3600 1063 return ( mEnd.hour() - mStart.hour() ) * 3600
@@ -740,15 +1205,23 @@ static Event parseVObject( VObject *obj )
740} 1205}
741 1206
742 1207
743 1208/*!
1209 Writes the list of \a events as a set of VCards to the file \a filename.
1210*/
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;
753 for( it = events.begin(); it != events.end(); ++it ) { 1226 for( it = events.begin(); it != events.end(); ++it ) {
754 VObject *obj = createVObject( *it ); 1227 VObject *obj = createVObject( *it );
@@ -756,17 +1229,27 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev
756 cleanVObject( obj ); 1229 cleanVObject( obj );
757 } 1230 }
758 1231
1232
759 cleanStrTbl(); 1233 cleanStrTbl();
760} 1234}
761 1235
1236/*!
1237 Writes \a event as a VCard to the file \a filename.
1238*/
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 );
771 writeVObject( f.directHandle() , obj ); 1254 writeVObject( f.directHandle() , obj );
772 cleanVObject( obj ); 1255 cleanVObject( obj );
@@ -774,7 +1257,9 @@ void Event::writeVCalendar( const QString &filename, const Event &event)
774 cleanStrTbl(); 1257 cleanStrTbl();
775} 1258}
776 1259
777 1260/*!
1261 Returns the set of events read as VCards from the file \a filename.
1262*/
778QValueList<Event> Event::readVCalendar( const QString &filename ) 1263QValueList<Event> Event::readVCalendar( const QString &filename )
779{ 1264{
780 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1265 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -23,22 +23,31 @@
23 23
24#include <qdatetime.h> 24#include <qdatetime.h>
25#include <qvaluelist.h> 25#include <qvaluelist.h>
26#include <qcolor.h>
26 27
27#ifdef PALMTOPCENTER 28#ifdef PALMTOPCENTER
28#include <qpc/qsorter.h> 29#include <qpc/qsorter.h>
29#endif 30#endif
30#include <qpe/palmtoprecord.h> 31#include <qtopia/private/palmtoprecord.h>
31 32
32#include <qpe/timeconversion.h> 33#include <qpe/timeconversion.h>
33 34
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;
35class QPC_EXPORT Event : public Qtopia::Record 41class QPC_EXPORT Event : public Qtopia::Record
36{ 42{
37public: 43public:
38 enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay, 44 enum RepeatType { NoRepeat = -1, Daily, Weekly, MonthlyDay,
39 MonthlyDate, Yearly }; 45 MonthlyDate, Yearly };
46
47 // Don't use this.
40 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, 48 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
41 FRI = 0x10, SAT = 0x20, SUN = 0x40 }; 49 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
50 // Don't use this.
42 struct QPC_EXPORT RepeatPattern 51 struct QPC_EXPORT RepeatPattern
43 { 52 {
44 RepeatPattern() { 53 RepeatPattern() {
@@ -70,6 +79,7 @@ public:
70 enum Type { Normal, AllDay }; 79 enum Type { Normal, AllDay };
71 enum SoundTypeChoice { Silent, Loud }; 80 enum SoundTypeChoice { Silent, Loud };
72 81
82 // Don't use these, there are essentially meaningless.
73 bool operator<( const Event &e1) const { return start() < e1.start(); }; 83 bool operator<( const Event &e1) const { return start() < e1.start(); };
74 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); }; 84 bool operator<=( const Event &e1 ) const { return start() <= e1.start(); };
75 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); }; 85 bool operator!=( const Event &e1 ) const { return !( *this == e1 ); };
@@ -83,34 +93,63 @@ public:
83 void setLocation( const QString &s ); 93 void setLocation( const QString &s );
84 const QString &location() const; 94 const QString &location() const;
85 95
86 void setType( Type t ); 96 void setNotes( const QString &n );
87 Type type() const; 97 const QString &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 );
103 void setRepeat( const RepeatPattern &p ); 140 void setRepeat( const RepeatPattern &p );
104 bool hasRepeat() const; 141 bool hasRepeat() const;
105 const RepeatPattern &repeatPattern() const; 142 const RepeatPattern &repeatPattern() const;
106 RepeatPattern &repeatPattern(); 143 RepeatPattern &repeatPattern();
107 void setNotes( const QString &n );
108 const QString &notes() const;
109 bool doRepeat() const { return pattern.type != NoRepeat; } 144 bool doRepeat() const { return pattern.type != NoRepeat; }
110 145
111 void save( QString& buf ); 146 void save( QString& buf );
112 //void load( Node *n ); 147 //void load( Node *n );
113 148
149 bool match( const QRegExp &r ) const;
150
151 // Don't use these either. Functionality will be moved elsewhere.
152
114 // helper function to calculate the week of the given date 153 // helper function to calculate the week of the given date
115 static int week( const QDate& date ); 154 static int week( const QDate& date );
116 // calculates the number of occurrences of the week day of 155 // calculates the number of occurrences of the week day of
@@ -123,7 +162,6 @@ public:
123 static int dayOfWeek( char day ); 162 static int dayOfWeek( char day );
124 // returns the difference of months from first to second. 163 // returns the difference of months from first to second.
125 static int monthDiff( const QDate& first, const QDate& second ); 164 static int monthDiff( const QDate& first, const QDate& second );
126 bool match( const QRegExp &r ) const;
127 165
128private: 166private:
129 Qtopia::UidGen &uidGen() { return sUidGen; } 167 Qtopia::UidGen &uidGen() { return sUidGen; }
@@ -211,6 +249,109 @@ private:
211 249
212}; 250};
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
215class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent> 356class QPC_EXPORT EffectiveEventSizeSorter : public QSorter<EffectiveEvent>
216{ 357{
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,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** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free 7** GNU General Public License version 2 as published by the Free Software
8** Software Foundation and appearing in the file LICENSE.GPL included 8** Foundation and appearing in the file LICENSE.GPL included in the
9** in the packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** PARTICULAR PURPOSE.
14** 13**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 15**
@@ -18,12 +17,24 @@
18** not clear to you. 17** not clear to you.
19** 18**
20**********************************************************************/ 19**********************************************************************/
21#include "palmtoprecord.h" 20#include <qtopia/private/palmtoprecord.h>
22#include "stringutil.h" 21#include <qtopia/stringutil.h>
23#include <qstringlist.h> 22#include <qstringlist.h>
24 23
24/*! \class Qtopia::PalmtopRecord palmtoprecord.h
25 \brief The Qtopia::PalmtopRecord class is the base class for all PIM records.
26
27 Provides unique id and category support for all PIM records.
28
29 \ingroup qtopiaemb
30 \ingroup qtopiadesktop
31*/
32
33
25namespace Qtopia { 34namespace Qtopia {
26 35
36
37
27Record &Record::operator=( const Record &c ) 38Record &Record::operator=( const Record &c )
28{ 39{
29 mUid = c.mUid; 40 mUid = c.mUid;
@@ -41,8 +52,11 @@ void Record::setCategories( int single )
41} 52}
42 53
43// convenience methods provided for loading and saving to xml 54// convenience methods provided for loading and saving to xml
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;
47 for ( uint i = 0; i < cats.size(); i++ ) 61 for ( uint i = 0; i < cats.size(); i++ )
48 if ( i == 0 ) 62 if ( i == 0 )
@@ -84,13 +98,13 @@ QString Record::customField( const QString &key) const
84 */ 98 */
85void Record::setCustomField( const QString &key, const QString &value) 99void Record::setCustomField( const QString &key, const QString &value)
86{ 100{
87 qWarning("setting custom " + key + " to " + value); 101// qWarning("setting custom " + key + " to " + value);
88 if (customMap.contains(key)) 102 if (customMap.contains(key))
89 customMap.replace(key, value); 103 customMap.replace(key, value);
90 else 104 else
91 customMap.insert(key, value); 105 customMap.insert(key, value);
92 106
93 qWarning(QString("custom size %1").arg(customMap.count())); 107// qWarning(QString("custom size %1").arg(customMap.count()));
94} 108}
95 109
96/*! 110/*!
@@ -107,7 +121,7 @@ QString Record::customToXml() const
107 QString buf(" "); 121 QString buf(" ");
108 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 122 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
109 cit != customMap.end(); ++cit) { 123 cit != customMap.end(); ++cit) {
110 qWarning(".ITEM."); 124 // qWarning(".ITEM.");
111 buf += cit.key(); 125 buf += cit.key();
112 buf += "=\""; 126 buf += "=\"";
113 buf += escapeString(cit.data()); 127 buf += escapeString(cit.data());
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,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** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free 7** GNU General Public License version 2 as published by the Free Software
8** Software Foundation and appearing in the file LICENSE.GPL included 8** Foundation and appearing in the file LICENSE.GPL included in the
9** in the packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** PARTICULAR PURPOSE.
14** 13**
15** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
16** 15**
@@ -18,10 +17,8 @@
18** not clear to you. 17** not clear to you.
19** 18**
20**********************************************************************/ 19**********************************************************************/
21
22#ifndef QTPALMTOP_RECORD_H 20#ifndef QTPALMTOP_RECORD_H
23#define QTPALMTOP_RECORD_H 21#define QTPALMTOP_RECORD_H
24
25#include <qglobal.h> 22#include <qglobal.h>
26#include "qpcglobal.h" 23#include "qpcglobal.h"
27#include "palmtopuidgen.h" 24#include "palmtopuidgen.h"
@@ -30,7 +27,7 @@
30 27
31#if defined(QPC_TEMPLATEDLL) 28#if defined(QPC_TEMPLATEDLL)
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
35#endif 32#endif
36 33
@@ -49,10 +46,17 @@ public:
49 46
50 virtual bool match( const QRegExp & ) const { return FALSE; } 47 virtual bool match( const QRegExp & ) const { return FALSE; }
51 48
52 void setCategories( const QArray<int> &v ) { mCats = v; } 49 void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); }
53 void setCategories( int single ); 50 void setCategories( int single );
54 const QArray<int> &categories() const { return mCats; } 51 const QArray<int> &categories() const { return mCats; }
55 52
53 void reassignCategoryId( int oldId, int newId )
54 {
55 int index = mCats.find( oldId );
56 if ( index >= 0 )
57 mCats[index] = newId;
58 }
59
56 int uid() const { return mUid; }; 60 int uid() const { return mUid; };
57 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); } 61 virtual void setUid( int i ) { mUid = i; uidGen().store( mUid ); }
58 bool isValidUid() const { return mUid != 0; } 62 bool isValidUid() const { return mUid != 0; }
@@ -77,18 +81,15 @@ public:
77 81
78protected: 82protected:
79 virtual UidGen &uidGen() = 0; 83 virtual UidGen &uidGen() = 0;
80
81 virtual QString customToXml() const; 84 virtual QString customToXml() const;
82
83private: 85private:
84 int mUid; 86 int mUid;
85 QArray<int> mCats; 87 QArray<int> mCats;
86
87 QMap<QString, QString> customMap; 88 QMap<QString, QString> customMap;
88
89 RecordPrivate *d; 89 RecordPrivate *d;
90}; 90};
91 91
92} 92}
93 93
94#endif 94#endif
95
diff --git a/library/backend/palmtopuidgen.h b/library/backend/palmtopuidgen.h
index 1a16681..c3fbcb9 100644
--- a/library/backend/palmtopuidgen.h
+++ b/library/backend/palmtopuidgen.h
@@ -1,33 +1,33 @@
1#ifndef QTPALMTOP_UIDGEN_H
2#define QTPALMTOP_UIDGEN_H
3/********************************************************************** 1/**********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
5** 3**
6** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
7** 5**
8** Licensees holding valid Qtopia Developer license may use this 6** This file may be distributed and/or modified under the terms of the
9** file in accordance with the Qtopia Developer License Agreement 7** GNU General Public License version 2 as published by the Free Software
10** provided with the Software. 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
11** 10**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14** PURPOSE.
15** 13**
16** email sales@trolltech.com for information about Qtopia License 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
17** Agreements.
18** 15**
19** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
20** not clear to you. 17** not clear to you.
21** 18**
22**********************************************************************/ 19**********************************************************************/
23 20
21#ifndef QTPALMTOP_UIDGEN_H
22#define QTPALMTOP_UIDGEN_H
23
24#include <time.h> 24#include <time.h>
25#include <qmap.h> 25#include <qmap.h>
26#include "qpcglobal.h" 26#include "qpcglobal.h"
27 27
28#if defined(QPC_TEMPLATEDLL) 28#if defined(QPC_TEMPLATEDLL)
29// MOC_SKIP_BEGIN 29// MOC_SKIP_BEGIN
30template class QPC_EXPORT QMap< int, bool >; 30QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap< int, bool >;
31// MOC_SKIP_END 31// MOC_SKIP_END
32#endif 32#endif
33 33
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,18 +1,17 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** Licensees holding valid Qtopia Developer license may use this 6** This file may be distributed and/or modified under the terms of the
7** file in accordance with the Qtopia Developer License Agreement 7** GNU General Public License version 2 as published by the Free Software
8** provided with the Software. 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
9** 10**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** PURPOSE.
13** 13**
14** email sales@trolltech.com for information about Qtopia License 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** Agreements.
16** 15**
17** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 17** not clear to you.
@@ -22,7 +21,7 @@
22#ifndef QFILE_DIRECT_H 21#ifndef QFILE_DIRECT_H
23#define QFILE_DIRECT_H 22#define QFILE_DIRECT_H
24#include <qfile.h> 23#include <qfile.h>
25#include <qpe/qpcglobal.h> 24#include <qtopia/private/qpcglobal.h>
26 25
27class QPC_EXPORT QFileDirect : public QFile 26class QPC_EXPORT QFileDirect : public QFile
28{ 27{
@@ -34,4 +33,3 @@ public:
34}; 33};
35 34
36#endif 35#endif
37
diff --git a/library/backend/qpcglobal.h b/library/backend/qpcglobal.h
index 0d60272..7b71f06 100644
--- a/library/backend/qpcglobal.h
+++ b/library/backend/qpcglobal.h
@@ -1,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** Licensees holding valid Qtopia Developer license may use this 6** Licensees holding valid Qtopia Developer license may use this
7** file in accordance with the Qtopia Developer License Agreement 7** file in accordance with the Qtopia Developer License Agreement
@@ -22,8 +22,9 @@
22#ifndef QPC_GLOBAL_H 22#ifndef QPC_GLOBAL_H
23#define QPC_GLOBAL_H 23#define QPC_GLOBAL_H
24 24
25#if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER)
26#include <qglobal.h> 25#include <qglobal.h>
26
27#if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER)
27// # if defined(QT_NODLL) 28// # if defined(QT_NODLL)
28//# undef QPC_MAKEDLL 29//# undef QPC_MAKEDLL
29//# undef QPC_DLL 30//# undef QPC_DLL
@@ -32,10 +33,12 @@
32# undef QPC_DLL 33# undef QPC_DLL
33# endif 34# endif
34# define QPC_EXPORT __declspec(dllexport) 35# define QPC_EXPORT __declspec(dllexport)
36# define QPC_TEMPLATEEXTERN
35# define QPC_TEMPLATEDLL 37# define QPC_TEMPLATEDLL
36 # undef QPC_DISABLE_COPY/* avoid unresolved externals */ 38 # undef QPC_DISABLE_COPY/* avoid unresolved externals */
37 # elif defined(QPC_DLL) /* use a Qt DLL library */ 39 # elif defined(QPC_DLL) /* use a Qt DLL library */
38# define QPC_EXPORT __declspec(dllimport) 40# define QPC_EXPORT __declspec(dllimport)
41# define QPC_TEMPLATEEXTERN extern
39# define QPC_TEMPLATEDLL 42# define QPC_TEMPLATEDLL
40 # undef QPC_DISABLE_COPY/* avoid unresolved externals */ 43 # undef QPC_DISABLE_COPY/* avoid unresolved externals */
41# endif 44# endif
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,18 +1,17 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** Licensees holding valid Qtopia Developer license may use this 6** This file may be distributed and/or modified under the terms of the
7** file in accordance with the Qtopia Developer License Agreement 7** GNU General Public License version 2 as published by the Free Software
8** provided with the Software. 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
9** 10**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** PURPOSE.
13** 13**
14** email sales@trolltech.com for information about Qtopia License 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** Agreements.
16** 15**
17** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
18** not clear to you. 17** not clear to you.
@@ -88,9 +87,10 @@ namespace Qtopia
88 87
89 // other 88 // other
90 Notes, 89 Notes,
91 Groups
92 90
93 ,rid, 91 // used for internal record keeping, not for end user.
92 Groups,
93 rid,
94 rinfo 94 rinfo
95 }; 95 };
96 96
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -18,25 +18,124 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qpe/task.h> 21#include "task.h"
22#include <qregexp.h> 22#include "recordfields.h"
23#include <qstring.h>
24#include <qpe/recordfields.h>
25#include "vobject_p.h" 23#include "vobject_p.h"
26#include "timeconversion.h"
27#include "qfiledirect_p.h" 24#include "qfiledirect_p.h"
28 25
26#include <qtopia/timeconversion.h>
27
28#include <qregexp.h>
29#include <qstring.h>
30
29#include <stdio.h> 31#include <stdio.h>
30 32
31using namespace Qtopia; 33using namespace Qtopia;
32UidGen Task::sUidGen( UidGen::Qtopia ); 34UidGen 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 ),
35mDueDate( QDate::currentDate() ), 51mDueDate( QDate::currentDate() ),
36mCompleted( FALSE ), mPriority( 3 ), mDesc() 52mCompleted( FALSE ), mPriority( 3 ), mDesc()
37{ 53{
38} 54}
39 55
56/*!
57 \fn void Task::setPriority( int priority )
58
59 Sets the priority of the task to \a priority.
60*/
61
62/*!
63 \fn int Task::priority() const
64
65 Returns the priority of the task.
66*/
67
68/*!
69 \fn void Task::setDescription( const QString &description )
70
71 Sets the description of the task to \a description.
72 */
73
74/*!
75 \fn const QString &Task::description() const
76
77 Returns the description of the task.
78 */
79
80/*!
81 \fn void Task::setDueDate( const QDate &date, bool hasDue )
82
83 \internal
84 If \a hasDue is TRUE sets the due date of the task to \a date.
85 Otherwise clears the due date of the task.
86*/
87
88/*!
89 \fn void Task::setDueDate( const QDate &date )
90
91 Sets the due date of the task to \a date.
92*/
93
94/*!
95 \fn void Task::clearDueDate( )
96
97 Clears the due date of the task.
98*/
99
100/*!
101 \fn void Task::setCompleted( bool b )
102
103 If \a b is TRUE marks the task as completed. Otherwise marks the task as
104 uncompleted.
105*/
106
107/*!
108 \fn bool Task::isCompleted() const
109
110 Returns TRUE if the task is completed. Otherwise returns FALSE.
111*/
112
113/*!
114 \fn const QDate &Task::dueDate() const
115
116 Returns the due date of the task.
117 */
118
119/*!
120 \fn bool Task::hasDueDate() const
121
122 Returns TRUE if there is a due date set for the task. Otherwise returns
123 FALSE.
124*/
125
126/*!
127 \fn void Task::setHasDueDate( bool b )
128
129 \internal
130 Just don't ask. I really can't justify the function.
131*/
132
133
134/*!
135 \internal
136 Creates a new task. The properties of the task are set from \a m.
137*/
138
40Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), 139Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ),
41mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() 140mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
42{ 141{
@@ -51,22 +150,34 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc()
51 case Priority: setPriority( (*it).toInt() ); break; 150 case Priority: setPriority( (*it).toInt() ); break;
52 case Date: mDueDate = TimeConversion::fromString( (*it) ); break; 151 case Date: mDueDate = TimeConversion::fromString( (*it) ); break;
53 case TaskUid: setUid( (*it).toInt() ); break; 152 case TaskUid: setUid( (*it).toInt() ); break;
54 default: break; 153 case TaskRid:
154 case TaskRinfo:
155 break;
55 } 156 }
56} 157}
57 158
159/*!
160 Destroys a task.
161*/
58Task::~Task() 162Task::~Task()
59{ 163{
60} 164}
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
63{ 171{
64 QMap<int, QString> m; 172 QMap<int, QString> m;
65 m.insert( HasDate, hasDueDate() ? "1" : "0" ); 173 m.insert( HasDate, hasDueDate() ? "1" : "0" );
66 m.insert( Completed, isCompleted() ? "1" : "0" ); 174 m.insert( Completed, isCompleted() ? "1" : "0" );
175 if ( categories().count() )
67 m.insert( TaskCategory, idsToString( categories() ) ); 176 m.insert( TaskCategory, idsToString( categories() ) );
177 if ( !description().isEmpty() )
68 m.insert( TaskDescription, description() ); 178 m.insert( TaskDescription, description() );
69 m.insert( Priority, QString::number( priority() ) ); 179 m.insert( Priority, QString::number( priority() ) );
180 if ( hasDueDate() )
70 m.insert( Date, TimeConversion::toString( dueDate() ) ); 181 m.insert( Date, TimeConversion::toString( dueDate() ) );
71 m.insert( TaskUid, QString::number(uid()) ); 182 m.insert( TaskUid, QString::number(uid()) );
72 183
@@ -75,6 +186,10 @@ QMap<int, QString> Task::toMap() const
75 return m; 186 return m;
76} 187}
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
79{ 194{
80 buf += " Completed=\""; 195 buf += " Completed=\"";
@@ -117,20 +232,27 @@ void Task::save( QString& buf ) const
117 buf += "\""; 232 buf += "\"";
118} 233}
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{
122 // match on priority, description on due date... 241 // match on priority, description on due date...
123 bool match; 242 bool match;
124 match = false; 243 match = false;
125 if ( QString::number( mPriority ).find( r ) > -1 ) 244 if ( QString::number( mPriority ).find( regexp ) > -1 )
126 match = true; 245 match = true;
127 else if ( mDue && mDueDate.toString().find( r ) > -1 ) 246 else if ( mDue && mDueDate.toString().find( regexp ) > -1 )
128 match = true; 247 match = true;
129 else if ( mDesc.find( r ) > -1 ) 248 else if ( mDesc.find( regexp ) > -1 )
130 match = true; 249 match = true;
131 return match; 250 return match;
132} 251}
133 252
253/*!
254 \internal
255*/
134static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) 256static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value )
135{ 257{
136 VObject *ret = 0; 258 VObject *ret = 0;
@@ -139,6 +261,9 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt
139 return ret; 261 return ret;
140} 262}
141 263
264/*!
265 \internal
266*/
142static inline VObject *safeAddProp( VObject *o, const char *prop) 267static inline VObject *safeAddProp( VObject *o, const char *prop)
143{ 268{
144 VObject *ret = 0; 269 VObject *ret = 0;
@@ -148,6 +273,9 @@ static inline VObject *safeAddProp( VObject *o, const char *prop)
148} 273}
149 274
150 275
276/*!
277 \internal
278*/
151static VObject *createVObject( const Task &t ) 279static VObject *createVObject( const Task &t )
152{ 280{
153 VObject *vcal = newVObject( VCCalProp ); 281 VObject *vcal = newVObject( VCCalProp );
@@ -164,7 +292,9 @@ static VObject *createVObject( const Task &t )
164 return vcal; 292 return vcal;
165} 293}
166 294
167 295/*!
296 \internal
297*/
168static Task parseVObject( VObject *obj ) 298static Task parseVObject( VObject *obj )
169{ 299{
170 Task t; 300 Task t;
@@ -207,7 +337,9 @@ static Task parseVObject( VObject *obj )
207} 337}
208 338
209 339
210 340/*!
341 Writes the list of \a tasks as a set of VCards to the file \a filename.
342*/
211void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) 343void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks)
212{ 344{
213 QFileDirect f( filename.utf8().data() ); 345 QFileDirect f( filename.utf8().data() );
@@ -226,6 +358,9 @@ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &task
226 cleanStrTbl(); 358 cleanStrTbl();
227} 359}
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)
230{ 365{
231 QFileDirect f( filename.utf8().data() ); 366 QFileDirect f( filename.utf8().data() );
@@ -241,7 +376,9 @@ void Task::writeVCalendar( const QString &filename, const Task &task)
241 cleanStrTbl(); 376 cleanStrTbl();
242} 377}
243 378
244 379/*!
380 Returns the set of tasks read as VCards from the file \a filename.
381*/
245QValueList<Task> Task::readVCalendar( const QString &filename ) 382QValueList<Task> Task::readVCalendar( const QString &filename )
246{ 383{
247 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 384 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -20,8 +20,8 @@
20#ifndef __TASK_H__ 20#ifndef __TASK_H__
21#define __TASK_H__ 21#define __TASK_H__
22 22
23#include <qpe/palmtoprecord.h> 23#include <qtopia/private/palmtoprecord.h>
24#include <qpe/stringutil.h> 24#include <qtopia/stringutil.h>
25 25
26#include <qvaluelist.h> 26#include <qvaluelist.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
@@ -40,6 +40,8 @@ public:
40 static void writeVCalendar( const QString &filename, const Task &task); 40 static void writeVCalendar( const QString &filename, const Task &task);
41 static QValueList<Task> readVCalendar( const QString &filename ); 41 static QValueList<Task> readVCalendar( const QString &filename );
42 42
43 enum PriorityValue { VeryHigh=1, High, Normal, Low, VeryLow };
44
43 void setPriority( int priority ) { mPriority = priority; } 45 void setPriority( int priority ) { mPriority = priority; }
44 int priority() const { return mPriority; } 46 int priority() const { return mPriority; }
45 47
@@ -51,10 +53,16 @@ public:
51 { mDesc = Qtopia::simplifyMultiLineSpace(description); } 53 { mDesc = Qtopia::simplifyMultiLineSpace(description); }
52 const QString &description() const { return mDesc; } 54 const QString &description() const { return mDesc; }
53 55
56 // Use THESE functions
57 void setDueDate( const QDate &date);
58 void clearDueDate();
59
60 // Instead of these functions.
54 void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } 61 void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; }
62 void setHasDueDate( bool b ) { mDue = b; }
63
55 const QDate &dueDate() const { return mDueDate; } 64 const QDate &dueDate() const { return mDueDate; }
56 bool hasDueDate() const { return mDue; } 65 bool hasDueDate() const { return mDue; }
57 void setHasDueDate( bool b ) { mDue = b; }
58 66
59 void setCompleted( bool b ) { mCompleted = b; } 67 void setCompleted( bool b ) { mCompleted = b; }
60 bool isCompleted() const { return mCompleted; } 68 bool isCompleted() const { return mCompleted; }
@@ -78,4 +86,7 @@ private:
78 // 86 //
79}; 87};
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
@@ -517,7 +517,7 @@ static int lexWithinMode(enum LexMode mode) {
517 return 0; 517 return 0;
518 } 518 }
519 519
520static char lexGetc_() 520static int lexGetc_()
521 { 521 {
522 /* get next char from input, no buffering. */ 522 /* get next char from input, no buffering. */
523 if (lexBuf.curPos == lexBuf.inputLen) 523 if (lexBuf.curPos == lexBuf.inputLen)
@@ -931,60 +931,69 @@ static int match_begin_end_name(int end) {
931 931
932static char* lexGetQuotedPrintable() 932static 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
989static int yylex() { 998static int yylex() {
990 999
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,5 +1,6 @@
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
4#define YYBYACC 1 5#define YYBYACC 1
5#define YYMAJOR 1 6#define YYMAJOR 1
@@ -7,8 +8,32 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
7#define yyclearin (yychar=(-1)) 8#define yyclearin (yychar=(-1))
8#define yyerrok (yyerrflag=0) 9#define yyerrok (yyerrflag=0)
9#define YYRECOVERING (yyerrflag!=0) 10#define YYRECOVERING (yyerrflag!=0)
10#define YYPREFIX "yy" 11#define yyparse vccparse
11#line 1 "vcc.y" 12#define yylex vcclex
13#define yyerror vccerror
14#define yychar vccchar
15#define yyval vccval
16#define yylval vcclval
17#define yydebug vccdebug
18#define yynerrs vccnerrs
19#define yyerrflag vccerrflag
20#define yyss vccss
21#define yyssp vccssp
22#define yyvs vccvs
23#define yyvsp vccvsp
24#define yylhs vcclhs
25#define yylen vcclen
26#define yydefred vccdefred
27#define yydgoto vccdgoto
28#define yysindex vccsindex
29#define yyrindex vccrindex
30#define yygindex vccgindex
31#define yytable vcctable
32#define yycheck vcccheck
33#define yyname vccname
34#define yyrule vccrule
35#define YYPREFIX "vcc"
36#line 1 "backend/vcc.y"
12 37
13 38
14/*************************************************************************** 39/***************************************************************************
@@ -73,6 +98,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
73 we can use more than one yacc based parser. 98 we can use more than one yacc based parser.
74*/ 99*/
75 100
101#if 0
76#define yyparse mime_parse 102#define yyparse mime_parse
77#define yylex mime_lex 103#define yylex mime_lex
78#define yyerror mime_error 104#define yyerror mime_error
@@ -105,6 +131,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
105#undef YYPREFIX 131#undef YYPREFIX
106#endif 132#endif
107#define YYPREFIX "mime_" 133#define YYPREFIX "mime_"
134#endif
108 135
109 136
110#ifndef _NO_LINE_FOLDING 137#ifndef _NO_LINE_FOLDING
@@ -128,20 +155,17 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
128#include <stdlib.h> 155#include <stdlib.h>
129#include <ctype.h> 156#include <ctype.h>
130 157
131#ifdef PALMTOPCENTER 158/*#ifdef PALMTOPCENTER */
132#include <qpe/vobject_p.h> 159/*#include <qpe/vobject_p.h> */
133#include <qpe/qfiledirect_p.h> 160/*#else */
134#else
135#include "vobject_p.h" 161#include "vobject_p.h"
136#include "qfiledirect_p.h" 162/*#endif */
137#endif
138 163
139/**** Types, Constants ****/ 164/**** Types, Constants ****/
140 165
141 #define YYDEBUG 0/* 1 to compile in some debugging code */ 166 #define YYDEBUG 0/* 1 to compile in some debugging code */
142 #define MAXTOKEN 256/* maximum token (line) length */ 167 #define MAXTOKEN 256/* maximum token (line) length */
143 #define YYSTACKSIZE 100/* ~unref ? 168 #define YYSTACKSIZE 100/* ~unref ? */
144*/
145 #define MAXLEVEL 10/* max # of nested objects parseable */ 169 #define MAXLEVEL 10/* max # of nested objects parseable */
146 /* (includes outermost) */ 170 /* (includes outermost) */
147 171
@@ -188,14 +212,16 @@ static void lexPushMode(enum LexMode mode);
188static void enterProps(const char *s); 212static void enterProps(const char *s);
189static void enterAttr(const char *s1, const char *s2); 213static 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 {
195 char *str; 221 char *str;
196 VObject *vobj; 222 VObject *vobj;
197 } YYSTYPE; 223 } YYSTYPE;
198#line 196 "y.tab.c" 224#line 225 "y.tab.c"
199#define EQ 257 225#define EQ 257
200#define COLON 258 226#define COLON 258
201#define DOT 259 227#define DOT 259
@@ -215,21 +241,21 @@ typedef union {
215#define ID 273 241#define ID 273
216#define STRING 274 242#define STRING 274
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,
220 7, 13, 10, 10, 15, 11, 11, 14, 14, 16, 246 7, 13, 10, 10, 15, 11, 11, 14, 14, 16,
221 17, 17, 1, 18, 12, 12, 2, 2, 20, 4, 247 17, 17, 1, 18, 12, 12, 2, 2, 20, 4,
222 21, 4, 19, 19, 22, 22, 22, 25, 23, 26, 248 21, 4, 19, 19, 22, 22, 22, 25, 23, 26,
223 23, 27, 24, 28, 24, 249 23, 27, 24, 28, 24,
224}; 250};
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,
227 1, 0, 5, 1, 0, 3, 1, 2, 1, 2, 253 1, 0, 5, 1, 0, 3, 1, 2, 1, 2,
228 1, 3, 1, 0, 4, 1, 1, 0, 0, 4, 254 1, 3, 1, 0, 4, 1, 1, 0, 0, 4,
229 0, 3, 2, 1, 1, 1, 1, 0, 4, 0, 255 0, 3, 2, 1, 1, 1, 1, 0, 4, 0,
230 3, 0, 4, 0, 3, 256 3, 0, 4, 0, 3,
231}; 257};
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,
234 0, 2, 14, 23, 0, 0, 11, 0, 9, 0, 260 0, 2, 14, 23, 0, 0, 11, 0, 9, 0,
235 0, 0, 0, 34, 35, 36, 32, 0, 7, 10, 261 0, 0, 0, 34, 35, 36, 32, 0, 7, 10,
@@ -237,12 +263,12 @@ short yydefred[] = { 0,
237 0, 0, 41, 0, 45, 0, 20, 18, 27, 0, 263 0, 0, 41, 0, 45, 0, 20, 18, 27, 0,
238 0, 39, 43, 0, 24, 13, 22, 0, 25, 264 0, 39, 43, 0, 24, 13, 22, 0, 25,
239}; 265};
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,
242 18, 51, 41, 39, 28, 40, 47, 58, 23, 10, 268 18, 51, 41, 39, 28, 40, 47, 58, 23, 10,
243 11, 24, 25, 26, 32, 33, 34, 35, 269 11, 24, 25, 26, 32, 33, 34, 35,
244}; 270};
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,
247 -256, 0, 0, 0, 0, -227, 0, -242, 0, 0, 273 -256, 0, 0, 0, 0, -227, 0, -242, 0, 0,
248 0, -252, -254, 0, 0, 0, 0, -208, 0, 0, 274 0, -252, -254, 0, 0, 0, 0, -208, 0, 0,
@@ -250,7 +276,7 @@ short yysindex[] = { -262,
250 -214, -233, 0, -224, 0, -195, 0, 0, 0, -197, 276 -214, -233, 0, -224, 0, -195, 0, 0, 0, -197,
251 -199, 0, 0, -212, 0, 0, 0, -214, 0, 277 -199, 0, 0, -212, 0, 0, 0, -214, 0,
252}; 278};
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,
255 0, 0, 0, 0, -215, 0, 0, 0, 0, -220, 281 0, 0, 0, 0, -215, 0, 0, 0, 0, -220,
256 -218, -260, 0, 0, 0, 0, 0, 0, 0, 0, 282 -218, -260, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -258,13 +284,13 @@ short yyrindex[] = { 0,
258 -250, 0, 0, 0, 0, -202, 0, 0, 0, -196, 284 -250, 0, 0, 0, 0, -202, 0, 0, 0, -196,
259 0, 0, 0, 0, 0, 0, 0, -250, 0, 285 0, 0, 0, 0, 0, 0, 0, -250, 0,
260}; 286};
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,
263 0, 11, 0, 0, 0, 31, 0, 0, 0, 0, 289 0, 11, 0, 0, 0, 31, 0, 0, 0, 0,
264 0, 48, 0, 0, 0, 0, 0, 0, 290 0, 48, 0, 0, 0, 0, 0, 0,
265}; 291};
266#define YYTABLESIZE 71 292#define YYTABLESIZE 71
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,
269 37, 27, 28, 36, 20, 31, 21, 29, 14, 20, 295 37, 27, 28, 36, 20, 31, 21, 29, 14, 20,
270 14, 21, 13, 14, 42, 30, 44, 30, 13, 31, 296 14, 21, 13, 14, 42, 30, 44, 30, 13, 31,
@@ -274,7 +300,7 @@ short yytable[] = { 30,
274 14, 54, 55, 56, 1, 16, 26, 12, 59, 48, 300 14, 54, 55, 56, 1, 16, 26, 12, 59, 48,
275 37, 301 37,
276}; 302};
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,
279 271, 268, 263, 268, 269, 258, 271, 256, 273, 269, 305 271, 268, 263, 268, 269, 258, 271, 256, 273, 269,
280 273, 271, 256, 273, 32, 42, 34, 44, 256, 268, 306 273, 271, 256, 273, 32, 42, 34, 44, 256, 268,
@@ -290,7 +316,7 @@ short yycheck[] = { 16,
290#endif 316#endif
291#define YYMAXTOKEN 274 317#define YYMAXTOKEN 274
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,
2950,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3210,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
2960,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 3220,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -301,7 +327,7 @@ char *yyname[] = {
301"SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL", 327"SPACE","HTAB","LINESEP","NEWLINE","BEGIN_VCARD","END_VCARD","BEGIN_VCAL",
302"END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING", 328"END_VCAL","BEGIN_VEVENT","END_VEVENT","BEGIN_VTODO","END_VTODO","ID","STRING",
303}; 329};
304char *yyrule[] = { 330char *vccrule[] = {
305"$accept : mime", 331"$accept : mime",
306"mime : vobjects", 332"mime : vobjects",
307"vobjects : vobjects vobject", 333"vobjects : vobjects vobject",
@@ -372,7 +398,7 @@ YYSTYPE yylval;
372short yyss[YYSTACKSIZE]; 398short yyss[YYSTACKSIZE];
373YYSTYPE yyvs[YYSTACKSIZE]; 399YYSTYPE yyvs[YYSTACKSIZE];
374#define yystacksize YYSTACKSIZE 400#define yystacksize YYSTACKSIZE
375#line 378 "vcc.y" 401#line 382 "backend/vcc.y"
376 402
377/*------------------------------------*/ 403/*------------------------------------*/
378static int pushVObject(const char *prop) 404static int pushVObject(const char *prop)
@@ -511,7 +537,7 @@ static int lexWithinMode(enum LexMode mode) {
511 return 0; 537 return 0;
512 } 538 }
513 539
514static char lexGetc_() 540static int lexGetc_()
515 { 541 {
516 /* get next char from input, no buffering. */ 542 /* get next char from input, no buffering. */
517 if (lexBuf.curPos == lexBuf.inputLen) 543 if (lexBuf.curPos == lexBuf.inputLen)
@@ -925,7 +951,7 @@ static int match_begin_end_name(int end) {
925 951
926static char* lexGetQuotedPrintable() 952static char* lexGetQuotedPrintable()
927 { 953 {
928 char cur; 954 int cur;
929 955
930 lexClearToken(); 956 lexClearToken();
931 do { 957 do {
@@ -967,13 +993,13 @@ static char* lexGetQuotedPrintable()
967 lexPushLookaheadc('\n'); 993 lexPushLookaheadc('\n');
968 goto EndString; 994 goto EndString;
969 } 995 }
970 case (char)EOF: 996 case (int)EOF:
971 break; 997 break;
972 default: 998 default:
973 lexAppendc(cur); 999 lexAppendc(cur);
974 break; 1000 break;
975 } /* switch */ 1001 } /* switch */
976 } while (cur != (char)EOF); 1002 } while (cur != (int)EOF);
977 1003
978EndString: 1004EndString:
979 lexAppendc(0); 1005 lexAppendc(0);
@@ -1150,13 +1176,18 @@ VObject* Parse_MIME_FromFile(FILE *file)
1150 1176
1151DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) 1177DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname)
1152 { 1178 {
1153 QFileDirect f( fname ); 1179 FILE *fp = fopen(fname,"r");
1154 if ( !f.open( IO_ReadOnly ) ) { 1180 if (fp) {
1155 qWarning("Unable to open mime for reading %s", fname); 1181 VObject* o = Parse_MIME_FromFile(fp);
1182 fclose(fp);
1183 return o;
1184 }
1185 else {
1186 char msg[80];
1187 sprintf(msg, "can't open file '%s' for reading\n", fname);
1188 mime_error_(msg);
1156 return 0; 1189 return 0;
1157 } 1190 }
1158
1159 return Parse_MIME_FromFile( f.directHandle() );
1160 } 1191 }
1161 1192
1162#endif 1193#endif
@@ -1186,13 +1217,17 @@ void mime_error_(char *s)
1186 } 1217 }
1187 } 1218 }
1188 1219
1189#line 1192 "y.tab.c" 1220#line 1221 "y.tab.c"
1190#define YYABORT goto yyabort 1221#define YYABORT goto yyabort
1191#define YYREJECT goto yyabort 1222#define YYREJECT goto yyabort
1192#define YYACCEPT goto yyaccept 1223#define YYACCEPT goto yyaccept
1193#define YYERROR goto yyerrlab 1224#define YYERROR goto yyerrlab
1194int 1225int
1226#if defined(__STDC__)
1227yyparse(void)
1228#else
1195yyparse() 1229yyparse()
1230#endif
1196{ 1231{
1197 register int yym, yyn, yystate; 1232 register int yym, yyn, yystate;
1198#if YYDEBUG 1233#if YYDEBUG
@@ -1216,7 +1251,7 @@ yyparse()
1216 *yyssp = yystate = 0; 1251 *yyssp = yystate = 0;
1217 1252
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)
1221 { 1256 {
1222 if ((yychar = yylex()) < 0) yychar = 0; 1257 if ((yychar = yylex()) < 0) yychar = 0;
@@ -1256,10 +1291,6 @@ yyloop:
1256 goto yyreduce; 1291 goto yyreduce;
1257 } 1292 }
1258 if (yyerrflag) goto yyinrecovery; 1293 if (yyerrflag) goto yyinrecovery;
1259#ifdef lint
1260 goto yynewerror;
1261#endif
1262yynewerror:
1263 yyerror("syntax error"); 1294 yyerror("syntax error");
1264#ifdef lint 1295#ifdef lint
1265 goto yyerrlab; 1296 goto yyerrlab;
@@ -1328,49 +1359,49 @@ yyreduce:
1328 switch (yyn) 1359 switch (yyn)
1329 { 1360 {
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; }
1333break; 1364break;
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; }
1337break; 1368break;
1338case 6: 1369case 6:
1339#line 228 "vcc.y" 1370#line 232 "backend/vcc.y"
1340{ 1371{
1341 lexPushMode(L_VCARD); 1372 lexPushMode(L_VCARD);
1342 if (!pushVObject(VCCardProp)) YYERROR; 1373 if (!pushVObject(VCCardProp)) YYERROR;
1343 } 1374 }
1344break; 1375break;
1345case 7: 1376case 7:
1346#line 233 "vcc.y" 1377#line 237 "backend/vcc.y"
1347{ 1378{
1348 lexPopMode(0); 1379 lexPopMode(0);
1349 yyval.vobj = popVObject(); 1380 yyval.vobj = popVObject();
1350 } 1381 }
1351break; 1382break;
1352case 8: 1383case 8:
1353#line 238 "vcc.y" 1384#line 242 "backend/vcc.y"
1354{ 1385{
1355 lexPushMode(L_VCARD); 1386 lexPushMode(L_VCARD);
1356 if (!pushVObject(VCCardProp)) YYERROR; 1387 if (!pushVObject(VCCardProp)) YYERROR;
1357 } 1388 }
1358break; 1389break;
1359case 9: 1390case 9:
1360#line 243 "vcc.y" 1391#line 247 "backend/vcc.y"
1361{ 1392{
1362 lexPopMode(0); 1393 lexPopMode(0);
1363 yyval.vobj = popVObject(); 1394 yyval.vobj = popVObject();
1364 } 1395 }
1365break; 1396break;
1366case 12: 1397case 12:
1367#line 254 "vcc.y" 1398#line 258 "backend/vcc.y"
1368{ 1399{
1369 lexPushMode(L_VALUES); 1400 lexPushMode(L_VALUES);
1370 } 1401 }
1371break; 1402break;
1372case 13: 1403case 13:
1373#line 258 "vcc.y" 1404#line 262 "backend/vcc.y"
1374{ 1405{
1375 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE)) 1406 if (lexWithinMode(L_BASE64) || lexWithinMode(L_QUOTED_PRINTABLE))
1376 lexPopMode(0); 1407 lexPopMode(0);
@@ -1378,115 +1409,115 @@ case 13:
1378 } 1409 }
1379break; 1410break;
1380case 15: 1411case 15:
1381#line 267 "vcc.y" 1412#line 271 "backend/vcc.y"
1382{ 1413{
1383 enterProps(yyvsp[0].str); 1414 enterProps(yyvsp[0].str);
1384 } 1415 }
1385break; 1416break;
1386case 17: 1417case 17:
1387#line 272 "vcc.y" 1418#line 276 "backend/vcc.y"
1388{ 1419{
1389 enterProps(yyvsp[0].str); 1420 enterProps(yyvsp[0].str);
1390 } 1421 }
1391break; 1422break;
1392case 21: 1423case 21:
1393#line 285 "vcc.y" 1424#line 289 "backend/vcc.y"
1394{ 1425{
1395 enterAttr(yyvsp[0].str,0); 1426 enterAttr(yyvsp[0].str,0);
1396 } 1427 }
1397break; 1428break;
1398case 22: 1429case 22:
1399#line 289 "vcc.y" 1430#line 293 "backend/vcc.y"
1400{ 1431{
1401 enterAttr(yyvsp[-2].str,yyvsp[0].str); 1432 enterAttr(yyvsp[-2].str,yyvsp[0].str);
1402 1433
1403 } 1434 }
1404break; 1435break;
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); }
1408break; 1439break;
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); }
1412break; 1443break;
1413case 28: 1444case 28:
1414#line 305 "vcc.y" 1445#line 309 "backend/vcc.y"
1415{ yyval.str = 0; } 1446{ yyval.str = 0; }
1416break; 1447break;
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; }
1420break; 1451break;
1421case 30: 1452case 30:
1422#line 313 "vcc.y" 1453#line 317 "backend/vcc.y"
1423{ yyval.vobj = popVObject(); } 1454{ yyval.vobj = popVObject(); }
1424break; 1455break;
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; }
1428break; 1459break;
1429case 32: 1460case 32:
1430#line 317 "vcc.y" 1461#line 321 "backend/vcc.y"
1431{ yyval.vobj = popVObject(); } 1462{ yyval.vobj = popVObject(); }
1432break; 1463break;
1433case 38: 1464case 38:
1434#line 332 "vcc.y" 1465#line 336 "backend/vcc.y"
1435{ 1466{
1436 lexPushMode(L_VEVENT); 1467 lexPushMode(L_VEVENT);
1437 if (!pushVObject(VCEventProp)) YYERROR; 1468 if (!pushVObject(VCEventProp)) YYERROR;
1438 } 1469 }
1439break; 1470break;
1440case 39: 1471case 39:
1441#line 338 "vcc.y" 1472#line 342 "backend/vcc.y"
1442{ 1473{
1443 lexPopMode(0); 1474 lexPopMode(0);
1444 popVObject(); 1475 popVObject();
1445 } 1476 }
1446break; 1477break;
1447case 40: 1478case 40:
1448#line 343 "vcc.y" 1479#line 347 "backend/vcc.y"
1449{ 1480{
1450 lexPushMode(L_VEVENT); 1481 lexPushMode(L_VEVENT);
1451 if (!pushVObject(VCEventProp)) YYERROR; 1482 if (!pushVObject(VCEventProp)) YYERROR;
1452 } 1483 }
1453break; 1484break;
1454case 41: 1485case 41:
1455#line 348 "vcc.y" 1486#line 352 "backend/vcc.y"
1456{ 1487{
1457 lexPopMode(0); 1488 lexPopMode(0);
1458 popVObject(); 1489 popVObject();
1459 } 1490 }
1460break; 1491break;
1461case 42: 1492case 42:
1462#line 356 "vcc.y" 1493#line 360 "backend/vcc.y"
1463{ 1494{
1464 lexPushMode(L_VTODO); 1495 lexPushMode(L_VTODO);
1465 if (!pushVObject(VCTodoProp)) YYERROR; 1496 if (!pushVObject(VCTodoProp)) YYERROR;
1466 } 1497 }
1467break; 1498break;
1468case 43: 1499case 43:
1469#line 362 "vcc.y" 1500#line 366 "backend/vcc.y"
1470{ 1501{
1471 lexPopMode(0); 1502 lexPopMode(0);
1472 popVObject(); 1503 popVObject();
1473 } 1504 }
1474break; 1505break;
1475case 44: 1506case 44:
1476#line 367 "vcc.y" 1507#line 371 "backend/vcc.y"
1477{ 1508{
1478 lexPushMode(L_VTODO); 1509 lexPushMode(L_VTODO);
1479 if (!pushVObject(VCTodoProp)) YYERROR; 1510 if (!pushVObject(VCTodoProp)) YYERROR;
1480 } 1511 }
1481break; 1512break;
1482case 45: 1513case 45:
1483#line 372 "vcc.y" 1514#line 376 "backend/vcc.y"
1484{ 1515{
1485 lexPopMode(0); 1516 lexPopMode(0);
1486 popVObject(); 1517 popVObject();
1487 } 1518 }
1488break; 1519break;
1489#line 1492 "y.tab.c" 1520#line 1521 "y.tab.c"
1490 } 1521 }
1491 yyssp -= yym; 1522 yyssp -= yym;
1492 yystate = *yyssp; 1523 yystate = *yyssp;
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
@@ -1005,19 +1005,94 @@ static int writeBase64(OFile *fp, unsigned char *s, long len)
1005 return 1; 1005 return 1;
1006} 1006}
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);
1016 p++; 1076 p++;
1017 } 1077 }
1018} 1078}
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
1022static void writeVObject_(OFile *fp, VObject *o); 1097static void writeVObject_(OFile *fp, VObject *o);
1023 1098
@@ -1059,6 +1134,10 @@ static void writeAttrValue(OFile *fp, VObject *o)
1059 struct PreDefProp *pi; 1134 struct PreDefProp *pi;
1060 pi = lookupPropInfo(NAME_OF(o)); 1135 pi = lookupPropInfo(NAME_OF(o));
1061 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; 1136 if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
1137 if ( includesUnprintable(o) ) {
1138 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1139 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1140 }
1062 appendcOFile(fp,';'); 1141 appendcOFile(fp,';');
1063 appendsOFile(fp,NAME_OF(o)); 1142 appendsOFile(fp,NAME_OF(o));
1064 } 1143 }
@@ -1122,6 +1201,18 @@ static void writeProp(OFile *fp, VObject *o)
1122 int i = 0, n = 0; 1201 int i = 0, n = 0;
1123 const char** fields = fields_; 1202 const char** fields = fields_;
1124 /* output prop as fields */ 1203 /* output prop as fields */
1204 bool printable = TRUE;
1205 while (*fields && printable) {
1206 VObject *t = isAPropertyOf(o,*fields);
1207 if (includesUnprintable(t))
1208 printable = FALSE;
1209 fields++;
1210 }
1211 fields = fields_;
1212 if (!printable) {
1213 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1214 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1215 }
1125 appendcOFile(fp,':'); 1216 appendcOFile(fp,':');
1126 while (*fields) { 1217 while (*fields) {
1127 VObject *t = isAPropertyOf(o,*fields); 1218 VObject *t = isAPropertyOf(o,*fields);
@@ -1138,7 +1229,12 @@ static void writeProp(OFile *fp, VObject *o)
1138 } 1229 }
1139 } 1230 }
1140 1231
1232
1141 if (VALUE_TYPE(o)) { 1233 if (VALUE_TYPE(o)) {
1234 if ( includesUnprintable(o) ) {
1235 appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp);
1236 appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8");
1237 }
1142 unsigned long size = 0; 1238 unsigned long size = 0;
1143 VObject *p = isAPropertyOf(o,VCDataSizeProp); 1239 VObject *p = isAPropertyOf(o,VCDataSizeProp);
1144 if (p) size = LONG_VALUE_OF(p); 1240 if (p) size = LONG_VALUE_OF(p);
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
@@ -74,6 +74,8 @@ which accompanied this distribution.
74 74
75*/ 75*/
76 76
77// No tr() anywhere in this file
78
77 79
78#ifndef __VOBJECT_H__ 80#ifndef __VOBJECT_H__
79#define __VOBJECT_H__ 1 81#define __VOBJECT_H__ 1
@@ -142,7 +144,7 @@ For example:
142 #define VCCategoriesProp "CATEGORIES" 144 #define VCCategoriesProp "CATEGORIES"
143 #define VCCellularProp "CELL" 145 #define VCCellularProp "CELL"
144 #define VCCGMProp "CGM" 146 #define VCCGMProp "CGM"
145 #define VCCharSetProp "CS" 147 #define VCCharSetProp "CHARSET"
146 #define VCCIDProp "CID" 148 #define VCCIDProp "CID"
147 #define VCCISProp "CIS" 149 #define VCCISProp "CIS"
148 #define VCCityProp "L" 150 #define VCCityProp "L"