|
1 /* |
|
2 * Copyright (c) 2004-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 the License "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 * SWIS state machine |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __SWIS_STATEMACHINE_H__ |
|
26 #define __SWIS_STATEMACHINE_H__ |
|
27 |
|
28 #include <e32std.h> |
|
29 #include <e32base.h> |
|
30 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
31 #include <usif/sts/sts.h> |
|
32 #include "registrywrapper.h" |
|
33 #else |
|
34 #include "integrityservices.h" |
|
35 #include "sisregistrywritablesession.h" |
|
36 #endif |
|
37 #include "sishelperclient.h" |
|
38 #include "sisuihandler.h" |
|
39 #include "swi/sisinstallationresult.h" |
|
40 #include "securitymanager.h" |
|
41 #include "swiobserverclient.h" |
|
42 |
|
43 |
|
44 namespace Swi |
|
45 { |
|
46 class CPlan; |
|
47 |
|
48 /** Panic ID for panics raised in state machine */ |
|
49 enum StateMachinePanic |
|
50 { |
|
51 EStateError |
|
52 }; |
|
53 |
|
54 /** |
|
55 * State machine base absrtract class. A state machine in this implementation |
|
56 * represents one task for SWIS (installation or uninstallation). |
|
57 * |
|
58 * @internalComponent |
|
59 * @released |
|
60 */ |
|
61 class CSwisStateMachine : public CActive |
|
62 { |
|
63 public: |
|
64 virtual ~CSwisStateMachine(); |
|
65 virtual TInt Start(); |
|
66 virtual void PostJournalFinalizationL(TInt aError); |
|
67 /** |
|
68 * Abstract base class for all states of a state machine. |
|
69 * |
|
70 * @internalComponent |
|
71 * @released |
|
72 */ |
|
73 class TState |
|
74 { |
|
75 public: |
|
76 virtual void EnterL()=0; |
|
77 virtual TState* CompleteL()=0; |
|
78 virtual TState* ErrorL(TInt aCode)=0; |
|
79 virtual void Cancel()=0; |
|
80 }; |
|
81 |
|
82 void CancelInstallation(); |
|
83 |
|
84 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
85 // Returns the mode in which state machine operates on. |
|
86 // Will return TRUE if it operates on component information extraction mode, |
|
87 // FALSE when it operates on normal installtion/uninstallation mode ( By default ). |
|
88 TBool IsInInfoMode(); |
|
89 |
|
90 // Sets the state machine to operate on information exteraction mode. |
|
91 void SetIsInInfoMode(TBool aMode); |
|
92 #endif |
|
93 |
|
94 protected: |
|
95 CSwisStateMachine(const RMessage2& aMessage); |
|
96 |
|
97 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
98 CSwisStateMachine(const RMessage2& aMessage,const TBool aInInfoMode); |
|
99 #endif |
|
100 |
|
101 /** Must be called in derived classes */ |
|
102 void ConstructL(); |
|
103 void ChangeStateL(TState* aNextState); |
|
104 inline TState* CurrentState(); |
|
105 void SetNextState(TState* aNextState); |
|
106 void CompleteSelf(); |
|
107 |
|
108 void FinalizeJournalsL(TInt aError); |
|
109 void CompleteClientL(TInt aError); |
|
110 RUiHandler& UiHandler(); |
|
111 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
112 Usif::RStsSession& TransactionSession(); |
|
113 CRegistryWrapper& RegistryWrapper(); |
|
114 void SetFinalProgressBarValue(TInt aValue); |
|
115 // Is the state machine runs in information extraction mode or normal installation/uninstallation mode? |
|
116 TBool iIsInInfoMode; |
|
117 #else |
|
118 CIntegrityServices& IntegrityServicesL(); |
|
119 #endif |
|
120 |
|
121 virtual TState* FirstState()=0; |
|
122 virtual TState* ErrorOnStateEntryL(TInt aError)=0; |
|
123 |
|
124 const RMessage2& Message() const; |
|
125 |
|
126 // These are overridden and used to signal the UI |
|
127 virtual void SignalCompletedL()=0; |
|
128 |
|
129 // Used to do signalling to the UI, copes with the plan not having a valid |
|
130 // TAppInfo yet |
|
131 void HandleInstallationEventL(CPlan* plan, TInstallEvent aEvent, TInt aValue = 0); |
|
132 RSwiObserverSession& Observer(); |
|
133 private: |
|
134 // from CActive |
|
135 void RunL(); |
|
136 TInt RunError(TInt aError); |
|
137 void DoCancel(); |
|
138 void InformUserOfFatalErrorL(TInt aError); |
|
139 |
|
140 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
141 void ResetRegistryCache(void); |
|
142 #endif |
|
143 |
|
144 protected: |
|
145 // The confirmation state; where the user elects to go ahead with |
|
146 // the installation/un-installation; has been entered. Therefore |
|
147 // the registery MIGHT have been altered. |
|
148 TBool iOperationConfirmed; |
|
149 |
|
150 private: |
|
151 TState* iState; ///< Curent state |
|
152 const RMessage2 iMessage; ///< Message to complete when done |
|
153 RUiHandler iUiHandler; ///< UI handler server session |
|
154 |
|
155 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
156 Usif::RStsSession iStsSession; ///< Transaction service session handle |
|
157 CRegistryWrapper* iRegistryWrapper; ///< Registry wrapper to access the registry |
|
158 CProgressBarValuePublisher* iProgressPublisher; ///< Pointer to the progress bar value publisher object.. |
|
159 #else |
|
160 CIntegrityServices* iIntegrityServices; ///< Shared integrity services. |
|
161 #endif |
|
162 |
|
163 TBool iCancelled; |
|
164 RSwiObserverSession iObserver; ///< Swi Observer session handle. |
|
165 }; // class CSwisStateMachine |
|
166 |
|
167 inline CSwisStateMachine::TState* CSwisStateMachine::CurrentState() |
|
168 { |
|
169 return iState; |
|
170 }; |
|
171 |
|
172 inline RUiHandler& CSwisStateMachine::UiHandler() |
|
173 { |
|
174 return iUiHandler; |
|
175 } |
|
176 |
|
177 inline const RMessage2& CSwisStateMachine::Message() const |
|
178 { |
|
179 return iMessage; |
|
180 } |
|
181 |
|
182 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
183 inline Usif::RStsSession& CSwisStateMachine::TransactionSession() |
|
184 { |
|
185 return iStsSession; |
|
186 } |
|
187 |
|
188 inline CRegistryWrapper& CSwisStateMachine::RegistryWrapper() |
|
189 { |
|
190 return *iRegistryWrapper; |
|
191 } |
|
192 #else |
|
193 inline CIntegrityServices& CSwisStateMachine::IntegrityServicesL() |
|
194 { |
|
195 if (!iIntegrityServices) |
|
196 { |
|
197 User::Leave(KErrBadUsage); |
|
198 } |
|
199 |
|
200 return *iIntegrityServices; |
|
201 } |
|
202 #endif |
|
203 |
|
204 inline RSwiObserverSession& CSwisStateMachine::Observer() |
|
205 { |
|
206 return iObserver; |
|
207 } |
|
208 |
|
209 } // namespace Swi |
|
210 |
|
211 #endif |