Пример #1
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1153
@SYMTestCaseDesc	    Tests for writing using a permanent file store
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for memory and end of file error while creating the store.
                        Tests for writing to replaced,temporary,opened,created file.
						Tests for creating an already existing file.
						Tests for panic while deleting a file.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testWriteL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1153 Creating and failing to open 'ghost' file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	TheFs.Delete(parse.NameAndExt());
	CFileStore* store=CPermanentFileStore::CreateLC(TheFs,parse.NameAndExt(),EFileWrite);
	CleanupStack::PopAndDestroy();
	store=NULL;
	TRAPD(r,store=CPermanentFileStore::OpenL(TheFs,parse.NameAndExt(),EFileRead|EFileWrite));
	test(store==NULL&&r==KErrEof);
//
	test.Next(_L("Empty tests on replaced file"));
	store=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileWrite);
	store->SetTypeL(TUidType(KPermanentFileStoreLayoutUid,KPermanentFileStoreLayoutUid));
	testEmptyL(*store);
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to temp file"));
	store=CPermanentFileStore::TempLC(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KPermanentFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	(void)TheFs.Delete(TheTempFile);
//
	test.Next(_L("Writing to temp file - 2"));
	store=CPermanentFileStore::TempL(TheFs,parse.DriveAndPath(),TheTempFile,EFileWrite);
	CleanupStack::PushL(store);
	store->SetTypeL(TUidType(store->Layout(),KNullUid,KPermanentFileStoreLayoutUid));
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Writing to opened file"));
	store=CPermanentFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
//
	test.Next(_L("Failing to create existing file"));
	store=NULL;
	TRAP(r,store=CPermanentFileStore::CreateL(TheFs,TheTempFile,EFileWrite));
	test(store==NULL&&r==KErrAlreadyExists);
	if (TheFs.Delete(parse.NameAndExt())!=KErrNone)
		test.Panic(_L("Deleting file"));
//
	test.Next(_L("Writing to created file"));
	RFile file;
	test(file.Create(TheFs,parse.NameAndExt(),EFileWrite)==KErrNone);
	store=CPermanentFileStore::NewLC(file);
	store->SetTypeL(KPermanentFileStoreLayoutUid);
	testWriteL(*store);
	store->CommitL();
	CleanupStack::PopAndDestroy();
	}
Пример #2
0
void HandleStart()
{
	RDebug::Print(_L("TrkLauncher::HandleStart()"));
	
	if (!IsAlreadyRunning())
	{		
		TInt result;		
		RProcess p;
		
		//start TrkConsole	process
		result = p.Create(KTrkConsoleExe, TPtr(NULL, 0), TUidType(KNullUid, KNullUid, KTrkConsoleExeUid));
		if (result == KErrNone)
		{
			RDebug::Print(_L("TrkLauncher - Trk process resume"));
			p.Resume();
			RDebug::Print(_L("TrkLauncher - After Trk process resume"));
			p.Close();
			RDebug::Print(_L("TrkLauncher - After Trk process close"));
		}
		else
		{
			RDebug::Print(_L("TrkLauncher - Trk process not created with %d \n"),result);
			RDebug::Print(_L("TrkLauncher - Returning without process creation"));
		}
			
	}
}
Пример #3
0
/**
Construct a clipboard store for writing to.
*/
void CClipboard::ConstructForWritingL(const TDesC& aFileName)
    {
	CreateDirectoryL(aFileName);
	iStore=CDirectFileStore::ReplaceL(iFsSession,aFileName,EFileRead|EFileWrite);
	iStore->SetTypeL(TUidType(KDirectFileStoreLayoutUid,KClipboardFileUid));
	iStreamDictionary=CStreamDictionary::NewL();
	}
