/** * Add fields that meet some desired sort order * @param aContact - Contact to be updated woth desired fields * @param aSortOrder - specifies information about the desired fields */ void CTestContactViewCRUDOperationsStep::AddContactFieldL(CContactItem& aContact, const RContactViewSortOrder& aSortOrder) { const TInt KMaxSortOrderCount = 3; for(TInt i = 0; i < KMaxSortOrderCount; ++i) { TFieldType fieldType = aSortOrder[i]; TStorageType storageType = GetStorageType(fieldType); CContentType* contentType = CContentType::NewL(); CleanupStack::PushL(contentType); contentType->AddFieldTypeL(fieldType); CContactItemField* field = CContactItemField::NewL(storageType, *contentType); CleanupStack::PushL(field); SetDataL(fieldType, *field); aContact.AddFieldL(*field); CleanupStack::Pop(field); CleanupStack::PopAndDestroy(contentType); } }
void CTestContactViewCRUDOperationsStep::AddMatchingStringToContactL(CContactItem& aContact) { _LIT(KDesiredMatchingString, "matchingstring"); TPtrC desiredMatchingString; GetStringFromConfig(ConfigSection(), KDesiredMatchingString, desiredMatchingString); _LIT(KDesiredContactField, "contactfield"); TPtrC desiredContactField; GetStringFromConfig(ConfigSection(), KDesiredContactField, desiredContactField); TUid uidInfo = GetContactFieldType(desiredContactField); CContactItemFieldSet& fieldSet = aContact.CardFields(); TInt pos = fieldSet.Find(uidInfo); if(pos == KErrNotFound) { TFieldType fieldType = uidInfo; TStorageType storageType = GetStorageType(fieldType); CContentType* contentType = CContentType::NewL(); CleanupStack::PushL(contentType); contentType->AddFieldTypeL(fieldType); CContactItemField* field = CContactItemField::NewL(storageType, *contentType); CleanupStack::PushL(field); field->TextStorage()->SetTextL(desiredMatchingString); aContact.AddFieldL(*field); CleanupStack::Pop(field); CleanupStack::PopAndDestroy(contentType); } else { CContactItemField& field = fieldSet[pos]; field.TextStorage()->SetTextL(desiredMatchingString); } }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::StringFieldContentTypeL // (other items were commented in a header) // --------------------------------------------------------------------------- // CContentType* CPIMContactFieldInfo::StringFieldContentTypeL( const TPIMContactField aContactField, const TPIMAttribute aAttributes, EContactFieldCategory& aCategory) const { JELOG2(EPim); CContentType* type = NULL; switch (aContactField) { case EPIMContactEmail: { type = CContentType::NewL(KUidContactFieldEMail, KUidContactFieldVCardMapEMAILINTERNET); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPREF); } CleanupStack::Pop(type); break; } case EPIMContactNote: { type = CContentType::NewL(KUidContactFieldNote, KUidContactFieldVCardMapNOTE); aCategory = EContactCategoryOther; break; } case EPIMContactOrg: { type = CContentType::NewL(KUidContactFieldCompanyName, KUidContactFieldVCardMapORG); aCategory = EContactCategoryWork; break; } case EPIMContactTel: { // PIM API Contact.TEL field is mapped to either a // telephone or a fax field in Contacts Model according to // PIM API attributes if ((aAttributes & EPIMContactAttrFax) != 0) { type = CContentType::NewL(KUidContactFieldFax, KUidContactFieldVCardMapTEL); } else { type = CContentType::NewL(KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL); } CleanupStack::PushL(type); // PIM API attributes are further mapped to details in // Contacts Model fields. // Fax, pager and mobile numbers are preferred in this order // (rarest first). if ((aAttributes & EPIMContactAttrFax) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapFAX); } else if ((aAttributes & EPIMContactAttrPager) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPAGER); aCategory = EContactCategoryNone; } else if ((aAttributes & EPIMContactAttrMobile) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapCELL); } else if ((aAttributes & EPIMContactAttrAuto) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapCAR); aCategory = EContactCategoryNone; } else if ((aAttributes & EPIMContactAttrAsst) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapAssistantTel); // Assistant Phone is not mapped as a Telephone field in Pbk // so we have to set the mapping to match it type->SetMapping(KUidContactFieldVCardMapAssistantTel); } else if ((aAttributes & EPIMContactAttrExtVideoCall) != 0) { type ->AddFieldTypeL(KUidContactFieldVCardMapVIDEO); } else if ((aAttributes & EPIMContactAttrOther) != 0) { // Discard ATTR_OTHER because contacts model doesn't // provide anything where we could map this attribute } else { type->AddFieldTypeL(KUidContactFieldVCardMapVOICE); } if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { type->AddFieldTypeL(KUidContactFieldVCardMapPREF); } if ((aAttributes & EPIMContactAttrSms) != 0) { TUid uid = { KPIMIntPbkDefaultFieldSms }; type->AddFieldTypeL(uid); } CleanupStack::Pop(type); break; } case EPIMContactTitle: { type = CContentType::NewL(KUidContactFieldJobTitle, KUidContactFieldVCardMapTITLE); aCategory = EContactCategoryWork; break; } case EPIMContactNickname: { type = CContentType::NewL(KUidContactFieldSecondName, KUidContactFieldVCardMapSECONDNAME); break; } case EPIMContactUrl: { type = CContentType::NewL(KUidContactFieldUrl, KUidContactFieldVCardMapURL); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } CleanupStack::Pop(type); break; } case EPIMContactExtSip: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapSIPID); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from VOIP field type->AddFieldTypeL(KUidContactFieldVCardMapSIPID); CleanupStack::Pop(type); break; } case EPIMContactExtDtmf: { // Note: DTMF is not imported or exported in vCards type = CContentType::NewL(KUidContactFieldDTMF, KUidContactFieldVCardMapUnknown); break; } case EPIMContactExtWvUserId: { type = CContentType::NewL(KUidContactFieldIMAddress, KUidContactFieldVCardMapWV); break; } case EPIMContactExtDepartment: { type = CContentType::NewL(KUidContactFieldDepartmentName, KUidContactFieldVCardMapDepartment); break; } case EPIMContactExtAssistantName: { type = CContentType::NewL(KUidContactFieldAssistant, KUidContactFieldVCardMapAssistant); break; } case EPIMContactExtChildren: { type = CContentType::NewL(KUidContactFieldChildren, KUidContactFieldVCardMapChildren); break; } case EPIMContactExtSpouse: { type = CContentType::NewL(KUidContactFieldSpouse, KUidContactFieldVCardMapSpouse); break; } case EPIMContactExtVoip: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapVOIP); CleanupStack::PushL(type); if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } if ((aAttributes & EPIMContactAttrPreferred) != 0) { TUid uid = { KPIMIntPbkDefaultFieldVoip }; type->AddFieldTypeL(uid); } CleanupStack::Pop(type); break; } case EPIMContactExtPTT: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapPOC); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from PTT field type->AddFieldTypeL(KUidContactFieldVCardMapPOC); CleanupStack::Pop(type); break; } case EPIMContactExtSWIS: { type = CContentType::NewL(KUidContactFieldSIPID, KUidContactFieldVCardMapSWIS); CleanupStack::PushL(type); // Phonebook needs this field to separate SIP field from SWIS field type->AddFieldTypeL(KUidContactFieldVCardMapSWIS); CleanupStack::Pop(type); break; } default: { __ASSERT_DEBUG(EFalse, User::Panic(KPIMPanicCategory, EPIMPanicUnsupportedField)); } } return type; }
// --------------------------------------------------------------------------- // CPIMContactFieldInfo::AddressContentTypeL // (other items were commented in a header) // --------------------------------------------------------------------------- // CContentType* CPIMContactFieldInfo::AddressContentTypeL( TPIMContactAddrElement aElement, EContactFieldCategory aCategory) const { JELOG2(EPim); CContentType* type = NULL; switch (aElement) { case EPIMContactAddrPoBox: { type = CContentType::NewL(KUidContactFieldPostOffice, KUidContactFieldVCardMapPOSTOFFICE); break; } case EPIMContactAddrExtra: { type = CContentType::NewL(KUidContactFieldExtendedAddress, KUidContactFieldVCardMapEXTENDEDADR); break; } case EPIMContactAddrStreet: { type = CContentType::NewL(KUidContactFieldAddress, KUidContactFieldVCardMapADR); break; } case EPIMContactAddrLocality: { type = CContentType::NewL(KUidContactFieldLocality, KUidContactFieldVCardMapLOCALITY); break; } case EPIMContactAddrRegion: { type = CContentType::NewL(KUidContactFieldRegion, KUidContactFieldVCardMapREGION); break; } case EPIMContactAddrPostalCode: { type = CContentType::NewL(KUidContactFieldPostcode, KUidContactFieldVCardMapPOSTCODE); break; } case EPIMContactAddrCountry: { type = CContentType::NewL(KUidContactFieldCountry, KUidContactFieldVCardMapCOUNTRY); break; } default: { User::Leave(KErrArgument); } } CleanupStack::PushL(type); // Add category if (EContactCategoryHome == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapHOME); } else if (EContactCategoryWork == aCategory) { type->AddFieldTypeL(KUidContactFieldVCardMapWORK); } CleanupStack::Pop(type); return type; }