예제 #1
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1196
@SYMTestCaseDesc	    Writing to a write once file store created using CEmbeddedStore test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for writing to a newly created store and a temporary store.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1196 Replacing host file "));
	TParsePtrC parse(KFileLocationSpec);
	
	CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	file->SetTypeL(file->Layout());
//
	test.Next(_L("Writing root store"));
	RStoreWriteStream stream;
	TStreamId root=stream.CreateLC(*file);
	stream.WriteL(_L8(" root"));
	CleanupStack::Pop();
	CEmbeddedStore* store=CEmbeddedStore::NewL(stream);
	CleanupStack::PushL(store);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	file->SetRootL(root);
//
	test.Next(_L("Writing temp store"));
	TheTempId=stream.CreateLC(*file);
	stream.WriteL(_L8(" temp"));
	CleanupStack::Pop();
	store=CEmbeddedStore::NewLC(stream);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	file->CommitL();
	CleanupStack::PopAndDestroy();
	}
void CCreateFileCertStore::CreateStoreL(const TDesC& aFileName, RFs& aFs)
	{
	aFs.MkDirAll(aFileName);
	RFile file;
	User::LeaveIfError(file.Replace(aFs, aFileName, EFileWrite));

	//TCleanupItem deleteFile(CFileCertStore::DeleteFile, this);//store will revert() if a leave occurs
	//CleanupStack::PushL(deleteFile);

	CPermanentFileStore* store = CPermanentFileStore::NewLC(file);
	store->SetTypeL(KPermanentFileStoreLayoutUid);	

	RStoreWriteStream caCertEntryStream;
	TStreamId caCertEntryStreamId = caCertEntryStream.CreateLC(*store);
	caCertEntryStream.WriteInt32L(0);//we have zero ca certs
	caCertEntryStream.CommitL();
	CleanupStack::PopAndDestroy();

	RStoreWriteStream rootStream;
	TStreamId rootId = rootStream.CreateLC(*store);

	rootStream << caCertEntryStreamId;
	rootStream.CommitL();
	CleanupStack::PopAndDestroy();
	
	store->SetRootL(rootId);							
	store->CommitL();							
	CleanupStack::PopAndDestroy();//store
	}
예제 #3
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1128
@SYMTestCaseDesc	    Tests for writing to a store
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for writing to a root store and empty store.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1128 Replacing host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	file->SetTypeL(file->Layout());
//
	test.Next(_L("Writing root store"));
	RStoreWriteStream stream;
	TStreamId embed=stream.CreateL(*file);
	CEmbeddedStore* store=CEmbeddedStore::NewLC(stream);

	CSecureStore* secure=CSecureStore::NewLC(*store, *thePBEKey);

	store->SetRootL(testWriteL(*secure));
	CleanupStack::PopAndDestroy(secure);
	store->CommitL();
	CleanupStack::PopAndDestroy();

	__UHEAP_MARK;
	TStreamId root=stream.CreateLC(*file);
	REncryptStream encrypt;
	encrypt.AttachLC(stream,*thePBEKey);

	encrypt<<_L8(" root")<<embed;
	encrypt.CommitL();
	CleanupStack::PopAndDestroy(2);
	__UHEAP_MARKEND;

	file->SetRootL(root);
//
	test.Next(_L("Writing temp store"));
	embed=stream.CreateL(*file);
	store=CEmbeddedStore::NewLC(stream);
	secure = CSecureStore::NewLC(*store, *thePBEKey);

	store->SetRootL(testWriteL(*secure));
	CleanupStack::PopAndDestroy(secure);
	store->CommitL();
	CleanupStack::PopAndDestroy();

	__UHEAP_MARK;
	TheTempId=stream.CreateLC(*file);
	encrypt.OpenLC(stream,*thePBEKey);

	encrypt<<_L8(" temp")<<embed;
	encrypt.CommitL();
	CleanupStack::PopAndDestroy();
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	__UHEAP_MARKEND;
//
	file->CommitL();
	CleanupStack::PopAndDestroy(file);
	}