Пример #4
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();
}
LOCAL_C void TestDoFindFullName()
//
//	Test DoFindFullName method
//
	{
	CDummyRegisterMtmDllObserver* dummyRegisterMtmDllObserver=new(ELeave) CDummyRegisterMtmDllObserver();
	CleanupStack::PushL(dummyRegisterMtmDllObserver);

	CMtmDllInfo* mtmDllInfo=CMtmDllInfo::NewL(_L("My server dummy dll info"),TUidType(KDynamicLibraryUid,KUidMtmServerComponent,TUid::Uid(KUidMtmDefaultSpecificVal)),KDummyMtmFilename,1,TVersion(2,0,0));
	CleanupStack::PushL(mtmDllInfo);
	CRegisteredMtmDll* registeredMtmDll=CRegisteredMtmDll::NewL(KDummyMtmTypeUid,KDummyTechnologyTypeUid,(const CMtmDllInfo&) *mtmDllInfo,KMsvDefaultTimeoutMicroSeconds32,*dummyRegisterMtmDllObserver);
	CleanupStack::PushL(registeredMtmDll);

	RLibrary mtmDllLibrary;
	TInt ret=KErrNone;

	// Test 1.
	// Set Rfs to fail with KErrGeneral on the second call.  
	//  This will be at the call to GetDir in DoFindFullName, ie when tring to GetDir on A:
	//  DoFindFullName will return KErrNotFound in this condition.
	theUtils->FileSession().SetErrorCondition(KErrCorrupt, 2);  
	ret = registeredMtmDll->GetLibrary(theUtils->FileSession(), mtmDllLibrary);
	// This will work with secure API
	test(ret == KErrNone || ret == KErrNotFound);
	// Release the library
	if (registeredMtmDll->MtmDllRefCount())  
		registeredMtmDll->ReleaseLibrary();	//  Library not released in mtm destructor

	// Test 2.
	// Set Rfs to fail with KErrNotSupported on the second call.  
	//  This will be at the call to GetDir in DoFindFullName, ie when tring to GetDir on A:
	// This test case is for defect DEF027335 - "WINS: Mailinit fails on clean baseline"
	//   Prior to the fix, DoFindFullName could return with KErrNotSupported before
	//   it had finished scanning the list of available drives.  It should now complete
	//   with KErrNotFound
	theUtils->FileSession().SetErrorCondition(KErrNotSupported, 2);  
	ret = registeredMtmDll->GetLibrary(theUtils->FileSession(), mtmDllLibrary);
	// This will work with secure API
	test(ret == KErrNone || ret == KErrNotFound);
	// Release the library
	if (registeredMtmDll->MtmDllRefCount())  
		registeredMtmDll->ReleaseLibrary();	//  Library not released in mtm destructor

	// Test 3.
	// Allow calls to RFs to complete
	//  Validreturn values for this case are: KErrNone if found and KErrNotFound if not found
	theUtils->FileSession().SetErrorCondition(KErrNone);  
	ret = registeredMtmDll->GetLibrary(theUtils->FileSession(), mtmDllLibrary);
	test(ret == KErrNone || ret == KErrNotFound);

	// Release the library
	if (registeredMtmDll->MtmDllRefCount())  
		registeredMtmDll->ReleaseLibrary();	//  Library not released in mtm destructor

	// Clean up
	CleanupStack::PopAndDestroy(registeredMtmDll);
	CleanupStack::PopAndDestroy(mtmDllInfo);
	CleanupStack::PopAndDestroy(dummyRegisterMtmDllObserver);
	}
Пример #6
0
/**
  Auxiliary function for T-CoGridStep-RunTestStepL.\n
  Creates a File Store and returns the pointer.\n
 
  @return FileStore pointer used for storing persistant data.\n 
 
*/
CFileStore* CTestCoeGridAppUi::CreateStoreLC(RFile &aFile)
	{
    CFileStore *store=CDirectFileStore::NewLC(aFile);
	TUid uid;
	uid.iUid=TUint32('G'|('R'<<8)|('D'<<16));
	store->SetTypeL(TUidType(KDirectFileStoreLayoutUid,uid));
    return(store);
	}
Пример #7
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
	}
void CAgnCalendarConverter::ConstructL(CAgnServFile& aAgnServerFile)
/** @internalComponent */
	{ 
	iOutModelStreamIdSet = CAgnModelStreamIdSet::NewL();
	iOutEntryManager = CAgnEntryManager::NewL();
	iAgnServerFile = &aAgnServerFile;
	
	// Get the original (old version) stream store from the CAgnServFile
	//
	iInputStreamStore = iAgnServerFile->StoreL();
	__ASSERT_ALWAYS(iInputStreamStore, User::Leave(KErrCorrupt));
	
	// Create the output stream store
	//
	TParsePtrC fullFileName(iAgnServerFile->FileName());
	HBufC* fileName = HBufC::NewLC(fullFileName.Drive().Length() + 
								   fullFileName.NameAndExt().Length() +
								   KUpdatedAgendaFileExtension().Length());
	TPtr fileNamePtr(fileName->Des());
	fileNamePtr.Append(fullFileName.Drive());
	fileNamePtr.Append(fullFileName.NameAndExt());
	fileNamePtr.Append(KUpdatedAgendaFileExtension);
	
	// Create the output stream store where converted information will be kept
	// This code copied from CAgnServerSession::CreateAgendaFileL() and CAgnEntryModel::CreateL(CStreamStore& aStore)
	//
	iOutputStreamStore = iAgnServerFile->Server().FileMgr()->CreateAgendaFileLC(fileNamePtr);
	CleanupStack::Pop(iOutputStreamStore);
	CleanupStack::PopAndDestroy(fileName);
	iOutputStreamStore->SetTypeL(TUidType(KPermanentFileStoreLayoutUid, KUidAppDllDoc, KUidAgnApp));
	
    iOutEntryManager->SetStore(*iOutputStreamStore);
        
	// Create the network of stream Ids needed by the model
	TStreamId headstreamId = iOutModelStreamIdSet->CreateL(*iOutputStreamStore, CalFileVersionUtils::CurrentFileVersion());
	
	// Create the stream dictionary for iOutputStreamStore and keep headstreamId in it
	//
	iDictionary = CStreamDictionary::NewL();
	iDictionary->AssignL(KUidAgnModel, headstreamId);
	
    // Set stream dictionary in stream store
	TApaAppIdentifier dummyApp(KUidAgnModel, KNullDesC());
	CApaProcess::WriteRootStreamL(*iOutputStreamStore,*iDictionary, dummyApp);
	
	iOutputTzRuleIndex = CAgnTzRuleIndex::NewL(*iDictionary, *iOutputStreamStore);
	}
