|
1 /* |
|
2 * Copyright (c) 2006-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #pragma warning (disable: 4786) |
|
20 #include "sisregistryobject.h" |
|
21 |
|
22 // System includes |
|
23 #include <openssl/sha.h> |
|
24 #include <iostream> |
|
25 |
|
26 // SisX Includes |
|
27 #include "sisdatetime.h" |
|
28 #include "sisstring.h" |
|
29 #include "sisfiledata.h" |
|
30 #include "sisproperties.h" |
|
31 #include "sisproperty.h" |
|
32 #include "sisdependency.h" |
|
33 #include "sisprerequisites.h" |
|
34 #include "sisinstallblock.h" |
|
35 #include "sisfiledescription.h" |
|
36 #include "sissupportedlanguages.h" |
|
37 #include "sislanguage.h" |
|
38 #include "siscapabilities.h" |
|
39 #include "sisversion.h" |
|
40 |
|
41 // User includes |
|
42 #include "symbiantypes.h" |
|
43 #include "is_utils.h" |
|
44 #include "deserialiser.h" |
|
45 #include "sisfile.h" |
|
46 #include "installablefile.h" |
|
47 #include "serialiser.h" |
|
48 #include "hashcontainer.h" |
|
49 #include "errors.h" |
|
50 #include "rommanager.h" |
|
51 #include "stringutils.h" |
|
52 |
|
53 // Type definitions |
|
54 typedef int TInt; |
|
55 typedef bool TBool; |
|
56 |
|
57 |
|
58 |
|
59 // from swi/sispackaGetrust.h |
|
60 const TUint32 SisRegistryObject::KSisPackageCertificateChainValidatedToTrustAnchor = 200; |
|
61 const TUint32 SisRegistryObject::KSisPackageBuiltIntoRom = 500; |
|
62 |
|
63 const TInt KExecutableImageUidValue=0x1000007a; |
|
64 |
|
65 const TUint32 KDriveZ = 1 << 25; |
|
66 const TUint32 KDriveC = 1 << 2; |
|
67 |
|
68 |
|
69 |
|
70 Deserialiser& operator>>(Deserialiser& aInput, std::vector<CSISString*>& val) |
|
71 { |
|
72 TUint32 size = 0; |
|
73 aInput>> size; |
|
74 val.resize(size); |
|
75 for (TUint32 i = 0; i < size ; ++i) |
|
76 { |
|
77 std::wstring *tmpString = new std::wstring(); |
|
78 aInput >> *tmpString; |
|
79 val[i] = new CSISString(*tmpString); |
|
80 delete tmpString; |
|
81 } |
|
82 return aInput; |
|
83 } |
|
84 |
|
85 Serialiser& operator<<(Serialiser& aOutput, std::vector<CSISString*>& val) |
|
86 { |
|
87 TUint32 size = val.size(); |
|
88 aOutput << size; |
|
89 for (TUint32 i = 0; i < size ; ++i) |
|
90 { |
|
91 std::wstring tmpStr = val[i]->GetString(); |
|
92 aOutput << tmpStr; |
|
93 } |
|
94 return aOutput; |
|
95 } |
|
96 |
|
97 |
|
98 |
|
99 SisRegistryObject::SisRegistryObject (ConfigManager& aConfigManager):iConfigManager(aConfigManager) |
|
100 { |
|
101 iVendorLocalizedName = new std::wstring(); |
|
102 iTrustStatus = new TrustStatus(); |
|
103 } |
|
104 |
|
105 |
|
106 SisRegistryObject::SisRegistryObject(const SisFile& aSis, |
|
107 const InstallableFiles& aFiles, |
|
108 const TInt aTargetDrive, |
|
109 const TUint16 aRegistryFileMajorVersion, |
|
110 const TUint16 aRegistryFileMinorVersion, |
|
111 const bool aSUFlag, |
|
112 ConfigManager& aConfigManager) |
|
113 : SisRegistryToken( |
|
114 aSis.GetIndex(), |
|
115 aSis.GetVendorName(), |
|
116 aSis.GetPackageName(), |
|
117 aSis.GetPackageUid(), |
|
118 aTargetDrive, |
|
119 aSis.GetLanguage(), |
|
120 aSis.GetVersion(), |
|
121 aSis.GetControllerInfo(aRegistryFileMajorVersion,aRegistryFileMinorVersion), |
|
122 KDriveC), |
|
123 iVendorLocalizedName(new std::wstring(aSis.GetVendorLocalName())),iConfigManager(aConfigManager) |
|
124 { |
|
125 for( InstallableFiles::const_iterator curr = aFiles.begin(); curr != aFiles.end(); ++curr ) |
|
126 { |
|
127 InstallableFile* installableFile= *curr; |
|
128 FileDescription* f = new FileDescription(*installableFile->FileDescription() , installableFile->Sid(), aTargetDrive, installableFile->GetTarget()); |
|
129 iFileDescriptions.push_back(f); |
|
130 } |
|
131 |
|
132 iTrustStatus = new TrustStatus(); |
|
133 TUint64 x = 0; |
|
134 iTrustStatus->SetLastCheckDate(x); |
|
135 iTrustStatus->SetQuaratined((TUint32)0); |
|
136 iTrustStatus->SetQuaratinedDate(x); |
|
137 iTrustStatus->SetResultDate(x); |
|
138 iTrustStatus->SetRevocationStatus(TrustStatus::KOcspNotPerformed); |
|
139 iTrustStatus->SetValidationStatus(TrustStatus::KValidatedToAnchor); |
|
140 |
|
141 const CSISProperties::SISPropertyArray& props = aSis.GetProperties()->Properties(); |
|
142 |
|
143 for (int i = 0; i < props.size(); ++i) |
|
144 { |
|
145 SisRegistryProperty* p = new SisRegistryProperty(props[i]); |
|
146 iProperties.push_back(p); |
|
147 } |
|
148 |
|
149 const const CSISArray<CSISDependency, CSISFieldRoot::ESISDependency>& deps = |
|
150 aSis.GetDependencies()->DependencyList(); |
|
151 |
|
152 for(i = 0; i < deps.size(); ++i) |
|
153 { |
|
154 SisRegistryDependency* p = new SisRegistryDependency(deps[i]); |
|
155 iDependencies.push_back(p); |
|
156 } |
|
157 |
|
158 iFileMajorVersion = aRegistryFileMajorVersion; |
|
159 iFileMinorVersion = aRegistryFileMinorVersion; |
|
160 |
|
161 iInstallType = aSis.GetInstallType(); |
|
162 iInRom = false; |
|
163 if (iInstallType == CSISInfo::EInstPreInstalledApp) |
|
164 { |
|
165 iDeletablePreInstalled = true; |
|
166 } |
|
167 else |
|
168 { |
|
169 iDeletablePreInstalled = false; |
|
170 } |
|
171 iSigned = aSis.GetSigned(); |
|
172 iTrust = KSisPackageCertificateChainValidatedToTrustAnchor; |
|
173 iRemoveWithLastDependent = 0; |
|
174 iTrustTimeStamp = 0; |
|
175 iInstallChainIndices = aSis.GetAllInstallChainIndices(); |
|
176 if(iFileMajorVersion == 4) |
|
177 iIsRemovable = true; |
|
178 else |
|
179 iIsRemovable = !(aSis.GetInstallFlags() & CSISInfo::EInstFlagNonRemovable); |
|
180 |
|
181 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
182 iIsHidden = !(!(aSis.GetInstallFlags() & CSISInfo::EInstFlagHide)); |
|
183 #endif |
|
184 |
|
185 Sids sids; |
|
186 GetSidsFromInstallable(aFiles, sids); |
|
187 TUint32 drives = 0; |
|
188 if (!iFileDescriptions.empty()) |
|
189 drives = 1 << (aTargetDrive - 'A'); |
|
190 |
|
191 SetSids(sids); |
|
192 SetDrives(drives); |
|
193 |
|
194 iSignedBySuCert = aSUFlag; |
|
195 |
|
196 // Set Localized Package Names and Vendor Names |
|
197 std::vector<int> matchingDeviceLanguagesArray = iConfigManager.GetMatchingSupportedLanguages(); |
|
198 TInt matchingLanguageCount = matchingDeviceLanguagesArray.size(); |
|
199 |
|
200 for (TInt i=0; i < matchingLanguageCount; i++) |
|
201 { |
|
202 TInt languageId = matchingDeviceLanguagesArray.at(i); |
|
203 CSISController sisController = aSis.GetController(); |
|
204 TInt supportedLanguageCount = sisController.LanguageCount(); |
|
205 |
|
206 for ( TInt j=0; j < supportedLanguageCount; j++ ) |
|
207 { |
|
208 if ( sisController.Language(j) == languageId) |
|
209 { |
|
210 iSupportedLanguageIds.push_back(languageId); |
|
211 iLocalizedVendorNames.push_back(new CSISString(sisController.SISInfo().VendorName(j))); |
|
212 iLocalizedPackageNames.push_back(new CSISString(sisController.SISInfo().PackageName(j))); |
|
213 break; |
|
214 } |
|
215 } |
|
216 } |
|
217 } |
|
218 |
|
219 SisRegistryObject::SisRegistryObject(CSISController& aSisController, |
|
220 RomManager& aRomManager, |
|
221 const TUint16 aRegistryFileMajorVersion, |
|
222 const TUint16 aRegistryFileMinorVersion, |
|
223 ConfigManager& aConfigManager) |
|
224 : SisRegistryToken(), |
|
225 iFileMajorVersion(aRegistryFileMajorVersion), |
|
226 iFileMinorVersion(aRegistryFileMinorVersion), |
|
227 iInRom(true), |
|
228 iDeletablePreInstalled(false), |
|
229 iIsRemovable(false), |
|
230 iConfigManager(aConfigManager) |
|
231 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
232 ,iIsHidden(false) |
|
233 #endif |
|
234 { |
|
235 //*** SisRegistryPackage ***// |
|
236 |
|
237 // UID |
|
238 const CSISInfo& info = aSisController.SISInfo(); |
|
239 TUint32 uid = info.UID1(); |
|
240 SetUid(uid); |
|
241 |
|
242 // Vendor Name |
|
243 std::wstring vendorName = aSisController.SISInfo().UniqueVendorName(); |
|
244 SetVendorName(vendorName); |
|
245 |
|
246 // Package Name |
|
247 std::wstring packageName; |
|
248 if (aSisController.SISInfo().PackageNameCount() > 0 ) |
|
249 { |
|
250 packageName = aSisController.SISInfo().PackageName(0); |
|
251 SetPackageName(packageName); |
|
252 } |
|
253 else |
|
254 { |
|
255 std::string error = "can not retrieve package name"; |
|
256 throw InvalidSis("", error, INVALID_SIS); |
|
257 } |
|
258 |
|
259 // Index |
|
260 TInt dataIndex = aSisController.DataIndex(); |
|
261 SetIndex(dataIndex); |
|
262 |
|
263 //*** SisRegistryToken ***// |
|
264 |
|
265 // Language |
|
266 TInt lang = aSisController.Language(0); |
|
267 SetLanguage(lang); |
|
268 |
|
269 // Version |
|
270 const CSISVersion& sisVersion = aSisController.SISInfo().SISVersion(); |
|
271 Version version = Version(sisVersion.Major(), sisVersion.Minor(), sisVersion.Build()); |
|
272 SetVersion(version); |
|
273 |
|
274 // Controller Info |
|
275 ControllerInfo* ci = new ControllerInfo(); |
|
276 ci->CalculateAndSetHash(aSisController,aRegistryFileMajorVersion,aRegistryFileMinorVersion); |
|
277 ci->SetVersion(version); |
|
278 ci->SetOffset(0); |
|
279 |
|
280 Controllers controllers; |
|
281 |
|
282 controllers.push_back(ci); |
|
283 |
|
284 // Embedded SIS controllers |
|
285 TControllerMap embeddedCtls; |
|
286 aSisController.InstallBlock().GetEmbeddedControllers(embeddedCtls, false); |
|
287 for (TControllerMapConstIter iter = embeddedCtls.begin(); iter != embeddedCtls.end(); ++iter) |
|
288 { |
|
289 const CSISController& ctrl = *iter->second; |
|
290 ControllerInfo* ctlInfo = new ControllerInfo(); |
|
291 |
|
292 ctlInfo->SetVersion(version); |
|
293 ctlInfo->CalculateAndSetHash(ctrl, aRegistryFileMajorVersion, aRegistryFileMinorVersion); |
|
294 ctlInfo->SetOffset(0); |
|
295 |
|
296 controllers.push_back(ctlInfo); |
|
297 } |
|
298 |
|
299 SetControllerInfo(controllers); |
|
300 |
|
301 // Drives |
|
302 SetDrives(KDriveZ); |
|
303 |
|
304 // Selected Drive |
|
305 int drive = 0; |
|
306 SetSelectedDrive(drive); |
|
307 |
|
308 //*** SisRegistryObject ***// |
|
309 iInstallType = aSisController.SISInfo().InstallationType(); |
|
310 |
|
311 int signatureCount = aSisController.SignatureCount(); |
|
312 iSigned = (signatureCount == 0)? false:true; |
|
313 |
|
314 TInt index = 0; |
|
315 for(index = 0; index < signatureCount; ++index) |
|
316 { |
|
317 iInstallChainIndices.push_back(index); |
|
318 } |
|
319 iTrust = KSisPackageBuiltIntoRom; |
|
320 iRemoveWithLastDependent = 0; |
|
321 |
|
322 iTrustTimeStamp = 0; |
|
323 iTrustStatus = new TrustStatus(); |
|
324 TUint64 x = 0; |
|
325 iTrustStatus->SetLastCheckDate(x); ///< the last date a revocation check was |
|
326 ///< attempted |
|
327 iTrustStatus->SetQuaratined((TUint32)0); ///< true if quarantined. |
|
328 ///< Not used currently |
|
329 iTrustStatus->SetQuaratinedDate(x); ///< date entry was quarantined. |
|
330 ///< Not used currently |
|
331 iTrustStatus->SetResultDate(x); ///< the last date a successful revocation |
|
332 ///< check was performed |
|
333 iTrustStatus->SetRevocationStatus(TrustStatus::KOcspNotPerformed); |
|
334 iTrustStatus->SetValidationStatus(TrustStatus::KPackageInRom); |
|
335 |
|
336 // Properties |
|
337 const CSISProperties::SISPropertyArray& props = aSisController.Properties().Properties(); |
|
338 for (int i = 0; i < props.size(); ++i) |
|
339 { |
|
340 SisRegistryProperty* p = new SisRegistryProperty(props[i]); |
|
341 iProperties.push_back(p); |
|
342 } |
|
343 |
|
344 // File descriptions and SIDs |
|
345 Sids aSids; |
|
346 int fileCount = aSisController.InstallBlock().FileCount(); |
|
347 int value = fileCount; |
|
348 for(i = 0; i < aSisController.InstallBlock().FileCount(); ++i) |
|
349 { |
|
350 TUint32 aSid = 0; |
|
351 const CSISFileDescription& fileDesc =aSisController.InstallBlock().FileDescription(i); |
|
352 |
|
353 std::wstring target = std::wstring(fileDesc.Target().GetString()); |
|
354 |
|
355 // if the target name contains wildchars, do not open to check SID, it is for eclipsing |
|
356 if ((target.find(L"?") == std::wstring::npos) || (target.find(L"*") == std::wstring::npos)) |
|
357 { |
|
358 std::wstring::size_type index = target.rfind(L"."); |
|
359 |
|
360 if (index != std::wstring::npos) |
|
361 { |
|
362 std::wstring extOfString = StringUtils::ToUpper(target.substr(index+1)); |
|
363 |
|
364 const bool fileExists = aRomManager.RomFileExists( target ); |
|
365 if ( fileExists ) |
|
366 { |
|
367 SBinarySecurityInfo info; |
|
368 const TInt err = aRomManager.ReadSecurityInfo( info, target ); |
|
369 |
|
370 // SID is only applicable to an exe |
|
371 if (!err && (extOfString == L"EXE")) |
|
372 { |
|
373 aSid = info.iSecureId; |
|
374 } |
|
375 } |
|
376 } |
|
377 |
|
378 if(aSid) |
|
379 { |
|
380 aSids.push_back(aSid); |
|
381 } |
|
382 } |
|
383 |
|
384 FileDescription* aFileDescription = new FileDescription(fileDesc, aSid, L'Z', fileDesc.Target().GetString()); |
|
385 iFileDescriptions.push_back(aFileDescription); |
|
386 } |
|
387 SetSids(aSids); |
|
388 |
|
389 // Dependencies |
|
390 const CSISPrerequisites::TDependencyList& deps = aSisController.Prerequisites().DependencyList(); |
|
391 for (i = 0; i < deps.size(); ++i) |
|
392 { |
|
393 SisRegistryDependency* p = new SisRegistryDependency(deps[i]); |
|
394 iDependencies.push_back(p); |
|
395 } |
|
396 |
|
397 // Vendor Localized Name |
|
398 if ( aSisController.SISInfo().VendorNameCount() > 0 ) |
|
399 { |
|
400 iVendorLocalizedName = new std::wstring(aSisController.SISInfo().VendorName(0)); |
|
401 } |
|
402 else |
|
403 { |
|
404 std::string x; |
|
405 std::string error = "can not retrieve localized vendor name"; |
|
406 throw InvalidSis(Ucs2ToUtf8((std::wstring)packageName,x), error, INVALID_SIS); |
|
407 } |
|
408 |
|
409 // Signed by SU cert |
|
410 iSignedBySuCert = false; |
|
411 |
|
412 // Set Localized Package Names and Vendor Names |
|
413 std::vector<int> matchingDeviceLanguagesArray = iConfigManager.GetMatchingSupportedLanguages(); |
|
414 TInt matchingLanguageCount = matchingDeviceLanguagesArray.size(); |
|
415 |
|
416 for (TInt i=0; i < matchingLanguageCount; i++) |
|
417 { |
|
418 TInt languageId = matchingDeviceLanguagesArray.at(i); |
|
419 TInt supportedLanguageCount = aSisController.LanguageCount(); |
|
420 |
|
421 for ( TInt j=0; j < supportedLanguageCount; j++ ) |
|
422 { |
|
423 if ( aSisController.Language(j) == languageId) |
|
424 { |
|
425 iSupportedLanguageIds.push_back(languageId); |
|
426 iLocalizedVendorNames.push_back(new CSISString(aSisController.SISInfo().VendorName(j))); |
|
427 iLocalizedPackageNames.push_back(new CSISString(aSisController.SISInfo().PackageName(j))); |
|
428 } |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 SisRegistryObject::~SisRegistryObject () |
|
434 { |
|
435 |
|
436 delete iTrustStatus; |
|
437 TInt i; |
|
438 for (i = 0 ; i < iFileDescriptions.size() ; ++i) |
|
439 delete iFileDescriptions[i]; |
|
440 for (i = 0 ; i < iProperties.size() ; ++i) |
|
441 delete iProperties[i]; |
|
442 for (i = 0 ; i < iEmbeddedPackages.size() ; ++i) |
|
443 delete iEmbeddedPackages[i]; |
|
444 for (i = 0 ; i < iDependencies.size() ; ++i) |
|
445 delete iDependencies[i]; |
|
446 |
|
447 for (i = 0 ; i < iLocalizedPackageNames.size() ; ++i) |
|
448 delete iLocalizedPackageNames[i]; |
|
449 for (i = 0 ; i < iLocalizedVendorNames.size() ; ++i) |
|
450 delete iLocalizedVendorNames[i]; |
|
451 |
|
452 iSupportedLanguageIds.clear(); |
|
453 delete iVendorLocalizedName; |
|
454 |
|
455 } |
|
456 |
|
457 void SisRegistryObject::Internalize(Deserialiser& des) |
|
458 { |
|
459 SisRegistryToken::Internalize(des); |
|
460 |
|
461 des >> iFileMajorVersion |
|
462 >> iFileMinorVersion |
|
463 >> *iVendorLocalizedName |
|
464 >> iInstallType |
|
465 >> iInRom |
|
466 >> iDeletablePreInstalled |
|
467 >> iSigned |
|
468 >> iTrust |
|
469 >> iRemoveWithLastDependent |
|
470 >> iTrustTimeStamp |
|
471 >> iDependencies |
|
472 >> iEmbeddedPackages |
|
473 >> iProperties |
|
474 >> iFileDescriptions |
|
475 >> *iTrustStatus |
|
476 >> iInstallChainIndices; |
|
477 if(iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion > 0)) |
|
478 des >> iIsRemovable; |
|
479 else |
|
480 iIsRemovable = true; |
|
481 |
|
482 if(iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion >= 3)) |
|
483 des >> iSignedBySuCert; |
|
484 else |
|
485 iSignedBySuCert = false; |
|
486 if(iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion >= 4)) |
|
487 { |
|
488 des >> iSupportedLanguageIds; |
|
489 |
|
490 des >> iLocalizedPackageNames; |
|
491 |
|
492 des >> iLocalizedVendorNames; |
|
493 |
|
494 } |
|
495 } |
|
496 |
|
497 void SisRegistryObject::Externalize(Serialiser& ser) |
|
498 { |
|
499 SisRegistryToken::Externalize(ser); |
|
500 ser << iFileMajorVersion |
|
501 << iFileMinorVersion |
|
502 << *iVendorLocalizedName |
|
503 << iInstallType |
|
504 << iInRom |
|
505 << iDeletablePreInstalled |
|
506 << iSigned |
|
507 << iTrust |
|
508 << iRemoveWithLastDependent |
|
509 << iTrustTimeStamp |
|
510 << iDependencies |
|
511 << iEmbeddedPackages |
|
512 << iProperties |
|
513 << iFileDescriptions |
|
514 << *iTrustStatus |
|
515 << iInstallChainIndices; |
|
516 if(iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion > 0)) |
|
517 ser << iIsRemovable; |
|
518 |
|
519 if (iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion >= 3)) |
|
520 ser << iSignedBySuCert; |
|
521 if (iFileMajorVersion > 5 || (iFileMajorVersion == 5 && iFileMinorVersion >= 4)) |
|
522 { |
|
523 ser << iSupportedLanguageIds; |
|
524 |
|
525 ser << iLocalizedPackageNames; |
|
526 |
|
527 ser << iLocalizedVendorNames; |
|
528 |
|
529 } |
|
530 } |
|
531 |
|
532 |
|
533 FileDescription const * SisRegistryObject::GetFile(const std::wstring& aFile) const |
|
534 { |
|
535 FileDescriptions::const_iterator end = iFileDescriptions.end(); |
|
536 for (FileDescriptions::const_iterator curr = iFileDescriptions.begin() ; |
|
537 curr != end; ++curr) |
|
538 { |
|
539 if ( FoldedCompare((*curr)->GetTarget(), aFile) == 0) |
|
540 { |
|
541 return *curr; |
|
542 } |
|
543 } |
|
544 return 0; |
|
545 } |
|
546 |
|
547 FileDescription const * SisRegistryObject::GetFile(TUint32 aSid) const |
|
548 { |
|
549 FileDescriptions::const_iterator end = iFileDescriptions.end(); |
|
550 for (FileDescriptions::const_iterator curr = iFileDescriptions.begin() ; |
|
551 curr != end; ++curr) |
|
552 { |
|
553 if ( (*curr)->GetSid() == aSid) |
|
554 { |
|
555 return *curr; |
|
556 } |
|
557 } |
|
558 return 0; |
|
559 } |
|
560 |
|
561 |
|
562 std::wstring SisRegistryObject::GetRegistryDir( const std::wstring& aDrivePath ) const |
|
563 { |
|
564 const TUint32 uid = GetUid(); |
|
565 std::wstring ret = StringUtils::MakePathFromSID( aDrivePath + L"/sys/install/sisregistry/", uid ); |
|
566 return ret; |
|
567 } |
|
568 |
|
569 int SisRegistryObject::NextSisRegistryIndex(const std::wstring& aDrivePath) const |
|
570 { |
|
571 const TUint32 uid = GetUid(); |
|
572 std::wstring regPath = GetRegistryDir(aDrivePath); |
|
573 |
|
574 for (int index = 0; index < 0xFFFFFFFF; index++) |
|
575 { |
|
576 std::wstring fileName = regPath + StringUtils::BuildSisRegistryFileName( index ); |
|
577 |
|
578 if ( !FileExists(fileName) ) |
|
579 { |
|
580 // return the next available index |
|
581 return index; |
|
582 } |
|
583 } |
|
584 |
|
585 return 0; |
|
586 } |
|
587 |
|
588 int SisRegistryObject::NextSisControllerIndex(const std::wstring& aDrivePath) const |
|
589 { |
|
590 const TUint32 uid = GetUid(); |
|
591 std::wstring regPath = GetRegistryDir(aDrivePath); |
|
592 |
|
593 for (int index = 0; index < 0xFFFFFFFF; index++) |
|
594 { |
|
595 std::wstring fileName = regPath + StringUtils::BuildControllerFileName(GetIndex(), index); |
|
596 |
|
597 if ( !FileExists(fileName) ) |
|
598 { |
|
599 // return the next available index |
|
600 return index; |
|
601 } |
|
602 } |
|
603 |
|
604 return 0; |
|
605 } |
|
606 |
|
607 void SisRegistryObject::UpgradeEntry(const SisFile& aSis, const InstallableFiles& aFiles, TInt aInstallDrive, const bool aSUFlag, ConfigManager& aConfigManager) |
|
608 { |
|
609 // Version |
|
610 iVersion = aSis.GetVersion(); |
|
611 |
|
612 // Controller Info. Update the controller info using the same SIS Registry version as the base package |
|
613 StoreControllerInfo(aSis.GetControllerInfo(iFileMajorVersion,iFileMinorVersion)); |
|
614 |
|
615 iInstallType = aSis.GetInstallType(); |
|
616 |
|
617 iSelectedDrive = toupper(aInstallDrive); |
|
618 |
|
619 // With interpretsis, SisFile is default to true |
|
620 iSigned = aSis.GetSigned(); |
|
621 |
|
622 iSignedBySuCert = aSUFlag; |
|
623 |
|
624 iTrust = KSisPackageCertificateChainValidatedToTrustAnchor; |
|
625 |
|
626 iTrustTimeStamp = 0; |
|
627 |
|
628 TUint64 x = 0; |
|
629 iTrustStatus->SetLastCheckDate(x); |
|
630 iTrustStatus->SetQuaratined((TUint32)0); |
|
631 iTrustStatus->SetQuaratinedDate(x); |
|
632 iTrustStatus->SetResultDate(x); |
|
633 iTrustStatus->SetRevocationStatus(TrustStatus::KOcspNotPerformed); |
|
634 iTrustStatus->SetValidationStatus(TrustStatus::KValidatedToAnchor); |
|
635 |
|
636 iRemoveWithLastDependent = 0; |
|
637 |
|
638 std::vector<TInt> indices = aSis.GetAllInstallChainIndices(); |
|
639 |
|
640 std::vector<TInt>::const_iterator end = indices.end(); |
|
641 int size = indices.size(); |
|
642 for (std::vector<TInt>::const_iterator curr = indices.begin() ; |
|
643 curr != end; ++curr) |
|
644 { |
|
645 int w = *curr; |
|
646 iInstallChainIndices.push_back(*curr); |
|
647 } |
|
648 |
|
649 // Properties |
|
650 TInt i = 0; |
|
651 for (i = 0 ; i < iProperties.size() ; ++i) |
|
652 delete iProperties[i]; |
|
653 |
|
654 const CSISProperties::SISPropertyArray& props = aSis.GetProperties()->Properties(); |
|
655 |
|
656 for(i = 0; i < props.size(); ++i) |
|
657 { |
|
658 SisRegistryProperty* p = new SisRegistryProperty(props[i]); |
|
659 iProperties.push_back(p); |
|
660 } |
|
661 |
|
662 // Dependencies |
|
663 for (i = 0 ; i < iDependencies.size() ; ++i) |
|
664 delete iDependencies[i]; |
|
665 |
|
666 const CSISPrerequisites::TDependencyList& deps = aSis.GetDependencies()->DependencyList(); |
|
667 |
|
668 for(i = 0; i < deps.size(); ++i) |
|
669 { |
|
670 SisRegistryDependency* p = new SisRegistryDependency(deps[i]); |
|
671 iDependencies.push_back(p); |
|
672 } |
|
673 |
|
674 RemoveFiles(aFiles); |
|
675 AddFiles(aFiles); |
|
676 UpdateDrives(); |
|
677 |
|
678 // Set Localized Package Names and Vendor Names |
|
679 std::vector<int> matchingDeviceLanguagesArray = iConfigManager.GetMatchingSupportedLanguages(); |
|
680 TInt matchingLanguageCount = matchingDeviceLanguagesArray.size(); |
|
681 |
|
682 for (TInt i=0; i < matchingLanguageCount; i++) |
|
683 { |
|
684 TInt languageId = matchingDeviceLanguagesArray.at(i); |
|
685 CSISController sisController = aSis.GetController(); |
|
686 TInt supportedLanguageCount = sisController.LanguageCount(); |
|
687 |
|
688 for ( TInt j=0; j < supportedLanguageCount; j++ ) |
|
689 { |
|
690 if ( sisController.Language(j) == languageId) |
|
691 { |
|
692 iSupportedLanguageIds.push_back(languageId); |
|
693 iLocalizedVendorNames.push_back(new CSISString(sisController.SISInfo().VendorName(j))); |
|
694 iLocalizedPackageNames.push_back(new CSISString(sisController.SISInfo().PackageName(j))); |
|
695 break; |
|
696 } |
|
697 } |
|
698 } |
|
699 |
|
700 } |
|
701 |
|
702 void SisRegistryObject::UpdateDrives() |
|
703 { |
|
704 TUint32 drives = 0; |
|
705 FileDescriptions::const_iterator end = iFileDescriptions.end(); |
|
706 for (FileDescriptions::const_iterator curr = iFileDescriptions.begin() ; |
|
707 curr != end; ++curr) |
|
708 { |
|
709 std::wstring target = (*curr)->GetTarget(); |
|
710 // At this stage, '!' has already been assigned, so no need to worry about it... |
|
711 if (StringUtils::StartsWithDrive(target)) |
|
712 { |
|
713 drives |= 1 << (target.at(0) - 'A'); |
|
714 } |
|
715 } |
|
716 SetDrives(drives); |
|
717 } |
|
718 |
|
719 void SisRegistryObject::AddFiles(const InstallableFiles& aFiles) |
|
720 { |
|
721 for(InstallableFiles::const_iterator curr = aFiles.begin(); curr != aFiles.end(); ++curr ) |
|
722 { |
|
723 InstallableFile* installableFile= *curr; |
|
724 TUint32 sid = installableFile->Sid(); |
|
725 FileDescription* f = new FileDescription(*installableFile->FileDescription() , sid, iSelectedDrive, installableFile->GetTarget()); |
|
726 iFileDescriptions.push_back(f); |
|
727 |
|
728 // If the SID is there already there is no reason to add it again |
|
729 if (installableFile->IsExe()) |
|
730 { |
|
731 if (std::find(iSids.begin(), iSids.end(), sid) == iSids.end()) |
|
732 { |
|
733 iSids.push_back(sid); |
|
734 } |
|
735 } |
|
736 } |
|
737 } |
|
738 |
|
739 void SisRegistryObject::RemoveFiles(const InstallableFiles& aFiles) |
|
740 { |
|
741 // Check the new files to determine which files we need to remove prior to installing them |
|
742 for(InstallableFiles::const_iterator curr = aFiles.begin(); curr != aFiles.end(); ++curr ) |
|
743 { |
|
744 InstallableFile* installableFile= *curr; |
|
745 TUint32 sid = installableFile->Sid(); |
|
746 FileDescription f = FileDescription(*installableFile->FileDescription(), sid, |
|
747 iSelectedDrive, installableFile->GetTarget()); |
|
748 |
|
749 FileDescriptions::const_iterator end = iFileDescriptions.end(); |
|
750 for (FileDescriptions::iterator curr2 = iFileDescriptions.begin(); |
|
751 curr2 != end; ++curr2) |
|
752 { |
|
753 if (f.GetTarget() == (*curr2)->GetTarget()) |
|
754 { |
|
755 // If the file to remove is an .exe, remove it's associated SID |
|
756 if (sid) |
|
757 { |
|
758 Sids::iterator i = std::find(iSids.begin(), iSids.end(), sid); |
|
759 if (i != iSids.end()) |
|
760 { |
|
761 iSids.erase(i); |
|
762 } |
|
763 } |
|
764 |
|
765 delete *curr2; |
|
766 iFileDescriptions.erase(curr2); |
|
767 break; |
|
768 } |
|
769 } |
|
770 } |
|
771 } |
|
772 |
|
773 void SisRegistryObject::SetFileDescriptions(const FileDescriptions& aFileDescriptions) |
|
774 { |
|
775 iFileDescriptions.resize(aFileDescriptions.size()); |
|
776 FileDescriptions::const_iterator scurr = aFileDescriptions.begin(); |
|
777 FileDescriptions::const_iterator end = aFileDescriptions.end(); |
|
778 |
|
779 FileDescriptions::iterator dcurr = iFileDescriptions.begin(); |
|
780 |
|
781 while (scurr != end) |
|
782 { |
|
783 *dcurr++ = new FileDescription(**scurr++); |
|
784 } |
|
785 } |
|
786 |
|
787 void SisRegistryObject::SetProperties(const Properties& aProperties) |
|
788 { |
|
789 iProperties.resize(aProperties.size()); |
|
790 Properties::const_iterator scurr = aProperties.begin(); |
|
791 Properties::const_iterator end = aProperties.end(); |
|
792 |
|
793 Properties::iterator dcurr = iProperties.begin(); |
|
794 |
|
795 while (scurr != end) |
|
796 { |
|
797 *dcurr++ = new SisRegistryProperty(**scurr++); |
|
798 } |
|
799 } |
|
800 |
|
801 void SisRegistryObject::SetEmbeddedPackages(const Packages& aEmbeddedPackages) |
|
802 { |
|
803 iEmbeddedPackages.resize(aEmbeddedPackages.size()); |
|
804 Packages::const_iterator scurr = aEmbeddedPackages.begin(); |
|
805 Packages::const_iterator end = aEmbeddedPackages.end(); |
|
806 |
|
807 Packages::iterator dcurr = iEmbeddedPackages.begin(); |
|
808 |
|
809 while (scurr != end) |
|
810 { |
|
811 *dcurr++ = new SisRegistryPackage(**scurr++); |
|
812 } |
|
813 } |
|
814 |
|
815 void SisRegistryObject::SetDependencies(const Dependencies& aDependencies) |
|
816 { |
|
817 iDependencies.resize(aDependencies.size()); |
|
818 Dependencies::const_iterator scurr = aDependencies.begin(); |
|
819 Dependencies::const_iterator end = aDependencies.end(); |
|
820 |
|
821 Dependencies::iterator dcurr = iDependencies.begin(); |
|
822 |
|
823 while (scurr != end) |
|
824 { |
|
825 *dcurr++ = new SisRegistryDependency(**scurr++); |
|
826 } |
|
827 } |
|
828 |
|
829 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
830 void SisRegistryObject::SetValidationStatus(bool aOriginVerificationStatus) |
|
831 { |
|
832 // Set the validation status based on the input parameter preference. |
|
833 if(aOriginVerificationStatus) |
|
834 { |
|
835 iTrustStatus->SetValidationStatus(TrustStatus::KValidatedToAnchor); |
|
836 } |
|
837 else |
|
838 { |
|
839 iTrustStatus->SetValidationStatus(TrustStatus::KValidationStatusUnknown); |
|
840 } |
|
841 } |
|
842 #endif |