93 // ----------------------------------------------------------------------------- |
99 // ----------------------------------------------------------------------------- |
94 // |
100 // |
95 ChspsRomInstaller::~ChspsRomInstaller() |
101 ChspsRomInstaller::~ChspsRomInstaller() |
96 { |
102 { |
97 Cancel(); // Causes call to DoCancel() |
103 Cancel(); // Causes call to DoCancel() |
98 delete iInstallationHandler; |
104 delete iInstallationHandler; |
99 iImportsArrayV1.ResetAndDestroy(); |
105 } |
100 } |
106 |
101 |
107 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
108 // ChspsRomInstaller::FindInstallationFilesL() |
103 // ChspsRomInstaller::SetImportsFilterL() |
109 // ----------------------------------------------------------------------------- |
104 // ----------------------------------------------------------------------------- |
110 // |
105 // |
111 void ChspsRomInstaller::FindInstallationFilesL( |
106 TBool ChspsRomInstaller::SetImportsFilterL( |
112 RPointerArray<HBufC>& aFolders ) |
107 const TDesC& aFileFilter ) |
113 { |
108 { |
114 __ASSERT_DEBUG( aFolders.Count() == 0, User::Leave( KErrArgument ) ); |
109 TFindFile fileFinder( iFsSession ); |
115 |
110 CDir* fileList( NULL ); |
116 DoFindInstallationFilesL( aFolders, KPrivateInstallC ); |
111 fileFinder.FindWildByDir( aFileFilter, KInstallDirectoryZ, fileList ); |
117 DoFindInstallationFilesL( aFolders, KPrivateInstallZ ); |
112 if ( fileList ) |
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // ChspsRomInstaller::DoFindInstallationFilesL() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void ChspsRomInstaller::DoFindInstallationFilesL( |
|
125 RPointerArray<HBufC>& aFolders, |
|
126 const TDesC& aPath ) |
|
127 { |
|
128 TFindFile fileFinder( iFsSession ); |
|
129 fileFinder.SetFindMask( |
|
130 KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted ); |
|
131 CDir* dirList( NULL ); |
|
132 fileFinder.FindWildByDir( KMaskAllFiles, aPath, dirList ); |
|
133 if ( dirList ) |
113 { |
134 { |
114 CleanupStack::PushL( fileList ); |
135 CleanupStack::PushL( dirList ); |
115 |
136 |
116 TFileName sourceName; |
137 const TInt count = dirList->Count(); |
117 for( TInt i = 0; i < fileList->Count(); i++ ) |
138 const TInt KMaxEntryLength = KMaxFileName - 50; |
|
139 for( TInt i = 0; i < count; i++ ) |
118 { |
140 { |
119 const TEntry& entry = (*fileList)[i]; |
141 const TEntry& dirEntry = (*dirList)[i]; |
120 sourceName.Copy( KInstallDirectoryZ ); |
142 if ( dirEntry.IsDir() ) |
121 sourceName.Append( entry.iName ); |
143 { |
122 iImportsArrayV1.AppendL( sourceName.AllocL() ); |
144 // Populate path for the manifest file |
123 } |
145 const TEntry& folderEntry = (*dirList)[i]; |
124 |
146 |
125 CleanupStack::PopAndDestroy( fileList ); |
147 // Check for length of the directory name |
126 fileList = NULL; |
148 if( dirEntry.iName.Length() > KMaxEntryLength ) |
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 { |
149 { |
164 // Check whether the V2 directory structure is available |
150 // Skip plugins which have too long name |
165 TFileName nameV2; |
151 continue; |
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 } |
152 } |
176 |
153 |
177 aFolders.AppendL( sourceName.AllocL() ); |
154 TFileName manifest( aPath ); |
|
155 manifest.Append( dirEntry.iName ); |
|
156 manifest.Append( KBackslash ); |
|
157 manifest.Append( KHsps ); |
|
158 manifest.Append( KBackslash ); |
|
159 manifest.Append( KTestLanguage ); |
|
160 manifest.Append( KBackslash ); |
|
161 manifest.Append( KManifest ); |
|
162 |
|
163 // Check for duplicates |
|
164 TBool isShadowed = EFalse; |
|
165 TParsePtrC manifestPtr( manifest ); |
|
166 for( TInt i=0; i < aFolders.Count(); i++ ) |
|
167 { |
|
168 TParsePtrC ptr( aFolders[i]->Des() ); |
|
169 if( ptr.Path() == manifestPtr.Path() ) |
|
170 { |
|
171 isShadowed = ETrue; |
|
172 break; |
|
173 } |
|
174 } |
|
175 |
|
176 if( !isShadowed ) |
|
177 { |
|
178 // Append the drive information (C or Z) |
|
179 TFileName driveIncluded; |
|
180 hspsServerUtil::FindFile( |
|
181 iFsSession, |
|
182 manifest, |
|
183 KNullDesC, |
|
184 driveIncluded ); |
|
185 if( driveIncluded.Length() ) |
|
186 { |
|
187 HBufC* nameBuf = driveIncluded.AllocLC(); |
|
188 aFolders.AppendL( nameBuf ); |
|
189 CleanupStack::Pop( nameBuf ); |
|
190 } |
|
191 } |
178 } |
192 } |
179 } |
193 } |
180 |
194 |
181 CleanupStack::PopAndDestroy( fileList ); |
195 CleanupStack::PopAndDestroy( dirList ); |
182 fileList = NULL; |
196 dirList = 0; |
|
197 } |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // ChspsRomInstaller::FindInstallationFileL |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void ChspsRomInstaller::FindInstallationFileL( |
|
205 const TInt aConfigurationUid, |
|
206 TFileName& aManifest ) |
|
207 { |
|
208 aManifest.FillZ(); |
|
209 |
|
210 _LIT(KFormat, "*_%X"); |
|
211 TFileName fileMask; |
|
212 fileMask.Format( KFormat, aConfigurationUid ); |
|
213 |
|
214 TFindFile fileFinder( iFsSession ); |
|
215 CDir* dirList( NULL ); |
|
216 fileFinder.FindWildByDir( fileMask, KPrivateInstallZ, dirList ); |
|
217 if ( !dirList ) |
|
218 { |
|
219 User::Leave( KErrNotFound ); |
|
220 } |
|
221 |
|
222 CleanupStack::PushL( dirList ); |
|
223 |
|
224 const TInt count = dirList->Count(); |
|
225 for( TInt i = 0; i < count; i++ ) |
|
226 { |
|
227 const TEntry& dirEntry = (*dirList)[i]; |
|
228 if ( dirEntry.IsDir() ) |
|
229 { |
|
230 // Populate path for the manifest file |
|
231 const TEntry& folderEntry = (*dirList)[i]; |
|
232 |
|
233 aManifest.Copy( KPrivateInstallZ ); |
|
234 aManifest.Append( dirEntry.iName ); |
|
235 aManifest.Append( KBackslash ); |
|
236 aManifest.Append( KHsps ); |
|
237 aManifest.Append( KBackslash ); |
|
238 aManifest.Append( KTestLanguage ); |
|
239 aManifest.Append( KBackslash ); |
|
240 aManifest.Append( KManifest ); |
|
241 break; |
|
242 } |
183 } |
243 } |
184 } |
244 CleanupStack::PopAndDestroy( dirList ); |
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 } |
245 } |
201 |
246 |
202 // ----------------------------------------------------------------------------- |
247 // ----------------------------------------------------------------------------- |
203 // ChspsRomInstaller::InstallThemeL |
248 // ChspsRomInstaller::InstallThemeL |
204 // ----------------------------------------------------------------------------- |
249 // ----------------------------------------------------------------------------- |
226 // ----------------------------------------------------------------------------- |
271 // ----------------------------------------------------------------------------- |
227 // |
272 // |
228 ThspsServiceCompletedMessage ChspsRomInstaller::ReinstallThemeL( |
273 ThspsServiceCompletedMessage ChspsRomInstaller::ReinstallThemeL( |
229 const TInt aAppUid, |
274 const TInt aAppUid, |
230 const TInt aConfigurationUid ) |
275 const TInt aConfigurationUid ) |
231 { |
276 { |
|
277 __ASSERT_DEBUG( aAppUid > 0 && aConfigurationUid > 0, User::Leave( KErrArgument ) ); |
|
278 |
232 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
279 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
233 |
280 |
234 iImportsArrayV1.ResetAndDestroy(); |
281 // Find an installation file from the ROM |
235 |
282 TFileName manifest; |
236 if ( aAppUid > 0 && aConfigurationUid > 0 ) |
283 FindInstallationFileL( |
237 { |
284 aConfigurationUid, |
238 // Setup a filter for finding a specific import |
285 manifest ); |
239 _LIT(KFormat, "app_%X_*_%X_1.0.dat"); |
286 if ( manifest.Length() > 0 ) |
240 HBufC* filter = HBufC::NewLC( KMaxFileName ); |
287 { |
241 filter->Des().AppendFormat( KFormat, aAppUid, aConfigurationUid ); |
288 // Install the plugin configuration (sync request) |
242 SetImportsFilterL( *filter ); |
289 ret = InstallThemeL( manifest ); |
243 CleanupStack::PopAndDestroy( filter ); |
290 } |
244 |
291 if( ret == EhspsInstallThemeSuccess ) |
245 // There should be only one import matching the UIDs |
292 { |
246 if ( iImportsArrayV1.Count() == 1 ) |
293 // The installed application configuration should now hold only plugin references, |
247 { |
294 // in addition it hasn't been updated to the header cache |
248 // Get path for a manifest from the import's file name |
295 iThemeServer.UpdateHeaderListCacheL(); |
249 HBufC* manifestBuf = iThemeServer.GetManifestFromImportLC( |
296 |
250 iImportsArrayV1[0]->Des(), |
297 // Complete reinstallation of the application configuration |
251 KInstallDirectoryZ ); |
298 ChspsODT* odt = ChspsODT::NewL(); |
252 if ( manifestBuf ) |
299 CleanupStack::PushL( odt ); |
253 { |
300 User::LeaveIfError( iThemeServer.GetConfigurationL( aAppUid, aConfigurationUid, *odt ) ); |
254 // Sync request |
301 if ( odt->ConfigurationType() == EhspsAppConfiguration ) |
255 ret = InstallThemeL( manifestBuf->Des() ); |
302 { |
256 CleanupStack::PopAndDestroy( manifestBuf ); |
303 ChspsClientRequestHandler* clientReqHandler = ChspsClientRequestHandler::NewL( iThemeServer ); |
257 } |
304 CleanupStack::PushL( clientReqHandler ); |
|
305 |
|
306 // Append configurations from referred plugins to the application configuration's DOM |
|
307 clientReqHandler->HandlePluginReferencesL( *odt ); |
|
308 |
|
309 CleanupStack::PopAndDestroy( clientReqHandler ); |
258 } |
310 } |
259 |
311 CleanupStack::PopAndDestroy( odt ); |
260 iImportsArrayV1.ResetAndDestroy(); |
|
261 } |
312 } |
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 |
313 |
277 return ret; |
314 return ret; |
278 } |
315 } |
279 |
316 |
280 // ----------------------------------------------------------------------------- |
317 // ----------------------------------------------------------------------------- |