core/src/command_wrappers.h
changeset 95 b3ffff030d5c
parent 0 7f656887cf89
equal deleted inserted replaced
94:8df58d8c99e8 95:b3ffff030d5c
    53 	{
    53 	{
    54 public:
    54 public:
    55 	virtual void HandleCommandComplete(MCommand& aCommand, TInt aError) = 0;
    55 	virtual void HandleCommandComplete(MCommand& aCommand, TInt aError) = 0;
    56 	};
    56 	};
    57 
    57 
    58 
    58 class CCommandWrapperBase : public CActive, public MCommand
    59 class CCommandWrapperBase : public CBase, public MCommand
       
    60 	{
    59 	{
    61 protected:
    60 protected:
    62 	CCommandWrapperBase();
    61 	CCommandWrapperBase();
    63 	~CCommandWrapperBase();
    62 	~CCommandWrapperBase();
    64 	void BaseConstructL(const TDesC& aName);
    63 	void BaseConstructL(const TDesC& aName);
    72 	virtual TInt CmndReattachStderr(RIoEndPoint& aStderrEndPoint);
    71 	virtual TInt CmndReattachStderr(RIoEndPoint& aStderrEndPoint);
    73 	virtual TBool CmndIsDisownable() const;
    72 	virtual TBool CmndIsDisownable() const;
    74 	virtual void CmndDisown();
    73 	virtual void CmndDisown();
    75 private: // From MCommand.
    74 private: // From MCommand.
    76 	virtual void CmndRelease();
    75 	virtual void CmndRelease();
       
    76 protected: // From CActive
       
    77 	void RunL();
       
    78 	void DoCancel();
       
    79 
    77 private:
    80 private:
    78 	HBufC* iName;	///< This is used by concrete classes as they see fit.
    81 	HBufC* iName;	///< This is used by concrete classes as they see fit.
    79 	RIoReadHandle iStdin;
    82 	RIoReadHandle iStdin;
    80 	RIoWriteHandle iStdout;
    83 	RIoWriteHandle iStdout;
    81 	RIoWriteHandle iStderr;
    84 	RIoWriteHandle iStderr;
    89 		{
    92 		{
    90 		EUpdateEnvironment = 0x00000001,
    93 		EUpdateEnvironment = 0x00000001,
    91 		ESharedHeap = 0x00000002, // Any command that accesses gShell must have this set
    94 		ESharedHeap = 0x00000002, // Any command that accesses gShell must have this set
    92 		};
    95 		};
    93 public:
    96 public:
    94 	static CThreadCommand* NewL(const TDesC& aName, TCommandConstructor aCommandConstructor, TUint aFlags);
    97 	static CThreadCommand* NewL(const TDesC& aName, TCommandConstructor aCommandConstructor, TUint aFlags, MTaskRunner* aTaskRunner);
    95 	~CThreadCommand();
    98 	~CThreadCommand();
    96 private:
    99 private:
    97 	CThreadCommand(TCommandConstructor aCommandConstructor, TUint aFlags);
   100 	CThreadCommand(TCommandConstructor aCommandConstructor, TUint aFlags, MTaskRunner* aTaskRunner);
    98 	void ConstructL(const TDesC& aName);
   101 	void ConstructL(const TDesC& aName);
       
   102 	void RunL();
       
   103 	void DoCancel();
       
   104 	static void DoCommandThreadStartL(TAny* aSelf);
    99 private: // From MCommand.
   105 private: // From MCommand.
   100 	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
   106 	virtual TInt CmndRun(const TDesC& aCommandLine, IoUtils::CEnvironment& aEnv, MCommandObserver& aObserver, RIoSession& aIoSession);
   101 	virtual void CmndForeground();
   107 	virtual void CmndForeground();
   102 	virtual void CmndBackground();
   108 	virtual void CmndBackground();
   103 	virtual void CmndKill();
   109 	virtual void CmndKill();
   104 	virtual TInt CmndSuspend();
   110 	virtual TInt CmndSuspend();
   105 	virtual TInt CmndResume();
   111 	virtual TInt CmndResume();
   106 	virtual TExitType CmndExitType() const;
   112 	virtual TExitType CmndExitType() const;
   107 	virtual TExitCategoryName CmndExitCategory() const;
   113 	virtual TExitCategoryName CmndExitCategory() const;
   108 public:
       
   109 	class TArgs
       
   110 		{
       
   111 	public:
       
   112 		TArgs(TUint aFlags, CEnvironment& aEnv, TCommandConstructor aCommandConstructor, const TDesC& aCommandLine, TRequestStatus& aParentStatus);
       
   113 	public:
       
   114 		TUint iFlags;
       
   115 		CEnvironment& iEnv;
       
   116 		TCommandConstructor iCommandConstructor;
       
   117 		const TPtrC iCommandLine;
       
   118 		TRequestStatus* iParentStatus;
       
   119 		TThreadId iParentThreadId;
       
   120 		};
       
   121 	class CThreadWatcher : public CActive
       
   122 		{
       
   123 	public:
       
   124 		static CThreadWatcher* NewL();
       
   125 		~CThreadWatcher();
       
   126 		TInt Logon(CThreadCommand& aCommand, RThread& aThread, MCommandObserver& aObserver);
       
   127 		void SetActive();
       
   128 	private:
       
   129 		CThreadWatcher();
       
   130 	private: // From CActive.
       
   131 		virtual void RunL();
       
   132 		virtual void DoCancel();
       
   133 	private:
       
   134 		CThreadCommand* iCommand;
       
   135 		RThread* iThread;
       
   136 		MCommandObserver* iObserver;
       
   137 		};
       
   138 private:
   114 private:
   139 	TUint iFlags;
   115 	TUint iFlags;
   140 	TCommandConstructor iCommandConstructor;
   116 	TCommandConstructor iCommandConstructor;
   141 	MCommandObserver* iObserver;
   117 	MCommandObserver* iObserver;
   142 	TArgs* iArgs;
       
   143 	RThread iThread;
   118 	RThread iThread;
   144 	CThreadWatcher* iWatcher;
   119 	MTaskRunner* iTaskRunner;
       
   120 	CEnvironment* iSuppliedEnv;
       
   121 	HBufC* iCommandLine;
   145 	};
   122 	};
   146 
   123 
   147 
   124 
   148 class CProcessCommand : public CCommandWrapperBase
   125 class CProcessCommand : public CCommandWrapperBase
   149 	{
   126 	{