Пример #9
0
// -----------------------------------------------------------------------------
// RDosServer::StartServer
// Creates the server thread/process
// -----------------------------------------------------------------------------
EXPORT_C TInt RDosServer::StartServer() const
{
    API_TRACE_( "[DOSSERVER] RDosServer::StartServer()" );

    TInt ret(KErrNone);
	TRequestStatus status;
    // IPCv2: TSignal no longer used, but still passed to threadfunction as 
	// otherwise API change would be required.
	CDosServer::TSignal signal( status );

	// Create startup semaphore
	RSemaphore startupSemaphore;
	ret = startupSemaphore.CreateGlobal( KServerStartupSemaphoreName, 0 );

	if ( ret == KErrAlreadyExists )
		{
		// The server is starting up, but has not yet started 
		startupSemaphore.OpenGlobal( KServerStartupSemaphoreName );
		startupSemaphore.Wait(); // wait until the server has started up.
		startupSemaphore.Close();
		return ret;
		}

	// launch server thread (emulator) or process (Target platform)

	RProcess server;

	ret = server.Create( KDosServerExe, signal.Get(),
                       TUidType( KNullUid, KNullUid, KDosServerUid ),
                       EOwnerThread );

	if ( ret )
	{
		startupSemaphore.Close();
		return ret;
	}

	server.SetPriority(EPriorityHigh);

	server.Resume();
	server.Close();

	startupSemaphore.Wait();
	startupSemaphore.Close();

	return KErrNone;
}
Пример #10
0
LOCAL_C void CorruptIndexFileL(TInt aMode)
	{
	switch (aMode)
		{
		case 0: // uicode/narrow conflict
			{
			theUtils->FileSession().Delete(KMsvDefaultIndexFile2);
			CPermanentFileStore* indexStore = NULL;
			TRAPD (bogus, indexStore = CPermanentFileStore::CreateL(theUtils->FileSession(), KMsvDefaultIndexFile2, EFileShareExclusive|EFileWrite));
			indexStore->SetTypeL(TUidType(KPermanentFileStoreLayoutUid, KNullUid)); // 2nd uid should be KUidMsvIndexFile
			indexStore->CommitL();
			delete indexStore;
			break;
			}
		default:
			test(EFalse);
		}
	}
Пример #11
0
extern "C" TLinAddr GetEka1ExeEntryPoint()
	{
	TLinAddr a = 0;
	RLibrary l;
	TInt r = l.Load(KEka1EntryStubName, KNullDesC, TUidType(KDynamicLibraryUid, KEka1EntryStubUid));
	if (r == KErrNone)
		r = l.Duplicate(RThread(), EOwnerProcess);
	if (r == KErrNone)
		{
		a = (TLinAddr)l.Lookup(1);
		if (!a)
			r = KErrNotSupported;
		}
	if (r != KErrNone)
		RThread().Kill(r);
	Exec::SetReentryPoint(a);
	return a;
	}
/**
  Function : ExecuteActionL
  Description		: Launches the schsendexe.exe and verifies the result of process 
					  completion with that of the expected result.
  @internalTechnology
  @param			: none
  @return			: void
  @pre	 
  @post	: none
*/
void CMtfTestActionLaunchSchSendExe::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionLaunchSchSendExe);
	// Expected result
	TInt expectedResult  = KErrPermissionDenied;
	
	TBuf<20> cmdString;
	
	// Return KErrNotSupported in case of Wins
	TInt returnValue = KErrNotSupported;
	
	TRequestStatus status = KRequestPending;

	RProcess process;					
	User::LeaveIfError(process.Create(KMsvSchSendExe, cmdString, TUidType(KNullUid, KNullUid, KMsvSchSendExeUid)));
	TestCase().INFO_PRINTF2(_L("RProcess::Create() is successful %S "), &KTestActionLaunchSchSendExe);

	// Make the process eligible for execution
	process.Logon(status);
	process.Resume();

	// Wait for the process completion
	User::WaitForRequest(status);
				
	// Check the exit reason of the process.If Panic occurs the return value is set to KErrGeneral as the 
	// focus of test action is to check if KErrPermissionDenied is returned.
	returnValue = (process.ExitType() == EExitPanic)? KErrGeneral: status.Int();

	process.Close();

	TestCase().INFO_PRINTF4(_L("Test Action %S completed with %d, while expected %d "), &KTestActionLaunchSchSendExe,returnValue, expectedResult );
	
	if(returnValue != expectedResult )
		{
		TestCase().SetTestStepResult(EFail);
		}
		
	TestCase().ActionCompletedL(*this);
	}
