Exemple #1
0
EXPORT_C void RDecryptStream::AttachLC(RReadStream& aHost,const CPBEncryptionBase& aKey)
/**
Attach a decrypting read stream to aHost.
Takes ownership of the source stream owned by the specified read stream interface object, 
prepares the stream for reading through a decrypting filter, and puts a cleanup item onto the cleanup stack.
@publishedPartner
@leave KErrNoMemory
@param aHost The read stream interface object for the source stream.
@param aKey A Password Based Encryption object for encryption handling.
*/	{
	MStreamBuf* host=aHost.Source();
	aHost=RReadStream();
	RReadStream::Attach(host);		// initial cleanup via this
	PushL();

	CPBDecryptor* decryptor = aKey.NewDecryptLC();
	iFilter.SetL(host,decryptor,iFilter.ERead|iFilter.EAttached);
	CleanupStack::Pop(decryptor);
	
	RReadStream::Attach(&iFilter);
	}
Exemple #2
0
void CVersitTest::StreamLC(RReadStream& aStream)
	{
	GetSampleVersitL();
	RFs fsSession; 
	User::LeaveIfError(fsSession.Connect());
	CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersitIn"),EFileWrite);
	store->SetTypeL(KDirectFileStoreLayoutUid);
	RStoreWriteStream outstream;
	TStreamId id = outstream.CreateLC(*store);
	TInt length=iVersit.Length();
	for (TInt ii=0; ii<length; ii++)
		outstream.WriteInt8L(iVersit[ii]);
	outstream.CommitL();
	CleanupStack::PopAndDestroy();
	store->SetRootL(id);
	store->CommitL();
 	CleanupStack::PopAndDestroy();	// store
	store = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersitIn"),EFileRead); //retrieve stream
	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());
	CleanupStack::Pop();	// instream
	aStream=RReadStream(instream);
	}
Exemple #3
0
void CVersitTest::Stream2LC(RReadStream& aStream)
	{
	GetSampleVersit2L();
	RFile file;
	FileRegister->CreateTempFileLC(file, _L("ExpDelVersitIn2"));
	CDirectFileStore* store	= CDirectFileStore::NewLC(file);
	store->SetTypeL(KDirectFileStoreLayoutUid);
	RStoreWriteStream outstream;
	TStreamId id = outstream.CreateLC(*store);
	TInt length=iVersit.Length();
	for (TInt ii=0; ii<length; ii++)
		outstream.WriteInt8L(iVersit[ii]);
	outstream.CommitL();
	CleanupStack::PopAndDestroy();
	store->SetRootL(id);
	store->CommitL();
 	CleanupStack::PopAndDestroy();	// store
	FileRegister->OpenTempFileLC(file, _L("ExpDelVersitIn2"));
	store = CDirectFileStore::NewLC(file);
	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());
	CleanupStack::Pop();	// instream
	aStream=RReadStream(instream);
	}
