|
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 CESMRAgnParseRRuleMonthly. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmragnparserrulemonthly.h" |
|
21 |
|
22 //<cmail> |
|
23 #include "cesmricalvalue.h" |
|
24 //</cmail> |
|
25 #include <calrrule.h> |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CESMRAgnParseRRuleMonthly::CESMRAgnParseRRuleMonthly |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CESMRAgnParseRRuleMonthly::CESMRAgnParseRRuleMonthly( MESMRAgnImpUtil& aAgnImpUtil ): |
|
34 CESMRAgnParseRRule( aAgnImpUtil ) |
|
35 { |
|
36 FUNC_LOG; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CESMRAgnParseRRuleMonthly::~CESMRAgnParseRRuleMonthly |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CESMRAgnParseRRuleMonthly::~CESMRAgnParseRRuleMonthly() |
|
44 { |
|
45 FUNC_LOG; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CESMRAgnParseRRuleMonthly::NewLC |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CESMRAgnParseRRule* CESMRAgnParseRRuleMonthly::NewLC( MESMRAgnImpUtil& aAgnImpUtil ) |
|
53 { |
|
54 FUNC_LOG; |
|
55 |
|
56 CESMRAgnParseRRule *self = new (ELeave) CESMRAgnParseRRuleMonthly( aAgnImpUtil ); |
|
57 CleanupStack::PushL( self ); |
|
58 |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CESMRAgnParseRRuleMonthly::DoParseL |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 TBool CESMRAgnParseRRuleMonthly::DoParseL( CESMRICalRuleSegment& aSegment, TCalRRule& aRule ) |
|
68 { |
|
69 FUNC_LOG; |
|
70 |
|
71 TBool parsed; |
|
72 |
|
73 switch( aSegment.Type() ) |
|
74 { |
|
75 //ByDay |
|
76 case CESMRICalRuleSegment::ESegByDay : |
|
77 { |
|
78 parsed = SetRRuleByDayL( aSegment, aRule ); |
|
79 break; |
|
80 } |
|
81 //ByMonthDay |
|
82 case CESMRICalRuleSegment::ESegByMonthDay : |
|
83 { |
|
84 parsed = SetRRuleByMonthDayL( aSegment, aRule ); |
|
85 break; |
|
86 } |
|
87 default: |
|
88 { |
|
89 parsed = EFalse; |
|
90 } |
|
91 } |
|
92 |
|
93 return parsed; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CESMRAgnParseRRuleMonthly::FinalizeParsingL |
|
98 // --------------------------------------------------------------------------- |
|
99 // |
|
100 TBool CESMRAgnParseRRuleMonthly::FinalizeParsingL( TCalRRule& aRule, const TCalTime& aStartTime ) |
|
101 { |
|
102 FUNC_LOG; |
|
103 |
|
104 //Call the parent, to set some common values |
|
105 TBool finalized = CESMRAgnParseRRule::FinalizeParsingL( aRule, aStartTime ); |
|
106 |
|
107 // If we are monthly, we would rather have a ByMonthDay than a ByDay: |
|
108 if ( !( iSetSegs & ( ESegFlagByDay | ESegFlagByMonthDay ) ) ) |
|
109 { |
|
110 // The specification requires certain fields to be taken from the DTSTART |
|
111 // if they have not already been set. |
|
112 TDateTime startDate = aStartTime.TimeUtcL().DateTime(); |
|
113 |
|
114 RArray<TInt> days; |
|
115 CleanupClosePushL(days); |
|
116 User::LeaveIfError(days.Append(startDate.Day() + 1)); |
|
117 aRule.SetByMonthDay(days); |
|
118 CleanupStack::PopAndDestroy(&days); |
|
119 } |
|
120 |
|
121 return finalized; |
|
122 } |
|
123 |