예제 #4
0
EXPORT_C TStreamId CApaModelDoor::StoreL(CStreamStore& aTargetStore)const
/** Stores the model data in the specified store as an embedded store.

The function stores the model data, if the model exists in memory, otherwise, 
it simply copies the stream containing the embedded document into the specified 
store.

@param aStore The store in which the model data is to be stored.
@return The stream ID of the head stream for the embedded model data. This 
stream contains the stream dictionary through which the embedded data and 
its door can be restored. */
	{
	// create stream dictionary
	CStreamDictionary* streamDic = CStreamDictionary::NewLC();
	//
	// stream out door's state
	ExternalizeBaseStreamL(aTargetStore,*streamDic);
	//
	// store the model 
	TStreamId id;
	RStoreWriteStream stream;
	if (iModelHeader)
		{
		// create an embedded store in a new write stream
		id = stream.CreateL(aTargetStore);
		CEmbeddedStore* target=CEmbeddedStore::NewLC(stream); // takes ownership of stream
		streamDic->AssignL(KUidApaDoorDocStream,id);
		// store the model
		CStreamDictionary* rootDict=CStreamDictionary::NewLC();
		iModelHeader->StoreL(*target,*rootDict);
		CApaProcess::WriteRootStreamL(*target,*rootDict,iModelHeader->AppId());
		CleanupStack::PopAndDestroy(); // rootDict
		// close the new embedded store
		target->CommitL();
		CleanupStack::PopAndDestroy(); // target
		}
	else if (iStore)
		{
		RStoreWriteStream trg;
		id = trg.CreateLC(aTargetStore);
		CopyStoreL(*iStore,trg);
		CleanupStack::PopAndDestroy(); // trg
		streamDic->AssignL(KUidApaDoorDocStream,id);
		}
	else 
		Panic(EPanicNoModelHeaderWhenStoring); // impossible situation
	//
	// store the stream dictionary and return its stream id
	id = stream.CreateLC(aTargetStore);
	stream<< *streamDic;
	stream.CommitL();
	CleanupStack::PopAndDestroy(2); // stream,streamDic
	return id;
	}
예제 #5
0
/**
 * Externalize the contents of the Alarm Server backup
 * to the backup file.
 */
void CASSrvAlarmStore::ExternalizeL()
	{
	TStreamId streamId;
	RStoreWriteStream stream;
	CStreamDictionary* dictionary = CStreamDictionary::NewLC();

	CDirectFileStore* store = OpenStoreLC(EFileWrite | EFileShareExclusive);

	// Create the alarm queue stream & externalize
	streamId = stream.CreateLC(*store);
	stream << ServerWideData().Queue();
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	dictionary->AssignL(KAlarmStoreStreamUidQueue, streamId);

	// Create the alarm data queue & externalize
	streamId = stream.CreateLC(*store);
	stream << ServerWideData().DataPool();
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	dictionary->AssignL(KAlarmStoreStreamUidData, streamId);

	// Create the alarm data queue & externalize
	streamId = stream.CreateLC(*store);
	stream << ServerWideData().SoundSettings();
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	dictionary->AssignL(KAlarmStoreStreamUidSoundSettings, streamId);

#ifdef SYMBIAN_SKIPPED_CALENDAR_ALARMS
	// Create the missed alarm data stream & externalize
	streamId = stream.CreateLC(*store);
	ServerWideData().Queue().ExternalizeLastAlarmedInstanceParamsL(stream);
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	dictionary->AssignL(KAlarmStoreStreamUidEnvironmentChangeData, streamId);	
#endif
	
	// Create root stream
	streamId = stream.CreateLC(*store);
	stream << *dictionary;
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	store->SetRootL(streamId);
	store->CommitL();

	// clear Externalize request flag now, so another can be requested
	iFlags.Clear(ERequestExternalize);

	// Tidy up
	CleanupStack::PopAndDestroy(2, dictionary);
	}
