|
1 /* |
|
2 * Copyright (c) 2008 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: Provides static information about anniversary lists and creates |
|
15 * anniversary list adapters. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "cpimannivadaptermanager.h" |
|
22 #include "cpimeventlistadapter.h" |
|
23 #include "cpimagnannivadapter.h" |
|
24 #include "logger.h" |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CPIMAnnivAdapterManager::CPIMAnnivAdapterManager |
|
28 // C++ default constructor can NOT contain any code, that |
|
29 // might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CPIMAnnivAdapterManager::CPIMAnnivAdapterManager() |
|
33 { |
|
34 JELOG2(EPim); |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CPIMAnnivAdapterManager::ConstructL |
|
39 // Symbian 2nd phase constructor can leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void CPIMAnnivAdapterManager::ConstructL(const TDesC& aListName) |
|
43 { |
|
44 JELOG2(EPim); |
|
45 CPIMEventAdapterManager::ConstructL(aListName); |
|
46 |
|
47 iSupportedFields |
|
48 = new(ELeave) CArrayFixFlat<TPIMField> (KPIMSupportedAnnivFieldsCount); |
|
49 |
|
50 iSupportedFields->AppendL(KPIMSupportedAnnivFields, |
|
51 KPIMSupportedAnnivFieldsCount); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CPIMAnnivAdapterManager::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CPIMAnnivAdapterManager* CPIMAnnivAdapterManager::NewL(const TDesC& aListName) |
|
60 { |
|
61 JELOG2(EPim); |
|
62 CPIMAnnivAdapterManager* self = new(ELeave) CPIMAnnivAdapterManager(); |
|
63 |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(aListName); |
|
66 CleanupStack::Pop(self); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 // Destructor |
|
72 CPIMAnnivAdapterManager::~CPIMAnnivAdapterManager() |
|
73 { |
|
74 JELOG2(EPim); |
|
75 delete iSupportedFields; |
|
76 delete iRepeatRuleFieldArrayAnniv; |
|
77 delete iRepeatRuleFieldArrayAnnivEmpty; |
|
78 delete iRepeatRuleIntervalArrayAnnivEmpty; |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CPIMAnnivAdapterManager::GetAdapterManager |
|
83 // Returns: A MPIMAdapterManager representation of this object. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 MPIMAdapterManager* CPIMAnnivAdapterManager::GetAdapterManager() |
|
87 { |
|
88 JELOG2(EPim); |
|
89 return this; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPIMAnnivAdapterManager::GetSupportedRepeatRuleFields |
|
94 // Provides the supported repeat rule fields for a given frequency. |
|
95 // Returns: Supported repeat rule fields for \a aFrequency. If no |
|
96 // fields are supported for the frequency, an empty array is returned. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 |
|
100 const CArrayFix<TPIMField>& |
|
101 CPIMAnnivAdapterManager::GetSupportedRepeatRuleFieldsL( |
|
102 const TPIMRepeatRuleFrequency& aFrequency) |
|
103 { |
|
104 JELOG2(EPim); |
|
105 const CArrayFix<TPIMField>* retVal = NULL; |
|
106 |
|
107 switch (aFrequency) |
|
108 { |
|
109 case EPIMRepeatRuleDaily: |
|
110 case EPIMRepeatRuleWeekly: |
|
111 case EPIMRepeatRuleMonthly: |
|
112 { |
|
113 // Return an empty array indicating no supported fields |
|
114 if (!iRepeatRuleFieldArrayAnnivEmpty) |
|
115 { |
|
116 iRepeatRuleFieldArrayAnnivEmpty = new(ELeave) CArrayFixFlat< |
|
117 TPIMField> (1); |
|
118 } |
|
119 retVal = iRepeatRuleFieldArrayAnnivEmpty; |
|
120 break; |
|
121 } |
|
122 case EPIMRepeatRuleYearly: |
|
123 { |
|
124 // Return an array with one item, the frequency |
|
125 if (!iRepeatRuleFieldArrayAnniv) |
|
126 { |
|
127 iRepeatRuleFieldArrayAnniv |
|
128 = new(ELeave) CArrayFixFlat<TPIMField> (1); |
|
129 iRepeatRuleFieldArrayAnniv->AppendL(EPIMRepeatRuleFrequency); |
|
130 } |
|
131 retVal = iRepeatRuleFieldArrayAnniv; |
|
132 break; |
|
133 } |
|
134 default: |
|
135 { |
|
136 User::Leave(KErrArgument); // Field was not a valid field |
|
137 } |
|
138 } |
|
139 |
|
140 return *retVal; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CPIMAnnivAdapterManager::GetSupportedIntervals |
|
145 // Provides the supported interval values for given frequency. |
|
146 // Returns: Supported interval values for given frequency. If the |
|
147 // interval field is not supported for given frequency, |
|
148 // an empty array is returned. |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 |
|
152 const CArrayFix<TInt>& CPIMAnnivAdapterManager::GetSupportedIntervalsL( |
|
153 const TPIMRepeatRuleFrequency& aFrequency) |
|
154 { |
|
155 JELOG2(EPim); |
|
156 if (aFrequency != EPIMRepeatRuleDaily && aFrequency != EPIMRepeatRuleWeekly |
|
157 && aFrequency != EPIMRepeatRuleMonthly && aFrequency |
|
158 != EPIMRepeatRuleYearly) |
|
159 { |
|
160 User::Leave(KErrArgument); // codescanner::leave |
|
161 } |
|
162 |
|
163 // Frequency is valid, return an empty array indicating no supported interv. |
|
164 if (!iRepeatRuleIntervalArrayAnnivEmpty) |
|
165 { |
|
166 iRepeatRuleIntervalArrayAnnivEmpty |
|
167 = new(ELeave) CArrayFixFlat<TInt> (1); // codescanner::leave |
|
168 } |
|
169 return *iRepeatRuleIntervalArrayAnnivEmpty; |
|
170 } |
|
171 |
|
172 // End of File |