|
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 implements class CESMRAgnParseRRuleYearly. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmragnparserruleyearly.h" |
|
21 |
|
22 //<cmail> |
|
23 |
|
24 #include "cesmricalvalue.h" |
|
25 //</cmail> |
|
26 #include <calrrule.h> |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CESMRAgnParseRRuleYearly::CESMRAgnParseRRuleYearly |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CESMRAgnParseRRuleYearly::CESMRAgnParseRRuleYearly( MESMRAgnImpUtil& aAgnImpUtil ): |
|
35 CESMRAgnParseRRule( aAgnImpUtil ) |
|
36 { |
|
37 FUNC_LOG; |
|
38 //do nothing |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CESMRAgnParseRRuleYearly::~CESMRAgnParseRRuleYearly |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 CESMRAgnParseRRuleYearly::~CESMRAgnParseRRuleYearly() |
|
47 { |
|
48 FUNC_LOG; |
|
49 //do nothing |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CESMRAgnParseRRuleYearly::NewLC |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CESMRAgnParseRRule* CESMRAgnParseRRuleYearly::NewLC( MESMRAgnImpUtil& aAgnImpUtil ) |
|
57 { |
|
58 FUNC_LOG; |
|
59 |
|
60 CESMRAgnParseRRule *self = new (ELeave) CESMRAgnParseRRuleYearly( aAgnImpUtil ); |
|
61 CleanupStack::PushL( self ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CESMRAgnParseRRuleYearly::DoParseL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 TBool CESMRAgnParseRRuleYearly::DoParseL( CESMRICalRuleSegment& aSegment, TCalRRule& aRule ) |
|
71 { |
|
72 FUNC_LOG; |
|
73 |
|
74 TBool parsed; |
|
75 |
|
76 switch( aSegment.Type() ) |
|
77 { |
|
78 //ESegByDay |
|
79 case CESMRICalRuleSegment::ESegByDay : |
|
80 { |
|
81 parsed = SetRRuleByDayL( aSegment, aRule ); |
|
82 break; |
|
83 } |
|
84 |
|
85 //ESegByMonth |
|
86 case CESMRICalRuleSegment::ESegByMonth : |
|
87 { |
|
88 parsed = SetRRuleByMonthL( aSegment, aRule ); |
|
89 break; |
|
90 } |
|
91 default: |
|
92 { |
|
93 parsed = EFalse; |
|
94 } |
|
95 } |
|
96 |
|
97 return parsed; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CESMRAgnParseRRuleYearly::FinalizeParsingL |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TBool CESMRAgnParseRRuleYearly::FinalizeParsingL( TCalRRule& aRule, const TCalTime& aStartTime ) |
|
105 { |
|
106 FUNC_LOG; |
|
107 |
|
108 //Call the parent, to set some common values |
|
109 TBool finalized = CESMRAgnParseRRule::FinalizeParsingL( aRule, aStartTime ); |
|
110 |
|
111 // ByMonth is easy. |
|
112 if ( !(iSetSegs & ESegFlagByMonth) ) |
|
113 { |
|
114 // The specification requires certain fields to be taken from the DTSTART |
|
115 // if they have not already been set. |
|
116 TDateTime startDate = aStartTime.TimeUtcL().DateTime(); |
|
117 |
|
118 RArray<TMonth> theMonths; |
|
119 CleanupClosePushL(theMonths); |
|
120 User::LeaveIfError(theMonths.Append(startDate.Month())); |
|
121 aRule.SetByMonth(theMonths); |
|
122 CleanupStack::PopAndDestroy(&theMonths); |
|
123 } |
|
124 |
|
125 #if 0 |
|
126 //this will cause yearly repeat not to work |
|
127 //further investigation needed |
|
128 else if ( !( iSetSegs & ESegFlagByDay ) ) |
|
129 { |
|
130 /* |
|
131 // We are in trouble here, because we are trying to work out a rule along the |
|
132 // lines of "last saturday" from a date/time, which simply can't be done. |
|
133 // This arrises because agenda doesn't support a yearly repeating rule with |
|
134 // a numbered day of the month. |
|
135 // We can't import this RRule, but we can continue with the rest of the entry. |
|
136 */ |
|
137 finalized = EFalse; |
|
138 } |
|
139 #endif |
|
140 |
|
141 return finalized; |
|
142 } |
|
143 |