예제 #6
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1131
@SYMTestCaseDesc	    Writing and reading back a long stream test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt to write long data to a stream and read back and test for the integrity of the data.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testBugL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1131 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CDirectFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	file->SetTypeL(file->Layout());
	CSecureStore* secure=NULL;

		secure=CSecureStore::NewLC(*file,*thePBEKey);

	test.Next(_L("Writing long stream"));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(*secure);
	TInt ii;
	for (ii=0;ii<400;++ii)
		out<<_L("a goodly length of data");
	out.CommitL();
	CleanupStack::PopAndDestroy();
	file->SetRootL(out.CreateLC(*secure));
	out<<_L("spam")<<id;
	out.CommitL();
	CleanupStack::PopAndDestroy(2, secure);
	file->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Opening host file"));
	file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead);
	secure=CSecureStore::NewLC(*file,*thePBEKey);
//
	TBuf<30> buf;
	test.Next(_L("Reading"));
	RStoreReadStream in;
	in.OpenLC(*secure,file->Root());
	in>>buf>>id;
	CleanupStack::PopAndDestroy();
	test(buf==_L("spam"));
	in.OpenLC(*secure,id);
	for (ii=0;ii<400;++ii)
		{
		in>>buf;
		test (buf==_L("a goodly length of data"));
		}
	CleanupStack::PopAndDestroy(3);
	}
예제 #7
0
void CCreGenerator::CommitChangesToCreL(RFs& aFs,TUint8 aPersistVersion,CHeapRepository& aRep,const TDesC& aTargetFilePath)
{
    HBufC* tmpFilePath=aTargetFilePath.AllocLC();
    TPtr tmpFilePathPtr(tmpFilePath->Des());
    tmpFilePathPtr.Replace(tmpFilePath->Length()-3,3,KTmpExtension());

    CDirectFileStore* store = CDirectFileStore::ReplaceLC(aFs, *tmpFilePath,(EFileWrite | EFileShareExclusive));

    const TUid uid2	 = KNullUid ;
    store->SetTypeL(TUidType(KDirectFileStoreLayoutUid, uid2, KServerUid3)) ;

    // Write the stream index/dictionary as root stream within the store
    // so we can access it when we do a restore later on
    RStoreWriteStream rootStream ;
    TStreamId rootStreamId = rootStream.CreateLC(*store) ;
    ExternalizeCre(aPersistVersion,aRep, rootStream) ;
    rootStream.CommitL() ;

    CleanupStack::PopAndDestroy(&rootStream) ;
    store->SetRootL(rootStreamId);
    store->CommitL();
    CleanupStack::PopAndDestroy(store) ;
    User::LeaveIfError(aFs.Replace(*tmpFilePath,aTargetFilePath));
    CleanupStack::PopAndDestroy();
}
예제 #8
0
void  CSettingsManager::WriteVideoDataL( CMVSConfigVideoFormatDialog* aVideoFormatDlg,
						 				const TUid& aUid)
	{
	TStreamId controllerId;		
	RStoreWriteStream outstream;
	TBool existingController = IsControllerAvailableL(aUid,controllerId);
	OpenStore2WriteLC();	
	if(!existingController)
		{
		//if controller settings is not available create new stream
		controllerId = outstream.CreateLC(*iStore);		
		}
	else //open the existing for updation
		{
		outstream.ReplaceLC(*iStore,controllerId); 				
		}
	aVideoFormatDlg->ExternalizeL(outstream);
	outstream.CommitL();
	CleanupStack::PopAndDestroy();
	
    /*
    if there is no updation for controller i.e. new controller settings 
    is entered
    */
	if(!existingController)
		{
		outstream.ReplaceLC(*iStore,iRootId); 					
		WriteIndexL(outstream,aUid,controllerId);
		CleanupStack::PopAndDestroy();		
		}
	iStore->CommitL();
	CleanupStack::PopAndDestroy(); //for iStore	
	}
