Example #1
0
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);
	}
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;
	}
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;
}
Example #4
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);
	}
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);

	}
Example #6
0
//SYMBIAN_REMOVE_TRIVIAL_ENCRYPTION version of the method.
EXPORT_C void CDbFileStoreDatabase::CreateL(const TDesC& aName, TDbFormat::TCreate aMode,
                                            const TUidType& aType)
	{
	__ASSERT(!iName);	// check construction phase
//
	iName=aName.AllocL();
	CFileStore* store;
	switch (aMode)
		{
	default:
		__LEAVE(KErrNotSupported);
	case TDbFormat::ECreate:   
		store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite);
		break;
	case TDbFormat::EReplace:
		store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite);
		break;
		};
	iStore=store;
	iDelete=ETrue;		// cleanup fully in case of failure
	store->SetTypeL(aType);
	store->SetRootL(CreateRootL(CDbStoreDatabase::ConstructL()));
	store->CommitL();
	iDelete=EFalse;				// file is now good
	}
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);
	}
Example #8
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);
	}
/**
@SYMTestCaseID          SYSLIB-STORE-CT-4007
@SYMTestCaseDesc	    CDirectFileStore::ReplaceLC() and SetTypeL() performance test
@SYMTestPriority 	    High
@SYMTestActions  	    Creates new CDirectFileStore object and measures the time of the operation. 
@SYMTestExpectedResults Tests set type time 
@SYMCR                  ATHE-7CQP8H
*/
void CreateDirectFileStoreTestL()
	{	
	(void)TheFs.Delete(TheTestFile);
	    
    TUint32 fc = User::FastCounter();
	CFileStore* store = CDirectFileStore::ReplaceLC(TheFs, TheTestFile, EFileWrite | EFileRead);
	// Must say what kind of file store
	// SetTypeL() calls RFileBuf::EndL() which used to call RFile::Size()
	store->SetTypeL(KDirectFileStoreLayoutUid);
	TUint32 time = CalcTickDiff(fc, User::FastCounter());
	CleanupStack::PopAndDestroy(store);
	PrintFcDiffAsUs(_L("###  CDirectFileStore::ReplaceLC() & SetTypeL(), Time=%d us\r\n"), time);
	}
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;
	}
Example #11
0
LOCAL_C void doMakeAndExternalizeL(const TDesC& aName)
	{
	TParse	filestorename;
	fsSession.Parse(aName,filestorename);
				// construct file store object - the file to contain the
				// the store replaces any existing file of the same name.
	CFileStore* store = CPermanentFileStore::ReplaceLC(fsSession,filestorename.FullName(),EFileWrite);

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

					// Construct an object of type CCompound ... 
	CCompound* thecompound = CCompound::NewLC(*store);

				// ... and put some data into it.
				// Note that "iA->" achieves the same
				// as "iA->AsPtr()->"
	_LIT(KTxtClassAText,"CClassA text");
	_LIT(KTxtClassBText,"CClassB text");
	thecompound->iA.AsPtr()->iBufferA = KTxtClassAText;
	thecompound->iA.AsPtr()->iXA	  = -1; 
	thecompound->iA->iYA	          = 2; // see note above
	thecompound->iB.AsPtr()->iBufferB = KTxtClassBText;
	thecompound->iC.AsPtr()->iZC	  = 3.456;

				// Show contents of the CCompound object (and its
				// components).
	_LIT(KTxtInitialContent,"... Initial content of CCompound");
	doShowAll(KTxtInitialContent,*thecompound);

				// stores all components as separate streams and
				// then streams the store map
	TStreamId id = thecompound->StoreL();

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

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

				// 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);
	}