Пример #13
0
void DoExecuteL(const TDesC& aCmd)
	{
	CActiveScheduler* activeSch = new (ELeave) CActiveScheduler();
	CleanupStack::PushL(activeSch);
	CActiveScheduler::Install(activeSch);

	RProcess process;
	User::LeaveIfError(process.Create(KMsvAutoSendExe, aCmd,
							TUidType(KNullUid, KNullUid, KMsvAutoSendExeUid)));
	
	TRequestStatus status = KRequestPending;
	process.Logon(status);
	process.Resume();
	User::WaitForRequest(status);

	//Check the process completion status
	TInt err = (process.ExitType() == EExitPanic) ? KErrGeneral: status.Int();
	process.Close();
	User::LeaveIfError(err);
	
	CleanupStack::PopAndDestroy(activeSch);
	}
Пример #14
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"));
    }
Пример #15
0
	TE32ImageUids(TUint32 aUid1, TUint32 aUid2, TUint32 aUid3) : TCheckedUid(TUidType(TUid::Uid(aUid1), TUid::Uid(aUid2), TUid::Uid(aUid3))) {}
Пример #16
0
//
// ToolsClientDefs::ServerUidType()
//
// Return the Uid associated with the server image
//
TUidType ToolsClientDefs::ServerUidType()
{
	return TUidType(KNullUid, KNullUid, KToolsServerUid);
}
Пример #17
0
// ---------------------------------------------------------
// CPosTp666::SetupTestPartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp666::SetupTestPartL(TInt aIndex)
    {
    iLog->Put(_L("StartL(TInt aIndex)"));
/* 
#ifdef __WINS__
	_LIT(KNotOnWins, "!!!!This test is NOT supported on WINS!!!!");
	LogErrorAndLeave(KNotOnWins);		
	
#endif
*/
TBuf<20> capability;
switch (aIndex)
{
    case 0:
    iLog->Put(_L("Part1"));
    capability.Zero();
    // Set to all cap but readuserdata and writeuserdata
    capability.Append(_L("27FFF"));
    break;
    
    case 1:
    iLog->Put(_L("Part2"));
    // Set to Set to all cap but writeuserdata
    capability.Append(_L("2FFFF"));
    break;
    
    case 2:
    iLog->Put(_L("Part3"));
    // Set to Set to all cap but readuserdata
    capability.Append(_L("37FFF"));
    break;
    
    case 3:
    iLog->Put(_L("Part4"));
    // Set to only readuserdata and writeuserdata
    capability.Append(_L("18000"));
    break;
    
    default:
    iLog->Put(_L("Default"));
    LogErrorAndLeave(_L("We should never come here"));
    break;
}
    // Only for target, on winscw use bat-script
	RProcess execlient;
	RFile file;
	RFs fileSession;
	User::LeaveIfError(fileSession.Connect());
	CleanupClosePushL(fileSession);
	CleanupClosePushL(file);
	CFileMan* fileMan = CFileMan::NewL(fileSession);
	CleanupStack::PushL(fileMan);	

    TBuf<100> buf;

    buf.Append(_L("CapabilityTests.exe "));
    buf.Append(capability);
    buf.Append(_L(" CapabilityTests_tmp.exe"));

    // Make call to SetCap
	TInt result = execlient.Create(KSetCapPath, 
		//_L("CapabilityTests.exe 3FFFF CapabilityTests_All.exe"),
		buf,
		TUidType(KNullUid, KNullUid, KNullUid));
	User::LeaveIfError(result);
	execlient.Resume();	//make the execlient visible
	User::After(800000); //Wait 0.8 s
	
	execlient.Close(); //Close handle to exe-client
		
	// now move file CapabilityTests_tmp.exe to CapabilityTests.exe
	TInt err = fileMan->Move(_L("c:\\sys\\bin\\CapabilityTests_tmp.exe"), _L("c:\\sys\\bin\\CapabilityTests.exe"), CFileMan::EOverWrite);
	if (err != KErrNone)
	    {
	    iLog->Put(_L("Move problem"));
	    LogErrorAndLeave(_L("Move problem"), err);
	    }

	CleanupStack::PopAndDestroy(fileMan); //fileMan
	CleanupStack::PopAndDestroy(&file); //file
	CleanupStack::PopAndDestroy(&fileSession); //fileSession

    // Prepare test conditions
    SetupTestEnvironmentL();
    
    buf.Zero();
    buf.Format(_L("SetCap done, Now Execute CapabilityTest TP107, part %d"), aIndex+1);
    TUtfwUserAnswer answer = iUserInfo->ShowDialog(buf, EUtfwDialogTypeOk, EFalse);
    //if(answer == EUtfwUserAnswerNo)
	}