예제 #9
0
LOCAL_C void StoreRestoreTestL()
	{
	CStreamStore* blobstore=CBufStore::NewLC(3);
	CStreamStore* textstore=CBufStore::NewLC(3);
	CStreamStore* store=CBufStore::NewLC(3);
	RStoreWriteStream stream;
	TStreamId textId=stream.CreateLC(*textstore);
//
	CContactItemFieldSet* fieldSet=CContactItemFieldSet::NewLC();
	AddFieldL(fieldSet,KStorageTypeText,KUidContactFieldCompanyName,KUidContactFieldVCardMapORG);
	AddFieldL(fieldSet,KStorageTypeText,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL);
	AddFieldL(fieldSet,KStorageTypeDateTime,KUidContactFieldBirthday,KUidContactFieldVCardMapBDAY);
//
	TStreamId streamId=fieldSet->StoreL(*store,stream,*blobstore);
	CleanupStack::PopAndDestroy(); // fieldSet
//
	CContactItemFieldSet* fieldSet2=CContactItemFieldSet::NewLC();
	CContactItemViewDef *viewDef=CContactItemViewDef::NewLC(CContactItemViewDef::EMaskFields,CContactItemViewDef::EMaskHiddenFields );
	RStoreReadStream rstream;
	rstream.OpenLC(*textstore,textId);
	fieldSet2->RestoreL(*store,streamId,blobstore,*viewDef,rstream);
	test(fieldSet2->Count()==3);
	CntTest->TestField((*fieldSet2)[0],KStorageTypeText,KUidContactFieldCompanyName,KUidContactFieldVCardMapORG);
	CntTest->TestField((*fieldSet2)[1],KStorageTypeText,KUidContactFieldPhoneNumber,KUidContactFieldVCardMapTEL);
	CntTest->TestField((*fieldSet2)[2],KStorageTypeDateTime,KUidContactFieldBirthday,KUidContactFieldVCardMapBDAY);
	CleanupStack::PopAndDestroy(7); // viewDef,fieldSet2 stream store textstore rstream,blobstore
//zzz more to do here
	}
예제 #10
0
void CVersitTest::StreamInL()
//Convert the iVersit into stream format, save it as "ExpDelVersitIn"
//and internalize it as a CVersitParser
	{
	RFile file;
	FileRegister->CreateTempFileLC(file, _L("ExpDelVersit2"));
	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(2);	// store + file
	FileRegister->OpenTempFileLC(file, _L("ExpDelVersit2"));
	store = CDirectFileStore::NewLC(file);
	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());
	iParser->InternalizeL(instream);
	CleanupStack::PopAndDestroy(3); //store + stream + file
	}
/**
This method stores in CAgnCalendarConverter::iOutputStreamStore the entry that has been internalized
from an old version file. 

The persistence layer objects owned by the CAgnCalendarConverter (iOutEntryManager and iOutModelStreamIdSet)
will also be updated to register the new entry.
@internalComponent */
void CAgnCalendarConverter::SaveRestoredEntryL(CAgnEntry& aEntry) const
	{
	
	// Externalize outline attributes first
	TStreamId id = KNullStreamId;
	RStoreWriteStream out;
	
	id = WriteDescriptorToStreamL(aEntry.Description());
	aEntry.SetDescriptionStreamId(id);
	
	id = WriteDescriptorToStreamL(aEntry.Summary());
	aEntry.SetSummaryStreamId(id);
	
	if(aEntry.AlarmAction())
		{
		RStoreWriteStream out;
		id = out.CreateLC(*iOutputStreamStore);
		out << *aEntry.AlarmAction();
		out.CommitL();
		CleanupStack::PopAndDestroy(); //out
		aEntry.SetAlarmActionStreamId(id);
		}

	iOutputTzRuleIndex->AddTzRuleL(aEntry);
	TStreamId newStreamId = iOutEntryManager->AddEntryL(aEntry); // This changes the entry/instance ID

	if (newStreamId != KNullStreamId)
		{
		// This puts the stream id in the array but doesn't commit it
		// To reduce file acces, the ModelStreamIdSet is only commited when all
		// the entries have been converted.
		iOutModelStreamIdSet->EntryStreamIdSet().AddL(newStreamId);
		}
	}
