williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef __VRECUR_H__ williamr@2: #define __VRECUR_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: // williamr@2: // CWeekDayArray williamr@2: // williamr@2: williamr@2: class CWeekDayArray : public CBase williamr@2: /** Defines an array of the days in the week on which a 'weekly' williamr@2: or 'monthly by position' repeat event occurs. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CWeekDayArray(); williamr@2: IMPORT_C ~CWeekDayArray(); williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream); williamr@2: public: williamr@2: /** The array of days in the week. */ williamr@2: CArrayFix* iArray; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrence williamr@2: // williamr@2: class CVersitRecurrence : public CBase williamr@2: /** Abstract base class for all recurrence property value classes. williamr@2: williamr@2: A pointer to a derived recurrence property value class instance is owned by williamr@2: the CParserPropertyValueRecurrence class. williamr@2: williamr@2: Implementations of this class define when an event is to repeat. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrence(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate); williamr@2: IMPORT_C ~CVersitRecurrence(); williamr@2: /** Externalises an occurrence list to aStream. williamr@2: williamr@2: @param aStream The stream to which the occurrence list is to be externalised. */ williamr@2: virtual void ExternalizeOccurrenceListsL(RWriteStream& aStream) const=0; williamr@2: /** Repeat type. williamr@2: @publishedAll williamr@2: @released */ williamr@2: enum TType williamr@2: { williamr@2: /** Daily repeat. */ williamr@2: EDaily=1, williamr@2: /** Weekly repeat. */ williamr@2: EWeekly, williamr@2: /** Monthly repeat, by relative position within the month. */ williamr@2: EMonthlyByPos, williamr@2: /** Monthly repeat, by day number within the month. */ williamr@2: EMonthlyByDay, williamr@2: /** Yearly repeat, by specific months within the year. */ williamr@2: EYearlyByMonth, williamr@2: /** Yearly repeat, by specific days within the year. */ williamr@2: EYearlyByDay williamr@2: }; williamr@2: public: williamr@2: /** The type of repeat (daily, weekly etc.). */ williamr@2: TType iRepeatType; williamr@2: /** The interval between repeats: a number of days, weeks, months or years, depending williamr@2: on the repeat type. */ williamr@2: TInt iInterval; williamr@2: /** The duration in days, weeks, months or years (depending on the repeat type) williamr@2: for the repeat. williamr@2: williamr@2: A value of zero indicates the repeat should continue forever. */ williamr@2: TInt iDuration; williamr@2: /** Specification for the date at which the repeat will end. If a duration and williamr@2: an end date are both specified, the end date takes precedence. */ williamr@2: TVersitDateTime* iEndDate; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceDaily williamr@2: // williamr@2: class CVersitRecurrenceDaily : public CVersitRecurrence williamr@2: /** Defines when a 'daily' recurrence is to be repeated. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define when it is williamr@2: to occur. The days on which the event occurs are identified by the number williamr@2: of days between repeats, e.g. every third day. williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrenceDaily(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate); williamr@2: public: //from CVersitRecurrence williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& /*aStream*/) const; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceWeekly williamr@2: // williamr@2: class CVersitRecurrenceWeekly : public CVersitRecurrence williamr@2: /** Defines a list of days when a 'weekly' recurrence is to be williamr@2: repeated. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define when it is williamr@2: to occur. The days on which the event occurs are identified by the number williamr@2: of weeks between repeats and the day(s) of the week on which the event occurs, williamr@2: e.g. on Monday every other week. williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrenceWeekly(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate,CWeekDayArray* aArrayOfWeekDayOccurrences); williamr@2: IMPORT_C ~CVersitRecurrenceWeekly(); williamr@2: public: //from CVersitRecurrence williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& aStream) const; williamr@2: public: williamr@2: CWeekDayArray* iArrayOfWeekDayOccurrences; //Mon-Sun williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceMonthlyByPos williamr@2: // williamr@2: class CVersitRecurrenceMonthlyByPos : public CVersitRecurrence williamr@2: /** Defines a list of days when a 'monthly by position' recurrence williamr@2: is to be repeated. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define when it is williamr@2: to occur. williamr@2: williamr@2: The days on which the event occurs are identified by their relative position williamr@2: within the month, for example the second Monday or the last Friday. williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object williamr@2: williamr@2: Note: The CMonthPosition class, defined within this class, is used to williamr@2: define the positions of days within the month. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: class CMonthPosition : public CBase williamr@2: /** Defines a week within the month, using the numeric occurrence of the week williamr@2: (between 1 and 5 inclusive) counting from either the start or end of the month, williamr@2: and defines an array of days within this week. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C ~CMonthPosition(); williamr@2: public: williamr@2: /** Flags that define whether the week number is counted from the start or end of the month. williamr@2: @publishedAll williamr@2: @released */ williamr@2: enum TSign williamr@2: { williamr@2: /** Indicates that the iWeekNo member specifies a number counting forwards williamr@2: from the start of the month. */ williamr@2: EWeeksFromStartOfMonth, williamr@2: /** Indicates that the iWeekNo member specifies a number counting backwards from williamr@2: the end of the month. */ williamr@2: EWeeksFromEndOfMonth williamr@2: }; williamr@2: public: williamr@2: /** Indicates whether the week number iWeekNo is counted from the start or the williamr@2: end of the month. A plus sign denotes from the start of the month and a minus williamr@2: sign denotes from the end. */ williamr@2: TSign iSign; williamr@2: /** A week number within the month, between 1 and 5 inclusive. */ williamr@2: TInt iWeekNo; williamr@2: /** Pointer to an array of week days. */ williamr@2: CWeekDayArray* iArrayOfWeekDays; williamr@2: }; williamr@2: IMPORT_C CVersitRecurrenceMonthlyByPos(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate,CArrayPtrFlat* aMonthPositions); williamr@2: IMPORT_C ~CVersitRecurrenceMonthlyByPos(); williamr@2: public: //framework williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& aStream) const; williamr@2: public: williamr@2: /** Array of 'month positions' which define the days on which the event occurs. */ williamr@2: CArrayPtrFlat* iMonthPositions; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceMonthlyByDay williamr@2: // williamr@2: class CVersitRecurrenceMonthlyByDay : public CVersitRecurrence williamr@2: /** Defines a list of days when a 'monthly by day' recurrence williamr@2: is to repeat. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define when it is williamr@2: to occur. williamr@2: williamr@2: The days on which the event occurs are identified by a number, counting williamr@2: either from the start or the end of the month. williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrenceMonthlyByDay(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate, CArrayFix* aArrayOfOccurrencesInDaysFromStartOfMonth williamr@2: ,CArrayFix* aArrayOfOccurrencesInDaysFromEndOfMonth,TBool aLastDay); williamr@2: IMPORT_C ~CVersitRecurrenceMonthlyByDay(); williamr@2: public: //framework williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& aStream) const; williamr@2: public: williamr@2: /** Array of days, counting from the start of the month, on which the event occurs. */ williamr@2: CArrayFix* iArrayOfOccurrencesInDaysFromStartOfMonth; //1-31 williamr@2: /** Array of days, counting from the end of the month, on which the event occurs. */ williamr@2: CArrayFix* iArrayOfOccurrencesInDaysFromEndOfMonth; //1-31 williamr@2: /** Identifies whether the event occurs on the last day of the month. */ williamr@2: TBool iLastDay; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceYearlyByMonth williamr@2: // williamr@2: class CVersitRecurrenceYearlyByMonth : public CVersitRecurrence williamr@2: /** Defines a list of months when a 'yearly by month' recurrence williamr@2: is to repeat. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define the months williamr@2: in which it is to occur. The months on which the event occurs are identified williamr@2: by their number in the year (between 1 and 12 inclusive). williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrenceYearlyByMonth(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate,CArrayFix* aArrayOfMonthsInYearOccurrences); williamr@2: IMPORT_C ~CVersitRecurrenceYearlyByMonth(); williamr@2: public: //framework williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& aStream) const; williamr@2: public: williamr@2: /** Pointer to an array of month values. */ williamr@2: CArrayFix* iArrayOfMonthsInYearOccurrences; //Jan-Dec williamr@2: }; williamr@2: williamr@2: // williamr@2: // CVersitRecurrenceYearlyByDay williamr@2: // williamr@2: class CVersitRecurrenceYearlyByDay : public CVersitRecurrence williamr@2: /** Defines a list of days when a 'yearly by day' recurrence is williamr@2: to be repeated. williamr@2: williamr@2: Used by a repeating event (a vCalendar event or to-do) to define when it is williamr@2: to occur. williamr@2: williamr@2: The days on which the repeat occurs are identified by their day number in williamr@2: the year (between 1 and 366 inclusive). williamr@2: williamr@2: A pointer to this object may be owned by a CParserPropertyValueRecurrence williamr@2: object. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CVersitRecurrenceYearlyByDay(TInt aInterval,TInt aDuration,TVersitDateTime* aEndDate,CArrayFix* aArrayOfDaysInYearOccurrences); williamr@2: IMPORT_C ~CVersitRecurrenceYearlyByDay(); williamr@2: public: //framework williamr@2: IMPORT_C void ExternalizeOccurrenceListsL(RWriteStream& aStream) const; williamr@2: public: williamr@2: /** Pointer to an array of integers between 1 and 366 inclusive. williamr@2: williamr@2: Each integer represents a day on which the repeat event occurs. */ williamr@2: CArrayFix* iArrayOfDaysInYearOccurrences; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CParserPropertyValueRecurrence williamr@2: // williamr@2: class CParserPropertyValueRecurrence : public CParserTimePropertyValue williamr@2: /** A recurrence property value parser. williamr@2: williamr@2: This is used to store and retrieve the recurrence information for a repeating williamr@2: vEvent or vTodo. This information is stored as a CVersitRecurrence object. williamr@2: williamr@2: The UID for a recurrence property value is KVCalPropertyRecurrenceUid. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CParserPropertyValueRecurrence(CVersitRecurrence* aValue); williamr@2: IMPORT_C ~CParserPropertyValueRecurrence(); williamr@2: inline CVersitRecurrence* Value() const; williamr@2: public: // from CParserTimePropertyValue williamr@2: IMPORT_C void ConvertAllDateTimesToUTCL(const TTimeIntervalSeconds& aIncrement,const CVersitDaylight* aDaylight); williamr@2: IMPORT_C void ConvertAllUTCDateTimesToMachineLocalL(const TTimeIntervalSeconds& aIncrement); williamr@2: public: // from CParserPropertyValue williamr@2: IMPORT_C void ExternalizeL(RWriteStream& aStream,const Versit::TEncodingAndCharset& /*aEncodingCharset*/,TInt /*aLengthOutput*/); williamr@2: protected: williamr@2: CVersitRecurrence* iValue; williamr@2: }; williamr@2: williamr@2: // williamr@2: // CRecurrenceParser williamr@2: // williamr@2: class CRecurrenceParser : public CVersitParser williamr@2: /** Base class used in the derivation of CParserVCalEntity. williamr@2: williamr@2: Provides recurrence functionality for vEvents and vToDos in vCalendars. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CRecurrenceParser(TBool aHasVersion); williamr@2: IMPORT_C CParserPropertyValue* MakePropertyValueRecurrenceL(TDes& aRecurringEntity); williamr@2: private: williamr@2: static void ResetAndDestroyArrayOfMonthPositions(TAny* aObject); williamr@2: void GetFrequencyAndIntervalL(CVersitRecurrence::TType& aFrequency,TInt& aInterval, const TDesC& aRecurrenceType); williamr@2: CVersitRecurrence* GetFrequencyModifiersL(const CVersitRecurrence::TType& aRepeatType,TInt aInterval, const TDesC& aListDates); williamr@2: CWeekDayArray* GetListOfWeekDayOccurrencesL(const TDesC& aListDays); williamr@2: private: // from CVersitParser williamr@2: IMPORT_C virtual void Reserved1(); williamr@2: IMPORT_C virtual void Reserved2(); williamr@2: }; williamr@2: williamr@2: #include williamr@2: williamr@2: #endif