コード例 #1
0
// ---------------------------------------------------------------------------
// CAtPhbkStoreRead::GeneratePhbkData
// other items were commented in a header
// ---------------------------------------------------------------------------
TInt CAtPhbkStoreRead::GeneratePhbkDataL()
	{
	CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer(); // used to write phonebook data
	iPhbkData.Zero();
	pbBuffer->Set(&iPhbkData); // Set it to point to the Client buffer
	pbBuffer->AddNewEntryTag();
	
	TInt ret = pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBAdnIndex,iReadEntry.iIndex);
	if( ret!=KErrNone )
		{
		delete pbBuffer;
		return ret;
		}
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, iReadEntry.iNumber);
	if( ret!=KErrNone )
		{
		delete pbBuffer;
		return ret;
		}
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, iReadEntry.iTon);
	if(ret!=KErrNone)
		{
		delete pbBuffer;
		return ret;
		}
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, iReadEntry.iText);
	if(ret != KErrNone)
		{
		delete pbBuffer;
		return ret;
		}
	
	delete pbBuffer;
	return KErrNone;
	}
コード例 #2
0
void CTestLtsyPhbkWrite::WriteEntryL(TInt aIndex)
	{
	TRequestStatus status;
	TBuf8<800> pbData; // Client reserved space for phonebook data
	TInt ret;
	    
	_LIT16(KTel,"123456%03d");
	_LIT16(KText,"TelNo %03d");
	TBuf16<20> text(KTel), number(KText);

	CPhoneBookBuffer* pbBuffer = new(ELeave) CPhoneBookBuffer(); // used to write phonebook data
	CleanupStack::PushL(pbBuffer);
	pbBuffer->Set(&pbData); // Set it to point to the Client buffer
	pbBuffer->AddNewEntryTag();
	// convert number into TLV format and append it to allocated buffer
	TInt index = aIndex;
	ret = pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBAdnIndex,(TUint16)index);
	if( ret != KErrNone )
		{
		CleanupStack::PopAndDestroy();
		SetTestStepResult(EFail);
		}
	number.Format(KTel(), index);
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNumber, number);
//	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBNewEntry, number);
	if( ret != KErrNone )
		{
		CleanupStack::PopAndDestroy();
		SetTestStepResult(EFail);
		}
	// convert number type into TLV format and append it to allocated buffer
	TUint8 tonNpi=KTypeOfNumber; 
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBTonNpi, tonNpi);
	if(ret!=KErrNone)
		{
		CleanupStack::PopAndDestroy();
		SetTestStepResult(EFail);
		}

	text.Format(KText(), index);
// convert text into TLV format and append it to allocated buffer
	ret=pbBuffer->PutTagAndValue(RMobilePhoneBookStore::ETagPBText, text);
	if(ret != KErrNone)
		{
		CleanupStack::PopAndDestroy();
		SetTestStepResult(EFail);
		}
	PhoneBookStore().Write(status, pbData,index);
	User::WaitForRequest(status);
	TInt r=status.Int();
	INFO_PRINTF2(_L("Write() request status = %d"),r);
	CleanupStack::PopAndDestroy();
	}