|
1 /* |
|
2 * Copyright (c) 2008-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 * ScrHelperUtil class provides the list of functionalities needed to store and retrieve the |
|
16 * SIS Registry Object in to and from the Software Component Registry respectively. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 /** |
|
22 @file |
|
23 @released |
|
24 @internalComponent |
|
25 */ |
|
26 |
|
27 #include <e32uid.h> |
|
28 |
|
29 #include "scrhelperutil.h" |
|
30 #include "log.h" |
|
31 #include "scrdbconstants.h" |
|
32 #include "sisregistryobject.h" |
|
33 #include "sisregistrytoken.h" |
|
34 #include "sisregistrypackage.h" |
|
35 #include "hashcontainer.h" |
|
36 #include "sisproperties.h" |
|
37 #include "controllerinfo.h" |
|
38 #include "sisregistrydependency.h" |
|
39 #include "sisregistryfiledescription.h" |
|
40 #include "sisregistryproperty.h" |
|
41 #include "cleanuputils.h" |
|
42 #include <usif/usifcommon.h> |
|
43 #include <swi/sisregistrylog.h> |
|
44 #include <scs/streamingarray.h> |
|
45 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
46 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
47 #include "screntries_internal.h" |
|
48 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
49 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
50 |
|
51 using namespace Swi; |
|
52 |
|
53 // Store the SIS Registry Object details in to the Software Component Registry - SCR. |
|
54 // The component object should have been fully constructed before calling this method. |
|
55 void ScrHelperUtil::AddComponentL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::TComponentId& aCompId, CSisRegistryObject& aObject, Usif::TScrComponentOperationType aOpType) |
|
56 { |
|
57 WriteToScrL(aScrSession, aCompId, aObject, aOpType); |
|
58 ////StopTimerAndWriteResultL(timer, _L8(" WriteToScrL ")); |
|
59 // The default value of isRemovable is true in SCR - we change it only if needed |
|
60 if(aObject.iIsRemovable == EFalse) |
|
61 { |
|
62 aScrSession.SetIsComponentRemovableL(aCompId, aObject.IsRemovable()); |
|
63 } |
|
64 |
|
65 aScrSession.SetVendorNameL(aCompId, *(aObject.iVendorLocalizedName), aObject.Language()); |
|
66 |
|
67 if(KDefaultInstallType != aObject.InstallType()) |
|
68 { |
|
69 aScrSession.SetComponentPropertyL(aCompId, KCompInstallType, aObject.InstallType()); |
|
70 } |
|
71 |
|
72 if(KDefaultIsInRom != aObject.InRom()) |
|
73 { |
|
74 aScrSession.SetComponentPropertyL(aCompId, KCompInRom, aObject.InRom()); |
|
75 } |
|
76 |
|
77 if(KDefaultIsDeletablePreInstalled != aObject.DeletablePreInstalled()) |
|
78 { |
|
79 aScrSession.SetComponentPropertyL(aCompId, KCompDeletablePreinstalled, aObject.DeletablePreInstalled()); |
|
80 } |
|
81 |
|
82 if(KDefaultIsSigned != aObject.IsSigned()) |
|
83 { |
|
84 aScrSession.SetComponentPropertyL(aCompId, KCompIsSigned, aObject.IsSigned()); |
|
85 } |
|
86 |
|
87 if(KDefaultTrustValue != aObject.Trust()) |
|
88 { |
|
89 aScrSession.SetComponentPropertyL(aCompId, KCompTrust, aObject.Trust()); |
|
90 } |
|
91 |
|
92 if(KDefaultRemoveWithLastDependent != aObject.RemoveWithLastDependent()) |
|
93 { |
|
94 aScrSession.SetComponentPropertyL(aCompId, KCompIsRemoveWithLastDependent, aObject.RemoveWithLastDependent()); |
|
95 } |
|
96 |
|
97 aScrSession.SetComponentPropertyL(aCompId, KCompTrustTimeStamp, aObject.TrustTimeStamp().Int64()); |
|
98 |
|
99 if(KDefaultIsSignedBySuCert != aObject.IsSignedBySuCert()) |
|
100 { |
|
101 aScrSession.SetComponentPropertyL(aCompId, KCompSignedBySuCert, aObject.IsSignedBySuCert()); |
|
102 } |
|
103 |
|
104 if(KDefaultIsDrmProtected != aObject.IsDrmProtected()) |
|
105 { |
|
106 aScrSession.SetIsComponentDrmProtectedL(aCompId, aObject.IsDrmProtected()); |
|
107 } |
|
108 |
|
109 if(KDefaultIsComponentHidden != aObject.IsHidden()) |
|
110 { |
|
111 aScrSession.SetIsComponentHiddenL(aCompId, aObject.IsHidden()); |
|
112 } |
|
113 |
|
114 ExternalizeSupplierPackageArrayL(aScrSession, aObject.Uid(), aObject.Name(), aObject.InstallType(), aObject.iDependencies); |
|
115 ExternalizeEmbeddedPackageArrayL(aScrSession, aCompId, aObject.iEmbeddedPackages); |
|
116 ExternalizePropertiesArrayL(aScrSession, aCompId, aObject.iProperties); |
|
117 ExternalizeFileDescriptionsArrayL(aScrSession, aCompId, aObject.FileDescriptions()); |
|
118 WriteToScrL(aScrSession, aCompId, aObject.TrustStatus()); |
|
119 ExternalizeChainIndexArrayL(aScrSession, aCompId, aObject.InstallChainIndicies()); |
|
120 } |
|
121 |
|
122 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::TComponentId& aCompId, CSisRegistryObject& aObject, Usif::TScrComponentOperationType aOpType) |
|
123 { |
|
124 |
|
125 // Add the component name, it's vendor name and the supporting language in to the SCR. |
|
126 RPointerArray<Usif::CLocalizableComponentInfo> componentInfo; |
|
127 CleanupResetAndDestroyPushL(componentInfo); |
|
128 TInt matchingLanguageCount = aObject.GetLocalizedPackageNamesArray().Count(); |
|
129 Usif::CLocalizableComponentInfo* component; |
|
130 if( matchingLanguageCount > 0 ) |
|
131 { |
|
132 for(TInt i=0;i<matchingLanguageCount;i++) |
|
133 { |
|
134 component = Usif::CLocalizableComponentInfo::NewLC((*(aObject.GetLocalizedPackageNamesArray()[i])), (*(aObject.GetLocalizedVendorNamesArray()[i])), (TLanguage)aObject.GetSupportedLanguageIdsArray()[i]); |
|
135 componentInfo.AppendL(component); |
|
136 CleanupStack::Pop(component); |
|
137 } |
|
138 } |
|
139 else |
|
140 { |
|
141 component = Usif::CLocalizableComponentInfo::NewLC(aObject.Name(), aObject.Vendor(), aObject.Language()); |
|
142 componentInfo.AppendL(component); |
|
143 CleanupStack::Pop(component); |
|
144 } |
|
145 |
|
146 HBufC* compGlobalId = NULL; |
|
147 // For all SP and PP type packages, global Id is composed with package Uid and name. |
|
148 if (aObject.Index() > 0) |
|
149 { |
|
150 const TDesC& packageName = aObject.Name(); |
|
151 compGlobalId = HBufC::NewLC(KCompUidSize + packageName.Size()); |
|
152 TPtr ptr(compGlobalId->Des()); |
|
153 ptr.AppendFormat(KPatchGlobalIdFormat, aObject.Uid().iUid, &(aObject.Name())); |
|
154 } |
|
155 // For all other non-SP and non-PP packages the global Id is simply the package Uid. |
|
156 else |
|
157 { |
|
158 compGlobalId = HBufC::NewLC(KCompUidSize); |
|
159 TPtr ptr(compGlobalId->Des()); |
|
160 ptr.AppendFormat(KGlobalIdFormat, aObject.Uid().iUid); |
|
161 } |
|
162 |
|
163 aCompId = aScrSession.AddComponentL(componentInfo, KNativeSoftwareType, compGlobalId, aOpType); |
|
164 CleanupStack::PopAndDestroy(2, &componentInfo); |
|
165 |
|
166 // Write the SIS Registry Token details |
|
167 WriteToScrL(aScrSession, aCompId, static_cast<CSisRegistryToken&>(aObject)); |
|
168 } |
|
169 |
|
170 // Store the SIS Registry Token details in to the SCR. |
|
171 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::TComponentId& aCompId, CSisRegistryToken& aToken) |
|
172 { |
|
173 // First write the SIS Registry Package details |
|
174 WriteToScrL(aScrSession, aCompId, static_cast<CSisRegistryPackage&>(aToken)); |
|
175 // Format the version to text and store in the SCR. |
|
176 TBuf<KSmlBufferSize> versionString(KEmptyString); |
|
177 VersionToString(aToken.Version(), versionString); |
|
178 aScrSession.SetComponentVersionL(aCompId, versionString); |
|
179 // iDrives will be automatically populated by SCR |
|
180 ExternalizeSidArrayL(aScrSession, aCompId, aToken.Sids()); |
|
181 ExternalizeControllerArrayL(aScrSession, aCompId, aToken.ControllerInfo()); |
|
182 |
|
183 if (aToken.Language() != ELangEnglish) |
|
184 { |
|
185 // ROM stubs are typically set to English so save a few bytes in the database and a DB operation |
|
186 // for files installed as English |
|
187 aScrSession.SetComponentPropertyL(aCompId, KCompLanguage, static_cast<TInt32>(aToken.Language())); |
|
188 } |
|
189 |
|
190 if (aToken.SelectedDrive() != 0) |
|
191 { |
|
192 // ROM stubs are set to drive 0 - this optimisation avoids adding a custom property for these |
|
193 aScrSession.SetComponentPropertyL(aCompId, KCompSelectedDrive, static_cast<TInt32>(aToken.SelectedDrive())); |
|
194 } |
|
195 } |
|
196 |
|
197 // Store the SIS Registry Package details in to the SCR. |
|
198 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::TComponentId& aCompId, CSisRegistryPackage& aPackage) |
|
199 { |
|
200 // Store the Unique Vendor Name as a custom property |
|
201 aScrSession.SetComponentPropertyL(aCompId, KCompUniqueVendorName, *(aPackage.iVendorName)); |
|
202 |
|
203 aScrSession.SetComponentPropertyL(aCompId, KCompUid, static_cast<TInt32>(aPackage.iUid.iUid)); |
|
204 // The index is the Index of the component being installed. Always it will be 0 for SA type packages and |
|
205 // the index will start incrementing for each SP we install on top the base (SA) package. |
|
206 |
|
207 if (aPackage.Index() != KDefaultComponentIndex) |
|
208 aScrSession.SetComponentPropertyL(aCompId, KCompIndex, aPackage.Index()); |
|
209 } |
|
210 |
|
211 |
|
212 |
|
213 // Store the array of package's SID details in to the SCR. |
|
214 void ScrHelperUtil::ExternalizeSidArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const RArray<TUid>& aSids) |
|
215 { |
|
216 TBuf<KSmlBufferSize> compSid(KEmptyString); |
|
217 TInt sidCount = aSids.Count(); |
|
218 if(KDefaultSidCount != sidCount) |
|
219 aScrSession.SetComponentPropertyL(aCompId, KCompSidCount, sidCount); |
|
220 |
|
221 if(sidCount > 0) |
|
222 aScrSession.SetComponentPropertyL(aCompId, KCompSidsPresent, 1); |
|
223 |
|
224 for (TInt index = 0; index < sidCount; ++index) |
|
225 { |
|
226 compSid.Format(KCompSidFormat, index); |
|
227 aScrSession.SetComponentPropertyL(aCompId, compSid, static_cast<TUint>(aSids[index].iUid)); |
|
228 } |
|
229 } |
|
230 |
|
231 // Store the array of controllers in to the SCR. |
|
232 void ScrHelperUtil::ExternalizeControllerArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const RPointerArray<CControllerInfo>& aControllerInfoArray) |
|
233 { |
|
234 TInt controllerCount = aControllerInfoArray.Count(); |
|
235 if(KDefaultControllerCount != controllerCount) |
|
236 aScrSession.SetComponentPropertyL(aCompId, KCompControllerCount, controllerCount); |
|
237 |
|
238 for (TInt index = 0; index < controllerCount; ++index) |
|
239 { |
|
240 WriteToScrL(aScrSession, aCompId, *(aControllerInfoArray[index]), index); |
|
241 } |
|
242 } |
|
243 |
|
244 // Store the controller's details in to the SCR. |
|
245 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CControllerInfo& aControllerInfo, TInt aIndex) |
|
246 { |
|
247 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
248 TBuf<KSmlBufferSize> propertyValue(KEmptyString); |
|
249 |
|
250 propertyName.Format(KVersionNameFormat, aIndex); |
|
251 TVersion controllerVersion = aControllerInfo.Version(); |
|
252 if (controllerVersion.iMajor != KDefaultVersionMajor || controllerVersion.iMinor != KDefaultVersionMinor || |
|
253 controllerVersion.iBuild != KDefaultVersionBuild) |
|
254 |
|
255 { |
|
256 VersionToString(controllerVersion, propertyValue); |
|
257 aScrSession.SetComponentPropertyL(aCompId, propertyName, propertyValue); |
|
258 } |
|
259 |
|
260 // Multiple PU controllers on top of an SA will lead the offset values to be incremented by one for each PU. |
|
261 if (aControllerInfo.iOffset != 0) |
|
262 { |
|
263 // Most applications are SA's that have not been upgraded so use a default value of 0 |
|
264 propertyName.Format(KOffsetNameFormat, aIndex); |
|
265 aScrSession.SetComponentPropertyL(aCompId, propertyName, aControllerInfo.iOffset); |
|
266 } |
|
267 WriteToScrL(aScrSession, aCompId, *(aControllerInfo.iHashContainer), aIndex); |
|
268 } |
|
269 |
|
270 // Store the controller's hash details in to the SCR. |
|
271 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CHashContainer& aHashContainer, TInt aIndex) |
|
272 { |
|
273 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
274 |
|
275 propertyName.Format(KHashAlgorithmNameFormat, aIndex); |
|
276 if (aHashContainer.Algorithm() != CMessageDigest::ESHA1) |
|
277 aScrSession.SetComponentPropertyL(aCompId, propertyName, static_cast<TInt32>(aHashContainer.Algorithm())); |
|
278 |
|
279 propertyName.Format(KHashDataNameFormat, aIndex); |
|
280 aScrSession.SetComponentPropertyL(aCompId, propertyName, aHashContainer.Data()); |
|
281 } |
|
282 |
|
283 // Store the array of supplier package dependency details in to the SCR. |
|
284 // Supplier packages are the packages on which the current package is depending on. |
|
285 void ScrHelperUtil::ExternalizeSupplierPackageArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aCompUid, const TDesC& aCompName, Sis::TInstallType aInstallType, RPointerArray<CSisRegistryDependency>& aDependentPackageArray) |
|
286 { |
|
287 for (TInt index = 0; index < aDependentPackageArray.Count(); ++index) |
|
288 { |
|
289 WriteToScrL(aScrSession, aCompUid, aCompName, aInstallType, *(aDependentPackageArray[index])); |
|
290 } |
|
291 } |
|
292 |
|
293 // Store the details of one of the dependency package of given component in to SCR. |
|
294 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aCompUid, const TDesC& aCompName, Sis::TInstallType aInstallType, CSisRegistryDependency& aRegistryDependency) |
|
295 { |
|
296 TBuf <KCompUidSize> supplierGlobalIdString; |
|
297 TBuf<KSmlBufferSize> fromVersionString(KEmptyString); |
|
298 TBuf<KSmlBufferSize> toVersionString(KEmptyString); |
|
299 |
|
300 // Get the dependent details. |
|
301 HBufC* dependentGlobalIdString = FormatGlobalIdLC(aCompUid, aCompName, aInstallType); |
|
302 |
|
303 // Get the supplier details. |
|
304 supplierGlobalIdString.AppendFormat(KGlobalIdFormat, aRegistryDependency.iUid.iUid); |
|
305 |
|
306 VersionToString(aRegistryDependency.iFromVersion, fromVersionString); |
|
307 VersionToString(aRegistryDependency.iToVersion, toVersionString); |
|
308 |
|
309 // Create the component global id for both dependent and supplier. |
|
310 Usif::CGlobalComponentId* supplierGlobalId = Usif::CGlobalComponentId::NewLC(supplierGlobalIdString, Usif::KSoftwareTypeNative); |
|
311 Usif::CGlobalComponentId* dependentGlobalId = Usif::CGlobalComponentId::NewLC(*dependentGlobalIdString, Usif::KSoftwareTypeNative); |
|
312 |
|
313 // Create the versioned component Id for supplier. |
|
314 Usif::CVersionedComponentId* supplierVersionedCompId = Usif::CVersionedComponentId::NewLC(*supplierGlobalId, &fromVersionString, &toVersionString); |
|
315 |
|
316 // Add the dependency details in to SCR. |
|
317 TRAPD(err, aScrSession.AddComponentDependencyL(*supplierVersionedCompId, *dependentGlobalId)); |
|
318 // Since SWI allows multiple equal dependencies, we ignore KErrAlreadyExists |
|
319 if (err != KErrNone && err != KErrAlreadyExists) |
|
320 { |
|
321 User::Leave(err); |
|
322 } |
|
323 |
|
324 CleanupStack::PopAndDestroy(4, dependentGlobalIdString); |
|
325 } |
|
326 |
|
327 // Store details of the array of embedded packages of the given component in to SCR. |
|
328 void ScrHelperUtil::ExternalizeEmbeddedPackageArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryPackage>& aEmbeddedPackageArray) |
|
329 { |
|
330 TInt embeddedPackageCount = aEmbeddedPackageArray.Count(); |
|
331 if(KDefaultEmbeddedPackageCount != embeddedPackageCount) |
|
332 aScrSession.SetComponentPropertyL(aCompId, KCompEmbeddedPackageCount, embeddedPackageCount); |
|
333 |
|
334 if(embeddedPackageCount > 0) |
|
335 aScrSession.SetComponentPropertyL(aCompId, KCompEmbeddedPackagePresent, 1); |
|
336 |
|
337 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
338 for (TInt index = 0; index < embeddedPackageCount; ++index) |
|
339 { |
|
340 CSisRegistryPackage* package = aEmbeddedPackageArray[index]; |
|
341 // Store the package details |
|
342 propertyName.Format(KCompEmbeddedPackageUid, index); |
|
343 aScrSession.SetComponentPropertyL(aCompId, propertyName, package->Uid().iUid); |
|
344 |
|
345 propertyName.Format(KCompEmbeddedPackageName, index); |
|
346 aScrSession.SetComponentPropertyL(aCompId, propertyName, package->Name()); |
|
347 |
|
348 propertyName.Format(KCompEmbeddedPackageVendor, index); |
|
349 aScrSession.SetComponentPropertyL(aCompId, propertyName, package->Vendor()); |
|
350 |
|
351 propertyName.Format(KCompEmbeddedPackageIndex, index); |
|
352 aScrSession.SetComponentPropertyL(aCompId, propertyName, package->Index()); |
|
353 } |
|
354 } |
|
355 |
|
356 // Store the details of one of the embedded package of the given component in to SCR. |
|
357 void ScrHelperUtil::ExternalizePropertiesArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryProperty>& aRegistryPropertyArray) |
|
358 { |
|
359 TInt compPropertyCount = aRegistryPropertyArray.Count(); |
|
360 if(KDefaultCompPropertyCount != compPropertyCount) |
|
361 aScrSession.SetComponentPropertyL(aCompId, KCompPropertyCount, compPropertyCount); |
|
362 |
|
363 for (TInt index = 0; index < compPropertyCount; ++index) |
|
364 { |
|
365 WriteToScrL(aScrSession, aCompId, *(aRegistryPropertyArray[index]), index); |
|
366 } |
|
367 } |
|
368 |
|
369 // Store the SIS Registry property in to SCR. |
|
370 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryProperty& aRegistryProperty, TInt aIndex) |
|
371 { |
|
372 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
373 |
|
374 propertyName.Format(KCompPropertyKey, aIndex); |
|
375 aScrSession.SetComponentPropertyL(aCompId, propertyName, aRegistryProperty.iKey); |
|
376 |
|
377 propertyName.Format(KCompPropertyValue, aIndex); |
|
378 aScrSession.SetComponentPropertyL(aCompId, propertyName, aRegistryProperty.iValue); |
|
379 } |
|
380 |
|
381 TInt CompareDescriptors(const TPtrC &aLhs, const TPtrC& aRhs) |
|
382 { |
|
383 return aLhs.CompareF(aRhs); |
|
384 } |
|
385 |
|
386 // Store the array of owned file's details in to the SCR. |
|
387 // Wild carded files are stored as part of component custom property group. Where as the normal files are stored |
|
388 // as part of files property group. The wild carded files are used only in stub files and they are used only during |
|
389 // checking for eclipse validation during ROM upgrade. The wild carded files won't give file ownership information. |
|
390 void ScrHelperUtil::ExternalizeFileDescriptionsArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryFileDescription>& aFileDescriptionArray) |
|
391 { |
|
392 // As SCR won't support the wildcard characters on file names, if the file name has wildcard characters, |
|
393 // dont' store them as part file properties. Rather, store them as component custom properties only. |
|
394 TInt wildCardFileCount = 0; |
|
395 TInt executableFileIndex = 0; |
|
396 TInt64 componentSize = 0; |
|
397 // Since SCR does not check for duplicate entries, and they may occur in SWI, we filter them here |
|
398 // The file names are stored in a temporary array and compared with while iterating over file descriptions. Duplicates are skipped |
|
399 // Cannot use CDesC16ArrayFlat as it is in BAFL which the TCB sisregistryserver cannot link to |
|
400 |
|
401 RArray<TPtrC> filenamesArray; |
|
402 CleanupClosePushL(filenamesArray); |
|
403 |
|
404 TInt fileDescriptionsCount = aFileDescriptionArray.Count(); |
|
405 TLinearOrder<TPtrC> descriptorsComparator(&CompareDescriptors); |
|
406 for (TInt index = 0; index < fileDescriptionsCount; ++index) |
|
407 { |
|
408 |
|
409 const TDesC& fileTarget = aFileDescriptionArray[index]->Target(); |
|
410 TPtrC fileTargetPtr(fileTarget); |
|
411 if (filenamesArray.SpecificFindInOrder(fileTargetPtr, descriptorsComparator, EArrayFindMode_First) != KErrNotFound) |
|
412 continue; // Skip duplicates |
|
413 filenamesArray.InsertInOrder(fileTargetPtr, descriptorsComparator); |
|
414 |
|
415 if (IsWildcardFile(fileTarget)) |
|
416 { |
|
417 // Calls the method with ETrue if it's wild carded file. |
|
418 WriteToScrL(aScrSession, aCompId, *(aFileDescriptionArray[index]), ETrue, wildCardFileCount, -1); |
|
419 ++wildCardFileCount; |
|
420 } |
|
421 else |
|
422 { |
|
423 // If the file's SID value is not zero (only for EXEs) |
|
424 if (aFileDescriptionArray[index]->Sid().iUid != 0) |
|
425 { |
|
426 WriteToScrL(aScrSession, aCompId, *(aFileDescriptionArray[index]), EFalse, -1, executableFileIndex); |
|
427 ++executableFileIndex; |
|
428 } |
|
429 else |
|
430 { |
|
431 WriteToScrL(aScrSession, aCompId, *(aFileDescriptionArray[index]), EFalse, -1, -1); |
|
432 } |
|
433 // Get the each file size and accumulate it to get the whole component size. |
|
434 componentSize += aFileDescriptionArray[index]->UncompressedLength(); |
|
435 } |
|
436 } |
|
437 |
|
438 if (KDefaultWildCardFileCount != wildCardFileCount) |
|
439 aScrSession.SetComponentPropertyL(aCompId, KCompWildCardFileCount, wildCardFileCount); |
|
440 if (0 != componentSize) // For ROM components, the typical size is 0 which is also the default value at the SCR |
|
441 aScrSession.SetComponentSizeL(aCompId, componentSize); |
|
442 |
|
443 CleanupStack::PopAndDestroy(&filenamesArray); |
|
444 } |
|
445 |
|
446 // Store the owned files details in to the SCR. |
|
447 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryFileDescription& aFileDescription, |
|
448 TBool aIsWildcardedFile, TInt aIndex, TInt aExecutableFileIndex) |
|
449 { |
|
450 if (aIsWildcardedFile) |
|
451 { |
|
452 // SCR doesn't support the wildcard cahracters in file names. |
|
453 // So, store the object as a component custom property. |
|
454 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
455 propertyName.Format(KCompWildCardFile, aIndex); |
|
456 // For wild-carded files, all properties apart from the target are meaningless |
|
457 aScrSession.SetComponentPropertyL(aCompId, propertyName, aFileDescription.Target()); |
|
458 return; |
|
459 } |
|
460 |
|
461 // For normal file, store it using regular SCR file management APIs |
|
462 |
|
463 // Store the file name as component property to get the FileName related to a specific SID easily. |
|
464 // CSisRegistryPackage::iSids & CSisRegistryObject::iFileDescriptions are to be in sync. Otherwise, this mapping will fail. |
|
465 if (aExecutableFileIndex != -1) // Value will be -1 for non executables. |
|
466 { |
|
467 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
468 propertyName.Format(KCompSidFileNameFormat, aExecutableFileIndex); |
|
469 aScrSession.SetComponentPropertyL(aCompId, propertyName, aFileDescription.Target()); |
|
470 } |
|
471 |
|
472 TBool considerFileInDriveList = (aFileDescription.Operation() != Swi::Sis::EOpNull); |
|
473 // For OpNull, we shouldn't update the drive list, as the file does not actually exist, it is only registered for uninstall |
|
474 aScrSession.RegisterComponentFileL(aCompId, aFileDescription.Target(), considerFileInDriveList); |
|
475 |
|
476 if (aFileDescription.MimeType().Size() > 0) |
|
477 { |
|
478 RBuf8 mimeType8; |
|
479 mimeType8.CreateL(aFileDescription.MimeType().Size()); |
|
480 CleanupClosePushL(mimeType8); |
|
481 mimeType8.Copy(aFileDescription.MimeType()); |
|
482 aScrSession.SetFilePropertyL(aCompId, aFileDescription.Target(), KFileMimeType, mimeType8); |
|
483 CleanupStack::PopAndDestroy(&mimeType8); |
|
484 } |
|
485 |
|
486 if (aFileDescription.Operation() != Swi::Sis::EOpInstall) |
|
487 { |
|
488 aScrSession.SetFilePropertyL(aCompId, aFileDescription.Target(), KFileSisFileOperation, aFileDescription.Operation()); |
|
489 } |
|
490 |
|
491 if (aFileDescription.OperationOptions()) |
|
492 { |
|
493 aScrSession.SetFilePropertyL(aCompId, aFileDescription.Target(), KFileFileOperationOptions, aFileDescription.OperationOptions()); |
|
494 } |
|
495 |
|
496 if (aFileDescription.Sid().iUid) |
|
497 { |
|
498 aScrSession.SetFilePropertyL(aCompId, aFileDescription.Target(), KFileSid, aFileDescription.Sid().iUid); |
|
499 } |
|
500 |
|
501 WriteToScrL(aScrSession, aCompId, aFileDescription.Hash(), aFileDescription.Target()); |
|
502 } |
|
503 |
|
504 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const CHashContainer& aHashContainer, const TDesC& aFileName) |
|
505 { |
|
506 if (aHashContainer.Algorithm() != CMessageDigest::ESHA1) |
|
507 { |
|
508 aScrSession.SetFilePropertyL(aCompId, aFileName, KFileHashAlgorithm, static_cast<TInt32>(aHashContainer.Algorithm())); |
|
509 } |
|
510 |
|
511 if (aHashContainer.Data().Length() > 0) |
|
512 { |
|
513 aScrSession.SetFilePropertyL(aCompId, aFileName, KFileHashData, aHashContainer.Data()); |
|
514 } |
|
515 } |
|
516 |
|
517 // Store the SIS Trust Status to the Software Component Registry. |
|
518 void ScrHelperUtil::WriteToScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const TSisTrustStatus& aTrustStatus) |
|
519 { |
|
520 if(KDefaultValidationStatus != aTrustStatus.iValidationStatus) |
|
521 { |
|
522 aScrSession.SetComponentPropertyL(aCompId, KCompTrustValidationStatus, aTrustStatus.iValidationStatus); |
|
523 } |
|
524 |
|
525 if(KDefaultRevocationStatus != aTrustStatus.iRevocationStatus) |
|
526 { |
|
527 aScrSession.SetComponentPropertyL(aCompId, KCompTrustRevocationStatus, aTrustStatus.iRevocationStatus); |
|
528 } |
|
529 |
|
530 if(KDefaultGeneralDate != aTrustStatus.iResultDate.Int64()) |
|
531 { |
|
532 aScrSession.SetComponentPropertyL(aCompId, KCompTrustResultDate, aTrustStatus.iResultDate.Int64()); |
|
533 } |
|
534 |
|
535 if(KDefaultGeneralDate != aTrustStatus.iLastCheckDate.Int64()) |
|
536 { |
|
537 aScrSession.SetComponentPropertyL(aCompId, KCompTrustLastCheckDate, aTrustStatus.iLastCheckDate.Int64()); |
|
538 } |
|
539 |
|
540 if(KDefaultIsQuarantined != aTrustStatus.iQuarantined) |
|
541 { |
|
542 aScrSession.SetComponentPropertyL(aCompId, KCompTrustIsQuarantined, aTrustStatus.iQuarantined); |
|
543 } |
|
544 |
|
545 if(KDefaultGeneralDate != aTrustStatus.iQuarantinedDate.Int64()) |
|
546 { |
|
547 aScrSession.SetComponentPropertyL(aCompId, KCompTrustQuarantinedDate, aTrustStatus.iQuarantinedDate.Int64()); |
|
548 } |
|
549 |
|
550 // Update the 'Origin Verified' & 'Known Revoked' fields of the component |
|
551 // based on this object's validation status and revocation status respectively. |
|
552 if (aTrustStatus.iValidationStatus >= Swi::EValidatedToAnchor) |
|
553 { |
|
554 aScrSession.SetIsComponentOriginVerifiedL(aCompId, ETrue); |
|
555 } |
|
556 |
|
557 if (aTrustStatus.iRevocationStatus == Swi::EOcspRevoked) |
|
558 { |
|
559 aScrSession.SetIsComponentKnownRevokedL(aCompId, ETrue); |
|
560 } |
|
561 } |
|
562 |
|
563 // Store the Chain Index array elements to the Software Component Registry. |
|
564 void ScrHelperUtil::ExternalizeChainIndexArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const RArray<TInt>& aChainIndexArray) |
|
565 { |
|
566 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
567 TInt chainIndexCount = aChainIndexArray.Count(); |
|
568 if(KDefaultChainIndex != chainIndexCount) |
|
569 aScrSession.SetComponentPropertyL(aCompId, KCompInstallChainIndexCount, chainIndexCount); |
|
570 |
|
571 for (TInt index = 0; index < chainIndexCount; ++index) |
|
572 { |
|
573 propertyName.Format(KCompInstallChainIndex, index); |
|
574 aScrSession.SetComponentPropertyL(aCompId, propertyName, aChainIndexArray[index]); |
|
575 } |
|
576 } |
|
577 |
|
578 // Retrieve the SIS Registry Object details of the given component from Software Component Registry - SCR. |
|
579 void ScrHelperUtil::GetComponentL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryObject& aObject) |
|
580 { |
|
581 // First retrieve the user selected language to use it as the locale to retrive localized strings |
|
582 TLanguage userSelectedLanguage = static_cast<TLanguage>(GetIntPropertyValueL(aScrSession, aCompId, KCompLanguage, EFalse, ELangEnglish)); |
|
583 |
|
584 //Retrieve the locale information from ComponentLocalizable |
|
585 GetComponentLocalizedInfoL(aScrSession, aCompId, aObject); |
|
586 |
|
587 // Then get all properties of the component |
|
588 RPointerArray<Usif::CPropertyEntry> propertyArray; |
|
589 aScrSession.GetComponentPropertiesL(aCompId, propertyArray); |
|
590 CleanupResetAndDestroyPushL(propertyArray); |
|
591 |
|
592 // Get the component entry of the given Component Id and construct the registry object hierarchy. |
|
593 Usif::CComponentEntry* componentEntry = Usif::CComponentEntry::NewLC(); |
|
594 aScrSession.GetComponentL(aCompId, *componentEntry, userSelectedLanguage); |
|
595 |
|
596 // First read the SIS Registry Token |
|
597 ReadFromScrL(aScrSession, componentEntry, static_cast<CSisRegistryToken&>(aObject), &propertyArray); |
|
598 |
|
599 aObject.iIsRemovable = componentEntry->IsRemovable(); |
|
600 |
|
601 // Internalize other simple member variables of the object. |
|
602 // The values retrieved from the data base are casted according to the variable types. |
|
603 aObject.iVendorLocalizedName = componentEntry->Vendor().AllocL(); |
|
604 |
|
605 // Internalize the DRM protection status on the component |
|
606 aObject.iIsDrmProtected = componentEntry->IsDrmProtected(); |
|
607 |
|
608 // Internalize the 'hidden' nature of the component |
|
609 aObject.iIsHidden = componentEntry->IsHidden(); |
|
610 CleanupStack::PopAndDestroy(componentEntry); |
|
611 |
|
612 aObject.iTrustTimeStamp = TTime(GetInt64PropertyValueL(aScrSession, aCompId, KCompTrustTimeStamp, ETrue)); |
|
613 // Assign default values |
|
614 aObject.iInstallType = KDefaultInstallType; |
|
615 aObject.iInRom = KDefaultIsInRom; |
|
616 aObject.iDeletablePreInstalled = KDefaultIsDeletablePreInstalled; |
|
617 aObject.iSigned = KDefaultIsSigned; |
|
618 aObject.iTrust = KDefaultTrustValue; |
|
619 aObject.iRemoveWithLastDependent = KDefaultRemoveWithLastDependent; |
|
620 aObject.iSignedBySuCert = KDefaultIsSignedBySuCert; |
|
621 |
|
622 // Check the retrieved properties to see if the properties assigned with default values exist. |
|
623 // Update the existing properties with the retrieved property values. |
|
624 TInt propertyCount = propertyArray.Count(); |
|
625 for(TInt i=0; i<propertyCount; ++i) |
|
626 { |
|
627 const TDesC& propertyName = propertyArray[i]->PropertyName(); |
|
628 if(Usif::CPropertyEntry::EIntProperty != propertyArray[i]->PropertyType()) |
|
629 continue; // In this loop, only integer properties are checked. Ignore binary and localizable properties. |
|
630 |
|
631 Usif::CIntPropertyEntry* property = static_cast<Usif::CIntPropertyEntry*>(propertyArray[i]); |
|
632 TInt value = property->IntValue(); |
|
633 |
|
634 if(KCompInstallType() == propertyName) |
|
635 { |
|
636 aObject.iInstallType = static_cast<Sis::TInstallType>(value); |
|
637 } |
|
638 else if(KCompInRom() == propertyName) |
|
639 { |
|
640 aObject.iInRom = static_cast<TBool>(value); |
|
641 } |
|
642 else if(KCompDeletablePreinstalled() == propertyName) |
|
643 { |
|
644 aObject.iDeletablePreInstalled = static_cast<TBool>(value); |
|
645 } |
|
646 else if(KCompIsSigned() == propertyName) |
|
647 { |
|
648 aObject.iSigned = static_cast<TBool>(value); |
|
649 } |
|
650 else if(KCompTrust() == propertyName) |
|
651 { |
|
652 aObject.iTrust = static_cast<TSisPackageTrust>(value); |
|
653 } |
|
654 else if(KCompIsRemoveWithLastDependent() == propertyName) |
|
655 { |
|
656 aObject.iRemoveWithLastDependent = value; |
|
657 } |
|
658 else if(KCompSignedBySuCert() == propertyName) |
|
659 { |
|
660 aObject.iSignedBySuCert = static_cast<TBool>(value); |
|
661 } |
|
662 } |
|
663 |
|
664 // Internalize the other array members of the object. |
|
665 InternalizeSupplierPackageArrayL(aScrSession, aObject.Uid(), aObject.Name(), aObject.iInstallType, aObject.iDependencies); |
|
666 InternalizeEmbeddedPackageArrayL(aScrSession, aCompId, aObject.iEmbeddedPackages, &propertyArray); |
|
667 InternalizePropertiesArrayL(aScrSession, aCompId, aObject.iProperties, &propertyArray); |
|
668 InternalizeFileDescriptionsArrayL(aScrSession, aCompId, aObject.iFileDescriptions); |
|
669 aObject.iOwnedFileDescriptions = aObject.iFileDescriptions.Count(); |
|
670 ReadFromScrL(aScrSession, aCompId, aObject.iTrustStatus, &propertyArray); |
|
671 InternalizeChainIndexArrayL(aScrSession, aCompId, aObject.iInstallChainIndices, &propertyArray); |
|
672 CleanupStack::PopAndDestroy(&propertyArray); |
|
673 } |
|
674 |
|
675 // Retrieve the localizable details of a given component from Software Component Registry - SCR. |
|
676 void ScrHelperUtil::GetComponentLocalizedInfoL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryObject& aObject) |
|
677 { |
|
678 DEBUG_PRINTF2(_L8("Retrieve the localized information related to component with CompId:%d"),aCompId); |
|
679 RPointerArray<Usif::CLocalizableComponentInfo> compLocalizedInfoArray; |
|
680 CleanupResetAndDestroyPushL(compLocalizedInfoArray); |
|
681 aScrSession.GetComponentLocalizedInfoL(aCompId, compLocalizedInfoArray); |
|
682 for(TInt i=0;i<compLocalizedInfoArray.Count();i++) |
|
683 { |
|
684 aObject.iLocalizedPackageNames.AppendL((compLocalizedInfoArray[i]->NameL()).AllocL()); |
|
685 aObject.iLocalizedVendorNames.AppendL((compLocalizedInfoArray[i]->VendorL()).AllocL()); |
|
686 aObject.iSupportedLanguageIds.AppendL(compLocalizedInfoArray[i]->Locale()); |
|
687 } |
|
688 CleanupStack::Pop(&compLocalizedInfoArray); |
|
689 compLocalizedInfoArray.ResetAndDestroy(); |
|
690 } |
|
691 TBool ScrHelperUtil::IsUidPresentL(const Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aPackageUid) |
|
692 { |
|
693 Usif::TComponentId dummyComponentId(0); |
|
694 return GetComponentIdL(aScrSession, aPackageUid, CSisRegistryPackage::PrimaryIndex, dummyComponentId); // If the base package for the UID does not exist, then it cannot be present on the system |
|
695 } |
|
696 |
|
697 TBool ScrHelperUtil::IsUidAndNamePresentL(const Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aUid, const TDesC& aPackageName) |
|
698 { |
|
699 // Get all components for the given UID and perform a comparison with package names |
|
700 // Note that we cannot apply package names on the filter |
|
701 // Get the right component id matching with the package UID, name and index. |
|
702 Usif::CComponentFilter* componentFilter = Usif::CComponentFilter::NewLC(); |
|
703 componentFilter->SetSoftwareTypeL(Usif::KSoftwareTypeNative); |
|
704 componentFilter->AddPropertyL(KCompUid, aUid.iUid); |
|
705 |
|
706 Usif::RSoftwareComponentRegistryView subSession; |
|
707 CleanupClosePushL(subSession); |
|
708 subSession.OpenViewL(aScrSession, componentFilter); |
|
709 Usif::CComponentEntry* compEntry = NULL; |
|
710 TBool found = EFalse; |
|
711 while (!found && (compEntry = subSession.NextComponentL()) != NULL) |
|
712 { |
|
713 CleanupStack::PushL(compEntry); |
|
714 if (compEntry->Name() == aPackageName) |
|
715 { |
|
716 found = ETrue; |
|
717 } |
|
718 CleanupStack::PopAndDestroy(compEntry); |
|
719 } |
|
720 CleanupStack::PopAndDestroy(2, componentFilter); // subSession |
|
721 |
|
722 if (!found) |
|
723 { |
|
724 DEBUG_PRINTF2(_L8("Sis Registry Server - Retrieving Component ID for the given UID (%d) failed."), aUid.iUid); |
|
725 DEBUG_PRINTF2(_L8("Error : %d. Component not found in the SCR."), KErrNotFound); |
|
726 return EFalse; |
|
727 } |
|
728 |
|
729 return ETrue; |
|
730 } |
|
731 |
|
732 // Queries the SCR for a component ID matching with the given values for Package UID and Package Index |
|
733 // Returns EFalse, if not found. Returns ETrue if found, and returns the component id in the [out] parameter in such case |
|
734 TBool ScrHelperUtil::GetComponentIdL(const Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aPackageUid, const TInt aPackageIndex, Usif::TComponentId& aComponentId) |
|
735 { |
|
736 // Setup a filter based on the input parameters |
|
737 Usif::CComponentFilter* compFilter = Usif::CComponentFilter::NewLC(); |
|
738 compFilter->AddPropertyL(KCompUid, aPackageUid.iUid); |
|
739 |
|
740 compFilter->SetSoftwareTypeL(Usif::KSoftwareTypeNative); |
|
741 |
|
742 RArray<Usif::TComponentId> componentIdList; |
|
743 CleanupClosePushL(componentIdList); |
|
744 aScrSession.GetComponentIdsL(componentIdList, compFilter); |
|
745 |
|
746 if(componentIdList.Count() == 0) |
|
747 { |
|
748 // No components are found in the SCR. So, return false |
|
749 CleanupStack::PopAndDestroy(2, compFilter); // componentIdList |
|
750 DEBUG_PRINTF2(_L8("Sis Registry Server - Unable to find component for UID: %x"), aPackageUid.iUid); |
|
751 return EFalse; |
|
752 } |
|
753 // Filtering on KCompIndex is expensive in the SCR, as many values would be zero and the index is ineffective causing many comparisons in the DB. Usually the number of |
|
754 // components matching the UID is low (as these are the base package + augmentations). |
|
755 TBool matchingIndexFound = EFalse; |
|
756 for (TInt i = 0; i < componentIdList.Count(); ++i) |
|
757 { |
|
758 TInt componentIndex = GetIntPropertyValueL(aScrSession, componentIdList[i], KCompIndex, EFalse, KDefaultComponentIndex); |
|
759 if (componentIndex == aPackageIndex) |
|
760 { |
|
761 aComponentId = componentIdList[i]; |
|
762 matchingIndexFound = ETrue; |
|
763 break; |
|
764 } |
|
765 } |
|
766 |
|
767 CleanupStack::PopAndDestroy(2, compFilter); // componentIdList |
|
768 if (!matchingIndexFound) |
|
769 { |
|
770 DEBUG_PRINTF3(_L8("Sis Registry Server - Unable to find matching package for UID %d and index %d"), aPackageUid.iUid, aPackageIndex); |
|
771 return EFalse; |
|
772 } |
|
773 |
|
774 return ETrue; |
|
775 } |
|
776 |
|
777 // Queries the SCR for a component ID matching with the given values for Package UID and Package Index |
|
778 // Leaves with KErrNone if the a corresponding component cannot be found |
|
779 |
|
780 Usif::TComponentId ScrHelperUtil::GetComponentIdL(const Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aPackageUid, const TInt aPackageIndex) |
|
781 { |
|
782 Usif::TComponentId compId; |
|
783 if (!GetComponentIdL(aScrSession, aPackageUid, aPackageIndex, compId)) |
|
784 User::Leave(KErrNotFound); |
|
785 |
|
786 return compId; |
|
787 } |
|
788 |
|
789 // Queries the SCR for a component ID matching with the given values for Package Name and Package Vendor Name. |
|
790 // Returns the matching component Id, if succeeds. Otherwise, it leaves with relevant error code. |
|
791 // NOTE: There can be multiple such components and this API returns the first one found! |
|
792 Usif::TComponentId ScrHelperUtil::GetComponentIdL(const Usif::RSoftwareComponentRegistry& aScrSession, const TDesC& aPackageName, const TDesC& aVendorName) |
|
793 { |
|
794 Usif::TComponentId compId; |
|
795 if (!GetComponentIdL(aScrSession, aPackageName, aVendorName, compId)) |
|
796 User::Leave(KErrNotFound); |
|
797 |
|
798 return compId; |
|
799 } |
|
800 |
|
801 // Queries the SCR for a component ID matching with the given values for Package Name and Package Vendor Name. |
|
802 // Returns true iff the component exists. Uses the out parameter for setting the component's id in such case |
|
803 // NOTE: There can be multiple such components and this API returns the first one found! |
|
804 TBool ScrHelperUtil::GetComponentIdL(const Usif::RSoftwareComponentRegistry& aScrSession, const TDesC& aPackageName, const TDesC& aVendorName, Usif::TComponentId& aComponentId) |
|
805 { |
|
806 // Get the right component id matching with the package UID, name and vendor name. |
|
807 Usif::CComponentFilter* componentFilter = Usif::CComponentFilter::NewLC(); |
|
808 componentFilter->SetSoftwareTypeL(Usif::KSoftwareTypeNative); |
|
809 componentFilter->SetNameL(aPackageName); |
|
810 componentFilter->AddPropertyL(KCompUniqueVendorName, aVendorName, Usif::KNonLocalized); |
|
811 |
|
812 RArray<Usif::TComponentId> componentIdList; |
|
813 CleanupClosePushL(componentIdList); |
|
814 aScrSession.GetComponentIdsL(componentIdList, componentFilter); |
|
815 |
|
816 if(componentIdList.Count() == 0) |
|
817 { |
|
818 // No components are found in the SCR. So, return FALSE |
|
819 CleanupStack::PopAndDestroy(2, componentFilter); // componentIdList |
|
820 DEBUG_PRINTF3(_L("Sis Registry Server - Component ID not found for the given name (%S) and vendor (%S)."), |
|
821 &aPackageName, &aVendorName); |
|
822 return EFalse; |
|
823 } |
|
824 // If found, get the corresponding Component Id and return it. |
|
825 aComponentId = componentIdList[0]; |
|
826 |
|
827 CleanupStack::PopAndDestroy(2, componentFilter); // componentIdList |
|
828 return ETrue; |
|
829 } |
|
830 |
|
831 // Retrieve the SIS Registry Token details. |
|
832 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::CComponentEntry* aComponentEntry, CSisRegistryToken& aToken, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
833 { |
|
834 // First read the SIS Registry Package |
|
835 ReadFromScrL(aScrSession, aComponentEntry, static_cast<CSisRegistryPackage&>(aToken)); |
|
836 |
|
837 InternalizeSidArrayL(aScrSession, aComponentEntry->ComponentId(), aToken.iSids, aPropertyArray); |
|
838 InternalizeControllerArrayL(aScrSession, aComponentEntry->ComponentId(), aToken.iControllerInfo, aPropertyArray); |
|
839 |
|
840 // Reset the Installed Drives |
|
841 aToken.iDrives = 0; |
|
842 // Convert the TDriveList format to the BitMask format. |
|
843 TDriveList driveList = aComponentEntry->InstalledDrives(); |
|
844 MakeDrivesFromStringL(driveList, aToken.iDrives); |
|
845 // Since the wild carded files are not stored as part of FilesProperties, |
|
846 // SCR won't populate the installed drives itself. |
|
847 // So, for wild carded ROM packages, we will manually populate the iDrives with Z. |
|
848 TInt wildCardFileCount = GetIntPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompWildCardFileCount, EFalse, KDefaultWildCardFileCount); |
|
849 if (wildCardFileCount > 0) |
|
850 { |
|
851 aToken.iDrives |= 1 << EDriveZ; |
|
852 } |
|
853 |
|
854 // Get the version. |
|
855 StringToVersionL(aComponentEntry->Version(), aToken.iVersion); |
|
856 |
|
857 aToken.iLanguage = static_cast<TLanguage>(GetIntPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompLanguage, EFalse, ELangEnglish)); |
|
858 aToken.iSelectedDrive = static_cast<TChar>(GetIntPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompSelectedDrive, EFalse)); |
|
859 } |
|
860 |
|
861 // Retrieve the SIS Registry Package details. |
|
862 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, Usif::CComponentEntry* aComponentEntry, CSisRegistryPackage& aPackage) |
|
863 { |
|
864 aPackage.iUid.iUid = GetIntPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompUid, ETrue); |
|
865 aPackage.iPackageName = aComponentEntry->Name().AllocL(); |
|
866 aPackage.iVendorName = GetStrPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompUniqueVendorName); |
|
867 aPackage.iIndex = GetIntPropertyValueL(aScrSession, aComponentEntry->ComponentId(), KCompIndex, EFalse, KDefaultComponentIndex); |
|
868 } |
|
869 |
|
870 // Retrieve the component's array of SID details from SCR. |
|
871 void ScrHelperUtil::InternalizeSidArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RArray<TUid>& aSidsArray, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
872 { |
|
873 TBuf<KSmlBufferSize> compSid(KEmptyString); |
|
874 TInt sidCount = 0; |
|
875 if(aPropertyArray) |
|
876 sidCount = GetIntegerPropertyValueFromArrayL(KCompSidCount, KDefaultSidCount, *aPropertyArray); |
|
877 else |
|
878 sidCount = GetIntPropertyValueL(aScrSession, aCompId, KCompSidCount, EFalse, KDefaultSidCount); |
|
879 |
|
880 for (TInt index = 0; index < sidCount; ++index) |
|
881 { |
|
882 compSid.Format(KCompSidFormat, index); |
|
883 TUid tUid = TUid::Uid(GetIntPropertyValueL(aScrSession, aCompId, compSid, ETrue)); |
|
884 aSidsArray.AppendL(tUid); |
|
885 } |
|
886 } |
|
887 |
|
888 // Retrieve the array of controlller's details for the given component from SCR. |
|
889 void ScrHelperUtil::InternalizeControllerArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CControllerInfo>& aControllerInfoArray, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
890 { |
|
891 TInt controllerCount = 0; |
|
892 if(aPropertyArray) |
|
893 controllerCount = GetIntegerPropertyValueFromArrayL(KCompControllerCount, KDefaultControllerCount, *aPropertyArray); |
|
894 else |
|
895 controllerCount = GetIntPropertyValueL(aScrSession, aCompId, KCompControllerCount, EFalse, KDefaultControllerCount); |
|
896 |
|
897 for (TInt index = 0; index < controllerCount; ++index) |
|
898 { |
|
899 CControllerInfo* controllerInfo = NULL; |
|
900 ReadFromScrL(aScrSession, aCompId, controllerInfo, index); |
|
901 CleanupStack::PushL(controllerInfo); |
|
902 aControllerInfoArray.AppendL(controllerInfo); |
|
903 CleanupStack::Pop(controllerInfo); |
|
904 } |
|
905 } |
|
906 |
|
907 // Retrieve the given controller details from SCR. |
|
908 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CControllerInfo*& aControllerInfo, TInt aIndex) |
|
909 { |
|
910 TVersion version(KDefaultVersionMajor, KDefaultVersionMinor, KDefaultVersionBuild); |
|
911 TInt offset; |
|
912 CHashContainer* hashContainer = NULL; |
|
913 |
|
914 TBuf<KBigBufferSize> controllerVersionName(KEmptyString); |
|
915 TBuf<KBigBufferSize> controllerOffsetName(KEmptyString); |
|
916 HBufC* controllerVersionPointer = NULL; |
|
917 |
|
918 controllerVersionName.Format(KVersionNameFormat, aIndex); |
|
919 controllerVersionPointer = GetStrPropertyValueL(aScrSession, aCompId, controllerVersionName, Usif::KUnspecifiedLocale, EFalse); |
|
920 if (controllerVersionPointer) // The value is optional in the DB - assumed default if not present |
|
921 { |
|
922 StringToVersionL(controllerVersionPointer->Des(), version); |
|
923 delete controllerVersionPointer; |
|
924 } |
|
925 |
|
926 controllerOffsetName.Format(KOffsetNameFormat, aIndex); |
|
927 offset = GetIntPropertyValueL(aScrSession, aCompId, controllerOffsetName, EFalse, 0); |
|
928 ReadFromScrL(aScrSession, aCompId, hashContainer, aIndex); |
|
929 CleanupStack::PushL(hashContainer); |
|
930 aControllerInfo = CControllerInfo::NewL(version, *hashContainer, offset); |
|
931 CleanupStack::PopAndDestroy(hashContainer); |
|
932 } |
|
933 |
|
934 // Retrieve the hash details of the controller. |
|
935 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CHashContainer*& aHashContainer, TInt aIndex) |
|
936 { |
|
937 CMessageDigest::THashId algorithm; |
|
938 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
939 |
|
940 propertyName.Format(KHashAlgorithmNameFormat, aIndex); |
|
941 algorithm = static_cast<CMessageDigest::THashId>(GetIntPropertyValueL(aScrSession, aCompId, propertyName, EFalse, CMessageDigest::ESHA1)); |
|
942 |
|
943 propertyName.Format(KHashDataNameFormat, aIndex); |
|
944 HBufC8* data = GetBinaryPropertyValueL(aScrSession, aCompId, propertyName); |
|
945 CleanupStack::PushL(data); |
|
946 aHashContainer = CHashContainer::NewL(algorithm, *data); |
|
947 CleanupStack::PopAndDestroy(data); |
|
948 } |
|
949 |
|
950 // Retrieve the array of supplier package details for the given component. |
|
951 // Supplier packages are the packages on which the current package is depending on. |
|
952 void ScrHelperUtil::InternalizeSupplierPackageArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const TUid& aCompUid, const TDesC& aCompName, Sis::TInstallType aInstallType, RPointerArray<CSisRegistryDependency>& aDependentPackageArray) |
|
953 { |
|
954 RPointerArray<Usif::CVersionedComponentId> supplierCompList; |
|
955 CleanupResetAndDestroyPushL(supplierCompList); |
|
956 |
|
957 HBufC* dependentGlobalIdString = FormatGlobalIdLC(aCompUid, aCompName, aInstallType); |
|
958 |
|
959 Usif::CGlobalComponentId* dependentGlobalId = Usif::CGlobalComponentId::NewLC(*dependentGlobalIdString, Usif::KSoftwareTypeNative); |
|
960 |
|
961 aScrSession.GetSupplierComponentsL(*dependentGlobalId, supplierCompList); |
|
962 CleanupStack::PopAndDestroy(2, dependentGlobalIdString); |
|
963 |
|
964 for (TInt index = 0; index < supplierCompList.Count(); ++index) |
|
965 { |
|
966 // Create the object from SCR and append it to the array. |
|
967 CSisRegistryDependency* dependency = NULL; |
|
968 ReadFromScrL(*(supplierCompList[index]), dependency); |
|
969 CleanupStack::PushL(dependency); |
|
970 aDependentPackageArray.AppendL(dependency); |
|
971 CleanupStack::Pop(dependency); |
|
972 } |
|
973 CleanupStack::PopAndDestroy(&supplierCompList); |
|
974 } |
|
975 |
|
976 // Retrieve the package dependency details of the given component. |
|
977 void ScrHelperUtil::ReadFromScrL(Usif::CVersionedComponentId& aVersionedSupplierCompId, CSisRegistryDependency*& aRegistryDependency) |
|
978 { |
|
979 TUid tUid; |
|
980 TVersion fromVersion; |
|
981 TVersion toVersion; |
|
982 |
|
983 // Get the supplier package details. The supplier Uid if extracted from it's global Id. |
|
984 const Usif::CGlobalComponentId &supplierGlobalId = aVersionedSupplierCompId.GlobalId(); |
|
985 ExtractCompUidL(supplierGlobalId.GlobalIdName(), tUid); |
|
986 |
|
987 StringToVersionL(*(aVersionedSupplierCompId.VersionFrom()), fromVersion); |
|
988 StringToVersionL(*(aVersionedSupplierCompId.VersionTo()), toVersion); |
|
989 |
|
990 aRegistryDependency = CSisRegistryDependency::NewL(tUid, fromVersion, toVersion); |
|
991 } |
|
992 |
|
993 // Retrieve the array of embedded packages of the given component. |
|
994 void ScrHelperUtil::InternalizeEmbeddedPackageArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryPackage>& aEmbeddedPackageArray, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
995 { |
|
996 TInt embedCount = 0; |
|
997 if(aPropertyArray) |
|
998 embedCount = GetIntegerPropertyValueFromArrayL(KCompEmbeddedPackageCount, KDefaultEmbeddedPackageCount, *aPropertyArray); |
|
999 else |
|
1000 embedCount = GetIntPropertyValueL(aScrSession, aCompId, KCompEmbeddedPackageCount, EFalse, KDefaultEmbeddedPackageCount); |
|
1001 |
|
1002 for (TInt index = 0; index < embedCount; ++index) |
|
1003 { |
|
1004 // Get the package details |
|
1005 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
1006 propertyName.Format(KCompEmbeddedPackageUid, index); |
|
1007 TUid packageUid = TUid::Uid(GetIntPropertyValueL(aScrSession, aCompId, propertyName, ETrue)); |
|
1008 |
|
1009 propertyName.Format(KCompEmbeddedPackageName, index); |
|
1010 HBufC16* packageName = GetStrPropertyValueL(aScrSession, aCompId, propertyName); |
|
1011 CleanupStack::PushL(packageName); |
|
1012 |
|
1013 propertyName.Format(KCompEmbeddedPackageVendor, index); |
|
1014 HBufC* packageVendor = GetStrPropertyValueL(aScrSession, aCompId, propertyName); |
|
1015 CleanupStack::PushL(packageVendor); |
|
1016 |
|
1017 propertyName.Format(KCompEmbeddedPackageIndex, index); |
|
1018 TInt packageIndex = GetIntPropertyValueL(aScrSession, aCompId, propertyName, ETrue); |
|
1019 |
|
1020 CSisRegistryPackage *package = CSisRegistryPackage::NewLC(packageUid, *packageName, *packageVendor); |
|
1021 package->SetIndex(packageIndex); |
|
1022 aEmbeddedPackageArray.AppendL(package); |
|
1023 CleanupStack::Pop(package); |
|
1024 CleanupStack::PopAndDestroy(2, packageName); |
|
1025 } |
|
1026 } |
|
1027 |
|
1028 // Retrieve the package details of the given component from the SCR. |
|
1029 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryPackage*& aPackage) |
|
1030 { |
|
1031 TUid compUid = TUid::Uid(GetIntPropertyValueL(aScrSession, aCompId, KCompUid, ETrue)); |
|
1032 TInt componentIndex = GetIntPropertyValueL(aScrSession, aCompId, KCompIndex, EFalse, KDefaultComponentIndex); |
|
1033 |
|
1034 // Unique vendor name is stored as a custom property |
|
1035 HBufC* uniqueVendor = GetStrPropertyValueL(aScrSession, aCompId, KCompUniqueVendorName); |
|
1036 CleanupStack::PushL(uniqueVendor); |
|
1037 Usif::CComponentEntry* componentEntry = Usif::CComponentEntry::NewLC(); |
|
1038 aScrSession.GetComponentL(aCompId, *componentEntry); |
|
1039 aPackage = CSisRegistryPackage::NewL(compUid, componentEntry->Name(), *uniqueVendor); |
|
1040 aPackage->iIndex = componentIndex; |
|
1041 CleanupStack::PopAndDestroy(2, uniqueVendor); // componentEntry |
|
1042 } |
|
1043 |
|
1044 // Retrieve the array of SIS regiatry properties related to the given component from SCR. |
|
1045 void ScrHelperUtil::InternalizePropertiesArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryProperty>& aPropertyArray, RPointerArray<Usif::CPropertyEntry>* aCompPropertyArray) |
|
1046 { |
|
1047 TInt propertyCount = 0; |
|
1048 if(aCompPropertyArray) |
|
1049 propertyCount = GetIntegerPropertyValueFromArrayL(KCompPropertyCount, KDefaultCompPropertyCount, *aCompPropertyArray); |
|
1050 else |
|
1051 propertyCount = GetIntPropertyValueL(aScrSession, aCompId, KCompPropertyCount, EFalse, KDefaultCompPropertyCount); |
|
1052 |
|
1053 for (TInt index = 0; index < propertyCount; ++index) |
|
1054 { |
|
1055 // Create the object from SCR and append it to the array. |
|
1056 CSisRegistryProperty* property = NULL; |
|
1057 ReadFromScrL(aScrSession, aCompId, property, index); |
|
1058 aPropertyArray.AppendL(property); |
|
1059 CleanupStack::Pop(property); |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 // Retrieve the SIS registry property details from the SCR. |
|
1064 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryProperty*& aRegistryProperty, TInt aIndex) |
|
1065 { |
|
1066 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
1067 |
|
1068 aRegistryProperty = new(ELeave) CSisRegistryProperty(); |
|
1069 CleanupStack::PushL(aRegistryProperty); |
|
1070 propertyName.Format(KCompPropertyKey, aIndex); |
|
1071 aRegistryProperty->iKey = GetIntPropertyValueL(aScrSession, aCompId, propertyName, ETrue); |
|
1072 |
|
1073 propertyName.Format(KCompPropertyValue, aIndex); |
|
1074 aRegistryProperty->iValue = GetIntPropertyValueL(aScrSession, aCompId, propertyName, ETrue); |
|
1075 } |
|
1076 |
|
1077 // Retrieve the files owned by the given component from the Software Component Registry. |
|
1078 void ScrHelperUtil::InternalizeFileDescriptionsArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RPointerArray<CSisRegistryFileDescription>& aFileDescriptionArray) |
|
1079 { |
|
1080 HBufC* fileName = NULL; |
|
1081 // First internalize all the wildcarded files (if any). |
|
1082 TInt wildCardFileCount = GetIntPropertyValueL(aScrSession, aCompId, KCompWildCardFileCount, EFalse, KDefaultWildCardFileCount); |
|
1083 for (TInt index = 0; index < wildCardFileCount; index++) |
|
1084 { |
|
1085 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
1086 propertyName.Format(KCompWildCardFile, index); |
|
1087 fileName = GetStrPropertyValueL(aScrSession, aCompId, propertyName); |
|
1088 CleanupStack::PushL(fileName); |
|
1089 CSisRegistryFileDescription* fileDescription; |
|
1090 ReadFromScrL(aScrSession, aCompId, fileDescription, *fileName, ETrue); // ETrue for wild carded files |
|
1091 CleanupStack::PushL(fileDescription); |
|
1092 aFileDescriptionArray.AppendL(fileDescription); |
|
1093 CleanupStack::Pop(fileDescription); |
|
1094 CleanupStack::PopAndDestroy(fileName); |
|
1095 } |
|
1096 // Internalize the normal files (non wildcarded). |
|
1097 Usif::RSoftwareComponentRegistryFilesList subSession; |
|
1098 CleanupClosePushL(subSession); |
|
1099 subSession.OpenListL(aScrSession, aCompId); |
|
1100 |
|
1101 for (;;) |
|
1102 { |
|
1103 fileName = subSession.NextFileL(); |
|
1104 if (!fileName) |
|
1105 { |
|
1106 break; |
|
1107 } |
|
1108 CleanupStack::PushL(fileName); |
|
1109 CSisRegistryFileDescription* fileDescription = NULL; |
|
1110 ReadFromScrL(aScrSession, aCompId, fileDescription, *fileName, EFalse); // EFalse for normal (non wild carded) files |
|
1111 CleanupStack::PushL(fileDescription); |
|
1112 aFileDescriptionArray.AppendL(fileDescription); |
|
1113 CleanupStack::Pop(fileDescription); |
|
1114 CleanupStack::PopAndDestroy(fileName); |
|
1115 } |
|
1116 CleanupStack::PopAndDestroy(&subSession); |
|
1117 } |
|
1118 |
|
1119 // Retrieve information of the given file from Software Component Registry. |
|
1120 // Wild carded file's details are read from component custom properties group and |
|
1121 // Normal file's details are read from the file properties group. |
|
1122 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CSisRegistryFileDescription*& aFileDescription, const TDesC& aFileName, TBool aIsWildcardedFile) |
|
1123 { |
|
1124 aFileDescription = CSisRegistryFileDescription::NewLC(); |
|
1125 aFileDescription->iTarget = aFileName.AllocL(); |
|
1126 // If the file name has any wild card charactors on it, the object should be read from component custom porperties. |
|
1127 if (aIsWildcardedFile) |
|
1128 { |
|
1129 // A wildcard applies to MULTIPLE files so discard all values that only apply to single files |
|
1130 aFileDescription->iMimeType = HBufC16::NewL(0); |
|
1131 aFileDescription->iHash = CHashContainer::NewL(CMessageDigest::ESHA1, KNullDesC8); |
|
1132 aFileDescription->iOperation = Swi::Sis::EOpInstall; |
|
1133 CleanupStack::Pop(aFileDescription); |
|
1134 return; |
|
1135 } |
|
1136 |
|
1137 // Else, read the object from file properties |
|
1138 RPointerArray<Usif::CPropertyEntry> propertyArray; |
|
1139 CleanupResetAndDestroyPushL(propertyArray); |
|
1140 aScrSession.GetFilePropertiesL(aCompId, aFileDescription->Target(), propertyArray); |
|
1141 aFileDescription->iOperation = Swi::Sis::EOpInstall; // EOpInstall is the default value - we record the operation in the SCR only if it is different |
|
1142 // Not all file properties are present for every file. We use default values for the non-mandatory ones, such as SID |
|
1143 for (TInt i = 0; i < propertyArray.Count(); ++i) |
|
1144 { |
|
1145 const TDesC& propertyName = propertyArray[i]->PropertyName(); |
|
1146 if (propertyName == KFileMimeType) |
|
1147 { |
|
1148 Usif::CBinaryPropertyEntry* binaryPropertyEntry = static_cast<Usif::CBinaryPropertyEntry *>(propertyArray[i]); |
|
1149 const TDesC8& mimeType8 = binaryPropertyEntry->BinaryValue(); |
|
1150 aFileDescription->iMimeType = HBufC16::NewL(mimeType8.Length()); |
|
1151 aFileDescription->iMimeType->Des().Copy(mimeType8); |
|
1152 } |
|
1153 |
|
1154 Usif::CIntPropertyEntry* intPropertyEntry = static_cast<Usif::CIntPropertyEntry *>(propertyArray[i]); |
|
1155 if (propertyName == KFileSisFileOperation) |
|
1156 { |
|
1157 aFileDescription->iOperation = static_cast<Sis::TSISFileOperation>(intPropertyEntry->IntValue()); |
|
1158 } |
|
1159 else if (propertyName == KFileFileOperationOptions) |
|
1160 { |
|
1161 aFileDescription->iOperationOptions = static_cast<Sis::TSISFileOperationOptions>(intPropertyEntry->IntValue()); |
|
1162 } |
|
1163 else if (propertyName == KFileSid) |
|
1164 { |
|
1165 aFileDescription->iSid = TUid::Uid(intPropertyEntry->IntValue()); |
|
1166 } |
|
1167 } |
|
1168 |
|
1169 if (!aFileDescription->iMimeType) |
|
1170 { |
|
1171 aFileDescription->iMimeType = HBufC16::NewL(0); |
|
1172 } |
|
1173 CleanupStack::PopAndDestroy(&propertyArray); |
|
1174 ReadFromScrL(aScrSession, aCompId, aFileDescription->iHash, aFileName); |
|
1175 |
|
1176 CleanupStack::Pop(aFileDescription); |
|
1177 } |
|
1178 |
|
1179 // Retrieve the Hash values related to the given file from the Software Component Registry |
|
1180 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, CHashContainer*& aHashContainer, const TDesC& aFileName) |
|
1181 { |
|
1182 HBufC8* data = NULL; |
|
1183 CMessageDigest::THashId algorithm = CMessageDigest::ESHA1; |
|
1184 |
|
1185 RPointerArray<Usif::CPropertyEntry> propertyArray; |
|
1186 CleanupResetAndDestroyPushL(propertyArray); |
|
1187 aScrSession.GetFilePropertiesL(aCompId, aFileName, propertyArray); |
|
1188 for (TInt i = 0; i < propertyArray.Count(); ++i) |
|
1189 { |
|
1190 const TDesC& propertyName = propertyArray[i]->PropertyName(); |
|
1191 if (propertyName == KFileHashData) |
|
1192 { |
|
1193 Usif::CBinaryPropertyEntry* binaryPropertyEntry = static_cast<Usif::CBinaryPropertyEntry *>(propertyArray[i]); |
|
1194 data = HBufC8::NewLC(binaryPropertyEntry->BinaryValue().Length()); |
|
1195 data->Des().Copy(binaryPropertyEntry->BinaryValue()); |
|
1196 } |
|
1197 else if (propertyName == KFileHashAlgorithm) |
|
1198 { |
|
1199 Usif::CIntPropertyEntry* intPropertyEntry = static_cast<Usif::CIntPropertyEntry *>(propertyArray[i]); |
|
1200 algorithm = static_cast<CMessageDigest::THashId>(intPropertyEntry->IntValue()); |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 if (data == NULL) |
|
1205 { |
|
1206 data = HBufC8::NewLC(0); |
|
1207 } |
|
1208 |
|
1209 CleanupStack::Pop(data); |
|
1210 CleanupStack::PopAndDestroy(&propertyArray); |
|
1211 CleanupStack::PushL(data); |
|
1212 aHashContainer = CHashContainer::NewL(algorithm, *data); |
|
1213 CleanupStack::PopAndDestroy(data); |
|
1214 } |
|
1215 |
|
1216 // Retrieve the SIS Trust Status from the Software Component Registry. |
|
1217 void ScrHelperUtil::ReadFromScrL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, TSisTrustStatus& aTrustStatus, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
1218 { |
|
1219 RPointerArray<Usif::CPropertyEntry> *localCopyOfPropertyArray; |
|
1220 RPointerArray<Usif::CPropertyEntry> localPropertyArray; |
|
1221 |
|
1222 if(aPropertyArray) |
|
1223 { |
|
1224 localCopyOfPropertyArray = aPropertyArray; |
|
1225 } |
|
1226 else |
|
1227 { // if the properties array parameter is not passed, retrieve all properties of the component in question. |
|
1228 aScrSession.GetComponentPropertiesL(aCompId, localPropertyArray); |
|
1229 CleanupResetAndDestroyPushL(localPropertyArray); |
|
1230 localCopyOfPropertyArray = &localPropertyArray; |
|
1231 } |
|
1232 |
|
1233 // Then find and assign values from the component properties array |
|
1234 aTrustStatus.iValidationStatus = KDefaultValidationStatus; |
|
1235 aTrustStatus.iRevocationStatus = KDefaultRevocationStatus; |
|
1236 aTrustStatus.iResultDate = TTime(KDefaultGeneralDate); |
|
1237 aTrustStatus.iLastCheckDate = TTime(KDefaultGeneralDate); |
|
1238 aTrustStatus.iQuarantined = KDefaultIsQuarantined; |
|
1239 aTrustStatus.iQuarantinedDate = TTime(KDefaultGeneralDate); |
|
1240 |
|
1241 RPointerArray<Usif::CPropertyEntry>& propertyArray = *localCopyOfPropertyArray; |
|
1242 TInt propertyCount = propertyArray.Count(); |
|
1243 for(TInt i=0; i<propertyCount; ++i) |
|
1244 { |
|
1245 if(Usif::CPropertyEntry::EIntProperty != propertyArray[i]->PropertyType()) |
|
1246 continue; // In this loop, only integer properties are checked. Ignore binary and localizable properties. |
|
1247 |
|
1248 const TDesC& propertyName = propertyArray[i]->PropertyName(); |
|
1249 Usif::CIntPropertyEntry* property = static_cast<Usif::CIntPropertyEntry*>(propertyArray[i]); |
|
1250 |
|
1251 if(KCompTrustValidationStatus() == propertyName) |
|
1252 { |
|
1253 aTrustStatus.iValidationStatus = static_cast<TValidationStatus>(property->IntValue()); |
|
1254 } |
|
1255 else if(KCompTrustRevocationStatus() == propertyName) |
|
1256 { |
|
1257 aTrustStatus.iRevocationStatus = static_cast<TRevocationStatus>(property->IntValue()); |
|
1258 } |
|
1259 else if(KCompTrustResultDate() == propertyName) |
|
1260 { |
|
1261 aTrustStatus.iResultDate = TTime(property->Int64Value()); |
|
1262 } |
|
1263 else if(KCompTrustLastCheckDate() == propertyName) |
|
1264 { |
|
1265 aTrustStatus.iLastCheckDate = TTime(property->Int64Value()); |
|
1266 } |
|
1267 else if(KCompTrustIsQuarantined() == propertyName) |
|
1268 { |
|
1269 aTrustStatus.iQuarantined = static_cast<TBool>(property->IntValue()); |
|
1270 } |
|
1271 else if(KCompTrustQuarantinedDate() == propertyName) |
|
1272 { |
|
1273 aTrustStatus.iQuarantinedDate = TTime(property->Int64Value()); |
|
1274 } |
|
1275 } |
|
1276 |
|
1277 if(!aPropertyArray) |
|
1278 { // Delete the local array if it has been populated |
|
1279 CleanupStack::PopAndDestroy(&localPropertyArray); |
|
1280 } |
|
1281 } |
|
1282 |
|
1283 // Retrieve the Chain Index array elements from the Software Component Registry - SCR. |
|
1284 void ScrHelperUtil::InternalizeChainIndexArrayL(Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, RArray<TInt>& aChainIndexArray, RPointerArray<Usif::CPropertyEntry>* aPropertyArray) |
|
1285 { |
|
1286 TInt chainIndex = 0; |
|
1287 TBuf<KBigBufferSize> propertyName(KEmptyString); |
|
1288 |
|
1289 TInt chainIndexCount = 0; |
|
1290 if(aPropertyArray) |
|
1291 chainIndexCount = GetIntegerPropertyValueFromArrayL(KCompInstallChainIndexCount, KDefaultChainIndex, *aPropertyArray); |
|
1292 else |
|
1293 chainIndexCount = GetIntPropertyValueL(aScrSession, aCompId, KCompInstallChainIndexCount, EFalse, KDefaultChainIndex); |
|
1294 |
|
1295 for (TInt index = 0; index < chainIndexCount; ++index) |
|
1296 { |
|
1297 propertyName.Format(KCompInstallChainIndex, index); |
|
1298 chainIndex = GetIntPropertyValueL(aScrSession, aCompId, propertyName, ETrue); |
|
1299 aChainIndexArray.AppendL(chainIndex); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 // Get the value for given integer (64 bit) type property related to the given component. |
|
1304 TInt64 Swi::GetInt64PropertyValueL(const Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const TDesC& aPropertyName, TBool aAlwaysExpectedInDb, TInt64 aDefaultValue) |
|
1305 { |
|
1306 TInt64 propertyValue = 0; |
|
1307 Usif::CIntPropertyEntry* propertyEntry = NULL; |
|
1308 |
|
1309 propertyEntry = static_cast<Usif::CIntPropertyEntry *>(aScrSession.GetComponentPropertyL(aCompId, aPropertyName)); |
|
1310 |
|
1311 __ASSERT_ALWAYS(propertyEntry || !aAlwaysExpectedInDb, User::Leave(KErrAbort)); |
|
1312 |
|
1313 propertyValue = propertyEntry ? propertyEntry->Int64Value() : aDefaultValue; |
|
1314 delete propertyEntry; |
|
1315 |
|
1316 return (propertyValue); |
|
1317 } |
|
1318 |
|
1319 // Get the value for given integer type property related to the given component. |
|
1320 TInt Swi::GetIntPropertyValueL(const Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const TDesC& aPropertyName, TBool aAlwaysExpectedInDb, TInt aDefaultValue) |
|
1321 { |
|
1322 TInt propertyValue = 0; |
|
1323 Usif::CIntPropertyEntry* propertyEntry = NULL; |
|
1324 |
|
1325 propertyEntry = static_cast<Usif::CIntPropertyEntry *>(aScrSession.GetComponentPropertyL(aCompId, aPropertyName)); |
|
1326 |
|
1327 __ASSERT_ALWAYS(propertyEntry || !aAlwaysExpectedInDb, User::Leave(KErrAbort)); |
|
1328 |
|
1329 propertyValue = propertyEntry ? propertyEntry->Int64Value() : aDefaultValue; |
|
1330 delete propertyEntry; |
|
1331 |
|
1332 return (propertyValue); |
|
1333 } |
|
1334 |
|
1335 // Get the value for given string type property related to the given component. |
|
1336 HBufC* Swi::GetStrPropertyValueL(const Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const TDesC& aPropertyName, const TLanguage aLocale/*= Usif::KUnspecifiedLocale*/, TBool aAlwaysExpectedInDb /*=ETrue*/) |
|
1337 { |
|
1338 HBufC *propertyValue = NULL; |
|
1339 Usif::CLocalizablePropertyEntry* propertyEntry = NULL; |
|
1340 |
|
1341 propertyEntry = static_cast<Usif::CLocalizablePropertyEntry *>(aScrSession.GetComponentPropertyL(aCompId, aPropertyName, aLocale)); |
|
1342 |
|
1343 __ASSERT_ALWAYS(propertyEntry || !aAlwaysExpectedInDb, User::Leave(KErrAbort)); |
|
1344 if (!propertyEntry) |
|
1345 return NULL; |
|
1346 |
|
1347 CleanupStack::PushL(propertyEntry); |
|
1348 // Ownership of the descriptor is transfered to the caller. |
|
1349 propertyValue = propertyEntry->StrValue().AllocL(); |
|
1350 CleanupStack::PopAndDestroy(propertyEntry); |
|
1351 |
|
1352 return (propertyValue); |
|
1353 } |
|
1354 |
|
1355 // Get the binary string value for given property related to the given component. |
|
1356 HBufC8* Swi::GetBinaryPropertyValueL(const Usif::RSoftwareComponentRegistry& aScrSession, const Usif::TComponentId aCompId, const TDesC& aPropertyName) |
|
1357 { |
|
1358 HBufC8 *propertyValue = NULL; |
|
1359 Usif::CBinaryPropertyEntry* propertyEntry = NULL; |
|
1360 propertyEntry = static_cast<Usif::CBinaryPropertyEntry *>(aScrSession.GetComponentPropertyL(aCompId, aPropertyName)); |
|
1361 |
|
1362 __ASSERT_ALWAYS((propertyEntry != NULL), User::Leave(KErrAbort)); |
|
1363 |
|
1364 CleanupStack::PushL(propertyEntry); |
|
1365 // Ownership of the descriptor is transfered to the caller. |
|
1366 propertyValue = propertyEntry->BinaryValue().AllocL(); |
|
1367 CleanupStack::PopAndDestroy(propertyEntry); |
|
1368 |
|
1369 return (propertyValue); |
|
1370 } |
|
1371 |
|
1372 |
|
1373 |
|
1374 // Creates the bit mask formated drives from the TDriveList (string) formated drive. |
|
1375 void Swi::MakeDrivesFromStringL(TDriveList& aDriveList, TUint& aDrive) |
|
1376 { |
|
1377 if(aDriveList.Length() == 0 ) |
|
1378 { |
|
1379 return; |
|
1380 } |
|
1381 |
|
1382 for(TInt driveNum=EDriveA; driveNum<=EDriveZ; ++driveNum) |
|
1383 { |
|
1384 if(aDriveList[driveNum]) |
|
1385 { |
|
1386 aDrive |= 1<<driveNum; |
|
1387 } |
|
1388 } |
|
1389 } |
|
1390 |
|
1391 // Write the Version object in to string format. |
|
1392 void Swi::VersionToString(const TVersion& aVersion, TDes& aVersionString) |
|
1393 { |
|
1394 aVersionString.AppendFormat(KVersionFormat, aVersion.iMajor, aVersion.iMinor, aVersion.iBuild); |
|
1395 } |
|
1396 |
|
1397 // Create the Version object from the string format. |
|
1398 void Swi::StringToVersionL(const TDesC& aVersionString, TVersion& aVersion) |
|
1399 { |
|
1400 _LIT(KDot, "."); |
|
1401 TInt dotPos1 = aVersionString.FindF(KDot); |
|
1402 TInt dotPos2 = 0; |
|
1403 if(dotPos1 > 0) |
|
1404 { |
|
1405 dotPos2 = aVersionString.Mid(dotPos1 + 1).FindF(KDot); |
|
1406 } |
|
1407 |
|
1408 if (dotPos1 <= 0 || dotPos2 <= 0) |
|
1409 { |
|
1410 DEBUG_PRINTF2(_L8("Sis Registry Server - The version format is not recognized for a SIS file. Expected format: n.n.n But, Got : %S"), &aVersionString); |
|
1411 User::Leave(KErrNotSupported); |
|
1412 } |
|
1413 TLex lex(aVersionString); |
|
1414 User::LeaveIfError(lex.Val(aVersion.iMajor)); |
|
1415 |
|
1416 lex = aVersionString.Mid(dotPos1 + 1); |
|
1417 User::LeaveIfError(lex.Val(aVersion.iMinor)); |
|
1418 |
|
1419 lex = aVersionString.Mid(dotPos1 + dotPos2 + 2); |
|
1420 User::LeaveIfError(lex.Val(aVersion.iBuild)); |
|
1421 } |
|
1422 |
|
1423 void ScrHelperUtil::GetComponentIdListL(const Usif::RSoftwareComponentRegistry& aScrSession, RArray<Usif::TComponentId>& aComponentIdList) |
|
1424 { |
|
1425 // Create a filter. |
|
1426 Usif::CComponentFilter* componentFilter = Usif::CComponentFilter::NewLC(); |
|
1427 componentFilter->SetSoftwareTypeL(Usif::KSoftwareTypeNative); |
|
1428 |
|
1429 // Retrieve the componentId of all the components from the SCR. |
|
1430 aScrSession.GetComponentIdsL(aComponentIdList, componentFilter); |
|
1431 CleanupStack::PopAndDestroy(componentFilter); |
|
1432 } |
|
1433 |
|
1434 TBool ScrHelperUtil::IsWildcardFile(const TDesC& aFileName) |
|
1435 { |
|
1436 return (aFileName.Locate('?') != KErrNotFound || |
|
1437 aFileName.Locate('*') != KErrNotFound || |
|
1438 aFileName[aFileName.Length() - 1] == '\\'); |
|
1439 } |
|
1440 |
|
1441 // Extracts the UID of the component from it's global Id data. |
|
1442 // Just an string to TUid conversion. |
|
1443 void ScrHelperUtil::ExtractCompUidL(const TDesC& aGlobalIdStr, TUid& aUid) |
|
1444 { |
|
1445 TInt64 uidNum; |
|
1446 // Make sure the length of the global id string is exactly 8 chahacters in length. |
|
1447 __ASSERT_ALWAYS((aGlobalIdStr.Length() == 8), User::Leave(KErrCorrupt)); |
|
1448 TLex lex(aGlobalIdStr); |
|
1449 TInt error = lex.Val(uidNum, EHex); |
|
1450 __ASSERT_ALWAYS((error == KErrNone), User::Leave(error)); |
|
1451 aUid = TUid::Uid(uidNum); |
|
1452 } |
|
1453 |
|
1454 TBool ComparePropertyNames(const Usif::CPropertyEntry& aLhs, const Usif::CPropertyEntry& aRhs) |
|
1455 { |
|
1456 return (aLhs.PropertyName() == aRhs.PropertyName()); |
|
1457 } |
|
1458 |
|
1459 TInt ScrHelperUtil::FindPropertyL(const RPointerArray<Usif::CPropertyEntry>& aProperties, const TDesC& aPropertyName) |
|
1460 { |
|
1461 Usif::CPropertyEntry *dummyProperty = Usif::CIntPropertyEntry::NewLC(aPropertyName, 0); |
|
1462 TInt ret = aProperties.Find(dummyProperty, TIdentityRelation<Usif::CPropertyEntry>(ComparePropertyNames)); |
|
1463 CleanupStack::PopAndDestroy(dummyProperty); |
|
1464 return ret; |
|
1465 } |
|
1466 |
|
1467 TInt ScrHelperUtil::GetIntegerPropertyValueFromArrayL(const TDesC& aPropertyName, TInt aDefaultValue, const RPointerArray<Usif::CPropertyEntry>& aProperties) |
|
1468 { |
|
1469 TInt propertyValue = aDefaultValue; |
|
1470 TInt pos = FindPropertyL(aProperties, aPropertyName); |
|
1471 if(KErrNotFound != pos) |
|
1472 { |
|
1473 propertyValue = static_cast<Usif::CIntPropertyEntry*>(aProperties[pos])->IntValue(); |
|
1474 } |
|
1475 return propertyValue; |
|
1476 } |
|
1477 |
|
1478 HBufC8* ScrHelperUtil::GetLogInfoLC(const Usif::RSoftwareComponentRegistry& aScrSession, TInt aMaxLogEntries) |
|
1479 { |
|
1480 RPointerArray<Usif::CScrLogEntry> logEntries; |
|
1481 CleanupResetAndDestroyPushL(logEntries); |
|
1482 const TDesC& swType = Usif::KSoftwareTypeNative(); |
|
1483 aScrSession.RetrieveLogEntriesL(logEntries, &swType); |
|
1484 |
|
1485 RPointerArray<CLogEntry> swiLogEntries; |
|
1486 CleanupResetAndDestroyPushL(swiLogEntries); |
|
1487 |
|
1488 TInt logCount = logEntries.Count(); |
|
1489 TInt surplusCount = logCount - aMaxLogEntries; |
|
1490 TInt startIndex = surplusCount>0 ? surplusCount : 0; |
|
1491 |
|
1492 for(TInt i=startIndex; i<logCount; ++i) |
|
1493 { |
|
1494 Usif::CScrLogEntry *scrLog = logEntries[i]; |
|
1495 CLogEntry *swiLog = new(ELeave)CLogEntry(); |
|
1496 CleanupStack::PushL(swiLog); |
|
1497 |
|
1498 swiLog->iPackageName = scrLog->ComponentName().AllocL(); |
|
1499 TVersion version; |
|
1500 StringToVersionL(scrLog->ComponentVersion(), version); |
|
1501 swiLog->iMajorVersion = version.iMajor; |
|
1502 swiLog->iMinorVersion = version.iMinor; |
|
1503 swiLog->iBuildVersion = version.iBuild; |
|
1504 swiLog->iEvent = scrLog->OperationTime(); |
|
1505 |
|
1506 switch (scrLog->OperationType()) |
|
1507 { |
|
1508 case Usif::EScrCompUnInstall: |
|
1509 swiLog->iInstallType = ESwiLogUnInstall; |
|
1510 break; |
|
1511 case Usif::EScrCompUpgrade: |
|
1512 swiLog->iInstallType = ESwiLogUpgrade; |
|
1513 break; |
|
1514 case Usif::EScrCompInstall: |
|
1515 default: |
|
1516 swiLog->iInstallType = ESwiLogInstall; |
|
1517 } |
|
1518 |
|
1519 TBuf<KSmlBufferSize> uidString(KEmptyString); |
|
1520 uidString.Copy(scrLog->GlobalId().Ptr(), 8); |
|
1521 ExtractCompUidL(uidString, swiLog->iUid); |
|
1522 |
|
1523 swiLogEntries.AppendL(swiLog); |
|
1524 CleanupStack::Pop(swiLog); // Ownership has been transferred |
|
1525 } |
|
1526 |
|
1527 HBufC8 *logsBuf = ExternalizePointersArrayLC(swiLogEntries, EFalse); // EFalse -> Don't externalize the array length |
|
1528 CleanupStack::Pop(logsBuf); |
|
1529 CleanupStack::PopAndDestroy(2, &logEntries); // logEntries, swiLogEntries, |
|
1530 CleanupStack::PushL(logsBuf); |
|
1531 return logsBuf; |
|
1532 } |