|
1 /* |
|
2 * Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This file contains implementation of iCal parser which parses |
|
15 * the monthly recurring event specific information. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "AgnParseRRuleMonthly.h" |
|
22 |
|
23 #include "calendarengines_debug.h" |
|
24 #include "ICalValue.h" |
|
25 #include <calrrule.h> |
|
26 |
|
27 /** |
|
28 Constructor |
|
29 @param aAgnImpUtil AgnVersit2Importer utility functions |
|
30 */ |
|
31 CAgnParseRRuleMonthly::CAgnParseRRuleMonthly( MAgnImpUtil& aAgnImpUtil ): |
|
32 CAgnParseRRule( aAgnImpUtil ) |
|
33 { |
|
34 TRACE_ENTRY_POINT; |
|
35 TRACE_EXIT_POINT; |
|
36 } |
|
37 |
|
38 |
|
39 /** |
|
40 Destructor |
|
41 */ |
|
42 CAgnParseRRuleMonthly::~CAgnParseRRuleMonthly() |
|
43 { |
|
44 TRACE_ENTRY_POINT; |
|
45 TRACE_EXIT_POINT; |
|
46 } |
|
47 |
|
48 |
|
49 /** |
|
50 Constructs a new CAgnParseRRuleMonthly and returns it. |
|
51 The object is left on the cleanup stack. |
|
52 @param aAgnImpUtil AgnVersit2Importer utility functions |
|
53 @return a new CAgnParseRRuleMonthly. |
|
54 */ |
|
55 CAgnParseRRule* CAgnParseRRuleMonthly::NewLC( MAgnImpUtil& aAgnImpUtil ) |
|
56 { |
|
57 TRACE_ENTRY_POINT; |
|
58 |
|
59 CAgnParseRRule *self = new (ELeave) CAgnParseRRuleMonthly( aAgnImpUtil ); |
|
60 CleanupStack::PushL( self ); |
|
61 |
|
62 |
|
63 TRACE_EXIT_POINT; |
|
64 return self; |
|
65 } |
|
66 |
|
67 |
|
68 /** |
|
69 Parse the keywords and update RRule |
|
70 @param aSegment recurrence rule value segment. |
|
71 @param aRule recurrence rules |
|
72 @return True if parsed the keyword successfully |
|
73 */ |
|
74 TBool CAgnParseRRuleMonthly::DoParseL( CICalRuleSegment& aSegment, TCalRRule& aRule ) |
|
75 { |
|
76 TRACE_ENTRY_POINT; |
|
77 |
|
78 TBool parsed; |
|
79 |
|
80 switch( aSegment.Type() ) |
|
81 { |
|
82 //ByDay |
|
83 case CICalRuleSegment::ESegByDay : |
|
84 { |
|
85 parsed = SetRRuleByDayL( aSegment, aRule ); |
|
86 break; |
|
87 } |
|
88 //ByMonthDay |
|
89 case CICalRuleSegment::ESegByMonthDay : |
|
90 { |
|
91 parsed = SetRRuleByMonthDayL( aSegment, aRule ); |
|
92 break; |
|
93 } |
|
94 default: |
|
95 { |
|
96 parsed = EFalse; |
|
97 } |
|
98 } |
|
99 |
|
100 TRACE_EXIT_POINT; |
|
101 return parsed; |
|
102 } |
|
103 |
|
104 |
|
105 /** |
|
106 Finalize the parsing |
|
107 @param aRule recurrence rules |
|
108 @param aStartTime The DTSTART of the parent component. |
|
109 @return True if finalized parsing successfully |
|
110 */ |
|
111 TBool CAgnParseRRuleMonthly::FinalizeParsingL( TCalRRule& aRule, const TCalTime& aStartTime ) |
|
112 { |
|
113 TRACE_ENTRY_POINT; |
|
114 |
|
115 //Call the parent, to set some common values |
|
116 TBool finalized = CAgnParseRRule::FinalizeParsingL( aRule, aStartTime ); |
|
117 |
|
118 // If we are monthly, we would rather have a ByMonthDay than a ByDay: |
|
119 if ( !( iSetSegs & ( ESegFlagByDay | ESegFlagByMonthDay ) ) ) |
|
120 { |
|
121 // The specification requires certain fields to be taken from the DTSTART |
|
122 // if they have not already been set. |
|
123 TDateTime startDate = aStartTime.TimeUtcL().DateTime(); |
|
124 |
|
125 RArray<TInt> days; |
|
126 CleanupClosePushL(days); |
|
127 User::LeaveIfError(days.Append(startDate.Day() + 1)); |
|
128 aRule.SetByMonthDay(days); |
|
129 CleanupStack::PopAndDestroy(&days); |
|
130 } |
|
131 |
|
132 TRACE_EXIT_POINT; |
|
133 return finalized; |
|
134 } |