|
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: Field property array for field types. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "CFscFieldPropertyArray.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "FscPresentationUtils.h" |
|
24 #include "CFscFieldProperty.h" |
|
25 #include "CFscFieldOrderingManager.h" |
|
26 #include <pbk2rclactionutils.rsg> |
|
27 #include "CFscFieldPropertyGroup.h" |
|
28 #include <Pbk2ContentIdentifiers.hrh> |
|
29 |
|
30 // Virtual Phonebook |
|
31 #include <MVPbkFieldType.h> |
|
32 #include <TVPbkFieldVersitProperty.h> |
|
33 #include <CVPbkFieldTypeSelector.h> |
|
34 #include <VPbkEng.rsg> |
|
35 |
|
36 // System includes |
|
37 #include <barsc.h> |
|
38 #include <barsread.h> |
|
39 #include <featmgr.h> |
|
40 #include <eikenv.h> |
|
41 #include <apgcli.h> |
|
42 #include <eikappui.h> |
|
43 #include <eikapp.h> |
|
44 #include <data_caging_path_literals.hrh> |
|
45 #include <bautils.h> |
|
46 |
|
47 #include <coemain.h> |
|
48 |
|
49 // CONSTANTS DECLARATIONS |
|
50 _LIT( KFscRscFileName, "pbk2rclactionutils.rsc" ); |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CFscFieldPropertyArray::CFscFieldPropertyArray |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 inline CFscFieldPropertyArray::CFscFieldPropertyArray() |
|
58 { |
|
59 FUNC_LOG; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CFscFieldPropertyArray::ConstructL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 inline void CFscFieldPropertyArray::ConstructL( |
|
67 const MVPbkFieldTypeList& aSupportedFieldTypeList) |
|
68 { |
|
69 FUNC_LOG; |
|
70 |
|
71 TFileName resourceFileName( KDC_APP_RESOURCE_DIR ); |
|
72 resourceFileName.Append(KFscRscFileName); |
|
73 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resourceFileName ); |
|
74 TInt offset = CCoeEnv::Static()->AddResourceFileL( resourceFileName ); |
|
75 |
|
76 // Read field type presentation order information |
|
77 TResourceReader reader; |
|
78 CCoeEnv::Static()->CreateResourceReaderLC(reader, |
|
79 R_FSC_FIELDTYPE_PRESENTATION_ORDERS); |
|
80 |
|
81 CFscFieldOrderingManager* orderings = |
|
82 CFscFieldOrderingManager::NewL(reader); |
|
83 CleanupStack::PopAndDestroy(); // R_FSC_FIELDTYPE_PRESENTATION_ORDERS |
|
84 CleanupStack::PushL(orderings); |
|
85 |
|
86 // Read field property resource strucutre array |
|
87 CCoeEnv::Static()->CreateResourceReaderLC(reader, R_FSC_FIELD_PROPERTIES); |
|
88 ReadFieldPropertiesL(reader, aSupportedFieldTypeList, *orderings); |
|
89 |
|
90 CCoeEnv::Static()->DeleteResourceFile(offset); |
|
91 |
|
92 CleanupStack::PopAndDestroy(2);// orderings, r_fsc_field_properties |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CFscFieldPropertyArray::NewL |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 CFscFieldPropertyArray* CFscFieldPropertyArray::NewL |
|
100 (const MVPbkFieldTypeList& aSupportedFieldTypeList) |
|
101 { |
|
102 FUNC_LOG; |
|
103 CFscFieldPropertyArray* self = new(ELeave) CFscFieldPropertyArray; |
|
104 CleanupStack::PushL(self); |
|
105 self->ConstructL( aSupportedFieldTypeList); |
|
106 CleanupStack::Pop(self); |
|
107 return self; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CFscFieldPropertyArray::NewL |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 CFscFieldPropertyArray* CFscFieldPropertyArray::NewL( |
|
115 const MVPbkFieldTypeList& aSupportedFieldTypeList, |
|
116 TResourceReader& aReader) |
|
117 { |
|
118 FUNC_LOG; |
|
119 CFscFieldPropertyArray* self = new(ELeave) CFscFieldPropertyArray; |
|
120 CleanupStack::PushL(self); |
|
121 CFscFieldOrderingManager* orderings = |
|
122 self->CreateFieldOrderingsLC(); |
|
123 self->ReadFieldPropertiesL( aReader, aSupportedFieldTypeList, *orderings ); |
|
124 CleanupStack::PopAndDestroy( orderings ); |
|
125 CleanupStack::Pop(self); |
|
126 return self; |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CFscFieldPropertyArray::~CFscFieldPropertyArray |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 CFscFieldPropertyArray::~CFscFieldPropertyArray() |
|
134 { |
|
135 FUNC_LOG; |
|
136 iFieldProperties.ResetAndDestroy(); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CFscFieldPropertyArray::FindProperty |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 const MPbk2FieldProperty* CFscFieldPropertyArray::FindProperty( |
|
144 const MVPbkFieldType& aFieldType) const |
|
145 { |
|
146 FUNC_LOG; |
|
147 const CFscFieldProperty* result= NULL; |
|
148 const TInt count = iFieldProperties.Count(); |
|
149 for (TInt i = 0; i < count; ++i) |
|
150 { |
|
151 const CFscFieldProperty* property = iFieldProperties[i]; |
|
152 if (property->FieldType().IsSame(aFieldType)) |
|
153 { |
|
154 result = property; |
|
155 break; |
|
156 } |
|
157 } |
|
158 |
|
159 return result; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CFscFieldPropertyArray::Count |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CFscFieldPropertyArray::Count() const |
|
167 { |
|
168 FUNC_LOG; |
|
169 return iFieldProperties.Count(); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CFscFieldPropertyArray::At |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 const MPbk2FieldProperty& CFscFieldPropertyArray::At(TInt aIndex) const |
|
177 { |
|
178 FUNC_LOG; |
|
179 return *iFieldProperties[aIndex]; |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CFscFieldPropertyArray::ReadFieldPropertiesL |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CFscFieldPropertyArray::ReadFieldPropertiesL(TResourceReader& aReader, |
|
187 const MVPbkFieldTypeList& aSupportedFieldTypeList, |
|
188 CFscFieldOrderingManager& aOrderingManager) |
|
189 { |
|
190 FUNC_LOG; |
|
191 // aSupportedFieldTypeList is a list of the supported field type of the used store |
|
192 const TInt count = aReader.ReadInt16(); |
|
193 for (TInt i = 0; i < count; ++i) |
|
194 { |
|
195 CFscFieldProperty* property = CFscFieldProperty::NewLC(aReader, |
|
196 aSupportedFieldTypeList, aOrderingManager); |
|
197 TBool doNotAdd = EFalse; |
|
198 if (property->IsSupported()) |
|
199 { |
|
200 if (!FeatureManager::FeatureSupported(KFeatureIdJapanese)) |
|
201 { |
|
202 // Non-Japanese variants use all the other properties but |
|
203 // Japanese reading fields |
|
204 const MVPbkFieldType* lastNameReading = |
|
205 aSupportedFieldTypeList.Find( |
|
206 R_VPBK_FIELD_TYPE_LASTNAMEREADING); |
|
207 const MVPbkFieldType* firstNameReading = |
|
208 aSupportedFieldTypeList.Find( |
|
209 R_VPBK_FIELD_TYPE_FIRSTNAMEREADING); |
|
210 const MVPbkFieldType& type = property->FieldType(); |
|
211 if ( (lastNameReading && lastNameReading->IsSame(type) ) |
|
212 || firstNameReading && firstNameReading->IsSame(type) ) |
|
213 { |
|
214 doNotAdd = ETrue; |
|
215 } |
|
216 } |
|
217 } |
|
218 else |
|
219 { |
|
220 doNotAdd = ETrue; |
|
221 } |
|
222 |
|
223 if (doNotAdd) |
|
224 { |
|
225 CleanupStack::PopAndDestroy(property); |
|
226 } |
|
227 else |
|
228 { |
|
229 iFieldProperties.AppendL(property); |
|
230 CleanupStack::Pop(property); |
|
231 } |
|
232 } |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CFscFieldPropertyArray::CreateFieldOrderingsLC |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 CFscFieldOrderingManager* CFscFieldPropertyArray::CreateFieldOrderingsLC(void) |
|
240 { |
|
241 FUNC_LOG; |
|
242 TFileName resourceFileName( KDC_APP_RESOURCE_DIR ); |
|
243 resourceFileName.Append(KFscRscFileName); |
|
244 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), resourceFileName ); |
|
245 TInt offset = CCoeEnv::Static()->AddResourceFileL( resourceFileName ); |
|
246 |
|
247 // Read field type presentation order information |
|
248 TResourceReader reader; |
|
249 CCoeEnv::Static()->CreateResourceReaderLC(reader, |
|
250 R_FSC_FIELDTYPE_PRESENTATION_ORDERS); |
|
251 CFscFieldOrderingManager* orderings = |
|
252 CFscFieldOrderingManager::NewL(reader); |
|
253 |
|
254 CCoeEnv::Static()->DeleteResourceFile(offset); |
|
255 |
|
256 CleanupStack::PopAndDestroy(2);// R_FSC_FIELDTYPE_PRESENTATION_ORDERS, resFile |
|
257 CleanupStack::PushL(orderings); |
|
258 return orderings; |
|
259 } |
|
260 |
|
261 // End of File |
|
262 |