32 |
32 |
33 #include "threadmonitor.h" |
33 #include "threadmonitor.h" |
34 #include "queueprocessor.h" |
34 #include "queueprocessor.h" |
35 |
35 |
36 #ifndef SWI_TEXTSHELL_ROM |
36 #ifndef SWI_TEXTSHELL_ROM |
37 #include <apmstd.h> |
37 #include <apmstd.h> |
38 #include <apgcli.h> |
38 #include <apgcli.h> |
39 #include <apgwgnam.h> |
39 #include <apgwgnam.h> |
40 #include <apgtask.h> |
40 #include <apgtask.h> |
41 #endif |
41 #endif |
42 |
42 |
43 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
43 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
44 const TUint KInstallServerUid = 0x101F7295; |
44 const TUint KInstallServerUid = 0x101F7295; |
45 const TUint KSisRegistryServerUid = 0x10202DCA; |
45 const TUint KSisRegistryServerUid = 0x10202DCA; |
46 #endif |
46 #endif |
47 |
47 |
48 using namespace Swi; |
48 using namespace Swi; |
49 |
49 |
50 CServer2* CSisLauncherServer::NewLC() |
50 CServer2* CSisLauncherServer::NewLC() |
51 { |
51 { |
52 CSisLauncherServer* self=new(ELeave) CSisLauncherServer; |
52 CSisLauncherServer* self=new(ELeave) CSisLauncherServer; |
53 CleanupStack::PushL(self); |
53 CleanupStack::PushL(self); |
54 self->ConstructL(); |
54 self->ConstructL(); |
55 return self; |
55 return self; |
56 } |
56 } |
57 |
57 |
58 CSisLauncherServer::~CSisLauncherServer() |
58 CSisLauncherServer::~CSisLauncherServer() |
59 { |
59 { |
60 #ifndef SWI_TEXTSHELL_ROM |
60 #ifndef SWI_TEXTSHELL_ROM |
61 if (iBootMode != KTextShell) |
61 if (iBootMode != KTextShell) |
62 { |
62 { |
63 iWsSession.Close(); |
63 iWsSession.Close(); |
64 } |
64 } |
65 #endif |
65 #endif |
66 delete iShutdown; |
66 delete iShutdown; |
67 delete iQueueProcessor; |
67 delete iQueueProcessor; |
68 CSecurityPolicy::ReleaseResource(); |
68 CSecurityPolicy::ReleaseResource(); |
69 } |
69 } |
70 |
70 |
71 void CSisLauncherServer::ConstructL() |
71 void CSisLauncherServer::ConstructL() |
72 { |
72 { |
73 StartL(KSisLauncherServerName); |
73 StartL(KSisLauncherServerName); |
74 iShutdown = new (ELeave) CSisLauncherServerShutdown; |
74 iShutdown = new (ELeave) CSisLauncherServerShutdown; |
75 iShutdown->ConstructL(); |
75 iShutdown->ConstructL(); |
76 TInt connectErr = KErrNotFound; |
76 TInt connectErr = KErrNotFound; |
77 #ifndef SWI_TEXTSHELL_ROM |
77 #ifndef SWI_TEXTSHELL_ROM |
78 // Connect to Window Session |
78 // Connect to Window Session |
79 connectErr = iWsSession.Connect(); |
79 connectErr = iWsSession.Connect(); |
80 if (connectErr != KErrNotFound) |
80 if (connectErr != KErrNotFound) |
81 { |
81 { |
82 User::LeaveIfError(connectErr); |
82 User::LeaveIfError(connectErr); |
83 } |
83 } |
84 #endif |
84 #endif |
85 if (connectErr == KErrNotFound) |
85 if (connectErr == KErrNotFound) |
86 { |
86 { |
87 // emulator tests running in textshell or in textshell ROM (#def SWI_TEXTSHELL_ROM) |
87 // emulator tests running in textshell or in textshell ROM (#def SWI_TEXTSHELL_ROM) |
88 iBootMode = KTextShell; |
88 iBootMode = KTextShell; |
89 } |
89 } |
90 iQueueProcessor = CQueueProcessor::NewL(*this); |
90 iQueueProcessor = CQueueProcessor::NewL(*this); |
91 } |
91 } |
92 |
92 |
93 CSession2* CSisLauncherServer::NewSessionL(const TVersion&,const RMessage2&) const |
93 CSession2* CSisLauncherServer::NewSessionL(const TVersion&,const RMessage2&) const |
94 { |
94 { |
95 return new(ELeave) CSisLauncherSession(); |
95 return new(ELeave) CSisLauncherSession(); |
96 } |
96 } |
97 |
97 |
98 void CSisLauncherServer::AddSession() |
98 void CSisLauncherServer::AddSession() |
99 { |
99 { |
100 ++iSessionCount; |
100 ++iSessionCount; |
101 |
101 |
102 DEBUG_PRINTF2(_L8("Sis Launcher Server - Adding Session (%d sessions total.)"), iSessionCount); |
102 DEBUG_PRINTF2(_L8("Sis Launcher Server - Adding Session (%d sessions total.)"), iSessionCount); |
103 |
103 |
104 CancelShutdown(); |
104 CancelShutdown(); |
105 } |
105 } |
106 |
106 |
107 void CSisLauncherServer::DropSession() |
107 void CSisLauncherServer::DropSession() |
108 { |
108 { |
109 --iSessionCount; |
109 --iSessionCount; |
110 |
110 |
111 DEBUG_PRINTF2(_L8("Sis Launcher Server - Dropping Session (%d sessions total.)"), iSessionCount); |
111 DEBUG_PRINTF2(_L8("Sis Launcher Server - Dropping Session (%d sessions total.)"), iSessionCount); |
112 |
112 |
113 if (0==iSessionCount && iShutdown) |
113 if (0==iSessionCount && iShutdown) |
114 { |
114 { |
115 DEBUG_PRINTF(_L8("Sis Launcher Server - Starting shutdown timer.")); |
115 DEBUG_PRINTF(_L8("Sis Launcher Server - Starting shutdown timer.")); |
116 // ignored if a long timer is active |
116 // ignored if a long timer is active |
117 iShutdown->StartShort(EFalse); |
117 iShutdown->StartShort(EFalse); |
118 } |
118 } |
119 } |
119 } |
120 /** |
120 /** |
121 * Cancels an existing shutdown timer before renabling with the long timeout. This is used to catch |
121 * Cancels an existing shutdown timer before renabling with the long timeout. This is used to catch |
122 * the case where we need to allow ECOM to work before killing the server. ECOM should finish scanning |
122 * the case where we need to allow ECOM to work before killing the server. ECOM should finish scanning |
123 * files within a couple of seconds of SWI finishing but just in case we allow ECOM a little longer. |
123 * files within a couple of seconds of SWI finishing but just in case we allow ECOM a little longer. |
124 * The other reason we have the timer is to handle the case where SWI mistakenly identified a plugin |
124 * The other reason we have the timer is to handle the case where SWI mistakenly identified a plugin |
125 * resource file, we don't want to hang around forever waiting for an event that never comes. |
125 * resource file, we don't want to hang around forever waiting for an event that never comes. |
126 * */ |
126 * */ |
127 void CSisLauncherServer::LongServerShutdown() |
127 void CSisLauncherServer::LongServerShutdown() |
128 { |
128 { |
129 DEBUG_PRINTF(_L8("Sis Launcher Server - Switching to long shutdown timer")); |
129 DEBUG_PRINTF(_L8("Sis Launcher Server - Switching to long shutdown timer")); |
130 if (iShutdown) |
130 if (iShutdown) |
131 { |
131 { |
132 iShutdown->StartLong(); |
132 iShutdown->StartLong(); |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 void CSisLauncherServer::CancelShutdown() |
136 void CSisLauncherServer::CancelShutdown() |
137 { |
137 { |
138 DEBUG_PRINTF(_L8("Sis Launcher Server - Cancelling shutdown timer")); |
138 DEBUG_PRINTF(_L8("Sis Launcher Server - Cancelling shutdown timer")); |
139 |
139 |
140 if (iShutdown) |
140 if (iShutdown) |
141 { |
141 { |
142 iShutdown->Cancel(); |
142 iShutdown->Cancel(); |
143 } |
143 } |
144 } |
144 } |
145 |
145 |
146 void CSisLauncherServer::ShortServerShutdown() |
146 void CSisLauncherServer::ShortServerShutdown() |
147 { |
147 { |
148 DEBUG_PRINTF(_L8("Sis Launcher Server - Re-enabling short shutdown timer")); |
148 DEBUG_PRINTF(_L8("Sis Launcher Server - Re-enabling short shutdown timer")); |
149 if (0==iSessionCount && iShutdown) |
149 if (0==iSessionCount && iShutdown) |
150 { |
150 { |
151 DEBUG_PRINTF(_L8("Sis Launcher Server - Starting shutdown timer")); |
151 DEBUG_PRINTF(_L8("Sis Launcher Server - Starting shutdown timer")); |
152 iShutdown->StartShort(ETrue); |
152 iShutdown->StartShort(ETrue); |
153 } |
153 } |
154 } |
154 } |
155 |
155 |
|
156 // All functions require TCB capability |
156 const TInt CSisLauncherServer::iRanges[iRangeCount] = |
157 const TInt CSisLauncherServer::iRanges[iRangeCount] = |
157 { |
158 { |
158 0, // All connect attempts |
159 0, // All connect attempts |
159 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
160 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
160 EParseSwTypeRegFile, // accessible by Installserver |
161 // Range of utility services for Post manufacture management of Layered Execution Environemnts |
161 EUnregisterSifLauncherMimeTypes, // accessible by SisRegistryServer |
162 EParseSwTypeRegFile, |
162 ENotifyApparcForApps, // accessible by Installserver and SisRegistry |
163 EUnregisterSifLauncherMimeTypes, |
163 EAsyncParseResourceFileSize, // accessible by all clients |
164 #endif |
164 #endif |
165 ESeparatorEndAll, |
165 ESeparatorEndAll, |
166 }; |
166 }; |
|
167 |
167 |
168 const TUint8 CSisLauncherServer::iElementsIndex[iRangeCount] = |
168 const TUint8 CSisLauncherServer::iElementsIndex[iRangeCount] = |
169 { |
169 { |
170 0, // Used by Client which is only swis and TCB is needed. |
170 0, // Used by Client which is only swis and TCB is needed. |
171 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
171 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
172 1, // Utility services used by InstallServer |
172 1, // Utility services used by InstallServer |
173 2, // Utility services used by SisRegistryServer |
173 2, // Utility services used by SisRegistryServer |
174 CPolicyServer::ECustomCheck, |
174 #endif |
175 CPolicyServer::EAlwaysPass, |
175 CPolicyServer::ENotSupported, |
176 #endif |
176 }; |
177 CPolicyServer::ENotSupported, |
|
178 }; |
|
179 |
177 |
180 const CPolicyServer::TPolicyElement CSisLauncherServer::iPolicyElements[] = |
178 const CPolicyServer::TPolicyElement CSisLauncherServer::iPolicyElements[] = |
181 { |
179 { |
182 {_INIT_SECURITY_POLICY_C1(ECapabilityTCB), CPolicyServer::EFailClient}, |
180 {_INIT_SECURITY_POLICY_C1(ECapabilityTCB), CPolicyServer::EFailClient}, |
183 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
181 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
184 {_INIT_SECURITY_POLICY_S0(KInstallServerUid), CPolicyServer::EFailClient}, |
182 {_INIT_SECURITY_POLICY_S0(KInstallServerUid), CPolicyServer::EFailClient}, |
185 {_INIT_SECURITY_POLICY_S0(KSisRegistryServerUid), CPolicyServer::EFailClient}, |
183 {_INIT_SECURITY_POLICY_S0(KSisRegistryServerUid), CPolicyServer::EFailClient}, |
186 #endif |
184 #endif |
187 }; |
185 }; |
188 |
186 |
189 const CPolicyServer::TPolicy CSisLauncherServer::iPolicy = |
187 const CPolicyServer::TPolicy CSisLauncherServer::iPolicy = |
190 { |
188 { |
191 0, //specifies all connect attempts need TCB |
189 0, //specifies all connect attempts need TCB |
192 iRangeCount, |
190 iRangeCount, |
193 iRanges, |
191 iRanges, |
194 iElementsIndex, |
192 iElementsIndex, |
195 iPolicyElements, |
193 iPolicyElements, |
196 }; |
194 }; |
197 |
195 |
198 |
196 |
199 // shutdown timer |
197 // shutdown timer |
200 |
198 |
201 CSisLauncherServerShutdown::~CSisLauncherServerShutdown() |
199 CSisLauncherServerShutdown::~CSisLauncherServerShutdown() |
202 { |
200 { |
203 Cancel(); |
201 Cancel(); |
204 } |
202 } |
205 |
203 |
206 void CSisLauncherServerShutdown::RunL() |
204 void CSisLauncherServerShutdown::RunL() |
207 { |
205 { |
208 CActiveScheduler::Stop(); |
206 CActiveScheduler::Stop(); |
209 } |
207 } |
210 |
208 |
211 void CSisLauncherServerShutdown::StartShort(TBool aCancelLongTimer) |
209 void CSisLauncherServerShutdown::StartShort(TBool aCancelLongTimer) |
212 { |
210 { |
213 if (iLongTimerActive & !aCancelLongTimer) |
211 if (iLongTimerActive & !aCancelLongTimer) |
214 { |
212 { |
215 return; |
213 return; |
216 } |
214 } |
217 else |
215 else |
218 { |
216 { |
219 Cancel(); |
217 Cancel(); |
220 iLongTimerActive=EFalse; |
218 iLongTimerActive=EFalse; |
221 After(KSisLauncherShutdownDelay); |
219 After(KSisLauncherShutdownDelay); |
222 } |
220 } |
223 } |
221 } |
224 |
222 |
225 inline void CSisLauncherServerShutdown::StartLong() |
223 inline void CSisLauncherServerShutdown::StartLong() |
226 { |
224 { |
227 Cancel(); |
225 Cancel(); |
228 iLongTimerActive=ETrue; |
226 iLongTimerActive=ETrue; |
229 After(KSisLauncherLongShutdownDelay); |
227 After(KSisLauncherLongShutdownDelay); |
230 } |
228 } |
231 |
229 |
232 |
230 |
233 void CSisLauncherServer::RunExecutableL(const TDesC& aFileName, TBool aWait) |
231 void CSisLauncherServer::RunExecutableL(const TDesC& aFileName, TBool aWait) |
234 { |
232 { |
235 DEBUG_CODE_SECTION( |
233 DEBUG_CODE_SECTION( |
236 if (aWait) |
234 if (aWait) |
237 { |
235 { |
238 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to run executable by filename ('%S'), waiting for termination."), |
236 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to run executable by filename ('%S'), waiting for termination."), |
239 &aFileName); |
237 &aFileName); |
240 } |
238 } |
241 else |
239 else |
242 { |
240 { |
243 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to run executable by filename ('%S'), not waiting for termination."), |
241 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to run executable by filename ('%S'), not waiting for termination."), |
244 &aFileName); |
242 &aFileName); |
245 } |
243 } |
246 ); // DEBUG_CODE_SECTION |
244 ); // DEBUG_CODE_SECTION |
247 |
245 |
248 RProcess process; |
246 RProcess process; |
249 _LIT(KNullArgs, ""); |
247 _LIT(KNullArgs, ""); |
250 User::LeaveIfError(process.Create(aFileName, KNullArgs)); |
248 User::LeaveIfError(process.Create(aFileName, KNullArgs)); |
251 CleanupClosePushL(process); |
249 CleanupClosePushL(process); |
252 |
250 |
253 // Get the thread id of the main thread in the process |
251 // Get the thread id of the main thread in the process |
254 // From CApaExeRecognizer::RunL |
252 // From CApaExeRecognizer::RunL |
255 TFullName fullName(process.Name()); |
253 TFullName fullName(process.Name()); |
256 _LIT(KCCMain,"::Main"); |
254 _LIT(KCCMain,"::Main"); |
257 fullName.Append(KCCMain); |
255 fullName.Append(KCCMain); |
258 TFindThread fT(fullName); |
256 TFindThread fT(fullName); |
259 User::LeaveIfError(fT.Next(fullName)); |
257 User::LeaveIfError(fT.Next(fullName)); |
260 RThread thread; |
258 RThread thread; |
261 User::LeaveIfError(thread.Open(fT)); |
259 User::LeaveIfError(thread.Open(fT)); |
262 TThreadId threadId = thread.Id(); |
260 TThreadId threadId = thread.Id(); |
263 thread.Close(); |
261 thread.Close(); |
264 process.Resume(); |
262 process.Resume(); |
265 |
263 |
266 CleanupStack::PopAndDestroy(&process); |
264 CleanupStack::PopAndDestroy(&process); |
267 if (aWait) |
265 if (aWait) |
268 HandleShutdownL(threadId, ETrue); |
266 HandleShutdownL(threadId, ETrue); |
269 } |
267 } |
|
268 |
|
269 |
270 |
270 |
271 void CSisLauncherServer::ForceShutdownL(TUid aUid) |
271 void CSisLauncherServer::ForceShutdownL(TUid aUid) |
272 { |
272 { |
273 TBool needToScanFullList; |
273 TBool needToScanFullList; |
274 TFullName fullName; |
274 TFullName fullName; |
275 do |
275 do |
276 { |
276 { |
277 needToScanFullList = EFalse; |
277 needToScanFullList = EFalse; |
278 TFindProcess findProcess; |
278 TFindProcess findProcess; |
279 |
279 |
280 while(findProcess.Next(fullName) == KErrNone) |
280 while(findProcess.Next(fullName) == KErrNone) |
281 { |
281 { |
282 RProcess process; |
282 RProcess process; |
283 User::LeaveIfError(process.Open(findProcess)); |
283 User::LeaveIfError(process.Open(findProcess)); |
284 TUid sid(process.SecureId()); |
284 TUid sid(process.SecureId()); |
285 if (sid == aUid && process.ExitType() == EExitPending) |
285 if (sid == aUid && process.ExitType() == EExitPending) |
286 { |
286 { |
287 process.Kill(KErrNone); |
287 process.Kill(KErrNone); |
288 needToScanFullList = ETrue; |
288 needToScanFullList = ETrue; |
289 } |
289 } |
290 process.Close(); |
290 process.Close(); |
291 } |
291 } |
292 } while (needToScanFullList); |
292 } while (needToScanFullList); |
293 } |
293 } |
294 |
294 |
295 |
295 |
296 void CSisLauncherServer::HandleShutdownL(TThreadId aThread, TBool aKillOnTimeout) |
296 void CSisLauncherServer::HandleShutdownL(TThreadId aThread, TBool aKillOnTimeout) |
297 { |
297 { |
298 RWsSession* wsSession = NULL; |
298 RWsSession* wsSession = NULL; |
299 if (iBootMode == KTextShell) |
299 if (iBootMode == KTextShell) |
300 { |
300 { |
301 // emulator tests running in textshell or in textshell ROM (#def SWI_TEXTSHELL_ROM) |
301 // emulator tests running in textshell or in textshell ROM (#def SWI_TEXTSHELL_ROM) |
302 DEBUG_PRINTF(_L8("Sis Launcher Server - textshell - skipping shutdown of user applications")); |
302 DEBUG_PRINTF(_L8("Sis Launcher Server - textshell - skipping shutdown of user applications")); |
303 } |
303 } |
304 else |
304 else |
305 { |
305 { |
306 #ifndef SWI_TEXTSHELL_ROM |
306 #ifndef SWI_TEXTSHELL_ROM |
307 DEBUG_CODE_SECTION( |
307 DEBUG_CODE_SECTION( |
308 if (aKillOnTimeout) |
308 if (aKillOnTimeout) |
309 { |
309 { |
310 DEBUG_PRINTF(_L8("Sis Launcher Server - Awaiting thread shutdown, will forcibly kill process on timeout.")); |
310 DEBUG_PRINTF(_L8("Sis Launcher Server - Awaiting thread shutdown, will forcibly kill process on timeout.")); |
311 } |
311 } |
312 else |
312 else |
313 { |
313 { |
314 DEBUG_PRINTF(_L8("Sis Launcher Server - Awaiting thread shutdown, will not forcibly kill process on timeout.")); |
314 DEBUG_PRINTF(_L8("Sis Launcher Server - Awaiting thread shutdown, will not forcibly kill process on timeout.")); |
315 } |
315 } |
316 ); |
316 ); |
317 wsSession = &iWsSession; |
317 wsSession = &iWsSession; |
318 #endif |
318 #endif |
319 } |
319 } |
320 // Read timeout value from software install security |
320 // Read timeout value from software install security |
321 // policy. |
321 // policy. |
322 CSecurityPolicy* secPolicy = CSecurityPolicy::GetSecurityPolicyL(); |
322 CSecurityPolicy* secPolicy = CSecurityPolicy::GetSecurityPolicyL(); |
323 TInt runWaitTimeout = secPolicy->RunWaitTimeout(); |
323 TInt runWaitTimeout = secPolicy->RunWaitTimeout(); |
324 TInt shutdownTimeout = secPolicy->ApplicationShutdownTimeout(); |
324 TInt shutdownTimeout = secPolicy->ApplicationShutdownTimeout(); |
325 // Wait until the thread finishes or a timeout occurs |
325 // Wait until the thread finishes or a timeout occurs |
326 CThreadMonitor* threadMonitor = CThreadMonitor::NewLC(aThread, wsSession); |
326 CThreadMonitor* threadMonitor = CThreadMonitor::NewLC(aThread, wsSession); |
327 threadMonitor->SyncShutdownL(runWaitTimeout, aKillOnTimeout, shutdownTimeout); |
327 threadMonitor->SyncShutdownL(runWaitTimeout, aKillOnTimeout, shutdownTimeout); |
328 CleanupStack::PopAndDestroy(threadMonitor); |
328 CleanupStack::PopAndDestroy(threadMonitor); |
329 } |
329 } |
330 |
330 |
331 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
332 CPolicyServer::TCustomResult CSisLauncherServer::CustomSecurityCheckL(const RMessage2& aMsg, |
|
333 TInt& /*aAction*/, TSecurityInfo& /*aMissing*/) |
|
334 { |
|
335 TUint32 secureId = aMsg.SecureId().iId; |
|
336 if (secureId == KInstallServerUid || secureId == KSisRegistryServerUid) |
|
337 { |
|
338 return CPolicyServer::EPass; |
|
339 } |
|
340 else |
|
341 { |
|
342 //client accessing the function is neither Install Server nor Sis Registry |
|
343 return CPolicyServer::EFail; |
|
344 } |
|
345 } |
|
346 #endif |
|
347 |
331 |
348 #ifndef SWI_TEXTSHELL_ROM |
332 #ifndef SWI_TEXTSHELL_ROM |
349 void CSisLauncherServer::StartDocumentL(RFile& aFile, TBool aWait) |
333 void CSisLauncherServer::StartDocumentL(RFile& aFile, TBool aWait) |
350 { |
334 { |
351 DEBUG_CODE_SECTION( |
335 DEBUG_CODE_SECTION( |
352 if (aWait) |
336 if (aWait) |
353 { |
337 { |
354 DEBUG_PRINTF(_L8("Sis Launcher Server - Attempting to start document by filehandle, waiting for termination.")); |
338 DEBUG_PRINTF(_L8("Sis Launcher Server - Attempting to start document by filehandle, waiting for termination.")); |
355 } |
339 } |
356 else |
340 else |
357 { |
341 { |
358 DEBUG_PRINTF(_L8("Sis Launcher Server - Attempting to start document by filehandle, not waiting for termination.")); |
342 DEBUG_PRINTF(_L8("Sis Launcher Server - Attempting to start document by filehandle, not waiting for termination.")); |
359 } |
343 } |
360 ); |
344 ); |
361 |
345 |
362 RApaLsSession apaSession; |
346 RApaLsSession apaSession; |
363 User::LeaveIfError(apaSession.Connect()); |
347 User::LeaveIfError(apaSession.Connect()); |
364 CleanupClosePushL(apaSession); |
348 CleanupClosePushL(apaSession); |
365 |
349 |
366 TThreadId threadId; |
350 TThreadId threadId; |
367 User::LeaveIfError(apaSession.StartDocument(aFile, threadId)); |
351 User::LeaveIfError(apaSession.StartDocument(aFile, threadId)); |
368 |
352 |
369 CleanupStack::PopAndDestroy(&apaSession); |
353 CleanupStack::PopAndDestroy(&apaSession); |
370 if (aWait) |
354 if (aWait) |
371 HandleShutdownL(threadId); |
355 HandleShutdownL(threadId); |
372 } |
356 } |
373 |
357 |
374 void CSisLauncherServer::StartByMimeL(RFile& aFile, TDesC8& aMimeType, TBool aWait) |
358 void CSisLauncherServer::StartByMimeL(RFile& aFile, TDesC8& aMimeType, TBool aWait) |
375 { |
359 { |
376 DEBUG_CODE_SECTION( |
360 DEBUG_CODE_SECTION( |
377 if (aWait) |
361 if (aWait) |
378 { |
362 { |
379 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to start document by mimetype '%S' (filehandle supplied), waiting for termination."), |
363 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to start document by mimetype '%S' (filehandle supplied), waiting for termination."), |
380 &aMimeType); |
364 &aMimeType); |
381 } |
365 } |
382 else |
366 else |
383 { |
367 { |
384 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to start document by mimetype '%S' (filehandle supplied), not waiting for termination."), |
368 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to start document by mimetype '%S' (filehandle supplied), not waiting for termination."), |
385 &aMimeType); |
369 &aMimeType); |
386 } |
370 } |
387 ); |
371 ); |
388 |
372 |
389 RApaLsSession apaSession; |
373 RApaLsSession apaSession; |
390 User::LeaveIfError(apaSession.Connect()); |
374 User::LeaveIfError(apaSession.Connect()); |
391 CleanupClosePushL(apaSession); |
375 CleanupClosePushL(apaSession); |
392 |
376 |
393 TThreadId threadId; |
377 TThreadId threadId; |
394 TDataType dataType = TDataType(aMimeType); |
378 TDataType dataType = TDataType(aMimeType); |
395 User::LeaveIfError(apaSession.StartDocument(aFile, dataType, threadId)); |
379 User::LeaveIfError(apaSession.StartDocument(aFile, dataType, threadId)); |
396 |
380 |
397 CleanupStack::PopAndDestroy(&apaSession); |
381 CleanupStack::PopAndDestroy(&apaSession); |
398 if (aWait) |
382 if (aWait) |
399 HandleShutdownL(threadId); |
383 HandleShutdownL(threadId); |
400 } |
384 } |
|
385 |
|
386 void CSisLauncherServer::StartDocumentL(const TDesC& aFileName, TBool aWait) |
|
387 { |
|
388 DEBUG_CODE_SECTION( |
|
389 if (aWait) |
|
390 { |
|
391 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', waiting for termination."), |
|
392 &aFileName); |
|
393 } |
|
394 else |
|
395 { |
|
396 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', not waiting for termination."), |
|
397 &aFileName); |
|
398 } |
|
399 ); |
|
400 |
|
401 RApaLsSession apaSession; |
|
402 User::LeaveIfError(apaSession.Connect()); |
|
403 CleanupClosePushL(apaSession); |
|
404 |
|
405 TThreadId threadId; |
|
406 User::LeaveIfError(apaSession.StartDocument(aFileName, threadId)); |
|
407 |
|
408 CleanupStack::PopAndDestroy(&apaSession); |
|
409 if (aWait) |
|
410 HandleShutdownL(threadId); |
|
411 } |
|
412 |
|
413 void CSisLauncherServer::StartByMimeL(const TDesC& aFileName, TDesC8& aMimeType, TBool aWait) |
|
414 { |
|
415 DEBUG_CODE_SECTION( |
|
416 if (aWait) |
|
417 { |
|
418 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', waiting for termination."), |
|
419 &aFileName); |
|
420 } |
|
421 else |
|
422 { |
|
423 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', not waiting for termination."), |
|
424 &aFileName); |
|
425 } |
|
426 ); |
|
427 DEBUG_PRINTF2(_L8("Sis Launcher Server - Supplied MIME type is '%S'."), &aMimeType); |
|
428 |
|
429 RApaLsSession apaSession; |
|
430 User::LeaveIfError(apaSession.Connect()); |
|
431 CleanupClosePushL(apaSession); |
|
432 |
|
433 TThreadId threadId; |
|
434 TDataType dataType = TDataType(aMimeType); |
|
435 User::LeaveIfError(apaSession.StartDocument(aFileName, dataType, threadId)); |
|
436 |
|
437 CleanupStack::PopAndDestroy(&apaSession); |
|
438 if (aWait) |
|
439 HandleShutdownL(threadId); |
|
440 } |
|
441 |
|
442 void CSisLauncherServer::ShutdownL(TUid aUid, TInt aTimeout) |
|
443 { |
|
444 // This method shuts down running exes matching the SID provided in aUid. |
|
445 // It first attempts a graceful shutdown, killing processes if a graceful |
|
446 // shutdown is not supported or fails to work within aTimeout microseconds. |
|
447 |
|
448 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to kill process with SID: 0x%08x."), |
|
449 aUid.iUid); |
|
450 |
|
451 TInt wgId=0; |
|
452 |
|
453 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(iWsSession); |
|
454 CleanupStack::PushL(wgName); |
|
455 CApaWindowGroupName::FindByAppUid(aUid, iWsSession, wgId); |
|
456 |
|
457 while (wgId != KErrNotFound) |
|
458 { |
|
459 wgName->ConstructFromWgIdL(wgId); |
|
460 if(wgName->RespondsToShutdownEvent()) |
|
461 { |
|
462 TApaTask task(iWsSession); |
|
463 task.SetWgId(wgId); |
|
464 |
|
465 RThread thread; |
|
466 User::LeaveIfError(thread.Open(task.ThreadId())); |
|
467 CleanupClosePushL(thread); |
|
468 |
|
469 RProcess process; |
|
470 User::LeaveIfError(thread.Process(process)); |
|
471 CleanupClosePushL(process); |
|
472 |
|
473 TRequestStatus processStatus; |
|
474 process.Logon(processStatus); |
|
475 |
|
476 task.SendSystemEvent(EApaSystemEventShutdown); |
|
477 |
|
478 RTimer timer; |
|
479 CleanupClosePushL(timer); |
|
480 TRequestStatus timerStatus; |
|
481 timer.CreateLocal(); |
|
482 timer.After(timerStatus, aTimeout); |
|
483 |
|
484 User::WaitForRequest(processStatus,timerStatus); |
|
485 |
|
486 if (processStatus==KRequestPending) |
|
487 { |
|
488 // Failed to terminate gracefully, so kill the task. |
|
489 DEBUG_PRINTF(_L8("Sis Launcher Server - Process did not die before timeout. Forcibly killing it.")); |
|
490 process.Kill(KErrNone); |
|
491 } |
|
492 else if (timerStatus==KRequestPending) |
|
493 { |
|
494 // Rendezvous completed so cancel timer |
|
495 timer.Cancel(); |
|
496 } |
|
497 // Handle second request |
|
498 User::WaitForRequest(processStatus,timerStatus); |
|
499 CleanupStack::PopAndDestroy(3, &thread); |
|
500 } |
|
501 |
|
502 // See if there's another instance of this App running. |
|
503 CApaWindowGroupName::FindByAppUid(aUid, iWsSession, wgId); |
|
504 } |
|
505 CleanupStack::PopAndDestroy(wgName); |
|
506 } |
|
507 |
|
508 void CSisLauncherServer::ShutdownL() |
|
509 { |
|
510 TInt wgId=0; |
401 |
511 |
402 void CSisLauncherServer::StartDocumentL(const TDesC& aFileName, TBool aWait) |
512 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(iWsSession); |
403 { |
513 CleanupStack::PushL(wgName); |
404 DEBUG_CODE_SECTION( |
514 TBuf<1> matchAny; |
405 if (aWait) |
515 matchAny.Append(KMatchAny); |
406 { |
516 CApaWindowGroupName::FindByCaption(matchAny, iWsSession, wgId); |
407 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', waiting for termination."), |
517 while (wgId != KErrNotFound) |
408 &aFileName); |
518 { |
409 } |
519 wgName->ConstructFromWgIdL(wgId); |
410 else |
520 //DEF057706 - shut down hidden apps during uninstallation if |
411 { |
521 // SH flag is specified |
412 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', not waiting for termination."), |
522 if (!wgName->IsSystem() /* && !wgName->Hidden() */) |
413 &aFileName); |
523 { |
414 } |
524 // leave if we cannot shutdown the app because its busy |
415 ); |
525 if(!wgName->IsBusy()) |
416 |
526 { |
417 RApaLsSession apaSession; |
527 TApaTask task(iWsSession); |
418 User::LeaveIfError(apaSession.Connect()); |
528 task.SetWgId(wgId); |
419 CleanupClosePushL(apaSession); |
529 // show shutdown dialog for this app? |
420 |
530 task.SendSystemEvent(EApaSystemEventShutdown); |
421 TThreadId threadId; |
531 } |
422 User::LeaveIfError(apaSession.StartDocument(aFileName, threadId)); |
532 else |
423 |
533 { |
424 CleanupStack::PopAndDestroy(&apaSession); |
534 // could not shutdown an app |
425 if (aWait) |
535 User::Leave(KErrInUse); |
426 HandleShutdownL(threadId); |
536 } |
427 } |
537 } |
428 |
538 |
429 void CSisLauncherServer::StartByMimeL(const TDesC& aFileName, TDesC8& aMimeType, TBool aWait) |
539 // get next app to shutdown |
430 { |
540 CApaWindowGroupName::FindByCaption(matchAny, iWsSession, wgId); |
431 DEBUG_CODE_SECTION( |
541 } |
432 if (aWait) |
542 CleanupStack::PopAndDestroy(wgName); |
433 { |
543 } |
434 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', waiting for termination."), |
|
435 &aFileName); |
|
436 } |
|
437 else |
|
438 { |
|
439 DEBUG_PRINTF2(_L("Sis Launcher Server - Attempting to start document by filename '%S', not waiting for termination."), |
|
440 &aFileName); |
|
441 } |
|
442 ); |
|
443 DEBUG_PRINTF2(_L8("Sis Launcher Server - Supplied MIME type is '%S'."), &aMimeType); |
|
444 |
|
445 RApaLsSession apaSession; |
|
446 User::LeaveIfError(apaSession.Connect()); |
|
447 CleanupClosePushL(apaSession); |
|
448 |
|
449 TThreadId threadId; |
|
450 TDataType dataType = TDataType(aMimeType); |
|
451 User::LeaveIfError(apaSession.StartDocument(aFileName, dataType, threadId)); |
|
452 |
|
453 CleanupStack::PopAndDestroy(&apaSession); |
|
454 if (aWait) |
|
455 HandleShutdownL(threadId); |
|
456 } |
|
457 |
|
458 void CSisLauncherServer::ShutdownL(TUid aUid, TInt aTimeout) |
|
459 { |
|
460 // This method shuts down running exes matching the SID provided in aUid. |
|
461 // It first attempts a graceful shutdown, killing processes if a graceful |
|
462 // shutdown is not supported or fails to work within aTimeout microseconds. |
|
463 |
|
464 DEBUG_PRINTF2(_L8("Sis Launcher Server - Attempting to kill process with SID: 0x%08x."), |
|
465 aUid.iUid); |
|
466 |
|
467 TInt wgId=0; |
|
468 |
|
469 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(iWsSession); |
|
470 CleanupStack::PushL(wgName); |
|
471 CApaWindowGroupName::FindByAppUid(aUid, iWsSession, wgId); |
|
472 |
|
473 while (wgId != KErrNotFound) |
|
474 { |
|
475 wgName->ConstructFromWgIdL(wgId); |
|
476 if(wgName->RespondsToShutdownEvent()) |
|
477 { |
|
478 TApaTask task(iWsSession); |
|
479 task.SetWgId(wgId); |
|
480 |
|
481 RThread thread; |
|
482 User::LeaveIfError(thread.Open(task.ThreadId())); |
|
483 CleanupClosePushL(thread); |
|
484 |
|
485 RProcess process; |
|
486 User::LeaveIfError(thread.Process(process)); |
|
487 CleanupClosePushL(process); |
|
488 |
|
489 TRequestStatus processStatus; |
|
490 process.Logon(processStatus); |
|
491 |
|
492 task.SendSystemEvent(EApaSystemEventShutdown); |
|
493 |
|
494 RTimer timer; |
|
495 CleanupClosePushL(timer); |
|
496 TRequestStatus timerStatus; |
|
497 timer.CreateLocal(); |
|
498 timer.After(timerStatus, aTimeout); |
|
499 |
|
500 User::WaitForRequest(processStatus,timerStatus); |
|
501 |
|
502 if (processStatus==KRequestPending) |
|
503 { |
|
504 // Failed to terminate gracefully, so kill the task. |
|
505 DEBUG_PRINTF(_L8("Sis Launcher Server - Process did not die before timeout. Forcibly killing it.")); |
|
506 process.Kill(KErrNone); |
|
507 } |
|
508 else if (timerStatus==KRequestPending) |
|
509 { |
|
510 // Rendezvous completed so cancel timer |
|
511 timer.Cancel(); |
|
512 } |
|
513 // Handle second request |
|
514 User::WaitForRequest(processStatus,timerStatus); |
|
515 CleanupStack::PopAndDestroy(3, &thread); |
|
516 } |
|
517 |
|
518 // See if there's another instance of this App running. |
|
519 CApaWindowGroupName::FindByAppUid(aUid, iWsSession, wgId); |
|
520 } |
|
521 CleanupStack::PopAndDestroy(wgName); |
|
522 } |
|
523 |
|
524 void CSisLauncherServer::ShutdownL() |
|
525 { |
|
526 TInt wgId=0; |
|
527 |
|
528 CApaWindowGroupName* wgName = CApaWindowGroupName::NewL(iWsSession); |
|
529 CleanupStack::PushL(wgName); |
|
530 TBuf<1> matchAny; |
|
531 matchAny.Append(KMatchAny); |
|
532 CApaWindowGroupName::FindByCaption(matchAny, iWsSession, wgId); |
|
533 while (wgId != KErrNotFound) |
|
534 { |
|
535 wgName->ConstructFromWgIdL(wgId); |
|
536 //DEF057706 - shut down hidden apps during uninstallation if |
|
537 // SH flag is specified |
|
538 if (!wgName->IsSystem() /* && !wgName->Hidden() */) |
|
539 { |
|
540 // leave if we cannot shutdown the app because its busy |
|
541 if(!wgName->IsBusy()) |
|
542 { |
|
543 TApaTask task(iWsSession); |
|
544 task.SetWgId(wgId); |
|
545 // show shutdown dialog for this app? |
|
546 task.SendSystemEvent(EApaSystemEventShutdown); |
|
547 } |
|
548 else |
|
549 { |
|
550 // could not shutdown an app |
|
551 User::Leave(KErrInUse); |
|
552 } |
|
553 } |
|
554 |
|
555 // get next app to shutdown |
|
556 CApaWindowGroupName::FindByCaption(matchAny, iWsSession, wgId); |
|
557 } |
|
558 CleanupStack::PopAndDestroy(wgName); |
|
559 } |
|
560 |
544 |
561 void CSisLauncherServer::NotifyNewAppsL(const RPointerArray<TDesC>& aFiles) |
545 void CSisLauncherServer::NotifyNewAppsL(const RPointerArray<TDesC>& aFiles) |
562 { |
546 { |
563 RApaLsSession apaSession; |
547 RApaLsSession apaSession; |
564 User::LeaveIfError(apaSession.Connect()); |
548 User::LeaveIfError(apaSession.Connect()); |
565 CleanupClosePushL(apaSession); |
549 CleanupClosePushL(apaSession); |
566 |
550 |
567 // UI frameworks advise ignoring the return code |
551 // UI frameworks advise ignoring the return code |
568 apaSession.ForceRegistration(aFiles); |
552 apaSession.ForceRegistration(aFiles); |
569 |
553 |
570 CleanupStack::PopAndDestroy(); |
554 CleanupStack::PopAndDestroy(); |
571 } |
555 } |
572 |
556 #endif |
573 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
557 |
574 void CSisLauncherServer::NotifyNewAppsL(const RPointerArray<Usif::CApplicationRegistrationData>& aApplicationRegistrationData) |
558 |
575 { |
|
576 RApaLsSession apaSession; |
|
577 User::LeaveIfError(apaSession.Connect()); |
|
578 CleanupClosePushL(apaSession); |
|
579 |
|
580 // UI frameworks advise ignoring the return code |
|
581 // Proceeding even if force registration fails so that installation is not aborted |
|
582 apaSession.ForceRegistration(aApplicationRegistrationData); |
|
583 CleanupStack::PopAndDestroy(); |
|
584 } |
|
585 |
|
586 #endif |
|
587 #endif |
|
588 |
|
589 |
|