|
1 /* |
|
2 * Copyright (c) 2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "hsps_builds_cfg.hrh" |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 #include <bautils.h> |
|
24 #include "hspsrominstaller.h" |
|
25 #include "hspsthemeserver.h" |
|
26 #include "hspsinstallationhandler.h" |
|
27 #include "hspsclientrequesthandler.h" |
|
28 #include "hspsserverutil.h" |
|
29 |
|
30 _LIT( KInstallDirectoryZ, "z:\\private\\200159c0\\install\\" ); |
|
31 _LIT( KHsps, "hsps"); |
|
32 |
|
33 // ========================= MEMBER FUNCTIONS ================================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // ChspsRomInstaller::NewL() |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 ChspsRomInstaller* ChspsRomInstaller::NewL( |
|
40 ChspsThemeServer& aThemeServer, |
|
41 RFs& aFsSession ) |
|
42 { |
|
43 ChspsRomInstaller* self = NewLC( aThemeServer, aFsSession ); |
|
44 CleanupStack::Pop( self ); |
|
45 return( self ) ; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // ChspsRomInstaller::NewLC() |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 ChspsRomInstaller* ChspsRomInstaller::NewLC( |
|
53 ChspsThemeServer& aThemeServer, |
|
54 RFs& aFsSession) |
|
55 { |
|
56 ChspsRomInstaller* self = new ( ELeave ) ChspsRomInstaller( aThemeServer, aFsSession ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // ChspsRomInstaller::ConstructL() |
|
64 // Symbian 2nd phase constructor can leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void ChspsRomInstaller::ConstructL() |
|
68 { |
|
69 iInstallationHandler = ChspsInstallationHandler::NewL( iThemeServer ); |
|
70 |
|
71 // Prevent notifications from ROM based installations |
|
72 iInstallationHandler->DisableNotifications(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // ChspsRomInstaller::ChspsRomInstaller() |
|
77 // C++ default constructor can NOT contain any code, that might leave. |
|
78 // ----------------------------------------------------------------------------- |
|
79 ChspsRomInstaller::ChspsRomInstaller( |
|
80 ChspsThemeServer& aThemeServer, |
|
81 RFs& aFsSession ) |
|
82 : CActive(EPriorityStandard), |
|
83 iThemeServer(aThemeServer), |
|
84 iFsSession(aFsSession), |
|
85 iRet(EhspsInstallThemeFailed) |
|
86 { |
|
87 CActiveScheduler::Add( this ); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // ChspsRomInstaller::~ChspsRomInstaller() |
|
92 // Destructor. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 ChspsRomInstaller::~ChspsRomInstaller() |
|
96 { |
|
97 Cancel(); // Causes call to DoCancel() |
|
98 delete iInstallationHandler; |
|
99 iImportsArrayV1.ResetAndDestroy(); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // ChspsRomInstaller::SetImportsFilterL() |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 TBool ChspsRomInstaller::SetImportsFilterL( |
|
107 const TDesC& aFileFilter ) |
|
108 { |
|
109 TFindFile fileFinder( iFsSession ); |
|
110 CDir* fileList( NULL ); |
|
111 fileFinder.FindWildByDir( aFileFilter, KInstallDirectoryZ, fileList ); |
|
112 if ( fileList ) |
|
113 { |
|
114 CleanupStack::PushL( fileList ); |
|
115 |
|
116 TFileName sourceName; |
|
117 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
118 { |
|
119 const TEntry& entry = (*fileList)[i]; |
|
120 sourceName.Copy( KInstallDirectoryZ ); |
|
121 sourceName.Append( entry.iName ); |
|
122 iImportsArrayV1.AppendL( sourceName.AllocL() ); |
|
123 } |
|
124 |
|
125 CleanupStack::PopAndDestroy( fileList ); |
|
126 fileList = NULL; |
|
127 } |
|
128 |
|
129 return EFalse; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // ChspsRomInstaller::GetInstallationFoldersL() |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void ChspsRomInstaller::GetInstallationFoldersL( |
|
137 RPointerArray<HBufC>& aFolders ) |
|
138 { |
|
139 aFolders.ResetAndDestroy(); |
|
140 |
|
141 _LIT(KAllFolders, "*"); |
|
142 _LIT(KFolderSuffix, "\\"); |
|
143 CDir* fileList( NULL ); |
|
144 TFindFile fileFinder( iFsSession ); |
|
145 fileFinder.FindWildByDir( KAllFolders, KInstallDirectoryZ, fileList ); |
|
146 if ( fileList ) |
|
147 { |
|
148 CleanupStack::PushL( fileList ); |
|
149 |
|
150 TFileName sourceName; |
|
151 TBool verChecked = EFalse; |
|
152 for( TInt i = 0; i < fileList->Count(); i++ ) |
|
153 { |
|
154 const TEntry& entry = (*fileList)[i]; |
|
155 if ( entry.IsDir() ) |
|
156 { |
|
157 const TEntry& entry = (*fileList)[i]; |
|
158 sourceName.Copy( KInstallDirectoryZ ); |
|
159 sourceName.Append( entry.iName ); |
|
160 sourceName.Append( KFolderSuffix ); |
|
161 |
|
162 if ( !verChecked ) |
|
163 { |
|
164 // Check whether the V2 directory structure is available |
|
165 TFileName nameV2; |
|
166 nameV2.Copy( sourceName ); |
|
167 nameV2.Append( KHsps ); |
|
168 nameV2.Append( KFolderSuffix ); |
|
169 if( !BaflUtils::FolderExists( iFsSession, nameV2 ) ) |
|
170 { |
|
171 CleanupStack::PopAndDestroy( fileList ); |
|
172 return; |
|
173 } |
|
174 verChecked = ETrue; |
|
175 } |
|
176 |
|
177 aFolders.AppendL( sourceName.AllocL() ); |
|
178 } |
|
179 } |
|
180 |
|
181 CleanupStack::PopAndDestroy( fileList ); |
|
182 fileList = NULL; |
|
183 } |
|
184 } |
|
185 |
|
186 void ChspsRomInstaller::FindImportsV1L() |
|
187 { |
|
188 iImportsArrayV1.ResetAndDestroy(); |
|
189 SetImportsFilterL( KFilterAllPluginImportsV1 ); |
|
190 SetImportsFilterL( KFilterAllAppImportsV1 ); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // ChspsRomInstaller::ImportsV1 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 const RPointerArray<HBufC>& ChspsRomInstaller::ImportsV1() |
|
198 { |
|
199 return iImportsArrayV1; |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // ChspsRomInstaller::InstallThemeL |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 ThspsServiceCompletedMessage ChspsRomInstaller::InstallThemeL( |
|
207 const TDesC& aFileName ) |
|
208 { |
|
209 // Start installation by reading the manifest file |
|
210 iRet = iInstallationHandler->hspsInstallTheme( aFileName, iHeaderData ); |
|
211 if ( iRet == EhspsInstallThemeSuccess && !IsActive() ) |
|
212 { |
|
213 // Continue with remaining installation phases |
|
214 SetActive(); |
|
215 iInstallationHandler->hspsInstallNextPhaseL( iHeaderData, iStatus ); |
|
216 |
|
217 // Wait until the installation phases have been executed (async->sync) |
|
218 CActiveScheduler::Start(); |
|
219 } |
|
220 |
|
221 return iRet; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // ChspsRomInstaller::ReinstallThemeL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 ThspsServiceCompletedMessage ChspsRomInstaller::ReinstallThemeL( |
|
229 const TInt aAppUid, |
|
230 const TInt aConfigurationUid ) |
|
231 { |
|
232 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
|
233 |
|
234 iImportsArrayV1.ResetAndDestroy(); |
|
235 |
|
236 if ( aAppUid > 0 && aConfigurationUid > 0 ) |
|
237 { |
|
238 // Setup a filter for finding a specific import |
|
239 _LIT(KFormat, "app_%X_*_%X_1.0.dat"); |
|
240 HBufC* filter = HBufC::NewLC( KMaxFileName ); |
|
241 filter->Des().AppendFormat( KFormat, aAppUid, aConfigurationUid ); |
|
242 SetImportsFilterL( *filter ); |
|
243 CleanupStack::PopAndDestroy( filter ); |
|
244 |
|
245 // There should be only one import matching the UIDs |
|
246 if ( iImportsArrayV1.Count() == 1 ) |
|
247 { |
|
248 // Get path for a manifest from the import's file name |
|
249 HBufC* manifestBuf = iThemeServer.GetManifestFromImportLC( |
|
250 iImportsArrayV1[0]->Des(), |
|
251 KInstallDirectoryZ ); |
|
252 if ( manifestBuf ) |
|
253 { |
|
254 // Sync request |
|
255 ret = InstallThemeL( manifestBuf->Des() ); |
|
256 CleanupStack::PopAndDestroy( manifestBuf ); |
|
257 } |
|
258 } |
|
259 |
|
260 iImportsArrayV1.ResetAndDestroy(); |
|
261 } |
|
262 |
|
263 // Complete application configuration reinstallation |
|
264 ChspsODT* odt = ChspsODT::NewL(); |
|
265 CleanupStack::PushL( odt ); |
|
266 User::LeaveIfError( iThemeServer.GetConfigurationL( aAppUid, aConfigurationUid, *odt ) ); |
|
267 if ( odt->ConfigurationType() == EhspsAppConfiguration ) |
|
268 { |
|
269 // Add plugin configurations to the application configuration |
|
270 ChspsClientRequestHandler* clientReqHandler = ChspsClientRequestHandler::NewL( iThemeServer ); |
|
271 CleanupStack::PushL( clientReqHandler ); |
|
272 clientReqHandler->HandlePluginReferencesL( *odt ); |
|
273 CleanupStack::PopAndDestroy( clientReqHandler ); |
|
274 } |
|
275 CleanupStack::PopAndDestroy( odt ); |
|
276 |
|
277 return ret; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // ChspsRomInstaller::SetLogBus() |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 #ifdef HSPS_LOG_ACTIVE |
|
285 void ChspsRomInstaller::SetLogBus( ChspsLogBus* aLogBus ) |
|
286 { |
|
287 iLogBus = aLogBus; |
|
288 iInstallationHandler->SetLogBus( aLogBus ); |
|
289 } |
|
290 #endif |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // ChspsRomInstaller::RunError |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 TInt ChspsRomInstaller::RunError( TInt /*aError*/ ) |
|
297 { |
|
298 // Called when error occurred in asynchronous request |
|
299 CActiveScheduler::Stop(); |
|
300 return KErrNone; |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // ChspsRomInstaller::RunL |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void ChspsRomInstaller::RunL() |
|
308 { |
|
309 iRet = (ThspsServiceCompletedMessage)iStatus.Int(); |
|
310 switch ( iStatus.Int() ) |
|
311 { |
|
312 case EhspsInstallPhaseSuccess: |
|
313 { |
|
314 // Execute next phase of the installation |
|
315 if ( !IsActive() ) |
|
316 { |
|
317 SetActive(); |
|
318 iInstallationHandler->hspsInstallNextPhaseL( iHeaderData, iStatus ); |
|
319 } |
|
320 } |
|
321 break; |
|
322 |
|
323 case EhspsInstallThemeSuccess: |
|
324 case EhspsInstallThemeFailed: |
|
325 default: |
|
326 { |
|
327 // Allow continuation of the InstallTheme function |
|
328 CActiveScheduler::Stop(); |
|
329 } |
|
330 break; |
|
331 } |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // ChspsRomInstaller::DoCancel() |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void ChspsRomInstaller::DoCancel() |
|
339 { |
|
340 // Cancels any outstanding operation - nothing to do |
|
341 } |
|
342 |
|
343 // End of File |