core/src/command_factory.cpp
changeset 78 b3ffff030d5c
parent 69 849a0b46c767
child 87 63fd51b1ff80
equal deleted inserted replaced
77:8df58d8c99e8 78:b3ffff030d5c
    23 #include "gobble.h"
    23 #include "gobble.h"
    24 #include "xmodem.h"
    24 #include "xmodem.h"
    25 #include "ymodem.h"
    25 #include "ymodem.h"
    26 #include "version.h"
    26 #include "version.h"
    27 #include "ciftest.h"
    27 #include "ciftest.h"
       
    28 #include "worker_thread.h"
    28 
    29 
    29 //
    30 //
    30 // Constants.
    31 // Constants.
    31 //
    32 //
    32 
    33 
    82 CCommandFactory::~CCommandFactory()
    83 CCommandFactory::~CCommandFactory()
    83 	{
    84 	{
    84 	Cancel();
    85 	Cancel();
    85 	iCommands.ResetAndDestroy();
    86 	iCommands.ResetAndDestroy();
    86 	iLock.Close();
    87 	iLock.Close();
       
    88 	delete iThreadPool;
    87 	}
    89 	}
    88 
    90 
    89 TInt CompareCommandNames(const CCommandConstructorBase& aCommand1, const CCommandConstructorBase& aCommand2)
    91 TInt CompareCommandNames(const CCommandConstructorBase& aCommand1, const CCommandConstructorBase& aCommand2)
    90 	{
    92 	{
    91 	return aCommand1.CommandName().Compare(aCommand2.CommandName());
    93 	return aCommand1.CommandName().Compare(aCommand2.CommandName());
   248 
   250 
   249 void CCommandFactory::ConstructL()
   251 void CCommandFactory::ConstructL()
   250 	{
   252 	{
   251 	User::LeaveIfError(iLock.CreateLocal());
   253 	User::LeaveIfError(iLock.CreateLocal());
   252 	User::LeaveIfError(iFs.DriveList(iDriveList));
   254 	User::LeaveIfError(iFs.DriveList(iDriveList));
       
   255 	iThreadPool = CThreadPool::NewL();
   253 
   256 
   254 	AddThreadCommandL(CCmdExit::NewLC); // Note, this command should never execute as 'exit' has handled explicitly by CParser. It exists so that 'exit' appears in fshell's help list and also to support 'exit --help'.
   257 	AddThreadCommandL(CCmdExit::NewLC); // Note, this command should never execute as 'exit' has handled explicitly by CParser. It exists so that 'exit' appears in fshell's help list and also to support 'exit --help'.
   255 	AddThreadCommandL(CCmdHelp::NewLC, CThreadCommand::ESharedHeap);
   258 	AddThreadCommandL(CCmdHelp::NewLC, CThreadCommand::ESharedHeap);
   256 	AddThreadCommandL(CCmdCd::NewLC, CThreadCommand::EUpdateEnvironment);
   259 	AddThreadCommandL(CCmdCd::NewLC, CThreadCommand::EUpdateEnvironment);
   257 	AddThreadCommandL(CCmdClear::NewLC);
   260 	AddThreadCommandL(CCmdClear::NewLC);
   427 		}
   430 		}
   428 	}
   431 	}
   429 
   432 
   430 void CCommandFactory::AddThreadCommandL(TCommandConstructor aConstructor, TUint aFlags)
   433 void CCommandFactory::AddThreadCommandL(TCommandConstructor aConstructor, TUint aFlags)
   431 	{
   434 	{
   432 	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aConstructor, aFlags);
   435 	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aConstructor, aFlags, iThreadPool);
   433 	AddCommandL(constructor);
   436 	AddCommandL(constructor);
   434 	CleanupStack::Pop(constructor);
   437 	CleanupStack::Pop(constructor);
   435 	}
   438 	}
   436 
   439 
   437 void CCommandFactory::AddThreadCommandL(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aAttributes, TUint aFlags)
   440 void CCommandFactory::AddThreadCommandL(const TDesC& aCommandName, TCommandConstructor aConstructor, TUint aAttributes, TUint aFlags)
   438 	{
   441 	{
   439 	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aCommandName, aConstructor, aFlags);
   442 	CCommandConstructorBase* constructor = CThreadCommandConstructor::NewLC(aCommandName, aConstructor, aFlags, iThreadPool);
   440 	constructor->SetAttributes(aAttributes);
   443 	constructor->SetAttributes(aAttributes);
   441 	AddCommandL(constructor);
   444 	AddCommandL(constructor);
   442 	CleanupStack::Pop(constructor);
   445 	CleanupStack::Pop(constructor);
   443 	}
   446 	}
   444 
   447 
   445 void CCommandFactory::AddAliasCommandL(const TDesC& aAliasName, TCommandConstructor aConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments, TUint aAttributes, TUint aFlags)
   448 void CCommandFactory::AddAliasCommandL(const TDesC& aAliasName, TCommandConstructor aConstructor, const TDesC* aAdditionalArguments, const TDesC* aReplacementArguments, TUint aAttributes, TUint aFlags)
   446 	{
   449 	{
   447 	CCommandConstructorBase* aliasedCommand = CThreadCommandConstructor::NewLC(aConstructor, aFlags);
   450 	CCommandConstructorBase* aliasedCommand = CThreadCommandConstructor::NewLC(aConstructor, aFlags, iThreadPool);
   448 	CCommandConstructorBase* constructor = CAliasCommandConstructor::NewLC(aAliasName, aliasedCommand, aAdditionalArguments, aReplacementArguments);
   451 	CCommandConstructorBase* constructor = CAliasCommandConstructor::NewLC(aAliasName, aliasedCommand, aAdditionalArguments, aReplacementArguments);
   449 	CleanupStack::Pop(2, aliasedCommand); // Now owned by "constructor".
   452 	CleanupStack::Pop(2, aliasedCommand); // Now owned by "constructor".
   450 	CleanupStack::PushL(constructor);
   453 	CleanupStack::PushL(constructor);
   451 	constructor->SetAttributes(aAttributes);
   454 	constructor->SetAttributes(aAttributes);
   452 	AddCommandL(constructor);
   455 	AddCommandL(constructor);