예제 #1
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);

	}
예제 #2
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	
	}
예제 #3
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();
	}
예제 #4
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
	}
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
	}
예제 #6
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();
}
예제 #7
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);
		}
	}
/**
This method is executed as the last step of a calendar file conversion.
Externalizes to the new file store the new CAgnEntryManager and CAgnModelStreamIdSet.
Calls ReplaceAgendaFile() to update the Model and its ServerFile with the products of the
conversion.
@internalComponent */
void CAgnCalendarConverter::CompleteConversionL()
	{
	// Copy iFileId and iNextUniqueIdValue to the Converter's output stream store
	//
	iAgnServerFile->Model()->ExternalizeFileIdL(*iOutputStreamStore, iOutModelStreamIdSet->FileInformationStreamId());
	iAgnServerFile->Model()->ExternalizeNextUidValuesL(*iOutputStreamStore, iOutModelStreamIdSet->NextLocalUidValueStreamId());
	iOutputStreamStore->CommitL();

	// Commit the streamIdSet and the EntryManager to the output store
	//
	RStoreWriteStream stream;
	stream.ReplaceLC(*iOutputStreamStore,iOutModelStreamIdSet->EntryManagerStreamId());
	stream << *iOutEntryManager;
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	
	iOutModelStreamIdSet->CommitL(*iOutputStreamStore);
	iOutputStreamStore->CommitL();
	
	delete iDictionary;
	iDictionary = NULL;
	delete iOutputStreamStore;
	iOutputStreamStore = NULL;
	
	// Set new calendar file and dictionary in CAgnServFile
	// (this deletes the old file, and hands over the ownership of iOutputTzRuleIndex)
	//
	iAgnServerFile->ReplaceConvertedAgendaFileL(*iOutEntryManager, *iOutputTzRuleIndex);
	iOutputTzRuleIndex = NULL;
	}
예제 #10
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1200
@SYMTestCaseDesc	    Shape streaming test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for streaming of different shapes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testShapesL()
    {
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1200 Shape streaming "));

	TParsePtrC parse(KFileLocationSpec);
//
//	TheStore=CDirectFileStore::ReplaceLC(TheFs,KTestFile,EFileRead|EFileWrite);
	TheStore=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	TheStore->SetTypeL(TheStore->Layout());
//
	RStoreWriteStream snk;
	TStreamId id=snk.CreateL(*TheStore);
	TShapeHolder hldr(ESquare,new(ELeave) CSquare(TPoint(20,30),40));
	hldr.ExternalizeSerialL(snk);
	delete hldr.Shape();
	hldr=TShapeHolder(ECircle,new(ELeave) CCircle(TPoint(70,80),40));
	hldr.ExternalizeSerialL(snk);
	delete hldr.Shape();
	snk.Close();
	RStoreReadStream src;
	src.OpenL(*TheStore,id);
	hldr.InternalizeSerialL(src);
	delete hldr.Shape();
	hldr.InternalizeSerialL(src);
	delete hldr.Shape();
	src.Close();
//
	hldr=TShapeHolder(ESquare,new(ELeave) CSquare(TPoint(20,30),40));
	id=hldr.StoreL(*TheStore);
	delete hldr.Shape();
	hldr.RestoreL(*TheStore,id);
	delete hldr.Shape();
//
	CShape* shape=new(ELeave) CCircle(TPoint(70,80),40);
	CStoreMap* map=CStoreMap::NewL(*TheStore);
	TStreamId id2 = shape->StoreL(*TheStore);

	testExtraStoreMapAPIsL();
	
	map->BindL(shape,id2);
	snk=RStoreWriteStream(*map);
	id=snk.CreateL(*TheStore);
	snk<<shape;
	snk.Close();
	delete shape;
	src.OpenL(*TheStore,id);
	src>>id;
	src.Close();
	shape=new(ELeave) CCircle;
	shape->RestoreL(*TheStore,id);
	delete map;
	TRAPD(r,shape->RestoreL(*TheStore,id));
	test(r==KErrNotFound);
	delete shape;
//
	CleanupStack::PopAndDestroy();
    }
예제 #11
0
TStreamId CSWICertStoreTool::WriteCertDataL(const TDesC8& aData)
	{
	RStoreWriteStream stream;
	TStreamId streamId = stream.CreateLC(*iStore);
	stream.WriteL(aData);
	stream.CommitL();
	CleanupStack::PopAndDestroy(&stream);
	return streamId;
	}
예제 #12
0
TStreamId THighscoreHolder::StoreL(CStreamStore& aStore) const
{
	RStoreWriteStream stream;
	TStreamId id = stream.CreateLC(aStore);
	ExternalizeL(stream);
	stream.CommitL();
	CleanupStack::PopAndDestroy();
	return id;
}
예제 #13
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();
	}
예제 #14
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();
	}
예제 #15
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;
	}
예제 #17
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);
	}
예제 #18
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
    }
예제 #19
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);
	}
예제 #20
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);
	}
예제 #21
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);
	}
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
	}
예제 #23
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;
	}
