Exemple #1
0
void CReqCreateCnt::ConstructL(CCntPackager& aPackager)
	{
	aPackager.SetBufferFromMessageL(iMessage);
	iCntItem = aPackager.UnpackCntItemLC();
	CleanupStack::Pop(iCntItem);
	}
void CPackagerTests::ContactItemTestL()
	{
	CCntPackager* thePackage = CCntPackager::NewL();
	CleanupStack::PushL(thePackage);
	
	test.Next(_L("ContactItemTestL"));


	iCntTestImpl.CreateDatabaseL(nsCntTestImpl::KSecureDBName, ETrue);

	const CContactTemplate& goldenTemplate = iCntTestImpl.GetSysTemplate();
	//iTempl = iCntTestImpl.GetSysTemplate();

#ifdef __T_PACKAGER_DUMP_CONTACT__
	TESTTRAP(iCntTestImpl.DumpContactL(goldenTemplate, _L("Template")));
#endif

	CContactItem* card = CContactCard::NewLC(&goldenTemplate);
	TCnt theCnt(card);

	theCnt[KUidContactFieldGivenName] = _L("David");
	theCnt[KUidContactFieldFamilyName] = _L("Coulthard");

	theCnt[KUidContactFieldPhoneNumber] & KHome & KVoice & KCell = _L("mo1 39849342");
	theCnt[KUidContactFieldPhoneNumber] & KHome & KVoice & KCell += _L("mo2 34530903495803948503984545");

	theCnt[KUidContactFieldEMail] & KHome = _L("home@email");
	theCnt[KUidContactFieldAddress] & KHome = _L("Home addresssssss");
	theCnt[KUidContactFieldLocality] & KHome = _L("Glazgo");
	theCnt[KUidContactFieldIMAddress] & KHome & KWv = _L("wireless@village");
	theCnt[KUidContactFieldSecondName] = _L("Second name");

	theCnt[KUidContactFieldCompanyName] = _L("McLaren");
	theCnt[KUidContactFieldJobTitle]	= _L("Driver");
	theCnt[KUidContactFieldPhoneNumber] & KWork & KVoice = _L("work Tel 2342");

	theCnt[KUidContactFieldEMail] & KWork = _L("work@email");
	theCnt[KUidContactFieldUrl] & KWork = _L("sdfsd");
	theCnt[KUidContactFieldAddress] & KWork = _L("afas df asd");
	theCnt[KUidContactFieldLocality] & KWork = _L("sdfsd");

	theCnt[KUidContactFieldCustom1] = _L("Filterable 1");
	theCnt[KUidContactFieldCustom2] = _L("Filterable 2");

	theCnt[KUidContactFieldGivenNamePronunciation] = _L("first name re");
	theCnt[KUidContactFieldFamilyNamePronunciation] = _L("Last name re");
	
	theCnt[KUidContactFieldSIPID] & KPoc  = _L("SIP POC");
	theCnt[KUidContactFieldSIPID] & KSwis = _L("SIP SWIS");
	theCnt[KUidContactFieldSIPID] & KVoip = _L("SIP VOIP");

#ifdef __T_PACKAGER_DUMP_CONTACT__
	TESTTRAP(iCntTestImpl.DumpContactL(*card, _L("Before Creation")));
#endif

	iCntTestImpl.CreateL(*card);	
	
	// For now, call this to allocate memory for buffer in packager.
	TPtrC8 theBuffer = thePackage->GetTransmittingBuffer();
	
	TInt err  = KErrNoMemory;
	while(err==KErrNoMemory)
	{
		
		TRAPD(error, (theBuffer.Set(thePackage->PackL(*card))));
		err = error;
		if(error==KErrNoMemory)
			{
			thePackage->GetTransmittingBuffer();
			
			}
	}
	
	CContactItem* cntItem = thePackage->UnpackCntItemLC();
//	CleanupStack::PushL(cntItem);
	err = CompareContactItemTestL(cntItem, card);
	User::LeaveIfError(err);
	CleanupStack::PopAndDestroy(3, thePackage);
//	POPD(cntItem);
//	POPD(card);
//	POPD(thePackage);

	
	}