25 #include "hspsthemeserver.h" |
25 #include "hspsthemeserver.h" |
26 #include "hspsinstallationhandler.h" |
26 #include "hspsinstallationhandler.h" |
27 #include "hspsclientrequesthandler.h" |
27 #include "hspsclientrequesthandler.h" |
28 #include "hspsserverutil.h" |
28 #include "hspsserverutil.h" |
29 |
29 |
|
30 _LIT(KPrivateInstallC, "C:\\private\\200159c0\\install\\"); |
|
31 _LIT(KPrivateInstallE, "E:\\private\\200159c0\\install\\"); |
30 _LIT(KPrivateInstallZ, "Z:\\private\\200159c0\\install\\"); |
32 _LIT(KPrivateInstallZ, "Z:\\private\\200159c0\\install\\"); |
31 _LIT(KPrivateInstallC, "C:\\private\\200159c0\\install\\"); |
33 |
32 _LIT(KMaskAllFiles, "*"); |
|
33 _LIT(KBackslash, "\\"); |
34 _LIT(KBackslash, "\\"); |
34 _LIT(KHsps, "hsps"); |
35 _LIT(KHsps, "hsps"); |
35 _LIT(KTestLanguage, "00"); |
36 _LIT(KTestLanguage, "00"); |
36 _LIT(KManifest, "manifest.dat"); |
37 _LIT(KManifest, "manifest.dat"); |
37 |
38 |
|
39 // ========================= LOCAL FUNCTIONS ================================== |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CleanupResetAndDestroy() |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 template<class T> |
|
46 static void CleanupResetAndDestroy( TAny* aObj ) |
|
47 { |
|
48 if( aObj ) |
|
49 { |
|
50 static_cast<T*>( aObj )->ResetAndDestroy(); |
|
51 } |
|
52 } |
|
53 |
|
54 // ---------------------------------------------------------------------------- |
|
55 // CleanupResetAndDestroyPushL |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 template<class T> |
|
59 static void CleanupResetAndDestroyPushL(T& aArray) |
|
60 { |
|
61 CleanupStack::PushL( TCleanupItem( &CleanupResetAndDestroy<T>, &aArray ) ); |
|
62 } |
38 |
63 |
39 // ========================= MEMBER FUNCTIONS ================================== |
64 // ========================= MEMBER FUNCTIONS ================================== |
40 |
65 |
41 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
42 // ChspsRomInstaller::NewL() |
67 // ChspsRomInstaller::NewL() |
108 // ChspsRomInstaller::InstallL() |
133 // ChspsRomInstaller::InstallL() |
109 // ----------------------------------------------------------------------------- |
134 // ----------------------------------------------------------------------------- |
110 // |
135 // |
111 void ChspsRomInstaller::InstallL() |
136 void ChspsRomInstaller::InstallL() |
112 { |
137 { |
113 RPointerArray<HBufC> pluginFolders; |
138 RPointerArray<HBufC> fileArray; |
114 CleanupClosePushL( pluginFolders ); |
139 CleanupResetAndDestroyPushL( fileArray ); |
115 |
140 |
116 // Find UDA and ROM widgets to be installed |
141 // Find UDA and ROM widgets to be installed |
117 FindInstallationFilesL( pluginFolders ); |
142 FindInstallationFilesL( fileArray ); |
118 |
143 |
119 // Install the manifest files |
144 // Install the manifest files |
120 for( TInt index=0; index < pluginFolders.Count(); index++ ) |
145 for( TInt index=0; index < fileArray.Count(); index++ ) |
121 { |
146 { |
122 TPtrC namePtr( pluginFolders[index]->Des() ); |
147 TPtrC namePtr( fileArray[index]->Des() ); |
123 |
148 |
124 // Synchronous method |
149 // Synchronous method |
125 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
150 ThspsServiceCompletedMessage ret = EhspsInstallThemeFailed; |
126 TRAP_IGNORE( ret = InstallThemeL( namePtr ) ); |
151 TRAP_IGNORE( ret = InstallThemeL( namePtr ) ); |
127 if ( ret != EhspsInstallThemeSuccess ) |
152 if ( ret != EhspsInstallThemeSuccess ) |
128 { |
153 { |
129 // User::Leave( KErrAbort ); |
154 // User::Leave( KErrAbort ); |
130 } |
155 } |
131 } |
156 } |
132 |
157 |
133 if ( pluginFolders.Count() == 0 ) |
158 if ( fileArray.Count() == 0 ) |
134 { |
159 { |
135 // Mandatory plugins were missing |
160 // Mandatory plugins were missing |
136 User::Leave( KErrCorrupt ); |
161 User::Leave( KErrCorrupt ); |
137 } |
162 } |
138 |
163 |
139 pluginFolders.ResetAndDestroy(); |
164 CleanupStack::PopAndDestroy(); // fileArray |
140 CleanupStack::PopAndDestroy( 1, &pluginFolders ); |
|
141 } |
165 } |
142 |
166 |
143 |
167 |
144 // ----------------------------------------------------------------------------- |
168 // ----------------------------------------------------------------------------- |
145 // ChspsRomInstaller::FindInstallationFilesL() |
169 // ChspsRomInstaller::FindInstallationFilesL() |
146 // ----------------------------------------------------------------------------- |
170 // ----------------------------------------------------------------------------- |
147 // |
171 // |
148 void ChspsRomInstaller::FindInstallationFilesL( |
172 void ChspsRomInstaller::FindInstallationFilesL( |
149 RPointerArray<HBufC>& aFolders ) |
173 RPointerArray<HBufC>& aFileArray ) |
150 { |
174 { |
151 __ASSERT_DEBUG( aFolders.Count() == 0, User::Leave( KErrArgument ) ); |
175 __ASSERT_DEBUG( aFileArray.Count() == 0, User::Leave( KErrArgument ) ); |
152 |
176 |
153 DoFindInstallationFilesL( aFolders, KPrivateInstallC ); |
177 DoFindInstallationFilesL( aFileArray, KPrivateInstallE ); |
154 DoFindInstallationFilesL( aFolders, KPrivateInstallZ ); |
178 DoFindInstallationFilesL( aFileArray, KPrivateInstallC ); |
|
179 DoFindInstallationFilesL( aFileArray, KPrivateInstallZ ); |
155 } |
180 } |
156 |
181 |
157 // ----------------------------------------------------------------------------- |
182 // ----------------------------------------------------------------------------- |
158 // ChspsRomInstaller::DoFindInstallationFilesL() |
183 // ChspsRomInstaller::DoFindInstallationFilesL() |
159 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
160 // |
185 // |
161 void ChspsRomInstaller::DoFindInstallationFilesL( |
186 void ChspsRomInstaller::DoFindInstallationFilesL( |
162 RPointerArray<HBufC>& aFolders, |
187 RPointerArray<HBufC>& aFileArray, |
163 const TDesC& aPath ) |
188 const TDesC& aPath ) |
164 { |
189 { |
165 TFindFile fileFinder( iFsSession ); |
190 TFindFile fileFinder( iFsSession ); |
166 fileFinder.SetFindMask( |
191 fileFinder.SetFindMask( |
167 KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted ); |
192 KDriveAttExclude|KDriveAttRemovable|KDriveAttRemote|KDriveAttSubsted ); |
168 CDir* dirList( NULL ); |
193 CDir* dirList( NULL ); |
169 fileFinder.FindWildByDir( KMaskAllFiles, aPath, dirList ); |
194 fileFinder.FindWildByPath( aPath, NULL, dirList ); |
170 if ( dirList ) |
195 if ( dirList ) |
171 { |
196 { |
172 CleanupStack::PushL( dirList ); |
197 CleanupStack::PushL( dirList ); |
173 |
198 |
174 const TInt count = dirList->Count(); |
199 const TInt count = dirList->Count(); |
175 const TInt KMaxEntryLength = KMaxFileName - 50; |
|
176 for( TInt i = 0; i < count; i++ ) |
200 for( TInt i = 0; i < count; i++ ) |
177 { |
201 { |
178 const TEntry& dirEntry = (*dirList)[i]; |
202 const TEntry& dirEntry = (*dirList)[i]; |
179 if ( dirEntry.IsDir() ) |
203 if ( dirEntry.IsDir() ) |
180 { |
204 { |
181 // Populate path for the manifest file |
|
182 const TEntry& folderEntry = (*dirList)[i]; |
|
183 |
|
184 // Check for length of the directory name |
|
185 if( dirEntry.iName.Length() > KMaxEntryLength ) |
|
186 { |
|
187 // Skip plugins which have too long name |
|
188 continue; |
|
189 } |
|
190 |
|
191 TFileName manifest( aPath ); |
205 TFileName manifest( aPath ); |
192 manifest.Append( dirEntry.iName ); |
206 manifest.Append( dirEntry.iName ); |
193 manifest.Append( KBackslash ); |
207 manifest.Append( KBackslash ); |
194 manifest.Append( KHsps ); |
208 manifest.Append( KHsps ); |
195 manifest.Append( KBackslash ); |
209 manifest.Append( KBackslash ); |
196 manifest.Append( KTestLanguage ); |
210 manifest.Append( KTestLanguage ); |
197 manifest.Append( KBackslash ); |
211 manifest.Append( KBackslash ); |
198 manifest.Append( KManifest ); |
212 manifest.Append( KManifest ); |
199 |
213 |
200 if( !BaflUtils::FileExists( iFsSession, manifest ) ) |
|
201 { |
|
202 continue; |
|
203 } |
|
204 |
|
205 // Check for duplicates |
214 // Check for duplicates |
206 TBool isShadowed = EFalse; |
215 TBool isShadowed = EFalse; |
207 TParsePtrC manifestPtr( manifest ); |
216 TParsePtrC manifestPtr( manifest ); |
208 for( TInt i=0; i < aFolders.Count(); i++ ) |
217 for( TInt i=0; i < aFileArray.Count(); i++ ) |
209 { |
218 { |
210 TParsePtrC ptr( aFolders[i]->Des() ); |
219 TParsePtrC ptr( aFileArray[i]->Des() ); |
211 if( ptr.Path() == manifestPtr.Path() ) |
220 if( ptr.Path() == manifestPtr.Path() ) |
212 { |
221 { |
213 isShadowed = ETrue; |
222 isShadowed = ETrue; |
214 break; |
223 break; |
215 } |
224 } |
216 } |
225 } |
217 |
226 |
218 if( !isShadowed ) |
227 if( !isShadowed ) |
219 { |
228 { |
220 // Append the drive information (C or Z) |
229 if( BaflUtils::FileExists( iFsSession, manifest ) ) |
221 TFileName driveIncluded; |
|
222 hspsServerUtil::FindFile( |
|
223 iFsSession, |
|
224 manifest, |
|
225 KNullDesC, |
|
226 driveIncluded ); |
|
227 if( driveIncluded.Length() ) |
|
228 { |
230 { |
229 HBufC* nameBuf = driveIncluded.AllocLC(); |
231 HBufC* nameBuf = manifest.AllocLC(); |
230 aFolders.AppendL( nameBuf ); |
232 aFileArray.AppendL( nameBuf ); |
231 CleanupStack::Pop( nameBuf ); |
233 CleanupStack::Pop( nameBuf ); |
232 } |
234 } |
233 } |
235 } |
234 } |
236 } |
235 } |
237 } |