williamr@2: // Copyright (c) 2005-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 __CALRRULE_H__ williamr@2: #define __CALRRULE_H__ williamr@2: williamr@2: #include williamr@2: williamr@2: /** Class representing iCal repeat types. williamr@2: williamr@2: This supports the following standard iCal properties: williamr@2: - FREQ (rule type), williamr@2: - DTSTART (start date), williamr@2: - UNTIL (end date), williamr@2: - COUNT (number of instances), williamr@2: - INTERVAL (interval between instances), williamr@2: - BYDAY, williamr@2: - BYMONTHDAY, williamr@2: - BYYEARDAY, williamr@2: - WKST (start day of week). williamr@2: williamr@2: Note that the repeat rule type (FREQ) must be set before any of the following williamr@2: properties can be set, since their behaviour is dependent on the rule type: williamr@2: BYDAY, BYMONTHDAY, BYYEARDAY williamr@2: williamr@2: The WKST parameter is only significant in weekly repeat rules with an interval of williamr@2: greater than 1. williamr@2: williamr@2: The repeat rule type may not be changed once it has been set. williamr@2: williamr@2: If the start date of the entry does not match an instance of its repeat rule then williamr@2: the entry's start date will be moved forward to the first matching instance. For example, williamr@2: if the rule repeats every Wednesday but the start date of the entry is Monday, then the williamr@2: start date will be changed to the Wednesday. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: NONSHARABLE_CLASS(TCalRRule) williamr@2: { williamr@2: public: williamr@2: /** Types of repeat rule. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TType williamr@2: { williamr@2: /** The type has not yet been defined. */ williamr@2: EInvalid=0, williamr@2: /** Rule which repeats based on a number of days. */ williamr@2: EDaily, williamr@2: /** Rule which repeats based on a number of weeks. */ williamr@2: EWeekly, williamr@2: /** Rule which repeats based on a number of months. */ williamr@2: EMonthly, williamr@2: /** Rule which repeats based on a number of years. */ williamr@2: EYearly, williamr@2: }; williamr@2: williamr@2: /** Class to represent a weekday within a month. williamr@2: williamr@2: Valid values of iWeekInMonth are 1, 2, 3, 4 for the 1st, 2nd, 3rd and 4th week of williamr@2: the month, or -1 for the last week of the month. williamr@2: williamr@2: For example: williamr@2: The 3rd Wednesday would have iDay = EWednesday and iWeekInMonth = 3. williamr@2: The last Sunday would have iDay = ESunday and iWeekInMonth = -1. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TDayOfMonth williamr@2: { williamr@2: public: williamr@2: IMPORT_C TDayOfMonth(TDay aDay, TInt8 aWeekInMonth); williamr@2: IMPORT_C TDay Day() const; williamr@2: IMPORT_C TInt8 WeekInMonth() const; williamr@2: private: williamr@2: TDay iDay; williamr@2: TInt8 iWeekInMonth; williamr@2: }; williamr@2: williamr@2: IMPORT_C TCalRRule(); williamr@2: IMPORT_C TCalRRule(TType aType); williamr@2: williamr@2: IMPORT_C void SetType(TType aType); williamr@2: IMPORT_C TType Type() const; williamr@2: williamr@2: IMPORT_C void SetDtStart(const TCalTime& aTime); williamr@2: IMPORT_C TCalTime DtStart() const; williamr@2: williamr@2: IMPORT_C void SetUntil(const TCalTime& aTime); williamr@2: IMPORT_C TCalTime Until() const; williamr@2: williamr@2: IMPORT_C void SetCount(TUint aCount); williamr@2: IMPORT_C TUint Count() const; williamr@2: williamr@2: IMPORT_C void SetInterval(TInt aInterval); williamr@2: IMPORT_C TInt Interval() const; williamr@2: williamr@2: IMPORT_C void SetByDay(const RArray& aDays); williamr@2: IMPORT_C void GetByDayL(RArray& aDays) const; williamr@2: williamr@2: IMPORT_C void SetByDay(const RArray& aDays); williamr@2: IMPORT_C void GetByDayL(RArray& aDays) const; williamr@2: williamr@2: IMPORT_C void SetByMonthDay(const RArray& aMonthDays); williamr@2: IMPORT_C void GetByMonthDayL(RArray& aMonthDays) const; williamr@2: williamr@2: IMPORT_C void SetByMonth(const RArray aMonths); williamr@2: IMPORT_C void GetByMonthL(RArray& aMonths) const; williamr@2: williamr@2: IMPORT_C void SetWkSt(TDay aDay); williamr@2: IMPORT_C TDay WkSt() const; williamr@2: williamr@2: void SetUntilAndCount(const TCalTime& aTime, TUint aCount); williamr@2: williamr@2: private: williamr@2: void InitialiseData(); williamr@2: williamr@2: TUint MapToBitsWeekdays(TDay aDay); williamr@2: williamr@2: TBool GetNthBit(TUint aNum) const; williamr@2: void SetNthBit(TUint aNum); williamr@2: williamr@2: private: williamr@2: TUint64 iBuffer; // stores BYDAY/BYMONTHDAY williamr@2: TCalTime iDtStart; williamr@2: TCalTime iUntil; williamr@2: TInt32 iReserved; williamr@2: TInt32 iReserved2; williamr@2: TInt iCount; williamr@2: TDay iWkSt; williamr@2: TType iType; williamr@2: TUint8 iInterval; williamr@2: }; williamr@2: williamr@2: #endif // __CALRRULE_H__