Пример #18
0
LOCAL_C void testCheckedUid()
//
// Test checked UIDs
//
{

    test.Start(_L("All functions"));
    TCheckedUid check1;
    check1.Set(TUidType(g1));
    test(check1.UidType().IsValid()==TRUE);
    test(check1.UidType()[0]==g1);
    test(check1.UidType()[1]==KNullUid);
    test(check1.UidType()[2]==KNullUid);
    test(check1.UidType().MostDerived()==g1);
    test(check1.UidType().IsPresent(g1)==TRUE);
    test(check1.UidType().IsPresent(g2)==FALSE);
    test(check1.UidType().IsPresent(g3)==FALSE);
    TCheckedUid check2;
    check2.Set(TUidType(g1,g2));
    test(check2.UidType().IsValid()==TRUE);
    test(check2.UidType()[0]==g1);
    test(check2.UidType()[1]==g2);
    test(check2.UidType()[2]==KNullUid);
    test(check2.UidType().MostDerived()==g2);
    test(check2.UidType().IsPresent(g1)==TRUE);
    test(check2.UidType().IsPresent(g2)==TRUE);
    test(check2.UidType().IsPresent(g3)==FALSE);
    TCheckedUid check3;
    check3.Set(TUidType(g1,g2,g3));
    test(check3.UidType().IsValid()==TRUE);
    test(check3.UidType()[0]==g1);
    test(check3.UidType()[1]==g2);
    test(check3.UidType()[2]==g3);
    test(check3.UidType().MostDerived()==g3);
    test(check3.UidType().IsPresent(g1)==TRUE);
    test(check3.UidType().IsPresent(g2)==TRUE);
    test(check3.UidType().IsPresent(g3)==TRUE);
    HBufC8* pH=check3.Des().Alloc();
    TUidType t1(g3,check3.UidType()[1],check3.UidType()[2]);
    check3=t1;
    test(check3.UidType().IsValid()==TRUE);
    TUidType t2(g3,g1,check3.UidType()[2]);
    check3=t2;
    test(check3.UidType().IsValid()==TRUE);
    TUidType t3(g3,g1,g2);
    check3=t3;
    test(check3.UidType().IsValid()==TRUE);
    test(check3.UidType()[0]==g3);
    test(check3.UidType()[1]==g1);
    test(check3.UidType()[2]==g2);
    test(check3.UidType().IsPresent(g1)==TRUE);
    test(check3.UidType().IsPresent(g2)==TRUE);
    test(check3.UidType().IsPresent(g3)==TRUE);
    check3.Set(*pH);
    test(check3.UidType().IsValid()==TRUE);
    test(check3.UidType()[0]==g1);
    test(check3.UidType()[1]==g2);
    test(check3.UidType()[2]==g3);
    test(check3.UidType().IsPresent(g1)==TRUE);
    test(check3.UidType().IsPresent(g2)==TRUE);
    test(check3.UidType().IsPresent(g3)==TRUE);
    TCheckedUid check4(*pH);
    delete pH;
    test(check4.UidType().IsValid()==TRUE);
    test(check4.UidType()[0]==g1);
    test(check4.UidType()[1]==g2);
    test(check4.UidType()[2]==g3);
//
    test.End();
}
Пример #19
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
	}
Пример #20
0
/**
 * UpdateDriveStatusL()
 * @param TUint: The index of the said drive in preferred
 *               drive list.
 */	