void CHtmlToCrtConverter::FinaliseConversionL()
	{
	TInt error=iFsSession.MkDirAll(*iTargetFileName);
	if(!(error==KErrNone || error==KErrAlreadyExists))
		User::Leave(error);

	CDirectFileStore* directFileStore=CDirectFileStore::ReplaceLC(iFsSession, *iTargetFileName, EFileWrite);
	directFileStore->SetTypeL(KDirectFileStoreLayoutUid);

	CStreamDictionary* dictionary=CStreamDictionary::NewLC();
	if (iText->DocumentLength())
		{
		iText->CopyToStoreL(*directFileStore, *dictionary, 0, iText->DocumentLength());
		}

	RStoreWriteStream storeWriteStream;
	TStreamId streamId=storeWriteStream.CreateLC(*directFileStore);
	storeWriteStream << *dictionary;
	storeWriteStream.CommitL();

	CleanupStack::PopAndDestroy(2); //storeWriteStream, dictionary
	directFileStore->SetRootL(streamId);
	directFileStore->CommitL();
	CleanupStack::PopAndDestroy(directFileStore);

#ifdef __CHTMLTOCRTCONV_COPY_TO_CLIPBOARD__
	CClipboard* clipboard=CClipboard::NewForWritingLC(iFsSession);
	if (iText->DocumentLength())
		{
		iText->CopyToStoreL((clipboard->Store()), (clipboard->StreamDictionary()), 0, iText->DocumentLength());
		}
	clipboard->CommitL();
	CleanupStack::PopAndDestroy(clipboard);
#endif
	}
예제 #13
0
void CSecMgrStore::RegisterScriptL(TExecutableID aExecID, const CScript& aScript)
	{
	HBufC *scriptFile = HBufC::NewLC(KMaxName);
	TPtr ptr(scriptFile->Des());
	User::LeaveIfError(GetScriptFile(ptr,aExecID));

	CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr,
			EFileWrite);

	// Must say what kind of file store.
	store->SetTypeL (KPermanentFileStoreLayoutUid);

	// Construct the output stream.
	RStoreWriteStream outstream;
	TStreamId id = outstream.CreateLC (*store);

	aScript.ExternalizeL (outstream);

	// Commit changes to the stream
	outstream.CommitL ();

	// Cleanup the stream object
	CleanupStack::PopAndDestroy (&outstream);

	// Set this stream id as the root
	store->SetRootL (id);

	// Commit changes to the store
	store->CommitL ();

	CleanupStack::PopAndDestroy (store);
	CleanupStack::PopAndDestroy (scriptFile);

	}
예제 #14
0
//
// Test writing to a store
//
LOCAL_C void testWriteL(CPersistentStore& aStore)
	{
	test.Next(_L("Writing..."));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(aStore);
	TStreamPos end=KStreamBeginning; //*
	for (TInt i=0;i<=KTestLength;++i)
		{
		test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==end); //*
		out.WriteL(KTestDes,i);
		test(out.Sink()->SeekL(0,EStreamEnd,-i)==end); //*
		out.WriteL(&KTestData[i],KTestLength-i);
		end+=KTestLength; //*
		}
//*	test(out.Sink()->SizeL()==end.Offset());
//*	out.WriteL(KTestDes,12);
//*	end+=12;
	test(out.Sink()->SizeL()==end.Offset()); //*
	out.CommitL();
	test(out.Sink()->SizeL()==end.Offset()); //*
	out.Close();
	aStore.SetRootL(out.CreateL(aStore));
	out<<KTestDes;
	out<<id;
	out.CommitL();
	CleanupStack::PopAndDestroy();
	}
예제 #15
0
TStreamId TIniData::StoreL(CStreamStore& aStore) const
	{
	RStoreWriteStream stream;
	TStreamId id2=stream.CreateLC(aStore);
	stream << *this;
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	TStreamId id1=stream.CreateLC(aStore);
	stream << *this;
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	TStreamId id3=stream.CreateLC(aStore);
	stream << id1 << id2;
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	return id3;
	}
