Exemple #1
0
bool AVIIndex::makeIndex() {
	if (!allocateIndex(total_ents)) return false;

	put(indexPtr());

	return true;
}
void CSyncTestStep::WriteContactToICCL(TContactICCEntry& aIccEntry, TRequestStatus& aStatus)
/**
 * This method writes the phonebook data passed in the aIccEntry parameter to the ICC.
 */
	{
	CContactDatabase *ContactsDb=NULL;
	TRAPD(err,ContactsDb=CContactDatabase::OpenL());	// First try to open existing database
	if (err != KErrNone)
		{
		TRAP(err,CContactDatabase::CreateL()); // There is no existing database, so create default one
		if (err == KErrNone)
			ContactsDb=CContactDatabase::OpenL();			// Open new database
		}
	CleanupStack::PushL(ContactsDb);
	
	TContactItemId id = ContactsDb->ICCTemplateIdL(); 
	CContactItem* iccTemplate = ContactsDb->ReadContactL(id);
	CleanupStack::PushL(iccTemplate);
	CContactICCEntry* item;
	// If an overwrite is being attempted then ensure an entry with relevant UID is used
	if (aIccEntry.iContactUID > 0)
		{
		TContactItemId realId(GetValidUIDFromContactsDbL());
		item = static_cast<CContactICCEntry*> (ContactsDb->ReadContactL(realId));
		}
	else
		{
		item = CContactICCEntry::NewL(*iccTemplate); // Create an ICC entry
		}
	CleanupStack::PopAndDestroy(iccTemplate);
	CleanupStack::PushL(item);

	// Create phone number field 
	TBuf<RMobilePhone::KMaxMobileTelNumberSize> number;
	if(aIccEntry.iTON==RMobilePhone::EInternationalNumber)
		number.Append(KInternationalPrefix); // Append '+' prefix if International Number
	number.Append(aIccEntry.iNumber);
	AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldPhoneNumber, KUidContactFieldVCardMapTEL, number, item);

	// Create name field
	TBuf<TContactICCEntry::KMaxPhBkNameSize> name;
	name.Copy(aIccEntry.iName);
	AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldFamilyName, KUidContactFieldVCardMapUnusedN, name, item);

	if(aIccEntry.iSlotNum!=KSyncIndexNotSupplied) // it is not a new entry so slot number is supplied
		{
		// Create slot number field
		HBufC* buf = HBufC::NewL(5);
		TPtr indexPtr(buf->Des());
		indexPtr.AppendNum(aIccEntry.iSlotNum);
		TPtrC indexPtrC = indexPtr.Mid(0);
		AddTextFieldToIccContactL(KStorageTypeText, KUidContactFieldICCSlot, KUidContactFieldVCardMapNotRequired, indexPtrC, item);
		delete buf;
		}

	// Send a Write-Contact-ICC request
	TRequestStatus status;
	iSession.WriteContact(status, *item, aIccEntry.iSlotNum); 
	User::WaitForRequest(status);
	aStatus = status;
	CleanupStack::PopAndDestroy(2);	// item and ContactsDb
	}