|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef APSNNAPPS_H |
|
17 #define APSNNAPPS_H |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <f32file.h> |
|
21 #include <s32file.h> |
|
22 |
|
23 #include "apsnnappupdates.h" |
|
24 |
|
25 // classes referenced |
|
26 class CApaAppListServer; |
|
27 class CApsNonNativeApplicationsUpdateList; |
|
28 |
|
29 _LIT(KLitPathForTemporaryNonNativeResourceAndIconFiles, "\\private\\10003a3f\\temp\\NonNativeUpdates\\"); |
|
30 |
|
31 /** |
|
32 @internalComponent |
|
33 */ |
|
34 NONSHARABLE_CLASS(CApsNonNativeApplicationsManager) : public CBase |
|
35 { |
|
36 public: |
|
37 static CApsNonNativeApplicationsManager* NewL(CApaAppListServer& aServ, RFs& aFs); |
|
38 ~CApsNonNativeApplicationsManager(); |
|
39 |
|
40 private: |
|
41 CApsNonNativeApplicationsManager(CApaAppListServer& aServ, RFs& aFs); |
|
42 |
|
43 public: |
|
44 void NotifyScanComplete(); |
|
45 void PrepareNonNativeApplicationsUpdatesL(); |
|
46 void RegisterNonNativeApplicationL(const RMessage2& aMessage); |
|
47 void DeregisterNonNativeApplicationL(const RMessage2& aMessage); |
|
48 #ifdef _DEBUG |
|
49 void ForceFailInNonNativeApplicationsUpdatesL(); |
|
50 void ForcePanicInNonNativeApplicationsUpdatesL(); |
|
51 void ForcePanicInNonNativeApplicationsRollbackL(); |
|
52 #endif |
|
53 void CommitNonNativeApplicationsUpdatesL(const RMessage2& aMessage); |
|
54 void RollbackNonNativeApplicationsUpdates(); |
|
55 static void RecoverFromUpdateLogL(RFs& aFs); |
|
56 |
|
57 private: |
|
58 void DoRegisterNonNativeApplicationL(const RMessage2& aMessage); |
|
59 void AbortNonNativeApplicationsUpdates(); |
|
60 static void StaticAbortNonNativeApplicationsUpdates(TAny* aSelf); |
|
61 void CheckForUpdateAppsLockL(); |
|
62 |
|
63 private: |
|
64 CApaAppListServer& iServ; |
|
65 RFs& iFs; |
|
66 RMessage2 iNotifyOnScanCompleteMsg; |
|
67 TBool iNonNativeApplicationsUpdateAppsLock; |
|
68 CApsNonNativeApplicationsUpdateList* iUpdateList; |
|
69 }; |
|
70 |
|
71 class RApsUpdateLog; |
|
72 |
|
73 /** |
|
74 This class holds a list of updates to the non-native apps registry that should |
|
75 be performed as one transaction, along with code to execute / rollback the updates. |
|
76 |
|
77 |
|
78 |
|
79 Update list structure: |
|
80 |
|
81 These are the possible valid types of list: |
|
82 (* means "can occur 0 or more times", ? means "can occur 0 or 1 times") |
|
83 |
|
84 EPerformed*, EPerforming?, ENew* |
|
85 EPerformed*, ERollingBack?, ERolledBack*, ENew* |
|
86 |
|
87 The list can be destructed in any of these states: |
|
88 |
|
89 EPerformed*, ERolledBack*, ENew* |
|
90 |
|
91 @internalComponent |
|
92 */ |
|
93 NONSHARABLE_CLASS(CApsNonNativeApplicationsUpdateList) : public CBase |
|
94 { |
|
95 public: |
|
96 static CApsNonNativeApplicationsUpdateList* NewL(RFs& aFs); |
|
97 static void RecoverFromUpdateLogL(RFs& aFs, RFile& aFile); |
|
98 ~CApsNonNativeApplicationsUpdateList(); |
|
99 |
|
100 private: |
|
101 CApsNonNativeApplicationsUpdateList(RFs& aFs); |
|
102 void RecoverFromUpdateLogL(RFile& aFile); |
|
103 |
|
104 public: |
|
105 void Append(CApsNonNativeApplicationsUpdate* aUpdate); |
|
106 void ExecuteL(); |
|
107 |
|
108 private: |
|
109 void Rollback(CApsNonNativeApplicationsUpdate* aStartPoint, RApsUpdateLog& aUpdateLog); |
|
110 void SetLogWriteStream(RWriteStream* aStream); |
|
111 void InternalizeL(RReadStream& aStream, TInt& aPosition); |
|
112 void InternalizeActionL(RReadStream& aStream, int& aPosition); |
|
113 void InternalizeNewUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid); |
|
114 void InternalizePerformUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid); |
|
115 void InternalizeRollbackUpdateL(RReadStream& aStream, TInt& aPosition, CApsNonNativeApplicationsUpdate::TLogUpdateType aType, TUid aUid); |
|
116 |
|
117 private: |
|
118 RFs& iFs; |
|
119 CApsNonNativeApplicationsUpdate* iUpdateListHead; |
|
120 CApsNonNativeApplicationsUpdate* iLogReplayCurrentUpdate; |
|
121 TBool iEEndOfUpdateRequiredToFixLog; // for recovering from the log. This is ETrue if we've reached a beta stopping point. |
|
122 }; |
|
123 |
|
124 |
|
125 /* |
|
126 This class opens & owns the recovery log file |
|
127 |
|
128 Recovery log structure: |
|
129 |
|
130 As updates are performed, they are written to a log. The log's format on disk is documented here. |
|
131 |
|
132 When we read the log in, there are certain points that are considered to be "valid stopping points" |
|
133 These points are at the end of every useful section of data. When we keep track of the stream-position |
|
134 during internalization, we make sure that the position we record is always at one of these points, never |
|
135 between them. |
|
136 This means that we can then truncate the log to the last of these points and then append new operations to the |
|
137 log. |
|
138 There are two types of stopping points, i've called them alpha and beta. At an alpha stopping point we |
|
139 can start appending new operations to the log immediately. At a beta stopping point, we must append a |
|
140 EEndOfUpdate marker first. |
|
141 |
|
142 |
|
143 These points are denoted in the structure below with "--- stopping point ---" |
|
144 |
|
145 LogStructure = |
|
146 { |
|
147 (NewUpdateSection, |
|
148 PerformUpdateSection)* |
|
149 RollbackUpdateSection* |
|
150 } |
|
151 |
|
152 NewUpdateSection = |
|
153 { |
|
154 Int8 ENewUpdate |
|
155 Int8 TLogUpdateType |
|
156 Int32 TUid |
|
157 ... dependent on update type ... |
|
158 --- alpha stopping point --- |
|
159 } |
|
160 |
|
161 PerformUpdateSection = |
|
162 { |
|
163 Int8 EPerformUpdate |
|
164 Int8 TLogUpdateType |
|
165 Int32 TUid |
|
166 --- beta stopping point --- |
|
167 (UpdateContinuationSection | UpdateStateChangeSection)* |
|
168 Int8 EEndOfUpdate |
|
169 --- alpha stopping point --- |
|
170 } |
|
171 |
|
172 RollbackUpdateSection = |
|
173 { |
|
174 Int8 ERollbackUpdate |
|
175 Int8 TLogUpdateType |
|
176 Int32 TUid |
|
177 --- beta stopping point --- |
|
178 (UpdateContinuationSection | UpdateStateChangeSection)* |
|
179 Int8 EEndOfUpdate |
|
180 --- alpha stopping point --- |
|
181 } |
|
182 |
|
183 UpdateContinuationSection = |
|
184 { |
|
185 Int8 EUpdateContinuation |
|
186 ... dependent on update type ... |
|
187 --- beta stopping point --- |
|
188 } |
|
189 |
|
190 UpdateStateChangeSection = |
|
191 { |
|
192 Int8 EChangeOfUpdateState |
|
193 Int8 TState |
|
194 --- beta stopping point --- |
|
195 } |
|
196 |
|
197 @internalComponent |
|
198 */ |
|
199 NONSHARABLE_CLASS(RApsUpdateLog) |
|
200 { |
|
201 public: |
|
202 RApsUpdateLog(RFs& aFs); |
|
203 void OpenL(); |
|
204 void Open(RFile& aFile, TUint aSeekPos); |
|
205 void Close(); |
|
206 RPointerArray<HBufC>& NewRegistrationFiles(); |
|
207 RPointerArray<HBufC>& DrivesAffected(); |
|
208 RWriteStream& LogWriteStream(); |
|
209 private: |
|
210 RFs& iFs; |
|
211 // RPointerArray neccessary for use with CApaAppRegFinder |
|
212 RPointerArray<HBufC> iFilesRegistered; |
|
213 RPointerArray<HBufC> iDrivesAffected; |
|
214 RFileWriteStream iLogWriteStream; |
|
215 TFileName iLogFileName; |
|
216 }; |
|
217 |
|
218 #endif // APSNNAPPS_H |