예제 #16
0
TStreamId CSWICertStoreTool::WriteCertDataL(const TDesC8& aData)
	{
	RStoreWriteStream stream;
	TStreamId streamId = stream.CreateLC(*iStore);
	stream.WriteL(aData);
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	return streamId;
	}
예제 #17
0
TStreamId THighscoreHolder::StoreL(CStreamStore& aStore) const
{
	RStoreWriteStream stream;
	TStreamId id = stream.CreateLC(aStore);
	ExternalizeL(stream);
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	return id;
}
예제 #18
0
EXPORT_C void CClipboard::CommitL()
	{
	RStoreWriteStream stream;
	TStreamId streamId=stream.CreateLC(*iStore);
	stream<< *iStreamDictionary;
	stream.CommitL();
	CleanupStack::PopAndDestroy(); // dictionary stream
	iStore->SetRootL(streamId);
	iStore->CommitL();
	}
예제 #19
0
void CSWICertStoreTool::WriteRootStreamL(TStreamId aInfoStreamId)
	{
	// Create root stream - just contains id of info stream
	ASSERT(aInfoStreamId != KNullStreamId);
	RStoreWriteStream rootStream;
	TStreamId rootStreamId = rootStream.CreateLC(*iStore);
	iStore->SetRootL(rootStreamId);
	rootStream << aInfoStreamId;
	rootStream.CommitL();
	CleanupStack::PopAndDestroy(&rootStream);
	iStore->Commit();
	}
예제 #20
0
void CSecMgrStore::StorePolicyL(const CPolicy& aPolicy)
	{
	__UHEAP_MARK;

	HBufC *policyFile = HBufC::NewLC(KMaxName);
	TPtr ptr(policyFile->Des());
	GetPolicyFile (ptr, aPolicy.PolicyID ());

	CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession, ptr,
			EFileWrite);
	store->SetTypeL (KPermanentFileStoreLayoutUid);

	// Construct the output stream.
	RStoreWriteStream outstream;
	TStreamId id = outstream.CreateLC (*store);
	//Write version of the policy
	outstream.WriteReal32L (TReal(DEFAULT_VERSION));

	TInt aliasCnt(aPolicy.AliasGroup().Count());
	outstream.WriteInt32L (aliasCnt);
	RAliasGroup aliasGroups = aPolicy.AliasGroup();
	for (TInt i(0); i!=aliasCnt;++i)
		{
		CPermission* alias = aliasGroups[i];
		alias->ExternalizeL (outstream);
		}
	
	TInt domainCnt(aPolicy.ProtectionDomain().Count ());
	outstream.WriteInt32L (domainCnt);
	RProtectionDomains domains = aPolicy.ProtectionDomain ();
	for (TInt i(0); i!=domainCnt;++i)
		{
		CProtectionDomain* domain = domains[i];
		domain->ExternalizeL (outstream);
		}

	// Commit changes to the stream
	outstream.CommitL ();

	CleanupStack::PopAndDestroy (&outstream);

	// Set this stream id as the root
	store->SetRootL (id);

	// Commit changes to the store
	store->CommitL ();

	CleanupStack::PopAndDestroy (store);
	CleanupStack::PopAndDestroy (policyFile);
	__UHEAP_MARKEND;
	}
