|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #ifndef __RESTOREMACHINE_H__ |
|
25 #define __RESTOREMACHINE_H__ |
|
26 |
|
27 #include <e32base.h> |
|
28 |
|
29 #include "installationprocessor.h" |
|
30 #include "swi/siscontroller.h" |
|
31 #include "sisregistrywritablesession.h" |
|
32 |
|
33 namespace Swi |
|
34 { |
|
35 |
|
36 class CPlan; |
|
37 class CRestoreController; |
|
38 class CSecurityManager; |
|
39 class CSisRegistryFileDescription; |
|
40 class CRestoreProcessor; |
|
41 class RSisRegistryEntry; |
|
42 class RSisRegistrySession; |
|
43 |
|
44 |
|
45 |
|
46 /** |
|
47 * State machine controlled by events from an installserver |
|
48 * client that takes backed up metadata and files and |
|
49 * restores them to the device in a secure manner. |
|
50 * |
|
51 * @internalComponent |
|
52 * @released |
|
53 */ |
|
54 |
|
55 class CRestoreMachine : public CBase |
|
56 { |
|
57 friend class CCommitWatcher; |
|
58 public: |
|
59 static CRestoreMachine* NewL(const RMessage2& aMessage); |
|
60 static CRestoreMachine* NewLC(const RMessage2& aMessage); |
|
61 |
|
62 ~CRestoreMachine(); |
|
63 |
|
64 void ServiceFileRequestL(const RMessage2& aMessage); |
|
65 void ServiceCommitRequestL(const RMessage2& aMessage); |
|
66 |
|
67 TBool IsComplete(); |
|
68 RSwiObserverSession& Observer(); |
|
69 |
|
70 private: |
|
71 void ConstructL(const RMessage2& aMessage); |
|
72 |
|
73 CPlan* CreateUninstallPlanL(); |
|
74 TBool IsUniqueL(const TDesC& aFileName, TBool& aCheckFileHashOut); |
|
75 void PrepareUpgradesL(); |
|
76 void CheckVersionUpgradeL(); |
|
77 void RemovePackageFilesL(RSisRegistryEntry& aEntry); |
|
78 TBool FindInstalledAugmentationL(RSisRegistrySession& aSession, const Sis::CController& aController, |
|
79 RSisRegistryEntry& aEntryToOverwrite); |
|
80 TVersion GetLatestVersionOfPackageToRestore(); |
|
81 |
|
82 |
|
83 private: |
|
84 |
|
85 /** |
|
86 * Watches the restore process state machine and commits or |
|
87 * rolls back the transaction depending on the sucess or |
|
88 * failure of that state machine. |
|
89 * |
|
90 * |
|
91 * @internalComponent |
|
92 * @released |
|
93 */ |
|
94 |
|
95 class CCommitWatcher : public CActive |
|
96 { |
|
97 |
|
98 public: |
|
99 static CCommitWatcher* NewL(const RPointerArray<CPlan>& aPlans, CSecurityManager& aSecurityManager, |
|
100 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
101 Usif::RStsSession& aStsSession, RSisRegistryWritableSession& aRegistrySession, |
|
102 #else |
|
103 CIntegrityServices& aIntegrityServices, |
|
104 #endif |
|
105 CRestoreController& aController, const RMessage2& aMessage, RFs& aFs, CRestoreMachine& aMachine); |
|
106 |
|
107 |
|
108 void StartL(); |
|
109 |
|
110 ~CCommitWatcher(); |
|
111 |
|
112 protected: |
|
113 CCommitWatcher(const RPointerArray<CPlan>& aPlans, CSecurityManager& aSecurityManager, |
|
114 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
115 Usif::RStsSession& aStsSession, RSisRegistryWritableSession& aRegistrySession, |
|
116 #else |
|
117 CIntegrityServices& aIntegrityServices, |
|
118 #endif |
|
119 CRestoreController& aController, const RMessage2& aMessage, RFs& aFs, CRestoreMachine& aMachine); |
|
120 |
|
121 |
|
122 void RunL(); |
|
123 void DoCancel(); |
|
124 TInt RunError(TInt aError); |
|
125 |
|
126 void SwitchStateL(); |
|
127 void CompleteL(); |
|
128 |
|
129 private: |
|
130 TBool IsValidUpgradeL(const Sis::CController& aController, RArray<TUid>& aSids); |
|
131 TBool ValidEclipsingL(const CApplication& aApplication); |
|
132 |
|
133 |
|
134 private: |
|
135 const RMessage2& iClientMessage; // The client message, used to complete the request on termination of the processor |
|
136 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
137 Usif::RStsSession& iStsSession; // The restore STS session, used to commit or rollback the transaction |
|
138 RSisRegistryWritableSession& iRegistrySession; // Used to commit or rollback registry changes |
|
139 #else |
|
140 CIntegrityServices& iIntegrityServices; // The restore integrity services session, used to commit or rollback the transaction |
|
141 #endif |
|
142 CRestoreController& iRestoreController; // The sis controller support class |
|
143 CSecurityManager& iSecurityManager; |
|
144 const RPointerArray<CPlan>& iPlans; |
|
145 |
|
146 CRestoreProcessor* iProcessor; // The restore processor state machine to watch |
|
147 TInt iPlanIndex; |
|
148 TInt iVerifierIndex; |
|
149 |
|
150 RFs& iFs; |
|
151 CRestoreMachine& iMachine; |
|
152 }; |
|
153 |
|
154 private: |
|
155 TUid iPackageUid; // The UID of the top level package being restored |
|
156 CRestoreController* iRestoreController; // The controller handler used to verify the packages |
|
157 CSecurityManager* iSecurityManager; // A security manager for this transaction |
|
158 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
159 Usif::RStsSession iStsSession; // An STS session for this restore |
|
160 RSisRegistryWritableSession iRegistrySession; |
|
161 #else |
|
162 CIntegrityServices* iIntegrityServices; // An integrity services session for this restore |
|
163 #endif |
|
164 |
|
165 CCommitWatcher* iCommitWatcher; // Watcher to complete the session when the restore processor terminates |
|
166 RFs iFs; // A file server session for the restore server |
|
167 CFileMan* iFileMan; |
|
168 |
|
169 /// The drive on which to store device integrity data (hashes, registry etc) |
|
170 TChar iSystemDriveChar; |
|
171 RSwiObserverSession iObserver; ///< Swi Observer session handle. |
|
172 HBufC8 *iBuf; |
|
173 }; |
|
174 |
|
175 |
|
176 inline TBool CRestoreMachine::IsComplete() |
|
177 { |
|
178 |
|
179 if (iCommitWatcher) |
|
180 { |
|
181 return (iCommitWatcher->iStatus != KRequestPending); |
|
182 } |
|
183 return EFalse; |
|
184 |
|
185 } |
|
186 |
|
187 } |
|
188 |
|
189 |
|
190 #endif // __RESTOREMACHINE_H__ |