WEB开发网
开发学院手机开发Symbian 开发 Symbian OS通讯录模型 阅读

Symbian OS通讯录模型

 2010-08-11 12:18:00 来源:WEB开发网   
核心提示:_LIT(KForename,"Steve");_LIT(KSurname,"Wilkinson");_LIT(KWorkPhone,"+441617779700");CContactDatabase* contactDb = CContactDatabase

_LIT(KForename,"Steve");

_LIT(KSurname,"Wilkinson");

_LIT(KWorkPhone,"+441617779700");

CContactDatabase* contactDb = CContactDatabase::OpenL();

CleanupStack::PushL(contactDb);

CContactItem* contact = CContactCard::NewLC();

CContactItemField* field = CContactItemField::NewLC(

KStorageTypeText, KUidContactFieldFamilyName);

field->SetMapping(KUidContactFieldVCardMapUnusedN);

field->SetLabelL(KSurnameLabel);

field->TextStorage()->SetTextL(KSurname);

contact->AddFieldL(*field);

CleanupStack::Pop();

field = CContactItemField::NewLC(KStorageTypeText,

KUidContactFieldGivenName);

field->SetMapping(KUidContactFieldVCardMapUnusedN);

field->SetLabelL(KForenameLabel);

field->TextStorage()->SetTextL(KForename);

contact->AddFieldL(*field);

CleanupStack::Pop();

field = CContactItemField::NewLC(KStorageTypeText,

KUidContactFieldPhoneNumber);

field->SetMapping(KUidContactFieldVCardMapTEL);

field->SetLabelL(KWorkPhoneLabel);

field->TextStorage()->SetTextL(KWorkPhone);

contact->AddFieldL(*field);

CleanupStack::Pop();

contactDb->AddNewContactL(*contact);

contactDb->SetOwnCardL(*contact);

CleanupStack::PopAndDestroy(2);

例5 查找并更新通讯录条目

这个例子比较复杂,涉及的查找函数为FindAsyncL,该类函数实例有:

CContactIdArray * CContactDatabase::FindLC(const TDesC &aText, const CContactItemFieldDef *aFieldDef);

CIdleFinder * CContactDatabase::FindAsyncL(const TDesC &aText, const CContactItemFieldDef *aFieldDef, MIdleFindObserver *aObserver);

还有对应的FindInTextDefLC()和FindInTextDefAsyncL()各两组,具体参见sdk。

CContactDatabase* iContactsDb = CContactDatabase::OpenL();

上一页  1 2 3 4  下一页

Tags:Symbian OS 通讯录

编辑录入:coldstar [复制链接] [打 印]
赞助商链接