예제 #21
0
LOCAL_C void doMakeAndStoreL(CStreamStore& aStore,TStreamId& anId)
	{
				// Construct an object of type CClassA and put some 
				// data into it
	_LIT(KTxtForClassA,"Text for CClassA");
	CClassA* theA = CClassA::NewLC();
	theA->SetTextL(KTxtForClassA);	
	theA->iIntValue  = -1;
	theA->iUintValue = 2;

				// Construct an object of type CClassB and put some 
				// data into it
	_LIT(KTxtForClassB,"Text for CClassB");
	CClassB* theB = CClassB::NewLC();
	theB->iFixBuffer = KTxtForClassB;
	theB->iIntValue  = -3;
	theB->iUintValue = 4; 
	theB->iRealValue = 5.6;

				// Show contents of the CClassA object
	_LIT(KTxtClassAContent,"CClassA content ...");
	doShow(KTxtClassAContent,*theA);

				// Show contents of the CClassB object
	_LIT(KTxtClassBContent,"CClassB content ...");
	doShow(KTxtClassBContent,*theB);					

				// Construct the output stream.
				// The stream id (there is only one) is kept
				// in memory.
	RStoreWriteStream outstream;
	anId = outstream.CreateLC(aStore);

				// Stream out the CClassA object first
	outstream  << *theA; 
				
				// Stream out the CClassB object second
	outstream  << *theB;

				// Equally we could have done:
				//		outstream << *theA << *theB;
				// to the same effect

				// Commit changes to the stream
	outstream.CommitL();

				// Cleanup the stream object.
				// Destroy the CClassB object,
				// Destroy the CClassA object,
	CleanupStack::PopAndDestroy(3);
	}
TStreamId CAgnCalendarConverter::WriteDescriptorToStreamL(const TDesC& aString) const
/** @internalComponent */
	{
	if (aString.Length() > 0)
		{
		RStoreWriteStream out;
		TStreamId id = out.CreateLC(*iOutputStreamStore);
		out.WriteUint32L(aString.Length());
		out << aString;
		out.CommitL();
		CleanupStack::PopAndDestroy(); //out
		return id;
		}
	return KNullStreamId;
	}
예제 #23
0
/** Writes the application identifier followed by the stream dictionary 
to the store and makes the stream dictionary the root stream of the store.

Typically, the function is called by the application when it 
implements a file create or file save type operation. It is called after all 
model and UI data has been persisted. The IDs of the streams containing the 
model and UI data should have been lodged in the stream dictionary.

In effect, the function finishes off the file save or file
create type operation, leaving the file containing the store in a valid state
with the standard interface.

@param aStore  The store to which the root stream is to be written. Before
calling this function, a reference to the store must be saved by putting a
pointer onto the cleanup stack or by making it member data of a class. This
ensures that it is not orphaned in the event of this function leaving.
@param aStreamDic The stream dictionary containing the locations and associated 
UIDs of other streams in the store.
@param aAppId  The application identifier to be written into the application
identifier stream. */
EXPORT_C void CApaProcess::WriteRootStreamL(CPersistentStore& aStore,CStreamDictionary& aStreamDic,const TApaAppIdentifier& aAppId)
	{ // this is a static method
	__SHOW_TRACE(_L("Starting CApaProcess::WriteRootStreamL(id)"));
	// create a stream
	WriteAppIdentifierL(aStore,aStreamDic,aAppId);
	
	// externalize the dictionary
	RStoreWriteStream stream;
	TStreamId streamId = stream.CreateLC(aStore);
	stream << aStreamDic;
	stream.CommitL();
	CleanupStack::PopAndDestroy(); // dictionary stream
	
	// set the dictionary stream as the root stream
	aStore.SetRootL(streamId);
	}
예제 #24
0
// -----------------------------------------------------------------------------
// CShapeListManager::StoreL()
// Store the instance to the specified store
// -----------------------------------------------------------------------------
//
EXPORT_C TStreamId CShapeListManager::StoreL( CStreamStore& aStore ) const
    {

    RStoreWriteStream stream;

    // Create a stream within the store
    TStreamId id = stream.CreateLC( aStore );

    // Write the data to the stream
    ExternalizeL( stream );
    stream.CommitL();

    CleanupStack::PopAndDestroy(); // the stream

    return id; // return the stream ID
    }
