Exemple #1
0
LOCAL_C void doDeferredLoadingL(const TDesC& aName)
	{
	TParse	filestorename;
	fsSession.Parse(aName,filestorename);
				// construct file store object - specifying the file
				// containing the store.
	CFileStore* store = CPermanentFileStore::OpenLC(fsSession,filestorename.FullName(),EFileRead);
	
				// Construct an object of type CCompound.
				// The loading of its components is deferred 
				// until needed.
	CCompound* thecompound = CCompound::NewLC(*store,store->Root());
	
				// Display component A.
				// The component is loaded in from the 
				// stream if not already loaded.
	_LIT(KTxtFirstDisplay," (first display)");
	thecompound->DisplayAL(KTxtFirstDisplay);

				// Re-Display component A
				// The component should now be in memory.
	_LIT(KTxtSecondDisplay," (second display)");
	thecompound->DisplayAL(KTxtSecondDisplay);

	console->Printf(KTxtNewLine);

				// Destroy:
				// 1. the CCompound object
				// 2. the store object (this also closes 
				//    the file containing the store)
				// Remove both from the cleanup stack
	CleanupStack::PopAndDestroy(2);
	}
TInt CSecMgrStore::ReadCounter(TExecutableID& aExecID)
	{
	HBufC *configFile = HBufC::NewLC(KMaxName);
	TPtr ptr(configFile->Des());
	TInt ret(GetConfigFile (ptr));

	if ( KErrNone==ret)
		{
		if ( !BaflUtils::FileExists(iFsSession,*configFile))
			{
			aExecID = (TExecutableID)KCRUIdSecMgr.iUid;
			BaflUtils::EnsurePathExistsL (iFsSession, *configFile);
			CleanupStack::PopAndDestroy (configFile);
			return WriteCounter (aExecID);
			}

		CFileStore* store = CPermanentFileStore::OpenLC (iFsSession,
				*configFile, EFileRead);

		RStoreReadStream instream;
		instream.OpenLC (*store, store->Root ());

		aExecID = instream.ReadInt32L ();

		CleanupStack::PopAndDestroy (&instream);
		CleanupStack::PopAndDestroy (store);
		}
	CleanupStack::PopAndDestroy (configFile);
	return ret;
	}
void CMsvSendExe::RetrievePackagesL()
	{
	
	//open the filestore 	
	CFileStore* store = CDirectFileStore::FromLC(iTaskFile);//pushes store

	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());//pushes instream

	//get task count
	TInt taskCount = instream.ReadInt32L();

	SCHSENDLOG(FLog(iFileName, _L("\tTask Count=%d"), taskCount));

	for (TInt curTask = 0; curTask < taskCount; curTask++)
		{
		CScheduledTask* task = CScheduledTask::NewLC(instream);

		AddPackageL(*task);

		CleanupStack::PopAndDestroy(task);
		}

	CleanupStack::PopAndDestroy(2, store);
	}
LOCAL_C void doInternalizeL(const TDesC& aName)
{
    TParse	filestorename;

    fsSession.Parse(aName,filestorename);
    // construct file store object - specifying the file
    // containing the store.
    CFileStore* store = CDirectFileStore::OpenLC(fsSession,filestorename.FullName(),EFileRead);

    // Construct a CCompound object
    // from the root stream created earlier.
    CCompound* thecompound = CCompound::NewL(*store,store->Root());

    // Show contents of the CCompound object (and its
    // components)
    _LIT(KTxtRestoredContent,"... Restored CCompound content.");
    doShow(KTxtRestoredContent,*thecompound);

    // destroy the store object (this also closes the file
    // containing the store)
    CleanupStack::PopAndDestroy();

    // Now destroy the CCompound object
    delete thecompound;
}
void CSecMgrStore::RestorePoliciesL(RPolicies& aPolicy)
	{
	//Fetch all the individual policy files from "epoc32\winscw\c\private\<SECMGR_UID>\policy" directory
	//Iteratively internalise the policy files, with the policyID (PolicyID is = to filename)
	HBufC *privateDir = HBufC::NewLC(KMaxName);
	TPtr privateDirptr(privateDir->Des());
	GetPolicyPath (privateDirptr);

	// create search string
	HBufC* searchBuf = privateDirptr.AllocLC ();
	TPtr searchPtr(searchBuf->Des());

	CDir* dir=  NULL;
	iFsSession.GetDir (searchPtr, KEntryAttNormal,
			ESortByName | EAscending, dir);

	if ( dir)
		{
		CleanupStack::PushL (dir);
		for (TInt i=0; i!=dir->Count ();++i)
			{
			TEntry entry = dir->operator[] (i);
			HBufC *fileName = HBufC::NewLC(KMaxName);
			TPtr ptr(fileName->Des());
			ptr = entry.iName;

			HBufC *policyFile = HBufC::NewLC(KMaxName);
			TPtr policyFileptr(policyFile->Des());
			policyFileptr.Copy(privateDirptr) ;
			policyFileptr.Append (ptr);

			CFileStore* store = CPermanentFileStore::OpenLC (iFsSession,
					policyFileptr, EFileShareAny);

			RStoreReadStream instream;
			instream.OpenLC (*store, store->Root ());

			TLex16 lexer(ptr);
			TPolicyID pID;
			lexer.Val (pID);

			CPolicy* policy = CPolicy::NewL (pID, instream);
			aPolicy.Append (policy);

			CleanupStack::PopAndDestroy (&instream); //instream
			CleanupStack::PopAndDestroy (store); //store
			CleanupStack::PopAndDestroy (policyFile);
			CleanupStack::PopAndDestroy (fileName);
			}

		CleanupStack::PopAndDestroy (dir);
		}

	CleanupStack::PopAndDestroy (searchBuf);
	CleanupStack::PopAndDestroy (privateDir);
	}
