|
1 /* |
|
2 * Copyright (c) 2005-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 group view sort order. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPguSortOrder.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include <RPbk2LocalizedResourceFile.h> |
|
23 #include <Pbk2GroupUIRes.rsg> |
|
24 #include <Pbk2DataCaging.hrh> |
|
25 |
|
26 // Virtual Phonebook |
|
27 #include <CVPbkSortOrder.h> |
|
28 #include <CVPbkContactManager.h> |
|
29 |
|
30 // System includes |
|
31 #include <barsread.h> |
|
32 |
|
33 /// Unnamed namespace for local definitons |
|
34 namespace { |
|
35 |
|
36 _LIT(KPbk2GroupResFile, "Pbk2GroupUIRes.rsc"); |
|
37 |
|
38 #ifdef _DEBUG |
|
39 enum TPanicCode |
|
40 { |
|
41 EPanicPreCond_NullPointer |
|
42 }; |
|
43 |
|
44 void Panic(TInt aReason) |
|
45 { |
|
46 _LIT(KPanicText, "CPguSortOrder"); |
|
47 User::Panic(KPanicText, aReason); |
|
48 } |
|
49 #endif // _DEBUG |
|
50 |
|
51 } /// namespace |
|
52 |
|
53 // -------------------------------------------------------------------------- |
|
54 // CPguSortOrder::CPguSortOrder |
|
55 // -------------------------------------------------------------------------- |
|
56 // |
|
57 CPguSortOrder::CPguSortOrder |
|
58 ( const MVPbkFieldTypeList& aMasterFieldTypeList ) : |
|
59 iMasterFieldTypeList ( aMasterFieldTypeList ) |
|
60 { |
|
61 } |
|
62 |
|
63 // -------------------------------------------------------------------------- |
|
64 // CPguSortOrder::ConstructL |
|
65 // -------------------------------------------------------------------------- |
|
66 // |
|
67 inline void CPguSortOrder::ConstructL() |
|
68 { |
|
69 iSortOrder = CreateSortOrderL(); |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CPguSortOrder::NewL |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 CPguSortOrder* CPguSortOrder::NewL |
|
77 ( const MVPbkFieldTypeList& aMasterFieldTypeList ) |
|
78 { |
|
79 CPguSortOrder* self = |
|
80 new ( ELeave ) CPguSortOrder ( aMasterFieldTypeList ); |
|
81 CleanupStack::PushL( self ); |
|
82 self->ConstructL(); |
|
83 CleanupStack::Pop( self ); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // -------------------------------------------------------------------------- |
|
88 // CPguSortOrder::~CPguSortOrder |
|
89 // -------------------------------------------------------------------------- |
|
90 // |
|
91 CPguSortOrder::~CPguSortOrder() |
|
92 { |
|
93 delete iSortOrder; |
|
94 } |
|
95 |
|
96 // -------------------------------------------------------------------------- |
|
97 // CPguSortOrder::FieldTypeCount |
|
98 // -------------------------------------------------------------------------- |
|
99 // |
|
100 TInt CPguSortOrder::FieldTypeCount() const |
|
101 { |
|
102 return iSortOrder->FieldTypeCount(); |
|
103 } |
|
104 |
|
105 // -------------------------------------------------------------------------- |
|
106 // CPguSortOrder::FieldTypeAt |
|
107 // -------------------------------------------------------------------------- |
|
108 // |
|
109 const MVPbkFieldType& CPguSortOrder::FieldTypeAt( TInt aIndex ) const |
|
110 { |
|
111 return iSortOrder->FieldTypeAt( aIndex ); |
|
112 } |
|
113 |
|
114 // -------------------------------------------------------------------------- |
|
115 // CPguSortOrder::ContainsSame |
|
116 // -------------------------------------------------------------------------- |
|
117 // |
|
118 TBool CPguSortOrder::ContainsSame( const MVPbkFieldType& aFieldType ) const |
|
119 { |
|
120 return iSortOrder->ContainsSame( aFieldType ); |
|
121 } |
|
122 |
|
123 // -------------------------------------------------------------------------- |
|
124 // CPguSortOrder::MaxMatchPriority |
|
125 // -------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CPguSortOrder::MaxMatchPriority() const |
|
128 { |
|
129 return iSortOrder->MaxMatchPriority(); |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CPguSortOrder::FindMatch |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 const MVPbkFieldType* CPguSortOrder::FindMatch |
|
137 ( const TVPbkFieldVersitProperty& aMatchProperty, |
|
138 TInt aMatchPriority ) const |
|
139 { |
|
140 return iSortOrder->FindMatch( aMatchProperty, aMatchPriority ); |
|
141 } |
|
142 |
|
143 // -------------------------------------------------------------------------- |
|
144 // CPguSortOrder::FindMatch |
|
145 // -------------------------------------------------------------------------- |
|
146 // |
|
147 const MVPbkFieldType* CPguSortOrder::FindMatch |
|
148 ( TVPbkNonVersitFieldType aNonVersitType ) const |
|
149 { |
|
150 return iSortOrder->FindMatch( aNonVersitType ); |
|
151 } |
|
152 |
|
153 // -------------------------------------------------------------------------- |
|
154 // CPguSortOrder::Find |
|
155 // -------------------------------------------------------------------------- |
|
156 // |
|
157 const MVPbkFieldType* CPguSortOrder::Find( TInt aFieldTypeResId ) const |
|
158 { |
|
159 return iSortOrder->Find( aFieldTypeResId ); |
|
160 } |
|
161 |
|
162 // -------------------------------------------------------------------------- |
|
163 // CPguSortOrder::CreateSortOrderL |
|
164 // -------------------------------------------------------------------------- |
|
165 // |
|
166 CVPbkSortOrder* CPguSortOrder::CreateSortOrderL() |
|
167 { |
|
168 TResourceReader reader; |
|
169 RPbk2LocalizedResourceFile resFile; |
|
170 resFile.OpenLC( KPbk2RomFileDrive, KDC_RESOURCE_FILES_DIR, |
|
171 KPbk2GroupResFile ); |
|
172 HBufC8* buffer = resFile.AllocReadL( R_GROUP_DISPLAY_ORDER ); |
|
173 CleanupStack::PopAndDestroy(); // resFile |
|
174 CleanupStack::PushL( buffer ); |
|
175 reader.SetBuffer( buffer ); |
|
176 |
|
177 CVPbkSortOrder* result = CVPbkSortOrder::NewL |
|
178 ( reader, iMasterFieldTypeList ); |
|
179 |
|
180 CleanupStack::PopAndDestroy(); // AllocReadLC |
|
181 |
|
182 return result; |
|
183 } |
|
184 |
|
185 // End of File |