Namespaces
Variants
Actions

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

Jump to: navigation, search



Article Metadata

Compatibility
Platform(s): S60 1st Edition
S60 2nd Edition and FP1, FP2, and FP3
S60 3rd 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 09:35.
105 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved