pimappservices/calendar/inc/calrrule.h
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __CALRRULE_H__
       
    17 #define __CALRRULE_H__
       
    18 
       
    19 #include <caltime.h>
       
    20 
       
    21 /** Class representing iCal repeat types.
       
    22 
       
    23 This supports the following standard iCal properties:
       
    24 - FREQ (rule type), 
       
    25 - DTSTART (start date), 
       
    26 - UNTIL (end date), 
       
    27 - COUNT (number of instances),
       
    28 - INTERVAL (interval between instances), 
       
    29 - BYDAY, 
       
    30 - BYMONTHDAY, 
       
    31 - BYYEARDAY, 
       
    32 - WKST (start day of week).
       
    33 
       
    34 Note that the repeat rule type (FREQ) must be set before any of the following 
       
    35 properties can be set, since their behaviour is dependent on the rule type:
       
    36 BYDAY, BYMONTHDAY, BYYEARDAY
       
    37 
       
    38 The WKST parameter is only significant in weekly repeat rules with an interval of 
       
    39 greater than 1.
       
    40 
       
    41 The repeat rule type may not be changed once it has been set.
       
    42 
       
    43 If the start date of the entry does not match an instance of its repeat rule then 
       
    44 the entry's start date will be moved forward to the first matching instance. For example,
       
    45 if the rule repeats every Wednesday but the start date of the entry is Monday, then the 
       
    46 start date will be changed to the Wednesday.
       
    47 
       
    48 @publishedAll
       
    49 @released
       
    50 */
       
    51 NONSHARABLE_CLASS(TCalRRule)
       
    52 	{
       
    53 public:
       
    54 	/** Types of repeat rule. 
       
    55 	
       
    56 	@publishedAll
       
    57 	@released
       
    58 	*/	
       
    59 	enum TType 
       
    60 		{
       
    61 		/** The type has not yet been defined. */
       
    62 		EInvalid=0,
       
    63 		/** Rule which repeats based on a number of days. */
       
    64 		EDaily,
       
    65 		/** Rule which repeats based on a number of weeks. */
       
    66 		EWeekly,
       
    67 		/** Rule which repeats based on a number of months. */
       
    68 		EMonthly,
       
    69 		/** Rule which repeats based on a number of years. */
       
    70 		EYearly,
       
    71 		};
       
    72 		
       
    73 	/** Class to represent a weekday within a month.
       
    74 	
       
    75 	Valid values of iWeekInMonth are 1, 2, 3, 4 for the 1st, 2nd, 3rd and 4th week of 
       
    76 	the month, or -1 for the last week of the month.
       
    77 
       
    78 	For example:
       
    79 	The 3rd Wednesday would have iDay = EWednesday and iWeekInMonth = 3.
       
    80 	The last Sunday would have iDay = ESunday and iWeekInMonth = -1.
       
    81 	
       
    82 	@publishedAll
       
    83 	@released
       
    84 	*/
       
    85 	class TDayOfMonth
       
    86 		{
       
    87 	public:
       
    88 		IMPORT_C TDayOfMonth(TDay aDay, TInt8 aWeekInMonth);
       
    89 		IMPORT_C TDay Day() const;
       
    90 		IMPORT_C TInt8 WeekInMonth() const;
       
    91 	private:
       
    92 		TDay iDay;
       
    93 		TInt8 iWeekInMonth;
       
    94 		};
       
    95 	
       
    96 	IMPORT_C TCalRRule();
       
    97 	IMPORT_C TCalRRule(TType aType);
       
    98 	
       
    99 	IMPORT_C void SetType(TType aType);
       
   100 	IMPORT_C TType Type() const;
       
   101 	
       
   102 	IMPORT_C void SetDtStart(const TCalTime& aTime);
       
   103 	IMPORT_C TCalTime DtStart() const;
       
   104 		
       
   105 	IMPORT_C void SetUntil(const TCalTime& aTime);
       
   106 	IMPORT_C TCalTime Until() const;
       
   107 	
       
   108 	IMPORT_C void SetCount(TUint aCount);
       
   109 	IMPORT_C TUint Count() const;
       
   110 	
       
   111 	IMPORT_C void SetInterval(TInt aInterval);
       
   112 	IMPORT_C TInt Interval() const;
       
   113 	
       
   114 	IMPORT_C void SetByDay(const RArray<TDay>& aDays); 
       
   115 	IMPORT_C void GetByDayL(RArray<TDay>& aDays) const;
       
   116 	
       
   117 	IMPORT_C void SetByDay(const RArray<TDayOfMonth>& aDays); 
       
   118 	IMPORT_C void GetByDayL(RArray<TDayOfMonth>& aDays) const;
       
   119 
       
   120 	IMPORT_C void SetByMonthDay(const RArray<TInt>& aMonthDays);
       
   121 	IMPORT_C void GetByMonthDayL(RArray<TInt>& aMonthDays) const;
       
   122 
       
   123 	IMPORT_C void SetByMonth(const RArray<TMonth> aMonths);
       
   124 	IMPORT_C void GetByMonthL(RArray<TMonth>& aMonths) const;
       
   125 
       
   126 	IMPORT_C void SetWkSt(TDay aDay);
       
   127 	IMPORT_C TDay WkSt() const;
       
   128 
       
   129 	void SetUntilAndCount(const TCalTime& aTime, TUint aCount);
       
   130 
       
   131 private:
       
   132 	void InitialiseData();
       
   133 
       
   134 	TUint MapToBitsWeekdays(TDay aDay);
       
   135 	
       
   136 	TBool GetNthBit(TUint aNum) const;
       
   137 	void SetNthBit(TUint aNum);
       
   138 		
       
   139 private:
       
   140 	TUint64	iBuffer; 	// stores BYDAY/BYMONTHDAY
       
   141 	TCalTime iDtStart;
       
   142 	TCalTime iUntil;
       
   143 	TInt32  iReserved;
       
   144 	TInt32  iReserved2;
       
   145 	TInt	iCount;
       
   146 	TDay	iWkSt;
       
   147 	TType	iType;
       
   148 	TUint8	iInterval;
       
   149 	};
       
   150 
       
   151 #endif // __CALRRULE_H__