Ejemplo n.º 1
0
void CScrHelperSession::GetFileHandleL(RFs& aFs, const RMessage2& aMessage, const TDesC& aFileName)
	{
	DEBUG_PRINTF2(_L("Returning file handle of %S."), &aFileName);
	RBuf filePath;
	filePath.CreateL(aFileName.Length());
	filePath.CleanupClosePushL();
	filePath.Copy(aFileName);
	filePath[0] = aFs.GetSystemDriveChar();
	TInt err = aFs.MkDirAll(filePath);
	if(KErrNone != err && KErrAlreadyExists != err)
		{
		DEBUG_PRINTF3(_L("An error (%d) occured while making all directories of %S."), err, &filePath);
		User::Leave(err);
		}
	
	RFile file;
	TEntry entry;

	if(KErrNone == aFs.Entry(filePath, entry))
		{ // The file exists, just open it.
		User::LeaveIfError(file.Open(aFs, filePath, EFileShareAny|EFileWrite));
		}    
	else
		{ // The file doesn't exist. First, check if the requested file is database or journal file.
		if(KScrDatabaseFilePath() == aFileName)
			{ // This is the database file. Copy the default one into the requested location.
			DEBUG_PRINTF(_L8("SCR database file doesn't exist. It is being copied from ROM"));
			CopyDbFromROMToSystemL(aFs, filePath);
			 // Then, open the file.
			User::LeaveIfError(file.Open(aFs, filePath, EFileShareAny|EFileWrite));
			}
		else
			{ // This is the journal file, simply create an empty file.
			User::LeaveIfError(file.Create(aFs, filePath, EFileShareAny|EFileWrite));
			}
		}
	CleanupStack::PopAndDestroy(&filePath);
	CleanupClosePushL(file);
	
	// Store the RFile handle into the package buffer in slot 0 and complete the message with the RFs handle
	User::LeaveIfError(file.TransferToClient(aMessage, 0));
	ASSERT(aMessage.IsNull());  // The message should have been completed

	CleanupStack::PopAndDestroy(&file);
	}
Ejemplo n.º 2
0
void MainL()
	{
	test.Title(_L("c:\\upstest.log"));
	test.Start(_L(" @SYMTestCaseID:SEC-UPS-0001 Testing RUpsSubsession "));

	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	
	TBuf<21> notifierConfig(_L("!:\\upsrefnotifier.txt"));
	notifierConfig[0] = fs.GetSystemDriveChar();

	TBuf<35> database(_L("!:\\Private\\10283558\\database\\ups.db"));
	database[0] = fs.GetSystemDriveChar();

	TInt lineLength = User::CommandLineLength();
	switch(lineLength)
		{
	default:
		case 2:
			(void) fs.Delete(database);
			// Fall through to also delete notifier config file
		case 1:
			(void) fs.Delete(notifierConfig);
			break;
		case 0:
			{
			// No args so run in silent mode
			(void) fs.Delete(database);
			(void) fs.Delete(notifierConfig);
			RFile file;
			User::LeaveIfError(file.Create(fs, notifierConfig, EFileShareExclusive | EFileWrite));
			User::LeaveIfError(file.Write(_L8("Never")));
			file.Close();
			break;
			}
		}

	//RThread ourThread;
	//ourThread.SetPriority(EPriorityMore);
	//ourThread.Close();
//	User::SetProcessCritical(User::ESystemCritical);
//	User::SetCritical(User::ESystemCritical);
	TestOpenCloseSession();


	TInt r = sTestSession.Connect();
	test(r == KErrNone);
	User::LeaveIfError(r);

	TestRUpsSubsessionDeathL();

	TestOpenCloseSubsession();

	TestSwiObserverSecurityL();
	
	RThread thd;
	r = sTestSubsession.Initialise(sTestSession, thd);
	test(r == KErrNone);
	User::LeaveIfError(r);
	
	TestFlurryL();

	TestAuthoriseL();
	
	sTestSubsession.Close();

	TestRUpsSubsession();

	TestRUpsManagementL();

	sTestSession.ShutdownServer();

	// Close top level session (low level session was closed by
	// ShutdownServer, but we still need to do the RUpsSession
	// cleanup).
	sTestSession.Close();

	(void) fs.Delete(notifierConfig);
	CleanupStack::PopAndDestroy(&fs);
	
	test.End();
	test.Close();
}