예제 #25
0
/** Writes the application identifier to a new stream in the specified store and 
records the location of this stream in the specified stream dictionary.

@param aStore The store to which the application identifier should be written. 

@param aStreamDic The stream dictionary. 
@param aAppId The application identifier to be externalised to a stream. */
EXPORT_C void CApaProcess::WriteAppIdentifierL(CStreamStore& aStore,CStreamDictionary& aStreamDic,const TApaAppIdentifier& aAppId)
	{
	// this is a static method
	__SHOW_TRACE(_L("Starting CApaProcess::WriteAppIdentifierL"));
	
	// create a stream
	RStoreWriteStream stream;
	TStreamId streamId = stream.CreateLC(aStore);
	
	// stream the header
	stream << aAppId;
	stream.CommitL();
	
	CleanupStack::PopAndDestroy(); // id stream
	// enter the stream in the dictionary
	aStreamDic.AssignL(KUidAppIdentifierStream, streamId);
	}
예제 #26
0
/**
  Auxiliary function for T-CoGridStep-RunTestStepL.\n
  Stores the current grid settings to a Dat File.\n
  Saves the current cursor postion.\n
*/
void CTestCoeGridAppUi::SaveL()
	{
	RFs fsSession=iCoeEnv->FsSession();
	RFile file;
	TInt err=fsSession.MkDir(_L("C:\\data\\"));
	if (err!=KErrAlreadyExists)
		User::LeaveIfError(err);
    User::LeaveIfError(file.Replace(fsSession,_L("C:\\data\\TCOGRD.DAT"),EFileRead|EFileWrite));

    CFileStore *store=CreateStoreLC(file);
	RStoreWriteStream source;
	TStreamId root = source.CreateLC(*store);
	source << *(iGridWin->GridLay());
	source << iGridWin->CursorPos();
	store->SetRootL(root);
    CleanupStack::PopAndDestroy(2);
	}
예제 #27
0
TStreamId CSWICertStoreTool::WriteInfoStreamL()
	{
	// Create info stream
	RStoreWriteStream infoStream;
	TStreamId streamId = infoStream.CreateLC(*iStore);

	infoStream.WriteInt32L(iCerts.Count());
	for (TInt i = 0 ; i < iCerts.Count() ; ++i)
		{
		iCerts[i]->ExternalizeL(infoStream);
		}
	
	// Commit info stream
	infoStream.CommitL();
	CleanupStack::PopAndDestroy(&infoStream);

	return streamId;
	}
예제 #28
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1147
@SYMTestCaseDesc	    Writing to a store test
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for writing to a store
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL(CPersistentStore& aStore)
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1147 Writing... "));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(aStore);
	for (TInt i=0;i<=KTestLength;++i)
		{
		out.WriteL(KTestDes,i);
		out.WriteL(&KTestData[i],KTestLength-i);
		}
	out.CommitL();
	out.Close();
	aStore.SetRootL(out.CreateL(aStore));
	out<<KTestDes;
	out<<id;
	out.CommitL();
	CleanupStack::PopAndDestroy();
	}
예제 #29
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1151
@SYMTestCaseDesc	    Copying to a single file store test.
@SYMTestPriority 	    High
@SYMTestActions  	    Test for copying using different buffer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1151 Copying using small transfers "));
	TParsePtrC parse(KFileLocationSpec);
	
	CFileStore* store=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	RStoreReadStream in;
	in.OpenLC(*store,store->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*store,copyId);
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(*store);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*store,copyId);
	id=out.CreateL(*store);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
	in.Close();
	in.OpenL(*store,copyId);
	id=out.CreateL(*store);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
//
	CleanupStack::PopAndDestroy(3);
	}
예제 #30
0
//
// Test writing to a store
//
// Writes two streams in a store - the first containing sections of
// the test data repeated, and the the second containing the test data
// and the id of the first stream.  Returns the id of the second
// stream.
//
LOCAL_C TStreamId testWriteL(CStreamStore& aStore)
	{
	test.Next(_L("Writing..."));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(aStore);
	for (TInt i=0;i<=KTestLength;++i)
		{
		out.WriteL(KTestDes,i);
		out.WriteL(&KTestData[i],KTestLength-i);
		}
	out.CommitL();
	out.Close();
	TStreamId head=out.CreateL(aStore);
	out<<KTestDes;
	out<<id;
	out.CommitL();
	CleanupStack::PopAndDestroy();
	return head;
	}