|
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: Helper class to map Contacts Model fields |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "cpimcontactfieldinfo.h" |
|
21 |
|
22 // INTERNAL INCLUDES |
|
23 #include "pimpanics.h" |
|
24 #include "logger.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <cntdef.hrh> |
|
28 #include <cntitem.h> |
|
29 |
|
30 // UNNAMED LOCAL NAMESPACE |
|
31 namespace |
|
32 { |
|
33 // Voip field Phonebook default identifier |
|
34 const TInt KPIMIntPbkDefaultFieldVoip = 0x101F8863; |
|
35 // SMS field Phonebook default ideintifier |
|
36 const TInt KPIMIntPbkDefaultFieldSms = 0x101f4cf1; |
|
37 |
|
38 // PIM attribute vs Contacts Model field vCard map element size |
|
39 const TInt KPIMFieldAttributeMapElementSize = 2; |
|
40 // PIM attribute vs Contacts Model field vCard map map. This array |
|
41 // maps PIM attributes to Contacts Model field vCard maps and vice versa |
|
42 const TInt KPIMFieldAttributeMap[][KPIMFieldAttributeMapElementSize] = |
|
43 { |
|
44 { EPIMContactAttrHome, KIntContactFieldVCardMapHOME }, |
|
45 { EPIMContactAttrWork, KIntContactFieldVCardMapWORK }, |
|
46 { EPIMContactAttrPreferred, KIntContactFieldVCardMapPREF }, |
|
47 { EPIMContactAttrMobile, KIntContactFieldVCardMapCELL }, |
|
48 { EPIMContactAttrPager, KIntContactFieldVCardMapPAGER }, |
|
49 { EPIMContactAttrSms, KPIMIntPbkDefaultFieldSms }, |
|
50 { EPIMContactAttrAsst, KIntContactFieldVCardMapAssistantTel }, |
|
51 { EPIMContactAttrAuto, KIntContactFieldVCardMapCAR }, |
|
52 { EPIMContactAttrExtVideoCall, KIntContactFieldVCardMapVIDEO }, |
|
53 { EPIMContactAttrPreferred, KPIMIntPbkDefaultFieldVoip } |
|
54 }; |
|
55 |
|
56 // PIM attribute vs. Contacts Model field vCard map map size |
|
57 const TInt KPIMFieldAttributeMapSize = sizeof(KPIMFieldAttributeMap) |
|
58 / (sizeof(TInt) * KPIMFieldAttributeMapElementSize); |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CPIMContactFieldInfo::NewL |
|
63 // Two-phase constructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CPIMContactFieldInfo* CPIMContactFieldInfo::NewL() |
|
67 { |
|
68 JELOG2(EPim); |
|
69 CPIMContactFieldInfo* self = CPIMContactFieldInfo::NewLC(); |
|
70 CleanupStack::Pop(self); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CPIMContactFieldInfo::NewLC |
|
76 // Two-phase constructor |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CPIMContactFieldInfo* CPIMContactFieldInfo::NewLC() |
|
80 { |
|
81 JELOG2(EPim); |
|
82 CPIMContactFieldInfo* self = new(ELeave) CPIMContactFieldInfo; |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CPIMContactFieldInfo::~CPIMContactFieldInfo |
|
90 // Destructor |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CPIMContactFieldInfo::~CPIMContactFieldInfo() |
|
94 { |
|
95 JELOG2(EPim); |
|
96 delete iFieldsInfo; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CPIMContactFieldInfo::MatchContactField |
|
101 // (other items were commented in a header) |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 TPIMContactField CPIMContactFieldInfo::MatchContactField( |
|
105 TInt aContactsModelFieldType) const |
|
106 { |
|
107 JELOG2(EPim); |
|
108 TInt count = iFieldsInfo->Count(); |
|
109 for (TInt i = 0; i < count; i++) |
|
110 { |
|
111 const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[i]; |
|
112 if (fieldInfo.iContactsModelField == aContactsModelFieldType) |
|
113 { |
|
114 return fieldInfo.iPIMField; |
|
115 } |
|
116 } |
|
117 return EPIMContactInvalidField; // Invalid field |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CPIMContactFieldInfo::MatchPIMField |
|
122 // (other items were commented in a header) |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 CArrayFix<TInt>* CPIMContactFieldInfo::MatchPIMFieldL( |
|
126 TPIMContactField aContactField) const |
|
127 { |
|
128 JELOG2(EPim); |
|
129 CArrayFix<TInt>* fieldArray = new(ELeave) CArrayFixFlat<TInt> (7); |
|
130 CleanupStack::PushL(fieldArray); |
|
131 TInt count = iFieldsInfo->Count(); |
|
132 for (TInt i = 0; i < count; i++) |
|
133 { |
|
134 const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[i]; |
|
135 if (fieldInfo.iPIMField == aContactField) |
|
136 { |
|
137 fieldArray->AppendL(fieldInfo.iContactsModelField); |
|
138 } |
|
139 } |
|
140 CleanupStack::Pop(fieldArray); |
|
141 return fieldArray; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CPIMContactFieldInfo::MatchContactNameElement |
|
146 // (other items were commented in a header) |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 TInt CPIMContactFieldInfo::MatchContactArrayElement( |
|
150 TInt aContactsModelFieldType) const |
|
151 { |
|
152 JELOG2(EPim); |
|
153 TInt count = iFieldsInfo->Count(); |
|
154 for (TInt i = 0; i < count; i++) |
|
155 { |
|
156 const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[i]; |
|
157 if (fieldInfo.iContactsModelField == aContactsModelFieldType) |
|
158 { |
|
159 return fieldInfo.iSubElement; |
|
160 } |
|
161 } |
|
162 return -1; // Invalid field |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CPIMContactFieldInfo::FieldAttributes |
|
167 // (other items were commented in a header) |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TPIMAttribute CPIMContactFieldInfo::FieldAttributes( |
|
171 const CContentType& aContentType) const |
|
172 { |
|
173 JELOG2(EPim); |
|
174 TPIMAttribute retVal = KPIMAttrNone; |
|
175 for (TInt i = 0; i < KPIMFieldAttributeMapSize; i++) |
|
176 { |
|
177 // Generate uid from the specified Contacts Model field id |
|
178 TUid uid = |
|
179 { KPIMFieldAttributeMap[i][1] }; |
|
180 // Match if this content type contains certain PIM attribute |
|
181 if (aContentType.ContainsFieldType(uid)) |
|
182 { |
|
183 retVal |= KPIMFieldAttributeMap[i][0]; |
|
184 } |
|
185 } |
|
186 return retVal; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CPIMContactFieldInfo::FieldInternalAttributes |
|
191 // (other items were commented in a header) |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CPIMContactFieldInfo::GetFieldInternalAttributesL( |
|
195 const CContentType& aContentType, CArrayFix<TUid>& aArrayOfAttributes) const |
|
196 { |
|
197 JELOG2(EPim); |
|
198 TInt fieldCount = aContentType.FieldTypeCount(); |
|
199 for (TInt i = 0; i < fieldCount; i++) |
|
200 { |
|
201 TFieldType fieldType = aContentType.FieldType(i); |
|
202 TBool isSupported = EFalse; |
|
203 for (TInt j = 0; j < KPIMFieldAttributeMapSize && !isSupported; j++) |
|
204 { |
|
205 // Generate uid from the specified Contacts Model field id |
|
206 TUid uid = |
|
207 { KPIMFieldAttributeMap[j][1] }; |
|
208 |
|
209 // Add this attribute to internal attributes array if |
|
210 // it is not supported. This covers all unknow attributes |
|
211 // that those won't be lost when a database item is modified |
|
212 if (fieldType == uid) |
|
213 { |
|
214 isSupported = ETrue; |
|
215 } |
|
216 } |
|
217 // Check that if field info array knows this Uid |
|
218 TInt fieldInfoCount = iFieldsInfo->Count(); |
|
219 for (TInt j = 0; j < fieldInfoCount && !isSupported; j++) |
|
220 { |
|
221 const TPIMFieldInfo& fieldInfo = (*iFieldsInfo)[j]; |
|
222 // Contacts Model field type values are defined as field types |
|
223 // So the following mappings is equal to check with the field type |
|
224 TUid uid = |
|
225 { fieldInfo.iContactsModelField }; |
|
226 if (fieldType == uid) |
|
227 { |
|
228 isSupported = ETrue; |
|
229 } |
|
230 } |
|
231 // Not supported, add to internal attributes |
|
232 if (!isSupported) |
|
233 { |
|
234 aArrayOfAttributes.AppendL(fieldType); |
|
235 } |
|
236 } |
|
237 } |
|
238 |
|
239 // --------------------------------------------------------------------------- |
|
240 // CPIMContactFieldInfo::AddressContentTypeL |
|
241 // (other items were commented in a header) |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 CContentType* CPIMContactFieldInfo::AddressContentTypeL( |
|
245 TPIMContactAddrElement aElement, EContactFieldCategory aCategory) const |
|
246 { |
|
247 JELOG2(EPim); |
|
248 CContentType* type = NULL; |
|
249 switch (aElement) |
|
250 { |
|
251 case EPIMContactAddrPoBox: |
|
252 { |
|
253 type = CContentType::NewL(KUidContactFieldPostOffice, |
|
254 KUidContactFieldVCardMapPOSTOFFICE); |
|
255 break; |
|
256 } |
|
257 case EPIMContactAddrExtra: |
|
258 { |
|
259 type = CContentType::NewL(KUidContactFieldExtendedAddress, |
|
260 KUidContactFieldVCardMapEXTENDEDADR); |
|
261 break; |
|
262 } |
|
263 case EPIMContactAddrStreet: |
|
264 { |
|
265 type = CContentType::NewL(KUidContactFieldAddress, |
|
266 KUidContactFieldVCardMapADR); |
|
267 break; |
|
268 } |
|
269 case EPIMContactAddrLocality: |
|
270 { |
|
271 type = CContentType::NewL(KUidContactFieldLocality, |
|
272 KUidContactFieldVCardMapLOCALITY); |
|
273 break; |
|
274 } |
|
275 case EPIMContactAddrRegion: |
|
276 { |
|
277 type = CContentType::NewL(KUidContactFieldRegion, |
|
278 KUidContactFieldVCardMapREGION); |
|
279 break; |
|
280 } |
|
281 case EPIMContactAddrPostalCode: |
|
282 { |
|
283 type = CContentType::NewL(KUidContactFieldPostcode, |
|
284 KUidContactFieldVCardMapPOSTCODE); |
|
285 break; |
|
286 } |
|
287 case EPIMContactAddrCountry: |
|
288 { |
|
289 type = CContentType::NewL(KUidContactFieldCountry, |
|
290 KUidContactFieldVCardMapCOUNTRY); |
|
291 break; |
|
292 } |
|
293 default: |
|
294 { |
|
295 User::Leave(KErrArgument); |
|
296 } |
|
297 } |
|
298 CleanupStack::PushL(type); |
|
299 |
|
300 // Add category |
|
301 if (EContactCategoryHome == aCategory) |
|
302 { |
|
303 type->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
304 } |
|
305 else if (EContactCategoryWork == aCategory) |
|
306 { |
|
307 type->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
308 } |
|
309 |
|
310 CleanupStack::Pop(type); |
|
311 return type; |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // CPIMContactFieldInfo::NameContentTypeL |
|
316 // (other items were commented in a header) |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 CContentType* CPIMContactFieldInfo::NameContentTypeL( |
|
320 TPIMContactNameElement aElement) const |
|
321 { |
|
322 JELOG2(EPim); |
|
323 CContentType* type = NULL; |
|
324 switch (aElement) |
|
325 { |
|
326 case EPIMContactNameFamily: |
|
327 { |
|
328 type = CContentType::NewL(KUidContactFieldFamilyName, |
|
329 KUidContactFieldVCardMapUnusedN); |
|
330 break; |
|
331 } |
|
332 case EPIMContactNameGiven: |
|
333 { |
|
334 type = CContentType::NewL(KUidContactFieldGivenName, |
|
335 KUidContactFieldVCardMapUnusedN); |
|
336 break; |
|
337 } |
|
338 case EPIMContactNameOther: |
|
339 { |
|
340 type = CContentType::NewL(KUidContactFieldAdditionalName, |
|
341 KUidContactFieldVCardMapUnusedN); |
|
342 break; |
|
343 } |
|
344 case EPIMContactNameSuffix: |
|
345 { |
|
346 type = CContentType::NewL(KUidContactFieldSuffixName, |
|
347 KUidContactFieldVCardMapUnusedN); |
|
348 break; |
|
349 } |
|
350 case EPIMContactNamePrefix: |
|
351 { |
|
352 type = CContentType::NewL(KUidContactFieldPrefixName, |
|
353 KUidContactFieldVCardMapUnusedN); |
|
354 break; |
|
355 } |
|
356 case EPIMContactExtFamilyNameReading: |
|
357 { |
|
358 type = CContentType::NewL(KUidContactFieldFamilyNamePronunciation, |
|
359 KUidContactFieldVCardMapUnusedN); |
|
360 break; |
|
361 } |
|
362 case EPIMContactExtGivenNameReading: |
|
363 { |
|
364 type = CContentType::NewL(KUidContactFieldGivenNamePronunciation, |
|
365 KUidContactFieldVCardMapUnusedN); |
|
366 break; |
|
367 } |
|
368 default: |
|
369 { |
|
370 User::Leave(KErrArgument); |
|
371 } |
|
372 } |
|
373 return type; |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------------------------- |
|
377 // CPIMContactFieldInfo::StringFieldContentTypeL |
|
378 // (other items were commented in a header) |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 CContentType* CPIMContactFieldInfo::StringFieldContentTypeL( |
|
382 const TPIMContactField aContactField, const TPIMAttribute aAttributes, |
|
383 EContactFieldCategory& aCategory) const |
|
384 { |
|
385 JELOG2(EPim); |
|
386 CContentType* type = NULL; |
|
387 |
|
388 switch (aContactField) |
|
389 { |
|
390 case EPIMContactEmail: |
|
391 { |
|
392 type = CContentType::NewL(KUidContactFieldEMail, |
|
393 KUidContactFieldVCardMapEMAILINTERNET); |
|
394 CleanupStack::PushL(type); |
|
395 |
|
396 if (EContactCategoryHome == aCategory) |
|
397 { |
|
398 type->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
399 } |
|
400 if (EContactCategoryWork == aCategory) |
|
401 { |
|
402 type->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
403 } |
|
404 if ((aAttributes & EPIMContactAttrPreferred) != 0) |
|
405 { |
|
406 type->AddFieldTypeL(KUidContactFieldVCardMapPREF); |
|
407 } |
|
408 CleanupStack::Pop(type); |
|
409 break; |
|
410 } |
|
411 case EPIMContactNote: |
|
412 { |
|
413 type = CContentType::NewL(KUidContactFieldNote, |
|
414 KUidContactFieldVCardMapNOTE); |
|
415 aCategory = EContactCategoryOther; |
|
416 break; |
|
417 } |
|
418 case EPIMContactOrg: |
|
419 { |
|
420 type = CContentType::NewL(KUidContactFieldCompanyName, |
|
421 KUidContactFieldVCardMapORG); |
|
422 aCategory = EContactCategoryWork; |
|
423 break; |
|
424 } |
|
425 case EPIMContactTel: |
|
426 { |
|
427 // PIM API Contact.TEL field is mapped to either a |
|
428 // telephone or a fax field in Contacts Model according to |
|
429 // PIM API attributes |
|
430 if ((aAttributes & EPIMContactAttrFax) != 0) |
|
431 { |
|
432 type = CContentType::NewL(KUidContactFieldFax, |
|
433 KUidContactFieldVCardMapTEL); |
|
434 } |
|
435 else |
|
436 { |
|
437 type = CContentType::NewL(KUidContactFieldPhoneNumber, |
|
438 KUidContactFieldVCardMapTEL); |
|
439 } |
|
440 CleanupStack::PushL(type); |
|
441 |
|
442 // PIM API attributes are further mapped to details in |
|
443 // Contacts Model fields. |
|
444 // Fax, pager and mobile numbers are preferred in this order |
|
445 // (rarest first). |
|
446 if ((aAttributes & EPIMContactAttrFax) != 0) |
|
447 { |
|
448 type->AddFieldTypeL(KUidContactFieldVCardMapFAX); |
|
449 } |
|
450 else if ((aAttributes & EPIMContactAttrPager) != 0) |
|
451 { |
|
452 type->AddFieldTypeL(KUidContactFieldVCardMapPAGER); |
|
453 aCategory = EContactCategoryNone; |
|
454 } |
|
455 else if ((aAttributes & EPIMContactAttrMobile) != 0) |
|
456 { |
|
457 type->AddFieldTypeL(KUidContactFieldVCardMapCELL); |
|
458 } |
|
459 else if ((aAttributes & EPIMContactAttrAuto) != 0) |
|
460 { |
|
461 type->AddFieldTypeL(KUidContactFieldVCardMapCAR); |
|
462 aCategory = EContactCategoryNone; |
|
463 } |
|
464 else if ((aAttributes & EPIMContactAttrAsst) != 0) |
|
465 { |
|
466 type->AddFieldTypeL(KUidContactFieldVCardMapAssistantTel); |
|
467 // Assistant Phone is not mapped as a Telephone field in Pbk |
|
468 // so we have to set the mapping to match it |
|
469 type->SetMapping(KUidContactFieldVCardMapAssistantTel); |
|
470 } |
|
471 else if ((aAttributes & EPIMContactAttrExtVideoCall) != 0) |
|
472 { |
|
473 type ->AddFieldTypeL(KUidContactFieldVCardMapVIDEO); |
|
474 } |
|
475 else if ((aAttributes & EPIMContactAttrOther) != 0) |
|
476 { |
|
477 // Discard ATTR_OTHER because contacts model doesn't |
|
478 // provide anything where we could map this attribute |
|
479 } |
|
480 else |
|
481 { |
|
482 type->AddFieldTypeL(KUidContactFieldVCardMapVOICE); |
|
483 } |
|
484 |
|
485 if (EContactCategoryHome == aCategory) |
|
486 { |
|
487 type->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
488 } |
|
489 if (EContactCategoryWork == aCategory) |
|
490 { |
|
491 type->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
492 } |
|
493 if ((aAttributes & EPIMContactAttrPreferred) != 0) |
|
494 { |
|
495 type->AddFieldTypeL(KUidContactFieldVCardMapPREF); |
|
496 } |
|
497 if ((aAttributes & EPIMContactAttrSms) != 0) |
|
498 { |
|
499 TUid uid = |
|
500 { KPIMIntPbkDefaultFieldSms }; |
|
501 type->AddFieldTypeL(uid); |
|
502 } |
|
503 CleanupStack::Pop(type); |
|
504 break; |
|
505 } |
|
506 case EPIMContactTitle: |
|
507 { |
|
508 type = CContentType::NewL(KUidContactFieldJobTitle, |
|
509 KUidContactFieldVCardMapTITLE); |
|
510 aCategory = EContactCategoryWork; |
|
511 break; |
|
512 } |
|
513 case EPIMContactNickname: |
|
514 { |
|
515 type = CContentType::NewL(KUidContactFieldSecondName, |
|
516 KUidContactFieldVCardMapSECONDNAME); |
|
517 break; |
|
518 } |
|
519 case EPIMContactUrl: |
|
520 { |
|
521 type = CContentType::NewL(KUidContactFieldUrl, |
|
522 KUidContactFieldVCardMapURL); |
|
523 CleanupStack::PushL(type); |
|
524 if (EContactCategoryHome == aCategory) |
|
525 { |
|
526 type->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
527 } |
|
528 if (EContactCategoryWork == aCategory) |
|
529 { |
|
530 type->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
531 } |
|
532 CleanupStack::Pop(type); |
|
533 break; |
|
534 } |
|
535 case EPIMContactExtSip: |
|
536 { |
|
537 type = CContentType::NewL(KUidContactFieldSIPID, |
|
538 KUidContactFieldVCardMapSIPID); |
|
539 CleanupStack::PushL(type); |
|
540 // Phonebook needs this field to separate SIP field from VOIP field |
|
541 type->AddFieldTypeL(KUidContactFieldVCardMapSIPID); |
|
542 CleanupStack::Pop(type); |
|
543 break; |
|
544 } |
|
545 case EPIMContactExtDtmf: |
|
546 { |
|
547 // Note: DTMF is not imported or exported in vCards |
|
548 type = CContentType::NewL(KUidContactFieldDTMF, |
|
549 KUidContactFieldVCardMapUnknown); |
|
550 break; |
|
551 } |
|
552 case EPIMContactExtWvUserId: |
|
553 { |
|
554 type = CContentType::NewL(KUidContactFieldIMAddress, |
|
555 KUidContactFieldVCardMapWV); |
|
556 break; |
|
557 } |
|
558 case EPIMContactExtDepartment: |
|
559 { |
|
560 type = CContentType::NewL(KUidContactFieldDepartmentName, |
|
561 KUidContactFieldVCardMapDepartment); |
|
562 break; |
|
563 } |
|
564 case EPIMContactExtAssistantName: |
|
565 { |
|
566 type = CContentType::NewL(KUidContactFieldAssistant, |
|
567 KUidContactFieldVCardMapAssistant); |
|
568 break; |
|
569 } |
|
570 case EPIMContactExtChildren: |
|
571 { |
|
572 type = CContentType::NewL(KUidContactFieldChildren, |
|
573 KUidContactFieldVCardMapChildren); |
|
574 break; |
|
575 } |
|
576 case EPIMContactExtSpouse: |
|
577 { |
|
578 type = CContentType::NewL(KUidContactFieldSpouse, |
|
579 KUidContactFieldVCardMapSpouse); |
|
580 break; |
|
581 } |
|
582 case EPIMContactExtVoip: |
|
583 { |
|
584 type = CContentType::NewL(KUidContactFieldSIPID, |
|
585 KUidContactFieldVCardMapVOIP); |
|
586 CleanupStack::PushL(type); |
|
587 if (EContactCategoryHome == aCategory) |
|
588 { |
|
589 type->AddFieldTypeL(KUidContactFieldVCardMapHOME); |
|
590 } |
|
591 if (EContactCategoryWork == aCategory) |
|
592 { |
|
593 type->AddFieldTypeL(KUidContactFieldVCardMapWORK); |
|
594 } |
|
595 if ((aAttributes & EPIMContactAttrPreferred) != 0) |
|
596 { |
|
597 TUid uid = |
|
598 { KPIMIntPbkDefaultFieldVoip }; |
|
599 type->AddFieldTypeL(uid); |
|
600 } |
|
601 CleanupStack::Pop(type); |
|
602 break; |
|
603 } |
|
604 case EPIMContactExtPTT: |
|
605 { |
|
606 type = CContentType::NewL(KUidContactFieldSIPID, |
|
607 KUidContactFieldVCardMapPOC); |
|
608 CleanupStack::PushL(type); |
|
609 // Phonebook needs this field to separate SIP field from PTT field |
|
610 type->AddFieldTypeL(KUidContactFieldVCardMapPOC); |
|
611 CleanupStack::Pop(type); |
|
612 break; |
|
613 } |
|
614 case EPIMContactExtSWIS: |
|
615 { |
|
616 type = CContentType::NewL(KUidContactFieldSIPID, |
|
617 KUidContactFieldVCardMapSWIS); |
|
618 CleanupStack::PushL(type); |
|
619 // Phonebook needs this field to separate SIP field from SWIS field |
|
620 type->AddFieldTypeL(KUidContactFieldVCardMapSWIS); |
|
621 CleanupStack::Pop(type); |
|
622 break; |
|
623 } |
|
624 default: |
|
625 { |
|
626 __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory, |
|
627 EPIMPanicUnsupportedField)); |
|
628 } |
|
629 } |
|
630 |
|
631 return type; |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // CPIMContactFieldInfo::CPIMContactFieldInfo |
|
636 // Default C++ constructor |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 inline CPIMContactFieldInfo::CPIMContactFieldInfo() |
|
640 { |
|
641 JELOG2(EPim); |
|
642 } |
|
643 |
|
644 void CPIMContactFieldInfo::ConstructL() |
|
645 { |
|
646 JELOG2(EPim); |
|
647 // 5 for array granularity |
|
648 iFieldsInfo = new(ELeave) CArrayFixFlat<TPIMFieldInfo> (5); |
|
649 |
|
650 // Add fields to the array |
|
651 // Name fields and sub-elements |
|
652 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldFamilyNameValue, |
|
653 EPIMContactName, EPIMContactNameFamily)); |
|
654 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldGivenNameValue, |
|
655 EPIMContactName, EPIMContactNameGiven)); |
|
656 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldAdditionalNameValue, |
|
657 EPIMContactName, EPIMContactNameOther)); |
|
658 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSuffixNameValue, |
|
659 EPIMContactName, EPIMContactNameSuffix)); |
|
660 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldPrefixNameValue, |
|
661 EPIMContactName, EPIMContactNamePrefix)); |
|
662 iFieldsInfo->AppendL(TPIMFieldInfo( |
|
663 KUidContactFieldFamilyNamePronunciationValue, EPIMContactName, |
|
664 EPIMContactExtFamilyNameReading)); |
|
665 iFieldsInfo->AppendL(TPIMFieldInfo( |
|
666 KUidContactFieldGivenNamePronunciationValue, EPIMContactName, |
|
667 EPIMContactExtGivenNameReading)); |
|
668 |
|
669 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSecondNameValue, |
|
670 EPIMContactNickname)); |
|
671 |
|
672 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldPhoneNumberValue, |
|
673 EPIMContactTel)); |
|
674 |
|
675 iFieldsInfo->AppendL( |
|
676 TPIMFieldInfo(KUidContactFieldFaxValue, EPIMContactTel)); |
|
677 |
|
678 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldEMailValue, |
|
679 EPIMContactEmail)); |
|
680 |
|
681 iFieldsInfo->AppendL( |
|
682 TPIMFieldInfo(KUidContactFieldUrlValue, EPIMContactUrl)); |
|
683 |
|
684 // Address fields and sub-elements |
|
685 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldAddressValue, |
|
686 EPIMContactAddr, EPIMContactAddrStreet)); |
|
687 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldPostOfficeValue, |
|
688 EPIMContactAddr, EPIMContactAddrPoBox)); |
|
689 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldExtendedAddressValue, |
|
690 EPIMContactAddr, EPIMContactAddrExtra)); |
|
691 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldPostCodeValue, |
|
692 EPIMContactAddr, EPIMContactAddrPostalCode)); |
|
693 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldLocalityValue, |
|
694 EPIMContactAddr, EPIMContactAddrLocality)); |
|
695 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldRegionValue, |
|
696 EPIMContactAddr, EPIMContactAddrRegion)); |
|
697 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldCountryValue, |
|
698 EPIMContactAddr, EPIMContactAddrCountry)); |
|
699 |
|
700 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldCompanyNameValue, |
|
701 EPIMContactOrg)); |
|
702 |
|
703 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldNoteValue, |
|
704 EPIMContactNote)); |
|
705 |
|
706 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldJobTitleValue, |
|
707 EPIMContactTitle)); |
|
708 // VOIP, SIP and PoC are mapped under the same Contacts Model field |
|
709 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSIPIDValue, |
|
710 EPIMContactExtSip)); |
|
711 |
|
712 // PTT is recognized with KIntContactFieldVCardMapPOC and SIPID |
|
713 iFieldsInfo->AppendL(TPIMFieldInfo(KIntContactFieldVCardMapPOC, |
|
714 EPIMContactExtPTT)); |
|
715 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSIPIDValue, |
|
716 EPIMContactExtPTT)); |
|
717 |
|
718 // SWIS is recognized with KIntContactFieldVCardMapSWIS and SIPID |
|
719 iFieldsInfo->AppendL(TPIMFieldInfo(KIntContactFieldVCardMapSWIS, |
|
720 EPIMContactExtSWIS)); |
|
721 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSIPIDValue, |
|
722 EPIMContactExtSWIS)); |
|
723 |
|
724 // VOIP is recognized with KIntContactFieldVCardMapVOIP and SIPID |
|
725 iFieldsInfo->AppendL(TPIMFieldInfo(KIntContactFieldVCardMapVOIP, |
|
726 EPIMContactExtVoip)); |
|
727 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSIPIDValue, |
|
728 EPIMContactExtVoip)); |
|
729 |
|
730 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldDTMFValue, |
|
731 EPIMContactExtDtmf)); |
|
732 |
|
733 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldIMAddressValue, |
|
734 EPIMContactExtWvUserId)); |
|
735 |
|
736 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldAssistantValue, |
|
737 EPIMContactExtAssistantName)); |
|
738 |
|
739 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldSpouseValue, |
|
740 EPIMContactExtSpouse)); |
|
741 |
|
742 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldChildrenValue, |
|
743 EPIMContactExtChildren)); |
|
744 |
|
745 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldDepartmentNameValue, |
|
746 EPIMContactExtDepartment)); |
|
747 |
|
748 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldAnniversaryValue, |
|
749 EPIMContactExtAnniversary)); |
|
750 |
|
751 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldBirthdayValue, |
|
752 EPIMContactBirthday)); |
|
753 |
|
754 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldClassValue, |
|
755 EPIMContactClass)); |
|
756 |
|
757 iFieldsInfo->AppendL(TPIMFieldInfo(KUidContactFieldPictureValue, |
|
758 EPIMContactPhoto)); |
|
759 } |
|
760 |
|
761 // End of file |