|
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 field property. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2FieldProperty.h" |
|
20 |
|
21 // From Phonebook 2 |
|
22 #include "CPbk2FieldOrderingManager.h" |
|
23 |
|
24 // From Virtual Phonebook |
|
25 #include <MVPbkFieldType.h> |
|
26 |
|
27 // System includes |
|
28 #include <barsread.h> |
|
29 #include <coemain.h> |
|
30 |
|
31 |
|
32 // -------------------------------------------------------------------------- |
|
33 // CPbk2FieldProperty::CPbk2FieldProperty |
|
34 // -------------------------------------------------------------------------- |
|
35 // |
|
36 CPbk2FieldProperty::CPbk2FieldProperty() |
|
37 { |
|
38 } |
|
39 |
|
40 // -------------------------------------------------------------------------- |
|
41 // CPbk2FieldProperty::~CPbk2FieldProperty |
|
42 // -------------------------------------------------------------------------- |
|
43 // |
|
44 CPbk2FieldProperty::~CPbk2FieldProperty() |
|
45 { |
|
46 delete iAddItemText; |
|
47 delete iDefaultLabel; |
|
48 delete iXSpName; |
|
49 } |
|
50 |
|
51 // -------------------------------------------------------------------------- |
|
52 // CPbk2FieldProperty::ConstructL |
|
53 // -------------------------------------------------------------------------- |
|
54 // |
|
55 inline void CPbk2FieldProperty::ConstructL |
|
56 ( TResourceReader& aReader, |
|
57 const MVPbkFieldTypeList& aSupportedFieldTypeList, |
|
58 CPbk2FieldOrderingManager& aFieldOrderingManager ) |
|
59 { |
|
60 aReader.ReadInt8(); // read version number |
|
61 const TInt fieldTypeResId = aReader.ReadInt32(); |
|
62 |
|
63 iFieldType = aSupportedFieldTypeList.Find( fieldTypeResId ); |
|
64 iMultiplicity = aReader.ReadInt8(); |
|
65 iMaxLength = aReader.ReadInt16(); |
|
66 iEditMode = aReader.ReadInt8(); |
|
67 iDefaultCase = aReader.ReadInt8(); |
|
68 iIconId = TPbk2IconId( aReader ); |
|
69 iCtrlType = aReader.ReadInt8(); |
|
70 iFlags = aReader.ReadUint32(); |
|
71 iAddItemText = aReader.ReadHBufCL(); |
|
72 iLocation = aReader.ReadInt8(); |
|
73 iGroupId = aReader.ReadInt8(); |
|
74 iDefaultLabel = aReader.ReadHBufCL(); |
|
75 iXSpName = NULL; |
|
76 |
|
77 if ( iFieldType ) |
|
78 { |
|
79 // If field type is supported get ordering items |
|
80 iOrderingItem = |
|
81 aFieldOrderingManager.OrderingItem( *iFieldType ); |
|
82 iAddItemOrdering = |
|
83 aFieldOrderingManager.AddItemOrdering( *iFieldType ); |
|
84 } |
|
85 } |
|
86 |
|
87 // -------------------------------------------------------------------------- |
|
88 // CPbk2FieldProperty::NewLC |
|
89 // -------------------------------------------------------------------------- |
|
90 // |
|
91 CPbk2FieldProperty* CPbk2FieldProperty::NewLC |
|
92 ( TResourceReader& aReader, |
|
93 const MVPbkFieldTypeList& aSupportedFieldTypeList, |
|
94 CPbk2FieldOrderingManager& aFieldOrderingManager ) |
|
95 { |
|
96 CPbk2FieldProperty* self = new( ELeave ) CPbk2FieldProperty; |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL( aReader, aSupportedFieldTypeList, |
|
99 aFieldOrderingManager ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // -------------------------------------------------------------------------- |
|
104 // CPbk2FieldProperty::IsSupported |
|
105 // -------------------------------------------------------------------------- |
|
106 // |
|
107 TBool CPbk2FieldProperty::IsSupported() const |
|
108 { |
|
109 TBool ret = EFalse; |
|
110 |
|
111 if ( iFieldType ) |
|
112 { |
|
113 ret = ETrue; |
|
114 } |
|
115 |
|
116 return ret; |
|
117 } |
|
118 |
|
119 // -------------------------------------------------------------------------- |
|
120 // CPbk2FieldProperty::IsSame |
|
121 // -------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CPbk2FieldProperty::IsSame( const MPbk2FieldProperty& aOther) const |
|
124 { |
|
125 MPbk2FieldProperty2* fieldPropertyExtension = |
|
126 reinterpret_cast<MPbk2FieldProperty2*>( const_cast<MPbk2FieldProperty&> |
|
127 ( aOther ).FieldPropertyExtension( |
|
128 KMPbk2FieldPropertyExtension2Uid ) ); |
|
129 TBool xSpNameIsSame = ETrue; |
|
130 if ( fieldPropertyExtension != NULL ) |
|
131 { |
|
132 if ( fieldPropertyExtension->XSpName().CompareF( XSpName() ) != 0 ) |
|
133 { |
|
134 xSpNameIsSame = EFalse; |
|
135 } |
|
136 } |
|
137 |
|
138 return ( aOther.FieldType().IsSame( *iFieldType ) && xSpNameIsSame ); |
|
139 } |
|
140 |
|
141 // -------------------------------------------------------------------------- |
|
142 // CPbk2FieldProperty::FieldType |
|
143 // -------------------------------------------------------------------------- |
|
144 // |
|
145 const MVPbkFieldType& CPbk2FieldProperty::FieldType() const |
|
146 { |
|
147 return *iFieldType; |
|
148 } |
|
149 |
|
150 // -------------------------------------------------------------------------- |
|
151 // CPbk2FieldProperty::Multiplicity |
|
152 // -------------------------------------------------------------------------- |
|
153 // |
|
154 TPbk2FieldMultiplicity CPbk2FieldProperty::Multiplicity() const |
|
155 { |
|
156 return static_cast<TPbk2FieldMultiplicity>(iMultiplicity); |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------------- |
|
160 // CPbk2FieldProperty::MaxLength |
|
161 // -------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CPbk2FieldProperty::MaxLength() const |
|
164 { |
|
165 return iMaxLength; |
|
166 } |
|
167 |
|
168 // -------------------------------------------------------------------------- |
|
169 // CPbk2FieldProperty::EditMode |
|
170 // -------------------------------------------------------------------------- |
|
171 // |
|
172 TPbk2FieldEditMode CPbk2FieldProperty::EditMode() const |
|
173 { |
|
174 return static_cast<TPbk2FieldEditMode>(iEditMode); |
|
175 } |
|
176 |
|
177 // -------------------------------------------------------------------------- |
|
178 // CPbk2FieldProperty::DefaultCase |
|
179 // -------------------------------------------------------------------------- |
|
180 // |
|
181 TPbk2FieldDefaultCase CPbk2FieldProperty::DefaultCase() const |
|
182 { |
|
183 return static_cast<TPbk2FieldDefaultCase>(iDefaultCase); |
|
184 } |
|
185 |
|
186 // -------------------------------------------------------------------------- |
|
187 // CPbk2FieldProperty::IconId |
|
188 // -------------------------------------------------------------------------- |
|
189 // |
|
190 const TPbk2IconId& CPbk2FieldProperty::IconId() const |
|
191 { |
|
192 return iIconId; |
|
193 } |
|
194 |
|
195 // -------------------------------------------------------------------------- |
|
196 // CPbk2FieldProperty::CtrlType |
|
197 // -------------------------------------------------------------------------- |
|
198 // |
|
199 TPbk2FieldCtrlType CPbk2FieldProperty::CtrlType() const |
|
200 { |
|
201 return static_cast<TPbk2FieldCtrlType>(iCtrlType); |
|
202 } |
|
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CPbk2FieldProperty::Flags |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 TUint CPbk2FieldProperty::Flags() const |
|
209 { |
|
210 return iFlags; |
|
211 } |
|
212 |
|
213 // -------------------------------------------------------------------------- |
|
214 // CPbk2FieldProperty::OrderingItem |
|
215 // -------------------------------------------------------------------------- |
|
216 // |
|
217 TInt CPbk2FieldProperty::OrderingItem() const |
|
218 { |
|
219 return iOrderingItem; |
|
220 } |
|
221 |
|
222 // -------------------------------------------------------------------------- |
|
223 // CPbk2FieldProperty::AddItemOrdering |
|
224 // -------------------------------------------------------------------------- |
|
225 // |
|
226 TInt CPbk2FieldProperty::AddItemOrdering() const |
|
227 { |
|
228 return iAddItemOrdering; |
|
229 } |
|
230 |
|
231 // -------------------------------------------------------------------------- |
|
232 // CPbk2FieldProperty::AddItemText |
|
233 // -------------------------------------------------------------------------- |
|
234 // |
|
235 const TDesC& CPbk2FieldProperty::AddItemText() const |
|
236 { |
|
237 if (iAddItemText) |
|
238 { |
|
239 return *iAddItemText; |
|
240 } |
|
241 else if (iDefaultLabel) |
|
242 { |
|
243 return *iDefaultLabel; |
|
244 } |
|
245 else |
|
246 { |
|
247 return KNullDesC; |
|
248 } |
|
249 } |
|
250 |
|
251 // -------------------------------------------------------------------------- |
|
252 // CPbk2FieldProperty::Location |
|
253 // -------------------------------------------------------------------------- |
|
254 // |
|
255 TPbk2FieldLocation CPbk2FieldProperty::Location() const |
|
256 { |
|
257 return static_cast<TPbk2FieldLocation>(iLocation); |
|
258 } |
|
259 |
|
260 // -------------------------------------------------------------------------- |
|
261 // CPbk2FieldProperty::GroupId |
|
262 // -------------------------------------------------------------------------- |
|
263 // |
|
264 TPbk2FieldGroupId CPbk2FieldProperty::GroupId() const |
|
265 { |
|
266 return static_cast<TPbk2FieldGroupId>(iGroupId); |
|
267 } |
|
268 |
|
269 // -------------------------------------------------------------------------- |
|
270 // CPbk2FieldProperty::DefaultLabel |
|
271 // -------------------------------------------------------------------------- |
|
272 // |
|
273 const TDesC& CPbk2FieldProperty::DefaultLabel() const |
|
274 { |
|
275 return iDefaultLabel ? *iDefaultLabel : KNullDesC(); |
|
276 } |
|
277 |
|
278 // -------------------------------------------------------------------------- |
|
279 // CPbk2FieldProperty::FieldPropertyExtension |
|
280 // -------------------------------------------------------------------------- |
|
281 // |
|
282 TAny* CPbk2FieldProperty::FieldPropertyExtension( TUid aExtensionUid ) |
|
283 { |
|
284 if ( aExtensionUid == KMPbk2FieldPropertyExtension2Uid ) |
|
285 { |
|
286 return static_cast<MPbk2FieldProperty2*>( this ); |
|
287 } |
|
288 return NULL; |
|
289 } |
|
290 |
|
291 // -------------------------------------------------------------------------- |
|
292 // CPbk2FieldProperty::XSpName |
|
293 // -------------------------------------------------------------------------- |
|
294 // |
|
295 const TDesC& CPbk2FieldProperty::XSpName() const |
|
296 { |
|
297 return iXSpName ? *iXSpName : KNullDesC(); |
|
298 } |
|
299 |
|
300 // End of file |