void CMsvIndexContext::UpdateDriveStatusL(TUint aDriveIndex, TDriveState& aStoreStatus)
	{
	aStoreStatus = EMsvInvalidDriveStatus;
	TBool deleteStore = EFalse;
	TMsvPreferredDrive driveEntry;
	CMsvPreferredDriveList::GetDriveList()->DriveInfoL(aDriveIndex, driveEntry);

	// Check if the media is available in the drive.
	TVolumeInfo volume;
	if (iServer.FileSession().Volume(volume, driveEntry.driveNum) != KErrNone)
		{
		CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvDriveDiskNotAvailableStatus);
		aStoreStatus = EMsvDriveDiskNotAvailableStatus;
		return;
		}
	
	// Validate the database. The function opens the database
	// and check its version and returns appropriate error.
	TRAPD(err, CMsvDBAdapter::ValidateDatabaseL(driveEntry.driveNum));
	
	// If no error, database is available.
	if(KErrNone == err)
		{
		CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreAvailableStatus);
		return;
		}
	
	// If the database is not found in the drive.
	if(KErrNotFound == err)
		{
		// Check if index file exists.
		RFile file;
		TParse parse;
		TPtrC drive(TDriveUnit(driveEntry.driveNum).Name());
		parse.Set(KMsvDefaultIndexFile2, &drive, NULL);
		TFileName indexFileName = parse.FullName();
		err = file.Open(iServer.FileSession(), indexFileName, EFileShareAny|EFileWrite);
		//file.Close();
		
		// If index file exists, set drive status to NOT SUPPORTED.
		if(KErrNone == err)
			{
			CPermanentFileStore* fileStoreIndex = NULL;
			TRAPD(permError, fileStoreIndex = CPermanentFileStore::FromL(file));
			if(KErrNone == permError)
				{
				// Check if the store is corrupt. If so then delete it.
				if (fileStoreIndex->Type() != TUidType(KPermanentFileStoreLayoutUid, KUidMsvIndexFile))
					{
					deleteStore = ETrue;
					}
				}
			// There was an error in getting a permanent filestore object.
			// Mark the message store for deletion.
			else
				{
				deleteStore = ETrue;
				}
			
			delete fileStoreIndex;
			
			//If message store is corrupted, wipe it.
			if(deleteStore)
				{
				TFileName mail2Folder = parse.DriveAndPath();
				CFileMan* fileMan = CFileMan::NewL(iServer.FileSession());
				// Remove the readonly attribute..
				(void)fileMan->Attribs(mail2Folder, 0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse);
				CleanupStack::PushL(fileMan);
				//Check if the mailfolder exists..
				TBool mail2FolderExists = BaflUtils::FileExists(iServer.FileSession(), mail2Folder);
				if(mail2FolderExists)
					{
					// Remove old message store if exists..
					User::LeaveIfError(fileMan->RmDir(mail2Folder));
					}
				CleanupStack::PopAndDestroy(fileMan);
				CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus);
				aStoreStatus = EMsvMessageStoreCorruptStatus;
				
				// Create store delete file in the respective drive.
				CreateStoreDeleteFile(driveEntry.driveNum);
				}
			//Else only set status as EMsvMessageStoreNotSupportedStatus.
			else
				{
				CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreNotSupportedStatus);
				aStoreStatus = EMsvMessageStoreNotSupportedStatus;
				}
			
			file.Close();
			return;
			}
		
		// If index file does not exists, set drive status to STORE UNAVAILABLE.
		if((KErrNotFound == err) || (KErrPathNotFound == err))
			{
			CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus);
			aStoreStatus = EMsvMessageStoreUnavailableStatus;
			return;
			}
			
		User::Leave(err);
		}
	
	//If a database exists, but is corrupt.
	if( (KSqlErrCorrupt == err) ||
		(KSqlErrNotDb   == err)
	  )
		{
		// If the database is corrupt, delete
		// the database and old message store.
		
		// Delete the database.
		TParse parse;
		TPtrC drive(TDriveUnit(driveEntry.driveNum).Name());
		parse.Set(KDBFileName, &drive, NULL);
		TFileName dBFile = parse.FullName();
		RSqlDatabase::Delete(dBFile);
		
		// Delete the message store. //ISSUE Can we use ResetAndCreateNewMailStore()?
		parse.Set(KMsvDefaultIndexFile2, &drive, NULL);
		TFileName mail2Folder = parse.DriveAndPath();
		CFileMan* fileMan = CFileMan::NewL(iServer.FileSession());
		// Remove the readonly attribute..
		(void)fileMan->Attribs(mail2Folder, 0, KEntryAttReadOnly, TTime(0), CFileMan::ERecurse);
		CleanupStack::PushL(fileMan);
		//Check if the mailfolder exists..
		TBool mail2FolderExists = BaflUtils::FileExists(iServer.FileSession(), mail2Folder);
		if( mail2FolderExists)
			{
			// Remove old message store if exists..
			User::LeaveIfError(fileMan->RmDir(mail2Folder));
			}
		CleanupStack::PopAndDestroy(fileMan);
		
		// Update the drive status.
		CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreUnavailableStatus);
		aStoreStatus = EMsvMessageStoreCorruptStatus;

		// Create store delete file in the respective drive.
		CreateStoreDeleteFile(driveEntry.driveNum);
		return;
		}
	   
	//If the database version is not supported.
	if(KErrNotSupported == err)
		{
		// If the drive as old version of database.
		CMsvPreferredDriveList::GetDriveList()->UpdateDriveStatusL(aDriveIndex, EMsvMessageStoreNotSupportedStatus);
		aStoreStatus = EMsvMessageStoreNotSupportedStatus;
		return;
		}

	// Do not return DB error.
	if(err <= KSqlErrGeneral)
		{
		// If DB Error, return KErrGeneral.
		User::LeaveIfError(KErrGeneral);
		}
	else
		{
		User::LeaveIfError(err);
		}
	}
