|
1 /* |
|
2 * Copyright (c) 1020 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: process monitor. |
|
15 */ |
|
16 |
|
17 |
|
18 #ifndef __HS_PROCESS_MONITOR__ |
|
19 #define __HS_PROCESS_MONITOR__ |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 /** |
|
24 * MHsProcessMonitorObserver |
|
25 * |
|
26 * Monitor component observer. |
|
27 * |
|
28 * @since S60 5.2 |
|
29 */ |
|
30 class MHsProcessMonitorObserver |
|
31 { |
|
32 public: |
|
33 /** |
|
34 * Called when monitored process is ended. |
|
35 * |
|
36 * @param aExitType Exit type |
|
37 * @param aExitReason Exit reason |
|
38 * @param aExitCategory Exit category |
|
39 */ |
|
40 virtual void ProcessEnded( const TExitType& aExitType, |
|
41 const TInt aExitReason, |
|
42 const TExitCategoryName& aExitCategory ) = 0; |
|
43 |
|
44 /** |
|
45 * Called when error occured during monitoring. |
|
46 * |
|
47 * @param aError System wide error code. |
|
48 */ |
|
49 virtual void ProcessMonitoringError( TInt aError ) = 0; |
|
50 }; |
|
51 |
|
52 /** |
|
53 * HsProcessMonitor |
|
54 * |
|
55 * Component for monitoring process states. |
|
56 * |
|
57 * @since S60 5.2 |
|
58 */ |
|
59 class CHsProcessMonitor : public CActive |
|
60 { |
|
61 public: |
|
62 /** |
|
63 * Create new monitor |
|
64 * |
|
65 * @param aProcessName process id |
|
66 * @param aObserver monitor observer |
|
67 * @since S60 5.2 |
|
68 */ |
|
69 static CHsProcessMonitor* NewL( const TInt aProcessId, |
|
70 MHsProcessMonitorObserver& aObserver ); |
|
71 |
|
72 /** |
|
73 * Destructor |
|
74 * |
|
75 * @since S60 5.2 |
|
76 */ |
|
77 ~CHsProcessMonitor(); |
|
78 |
|
79 /** |
|
80 * Attach monitor |
|
81 * |
|
82 * @return TInt System wide error code. |
|
83 * @since S60 5.2 |
|
84 */ |
|
85 TInt AttachMonitor(); |
|
86 |
|
87 /** |
|
88 * Start monitor |
|
89 * |
|
90 * @return TInt System wide error code. |
|
91 * @since S60 5.2 |
|
92 */ |
|
93 TInt StartMonitor(); |
|
94 |
|
95 protected: |
|
96 /** |
|
97 * C++ constructor |
|
98 * |
|
99 * @param aProcessName process id |
|
100 * @param aObserver watchdog observer. |
|
101 * @since S60 5.2 |
|
102 */ |
|
103 CHsProcessMonitor( const TInt aProcessId, |
|
104 MHsProcessMonitorObserver& aObserver ); |
|
105 |
|
106 /** |
|
107 * Symbian 2nd phase constructor |
|
108 * |
|
109 * @since S60 5.2 |
|
110 */ |
|
111 void ConstructL(); |
|
112 |
|
113 private: // From CActive |
|
114 /** |
|
115 * From CActive |
|
116 */ |
|
117 void RunL(); |
|
118 |
|
119 /** |
|
120 * From CActive |
|
121 * |
|
122 * @since S60 5.2 |
|
123 */ |
|
124 void DoCancel(); |
|
125 |
|
126 /** |
|
127 * From CActive |
|
128 * |
|
129 * @since S60 5.2 |
|
130 */ |
|
131 TInt RunError( TInt aError ); |
|
132 |
|
133 private: // New methods |
|
134 /** |
|
135 * Close process handle if open |
|
136 * |
|
137 * @since S60 5.2 |
|
138 */ |
|
139 void SecureProcessHandleAsClosed(); |
|
140 |
|
141 private: |
|
142 // process id |
|
143 TInt iProcessId; |
|
144 |
|
145 // watchdog observer |
|
146 MHsProcessMonitorObserver& iObserver; |
|
147 |
|
148 // Process handle |
|
149 RProcess iProcess; |
|
150 |
|
151 // boolean to represent whether process handle is open |
|
152 TBool iProcessHandleOpen; |
|
153 }; |
|
154 |
|
155 #endif // __HS_PROCESS_MONITOR__ |