×
Namespaces

Variants
Actions

How can I programmatically add contact information with subfields such as "Street (home) on Symbian?

From Nokia Developer Wiki
Jump to: navigation, search



Article Metadata
Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition and FP1, FP2, and FP3
S60 3rd Edition
S60 3rd Edition (initial release)
S60 2nd Edition (initial release)
S60 1st Edition
Article
Created: User:Technical writer 2 (24 Aug 2006)
Last edited: hamishwillee (14 Jun 2012)

Overview

How can I programmatically add contact information with subfields such as "Street (home)"?

Description

My application manages the contact fields by using the vCard UIDs of the respective fields (TFieldType in cntdef.h). Everything works fine, except for the field "Street (home)", which once added, appears to be in the field "Address (home)".
Solution:
Unlike normal fields, "Street (home)" is a subfield of "Address (home)". This needs two levels of vCard mapping for adding the information to the correct field.
Below is a simplified code example for doing this:
//-------------------------------------------------------
CContactDatabase* contactsDb = CContactDatabase::OpenL();
CleanupStack::PushL(contactsDb);
CContactItem* contact = CContactCard::NewLC();
CContactItemFieldSet* fieldset = CContactItemFieldSet::NewLC();
CContactItemField* field =
    CContactItemField::NewLC(KStorageTypeText,
                           KUidContactFieldAddress);     // VCardUID for address field
field->SetMapping(KUidContactFieldVCardMapADR);              // VCardUID for street field type
field->AddFieldTypeL(KUidContactFieldVCardMapHOME);  // VCardUID for home field type
field->TextStorage()->SetTextL(KStreetname);
fieldset->AddL(*field);
contact->UpdateFieldSet(fieldset);
CleanupStack::Pop(2);   // field, fieldset
contactsDb->AddNewContactL(*contact);
CleanupStack::PopAndDestroy(2);    // contact, contactsDb
//-------------------------------------------------------

This page was last modified on 14 June 2012, at 06:35.
16 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×