void CSsmCommandListResourceReaderImpl::CInitialiser::DoInitialiseFirstStepL()
	{
	if (!iResourcePool.IsEmpty())
		{
		// already initialised, don't count this as an error
		iAction = EIdle;
		return;
		}

	// get list of command list resource filenames
	TFileName path(iPath);
	_LIT(KStar, "*");
	path.Append(KStar);
	const TUid KUidResourceFile = {0x101f4a6b};
	__ASSERT_ALWAYS(iResourceFileEntries == NULL, PanicNow(KPanicCmdResourceReader, ENonNullResourceFileEntries));
	// The error cannot be KErrPathNotFound as fallback will be used if there is not startup path
	// Even if there are no resource files, this succeeds
	// User::LeaveIfError handles other error conditions
	User::LeaveIfError(iFs.GetDir(path, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iResourceFileEntries));
	iEntryIndex = iResourceFileEntries->Count();

#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
#ifdef __WINS__
	if(!IsExtendedFolderDisabled())
	    {
	    TFileName extPath(iPath);
	    extPath.Replace(iPath.Length() - 1, 1, KExtendedCommandListPath);
	    iExtendedPath.CreateL(extPath);
	    DEBUGPRINT2(_L("Extended list path is %S"), &extPath);

	    extPath.Append(KStar);
	    const TInt extErr = (iFs.GetDir(extPath, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iExtendedResourceFileEntries));
	    if (KErrNone == extErr)
	        {
	        iExtendedEntryIndex = iExtendedResourceFileEntries->Count();
	        DEBUGPRINT2(_L("Number of resource files in extended folder : %d"), iExtendedEntryIndex);
	        }	    
	    }
#endif //__WINS__

	DEBUGPRINT2(_L("Number of resource files in ROM Drive : %d"),iEntryIndex );
	// Now, get list of command list resource filenames from system drive too
	TFileName sysPath(iSystemDrivePath);
	sysPath.Append(KStar);
	TInt err = (iFs.GetDir(sysPath, TUidType(KUidResourceFile, TUid::Uid(KUidSsmCommandListResourceFile)), ESortNone, iRssFileEntriesInSysDrive));
	if (KErrNone == err)
		{
		iSysDriveEntryIndex = iRssFileEntriesInSysDrive->Count();
		DEBUGPRINT2(_L("Number of resource files in System Drive : %d"),iSysDriveEntryIndex );
		}
	// all other error conditions are ignored as there is no compulsion for resource files to be present on system drive
	else if(KErrPathNotFound == err)
		{
		//the path for SCLs on system drive does not exist
		DEBUGPRINT1(_L("System Drive does not contain command lists"));
		}
	if(iEntryIndex == 0 && iSysDriveEntryIndex == 0)
		{
		DEBUGPRINT3(_L("Command list resource file directories (%S) and (%S) do not contain any command list resource files"), &path, &sysPath);
		SSMLOGLEAVE(KErrNotFound);
		}
#else
	if (iEntryIndex == 0)
		{
		DEBUGPRINT2(_L("Command list resource file directory (%S) does not contain any command list resource files"), &path);
		SSMLOGLEAVE(KErrNotFound);
		}
#endif
	iAction = EInitialiseNextStep;
	}
