|
1 // job.h |
|
2 // |
|
3 // Copyright (c) 2006 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 |
|
14 #ifndef __JOB_H__ |
|
15 #define __JOB_H__ |
|
16 |
|
17 #include <e32base.h> |
|
18 #include "parser.h" |
|
19 |
|
20 class CJob; |
|
21 class RIoSession; |
|
22 class MConsole; |
|
23 class CParser; |
|
24 class CCommandFactory; |
|
25 |
|
26 class MJobObserver |
|
27 { |
|
28 public: |
|
29 virtual void HandleJobComplete(CJob& aJob, const TError& aError) = 0; |
|
30 }; |
|
31 |
|
32 |
|
33 class CJob : public CBase, public MParserObserver |
|
34 { |
|
35 public: |
|
36 enum TStatus |
|
37 { |
|
38 EPending, |
|
39 ERunning, |
|
40 EStopped, |
|
41 EComplete |
|
42 }; |
|
43 public: |
|
44 static CJob* NewL(TInt aId, const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory, MJobObserver* aObserver); |
|
45 ~CJob(); |
|
46 void Start(TBool& aIsForeground); |
|
47 void Kill(); |
|
48 void Suspend(); |
|
49 void Resume(); |
|
50 TInt BringToForeground(); |
|
51 void SendToBackground(); |
|
52 TInt Id() const; |
|
53 const TDesC* Name() const; |
|
54 TStatus Status() const; |
|
55 TInt Reattach(RIoEndPoint& aStdinEndPoint, RIoEndPoint& aStdoutEndPoint, RIoEndPoint& aStderrEndPoint); |
|
56 TBool IsDisownable() const; |
|
57 void Disown(); |
|
58 private: |
|
59 CJob(TInt aId, MJobObserver* aObserver, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv); |
|
60 void ConstructL(const TDesC& aCommandLine, RIoSession& aIoSession, RIoReadHandle& aStdin, RIoWriteHandle& aStdout, RIoWriteHandle& aStderr, IoUtils::CEnvironment& aEnv, CCommandFactory& aFactory); |
|
61 static TInt CompletionCallBack(TAny* aSelf); |
|
62 private: // From MParserObserver. |
|
63 virtual void HandleParserComplete(CParser& aParser, const TError& aError); |
|
64 private: |
|
65 TInt iId; |
|
66 TStatus iStatus; |
|
67 MJobObserver* iObserver; |
|
68 HBufC* iCommandLine; |
|
69 TError iCompletionError; |
|
70 CAsyncCallBack* iCompletionCallBack; |
|
71 CParser* iParser; |
|
72 }; |
|
73 |
|
74 #endif // __JOB_H__ |