|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Handles shutdown situation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef AKNCAPSERVERSHUTDOWN_H |
|
19 #define AKNCAPSERVERSHUTDOWN_H |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 class TApaTask; |
|
24 class RWsSession; |
|
25 |
|
26 class CAknCapServerShutdown : public CBase |
|
27 { |
|
28 public: |
|
29 CAknCapServerShutdown(); |
|
30 ~CAknCapServerShutdown(); |
|
31 void ConstructL(); |
|
32 |
|
33 void ShutdownAppsL(const TUid aRequesterUID, const RMessage2& aShutdownMessage, |
|
34 const TInt aTimeoutInMicroseconds); |
|
35 |
|
36 void CancelShutdownAppsL(); |
|
37 |
|
38 private: |
|
39 enum TAknCapServerShutdownState |
|
40 { |
|
41 EShutdownWaitingForApps = 0, |
|
42 EShutdownKillingRogueApps |
|
43 }; |
|
44 |
|
45 // Exits / kills a running task & notifies when complete. |
|
46 class CAppExitNotifier : public CActive |
|
47 { |
|
48 public: |
|
49 enum TAppExitMethod |
|
50 { |
|
51 EAppExitNormal, |
|
52 EAppExitForced |
|
53 }; |
|
54 |
|
55 public: // Constructors and destructor |
|
56 static CAppExitNotifier* NewL(TApaTask* aTask, CAknCapServerShutdown* aObserver); |
|
57 ~CAppExitNotifier(); |
|
58 void ExitTask(); // The nice way, exits a task cleanly. |
|
59 void KillTask(); // The nasty way, kills a task. For use when ExitTask doesn't work. |
|
60 TBool IsDead(); |
|
61 const TApaTask& Task() const; |
|
62 const TThreadId ThreadId() const; |
|
63 |
|
64 private: |
|
65 void ConstructL(); |
|
66 void RunL(); |
|
67 void DoCancel(); |
|
68 CAppExitNotifier(TApaTask* aTask, CAknCapServerShutdown* aObserver); |
|
69 |
|
70 private: // Data |
|
71 CAknCapServerShutdown* iObserver; // Pointer to CAknCapServerShutdown for callbacks. |
|
72 TBool iIsDead; // Flag indicating the status of the thread. |
|
73 TApaTask* iTask; // Task being exited. |
|
74 RThread iThread; // iTask's thread. |
|
75 TThreadId iThreadId; // iTask's threadID. |
|
76 TAppExitMethod iExitMethod; // How the app is closed. |
|
77 }; |
|
78 public: |
|
79 void AppExitNotifierL(const CAppExitNotifier* aNotifier, |
|
80 CAppExitNotifier::TAppExitMethod aHowClosed); |
|
81 |
|
82 private: |
|
83 static TInt ShutdownTimeoutL(TAny* aPtr); |
|
84 TInt DoShutdownTimeoutL(); |
|
85 void ProceedWithShutdown(); |
|
86 |
|
87 private: |
|
88 RMessagePtr2 iShutdownMessage; |
|
89 CArrayPtrFlat<CAppExitNotifier>* iAppExitNotifiers; |
|
90 TInt iTotalAppExitNotifiers; |
|
91 CPeriodic* iShutdownTimeout; |
|
92 TAknCapServerShutdownState iShutdownState; |
|
93 RWsSession& iWs; |
|
94 }; |
|
95 |
|
96 #endif // AKNCAPSERVERSHUTDOWN_H |