Пример #22
0
void CMsvIndexContext::CreateIndexL(TInt aDrive, TBool aSync)
	{
	__ASSERT_DEBUG(iProgress.iState == TMsvIndexLoadProgress::EIndexNotLoaded, PanicServer(EMsvBadIndexState));
	__ASSERT_DEBUG(RFs::IsValidDrive(aDrive), PanicServer(EMsvInvalidDrive));

	// Remember stuff
	iConfig.iDrive = TDriveUnit(aDrive);
	iObserverStatus = NULL;
	iRunMailInit = EFalse;

	// Set the drive for this index file
	TParse parse;
	TPtrC drive(iConfig.iDrive.Name());
	parse.Set(KMsvDefaultIndexFile2(), &drive, NULL);

	// Construct the message folder name etc
	iMessageFolder = parse.DriveAndPath();
	TFileName indexFileName = parse.FullName();
	// Adding the new code
	// Now we are creating the new database adapter.
	// Find out if the db exists
	// Construct the db file name
	parse.Set(KDBFileName, &drive, NULL);
	TFileName dBFile = parse.FullName();	
	RSqlDatabase db;
	TRAPD(err,db.OpenL(dBFile));
	TBool create=EFalse;
	
	// Database may be corrupted, so delete the old database and create a new one.
	if(err == KSqlErrCorrupt || err == KSqlErrNotDb )
		{
		RSqlDatabase::Delete(dBFile);
		create = ETrue;
		}
	// Database is not present. We need to check if the store is an old one.
	// If it is, we check if it is corrupt. 
	// If it is corrupt we can safely delete the store and create a new one
	// in its place. If not, then we leave with KErrNotSupported stating that
	// the old store is incompatible with this implementation of the message
	// store which uses an SQL database for the index.
	else if( err == KErrNotFound)
		{
		// Check if any of the old index files exist in the Mail2 folder.
		TParse parse1;
		parse1.Set(KMsvDefaultIndexFile, &drive, NULL); //old version of index file
		if( BaflUtils::FileExists(iServer.FileSession(), parse1.FullName()) ||
		    BaflUtils::FileExists(iServer.FileSession(), indexFileName))
			{
			// Open index store.
			RFile file;
			TInt error = file.Open(iServer.FileSession(), indexFileName, EFileShareAny|EFileWrite);
			
			// Check if we have an old 'legacy' version of the index file.
			CPermanentFileStore* index = NULL;
			TRAPD(permError, index = CPermanentFileStore::FromL(file));
			CleanupStack::PushL(index);
			if (KErrNone == permError)
				{
				// Check if the store is corrupt. If so then delete it.
				if (index->Type() != TUidType(KPermanentFileStoreLayoutUid, KUidMsvIndexFile))
					{
					create = ETrue;
					}
				}
			// There was an error in getting a permanent filestore object.
			// Delete the message store.
			else
				{
				create = ETrue;
				}
			
			CleanupStack::PopAndDestroy(); //index
			file.Close();
			
			// If the old store is valid, then throw an error.
			if(!create)
				{
				User::Leave(KErrNotSupported);
				}
			}
		//Index file does not exist in Mail2 folder. Go ahead with database creation.
		else
			{
			create = ETrue;
			}
		}	
	else
		{
		db.Close();
		User::LeaveIfError(err);
		}
	
	db.Close();
	
	if(!create)
		{
		// Check for database version.
		TRAP(err, CMsvDBAdapter::ValidateDatabaseL(dBFile));
		User::LeaveIfError(err);
		
		iIndexAdapter = CMsvIndexAdapter::OpenL(iServer, dBFile);
		ResetAndCreateNewMailStoreL(EFalse);
		}
	else
		{
		iIndexAdapter = CMsvIndexAdapter::NewL(iServer, dBFile);
		ResetAndCreateNewMailStoreL();
		CreateStoreDeleteFile();
		iRunMailInit = ETrue;
		
		TResourceReader reader;
		reader.SetBuffer(iBuf);	
		// Read initial entries from resources
		const TInt numberOfEntries = reader.ReadInt16();
		for (TInt index=0; index<numberOfEntries; ++index)
			{
			TMsvEntry newEntry;
			// Values from resource file			
			newEntry.iId = reader.ReadInt32();
			newEntry.iParentId = reader.ReadInt32();
			newEntry.iServiceId = reader.ReadInt32();
			newEntry.iType.iUid = reader.ReadInt32();
			newEntry.iMtm.iUid = reader.ReadInt32();
			newEntry.iData = reader.ReadInt32();
			newEntry.iDescription.Set(reader.ReadTPtrC());
			newEntry.iDetails.Set(reader.ReadTPtrC());
			newEntry.iDate.UniversalTime();
			newEntry.iSize=0;

			// Create the new entry
			// This is required to create associated service directory.
			TInt error = iServer.AddEntry(this, newEntry, KMsvServerId, EFalse);
			User::LeaveIfError(error);
			}
		iIndexAdapter->SetLocalServiceComplete();	
			
		}
	if(aSync)
		{
		IndexLoadingCompleted(KErrNone);
		}
	else
		{
		iStatus = KRequestPending;
		SetActive();
		TRequestStatus* st = &iStatus;
		User::RequestComplete(st, KErrNone);// do we need to propogate the error from adapter to here
		}
	}
Пример #23
0
//
// TrkTcbClientDefs::ServerUidType()
//
// Return the Uid associated with the server image
//
TUidType TrkTcbClientDefs::ServerUidType()
{
	return TUidType(KNullUid, KNullUid, KTrkTcbServerUid);
}