|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * Header definition for EmailShutter |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef EMAILSHUTTER_H |
|
20 #define EMAILSHUTTER_H |
|
21 |
|
22 // Include Files |
|
23 #include <e32base.h> // CActive |
|
24 #include <e32cmn.h> // TUid |
|
25 #include <e32property.h> // RProperty |
|
26 |
|
27 ///////////////////////////////////////////////////////////////////////////// |
|
28 // FORWARD DECLARATIONS |
|
29 class CEmailServerMonitor; |
|
30 |
|
31 ///////////////////////////////////////////////////////////////////////////// |
|
32 // CONSTANT DEFINITIONS |
|
33 |
|
34 // Security policies used when defining P&S keys |
|
35 static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); |
|
36 static _LIT_SECURITY_POLICY_C1(KPowerMgmtPolicy,ECapabilityPowerMgmt); |
|
37 |
|
38 // Value to be set in shutdown P&S key. |
|
39 const TInt KEmailShutterPsValue = 1; |
|
40 |
|
41 // Maximum waiting times used to wait processes to close themselves gracefully |
|
42 const TInt KTimeToWaitApplicationsInSeconds = 2; |
|
43 const TInt KMaxTimeToWaitClientsInSeconds = 10; |
|
44 const TInt KMaxTimeToWaitPluginsInSeconds = 10; |
|
45 const TInt KMaxTimeToWaitMsgStoreInSeconds = 5; |
|
46 |
|
47 // Cycle length (in seconds) to check if some processes are still running |
|
48 const TInt KWaitTimeCycleInSeconds = 2; |
|
49 |
|
50 // Format string used with process finder to find processes by their UID |
|
51 _LIT( KFormatProcessFinderByUid, "*[%x]*" ); |
|
52 // Length of the formatted process finder string, basically length of |
|
53 // KFormatProcessFinderByUid + length of 32 bit number in hexadecimal format |
|
54 const TInt KFormatProcessFinderByUidLength = 12; |
|
55 |
|
56 |
|
57 ///////////////////////////////////////////////////////////////////////////// |
|
58 // CLASS DECLARATION |
|
59 |
|
60 /** |
|
61 * Class CEmailShutter implements functionality that shuts down all email |
|
62 * related services when IAD/sisx update starts. Shutdown is initiated by a |
|
63 * Publish & Subscribe event sent by email installation initiator. |
|
64 */ |
|
65 NONSHARABLE_CLASS( CEmailShutter ) : public CActive |
|
66 { |
|
67 |
|
68 public: // Public construcor and destructor |
|
69 /** |
|
70 * Two-phased class constructor. |
|
71 */ |
|
72 static CEmailShutter* NewL(); |
|
73 |
|
74 /** |
|
75 * Two-phased class constructor, leaves created object in cleanup stack. |
|
76 */ |
|
77 static CEmailShutter* NewLC(); |
|
78 |
|
79 /** |
|
80 * Destructor of CEmailShutter class. |
|
81 */ |
|
82 ~CEmailShutter(); |
|
83 |
|
84 public: // Public member functions |
|
85 |
|
86 /** |
|
87 * Start observing shutdown event. |
|
88 */ |
|
89 void StartObservingShutdownEvent(); |
|
90 |
|
91 /** |
|
92 * Set P&S key after installation is done |
|
93 */ |
|
94 void SetPsKeyInstallationFinished(); |
|
95 |
|
96 /** |
|
97 * Restart needed services after installation is finished |
|
98 */ |
|
99 void RestartServicesAfterInstallation(); |
|
100 |
|
101 /** |
|
102 * Set pointer to Email Server Monitor object |
|
103 */ |
|
104 void SetMonitor( CEmailServerMonitor* aMonitor ); |
|
105 |
|
106 private: // Private definitions |
|
107 |
|
108 /** |
|
109 * Definition of possible killing modes when killing processes gracelessly |
|
110 */ |
|
111 enum TEmailShutterKillingMode |
|
112 { |
|
113 EKillingModeAll, |
|
114 EKillingModeClients, |
|
115 EKillingModePlugins, |
|
116 EKillingModeMsgStore |
|
117 }; |
|
118 |
|
119 private: // Private constructors |
|
120 /** |
|
121 * Default class constructor. |
|
122 * Only NewL can be called |
|
123 */ |
|
124 CEmailShutter(); |
|
125 |
|
126 /** |
|
127 * Second phase class constructor. |
|
128 */ |
|
129 void ConstructL(); |
|
130 |
|
131 private: // From base class CActive |
|
132 |
|
133 void RunL(); |
|
134 void DoCancel(); |
|
135 |
|
136 private: // Private member functions |
|
137 |
|
138 /** |
|
139 * Highest level function to close everything in right order |
|
140 */ |
|
141 void StartShutdown(); |
|
142 |
|
143 /** |
|
144 * End client applications gracefully |
|
145 */ |
|
146 void EndClients(); |
|
147 |
|
148 /** |
|
149 * End UI applications gracefully |
|
150 */ |
|
151 void EndApplicationsL(); |
|
152 |
|
153 /** |
|
154 * Define and publish the P&S key to inform all related services about the |
|
155 * installation, so that they can shutdown themselves gracefully |
|
156 */ |
|
157 void PublishPsKey( TInt aKey ); |
|
158 |
|
159 /** |
|
160 * Closes all non-email related plugins/services |
|
161 */ |
|
162 void Close3rdPartyServices(); |
|
163 |
|
164 /** |
|
165 * Sends command to Always Online server to stop fs email plugin |
|
166 */ |
|
167 void CloseAOPluginL(); |
|
168 |
|
169 /** |
|
170 * Sends command to Always Online server to start fs email plugin |
|
171 */ |
|
172 void StartAoPluginL() const; |
|
173 |
|
174 /** |
|
175 * Closes PCS (Predictive Contact Search) server |
|
176 */ |
|
177 void ClosePcsServerL(); |
|
178 |
|
179 /** |
|
180 * Starts PCS (Predictive Contact Search) server |
|
181 */ |
|
182 void StartPcsServerL() const; |
|
183 |
|
184 /** |
|
185 * Try to find the UID given as parameter from the array given as parameter. |
|
186 * |
|
187 * @param aSid Process UID to be searched |
|
188 * @param aArray Array from where to search |
|
189 * @param aArrayCount Item count of the aArray |
|
190 * @return ETrue if the UID can be found from the array, otherwise EFalse. |
|
191 */ |
|
192 TBool FindFromArray( |
|
193 const TUid aSid, |
|
194 const TUid aArray[], |
|
195 const TInt aArrayCount ); |
|
196 |
|
197 /** |
|
198 * Checks does this UID belong to the list of the services that we need to |
|
199 * close down. |
|
200 * |
|
201 * @param aSid Process UID to check |
|
202 * @param aMode Killing mode, are we now killing clients, plugins or msg store |
|
203 * @return ETrue if this is one of the services we need to close in specified |
|
204 * mode, otherwise EFalse |
|
205 */ |
|
206 TBool NeedToKillThisProcess( |
|
207 const TUid aSid, |
|
208 const TEmailShutterKillingMode aMode ); |
|
209 |
|
210 /** |
|
211 * Kills all the related processes gracelessly. This is used as a backup for |
|
212 * those processes that didn't close themselves gracefully. |
|
213 * |
|
214 * @param aMode Process killing mode as defined in TEmailShutterKillingMode |
|
215 * @param aOnlyCheckIfRunning If EFalse (default value) when calling this |
|
216 * function, it kills all the processes that match the mode and |
|
217 * are running. If ETrue when calling this function, it only |
|
218 * checks if at least one process needs to be killed (is running). |
|
219 * @return ETrue if at least one process was killed or need to be killed. |
|
220 */ |
|
221 TBool KillEmAll( const TEmailShutterKillingMode aMode = EKillingModeAll, |
|
222 const TBool aOnlyCheckIfRunning = EFalse ); |
|
223 |
|
224 /** |
|
225 * Waits in cycles and checks between cycles have all relevant processes |
|
226 * closed or do we still need to wait. Returns when either aMaxWaitTime |
|
227 * has elapsed or when all relevant processes have been shutdown. |
|
228 * |
|
229 * @param aMaxWaitTime Maximum time to wait in seconds |
|
230 * @param aMode Killing mode, are we now killing clients, plugins or msg |
|
231 * store. Used to determine are there still some processes |
|
232 * that have not closed themselves. |
|
233 */ |
|
234 void WaitInCycles( const TInt aMaxWaitTime, |
|
235 const TEmailShutterKillingMode aMode ); |
|
236 |
|
237 private: // Member variables |
|
238 |
|
239 /** |
|
240 * Publish & Subscribe property to be observed. |
|
241 */ |
|
242 RProperty iInstStatusProperty; |
|
243 |
|
244 /** |
|
245 * Pointer to Email Server Monitor |
|
246 * Not owned |
|
247 */ |
|
248 CEmailServerMonitor* iMonitor; |
|
249 |
|
250 }; |
|
251 |
|
252 |
|
253 #endif // EMAILSHUTTER_H |
|
254 |