-rw-r--r-- | library/backend/categories.cpp | 319 | ||||
-rw-r--r-- | library/backend/contact.cpp | 526 | ||||
-rw-r--r-- | library/backend/contact.h | 102 | ||||
-rw-r--r-- | library/backend/event.cpp | 501 | ||||
-rw-r--r-- | library/backend/event.h | 173 | ||||
-rw-r--r-- | library/backend/palmtoprecord.cpp | 42 | ||||
-rw-r--r-- | library/backend/palmtoprecord.h | 33 | ||||
-rw-r--r-- | library/backend/palmtopuidgen.h | 26 | ||||
-rw-r--r-- | library/backend/qfiledirect_p.h | 20 | ||||
-rw-r--r-- | library/backend/qpcglobal.h | 9 | ||||
-rw-r--r-- | library/backend/recordfields.h | 24 | ||||
-rw-r--r-- | library/backend/stringutil.cpp | 415 | ||||
-rw-r--r-- | library/backend/stringutil.h | 57 | ||||
-rw-r--r-- | library/backend/task.cpp | 167 | ||||
-rw-r--r-- | library/backend/task.h | 21 | ||||
-rw-r--r-- | library/backend/timeconversion.cpp | 237 | ||||
-rw-r--r-- | library/backend/timeconversion.h | 45 | ||||
-rw-r--r-- | library/backend/vcc.y | 103 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 167 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 104 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 4 |
21 files changed, 2048 insertions, 1047 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index 6e011c4..e37b3b9 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp @@ -1,14 +1,13 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included -** in the packaging of this file. +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A -** PARTICULAR PURPOSE. +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** @@ -20,3 +19,4 @@ **********************************************************************/ -#include "categories.h" +#include <qtopia/categories.h> +#include <qtopia/stringutil.h> #include <qfile.h> @@ -24,3 +24,2 @@ #include <qtextstream.h> -#include "stringutil.h" @@ -40,2 +39,20 @@ UidGen CategoryGroup::sUidGen( UidGen::Qtopia ); +/*! \class CategoryGroup categories.h + \brief Helper class that is used by Categories + + CategoryGroup is a group of categories that is associated with an + application or global set. Mainly it defines a map of ids to + category labels and category labels to ids. Lookups can be done with + labels or unique idenifiers. + + \ingroup qtopiaemb + \ingroup qtopiadesktop + \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 + \sa Categories::appGroupMap(), Categories::globalGroup() + */ + +/*! Add \a label and return the UID. If failure, then 0 is returned. Note + that All and Unfiled are reserved labels. + \internal +*/ int CategoryGroup::add( const QString &label ) @@ -60,2 +77,4 @@ void CategoryGroup::insert( int uid, const QString &label ) +/*! \internal + */ bool CategoryGroup::add( int uid, const QString &label ) @@ -75,2 +94,5 @@ bool CategoryGroup::add( int uid, const QString &label ) +/*! Returns TRUE if \a label was removed from the group, FALSE if not. + \internal + */ bool CategoryGroup::remove( const QString &label ) @@ -87,2 +109,5 @@ bool CategoryGroup::remove( const QString &label ) +/*! Returns TRUE if \a uid was removed from the group, FALSE if not. + \internal + */ bool CategoryGroup::remove( int uid ) @@ -99,2 +124,4 @@ bool CategoryGroup::remove( int uid ) +/*! \internal + */ bool CategoryGroup::rename( int uid, const QString &newLabel ) @@ -115,2 +142,4 @@ bool CategoryGroup::rename( int uid, const QString &newLabel ) +/*! \internal + */ bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) @@ -120,2 +149,3 @@ bool CategoryGroup::rename( const QString &oldLabel, const QString &newLabel ) +/*! Returns TRUE if \a uid is stored in this group, FALSE if not. */ bool CategoryGroup::contains(int uid) const @@ -125,2 +155,3 @@ bool CategoryGroup::contains(int uid) const +/*! Returns TRUE if \a label is stored in this group, FALSE if not. */ bool CategoryGroup::contains(const QString &label) const @@ -130,4 +161,4 @@ bool CategoryGroup::contains(const QString &label) const -/** Returns label associated with the uid or QString::null if - * not found +/*! Returns label associated with the \a uid or QString::null if + not found */ @@ -141,3 +172,3 @@ const QString &CategoryGroup::label(int uid) const -/** Returns the uid associated with label or 0 if not found */ +/*! Returns the uid associated with \a label or 0 if not found */ int CategoryGroup::id(const QString &label) const @@ -150,2 +181,3 @@ int CategoryGroup::id(const QString &label) const +/*! Returns a list of all labels stored in this group. */ QStringList CategoryGroup::labels() const @@ -161,2 +193,3 @@ QStringList CategoryGroup::labels() const +/*! Returns a list of all labels associated with the \a catids */ QStringList CategoryGroup::labels(const QArray<int> &catids ) const @@ -179,4 +212,44 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const -/** Add the category name as long as it doesn't already exist locally - * or globally. Return TRUE if added, FALSE if conflicts. +/*! + \class Categories categories.h + \brief The Categories class is a database that groups categories and maps ids to names. + + The Categories class is the low level Categories accessor class. To + add a category menu and filter for your application, see CategoryMenu. + + The Categories class allows the developer to add, remove, and rename + categories. Categories can be created for an individual application + such as Todo List or to be used for all applications. Categories + that can be used by all applications are called global + categories. Each PalmtopRecord subclass stores categories as an + QArray<int> using PalmtopRecord::setCategories() and + PalmtopRecord::categories(). This allows each record to be assigned + to multiple categories. This also allows the user to rename a + category and for it to update automatically in all records. + + This class provides several methods to convert between a category id + and it's associated string such as id(), ids(), label() and labels(). A + helper class called CategoryGroup is used to access categories of a + single application group, such as Todo List. Global categories can + also be accessed via CategoryGroup objects. See appGroupMap() and + globalGroup() for the appropriate accessor methods. + + Categories are stored in an xml file in the Settings directory + (Categories.xml). A global function called categoryFileName() will + return to appropriate QString file location to be passed to load() + and save() for the master categories database. + + \ingroup qtopiaemb + \ingroup qtopiadesktop + \warning Categories API will likely change between Qtopia 1.5 and Qtopia 3 + \sa CategoryGroup, CategoryMenu +*/ + + +/*! + Add the category name as long as it doesn't already exist locally or + globally. The \a uid is assigned to the category if successfully + added. Return \a uid if added, 0 if conflicts (error). + + \internal */ @@ -206,2 +279,7 @@ int Categories::addCategory( const QString &appname, +/*! + Add the category name as long as it doesn't already exist locally or + globally. Return UID if added, 0 if conflicts (error). +*/ + int Categories::addCategory( const QString &appname, @@ -231,2 +309,5 @@ int Categories::addCategory( const QString &appname, +/*! + \internal +*/ int Categories::addGlobalCategory( const QString &catname, int uid ) @@ -238,2 +319,8 @@ int Categories::addGlobalCategory( const QString &catname, int uid ) +/*! + Add the global category \a catname while checking that it doesn't + already exist globally. Return UID if added, 0 if conflicts. + + \sa addCategory() + */ int Categories::addGlobalCategory( const QString &catname ) @@ -247,5 +334,7 @@ int Categories::addGlobalCategory( const QString &catname ) -/** Removes the category from the application; if it is not found - * in the application, then it attempts to remove it from - * the global list +/*! + + Removes the \a catname from the application group. If it is not + found in the application group and \a checkGlobal is TRUE, then it + attempts to remove it from the global list */ @@ -270,2 +359,7 @@ bool Categories::removeCategory( const QString &appname, + +/*! + Removes the \a uid from the application group \a appname. Returns TRUE + if success, FALSE if not found. +*/ bool Categories::removeCategory( const QString &appname, int uid ) @@ -284,2 +378,6 @@ bool Categories::removeCategory( const QString &appname, int uid ) +/*! + Removes the global category \a catname. Returns TRUE + if success, FALSE if not found. +*/ bool Categories::removeGlobalCategory( const QString &catname ) @@ -294,3 +392,6 @@ bool Categories::removeGlobalCategory( const QString &catname ) - +/*! + Removes the global category \a uid. Returns TRUE + if success, FALSE if not found. +*/ bool Categories::removeGlobalCategory( int uid ) @@ -304,5 +405,6 @@ bool Categories::removeGlobalCategory( int uid ) -/** Returns the sorted list of all categories that are associated with - * the app. If includeGlobal parameter is TRUE then the returned - * categories will include the global category items. +/*! + Returns the sorted list of all categories that are associated with + the \a app. If \a includeGlobal is TRUE then the returned + categories will include the global category items. */ @@ -318,3 +420,3 @@ QStringList Categories::labels( const QString &app, cats += (*appIt).labels(); - else qDebug("Categories::labels didn't find app %s", app.latin1() ); + //else qDebug("Categories::labels didn't find app %s", app.latin1() ); if ( includeGlobal ) @@ -340,2 +442,5 @@ QStringList Categories::labels( const QString &app, +/*! + Returns the label associated with the id +*/ QString Categories::label( const QString &app, int id ) const @@ -351,6 +456,12 @@ QString Categories::label( const QString &app, int id ) const -/** Returns a single string associated with the cat ids for display in - * a combobox or any area that requires one string. If catids are empty - * then "Unfiled" will be returned. If multiple categories are assigned - * the first cat id is shown with " (multi)" appended to the string. +/*! + Returns a single string associated with \a catids for display in a + combobox or any area that requires one string. If \a catids are empty + then "Unfiled" will be returned. If multiple categories are + assigned then the behavior depends on the DisplaySingle type. + + If \a display is set to ShowMulti then " (multi)" appended to the + first string. If \a display is set to ShowAll, then a space + seperated string is returned with all categories. If ShowFirst is + set, the just the first string is returned. */ @@ -382,2 +493,7 @@ QString Categories::displaySingle( const QString &app, +/*! + + Returns all ids associated with the application CategoryGroup \a app + and the passed in \a labels in that group. +*/ QArray<int> Categories::ids( const QString &app, const QStringList &labels) const @@ -399,2 +515,7 @@ QArray<int> Categories::ids( const QString &app, const QStringList &labels) cons +/*! + Returns the id associated with the app. If the id is not found in the + application CategoryGroup, then it searches the global CategoryGroup. + If it is not found it either, 0 is returned. +*/ int Categories::id( const QString &app, const QString &cat ) const @@ -410,4 +531,9 @@ int Categories::id( const QString &app, const QString &cat ) const -/** Return TRUE if renaming succeeded; FALSE if app name not found, - * or if there was a name conflict +/*! + Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName + is not found, or if \a newName conflicts with an existing category + in the CategoryGroup. + + It will first search the CategoryGroup associated with \a appname + and if not found it will try to replace in global CategoryGroup. */ @@ -431,2 +557,8 @@ bool Categories::renameCategory( const QString &appname, +/*! + Return TRUE if renaming succeeded; FALSE if \a appname or \a oldName + is not found, or if \a newName conflicts with an existing category + in the CategoryGroup. This function will only rename categories found + in the global CategoryGroup. + */ bool Categories::renameGlobalCategory( const QString &oldName, @@ -442,2 +574,6 @@ bool Categories::renameGlobalCategory( const QString &oldName, +/*! + Changes the grouping of a category. If a category was global and \a global + is set to TRUE, then the \a catname will be moved to the \a appname group. +*/ void Categories::setGlobal( const QString &appname, @@ -460,2 +596,5 @@ void Categories::setGlobal( const QString &appname, +/*! + Returns TRUE if the \a catname is in the global CategoryGroup, FALSE if not. +*/ bool Categories::isGlobal( const QString &catname ) const @@ -466,3 +605,5 @@ bool Categories::isGlobal( const QString &catname ) const -/** Returns true if the catname is associated with any application +/*! + Returns true if the \a catname is associated with any CategoryGroup, + including global. */ @@ -480,2 +621,6 @@ bool Categories::exists( const QString &catname ) const +/*! + Returns TRUE if the \a catname is associated with the \a appname + CategoryGroup, FALSE if not found. + */ bool Categories::exists( const QString &appname, @@ -492,3 +637,8 @@ bool Categories::exists( const QString &appname, +/*! + Saves the Categories database to the \a fname. See categoryFileName() + for the default file name string used for the shared category database. + Returns FALSE if there is error writing the file or TRUE on success. + */ bool Categories::save( const QString &fname ) const @@ -536,2 +686,5 @@ bool Categories::save( const QString &fname ) const +#ifdef Q_OS_WIN32 + QFile::remove( fname ); +#endif if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { @@ -546,2 +699,8 @@ bool Categories::save( const QString &fname ) const +/*! + Loads the Categories database using \a fname. See categoryFileName() + for the default file name string used for the shared category database. + + Returns FALSE if there is error reading the file or TRUE on success. + */ bool Categories::load( const QString &fname ) @@ -621,2 +780,6 @@ bool Categories::load( const QString &fname ) +/*! + Clear the categories in memory. Equivelent to creating an empty Categories + object. +*/ void Categories::clear() @@ -627,2 +790,5 @@ void Categories::clear() +/*! + Dump the contents to standard out. Used for debugging only. +*/ void Categories::dump() const @@ -677 +843,94 @@ void CheckedListView::setChecked( const QStringList &checked ) } + +/*! \fn Categories &Categories::operator= ( const Categories &c ) + + Performs deep copy. + */ + + +/*! \fn QStringList Categories::labels( const QString & app, const QArray<int> &catids ) const + + Returns list of labels associated with the application and catids +*/ + +/*! \fn QStringList Categories::globalCategories() const + + Returns list of all global category labels +*/ + +/*! \fn const QMap<QString, CategoryGroup> &Categories::appGroupMap() const + + Returns a map of application names to CategoryGroup. The CategoryGroup + class defines a map of ids to category labels and category labels to ids. +*/ + +/*! \fn const CategoryGroup &Categories::globalGroup() const + + Returns the global CategoryGroup. The CategoryGroup + class defines a map of ids to category labels and category labels to ids. +*/ + +/*! \fn void Categories::categoryAdded( const Categories &cats, const QString &appname, int uid) + + Emitted if a category is added. + + \a cats is a const reference to this object + \a appname is the CategoryGroup application name that the category was added to or QString::null if it was global + \a uid is the unique identifier associated with the added category +*/ + +/*! \fn void Categories::categoryRemoved( const Categories &cats, const QString &appname, + int uid) + + Emitted if removed category is removed. + + \a cats is a const reference to this object + \a appname is the CategoryGroup application name that the category was removed from or QString::null if it was the global CategoryGroup + \a uid is the unique identifier associated with the removed category +*/ + + +/*! \fn void Categories::categoryRenamed( const Categories &cats, const QString &appname, + int uid) + + Emitted if \a uid in the \a appname CategoryGroup is renamed in \a cats + object. + + \a cats is a const reference to this object + \a appname is the CategoryGroup application name that the category was renamed in or QString::null if it was the global CategoryGroup + \a uid is the unique identifier associated with the renamed category +*/ + +/*! \fn Categories::Categories( QObject *parent=0, const char *name = 0 ) + + Constructor for an empty Categories object. +*/ + +/*! \fn Categories::Categories( const Categories ©From ) + + Deep copy constructor +*/ + +/*! \fn Categories::~Categories() + + Empty destructor. Call save() before destruction if there are changes + that need to be saved. +*/ + +/*! \fn CategoryGroup::clear() + \internal +*/ + +/*! \fn const QMap<int, QString> &CategoryGroup::idMap() const + + Returns a const reference to the id to label QMap +*/ + +/*! \fn CategoryGroup::CategoryGroup() + \internal +*/ + +/*! \fn CategoryGroup::CategoryGroup(const CategoryGroup &c) + \internal +*/ + diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index b10b19a..3f4934a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -36,4 +36,18 @@ +/*! + \class Contact contact.h + \brief The Contact class holds the data of an address book entry. + + This data includes information the name of the person, contact + information, and business information such as deparment and job title. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); +/*! + Creates a new, empty contact. +*/ Contact::Contact() @@ -43,2 +57,7 @@ Contact::Contact() +/*! + \internal + Creates a new contact. The properties of the contact are + set from \a fromMap. +*/ Contact::Contact( const QMap<int, QString> &fromMap ) : @@ -50,2 +69,3 @@ Contact::Contact( const QMap<int, QString> &fromMap ) : QString uidStr = find( Qtopia::AddressUid ); + if ( uidStr.isEmpty() ) @@ -54,4 +74,10 @@ Contact::Contact( const QMap<int, QString> &fromMap ) : setUid( uidStr.toInt() ); + + if ( !uidStr.isEmpty() ) + setUid( uidStr.toInt() ); } +/*! + Destroys a contact. +*/ Contact::~Contact() @@ -60,2 +86,352 @@ Contact::~Contact() +/*! \fn void Contact::setTitle( const QString &str ) + Sets the title of the contact to \a str. +*/ + +/*! \fn void Contact::setFirstName( const QString &str ) + Sets the first name of the contact to \a str. +*/ + +/*! \fn void Contact::setMiddleName( const QString &str ) + Sets the middle name of the contact to \a str. +*/ + +/*! \fn void Contact::setLastName( const QString &str ) + Sets the last name of the contact to \a str. +*/ + +/*! \fn void Contact::setSuffix( const QString &str ) + Sets the suffix of the contact to \a str. +*/ + +/*! \fn void Contact::setFileAs( const QString &str ) + Sets the contact to filed as \a str. +*/ + +/*! \fn void Contact::setDefaultEmail( const QString &str ) + Sets the default email of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeStreet( const QString &str ) + Sets the home street address of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeCity( const QString &str ) + Sets the home city of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeState( const QString &str ) + Sets the home state of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeZip( const QString &str ) + Sets the home zip code of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeCountry( const QString &str ) + Sets the home country of the contact to \a str. +*/ + +/*! \fn void Contact::setHomePhone( const QString &str ) + Sets the home phone number of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeFax( const QString &str ) + Sets the home fax number of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeMobile( const QString &str ) + Sets the home mobile phone number of the contact to \a str. +*/ + +/*! \fn void Contact::setHomeWebpage( const QString &str ) + Sets the home webpage of the contact to \a str. +*/ + +/*! \fn void Contact::setCompany( const QString &str ) + Sets the company for contact to \a str. +*/ + +/*! \fn void Contact::setJobTitle( const QString &str ) + Sets the job title of the contact to \a str. +*/ + +/*! \fn void Contact::setDepartment( const QString &str ) + Sets the department for contact to \a str. +*/ + +/*! \fn void Contact::setOffice( const QString &str ) + Sets the office for contact to \a str. +*/ + +/*! \fn void Contact::setBusinessStreet( const QString &str ) + Sets the business street address of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessCity( const QString &str ) + Sets the business city of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessState( const QString &str ) + Sets the business state of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessZip( const QString &str ) + Sets the business zip code of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessCountry( const QString &str ) + Sets the business country of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessPhone( const QString &str ) + Sets the business phone number of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessFax( const QString &str ) + Sets the business fax number of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessMobile( const QString &str ) + Sets the business mobile phone number of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessPager( const QString &str ) + Sets the business pager number of the contact to \a str. +*/ + +/*! \fn void Contact::setBusinessWebpage( const QString &str ) + Sets the business webpage of the contact to \a str. +*/ + +/*! \fn void Contact::setProfession( const QString &str ) + Sets the profession of the contact to \a str. +*/ + +/*! \fn void Contact::setAssistant( const QString &str ) + Sets the assistant of the contact to \a str. +*/ + +/*! \fn void Contact::setManager( const QString &str ) + Sets the manager of the contact to \a str. +*/ + +/*! \fn void Contact::setSpouse( const QString &str ) + Sets the spouse of the contact to \a str. +*/ + +/*! \fn void Contact::setGender( const QString &str ) + Sets the gender of the contact to \a str. +*/ + +/*! \fn void Contact::setBirthday( const QString &str ) + Sets the birthday for the contact to \a str. +*/ + +/*! \fn void Contact::setAnniversary( const QString &str ) + Sets the anniversary of the contact to \a str. +*/ + +/*! \fn void Contact::setNickname( const QString &str ) + Sets the nickname of the contact to \a str. +*/ + +/*! \fn void Contact::setNotes( const QString &str ) + Sets the notes about the contact to \a str. +*/ + +/*! \fn QString Contact::title() const + Returns the title of the contact. +*/ + +/*! \fn QString Contact::firstName() const + Returns the first name of the contact. +*/ + +/*! \fn QString Contact::middleName() const + Returns the middle name of the contact. +*/ + +/*! \fn QString Contact::lastName() const + Returns the last name of the contact. +*/ + +/*! \fn QString Contact::suffix() const + Returns the suffix of the contact. +*/ + +/*! \fn QString Contact::fileAs() const + Returns the string the contact is filed as. +*/ + +/*! \fn QString Contact::defaultEmail() const + Returns the default email address of the contact. +*/ + +/*! \fn QString Contact::emails() const + Returns the list of email address for a contact separated by ';'s in a single + string. +*/ + +/*! \fn QString Contact::homeStreet() const + Returns the home street address of the contact. +*/ + +/*! \fn QString Contact::homeCity() const + Returns the home city of the contact. +*/ + +/*! \fn QString Contact::homeState() const + Returns the home state of the contact. +*/ + +/*! \fn QString Contact::homeZip() const + Returns the home zip of the contact. +*/ + +/*! \fn QString Contact::homeCountry() const + Returns the home country of the contact. +*/ + +/*! \fn QString Contact::homePhone() const + Returns the home phone number of the contact. +*/ + +/*! \fn QString Contact::homeFax() const + Returns the home fax number of the contact. +*/ + +/*! \fn QString Contact::homeMobile() const + Returns the home mobile number of the contact. +*/ + +/*! \fn QString Contact::homeWebpage() const + Returns the home webpage of the contact. +*/ + +/*! \fn QString Contact::company() const + Returns the company for the contact. +*/ + +/*! \fn QString Contact::department() const + Returns the department for the contact. +*/ + +/*! \fn QString Contact::office() const + Returns the office for the contact. +*/ + +/*! \fn QString Contact::jobTitle() const + Returns the job title of the contact. +*/ + +/*! \fn QString Contact::profession() const + Returns the profession of the contact. +*/ + +/*! \fn QString Contact::assistant() const + Returns the assistant of the contact. +*/ + +/*! \fn QString Contact::manager() const + Returns the manager of the contact. +*/ + +/*! \fn QString Contact::businessStreet() const + Returns the business street address of the contact. +*/ + +/*! \fn QString Contact::businessCity() const + Returns the business city of the contact. +*/ + +/*! \fn QString Contact::businessState() const + Returns the business state of the contact. +*/ + +/*! \fn QString Contact::businessZip() const + Returns the business zip of the contact. +*/ + +/*! \fn QString Contact::businessCountry() const + Returns the business country of the contact. +*/ + +/*! \fn QString Contact::businessPhone() const + Returns the business phone number of the contact. +*/ + +/*! \fn QString Contact::businessFax() const + Returns the business fax number of the contact. +*/ + +/*! \fn QString Contact::businessMobile() const + Returns the business mobile number of the contact. +*/ + +/*! \fn QString Contact::businessPager() const + Returns the business pager number of the contact. +*/ + +/*! \fn QString Contact::businessWebpage() const + Returns the business webpage of the contact. +*/ + +/*! \fn QString Contact::spouse() const + Returns the spouse of the contact. +*/ + +/*! \fn QString Contact::gender() const + Returns the gender of the contact. +*/ + +/*! \fn QString Contact::birthday() const + Returns the birthday of the contact. +*/ + +/*! \fn QString Contact::anniversary() const + Returns the anniversary of the contact. +*/ + +/*! \fn QString Contact::nickname() const + Returns the nickname of the contact. +*/ + +/*! \fn QString Contact::children() const + Returns the children of the contact. +*/ + +/*! \fn QString Contact::notes() const + Returns the notes relating to the the contact. +*/ + +/*! \fn QString Contact::groups() const + \internal + Returns the groups for the contact. +*/ + +/*! \fn QStringList Contact::groupList() const + \internal +*/ + +/*! \fn QString Contact::field(int) const + \internal +*/ + +/*! \fn void Contact::saveJournal( journal_action, const QString & = QString::null ) + \internal +*/ + +/*! \fn void Contact::setUid( int id ) + \internal + Sets the uid for this record to \a id. +*/ + +/*! \enum Contact::journal_action + \internal +*/ + +/*! + \internal +*/ QMap<int, QString> Contact::toMap() const @@ -63,3 +439,5 @@ QMap<int, QString> Contact::toMap() const QMap<int, QString> map = mMap; - map.insert( Qtopia::AddressCategory, idsToString( categories() )); + QString cats = idsToString( categories() ); + if ( !cats.isEmpty() ) + map.insert( Qtopia::AddressCategory, cats ); return map; @@ -68,3 +446,3 @@ QMap<int, QString> Contact::toMap() const /*! - Returns a rich text formatted QString of the Contact. + Returns a rich text formatted QString representing the contents the contact. */ @@ -233,2 +611,5 @@ QString Contact::toRichText() const +/*! + \internal +*/ void Contact::insert( int key, const QString &v ) @@ -242,2 +623,5 @@ void Contact::insert( int key, const QString &v ) +/*! + \internal +*/ void Contact::replace( int key, const QString & v ) @@ -251,2 +635,5 @@ void Contact::replace( int key, const QString & v ) +/*! + \internal +*/ QString Contact::find( int key ) const @@ -256,2 +643,5 @@ QString Contact::find( int key ) const +/*! + \internal +*/ QString Contact::displayAddress( const QString &street, @@ -278,2 +668,5 @@ QString Contact::displayAddress( const QString &street, +/*! + \internal +*/ QString Contact::displayBusinessAddress() const @@ -285,2 +678,5 @@ QString Contact::displayBusinessAddress() const +/*! + \internal +*/ QString Contact::displayHomeAddress() const @@ -292,2 +688,5 @@ QString Contact::displayHomeAddress() const +/*! + Returns the full name of the contact +*/ QString Contact::fullName() const @@ -324,2 +723,5 @@ QString Contact::fullName() const +/*! + Returns a list of the names of the children of the contact. +*/ QStringList Contact::childrenList() const @@ -329,7 +731,50 @@ QStringList Contact::childrenList() const +/*! \fn void Contact::insertEmail( const QString &email ) + + Insert \a email into the email list. Ensures \a email can only be added + once. If there is no default email address set, it sets it to the \a email. +*/ + +/*! \fn void Contact::removeEmail( const QString &email ) + + Removes the \a email from the email list. If the default email was \a email, + then the default email address is assigned to the first email in the + email list +*/ + +/*! \fn void Contact::clearEmails() + + Clears the email list. + */ + +/*! \fn void Contact::insertEmails( const QStringList &emailList ) + + Appends the \a emailList to the exiting email list + */ + +/*! + Returns a list of email addresses belonging to the contact, including + the default email address. +*/ QStringList Contact::emailList() const { - return QStringList::split( ";", find( Qtopia::Emails ) ); + QString emailStr = emails(); + + QStringList r; + if ( !emailStr.isEmpty() ) { + qDebug(" emailstr "); + QStringList l = QStringList::split( emailSeparator(), emailStr ); + for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) + r += (*it).simplifyWhiteSpace(); + } + + return r; } +/*! + \overload + + Generates the string for the contact to be filed as from the first, + middle and last name of the contact. +*/ void Contact::setFileAs() @@ -355,2 +800,6 @@ void Contact::setFileAs() +/*! + \internal + Appends the contact information to \a buf. +*/ void Contact::save( QString &buf ) const @@ -379,2 +828,6 @@ void Contact::save( QString &buf ) const +/*! + \internal + Returns the list of fields belonging to a contact +*/ QStringList Contact::fields() @@ -437,2 +890,6 @@ QStringList Contact::fields() +/*! + \internal + Returns a translated list of field names for a contact. +*/ QStringList Contact::trfields() @@ -495,6 +952,10 @@ QStringList Contact::trfields() -void Contact::setEmails( const QString &v ) +/*! + Sets the list of email address for contact to those contained in \a str. + Email address should be separated by ';'s. +*/ +void Contact::setEmails( const QString &str ) { - replace( Qtopia::Emails, v ); - if ( v.isEmpty() ) + replace( Qtopia::Emails, str ); + if ( str.isEmpty() ) setDefaultEmail( QString::null ); @@ -502,5 +963,8 @@ void Contact::setEmails( const QString &v ) -void Contact::setChildren( const QString &v ) +/*! + Sets the list of children for the contact to those contained in \a str. +*/ +void Contact::setChildren( const QString &str ) { - replace( Qtopia::Children, v ); + replace( Qtopia::Children, str ); } @@ -508,2 +972,5 @@ void Contact::setChildren( const QString &v ) // vcard conversion code +/*! + \internal +*/ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) @@ -516,2 +983,5 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt +/*! + \internal +*/ static inline VObject *safeAddProp( VObject *o, const char *prop) @@ -524,2 +994,5 @@ static inline VObject *safeAddProp( VObject *o, const char *prop) +/*! + \internal +*/ static VObject *createVObject( const Contact &c ) @@ -624,2 +1097,5 @@ static VObject *createVObject( const Contact &c ) +/*! + \internal +*/ static Contact parseVObject( VObject *obj ) @@ -628,4 +1104,2 @@ static Contact parseVObject( VObject *obj ) - bool haveDefaultEmail = FALSE; - VObjectIterator it; @@ -769,10 +1243,3 @@ static Contact parseVObject( VObject *obj ) if ( valid ) { - if ( haveDefaultEmail ) { - QString str = c.emails(); - if ( !str.isEmpty() ) - str += ","+email; - c.setEmails( str ); - } else { - c.setDefaultEmail( email ); - } + c.insertEmail( email ); } @@ -853,2 +1320,5 @@ static Contact parseVObject( VObject *obj ) +/*! + Writes the list of \a contacts as a set of VCards to the file \a filename. +*/ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) @@ -870,2 +1340,5 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co +/*! + writes \a contact as a VCard to the file \a filename. +*/ void Contact::writeVCard( const QString &filename, const Contact &contact) @@ -885,3 +1358,5 @@ void Contact::writeVCard( const QString &filename, const Contact &contact) - +/*! + Returns the set of contacts read as VCards from the file \a filename. +*/ QValueList<Contact> Contact::readVCard( const QString &filename ) @@ -906,2 +1381,6 @@ QValueList<Contact> Contact::readVCard( const QString &filename ) +/*! + Returns TRUE if the contact matches the regular expression \a regexp. + Otherwise returns FALSE. +*/ bool Contact::match( const QString ®exp ) const @@ -911,2 +1390,7 @@ bool Contact::match( const QString ®exp ) const +/*! + \overload + Returns TRUE if the contact matches the regular expression \a regexp. + Otherwise returns FALSE. +*/ bool Contact::match( const QRegExp &r ) const diff --git a/library/backend/contact.h b/library/backend/contact.h index a74cbbe..4999430 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -23,4 +23,4 @@ -#include <qpe/palmtoprecord.h> -#include <qpe/recordfields.h> +#include <qtopia/private/palmtoprecord.h> +#include <qtopia/private/recordfields.h> @@ -30,3 +30,3 @@ // MOC_SKIP_BEGIN -template class QPC_EXPORT QMap<int, QString>; +QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; // MOC_SKIP_END @@ -58,5 +58,8 @@ public: // default email address - void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } - // the emails should be seperated by a semicolon - void setEmails( const QString &v ); + void setDefaultEmail( const QString &v ); + // inserts email to list and ensure's doesn't already exist + void insertEmail( const QString &v ); + void removeEmail( const QString &v ); + void clearEmails(); + void insertEmails( const QStringList &v ); @@ -125,3 +128,2 @@ public: QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } - QString emails() const { return find( Qtopia::Emails ); } QStringList emailList() const; @@ -204,3 +206,12 @@ public: private: + friend class AbEditor; friend class AbTable; + friend class AddressBookAccessPrivate; + friend class XMLIO; + + QString emailSeparator() const { return " "; } + // the emails should be seperated by a comma + void setEmails( const QString &v ); + QString emails() const { return find( Qtopia::Emails ); } + void insert( int key, const QString &value ); @@ -221,2 +232,75 @@ private: +// these methods are inlined to keep binary compatability with Qtopia 1.5 +inline void Contact::insertEmail( const QString &v ) +{ + //qDebug("insertEmail %s", v.latin1()); + QString e = v.simplifyWhiteSpace(); + QString def = defaultEmail(); + + // if no default, set it as the default email and don't insert + if ( def.isEmpty() ) { + setDefaultEmail( e ); // will insert into the list for us + return; + } + + // otherwise, insert assuming doesn't already exist + QString emailsStr = find( Qtopia::Emails ); + if ( emailsStr.contains( e )) + return; + if ( !emailsStr.isEmpty() ) + emailsStr += emailSeparator(); + emailsStr += e; + replace( Qtopia::Emails, emailsStr ); +} + +inline void Contact::removeEmail( const QString &v ) +{ + QString e = v.simplifyWhiteSpace(); + QString def = defaultEmail(); + QString emailsStr = find( Qtopia::Emails ); + QStringList emails = emailList(); + + // otherwise, must first contain it + if ( !emailsStr.contains( e ) ) + return; + + // remove it + //qDebug(" removing email from list %s", e.latin1()); + emails.remove( e ); + // reset the string + emailsStr = emails.join(emailSeparator()); // Sharp's brain dead separator + replace( Qtopia::Emails, emailsStr ); + + // if default, then replace the default email with the first one + if ( def == e ) { + //qDebug("removeEmail is default; setting new default"); + if ( !emails.count() ) + clearEmails(); + else // setDefaultEmail will remove e from the list + setDefaultEmail( emails.first() ); + } +} +inline void Contact::clearEmails() +{ + mMap.remove( Qtopia::DefaultEmail ); + mMap.remove( Qtopia::Emails ); +} +inline void Contact::setDefaultEmail( const QString &v ) +{ + QString e = v.simplifyWhiteSpace(); + + //qDebug("Contact::setDefaultEmail %s", e.latin1()); + replace( Qtopia::DefaultEmail, e ); + + if ( !e.isEmpty() ) + insertEmail( e ); + +} + +inline void Contact::insertEmails( const QStringList &v ) +{ + for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) + insertEmail( *it ); +} + #endif diff --git a/library/backend/event.cpp b/library/backend/event.cpp index 50a663d..7110717 100644 --- a/library/backend/event.cpp +++ b/library/backend/event.cpp @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -22,5 +22,5 @@ #include "qfiledirect_p.h" -#include <qpe/timeconversion.h> -#include <qpe/stringutil.h> -#include <qpe/recordfields.h> +#include <qtopia/timeconversion.h> +#include <qtopia/stringutil.h> +#include <qtopia/private/recordfields.h> #include <qbuffer.h> @@ -73,2 +73,251 @@ Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); +/*! + \class Event event.h + \brief The Event class holds the data of a calendar event. + + This data includes descriptive data of the event and schedualing information. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + +/*! + \class Event::RepeatPattern + \class The Event::RepeatPattern class is internal. + \internal +*/ + +/*! + \enum Event::Days + \internal +*/ + +/*! + \enum Event::Type + \internal +*/ + +/*! + \enum Event::SoundTypeChoice + + This enum type defines what kind of sound is made when an alarm occurs + for an event. The currently defined types are: + + <ul> + <li>\c Silent - No sound is produced. + <li>\c Loud - A loud sound is produced. + </ul> +*/ + +/*! + \fn bool Event::operator<( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator<=( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator!=( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator>( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator>=( const Event & ) const + \internal +*/ + +/*! + \enum Event::RepeatType + + This enum defines how a event will repeat, if at all. + + <ul> + <li>\c NoRepeat - Event does not repeat. + <li>\c Daily - Event occurs every n days. + <li>\c Weekly - Event occurs every n weeks. + <li>\c MonthlyDay - Event occurs every n months. Event will always occur in + the same week and same day of week as the first event. + <li>\c MonthlyDate - Event occurs every n months. Event will always occur + on the same day of the month as the first event. + <li>\c Yearly - Event occurs every n years. + </ul> +*/ + +/*! + \fn bool Event::isAllDay() const + + Returns TRUE if the event is an all day event. Otherwise returns FALSE. +*/ + +/*! + \fn void Event::setAllDay(bool allday) + + If \a allday is TRUE, will set the event to be an all day event. + Otherwise sets the event to not be an all day event. + + \warning This function may affect the start and end times of the event. +*/ + +/*! + \fn QDateTime Event::start() const + + Returns the start date and time of the first occurance of the event. +*/ + +/*! + \fn QDateTime Event::end() const + + Returns the end date and time of the first occurance of the event. +*/ + +/*! + \fn time_t Event::startTime() const + \internal +*/ + +/*! + \fn time_t Event::endTime() const + \internal +*/ + +/*! + \fn void Event::setAlarm(int delay, SoundTypeChoice s) + + Sets the alarm delay of the event to \a delay and the sound type of the + alarm to \a s. +*/ + +/*! + \fn void Event::clearAlarm() + + Clears the alarm for the event. +*/ + +/*! + \fn int Event::alarmDelay() const + + Returns the delay in minutes between the alarm for an event and the + start of the event. +*/ + +/*! + \fn Event::RepeatType Event::repeatType() const + + Returns the repeat pattern type for the event. + + \sa frequency() +*/ + +/*! + \fn int Event::weekOffset() const + + Returns the number of weeks from the start of the month that this event + occurs. +*/ + +/*! + \fn QDate Event::repeatTill() const + + Returns the date that the event will continue to repeat until. If the event + repeats forever the value returned is undefined. + + \sa repeatForever() +*/ + +/*! + \fn bool Event::repeatForever() const + + Returns FALSE if there is a date set for the event to continue until. + Otherwise returns TRUE. +*/ + +/*! + \fn bool Event::doRepeat() const + \internal +*/ + +/*! + \fn bool Event::repeatOnWeekDay(int day) const + + Returns TRUE if the event has a RepeatType of Weekly and is set to occur on + \a day each week. Otherwise returns FALSE. + + \sa QDate::dayName() +*/ + +/*! + \fn void Event::setRepeatOnWeekDay(int day, bool enable) + + If \a enable is TRUE then sets the event to occur on \a day each week. + Otherwise sets the event not to occur on \a day. + + \warning this function is only relavent for a event with RepeatType of + Weekly. + + \sa QDate::dayName() +*/ + +/*! + \fn int Event::frequency() const + + Returns how often the event repeats. + + \sa repeatType() +*/ + +/*! + \fn void Event::setRepeatType(RepeatType t) + + Sets the repeat pattern type of the event to \a t. + + \sa setFrequency() +*/ + +/*! + \fn void Event::setFrequency(int n) + + Sets how often the event occurs with in its repeat pattern. + + \sa setRepeatType() +*/ + +/*! + \fn void Event::setRepeatTill(const QDate &d) + + Sets the event to repeat until \a d. +*/ + +/*! + \fn void Event::setRepeatForever(bool enable) + + If \a enable is TRUE, sets the event to repeat forever. Otherwise + sets the event to stop repeating at some date. + + \warning This function may affect the specific date the event will repeat + till. +*/ + +/*! + \fn bool Event::match(const QRegExp &r) const + + Returns TRUE if the event matches the regular expression \a r. + Otherwise returns FALSE. +*/ + +/*! + \fn char Event::day(int) + \internal +*/ + +/*! + Creates a new, empty event. +*/ Event::Event() : Record() @@ -85,2 +334,5 @@ Event::Event() : Record() +/*! + \internal +*/ Event::Event( const QMap<int, QString> &map ) @@ -108,2 +360,5 @@ Event::Event( const QMap<int, QString> &map ) +/*! + Destroys an event. +*/ Event::~Event() @@ -112,2 +367,5 @@ Event::~Event() +/*! + \internal +*/ int Event::week( const QDate& date ) @@ -126,2 +384,5 @@ int Event::week( const QDate& date ) +/*! + \internal +*/ int Event::occurrence( const QDate& date ) @@ -133,2 +394,5 @@ int Event::occurrence( const QDate& date ) +/*! + \internal +*/ int Event::dayOfWeek( char day ) @@ -144,2 +408,5 @@ int Event::dayOfWeek( char day ) +/*! + \internal +*/ int Event::monthDiff( const QDate& first, const QDate& second ) @@ -150,2 +417,5 @@ int Event::monthDiff( const QDate& first, const QDate& second ) +/*! + \internal +*/ QMap<int, QString> Event::toMap() const @@ -153,7 +423,14 @@ QMap<int, QString> Event::toMap() const QMap<int, QString> m; + + if ( !description().isEmpty() ) m.insert( DatebookDescription, description() ); + if ( !location().isEmpty() ) m.insert ( Location, location() ); + if ( categories().count() ) m.insert ( DatebookCategory, idsToString( categories() ) ); + if ( !timeZone().isEmpty() ) m.insert ( TimeZone, timeZone() ); + if ( !notes().isEmpty() ) m.insert ( Note, notes() ); + m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); @@ -176,2 +453,5 @@ QMap<int, QString> Event::toMap() const +/*! + \internal +*/ void Event::setRepeat( const RepeatPattern &p ) @@ -181,2 +461,5 @@ void Event::setRepeat( const RepeatPattern &p ) +/*! + Sets the description of the event to \a s. +*/ void Event::setDescription( const QString &s ) @@ -186,2 +469,5 @@ void Event::setDescription( const QString &s ) +/*! + Sets the location of the event to \a s. +*/ void Event::setLocation( const QString &s ) @@ -196,2 +482,5 @@ void Event::setLocation( const QString &s ) +/*! + \internal +*/ void Event::setType( Type t ) @@ -201,2 +490,6 @@ void Event::setType( Type t ) +/*! + Sets the start date and time of the first or only occurance of this event + to the date and time \a d. \a d should be in local time. +*/ void Event::setStart( const QDateTime &d ) @@ -206,2 +499,5 @@ void Event::setStart( const QDateTime &d ) +/*! + \internal +*/ void Event::setStart( time_t time ) @@ -211,2 +507,6 @@ void Event::setStart( time_t time ) +/*! + Sets the end date and time of the first or only occurance of this event + to the date and time \a d. \a d should be in local time. +*/ void Event::setEnd( const QDateTime &d ) @@ -216,2 +516,5 @@ void Event::setEnd( const QDateTime &d ) +/*! + \internal +*/ void Event::setEnd( time_t time ) @@ -221,2 +524,5 @@ void Event::setEnd( time_t time ) +/*! + \internal +*/ void Event::setTimeZone( const QString &z ) @@ -226,2 +532,5 @@ void Event::setTimeZone( const QString &z ) +/*! + \internal +*/ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) @@ -233,2 +542,5 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) +/*! + \internal +*/ void Event::setRepeat( bool b, const RepeatPattern &p ) @@ -239,2 +551,5 @@ void Event::setRepeat( bool b, const RepeatPattern &p ) +/*! + Sets the notes for the event to \a n. +*/ void Event::setNotes( const QString &n ) @@ -244,2 +559,5 @@ void Event::setNotes( const QString &n ) +/*! + Returns the description of the event. +*/ const QString &Event::description() const @@ -249,2 +567,5 @@ const QString &Event::description() const +/*! + Returns the location of the event. +*/ const QString &Event::location() const @@ -259,2 +580,5 @@ const QString &Event::location() const +/*! + \internal +*/ Event::Type Event::type() const @@ -264,2 +588,5 @@ Event::Type Event::type() const +/*! + \internal +*/ QDateTime Event::start( bool actual ) const @@ -276,2 +603,5 @@ QDateTime Event::start( bool actual ) const +/*! + \internal +*/ QDateTime Event::end( bool actual ) const @@ -288,2 +618,5 @@ QDateTime Event::end( bool actual ) const +/*! + \internal +*/ const QString &Event::timeZone() const @@ -293,2 +626,5 @@ const QString &Event::timeZone() const +/*! + \internal +*/ bool Event::hasAlarm() const @@ -298,2 +634,5 @@ bool Event::hasAlarm() const +/*! + \internal +*/ int Event::alarmTime() const @@ -303,2 +642,5 @@ int Event::alarmTime() const +/*! + Returns the sound type for the alarm of this event. +*/ Event::SoundTypeChoice Event::alarmSound() const @@ -308,2 +650,5 @@ Event::SoundTypeChoice Event::alarmSound() const +/*! + \internal +*/ bool Event::hasRepeat() const @@ -313,2 +658,5 @@ bool Event::hasRepeat() const +/*! + \internal +*/ const Event::RepeatPattern &Event::repeatPattern() const @@ -318,2 +666,5 @@ const Event::RepeatPattern &Event::repeatPattern() const +/*! + \internal +*/ Event::RepeatPattern &Event::repeatPattern() @@ -323,2 +674,5 @@ Event::RepeatPattern &Event::repeatPattern() +/*! + Returns the notes for the event. +*/ const QString &Event::notes() const @@ -328,4 +682,9 @@ const QString &Event::notes() const +/*! + \internal +*/ bool Event::operator==( const Event &e ) const { + if ( uid() && e.uid() == uid() ) + return TRUE; return ( e.descript == descript && @@ -345,2 +704,6 @@ bool Event::operator==( const Event &e ) const +/*! + \internal + Appends the contact information to \a buf. +*/ void Event::save( QString& buf ) @@ -380,2 +743,5 @@ void Event::save( QString& buf ) +/*! + \internal +*/ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const @@ -392,2 +758,24 @@ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const +/*! + \class EffectiveEvent + \brief The EffectiveEvent class the data for a single occurance of an event. + + This class describes the event for a single occurance of it. For example if + an Event occurs every week, the effective event might represent the third + occurance of this Event. + + \ingroup qtopiaemb + \ingroup qtopiadesktop + \warning This class will be phased out in Qtopia 3.x +*/ + +/*! + \enum EffectiveEvent::Position + \internal +*/ + +/*! + \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &) + \internal +*/ @@ -402,3 +790,5 @@ public: - +/*! + \internal +*/ EffectiveEvent::EffectiveEvent() @@ -410,2 +800,5 @@ EffectiveEvent::EffectiveEvent() +/*! + \internal +*/ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) @@ -426,2 +819,5 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos +/*! + \internal +*/ EffectiveEvent::~EffectiveEvent() @@ -431,2 +827,5 @@ EffectiveEvent::~EffectiveEvent() +/*! + \internal +*/ EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) @@ -463,2 +862,5 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) +/*! + Returns the description of the event for this effective event. +*/ const QString &EffectiveEvent::description( ) const @@ -468,2 +870,5 @@ const QString &EffectiveEvent::description( ) const +/*! +\internal +*/ const QString &EffectiveEvent::location( ) const @@ -473,2 +878,5 @@ const QString &EffectiveEvent::location( ) const +/*! +\internal +*/ const QString &EffectiveEvent::notes() const @@ -478,2 +886,5 @@ const QString &EffectiveEvent::notes() const +/*! + Returns the event associated with this effective event. +*/ const Event &EffectiveEvent::event() const @@ -483,2 +894,5 @@ const Event &EffectiveEvent::event() const +/*! + \internal +*/ const QTime &EffectiveEvent::end() const @@ -488,2 +902,5 @@ const QTime &EffectiveEvent::end() const +/*! + \internal +*/ const QTime &EffectiveEvent::start() const @@ -493,2 +910,5 @@ const QTime &EffectiveEvent::start() const +/*! + Returns the date the effective event occurs on. +*/ const QDate &EffectiveEvent::date() const @@ -498,2 +918,5 @@ const QDate &EffectiveEvent::date() const +/*! + \internal +*/ int EffectiveEvent::length() const @@ -504,2 +927,5 @@ int EffectiveEvent::length() const +/*! + \internal +*/ void EffectiveEvent::setDate( const QDate &dt ) @@ -509,2 +935,5 @@ void EffectiveEvent::setDate( const QDate &dt ) +/*! + \internal +*/ void EffectiveEvent::setStart( const QTime &start ) @@ -514,2 +943,5 @@ void EffectiveEvent::setStart( const QTime &start ) +/*! + \internal +*/ void EffectiveEvent::setEnd( const QTime &end ) @@ -519,2 +951,5 @@ void EffectiveEvent::setEnd( const QTime &end ) +/*! + \internal +*/ void EffectiveEvent::setEvent( Event e ) @@ -524,2 +959,5 @@ void EffectiveEvent::setEvent( Event e ) +/*! + \internal +*/ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const @@ -534,2 +972,5 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const +/*! + \internal +*/ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const @@ -539,2 +980,5 @@ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const +/*! + \internal +*/ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const @@ -547,2 +991,5 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const +/*! + \internal +*/ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const @@ -552,2 +999,5 @@ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const +/*! + \internal +*/ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const @@ -557,2 +1007,5 @@ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const +/*! + \internal +*/ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const @@ -562,2 +1015,5 @@ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const +/*! + \internal +*/ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) @@ -575,2 +1031,5 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) +/*! + \internal +*/ QDate EffectiveEvent::startDate() const @@ -585,2 +1044,5 @@ QDate EffectiveEvent::startDate() const +/*! + \internal +*/ QDate EffectiveEvent::endDate() const @@ -595,2 +1057,5 @@ QDate EffectiveEvent::endDate() const +/*! + \internal +*/ int EffectiveEvent::size() const @@ -742,11 +1207,19 @@ static Event parseVObject( VObject *obj ) - +/*! + Writes the list of \a events as a set of VCards to the file \a filename. +*/ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) {
+ QFileDirect f( filename.utf8().data() );
+ if ( !f.open( IO_WriteOnly ) ) {
+ qWarning("Unable to open vcard write");
+ return;
+ }
+ QValueList<Event>::ConstIterator it; @@ -758,2 +1231,3 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev + cleanStrTbl(); @@ -761,10 +1235,19 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev +/*! + Writes \a event as a VCard to the file \a filename. +*/ void Event::writeVCalendar( const QString &filename, const Event &event) {
+ QFileDirect f( filename.utf8().data() );
+ if ( !f.open( IO_WriteOnly ) ) {
+ qWarning("Unable to open vcard write");
+ return;
+ }
+ VObject *obj = createVObject( event ); @@ -776,3 +1259,5 @@ void Event::writeVCalendar( const QString &filename, const Event &event) - +/*! + Returns the set of events read as VCards from the file \a filename. +*/ QValueList<Event> Event::readVCalendar( const QString &filename ) diff --git a/library/backend/event.h b/library/backend/event.h index 277aadd..7fe41a5 100644 --- a/library/backend/event.h +++ b/library/backend/event.h @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -25,2 +25,3 @@ #include <qvaluelist.h> +#include <qcolor.h> @@ -29,3 +30,3 @@ #endif -#include <qpe/palmtoprecord.h> +#include <qtopia/private/palmtoprecord.h> @@ -33,2 +34,7 @@ +static const QColor colorNormal = QColor(255, 0 , 0 ); +static const QColor colorRepeat = QColor(0 , 0 , 255); +static const QColor colorNormalLight = QColor(255, 220, 220); +static const QColor colorRepeatLight = QColor(200, 200, 255); + class EventPrivate; @@ -39,4 +45,7 @@ public: MonthlyDate, Yearly }; + + // Don't use this. enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08, FRI = 0x10, SAT = 0x20, SUN = 0x40 }; + // Don't use this. struct QPC_EXPORT RepeatPattern @@ -72,2 +81,3 @@ public: + // Don't use these, there are essentially meaningless. bool operator<( const Event &e1) const { return start() < e1.start(); }; @@ -85,18 +95,45 @@ public: - void setType( Type t ); - Type type() const; + void setNotes( const QString &n ); + const QString ¬es() const; + + void setType( Type t ); // Don't use me. + Type type() const; // Don't use me. + + void setAllDay(bool); + bool isAllDay() const; + void setStart( const QDateTime &d ); - void setStart( time_t time ); - QDateTime start( bool actual = FALSE ) const; - time_t startTime() const { return startUTC; } + void setStart( time_t time ); // don't use me. + QDateTime start( ) const; + QDateTime start( bool actual ) const; // don't use me. + time_t startTime() const { return startUTC; } // don't use me. void setEnd( const QDateTime &e ); - void setEnd( time_t time ); - QDateTime end( bool actual = FALSE ) const; - time_t endTime() const { return endUTC; } + void setEnd( time_t time ); // don't use me + QDateTime end( ) const; + QDateTime end( bool actual ) const; // don't use me. + time_t endTime() const { return endUTC; } // don't use me. void setTimeZone( const QString & ); const QString &timeZone() const; - void setAlarm( bool b, int minutes, SoundTypeChoice ); + void setAlarm( int minutes, SoundTypeChoice ); + void clearAlarm(); + void setAlarm( bool b, int minutes, SoundTypeChoice ); // Don't use me. bool hasAlarm() const; - int alarmTime() const; + int alarmDelay() const; + int alarmTime() const; // Don't use me. SoundTypeChoice alarmSound() const; + + RepeatType repeatType() const; + int frequency() const; + int weekOffset() const; + QDate repeatTill() const; + bool repeatForever() const; + bool repeatOnWeekDay(int day) const; + + void setRepeatType(RepeatType); + void setFrequency(int); + void setRepeatTill(const QDate &); + void setRepeatForever(bool); + void setRepeatOnWeekDay(int day, bool enable); + + // Don't use any of these. void setRepeat( bool b, const RepeatPattern &p ); @@ -106,4 +143,2 @@ public: RepeatPattern &repeatPattern(); - void setNotes( const QString &n ); - const QString ¬es() const; bool doRepeat() const { return pattern.type != NoRepeat; } @@ -113,2 +148,6 @@ public: + bool match( const QRegExp &r ) const; + + // Don't use these either. Functionality will be moved elsewhere. + // helper function to calculate the week of the given date @@ -125,3 +164,2 @@ public: static int monthDiff( const QDate& first, const QDate& second ); - bool match( const QRegExp &r ) const; @@ -213,2 +251,105 @@ private: +inline void Event::setAlarm( int minutes, SoundTypeChoice s ) +{ + setAlarm(TRUE, minutes, s); +} + +inline void Event::clearAlarm() +{ + setAlarm(FALSE, 0, Silent); +} + +inline int Event::alarmDelay() const +{ + return alarmTime(); +} + +inline void Event::setAllDay(bool enable) +{ + if (enable) + setType(AllDay); + else + setType(Normal); +}; + +inline bool Event::isAllDay() const +{ + return type() == AllDay; +} + +inline Event::RepeatType Event::repeatType() const +{ + return repeatPattern().type; +} + +inline int Event::frequency() const +{ + return repeatPattern().frequency; +} + +inline int Event::weekOffset() const +{ + if (start().date().day() == 1) + return 1; + return (start().date().day() - 1) / 7 + 1; +} + +inline QDate Event::repeatTill() const +{ + return repeatPattern().endDate(); +} + +inline bool Event::repeatForever() const +{ + return !repeatPattern().hasEndDate; +} + +inline void Event::setRepeatType(RepeatType t) +{ + pattern.type = t; +} + +inline void Event::setFrequency(int f) +{ + pattern.frequency = f; +} + +inline void Event::setRepeatTill(const QDate &d) +{ + pattern.setEndDate(d); + pattern.hasEndDate = TRUE; +} + +inline void Event::setRepeatForever(bool b) +{ + if (!b == pattern.hasEndDate) + return; + if (!b && !pattern.hasEndDate) + pattern.setEndDate(end().date()); + pattern.hasEndDate = !b; +} + +inline bool Event::repeatOnWeekDay(int day) const +{ + if (pattern.type != Weekly) + return FALSE; + return ( (1 << (day - 1)) & pattern.days ) != 0; +} + +inline void Event::setRepeatOnWeekDay(int day, bool enable) +{ + if ( repeatOnWeekDay( day ) != enable ) + pattern.days ^= 1 << (day - 1); +} + +inline QDateTime Event::start( ) const +{ + return start(FALSE); +} + +inline QDateTime Event::end( ) const +{ + return end(FALSE); +} + #ifdef PALMTOPCENTER diff --git a/library/backend/palmtoprecord.cpp b/library/backend/palmtoprecord.cpp index 0d57699..3cfa874 100644 --- a/library/backend/palmtoprecord.cpp +++ b/library/backend/palmtoprecord.cpp @@ -1,14 +1,13 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included -** in the packaging of this file. +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A -** PARTICULAR PURPOSE. +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** @@ -20,8 +19,20 @@ **********************************************************************/ -#include "palmtoprecord.h" -#include "stringutil.h" +#include <qtopia/private/palmtoprecord.h> +#include <qtopia/stringutil.h> #include <qstringlist.h> +/*! \class Qtopia::PalmtopRecord palmtoprecord.h + \brief The Qtopia::PalmtopRecord class is the base class for all PIM records. + + Provides unique id and category support for all PIM records. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + + namespace Qtopia { + + Record &Record::operator=( const Record &c ) @@ -43,4 +54,7 @@ void Record::setCategories( int single ) // convenience methods provided for loading and saving to xml -QString Record::idsToString( const QArray<int> &cats ) +QString Record::idsToString( const QArray<int> &catsUnsorted ) { + QArray<int> cats = catsUnsorted; + cats.sort(); + QString str; @@ -86,3 +100,3 @@ void Record::setCustomField( const QString &key, const QString &value) { - qWarning("setting custom " + key + " to " + value); +// qWarning("setting custom " + key + " to " + value); if (customMap.contains(key)) @@ -92,3 +106,3 @@ void Record::setCustomField( const QString &key, const QString &value) - qWarning(QString("custom size %1").arg(customMap.count())); +// qWarning(QString("custom size %1").arg(customMap.count())); } @@ -109,3 +123,3 @@ QString Record::customToXml() const cit != customMap.end(); ++cit) { - qWarning(".ITEM."); +// qWarning(".ITEM."); buf += cit.key(); diff --git a/library/backend/palmtoprecord.h b/library/backend/palmtoprecord.h index 0372011..72f7d1c 100644 --- a/library/backend/palmtoprecord.h +++ b/library/backend/palmtoprecord.h @@ -1,14 +1,13 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included -** in the packaging of this file. +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A -** PARTICULAR PURPOSE. +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** @@ -20,6 +19,4 @@ **********************************************************************/ - #ifndef QTPALMTOP_RECORD_H #define QTPALMTOP_RECORD_H - #include <qglobal.h> @@ -32,3 +29,3 @@ // MOC_SKIP_BEGIN -template class QPC_EXPORT QMap<QString, QString>; +QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<QString, QString>; // MOC_SKIP_END @@ -51,3 +48,3 @@ public: - void setCategories( const QArray<int> &v ) { mCats = v; } + void setCategories( const QArray<int> &v ) { mCats = v; mCats.sort(); } void setCategories( int single ); @@ -55,2 +52,9 @@ public: + void reassignCategoryId( int oldId, int newId ) + { + int index = mCats.find( oldId ); + if ( index >= 0 ) + mCats[index] = newId; + } + int uid() const { return mUid; }; @@ -79,5 +83,3 @@ protected: virtual UidGen &uidGen() = 0; - virtual QString customToXml() const; - private: @@ -85,5 +87,3 @@ private: QArray<int> mCats; - QMap<QString, QString> customMap; - RecordPrivate *d; @@ -94 +94,2 @@ private: #endif + diff --git a/library/backend/palmtopuidgen.h b/library/backend/palmtopuidgen.h index 1a16681..c3fbcb9 100644 --- a/library/backend/palmtopuidgen.h +++ b/library/backend/palmtopuidgen.h @@ -1,18 +1,15 @@ -#ifndef QTPALMTOP_UIDGEN_H -#define QTPALMTOP_UIDGEN_H /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** -** Licensees holding valid Qtopia Developer license may use this -** file in accordance with the Qtopia Developer License Agreement -** provided with the Software. +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR -** PURPOSE. +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** -** email sales@trolltech.com for information about Qtopia License -** Agreements. +** See http://www.trolltech.com/gpl/ for GPL licensing information. ** @@ -23,2 +20,5 @@ +#ifndef QTPALMTOP_UIDGEN_H +#define QTPALMTOP_UIDGEN_H + #include <time.h> @@ -29,3 +29,3 @@ // MOC_SKIP_BEGIN -template class QPC_EXPORT QMap< int, bool >; +QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap< int, bool >; // MOC_SKIP_END diff --git a/library/backend/qfiledirect_p.h b/library/backend/qfiledirect_p.h index 3ade622..976c69f 100644 --- a/library/backend/qfiledirect_p.h +++ b/library/backend/qfiledirect_p.h @@ -1,3 +1,3 @@ /**********************************************************************
-** Copyright (C) 2001 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. **
@@ -5,12 +5,11 @@ **
-** Licensees holding valid Qtopia Developer license may use this
-** file in accordance with the Qtopia Developer License Agreement
-** provided with the Software.
+** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. **
-** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
-** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-** PURPOSE.
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. **
-** email sales@trolltech.com for information about Qtopia License
-** Agreements.
+** See http://www.trolltech.com/gpl/ for GPL licensing information. **
@@ -24,3 +23,3 @@ #include <qfile.h>
-#include <qpe/qpcglobal.h>
+#include <qtopia/private/qpcglobal.h> @@ -36,2 +35 @@ public: #endif
-
diff --git a/library/backend/qpcglobal.h b/library/backend/qpcglobal.h index 0d60272..7b71f06 100644 --- a/library/backend/qpcglobal.h +++ b/library/backend/qpcglobal.h @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -24,4 +24,5 @@ -#if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER) #include <qglobal.h> + +#if ( defined(Q_OS_WIN32) || defined(Q_OS_WIN64) ) && defined(PALMTOPCENTER) // # if defined(QT_NODLL) @@ -34,2 +35,3 @@ # define QPC_EXPORT __declspec(dllexport) +# define QPC_TEMPLATEEXTERN # define QPC_TEMPLATEDLL @@ -38,2 +40,3 @@ # define QPC_EXPORT __declspec(dllimport) +# define QPC_TEMPLATEEXTERN extern # define QPC_TEMPLATEDLL diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h index 4196c8b..1167ed3 100644 --- a/library/backend/recordfields.h +++ b/library/backend/recordfields.h @@ -1,16 +1,15 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** -** Licensees holding valid Qtopia Developer license may use this -** file in accordance with the Qtopia Developer License Agreement -** provided with the Software. +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR -** PURPOSE. +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** -** email sales@trolltech.com for information about Qtopia License -** Agreements. +** See http://www.trolltech.com/gpl/ for GPL licensing information. ** @@ -90,5 +89,6 @@ namespace Qtopia Notes, - Groups - ,rid, + // used for internal record keeping, not for end user. + Groups, + rid, rinfo diff --git a/library/backend/stringutil.cpp b/library/backend/stringutil.cpp deleted file mode 100644 index df58f54..0000000 --- a/library/backend/stringutil.cpp +++ b/dev/null @@ -1,415 +0,0 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included -** in the packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A -** PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include "stringutil.h" -#include <qregexp.h> -#include <qstringlist.h> - -namespace Qtopia -{ - - - -/* - Very, very simple Latin-1 only collation guaranteed to displease anyone - who actually uses the non-ASCII characters. - */ - -static const char collationHack[] = { -0x00, //C-@ -0x01, //C-A -0x02, //C-B -0x03, //C-C -0x04, //C-D -0x05, //C-E -0x06, //C-F -0x07, //C-G -0x08, //C-H -0x09, //C-I -0x0a, //C-J -0x0b, //C-K -0x0c, //C-L -0x0d, //C-M -0x0e, //C-N -0x0f, //C-O -0x10, //C-P -0x11, //C-Q -0x12, //C-R -0x13, //C-S -0x14, //C-T -0x15, //C-U -0x16, //C-V -0x17, //C-W -0x18, //C-X -0x19, //C-Y -0x1a, //C-Z -0x1b, //C-[ -0x1c, //C-\ -0x1d, //C-] -0x1e, //C-^ -0x1f, //C-_ -' ', // -'!', //! -'"', //" -'#', //# -'$', //$ -'%', //% -'&', //& -'\'', //' -'(', //( -')', //) -'*', //* -'+', //+ -',', //, -'-', //- -'.', //. -'/', /// -0x80, //0 -0x81, //1 -0x82, //2 -0x83, //3 -0x84, //4 -0x85, //5 -0x86, //6 -0x87, //7 -0x88, //8 -0x89, //9 -':', //: -';', //; -'<', //< -'=', //= -'>', //> -'?', //? -'@', //@ -'A', //A -'B', //B -'C', //C -'D', //D -'E', //E -'F', //F -'G', //G -'H', //H -'I', //I -'J', //J -'K', //K -'L', //L -'M', //M -'N', //N -'O', //O -'P', //P -'Q', //Q -'R', //R -'S', //S -'T', //T -'U', //U -'V', //V -'W', //W -'X', //X -'Y', //Y -'Z', //Z -'[', //[ -'\\', //\ -']', //] -'^', //^ -'_', //_ -'`', //` -'A', //a -'B', //b -'C', //c -'D', //d -'E', //e -'F', //f -'G', //g -'H', //h -'I', //i -'J', //j -'K', //k -'L', //l -'M', //m -'N', //n -'O', //o -'P', //p -'Q', //q -'R', //r -'S', //s -'T', //t -'U', //u -'V', //v -'W', //w -'X', //x -'Y', //y -'Z', //z -'{', //{ -'|', //| -'}', //} -'~', //~ -'', // -0x80, //C-M-@ -0x81, //C-M-A -0x82, //C-M-B -0x83, //C-M-C -0x84, //C-M-D -0x85, //C-M-E -0x86, //C-M-F -0x87, //C-M-G -0x88, //C-M-H -0x89, //C-M-I -0x8a, //C-M-J -0x8b, //C-M-K -0x8c, //C-M-L -0x8d, //C-M-M -0x8e, //C-M-N -0x8f, //C-M-O -0x90, //C-M-P -0x91, //C-M-Q -0x92, //C-M-R -0x93, //C-M-S -0x94, //C-M-T -0x95, //C-M-U -0x96, //C-M-V -0x97, //C-M-W -0x98, //C-M-X -0x99, //C-M-Y -0x9a, //C-M-Z -0x9b, //C-M-[ -0x9c, //C-M-\ -0x9d, //C-M-] -0x9e, //C-M-^ -0x9f, //C-M-_ -' ', // -'¡', //¡ -'¢', //¢ -'£', //£ -'¤', //¤ -'¥', //¥ -'¦', //¦ -'§', //§ -'¨', //¨ -'©', //© -'A', //ª -'«', //« -'¬', //¬ -'', // -'®', //® -'¯', //¯ -'O', //° -'±', //± -'²', //² -'³', //³ -'´', //´ -'µ', //µ -'P', //¶ -'·', //· -'¸', //¸ -'¹', //¹ -'O', //º -'»', //» -'¼', //¼ -'½', //½ -'¾', //¾ -'¿', //¿ -'A', //À -'A', //Á -'A', //Â -'A', //Ã -'A', //Ä -'A', //Å -'A', //Æ -'C', //Ç -'E', //È -'E', //É -'E', //Ê -'E', //Ë -'I', //Ì -'I', //Í -'I', //Î -'I', //Ï -'D', //Ð -'N', //Ñ -'O', //Ò -'O', //Ó -'O', //Ô -'O', //Õ -'O', //Ö -'×', //× -'O', //Ø -'U', //Ù -'U', //Ú -'U', //Û -'U', //Ü -'Y', //Ý -'T', //Þ -'S', //ß -'A', //à -'A', //á -'A', //â -'A', //ã -'A', //ä -'A', //å -'A', //æ -'C', //ç -'E', //è -'E', //é -'E', //ê -'E', //ë -'I', //ì -'I', //í -'I', //î -'I', //ï -'D', //ð -'N', //ñ -'O', //ò -'O', //ó -'O', //ô -'O', //õ -'O', //ö -'÷', //÷ -'O', //ø -'U', //ù -'U', //ú -'U', //û -'U', //ü -'Y', //ý -'T', //þ -'Y', //ÿ -}; - - - - - -static void hackString ( QString &s ) -{ - int len = s.length(); - const QChar* uc = s.unicode(); - for ( int i = 0; i < len; i++ ) { - if ( !uc++->row() ) - s[i] = collationHack[s[i].cell()]; - } -} - -QString buildSortKey( const QString & s ) -{ - QString res = s; - hackString( res ); - return res; -} - -QString buildSortKey( const QString & s1, const QString & s2 ) -{ - QString res = s1 + QChar( '\0' ) + s2; - hackString( res ); - return res; -} - -QString buildSortKey( const QString & s1, const QString & s2, - const QString & s3 ) -{ - QString res = s1 + QChar( '\0' ) + s2 + QChar( '\0' ) + s3; - hackString( res ); - return res; -} - -static inline QChar coll( QChar u ) -{ - return u.row() ? u : QChar(collationHack[ u.cell() ]); -} - - -int compare( const QString & s1, const QString & s2 ) -{ - const QChar* u1 = s1.unicode(); - const QChar* u2 = s2.unicode(); - - if ( u1 == u2 ) - return 0; - if ( u1 == 0 ) - return 1; - if ( u2 == 0 ) - return -1; - int l=QMIN(s1.length(),s2.length()); - while ( l-- && coll(*u1) == coll(*u2) ) - u1++,u2++; - if ( l==-1 ) - return ( s1.length()-s2.length() ); - return u1->unicode() - u2->unicode(); -} - -QString simplifyMultiLineSpace( const QString &multiLine ) -{ - QString result; - QStringList lines = QStringList::split("\n", multiLine); - for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) { - if ( it != lines.begin() ) - result += "\n"; - result += (*it).simplifyWhiteSpace(); - } - return result; -} - -QString escapeString( const QString& plain ) -{ - QString tmp(plain); - int pos = tmp.length(); - const QChar *uc = plain.unicode(); - while ( pos-- ) { - unsigned char ch = uc[pos].latin1(); - if ( ch == '&' ) - tmp.replace( pos, 1, "&" ); - else if ( ch == '<' ) - tmp.replace( pos, 1, "<" ); - else if ( ch == '>' ) - tmp.replace( pos, 1, ">" ); - else if ( ch == '\"' ) - tmp.replace( pos, 1, """ ); - } - return tmp; -} - -QString plainString( const char* escaped, unsigned int length ) -{ - return plainString( QString::fromUtf8( escaped, length ) ); -} - -QString plainString( const QCString& string ) -{ - // We first have to pass it through a ::fromUtf8() - return plainString( string.data(), string.length() ); -} - -QString plainString( const QString& string ) -{ - QString tmp( string ); - int pos = -1; - while ( (pos = tmp.find( "&", pos +1 ) ) != -1 ) { - if ( tmp.find( "&", pos ) == pos ) - tmp.replace( pos, 5, "&" ); - else if ( tmp.find( "<", pos ) == pos ) - tmp.replace( pos, 4, "<" ); - else if( tmp.find( ">", pos ) == pos ) - tmp.replace( pos, 4, ">" ); - else if ( tmp.find( """, pos ) == pos ) - tmp.replace( pos, 6, "\"" ); - } - return tmp; -} - -} // 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 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included -** in the packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING -** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A -** PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - - -#ifndef QTPALMTOP_stringutil_h__ -#define QTPALMTOP_stringutil_h__ - -#include <qstring.h> -#include "qpcglobal.h" - -namespace Qtopia -{ - -// Simplifies white space within each line but keeps the new line characters -QString QPC_EXPORT simplifyMultiLineSpace( const QString &multiLine ); - -// Creates a QString which doesn't contain any "dangerous" -// characters (i.e. <, >, &, ") -QString QPC_EXPORT escapeString( const QString& plain ); - -// Takes a UTF-8!! string and removes all the XML thingies (entities?) -// from the string and also calls fromUtf8() on it... so make sure -// to pass a QCString/const char* with UTF-8 data only -QString QPC_EXPORT plainString( const char* escaped, unsigned int length ); -QString QPC_EXPORT plainString( const QCString& string ); - -QString QPC_EXPORT plainString( const QString& string ); - - -// collation functions -int compare( const QString & s1, const QString & s2 ); -QString buildSortKey( const QString & s ); -QString buildSortKey( const QString & s1, const QString & s2 ); -QString buildSortKey( const QString & s1, const QString & s2, - const QString & s3 ); - -} - -#endif diff --git a/library/backend/task.cpp b/library/backend/task.cpp index f0a38f1..a00adb3 100644 --- a/library/backend/task.cpp +++ b/library/backend/task.cpp @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -20,10 +20,12 @@ -#include <qpe/task.h> -#include <qregexp.h> -#include <qstring.h> -#include <qpe/recordfields.h> +#include "task.h" +#include "recordfields.h" #include "vobject_p.h" -#include "timeconversion.h" #include "qfiledirect_p.h" +#include <qtopia/timeconversion.h> + +#include <qregexp.h> +#include <qstring.h> + #include <stdio.h> @@ -33,2 +35,16 @@ UidGen Task::sUidGen( UidGen::Qtopia ); +/*! + \class Task + \brief The Task class holds the data of a todo entry. + + This data includes the priority of the task, a description, an optional due + date, and whether the task is completed or not. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + +/*! + Creates a new, empty task. +*/ Task::Task() : Record(), mDue( FALSE ), @@ -39,2 +55,85 @@ mCompleted( FALSE ), mPriority( 3 ), mDesc() +/*! + \fn void Task::setPriority( int priority ) + + Sets the priority of the task to \a priority. +*/ + +/*! + \fn int Task::priority() const + + Returns the priority of the task. +*/ + +/*! + \fn void Task::setDescription( const QString &description ) + + Sets the description of the task to \a description. + */ + +/*! + \fn const QString &Task::description() const + + Returns the description of the task. + */ + +/*! + \fn void Task::setDueDate( const QDate &date, bool hasDue ) + + \internal + If \a hasDue is TRUE sets the due date of the task to \a date. + Otherwise clears the due date of the task. +*/ + +/*! + \fn void Task::setDueDate( const QDate &date ) + + Sets the due date of the task to \a date. +*/ + +/*! + \fn void Task::clearDueDate( ) + + Clears the due date of the task. +*/ + +/*! + \fn void Task::setCompleted( bool b ) + + If \a b is TRUE marks the task as completed. Otherwise marks the task as + uncompleted. +*/ + +/*! + \fn bool Task::isCompleted() const + + Returns TRUE if the task is completed. Otherwise returns FALSE. +*/ + +/*! + \fn const QDate &Task::dueDate() const + + Returns the due date of the task. + */ + +/*! + \fn bool Task::hasDueDate() const + + Returns TRUE if there is a due date set for the task. Otherwise returns + FALSE. +*/ + +/*! + \fn void Task::setHasDueDate( bool b ) + + \internal + Just don't ask. I really can't justify the function. +*/ + + +/*! + \internal + Creates a new task. The properties of the task are set from \a m. +*/ + Task::Task( const QMap<int, QString> &m ) : Record(), mDue( FALSE ), @@ -53,3 +152,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() case TaskUid: setUid( (*it).toInt() ); break; - default: break; + case TaskRid: + case TaskRinfo: + break; } @@ -57,2 +158,5 @@ mDueDate( QDate::currentDate() ), mCompleted( FALSE ), mPriority( 3 ), mDesc() +/*! + Destroys a task. +*/ Task::~Task() @@ -61,2 +165,6 @@ Task::~Task() +/*! + \internal + Returns the task as a map of field ids to property values. +*/ QMap<int, QString> Task::toMap() const @@ -66,5 +174,8 @@ QMap<int, QString> Task::toMap() const m.insert( Completed, isCompleted() ? "1" : "0" ); + if ( categories().count() ) m.insert( TaskCategory, idsToString( categories() ) ); + if ( !description().isEmpty() ) m.insert( TaskDescription, description() ); m.insert( Priority, QString::number( priority() ) ); + if ( hasDueDate() ) m.insert( Date, TimeConversion::toString( dueDate() ) ); @@ -77,2 +188,6 @@ QMap<int, QString> Task::toMap() const +/*! + \internal + Appends the task information to \a buf. +*/ void Task::save( QString& buf ) const @@ -119,3 +234,7 @@ void Task::save( QString& buf ) const -bool Task::match ( const QRegExp &r ) const +/*! + Returns TRUE if the task matches the regular expressions \a regexp. + Otherwise returns FALSE. +*/ +bool Task::match ( const QRegExp ®exp ) const { @@ -124,7 +243,7 @@ bool Task::match ( const QRegExp &r ) const match = false; - if ( QString::number( mPriority ).find( r ) > -1 ) + if ( QString::number( mPriority ).find( regexp ) > -1 ) match = true; - else if ( mDue && mDueDate.toString().find( r ) > -1 ) + else if ( mDue && mDueDate.toString().find( regexp ) > -1 ) match = true; - else if ( mDesc.find( r ) > -1 ) + else if ( mDesc.find( regexp ) > -1 ) match = true; @@ -133,2 +252,5 @@ bool Task::match ( const QRegExp &r ) const +/*! + \internal +*/ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) @@ -141,2 +263,5 @@ static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QSt +/*! + \internal +*/ static inline VObject *safeAddProp( VObject *o, const char *prop) @@ -150,2 +275,5 @@ static inline VObject *safeAddProp( VObject *o, const char *prop) +/*! + \internal +*/ static VObject *createVObject( const Task &t ) @@ -166,3 +294,5 @@ static VObject *createVObject( const Task &t ) - +/*! + \internal +*/ static Task parseVObject( VObject *obj ) @@ -209,3 +339,5 @@ static Task parseVObject( VObject *obj ) - +/*! + Writes the list of \a tasks as a set of VCards to the file \a filename. +*/ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &tasks) @@ -228,2 +360,5 @@ void Task::writeVCalendar( const QString &filename, const QValueList<Task> &task +/*! + Writes \a task as a VCard to the file \a filename. +*/ void Task::writeVCalendar( const QString &filename, const Task &task) @@ -243,3 +378,5 @@ void Task::writeVCalendar( const QString &filename, const Task &task) - +/*! + Returns the set of tasks read as VCards from the file \a filename. +*/ QValueList<Task> Task::readVCalendar( const QString &filename ) diff --git a/library/backend/task.h b/library/backend/task.h index 6f383b8..091f2e9 100644 --- a/library/backend/task.h +++ b/library/backend/task.h @@ -1,5 +1,5 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** @@ -22,4 +22,4 @@ -#include <qpe/palmtoprecord.h> -#include <qpe/stringutil.h> +#include <qtopia/private/palmtoprecord.h> +#include <qtopia/stringutil.h> @@ -42,2 +42,4 @@ public: + enum PriorityValue { VeryHigh=1, High, Normal, Low, VeryLow }; + void setPriority( int priority ) { mPriority = priority; } @@ -53,6 +55,12 @@ public: + // Use THESE functions + void setDueDate( const QDate &date); + void clearDueDate(); + + // Instead of these functions. void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } + void setHasDueDate( bool b ) { mDue = b; } + const QDate &dueDate() const { return mDueDate; } bool hasDueDate() const { return mDue; } - void setHasDueDate( bool b ) { mDue = b; } @@ -80,2 +88,5 @@ private: +// MUST be inline. (forwards compatability). +inline void Task::setDueDate( const QDate &date) { setDueDate(date, date.isValid()); } +inline void Task::clearDueDate() { setHasDueDate( FALSE ); } #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 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#include <qglobal.h> -#include "timeconversion.h" -#include <qregexp.h> -#include <stdlib.h> - -QString TimeConversion::toString( const QDate &d ) -{ - QString r = QString::number( d.day() ) + "." + - QString::number( d.month() ) + "." + - QString::number( d.year() ); - //qDebug("TimeConversion::toString %s", r.latin1()); - return r; -} - -QDate TimeConversion::fromString( const QString &datestr ) -{ - int monthPos = datestr.find('.'); - int yearPos = datestr.find('.', monthPos+1 ); - if ( monthPos == -1 || yearPos == -1 ) { - qDebug("fromString didn't find . in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, yearPos ); - return QDate(); - } - int d = datestr.left( monthPos ).toInt(); - int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); - int y = datestr.mid( yearPos+1 ).toInt(); - QDate date ( y,m,d ); - //qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, yearPos); - return date; -} - -time_t TimeConversion::toUTC( const QDateTime& dt ) -{ - time_t tmp; - struct tm *lt; - -#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) - _tzset(); -#else - tzset(); -#endif - - // get a tm structure from the system to get the correct tz_name - tmp = time( 0 ); - lt = localtime( &tmp ); - - lt->tm_sec = dt.time().second(); - lt->tm_min = dt.time().minute(); - lt->tm_hour = dt.time().hour(); - lt->tm_mday = dt.date().day(); - lt->tm_mon = dt.date().month() - 1; // 0-11 instead of 1-12 - lt->tm_year = dt.date().year() - 1900; // year - 1900 - //lt->tm_wday = dt.date().dayOfWeek(); ignored anyway - //lt->tm_yday = dt.date().dayOfYear(); ignored anyway - lt->tm_wday = -1; - lt->tm_yday = -1; - // tm_isdst negative -> mktime will find out about DST - lt->tm_isdst = -1; - // keep tm_zone and tm_gmtoff - tmp = mktime( lt ); - return tmp; -} - -QDateTime TimeConversion::fromUTC( time_t time ) -{ - struct tm *lt; - -#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) - _tzset(); -#else - tzset(); -#endif - lt = localtime( &time ); - QDateTime dt; - dt.setDate( QDate( lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday ) ); - dt.setTime( QTime( lt->tm_hour, lt->tm_min, lt->tm_sec ) ); - return dt; -} - - -int TimeConversion::secsTo( const QDateTime &from, const QDateTime &to ) -{ - return toUTC( to ) - toUTC( from ); -} - -QCString TimeConversion::toISO8601( const QDate &d ) -{ - time_t tmp = toUTC( d ); - struct tm *utc = gmtime( &tmp ); - - QCString str; - str.sprintf("%04d%02d%02d", (utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday ); - return str; -} - -QCString TimeConversion::toISO8601( const QDateTime &dt ) -{ - time_t tmp = toUTC( dt ); - struct tm *utc = gmtime( &tmp ); - - QCString str; - str.sprintf("%04d%02d%02dT%02d%02d%02dZ", - (utc->tm_year + 1900), utc->tm_mon+1, utc->tm_mday, - utc->tm_hour, utc->tm_min, utc->tm_sec ); - return str; -} - -QDateTime TimeConversion::fromISO8601( const QCString &s ) -{ - -#if defined(_OS_WIN32) || defined (Q_OS_WIN32) || defined (Q_OS_WIN64) - _tzset(); -#else - tzset(); -#endif - - struct tm *thetime = new tm; - - QCString str = s.copy(); - str.replace(QRegExp("-"), "" ); - str.replace(QRegExp(":"), "" ); - str.stripWhiteSpace(); - str = str.lower(); - - int i = str.find( "t" ); - QCString date; - QCString timestr; - if ( i != -1 ) { - date = str.left( i ); - timestr = str.mid( i+1 ); - } else { - date = str; - } - -// qDebug("--- parsing ISO time---"); - thetime->tm_year = 100; - thetime->tm_mon = 0; - thetime->tm_mday = 0; - thetime->tm_hour = 0; - thetime->tm_min = 0; - thetime->tm_sec = 0; - -// qDebug("date = %s", date.data() ); - - switch( date.length() ) { - case 8: - thetime->tm_mday = date.right( 2 ).toInt(); - case 6: - thetime->tm_mon = date.mid( 4, 2 ).toInt() - 1; - case 4: - thetime->tm_year = date.left( 4 ).toInt(); - thetime->tm_year -= 1900; - break; - default: - break; - } - - int tzoff = 0; - bool inLocalTime = FALSE; - if ( timestr.find( 'z' ) == (int)timestr.length() - 1 ) - // UTC - timestr = timestr.left( timestr.length() -1 ); - else { - int plus = timestr.find( "+" ); - int minus = timestr.find( "-" ); - if ( plus != -1 || minus != -1 ) { - // have a timezone offset - plus = (plus != -1) ? plus : minus; - QCString off = timestr.mid( plus ); - timestr = timestr.left( plus ); - - int tzoffhour = 0; - int tzoffmin = 0; - switch( off.length() ) { - case 5: - tzoffmin = off.mid(3).toInt(); - case 3: - tzoffhour = off.left(3).toInt(); - default: - break; - } - tzoff = 60*tzoffhour + tzoffmin; - } else - inLocalTime = TRUE; - } - - // get the time: - switch( timestr.length() ) { - case 6: - thetime->tm_sec = timestr.mid( 4 ).toInt(); - case 4: - thetime->tm_min = timestr.mid( 2, 2 ).toInt(); - case 2: - thetime->tm_hour = timestr.left( 2 ).toInt(); - default: - break; - } - - int tzloc = 0; - time_t tmp = time( 0 ); - if ( !inLocalTime ) { - // have to get the offset between gmt and local time - struct tm *lt = localtime( &tmp ); - tzloc = mktime( lt ); - struct tm *ut = gmtime( &tmp ); - tzloc -= mktime( ut ); - } -// qDebug("time: %d %d %d, tzloc=%d, tzoff=%d", thetime->tm_hour, thetime->tm_min, thetime->tm_sec, -// tzloc, tzoff ); - - tmp = mktime( thetime ); - tmp += 60*(-tzloc + tzoff); - - delete thetime; - - return fromUTC( tmp ); -} - 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 @@ -/********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. -** -** This file is part of Qtopia Environment. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.trolltech.com/gpl/ for GPL licensing information. -** -** Contact info@trolltech.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -#ifndef __timeconversion_h__ -#define __timeconversion_h__ - -#include <time.h> -#include <sys/types.h> -#include <qdatetime.h> - -#include <qpe/qpcglobal.h> - -class QPC_EXPORT TimeConversion -{ -public: - static QString toString( const QDate &d ); - static QDate fromString( const QString &datestr ); - - static time_t toUTC( const QDateTime& dt ); - static QDateTime fromUTC( time_t time ); - static int secsTo( const QDateTime &from, const QDateTime &to ); - - static QCString toISO8601( const QDate & ); - static QCString toISO8601( const QDateTime & ); - static QDateTime fromISO8601( const QCString & ); -}; - -#endif // __timeconversion_h__ diff --git a/library/backend/vcc.y b/library/backend/vcc.y index e326a64..5bcf0cb 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y @@ -519,3 +519,3 @@ static int lexWithinMode(enum LexMode mode) { -static char lexGetc_() +static int lexGetc_()
{ @@ -933,56 +933,65 @@ static char* lexGetQuotedPrintable() { - char cur; - + int c;
+ lexSkipWhite();
+ c = lexLookahead();
lexClearToken(); - do { - cur = lexGetc(); - switch (cur) { - case '=': { - int c = 0; - int next[2]; - int i; - for (i = 0; i < 2; i++) { - next[i] = lexGetc(); - if (next[i] >= '0' && next[i] <= '9') - c = c * 16 + next[i] - '0'; - else if (next[i] >= 'A' && next[i] <= 'F') - c = c * 16 + next[i] - 'A' + 10; - else +
+ while (c != EOF && c != ';') {
+ if (c == '\n') {
+ // break, leave '\n' on remaining chars.
break; + } else if (c == '=') {
+ int cur = 0;
+ int next;
+
+ lexSkipLookahead(); // skip '='
+ next = lexLookahead();
+
+ if (next == '\n') {
+ // skip and only skip the \n
+ lexSkipLookahead();
+ c = lexLookahead();
+ ++mime_lineNum; // aid in error reporting
+ continue;
+ } else if (next >= '0' && next <= '9') {
+ cur = next - '0';
+ } else if (next >= 'A' && next <= 'F') {
+ cur = next - 'A' + 10;
+ } else {
+ // we have been sent buggy stuff. doesn't matter
+ // what we do so long as we keep going.
+ // should probably spit an error here
+ c = lexLookahead();
+ continue;
} - if (i == 0) { - /* single '=' follow by LINESEP is continuation sign? */ - if (next[0] == '\n') { - ++mime_lineNum; - } - else { - lexPushLookaheadc('='); - goto EndString; - } +
+ lexSkipLookahead(); // skip A-Z0-9
+ next = lexLookahead();
+
+ cur = cur * 16;
+ // this time really just expecting 0-9A-F
+ if (next >= '0' && next <= '9') {
+ cur += next - '0';
+ } else if (next >= 'A' && next <= 'F') {
+ cur += next - 'A' + 10;
+ } else {
+ // we have been sent buggy stuff. doesn't matter
+ // what we do so long as we keep going.
+ // should probably spit an error here
+ c = lexLookahead();
+ continue;
} - else if (i == 1) { - lexPushLookaheadc(next[1]); - lexPushLookaheadc(next[0]); - lexAppendc('='); +
+ // got a valid escaped =. append it.
+ lexSkipLookahead(); // skip second 0-9A-F
+ lexAppendc(cur);
} else { - lexAppendc(c); + lexSkipLookahead(); // skip whatever we just read.
+ lexAppendc(c); // and append it.
} - break; - } /* '=' */ - case '\n': { - lexPushLookaheadc('\n'); - goto EndString; + c = lexLookahead();
} - case (char)EOF: - break; - default: - lexAppendc(cur); - break; - } /* switch */ - } while (cur != (char)EOF); - -EndString: lexAppendc(0); - return lexStr(); - } /* LexQuotedPrintable */ + return c==EOF?0:lexStr();
+}
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp index cb24631..19a108f 100644 --- a/library/backend/vcc_yacc.cpp +++ b/library/backend/vcc_yacc.cpp @@ -1,3 +1,4 @@ #ifndef lint -static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +/*static char yysccsid[] = "from: @(#)yaccpar 1.9 (Berkeley) 02/21/93";*/ +static char yyrcsid[] = "$Id$"; #endif @@ -9,4 +10,28 @@ static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; #define YYRECOVERING (yyerrflag!=0) -#define YYPREFIX "yy" -#line 1 "vcc.y" +#define yyparse vccparse +#define yylex vcclex +#define yyerror vccerror +#define yychar vccchar +#define yyval vccval +#define yylval vcclval +#define yydebug vccdebug +#define yynerrs vccnerrs +#define yyerrflag vccerrflag +#define yyss vccss +#define yyssp vccssp +#define yyvs vccvs +#define yyvsp vccvsp +#define yylhs vcclhs +#define yylen vcclen +#define yydefred vccdefred +#define yydgoto vccdgoto +#define yysindex vccsindex +#define yyrindex vccrindex +#define yygindex vccgindex +#define yytable vcctable +#define yycheck vcccheck +#define yyname vccname +#define yyrule vccrule +#define YYPREFIX "vcc" +#line 1 "backend/vcc.y" @@ -75,2 +100,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. +#if 0
#define yyparse mime_parse
@@ -107,2 +133,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #define YYPREFIX "mime_"
+#endif
@@ -130,9 +157,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. -#ifdef PALMTOPCENTER -#include <qpe/vobject_p.h>
-#include <qpe/qfiledirect_p.h> -#else +/*#ifdef PALMTOPCENTER
*/ +/*#include <qpe/vobject_p.h>
*/ +/*#else
*/ #include "vobject_p.h"
-#include "qfiledirect_p.h" -#endif +/*#endif
*/ @@ -142,4 +167,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #define MAXTOKEN 256 /* maximum token (line) length */
-#define YYSTACKSIZE 100 /* ~unref ? -*/ +#define YYSTACKSIZE 100 /* ~unref ?
*/ #define MAXLEVEL 10 /* max # of nested objects parseable */
@@ -190,5 +214,7 @@ static void enterAttr(const char *s1, const char *s2); static void enterValues(const char *value);
+#define mime_error yyerror
+void mime_error(char *s);
void mime_error_(char *s);
-#line 185 "vcc.y" +#line 189 "backend/vcc.y" typedef union {
@@ -197,3 +223,3 @@ typedef union { } YYSTYPE; -#line 196 "y.tab.c" +#line 225 "y.tab.c" #define EQ 257 @@ -217,3 +243,3 @@ typedef union { #define YYERRCODE 256 -short yylhs[] = { -1, +short vcclhs[] = { -1, 0, 6, 6, 5, 5, 8, 3, 9, 3, 7, @@ -224,3 +250,3 @@ short yylhs[] = { -1, }; -short yylen[] = { 2, +short vcclen[] = { 2, 1, 2, 1, 1, 1, 0, 4, 0, 3, 2, @@ -231,3 +257,3 @@ short yylen[] = { 2, }; -short yydefred[] = { 0, +short vccdefred[] = { 0, 0, 0, 0, 4, 5, 3, 0, 0, 0, 0, @@ -239,3 +265,3 @@ short yydefred[] = { 0, }; -short yydgoto[] = { 3, +short vccdgoto[] = { 3, 15, 50, 4, 5, 6, 7, 22, 8, 9, 17, @@ -244,3 +270,3 @@ short yydgoto[] = { 3, }; -short yysindex[] = { -262, +short vccsindex[] = { -262, 0, 0, 0, 0, 0, 0, -262, -252, -219, -249, @@ -252,3 +278,3 @@ short yysindex[] = { -262, }; -short yyrindex[] = { 0, +short vccrindex[] = { 0, -222, -238, 0, 0, 0, 0, 65, 0, 0, 0, @@ -260,3 +286,3 @@ short yyrindex[] = { 0, }; -short yygindex[] = { 0, +short vccgindex[] = { 0, 3, 0, 0, 0, 61, 0, -7, 0, 0, -16, @@ -266,3 +292,3 @@ short yygindex[] = { 0, #define YYTABLESIZE 71 -short yytable[] = { 30, +short vcctable[] = { 30, 16, 13, 1, 13, 2, 30, 13, 37, 37, 28, @@ -276,3 +302,3 @@ short yytable[] = { 30, }; -short yycheck[] = { 16, +short vcccheck[] = { 16, 8, 256, 265, 256, 267, 22, 256, 268, 269, 260, @@ -292,3 +318,3 @@ short yycheck[] = { 16, #if YYDEBUG -char *yyname[] = { +char *vccname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -303,3 +329,3 @@ char *yyname[] = { }; -char *yyrule[] = { +char *vccrule[] = { "$accept : mime", @@ -374,3 +400,3 @@ YYSTYPE yyvs[YYSTACKSIZE]; #define yystacksize YYSTACKSIZE -#line 378 "vcc.y" +#line 382 "backend/vcc.y" @@ -513,3 +539,3 @@ static int lexWithinMode(enum LexMode mode) { -static char lexGetc_()
+static int lexGetc_()
{
@@ -927,3 +953,3 @@ static char* lexGetQuotedPrintable() {
- char cur;
+ int cur;
@@ -969,3 +995,3 @@ static char* lexGetQuotedPrintable() }
- case (char)EOF:
+ case (int)EOF:
break;
@@ -975,3 +1001,3 @@ static char* lexGetQuotedPrintable() } /* switch */
- } while (cur != (char)EOF);
+ } while (cur != (int)EOF);
@@ -1152,9 +1178,14 @@ DLLEXPORT(VObject*) Parse_MIME_FromFileName(char *fname) {
- QFileDirect f( fname );
- if ( !f.open( IO_ReadOnly ) ) {
- qWarning("Unable to open mime for reading %s", fname);
+ FILE *fp = fopen(fname,"r");
+ if (fp) {
+ VObject* o = Parse_MIME_FromFile(fp);
+ fclose(fp);
+ return o;
+ }
+ else {
+ char msg[80];
+ sprintf(msg, "can't open file '%s' for reading\n", fname);
+ mime_error_(msg);
return 0;
}
-
- return Parse_MIME_FromFile( f.directHandle() );
}
@@ -1188,3 +1219,3 @@ void mime_error_(char *s) -#line 1192 "y.tab.c" +#line 1221 "y.tab.c" #define YYABORT goto yyabort @@ -1194,3 +1225,7 @@ void mime_error_(char *s) int +#if defined(__STDC__) +yyparse(void) +#else yyparse() +#endif { @@ -1218,3 +1253,3 @@ yyparse() yyloop: - if (yyn = yydefred[yystate]) goto yyreduce; + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if (yychar < 0) @@ -1258,6 +1293,2 @@ yyloop: if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -#endif -yynewerror: yyerror("syntax error"); @@ -1330,3 +1361,3 @@ yyreduce: case 2: -#line 217 "vcc.y" +#line 221 "backend/vcc.y" { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } @@ -1334,3 +1365,3 @@ break; case 3: -#line 219 "vcc.y" +#line 223 "backend/vcc.y" { addList(&vObjList, yyvsp[0].vobj); curObj = 0; } @@ -1338,3 +1369,3 @@ break; case 6: -#line 228 "vcc.y" +#line 232 "backend/vcc.y" {
@@ -1345,3 +1376,3 @@ break; case 7: -#line 233 "vcc.y" +#line 237 "backend/vcc.y" {
@@ -1352,3 +1383,3 @@ break; case 8: -#line 238 "vcc.y" +#line 242 "backend/vcc.y" {
@@ -1359,3 +1390,3 @@ break; case 9: -#line 243 "vcc.y" +#line 247 "backend/vcc.y" {
@@ -1366,3 +1397,3 @@ break; case 12: -#line 254 "vcc.y" +#line 258 "backend/vcc.y" {
@@ -1372,3 +1403,3 @@ break; case 13: -#line 258 "vcc.y" +#line 262 "backend/vcc.y" {
@@ -1380,3 +1411,3 @@ break; case 15: -#line 267 "vcc.y" +#line 271 "backend/vcc.y" {
@@ -1386,3 +1417,3 @@ break; case 17: -#line 272 "vcc.y" +#line 276 "backend/vcc.y" {
@@ -1392,3 +1423,3 @@ break; case 21: -#line 285 "vcc.y" +#line 289 "backend/vcc.y" {
@@ -1398,3 +1429,3 @@ break; case 22: -#line 289 "vcc.y" +#line 293 "backend/vcc.y" {
@@ -1405,3 +1436,3 @@ break; case 24: -#line 298 "vcc.y" +#line 302 "backend/vcc.y" { enterValues(yyvsp[-1].str); } @@ -1409,3 +1440,3 @@ break; case 26: -#line 300 "vcc.y" +#line 304 "backend/vcc.y" { enterValues(yyvsp[0].str); } @@ -1413,3 +1444,3 @@ break; case 28: -#line 305 "vcc.y" +#line 309 "backend/vcc.y" { yyval.str = 0; } @@ -1417,3 +1448,3 @@ break; case 29: -#line 310 "vcc.y" +#line 314 "backend/vcc.y" { if (!pushVObject(VCCalProp)) YYERROR; } @@ -1421,3 +1452,3 @@ break; case 30: -#line 313 "vcc.y" +#line 317 "backend/vcc.y" { yyval.vobj = popVObject(); } @@ -1425,3 +1456,3 @@ break; case 31: -#line 315 "vcc.y" +#line 319 "backend/vcc.y" { if (!pushVObject(VCCalProp)) YYERROR; } @@ -1429,3 +1460,3 @@ break; case 32: -#line 317 "vcc.y" +#line 321 "backend/vcc.y" { yyval.vobj = popVObject(); } @@ -1433,3 +1464,3 @@ break; case 38: -#line 332 "vcc.y" +#line 336 "backend/vcc.y" {
@@ -1440,3 +1471,3 @@ break; case 39: -#line 338 "vcc.y" +#line 342 "backend/vcc.y" {
@@ -1447,3 +1478,3 @@ break; case 40: -#line 343 "vcc.y" +#line 347 "backend/vcc.y" {
@@ -1454,3 +1485,3 @@ break; case 41: -#line 348 "vcc.y" +#line 352 "backend/vcc.y" {
@@ -1461,3 +1492,3 @@ break; case 42: -#line 356 "vcc.y" +#line 360 "backend/vcc.y" {
@@ -1468,3 +1499,3 @@ break; case 43: -#line 362 "vcc.y" +#line 366 "backend/vcc.y" {
@@ -1475,3 +1506,3 @@ break; case 44: -#line 367 "vcc.y" +#line 371 "backend/vcc.y" {
@@ -1482,3 +1513,3 @@ break; case 45: -#line 372 "vcc.y" +#line 376 "backend/vcc.y" {
@@ -1488,3 +1519,3 @@ case 45: break; -#line 1492 "y.tab.c" +#line 1521 "y.tab.c" } diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index 9c2ba3b..e6f6b78 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp @@ -1007,9 +1007,69 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) +static const char *replaceChar(unsigned char c) +{ + if (c == '\n') { + return "=0A=\n"; + } else if ( + (c >= 'A' && c <= 'Z') + || + (c >= 'a' && c <= 'z') + || + (c >= '0' && c <= '9') + || + (c >= '\'' && c <= ')') + || + (c >= '+' && c <= '-') + || + (c == '/') + || + (c == '?') + || + (c == ' ')) + { + return 0; + } + + static char trans[4]; + trans[0] = '='; + trans[3] = '\0'; + int rem = c % 16; + int div = c / 16; + + if (div < 10) + trans[1] = '0' + div; + else + trans[1] = 'A' + (div - 10); + + if (rem < 10) + trans[2] = '0' + rem; + else + trans[2] = 'A' + (rem - 10); + + return trans; +} + static void writeQPString(OFile *fp, const char *s)
{
+ /* + only A-Z, 0-9 and + "'" (ASCII code 39) + "(" (ASCII code 40) + ")" (ASCII code 41) + "+" (ASCII code 43) + "," (ASCII code 44) + "-" (ASCII code 45) + "/" (ASCII code 47) + "?" (ASCII code 63) + + should remain un-encoded. + '=' needs to be encoded as it is the escape character. + ';' needs to be as it is a field separator. + + */ const char *p = s;
while (*p) {
- if (*p == '\n') {
- if (p[1]) appendsOFile(fp,"=0A=");
- }
+ const char *rep = replaceChar(*p); + if (rep) + appendsOFile(fp, rep); + else appendcOFile(fp,*p);
@@ -1019,3 +1079,18 @@ static void writeQPString(OFile *fp, const char *s) -
+static bool includesUnprintable(VObject *o) +{ + if (o) { + if (VALUE_TYPE(o) == VCVT_STRINGZ) { + const char *p = STRINGZ_VALUE_OF(o); + if (p) { + while (*p) { + if (replaceChar(*p)) + return TRUE; + p++; + } + } + } + } + return FALSE; +} @@ -1061,2 +1136,6 @@ static void writeAttrValue(OFile *fp, VObject *o) if (pi && ((pi->flags & PD_INTERNAL) != 0)) return;
+ if ( includesUnprintable(o) ) { + appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); + appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); + } appendcOFile(fp,';');
@@ -1124,2 +1203,14 @@ static void writeProp(OFile *fp, VObject *o) /* output prop as fields */
+ bool printable = TRUE; + while (*fields && printable) { + VObject *t = isAPropertyOf(o,*fields); + if (includesUnprintable(t)) + printable = FALSE; + fields++; + } + fields = fields_; + if (!printable) { + appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); + appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); + } appendcOFile(fp,':');
@@ -1140,3 +1231,8 @@ static void writeProp(OFile *fp, VObject *o) + if (VALUE_TYPE(o)) {
+ if ( includesUnprintable(o) ) { + appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); + appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); + } unsigned long size = 0;
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index a0d921e..0d0a2a8 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h @@ -76,2 +76,4 @@ which accompanied this distribution. +// No tr() anywhere in this file + @@ -144,3 +146,3 @@ For example: #define VCCGMProp "CGM"
-#define VCCharSetProp "CS"
+#define VCCharSetProp "CHARSET" #define VCCIDProp "CID"
|