本文整理汇总了C++中CContactDatabase::GetSpeedDialFieldL方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactDatabase::GetSpeedDialFieldL方法的具体用法?C++ CContactDatabase::GetSpeedDialFieldL怎么用?C++ CContactDatabase::GetSpeedDialFieldL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactDatabase
的用法示例。
在下文中一共展示了CContactDatabase::GetSpeedDialFieldL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LongNumSpeedDialTestsL
LOCAL_C void LongNumSpeedDialTestsL()
{
_LIT(KLongNumSpeedDialTest, "Long Phone Number Speed Dial Test");
g_test.Start(KLongNumSpeedDialTest);
// create default, empty database
CContactDatabase* db = CContactDatabase::ReplaceL(KLongNumSpeedDialDbName);
CleanupStack::PushL(db);
// create a contact and add it to the db
CContactItem* contact = CContactCard::NewLC();
CContactItemField* fname = CContactItemField::NewLC(KStorageTypeText,
KUidContactFieldGivenName);
_LIT(KFname, "James");
fname->TextStorage()->SetTextL(KFname() );
contact->AddFieldL(*fname);
CleanupStack::Pop(fname);
CContactItemField* phone = CContactItemField::NewLC(KStorageTypeText,
KUidContactFieldPhoneNumber);
_LIT(KPhoneNum, "01234567890123456789012345678901234567890123456789012345678901234567890123456789"); // 80 chars
phone->TextStorage()->SetTextL(KPhoneNum() );
contact->AddFieldL(*phone);
CleanupStack::Pop(phone);
const TContactItemId KContactId = db->AddNewContactL(*contact);
CleanupStack::PopAndDestroy(contact);
contact = NULL;
// retrieve contact and assign its number to speed dial #1
contact = db->OpenContactL(KContactId);
CleanupStack::PushL(contact);
const TInt KSpeedDial1(1);
const TInt KPhoneNumIndex = contact->CardFields().Find(KUidContactFieldPhoneNumber);
db->SetFieldAsSpeedDialL(*contact, KPhoneNumIndex, KSpeedDial1);
TBuf<100> speedDialNumberText;
TContactItemId speedDialId = db->GetSpeedDialFieldL(KSpeedDial1, speedDialNumberText);
_LIT(KOutputFormat, "retrieved speed dial id: %d;\nretrieved speed dial phone number: ...\n%S\n");
g_test.Printf(KOutputFormat, speedDialId, &speedDialNumberText);
db->CloseContactL(KContactId);
// cleanup
CleanupStack::PopAndDestroy(2, db); // and contact
CContactDatabase::DeleteDatabaseL(KLongNumSpeedDialDbName);
// Since PDEF121954, long phone numbers set as speed dial are truncated to
// the length of KSpeedDialPhoneLength. So, we need to get the truncated
// version of the phone number for comparison with the speed dial value.
TPtrC phoneNum(KPhoneNum().Mid(0, KSpeedDialPhoneLength));
g_test(speedDialId == KContactId && speedDialNumberText.CompareC(phoneNum) == 0);
g_test.End();
g_test.Close();
}