本文整理汇总了C++中CContactItem::SetId方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactItem::SetId方法的具体用法?C++ CContactItem::SetId怎么用?C++ CContactItem::SetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactItem
的用法示例。
在下文中一共展示了CContactItem::SetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePredSearchTablesL
void CPredictiveSearchSynchronizer::CreatePredSearchTablesL(TBool aAllTables)
{
PRINT1(_L("CPredictiveSearchSynchronizer::CreatePredSearchTablesL all=%d"), aAllTables);
if (aAllTables)
{
i12keyTable.CreateTableL();
iSettingsTable.CreateTableL();
iSettingsTable.StoreCurrentLanguageL();
}
iQwertyTable.CreateTableL();
_LIT(KSelectAllContactsFormat, "SELECT %S,%S,%S FROM %S;");
TInt bufSize = KSelectAllContactsFormat().Length() +
KContactId().Length() +
KContactFirstName().Length() +
KContactLastName().Length() +
KSqlContactTableName().Length();
HBufC* sqlStatement = HBufC::NewLC(bufSize);
sqlStatement->Des().AppendFormat(KSelectAllContactsFormat,
&KContactId,
&KContactFirstName,
&KContactLastName,
&KSqlContactTableName);
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
PRINT1(_L("CreatePredSearchTablesL prepare SQL statement:%S"), sqlStatement);
stmnt.PrepareL(iDatabase, *sqlStatement);
const TInt KContactIdIndex = 0;
const TInt KFirstNameIndex = 1;
const TInt KLastNameIndex = 2;
TInt err(KErrNone);
while ((err = stmnt.Next()) == KSqlAtRow)
{
PRINT(_L("CreatePredSearchTablesL create CContactItem"));
TInt id = KUidContactCardValue;
TUid uid;
uid.iUid = id;
CContactItem* contact = CContactItem::NewLC(uid);
contact->SetId(stmnt.ColumnInt(KContactIdIndex));
// If first name exists, write it to contact item
TPtrC firstName;
if (stmnt.ColumnText(KFirstNameIndex, firstName) == KErrNone)
{
CContactItemField* field =
CContactItemField::NewLC(KStorageTypeText, KUidContactFieldGivenName);
CContactTextField* textfield = field->TextStorage();
textfield->SetTextL(firstName);
contact->AddFieldL(*field); // Takes ownership
CleanupStack::Pop(field);
}
TPtrC lastName;
if (stmnt.ColumnText(KLastNameIndex, lastName) == KErrNone)
{
CContactItemField* field =
CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
CContactTextField* textfield = field->TextStorage();
textfield->SetTextL(lastName);
contact->AddFieldL(*field); // Takes ownership
CleanupStack::Pop(field);
}
PRINT(_L("CreatePredSearchTablesL create entry to tables"));
if (aAllTables)
{
i12keyTable.CreateInDbL(*contact);
}
if (ReadMailAddressesL(*contact))
{
iQwertyTable.CreateInDbL(*contact);
}
CleanupStack::PopAndDestroy(contact);
}
// Leave if we didn't complete going through the results properly
if (err != KSqlAtEnd)
{
PRINT1(_L("CreatePredSearchTablesL SQL err=%d"), err);
User::Leave(err);
}
CleanupStack::PopAndDestroy(&stmnt);
CleanupStack::PopAndDestroy(sqlStatement);
PRINT(_L("CPredictiveSearchSynchronizer::CreatePredSearchTablesL ends"));
}
示例2: Next
/**
Reads the contact item from the database using the given contact item ID.
@param aItemId The Id number of the contact to be read.
@param aView Specifies the fields to be read.
@param aInfoToRead not used
@param aSessionId The ID of the session that issued the request. This is used
to prevent Phonebook Synchroniser deadlock.
@param aIccOpenCheck Specifies if validation with the Phonebook Synchroniser is
needed for this contact.
@leave KErrArgument if the itemID can't be set within select statement
@leave KErrNotFound if a contact item with aItemId does not exist within contact database
@leave KSqlErrBusy the database file is locked; thrown if RSqlStatement::Next()
returns this error
@leave KErrNoMemory an out of memory condition has occurred - the statement
will be reset;thrown if RSqlStatement::Next() returns this error
@leave KSqlErrGeneral a run-time error has occured - this function must not
be called again;thrown if RSqlStatement::Next() returns this error
@leave KSqlErrMisuse this function has been called after a previous call
returned KSqlAtEnd or KSqlErrGeneral.thrown if RSqlStatement::Next()
returns this error
@leave KSqlErrStmtExpired the SQL statement has expired (if new functions or
collating sequences have been registered or if an
authorizer function has been added or changed);
thrown if RSqlStatement::Next() returns this error
@return CContactItem created from reading the database tables.
*/
CContactItem* CPplContactItemManager::ReadLC(TContactItemId aItemId, const CContactItemViewDef& aView, TInt aInfoToRead, TUint aSessionId, TBool aIccOpenCheck) const
{
CContactTemplate* sysTemplate = NULL;
if (aItemId != KGoldenTemplateId)
{
sysTemplate = const_cast<CContactTemplate*>(&iContactProperties.SystemTemplateL());
}
RSqlStatement selectStmt;
CleanupClosePushL(selectStmt);
User::LeaveIfError(selectStmt.Prepare(iDatabase, iSelectStatement->SqlStringL()));
TInt err = selectStmt.BindInt(KFirstParam, aItemId);
if(err != KErrNone)
{
User::Leave(KErrArgument);
}
CContactItem* item = NULL;
TUid type(KNullUid);
if((err = selectStmt.Next()) == KSqlAtRow)
{
TInt contactId = selectStmt.ColumnInt(iSelectStatement->ParameterIndex(KContactId));
TInt templateId = selectStmt.ColumnInt(iSelectStatement->ParameterIndex(KContactTemplateId));
TInt typeFlags = selectStmt.ColumnInt(iSelectStatement->ParameterIndex(KContactTypeFlags));
type = TCntPersistenceUtility::TypeFlagsToContactTypeUid(typeFlags);
item = CContactItem::NewLC(type);
item->SetId(contactId);
TPtrC guid = selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactGuidString));
item->SetUidStringL(guid);
TInt attr = (typeFlags & EContactAttributes_Mask) >> EContactAttributes_Shift;
item->SetAttributes(attr);
item->SetTemplateRefId(templateId);
item->SetLastModified(TTime(selectStmt.ColumnInt64(iSelectStatement->ParameterIndex(KContactLastModified))));
item->SetCreationDate(TTime(selectStmt.ColumnInt64(iSelectStatement->ParameterIndex(KContactCreationDate))));
item->SetAccessCount(selectStmt.ColumnInt(iSelectStatement->ParameterIndex(KContactAccessCount)));
RArray<TPtrC> fastAccessFields;
CleanupClosePushL(fastAccessFields);
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactFirstName)));
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactLastName)));
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactCompanyName)));
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactFirstNamePrn)));
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactLastNamePrn)));
fastAccessFields.AppendL(selectStmt.ColumnTextL(iSelectStatement->ParameterIndex(KContactCompanyNamePrn)));
//set first name, last name, company name, first name pronunciation, last name pronunciation, company name pronunciation
for (TInt fieldNum = item->CardFields().Count() - 1; fieldNum>=0; --fieldNum)
{
CContactItemField& textField = (item->CardFields())[fieldNum];
const TInt nameFieldIndex = NameFieldIndex(textField);
// Check if field is first name, last name, company name,
// first name pronunciation, last name pronunciation, company name pronunciation.
if (nameFieldIndex != KErrNotFound)
{
HBufC* text = HBufC::NewLC(fastAccessFields[nameFieldIndex].Size());
text->Des() = fastAccessFields[nameFieldIndex];
textField.TextStorage()->SetText(text);
CleanupStack::PopAndDestroy(text);
}
}
CleanupStack::PopAndDestroy(&fastAccessFields);
}