|
1 /* |
|
2 * Copyright (c) 2002-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: Phonebook 2 contact name construction policy. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2ContactNameConstructionPolicy.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include <CPbk2SortOrderManager.h> |
|
23 #include <Pbk2ContactNameFormatterFactory.h> |
|
24 #include <MPbk2ContactNameFormatter.h> |
|
25 #include <MPbk2ContactNameFormatter3.h> |
|
26 #include <CVPbkContactFieldIterator.h> |
|
27 |
|
28 // Virtual Phonebook |
|
29 #include <CVPbkContactManager.h> |
|
30 #include <CVPbkFieldTypeRefsList.h> |
|
31 |
|
32 #include <featmgr.h> |
|
33 |
|
34 // -------------------------------------------------------------------------- |
|
35 // CPbk2ContactNameConstructionPolicy::CPbk2ContactNameConstructionPolicy |
|
36 // -------------------------------------------------------------------------- |
|
37 // |
|
38 CPbk2ContactNameConstructionPolicy::CPbk2ContactNameConstructionPolicy |
|
39 ( const MVPbkFieldTypeList& aMasterFieldTypeList ) : |
|
40 iMasterFieldTypeList( aMasterFieldTypeList ) |
|
41 { |
|
42 } |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // CPbk2ContactNameConstructionPolicy::~CPbk2ContactNameConstructionPolicy |
|
46 // -------------------------------------------------------------------------- |
|
47 // |
|
48 CPbk2ContactNameConstructionPolicy::~CPbk2ContactNameConstructionPolicy() |
|
49 { |
|
50 delete iSortOrderManager; |
|
51 delete iNameFormatter; |
|
52 FeatureManager::UnInitializeLib(); |
|
53 } |
|
54 |
|
55 // -------------------------------------------------------------------------- |
|
56 // CPbk2ContactNameConstructionPolicy::NewL |
|
57 // -------------------------------------------------------------------------- |
|
58 // |
|
59 CPbk2ContactNameConstructionPolicy* CPbk2ContactNameConstructionPolicy::NewL |
|
60 ( TParam* aParam ) |
|
61 { |
|
62 CPbk2ContactNameConstructionPolicy* self = |
|
63 new ( ELeave ) CPbk2ContactNameConstructionPolicy |
|
64 ( aParam->iMasterFieldTypeList ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 // CPbk2ContactNameConstructionPolicy::ConstructL |
|
73 // -------------------------------------------------------------------------- |
|
74 // |
|
75 inline void CPbk2ContactNameConstructionPolicy::ConstructL() |
|
76 { |
|
77 iSortOrderManager = CPbk2SortOrderManager::NewL( iMasterFieldTypeList ); |
|
78 |
|
79 iNameFormatter = Pbk2ContactNameFormatterFactory::CreateL |
|
80 ( iMasterFieldTypeList, *iSortOrderManager ); |
|
81 FeatureManager::InitializeLibL(); |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CPbk2ContactNameConstructionPolicy::NameConstructionFieldsLC |
|
86 // -------------------------------------------------------------------------- |
|
87 // |
|
88 MVPbkBaseContactFieldIterator* |
|
89 CPbk2ContactNameConstructionPolicy::NameConstructionFieldsLC |
|
90 ( const MVPbkBaseContactFieldCollection& aFieldCollection, |
|
91 CVPbkFieldTypeRefsList& aFieldTypeRefsList ) |
|
92 { |
|
93 if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
|
94 { |
|
95 MPbk2ContactNameFormatter3* nameformatterExtension = |
|
96 reinterpret_cast<MPbk2ContactNameFormatter3*>( iNameFormatter-> |
|
97 ContactNameFormatterExtension( MPbk2ContactNameFormatterExtension3Uid ) ); |
|
98 |
|
99 if ( nameformatterExtension ) |
|
100 { |
|
101 return nameformatterExtension->TitleWithCompanyNameFieldsLC( aFieldTypeRefsList, aFieldCollection ); |
|
102 } |
|
103 } |
|
104 return iNameFormatter->ActualTitleFieldsLC( aFieldTypeRefsList, aFieldCollection ); |
|
105 } |
|
106 |
|
107 // End of File |