예제 #24
0
void CTTypes::InitialiseWriteStream()
	{
	TRAPD(ret,writestore=CDirectFileStore::ReplaceL(fs,_L("c:\\ttypes.str"),EFileStream|EFileWrite));
	TEST2(ret, KErrNone);
	TRAP(ret,writestore->SetTypeL(KDirectFileStoreLayoutUid));
	TEST2(ret, KErrNone);
	TStreamId headerid(0);      //To stop a warning
	TRAP(ret,headerid=writestrm.CreateL(*writestore));
	TEST2(ret, KErrNone);
	TRAP(ret,writestore->SetRootL(headerid));
	TEST2(ret, KErrNone);
	}
예제 #25
0
/*
 *This function assumes that the index doesn't exist
 */
void CSettingsManager::MakeSeedIndexL()
	{
	OpenStore2WriteLC();
	RStoreWriteStream outstream;
	TStreamId invalidId(0); //caution: confirm the reliability of this value
	iRootId = outstream.CreateLC(*iStore);		
	
	//write an invalid  stream index for general settings i.e.iGenSettingsId
	outstream << invalidId;	 
		
	//write no. of controllers as 0
	outstream.WriteInt8L(0);
	
	outstream.CommitL(); //commit stream changes
	CleanupStack::PopAndDestroy();
	
	iStore->SetRootL(iRootId);
	iStore->CommitL(); //commit changes to store
	
	CleanupStack::PopAndDestroy(); //for iStore	
	}
예제 #26
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);
	}
예제 #27
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);
	}
예제 #28
0
void CSettingsManager::WriteGeneralSettingsL(CMVSAppUi* aAppUI)
	{	
	OpenStore2WriteLC();
	
	RStoreWriteStream outstream;
	/*
	if already there is stream id for general settings open the existing
	stream; otherwise create new stream id 
	*/
	TBool updation = iGenSettingsId.Value();
	if(updation)
		{
		outstream.ReplaceLC(*iStore,iGenSettingsId);
		}
	else
		{
		iGenSettingsId = outstream.CreateLC(*iStore);
		}
	
	//write the general settings
	aAppUI->ExternalizeL(outstream);
	outstream.CommitL();
	CleanupStack::PopAndDestroy();
	
	if(!updation)
		{
		outstream.ReplaceLC(*iStore,iStore->Root());
		TUid tempUid;
		TStreamId tempStreamId(0);
		WriteIndexL(outstream,tempUid,tempStreamId);
		CleanupStack::PopAndDestroy();	
		}		
						
	iStore->CommitL();// commit the changes to the store
	CleanupStack::PopAndDestroy(); //for iStore 
	iFsSession.Close(); //close the file session
	}	  
예제 #29
0
TInt CSecMgrStore::WriteCounter(TExecutableID aExecID)
	{
	HBufC *configFile = HBufC::NewLC(KMaxName);
	TPtr ptr(configFile->Des());
	TInt ret(GetConfigFile (ptr));

	if ( KErrNone==ret)
		{
		CFileStore* store = CPermanentFileStore::ReplaceLC (iFsSession,
				*configFile, EFileWrite);

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

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

		outstream.WriteInt32L (aExecID);

		// 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 (configFile);
	return ret;
	}
예제 #30
0
EXPORT_C void CMsvTestUtils::CreateServerMtmRegL(const TUid aMsgType, const TDesC& aHumanReadableName, const TMsvTestDllInfo& aServerMtm, const TMsvTestDllInfo& aClientMtm, const TMsvTestDllInfo& aUiMtm, const TMsvTestDllInfo& aUiDataMtm, const TUid aGroup, const TDesC& aDatFile)
	{
	CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray();
	CleanupStack::PushL(mtmdllinfoarray);

	CMtmDllInfo* mtmdllinfo1=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmServerComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aServerMtm.iFileName,aServerMtm.iOrdinal,aServerMtm.iVersion);
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo1);

	CMtmDllInfo* mtmdllinfo2=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmClientComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aClientMtm.iFileName,aClientMtm.iOrdinal,aClientMtm.iVersion);
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo2);

	CMtmDllInfo* mtmdllinfo3=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiMtm.iFileName,aUiMtm.iOrdinal,aUiMtm.iVersion);
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo3);

	CMtmDllInfo* mtmdllinfo4=CMtmDllInfo::NewL(aHumanReadableName,TUidType(KDynamicLibraryUid,KUidMtmUiDataComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),aUiDataMtm.iFileName,aUiDataMtm.iOrdinal,aUiDataMtm.iVersion);
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo4);

	// Create an empty capability set for creating a new group data object
	TCapabilitySet capSet;
	capSet.SetEmpty();
	CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership
	CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(aMsgType, aGroup, mtmdllinfoarray, capSet);
	CleanupStack::PushL(mtmgroupdata);

	CFileStore* filestore = CPermanentFileStore::ReplaceLC(FileSession(), aDatFile, EFileShareExclusive|EFileStream|EFileWrite);
	TUidType uidtype(KPermanentFileStoreLayoutUid, KUidMsvDataComponent, aMsgType);

	filestore->SetTypeL(uidtype);
	RStoreWriteStream out;
	TStreamId streamid=out.CreateLC(*filestore);	// Push to stack
	mtmgroupdata->ExternalizeL(out);
	out.CommitL();
	CleanupStack::PopAndDestroy(); // out
	filestore->SetRootL(streamid);
	filestore->CommitL();
	CleanupStack::PopAndDestroy(2, mtmgroupdata); // filestore, mtmgroupdata
	}