Exemple #4
0
LOCAL_C void DoTestsL()
	{
	// create test database
	test.Start(_L("@SYMTESTCaseID:PIM-T-TTVERS-0001 Preparing tests"));

	User::LeaveIfError(TheFs.Connect());
	CleanupClosePushL(TheFs);
	CTestRegister * TempFiles = CTestRegister::NewLC();
	TempFiles->RegisterL(KDatabaseFileName, EFileTypeCnt);
	TempFiles->RegisterL(_L("C:\\ttversitin"));
	TempFiles->RegisterL(_L("C:\\ttversitin2"));
	TempFiles->RegisterL(_L("C:\\ttversitin3"));
	TempFiles->RegisterL(_L("C:\\ttversitout"));
	TempFiles->RegisterL(_L("C:\\ttversitout.vcf"));
	TempFiles->RegisterL(_L("C:\\ttversitoutb.vcf"));

	TheIds=CContactIdArray::NewLC();
	TRAPD(err, CContactDatabase::DeleteDatabaseL(KDatabaseFileName));
	if ((err != KErrNone) && (err != KErrNotFound))
		{
		User::Leave(err);
		}
	
	CVersitTest* vtest=NULL;
		
	if (vtest)
		CleanupStack::PopAndDestroy(); //vtest;
	vtest=new(ELeave)CVCardTest;
	CleanupStack::PushL(vtest);
	CVersitTest* vtest2=NULL;
	vtest2=new(ELeave)CVCardTest;
	CleanupStack::PushL(vtest2);
	CVersitTest* vtest3=NULL;
	vtest3=new(ELeave)CVCardTest;
	CleanupStack::PushL(vtest3);
	//Import
	test.Next(_L("Importing vcard"));

	CContactDatabase* db=CntTest->CreateDatabaseL();
	CntTest->Db()->OverrideMachineUniqueId(0); //testcode assumes machineUID is 0
	TBool success;
	TUid vcardmode;
	vcardmode.iUid=KUidVCardConvDefaultImpl;
	RReadStream stream;
	vtest->StreamLC(stream);
	stream.PushL();
	TheItems=db->ImportContactsL(vcardmode,stream,success,CContactDatabase::EIncludeX);
	test(success);
	CleanupStack::PopAndDestroy(2);	// stream,store
	test(db->CountL()==1);
	test(TheItems->Count()==1);
	test((*TheItems)[0]->UidStringL(0x0)==_L("AAA"));
	//Export
	test.Next(_L("Exporting vcard"));

	CFileStore* store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileWrite);
	store->SetTypeL(KDirectFileStoreLayoutUid);
	RStoreWriteStream outstream;
	TStreamId id = outstream.CreateLC(*store);
	TUid uid;
	uid.iUid=KUidVCardConvDefaultImpl;
	TInt itemCount=TheItems->Count();
	for (TInt ii=0;ii<itemCount;ii++)
		TheIds->AddL((*TheItems)[ii]->Id());
	db->ExportSelectedContactsL(uid,*TheIds,outstream,CContactDatabase::ETTFormat);
	outstream.CommitL();
	store->SetRootL(id);
	store->CommitL();  	
	CleanupStack::PopAndDestroy(2); // store+ oustream
	// check there are no X-EPOC
	CFileStore* store2 = CDirectFileStore::OpenLC(TheFs,_L("c:\\ttVersitout.vcf"),EFileRead); //retrieve stream
	RStoreReadStream tinstream;
	tinstream.OpenLC(*store2,id);
	RReadStream xstream=RReadStream(tinstream);
	HBufC* xdes=HBufC::NewLC(99);
	TPtr ptr(xdes->Des());
	xstream.ReadL(ptr);
    test(xdes->Des().Match(_L("*X-*"))==KErrNotFound);
	CleanupStack::PopAndDestroy(3); // store2+ instream
	//DisplayDatabase(db);
	test.Next(_L("Updating vcard 2"));

	RReadStream stream2;
	vtest2->Stream2LC(stream2);
	stream2.PushL();
	TheItems2=db->ImportContactsL(vcardmode,stream2,success,CContactDatabase::ETTFormat);
	test(success);
	CleanupStack::PopAndDestroy(2);	// stream,store
	test(db->CountL()==1);
	//Export again
	//DisplayDatabase(db);
	test.Next(_L("Exporting vcard"));

	TheIds->Reset();
	TheIds->AddL(1);
	store = CDirectFileStore::ReplaceLC(TheFs,_L("c:\\ttVersitoutb.vcf"),EFileWrite);
	store->SetTypeL(KDirectFileStoreLayoutUid);
	id = outstream.CreateLC(*store);
	uid.iUid=KUidVCardConvDefaultImpl;
	itemCount=TheItems->Count();
	db->ExportSelectedContactsL(uid,*TheIds,outstream,CContactDatabase::ETTFormat);
	outstream.CommitL();
	store->SetRootL(id);
	store->CommitL();  	
	CleanupStack::PopAndDestroy(2); // store+ oustream
/**
@SYMTestCaseID     PIM-T-TTVERS-0002
@SYMTestType UT
@SYMTestPriority High
@SYMDEF INC056117
@SYMTestCaseDesc To verify that the incorrect behaviour described in INC056117
no longer exists.
@SYMTestActions A vCard is imported where the N, ADR;WORK, EMAIL;INTERNET,
TITLE, ORG, NOTE, URL, ROLE and FN property values all have > 255 characters.
@SYMTestExpectedResults The vCard is correctly imported i.e. properties which
map to text fields with maximum of 255 characters are truncated and no overflow
occurs in the DBMS component (leading to a panic in the test case).  Further
sanity checks are made to ensure that the contacts database contains the
expected number of contacts (2), that the number of CContactItem objects in
TheItems3 is as expected (1) and that the UID string for the CContactItem
object in TheItems3 is as expected ("BBB").
*/
	test.Next(_L("@SYMTESTCaseID:PIM-T-TTVERS-0002 Import vCard with property values > 255 characters"));

	RReadStream stream3;
	vtest3->Stream3LC(stream3);
	stream3.PushL();
	TheItems3=db->ImportContactsL(vcardmode,stream3,success,CContactDatabase::EIncludeX);
	test(success);
	CleanupStack::PopAndDestroy(2);	// stream3,store
	test(db->CountL()==2);
	test(TheItems3->Count()==1);
	test((*TheItems3)[0]->UidStringL(0x0)==_L("BBB"));

	if (TheItems)
		TheItems->ResetAndDestroy();
	delete TheItems;
	if (TheItems2)
		TheItems2->ResetAndDestroy();
	delete TheItems2;
	if (TheItems3)
		TheItems3->ResetAndDestroy();
	delete TheItems3;
	
	CleanupStack::PopAndDestroy(4); // TheIds, vtest, vtest2, vtest3
//
	ExportImportTestL();
//
	CntTest->CloseDatabase();
	User::After(1000000);
	CntTest->DeleteDatabaseL();
	CleanupStack::PopAndDestroy(2); // FS, TempFiles
	}