Example #12
0
LOCAL_C void doMakeAndExternalizeL(const TDesC& aName)
{
    TParse	filestorename;

    fsSession.Parse(aName,filestorename);
    // construct file store object - the file to contain the
    // the store replaces any existing file of the same name.
    CFileStore* store = CDirectFileStore::ReplaceLC(fsSession,filestorename.FullName(),EFileWrite);

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

    // Construct an object of type CCompound
    // and put some data into it.
    CCompound* thecompound = CCompound::NewLC();

    _LIT(KTxtClassAText,"CClassA text");
    _LIT(KTxtClassBText,"CClassB text");

    thecompound->iCa->iBufferA = KTxtClassAText;
    thecompound->iCa->iXA      = -1;
    thecompound->iCa->iYA      = 2;
    thecompound->iCb->iBufferB = KTxtClassBText;
    thecompound->iTc.iZC       = 3.456;

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

    // Store the compound object to a single stream
    // and save the stream id as the root id.
    TStreamId  id = thecompound->StoreL(*store);

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

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

    // 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);
}
Example #13
0
/**
 Auxiliary Fn for Test Case ID T-StreamStep-TestPrintSetupL,
 T-StreamStep-TestModelRestoreL,
 T-StreamStep-TestHeaderFooterL.\n

 This function tests Picture persistance.\n
 Copies the aOriginal CPrintSetup object to the store and restores to the aCopy object\n
*/
void CT_StreamStep::TestStoreRestoreL(CPrintSetup* aCopy, CPrintSetup* aOriginal)
    {
	// set up the store
	RFile theFile;
	TInt ret=theFile.Replace(iFs,_L("c:\\tprint.tst"),EFileRead|EFileWrite);
	 	TEST(ret==KErrNone);
	CFileStore* theStore;
	theStore=CDirectFileStore::NewLC(theFile);  // Creates concrete store over the file.
	theStore->SetTypeL(TUidType(KDirectFileStoreLayoutUid,KNullUid,KNullUid));
	//
	// store the original
	TStreamId id=0;
	TRAP(ret,id=aOriginal->StoreL(*theStore));
		TEST(ret==KErrNone);
	//
	// restore into the copy
	TRAP(ret,aCopy->RestoreL(*theStore,id));
		TEST(ret==KErrNone);
	//
	// tidy up
	CleanupStack::PopAndDestroy();  // theStore
	iFs.Delete(_L("c:\\tprint.tst"));
    }
Example #14
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);
	}
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;
	}
Example #16
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
	}
Example #17
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
	}
Example #18
0
LOCAL_C void TestUiMtmLoadPanicL()
	{
	// Make sure the server is closed
	CMsgsTestUtils::WaitForServerClose();
	User::After(500000);
	TChar driveChar= theUtils->FileSession().GetSystemDriveChar();
	TBuf<2> systemDrive;
	systemDrive.Append(driveChar);
	systemDrive.Append(KDriveDelimiter);
	TPath pathName(systemDrive);
	pathName.Append(KDefaultRegistryFileStoreName);
	theUtils->FileSession().Delete(pathName);

	CMtmDllInfoArray* mtmdllinfoarray=new(ELeave) CMtmDllInfoArray();
	CleanupStack::PushL(mtmdllinfoarray);

	// Create library info with silly imports
	CMtmDllInfo* mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmServerComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0));
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);

	mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmClientComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,1,TVersion(2,0,0));
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);

	mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,345,TVersion(2,0,0));
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);

	mtmdllinfo=CMtmDllInfo::NewL(KMtmName, TUidType(KDynamicLibraryUid, KUidMtmUiDataComponent, TUid::Uid(KUidMtmDefaultSpecificVal)),KMtmDllName,456,TVersion(2,0,0));
	mtmdllinfoarray->AddMtmDllInfoL(mtmdllinfo);

	TCapabilitySet capSet;
	capSet.SetEmpty();
	CleanupStack::Pop(mtmdllinfoarray); // next line takes ownership
	CMtmGroupData* mtmgroupdata=CMtmGroupData::NewL(KUidTestMtm, KUidTestMtm, mtmdllinfoarray, capSet);
	CleanupStack::PushL(mtmgroupdata);

	CFileStore* filestore = CPermanentFileStore::ReplaceLC(theUtils->FileSession(), KMtmDataFile, EFileShareExclusive|EFileStream|EFileWrite);
	TUidType uidtype(KPermanentFileStoreLayoutUid,KUidMsvDataComponent, KUidTestMtm);
	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

	CDummyObserver* ob = new(ELeave)CDummyObserver;
	CleanupStack::PushL(ob);

	CMsvSession* session = CMsvSession::OpenSyncL(*ob);
	CleanupStack::PushL(session);

	TInt err = session->InstallMtmGroup(KMtmDataFile);
	test(err == KErrNone || err == KErrAlreadyExists);
	CClientMtmRegistry* clientReg = CClientMtmRegistry::NewL(*session);
	CleanupStack::PushL(clientReg);

	CBaseMtm* client = NULL;
	client = clientReg->NewMtmL(KUidTestMtm);
	CleanupStack::PushL(client);

	CMtmUiRegistry* uiReg = CMtmUiRegistry::NewL(*session);
	CleanupStack::PushL(uiReg);

	if (client !=NULL)
		{
		TRAPD(error, uiReg->NewMtmUiL(*client));
		test(error == KErrBadLibraryEntryPoint);
		}
	CleanupStack::PopAndDestroy(5); // uiReg, client, clientReg, session, ob
	}
Example #19
0
LOCAL_C void testDummyL(CFileStore& aStore)
	{
	aStore.SetTypeL(aStore.Layout());
	aStore.CommitL();
	}
/**
@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
	}
Example #21
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
	}