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