Exemple #6
0
void CApaProcess::DoReadRootStreamL(CStreamDictionary& aStreamDictionary, const CFileStore& aStore)
	{ // static
	const TStreamId rootStreamId=aStore.Root();
	if ((aStore.Type()[1] != KUidAppDllDoc) || (rootStreamId == KNullStreamId))
		User::Leave(KErrCorrupt);
	
	RStoreReadStream rootStream;
	rootStream.OpenLC(aStore, rootStreamId);
	rootStream >> aStreamDictionary;
	CleanupStack::PopAndDestroy(&rootStream);
	}
Exemple #7
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 #8
0
void CVersitTest::StreamInL()
//Convert the iVersit into stream format, save it as "TTVersitIn"
//and internalize it as a CVersitParser
	{
	RFs fsSession; 
	User::LeaveIfError(fsSession.Connect());
	CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,_L("c:\\TTVersit2"),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 = CDirectFileStore::OpenLC(fsSession,_L("c:\\TTVersit2"),EFileRead); //retrieve stream
	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());
	iParser->InternalizeL(instream);
	CleanupStack::PopAndDestroy(2); //store + stream
	}
/**
@SYMTestCaseID          SYSLIB-SCHSVR-CT-1345
@SYMTestCaseDesc	    Platform security Task handler test 
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt to test the contents of a task file.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/				
LOCAL_C void ConstructConsoleL(RFile& aTaskFile, RTest& aTest)
	{
	
	CConsoleBase* console=Console::NewL(KConsoleName, TSize(KConsFullScreen, KConsFullScreen));
	CleanupStack::PushL(console);
	console->Printf(_L(" contents of task file\n"));

	RArray<TCapability> enforcedCaps;
	CleanupStack::PushL(TCleanupItem(&DestroyArray,&enforcedCaps));

	for (TInt i=0; i<ECapability_Limit; i++)
		{
		// we're checking here to see which capabilities are enforced, skipping
		// ECapabilityMultimediaDD and ECapabilityWriteDeviceData as it is
		// needed to write persistent schedules upon which this test relies.
		
		if (i == KPlatSecTestCapability)
			continue;
		else if (i == ECapabilityWriteDeviceData)
			continue;
		else if (PlatSec::IsCapabilityEnforced((TCapability)i))
			enforcedCaps.Append((TCapability)i);
		}
	
	TBool isTestCapabilityEnforced = PlatSec::IsCapabilityEnforced(KPlatSecTestCapability);
	
	CFileStore* store;
	store = CDirectFileStore::FromLC(aTaskFile);

	RStoreReadStream instream;
	instream.OpenLC(*store,store->Root());
	
	TInt count = instream.ReadInt32L();
	for (TInt i=0;i<count;i++)
		{
		CScheduledTask* task = CScheduledTask::NewLC(instream);
		
		aTest(task->Info().iName.CompareF(KPlatSecTaskName)==0);
		aTest(task->Data().CompareF(KPlatSecTaskData)==0);
		aTest(task->SecurityInfo().iSecureId==KPlatSecTestSid); //This is the SID of tschsvrplatsec

		// check that client has capability it should have
		if(isTestCapabilityEnforced)
			aTest(task->SecurityInfo().iCaps.HasCapability(KPlatSecTestCapability));
		
		// check that the client has ECapabilityWriteDeviceData
		aTest(task->SecurityInfo().iCaps.HasCapability(ECapabilityWriteDeviceData));
		
		// check that client doesn't have any other capabilities
		for (TInt j=enforcedCaps.Count()-1; j>=0; --j)
			{
			aTest(!task->SecurityInfo().iCaps.HasCapability(enforcedCaps[j]));
			}
			
		
		CleanupStack::PopAndDestroy(task);
		}
		
	console->Printf(_L("Pausing for a one second..."));
	User::After(1000000);
	
	CleanupStack::PopAndDestroy(4); // instream, store, enforcedCaps, console
	}