|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Phonebook field types collection class |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkFieldsInfo.h" |
|
22 #include <barsc.h> // RResourceFile |
|
23 #include <barsread.h> // RResourceReader |
|
24 #include <cntitem.h> |
|
25 #include <cntmodel.rsg> |
|
26 |
|
27 #include <PbkEng.rsg> |
|
28 #include "CPbkFieldInfo.h" |
|
29 #include "CPbkFieldInfoGroup.h" |
|
30 #include "CPbkUidMap.h" |
|
31 #include "TPbkContactItemFieldType.h" |
|
32 #include "TPbkVcardFieldType.h" |
|
33 #include "TPbkMatchPriorityLevel.h" |
|
34 #include <MPbkGlobalSetting.h> |
|
35 #include "CPbkCenRepSetting.h" |
|
36 |
|
37 // MODULE DATA STRUCTURES |
|
38 |
|
39 |
|
40 /// Unnamed namespace for local definitions |
|
41 namespace { |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 enum TPanicCode |
|
45 { |
|
46 EPanicIndexOutOfRange = 1, |
|
47 EPanicResourceArrayCountsMismatch, |
|
48 EPanicFieldInfoArrayCountMismatch, |
|
49 EPanicResourceLinkedGroupNotFound |
|
50 }; |
|
51 |
|
52 |
|
53 // LOCAL FUNCTIONS |
|
54 |
|
55 void Panic(TPanicCode aReason) |
|
56 { |
|
57 _LIT(KPanicText, "CPbkFieldsInfo"); |
|
58 User::Panic(KPanicText, aReason); |
|
59 } |
|
60 |
|
61 TInt CompareOrdering(const CPbkFieldInfo& aLeft, const CPbkFieldInfo& aRight) |
|
62 { |
|
63 return aLeft.CompareOrdering(aRight); |
|
64 } |
|
65 |
|
66 /** |
|
67 * Interface that matches a CPbkFieldInfo object against some criteria. |
|
68 */ |
|
69 class MPbkFieldInfoMatcher |
|
70 { |
|
71 public: // Interface |
|
72 /** |
|
73 * Returns true if aFieldInfo matches some criteria. |
|
74 */ |
|
75 virtual TBool Match(const CPbkFieldInfo& aFieldInfo) const = 0; |
|
76 }; |
|
77 |
|
78 /** |
|
79 * Interface for an operation to be performed to a field info object. |
|
80 */ |
|
81 class MPbkFieldInfoOperation |
|
82 { |
|
83 public: // Interface |
|
84 /** |
|
85 * Performs operation for aFieldInfo. |
|
86 */ |
|
87 virtual void ProcessL(const CPbkFieldInfo& aFieldInfo) =0; |
|
88 }; |
|
89 |
|
90 /** |
|
91 * Implements MPbkFieldInfoMatcher to match a TPbkFieldId |
|
92 */ |
|
93 NONSHARABLE_CLASS(TMatchFieldId) : |
|
94 public MPbkFieldInfoMatcher |
|
95 { |
|
96 public: // Interface |
|
97 /** |
|
98 * Constructor. |
|
99 * @param aFieldId contact item field id |
|
100 */ |
|
101 inline TMatchFieldId(TPbkFieldId aFieldId) : |
|
102 iFieldId(aFieldId) |
|
103 { |
|
104 } |
|
105 |
|
106 public: // from MPbkFieldInfoMatcher |
|
107 TBool Match(const CPbkFieldInfo& aFieldInfo) const |
|
108 { |
|
109 return (aFieldInfo.FieldId()==iFieldId); |
|
110 } |
|
111 |
|
112 private: // data |
|
113 /// Own: contact item field id |
|
114 const TPbkFieldId iFieldId; |
|
115 }; |
|
116 |
|
117 /** |
|
118 * Implements MPbkFieldInfoMatcher to match a <TPbkFieldId,TPbkFieldLocation> pair. |
|
119 */ |
|
120 NONSHARABLE_CLASS(TMatchFieldIdAndLocation) : |
|
121 public MPbkFieldInfoMatcher |
|
122 { |
|
123 public: // Interface |
|
124 /** |
|
125 * Constructor. |
|
126 * @param aFieldId contact item field id |
|
127 * @param aLocation field location |
|
128 */ |
|
129 inline TMatchFieldIdAndLocation |
|
130 (TPbkFieldId aFieldId, TPbkFieldLocation aLocation) : |
|
131 iFieldId(aFieldId), iLocation(aLocation) |
|
132 { |
|
133 } |
|
134 |
|
135 public: // from MPbkFieldInfoMatcher |
|
136 TBool Match(const CPbkFieldInfo& aFieldInfo) const |
|
137 { |
|
138 return (aFieldInfo.FieldId()==iFieldId && aFieldInfo.Location()==iLocation); |
|
139 } |
|
140 |
|
141 private: // data |
|
142 /// Own: field id |
|
143 const TPbkFieldId iFieldId; |
|
144 /// Own: field location |
|
145 const TPbkFieldLocation iLocation; |
|
146 }; |
|
147 |
|
148 /** |
|
149 * Implements MPbkFieldInfoMatcher to match a CContactItemField. |
|
150 */ |
|
151 NONSHARABLE_CLASS(TMatchContactItemField) : |
|
152 public MPbkFieldInfoMatcher |
|
153 { |
|
154 public: // Interface |
|
155 /** |
|
156 * Constructor. |
|
157 * @param aField contact item field |
|
158 * @param aUidMap UID map |
|
159 */ |
|
160 inline TMatchContactItemField |
|
161 (const CContactItemField& aField, const CPbkUidMap& aUidMap) : |
|
162 iFieldType(aField,aUidMap) |
|
163 { |
|
164 } |
|
165 |
|
166 public: // from MPbkFieldInfoMatcher |
|
167 TBool Match(const CPbkFieldInfo& aFieldInfo) const |
|
168 { |
|
169 return aFieldInfo.Match(iFieldType); |
|
170 } |
|
171 |
|
172 private: // data |
|
173 /// Own: field type |
|
174 const TPbkContactItemFieldType iFieldType; |
|
175 }; |
|
176 |
|
177 /** |
|
178 * Implements MPbkFieldInfoMatcher to match a CContactItemField with priority. |
|
179 */ |
|
180 NONSHARABLE_CLASS(TMatchContactItemFieldWithLevel) : |
|
181 public MPbkFieldInfoMatcher |
|
182 { |
|
183 public: // Interface |
|
184 /** |
|
185 * Constructor. |
|
186 * @param aField contact item field |
|
187 * @param aUidMap UID map |
|
188 * @param aLevel match priority level |
|
189 */ |
|
190 inline TMatchContactItemFieldWithLevel |
|
191 (const CContactItemField& aField, |
|
192 const CPbkUidMap& aUidMap, |
|
193 const TPbkMatchPriorityLevel& aLevel) : |
|
194 iFieldType(aField,aUidMap), iLevel(aLevel) |
|
195 { |
|
196 } |
|
197 |
|
198 public: // from MPbkFieldInfoMatcher |
|
199 TBool Match(const CPbkFieldInfo& aFieldInfo) const |
|
200 { |
|
201 return aFieldInfo.Match(iFieldType,iLevel); |
|
202 } |
|
203 |
|
204 private: // data |
|
205 /// Own: contact item field type |
|
206 const TPbkContactItemFieldType iFieldType; |
|
207 /// Own: match priority level |
|
208 const TPbkMatchPriorityLevel iLevel; |
|
209 }; |
|
210 |
|
211 /** |
|
212 * Implements MPbkFieldInfoMatcher to match a vCard property. |
|
213 */ |
|
214 NONSHARABLE_CLASS(TMatchVcard) : |
|
215 public MPbkFieldInfoMatcher |
|
216 { |
|
217 public: // Interface |
|
218 /** |
|
219 * Constructor. |
|
220 * @param aVcardProperty |
|
221 * @param aUidMap UID map |
|
222 * @param aLevel match priority level |
|
223 */ |
|
224 inline TMatchVcard |
|
225 (const MPbkVcardProperty& aVcardProperty, |
|
226 const CPbkUidMap& aUidMap, |
|
227 const TPbkMatchPriorityLevel& aLevel) : |
|
228 iVcardType(aVcardProperty,aUidMap), iLevel(aLevel) |
|
229 { |
|
230 } |
|
231 |
|
232 public: // from MPbkFieldInfoMatcher |
|
233 TBool Match(const CPbkFieldInfo& aFieldInfo) const |
|
234 { |
|
235 return aFieldInfo.Match(iVcardType,iLevel); |
|
236 } |
|
237 |
|
238 private: // data |
|
239 /// Own: vCard field type |
|
240 const TPbkVcardFieldType iVcardType; |
|
241 /// Own: match priority level |
|
242 const TPbkMatchPriorityLevel iLevel; |
|
243 }; |
|
244 |
|
245 /** |
|
246 * Implements MPbkFieldInfoOperation to call CPbkFieldInfo::AddToViewDefL. |
|
247 */ |
|
248 NONSHARABLE_CLASS(TAddToViewDef) : |
|
249 public MPbkFieldInfoOperation |
|
250 { |
|
251 public: // Interface |
|
252 /** |
|
253 * Constructor. |
|
254 * @param aViewDef view definition to contact item |
|
255 */ |
|
256 inline TAddToViewDef(CContactItemViewDef& aViewDef) : |
|
257 iViewDef(aViewDef) |
|
258 { |
|
259 } |
|
260 |
|
261 public: // From MPbkFieldInfoOperation |
|
262 void ProcessL(const CPbkFieldInfo& aFieldInfo) |
|
263 { |
|
264 aFieldInfo.AddToViewDefL(iViewDef); |
|
265 } |
|
266 |
|
267 private: // Data |
|
268 /// Ref: view definition |
|
269 CContactItemViewDef& iViewDef; |
|
270 }; |
|
271 |
|
272 /** |
|
273 * Implements MPbkFieldInfoOperation to call CPbkFieldInfo::AddToFieldDefL. |
|
274 */ |
|
275 NONSHARABLE_CLASS(TAddToFieldDef) : |
|
276 public MPbkFieldInfoOperation |
|
277 { |
|
278 public: // Interface |
|
279 /** |
|
280 * Constructor. |
|
281 * @param aFieldDef field definition for contact item |
|
282 */ |
|
283 inline TAddToFieldDef(CContactItemFieldDef& aFieldDef) : |
|
284 iFieldDef(aFieldDef) |
|
285 { |
|
286 } |
|
287 |
|
288 public: // From MPbkFieldInfoOperation |
|
289 void ProcessL(const CPbkFieldInfo& aFieldInfo) |
|
290 { |
|
291 aFieldInfo.AddToFieldDefL(iFieldDef); |
|
292 } |
|
293 |
|
294 private: // Data |
|
295 /// Ref: field definition |
|
296 CContactItemFieldDef& iFieldDef; |
|
297 }; |
|
298 |
|
299 /** |
|
300 * Finds a matching field info object in an array. |
|
301 * @param aFieldInfos array to search. |
|
302 * @param aMatcher the matching predicate. |
|
303 * @return the matching field info object or NULL if no match is found. |
|
304 */ |
|
305 CPbkFieldInfo* FindMatching |
|
306 (const RPointerArray<CPbkFieldInfo>& aFieldInfos, |
|
307 const MPbkFieldInfoMatcher& aMatcher) |
|
308 { |
|
309 const TInt count = aFieldInfos.Count(); |
|
310 for (TInt i=0; i < count; ++i) |
|
311 { |
|
312 const CPbkFieldInfo& fieldInfo = *aFieldInfos[i]; |
|
313 if (aMatcher.Match(fieldInfo)) |
|
314 { |
|
315 return CONST_CAST(CPbkFieldInfo*,&fieldInfo); |
|
316 } |
|
317 } |
|
318 return NULL; |
|
319 } |
|
320 |
|
321 /** |
|
322 * Processes matching field info objects in an array. |
|
323 * |
|
324 * @param aFieldInfos array of field info objects to process. |
|
325 * @param aMatcher the matching predicate. |
|
326 * @param aOperation operation to perform to all matching field info |
|
327 * objects. |
|
328 * @return number of field info objects processed |
|
329 */ |
|
330 void ProcessMatchingL |
|
331 (const RPointerArray<CPbkFieldInfo>& aFieldInfos, |
|
332 const MPbkFieldInfoMatcher& aMatcher, |
|
333 MPbkFieldInfoOperation& aOperation) |
|
334 { |
|
335 const TInt count = aFieldInfos.Count(); |
|
336 for (TInt i=0; i < count; ++i) |
|
337 { |
|
338 const CPbkFieldInfo& fieldInfo = *aFieldInfos[i]; |
|
339 if (aMatcher.Match(fieldInfo)) |
|
340 { |
|
341 aOperation.ProcessL(fieldInfo); |
|
342 } |
|
343 } |
|
344 } |
|
345 |
|
346 /** |
|
347 * Process all field info objects which match aFieldTypes. |
|
348 */ |
|
349 void ProcessMatchingL |
|
350 (const RPointerArray<CPbkFieldInfo>& aFieldInfos, |
|
351 const CPbkFieldIdArray& aFieldTypes, |
|
352 MPbkFieldInfoOperation& aOperation) |
|
353 { |
|
354 const TInt count = aFieldTypes.Count(); |
|
355 for (TInt i=0; i<count; ++i) |
|
356 { |
|
357 TMatchFieldId fieldIdMatcher(aFieldTypes[i]); |
|
358 ProcessMatchingL(aFieldInfos,fieldIdMatcher,aOperation); |
|
359 } |
|
360 } |
|
361 |
|
362 /** |
|
363 * Reads the needed central repository max number length value |
|
364 */ |
|
365 inline TInt ReadMaxNumberLengthL() |
|
366 { |
|
367 MPbkGlobalSetting* globalSetting = CPbkCenRepSetting::NewL(); |
|
368 // push to cleanupStack |
|
369 globalSetting->PushL(); |
|
370 globalSetting->ConnectL(MPbkGlobalSetting::EPbkConfigurationCategory); |
|
371 TInt maxLength(0); |
|
372 TInt err = globalSetting->Get |
|
373 (MPbkGlobalSetting::EEditorMaxNumberLength, maxLength); |
|
374 User::LeaveIfError( err ); |
|
375 CleanupStack::PopAndDestroy( globalSetting ); |
|
376 return maxLength; |
|
377 } |
|
378 |
|
379 } // namespace |
|
380 |
|
381 |
|
382 // ==================== MEMBER FUNCTIONS ==================== |
|
383 |
|
384 inline CPbkFieldsInfo::CPbkFieldsInfo() |
|
385 { |
|
386 // CBase::operator new(TLeave) resets members |
|
387 } |
|
388 |
|
389 CPbkFieldsInfo* CPbkFieldsInfo::NewL |
|
390 (RResourceFile& aPbkResFile, RResourceFile& aCntModelResFile) |
|
391 { |
|
392 CPbkFieldsInfo* self = new(ELeave) CPbkFieldsInfo; |
|
393 CleanupStack::PushL(self); |
|
394 self->ConstructFromResourceL(aPbkResFile,aCntModelResFile); |
|
395 CleanupStack::Pop(self); |
|
396 return self; |
|
397 } |
|
398 |
|
399 CPbkFieldsInfo::~CPbkFieldsInfo() |
|
400 { |
|
401 iGroups.ResetAndDestroy(); |
|
402 delete iTypeUidMap; |
|
403 // Cannot use iEntries.ResetAndDestroy() because CPbkFieldInfo destructor |
|
404 // is private |
|
405 for (TInt i=iEntries.Count()-1; i >= 0; --i) |
|
406 { |
|
407 delete iEntries[i]; |
|
408 } |
|
409 iEntries.Close(); |
|
410 delete iPbkFieldInfoParams; |
|
411 } |
|
412 |
|
413 EXPORT_C CPbkFieldInfo* CPbkFieldsInfo::Find |
|
414 (TPbkFieldId aFieldId) const |
|
415 { |
|
416 TMatchFieldId matcher(aFieldId); |
|
417 return FindMatching(iEntries,matcher); |
|
418 } |
|
419 |
|
420 EXPORT_C CPbkFieldInfo* CPbkFieldsInfo::Find |
|
421 (TPbkFieldId aFieldId, TPbkFieldLocation aLocation) const |
|
422 { |
|
423 TMatchFieldIdAndLocation matcher(aFieldId,aLocation); |
|
424 return FindMatching(iEntries,matcher); |
|
425 } |
|
426 |
|
427 EXPORT_C CPbkFieldInfo* CPbkFieldsInfo::Find |
|
428 (const CContactItemField& aField) const |
|
429 { |
|
430 TMatchContactItemField matcher(aField,*iTypeUidMap); |
|
431 return FindMatching(iEntries,matcher); |
|
432 } |
|
433 |
|
434 CPbkFieldInfo* CPbkFieldsInfo::Match |
|
435 (const CContactItemField& aField, |
|
436 const TPbkMatchPriorityLevel& aMatchPriority) const |
|
437 { |
|
438 TMatchContactItemFieldWithLevel matcher(aField,*iTypeUidMap,aMatchPriority); |
|
439 return FindMatching(iEntries,matcher); |
|
440 } |
|
441 |
|
442 EXPORT_C CPbkFieldInfo* CPbkFieldsInfo::Match |
|
443 (const MPbkVcardProperty& aVcardProperty, |
|
444 const TPbkMatchPriorityLevel& aMatchPriority) const |
|
445 { |
|
446 TMatchVcard matcher(aVcardProperty, *iTypeUidMap, aMatchPriority); |
|
447 return FindMatching(iEntries,matcher); |
|
448 } |
|
449 |
|
450 EXPORT_C TPbkMatchPriorityLevel CPbkFieldsInfo::CreateMatchPriority() const |
|
451 { |
|
452 return TPbkMatchPriorityLevel(iHighestMatchPriorityLevel); |
|
453 } |
|
454 |
|
455 EXPORT_C TInt CPbkFieldsInfo::Count() const |
|
456 { |
|
457 return iEntries.Count(); |
|
458 } |
|
459 |
|
460 EXPORT_C CPbkFieldInfo* CPbkFieldsInfo::operator[](TInt aIndex) const |
|
461 { |
|
462 __ASSERT_ALWAYS(aIndex >= 0 && aIndex < iEntries.Count(), |
|
463 Panic(EPanicIndexOutOfRange)); |
|
464 return CONST_CAST(CPbkFieldInfo*,iEntries[aIndex]); |
|
465 } |
|
466 |
|
467 EXPORT_C TInt CPbkFieldsInfo::GroupCount() const |
|
468 { |
|
469 return iGroups.Count(); |
|
470 } |
|
471 |
|
472 EXPORT_C const CPbkFieldInfoGroup& CPbkFieldsInfo::GroupAt(TInt aIndex) const |
|
473 { |
|
474 return *iGroups[aIndex]; |
|
475 } |
|
476 |
|
477 EXPORT_C CContactItemViewDef* CPbkFieldsInfo::CreateContactItemViewDefLC |
|
478 (const CPbkFieldIdArray& aFieldTypes) const |
|
479 { |
|
480 CContactItemViewDef* result = |
|
481 CContactItemViewDef::NewLC( |
|
482 CContactItemViewDef::EIncludeFields, |
|
483 CContactItemViewDef::EIncludeHiddenFields); |
|
484 TAddToViewDef viewDefAdder(*result); |
|
485 ProcessMatchingL(iEntries, aFieldTypes, viewDefAdder); |
|
486 return result; |
|
487 } |
|
488 |
|
489 EXPORT_C CContactItemFieldDef* CPbkFieldsInfo::CreateContactItemFieldDefLC |
|
490 (const CPbkFieldIdArray* aFieldTypes) const |
|
491 { |
|
492 CContactItemFieldDef* result = new(ELeave) CContactItemFieldDef; |
|
493 CleanupStack::PushL(result); |
|
494 if (aFieldTypes) |
|
495 { |
|
496 TAddToFieldDef fieldDefAdder(*result); |
|
497 ProcessMatchingL(iEntries, *aFieldTypes, fieldDefAdder); |
|
498 } |
|
499 else |
|
500 { |
|
501 // No Phonebook fields specified, match all contact fields |
|
502 result->AppendL(KUidContactFieldMatchAll); |
|
503 } |
|
504 return result; |
|
505 } |
|
506 |
|
507 void CPbkFieldsInfo::AddFieldTypesFromResourceL |
|
508 (TResourceReader& aPbkResReader, |
|
509 TResourceReader& aCntModelResReader, |
|
510 RArray<const CPbkFieldInfo*>* aAddedFieldTypes) |
|
511 { |
|
512 // get the counts of items in the arrays |
|
513 const TInt stdCount = aCntModelResReader.ReadInt16(); |
|
514 const TInt addCount = aPbkResReader.ReadInt16(); |
|
515 __ASSERT_ALWAYS(stdCount==addCount, |
|
516 Panic(EPanicResourceArrayCountsMismatch)); |
|
517 |
|
518 // Read central repository params before the loop. |
|
519 // Otherwise there can be performance problems during device boot up. |
|
520 // Params are read to iPbkFieldInfoParams when needed. |
|
521 ReadFieldInfoParamsL(); |
|
522 |
|
523 // Allocate the info array |
|
524 TInt i; |
|
525 for (i=0; i < stdCount; ++i) |
|
526 { |
|
527 // Create new field info object and initialise it from resources |
|
528 CPbkFieldInfo* fieldInfo = CPbkFieldInfo::NewLC |
|
529 (aCntModelResReader, aPbkResReader, *iPbkFieldInfoParams); |
|
530 fieldInfo->UpdateTypeUidMapL(*iTypeUidMap); |
|
531 |
|
532 // Set the group of the field info object |
|
533 const TPbkFieldGroupId groupId = fieldInfo->iGroupLink.iGroupId; |
|
534 if (groupId == EPbkFieldGroupIdNone) |
|
535 { |
|
536 fieldInfo->iGroupLink.iGroup = NULL; |
|
537 } |
|
538 else |
|
539 { |
|
540 CPbkFieldInfoGroup* group = FindGroup(groupId); |
|
541 __ASSERT_ALWAYS(group, Panic(EPanicResourceLinkedGroupNotFound)); |
|
542 group->AddL(*fieldInfo); |
|
543 fieldInfo->iGroupLink.iGroup = group; |
|
544 } |
|
545 |
|
546 // Add field info object to the array |
|
547 User::LeaveIfError(iEntries.Append(fieldInfo)); |
|
548 CleanupStack::Pop(fieldInfo); |
|
549 if (aAddedFieldTypes) |
|
550 { |
|
551 User::LeaveIfError( aAddedFieldTypes->Append(fieldInfo) ); |
|
552 } |
|
553 } |
|
554 |
|
555 // Calculate type mapping signatures and maximum level of import priorities |
|
556 const TInt allCount = iEntries.Count(); |
|
557 for (i=0; i < allCount; ++i) |
|
558 { |
|
559 iEntries[i]->CalculateTypeSignatures(*iTypeUidMap); |
|
560 const TInt importPropertyCount = iEntries[i]->ImportPropertyCount(); |
|
561 if (importPropertyCount > iHighestMatchPriorityLevel) |
|
562 { |
|
563 iHighestMatchPriorityLevel = importPropertyCount; |
|
564 } |
|
565 } |
|
566 |
|
567 // Sort the info array to specified field ordering |
|
568 iEntries.Sort(CompareOrdering); |
|
569 } |
|
570 |
|
571 inline CPbkFieldInfoGroup* CPbkFieldsInfo::FindGroup(TPbkFieldGroupId aGroupId) |
|
572 { |
|
573 const TInt count = iGroups.Count(); |
|
574 for (TInt i=0; i < count; ++i) |
|
575 { |
|
576 CPbkFieldInfoGroup* group = iGroups[i]; |
|
577 if (group->Id() == aGroupId) |
|
578 { |
|
579 return group; |
|
580 } |
|
581 } |
|
582 return NULL; |
|
583 } |
|
584 |
|
585 inline void CPbkFieldsInfo::ReadGroupsInfoL(RResourceFile& aResFile) |
|
586 { |
|
587 TResourceReader resReader; |
|
588 resReader.SetBuffer(aResFile.AllocReadLC(R_PBK_FIELD_GROUPS)); |
|
589 TInt count = resReader.ReadInt16(); |
|
590 while (count-- > 0) |
|
591 { |
|
592 CPbkFieldInfoGroup* group = CPbkFieldInfoGroup::NewLC(resReader); |
|
593 User::LeaveIfError(iGroups.Append(group)); |
|
594 CleanupStack::Pop(group); |
|
595 } |
|
596 CleanupStack::PopAndDestroy(); // R_PBK_FIELD_GROUPS |
|
597 } |
|
598 |
|
599 void CPbkFieldsInfo::ConstructFromResourceL |
|
600 (RResourceFile& aPbkResFile, RResourceFile& aCntModelResFile) |
|
601 { |
|
602 // Read contact model field information |
|
603 TResourceReader cntModelReader; |
|
604 cntModelReader.SetBuffer(aCntModelResFile.AllocReadLC(R_CNTUI_NEW_FIELD_DEFNS)); |
|
605 // Read additional phonebook information |
|
606 TResourceReader pbkReader; |
|
607 pbkReader.SetBuffer(aPbkResFile.AllocReadLC(R_PHONEBOOK_FIELD_PROPERTIES)); |
|
608 |
|
609 // Allocate type UID map |
|
610 iTypeUidMap = new (ELeave) CPbkUidMap; |
|
611 |
|
612 ReadGroupsInfoL(aPbkResFile); |
|
613 |
|
614 AddFieldTypesFromResourceL(pbkReader, cntModelReader, NULL); |
|
615 CleanupStack::PopAndDestroy(2); // R_PHONEBOOK_FIELD_PROPERTIES, R_CNTUI_NEW_FIELD_DEFNS |
|
616 } |
|
617 |
|
618 void CPbkFieldsInfo::ReadFieldInfoParamsL() |
|
619 { |
|
620 if (!iPbkFieldInfoParams) |
|
621 { |
|
622 iPbkFieldInfoParams = new (ELeave) CPbkFieldInfo::TPbkFieldInfoParams(); |
|
623 iPbkFieldInfoParams->iEditorMaxNumberLength = ReadMaxNumberLengthL(); |
|
624 } |
|
625 } |
|
626 |
|
627 // End of File |