|
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 |
|
21 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
22 |
|
23 #include "dbhelper.h" |
|
24 #include "dblayer.h" |
|
25 #include "dbconstants.h" |
|
26 #include "is_utils.h" |
|
27 #include "xmlgenerator.h" |
|
28 #include "xmlparser.h" |
|
29 #include "util.h" |
|
30 #include <algorithm> |
|
31 #include <iostream> |
|
32 #include <stdexcept> |
|
33 #include <iostream> |
|
34 |
|
35 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
36 // constants |
|
37 #define IGNORE_FORMATTING -1 |
|
38 #define ENABLE 1 |
|
39 #define DISABLE 0 |
|
40 // System Includes |
|
41 #include <list> |
|
42 #include <fstream> |
|
43 #include <algorithm> |
|
44 #include <sys/stat.h> |
|
45 #include <sstream> |
|
46 |
|
47 #ifndef __TOOLS2_LINUX__ |
|
48 #include <windows.h> |
|
49 #endif |
|
50 |
|
51 // SisX Library Includes |
|
52 #include "sisfiledescription.h" |
|
53 #include "sisstring.h" |
|
54 |
|
55 // User Includes |
|
56 #include "sisregistry.h" |
|
57 #include "errors.h" |
|
58 #include "rommanager.h" |
|
59 #include "stringutils.h" |
|
60 #include "is_utils.h" |
|
61 #include "sisfile.h" |
|
62 #include "sisregistrypackage.h" |
|
63 #include "sisregistryobject.h" |
|
64 #include "configmanager.h" |
|
65 |
|
66 // Constants |
|
67 const std::wstring SisRegistry::KPathToRegistry(L"\\sys\\install\\sisregistry/"); |
|
68 const std::wstring SisRegistry::KPathToRomStubs(L"\\system\\install\\"); |
|
69 const std::wstring SisRegistry::KPathToRegistryVersionMarker(L"\\system\\data\\"); |
|
70 const std::wstring KRegistryEntry(L"00000000.reg"); |
|
71 const std::wstring KControllerEntry(L"00000000_0000.ctl"); |
|
72 const std::wstring KBackupLst(L"backup.lst"); |
|
73 |
|
74 const int SisRegistry::KSisRegistryMajorVersion = 5; |
|
75 const int SisRegistry::KSisRegistryMinorVersion = 1; |
|
76 |
|
77 // Supported SisRegistry versions |
|
78 const std::wstring SisRegistry::KRegistryFormat(L"sisregistry_?.?.txt"); |
|
79 const std::wstring SisRegistry::KRegistryV40(L"sisregistry_4.0.txt"); |
|
80 const std::wstring SisRegistry::KRegistryV51(L"sisregistry_5.1.txt"); |
|
81 const std::wstring SisRegistry::KRegistryV52(L"sisregistry_5.2.txt"); |
|
82 const std::wstring SisRegistry::KRegistryV53(L"sisregistry_5.3.txt"); |
|
83 const std::wstring SisRegistry::KRegistryV54(L"sisregistry_5.4.txt"); |
|
84 const std::wstring SisRegistry::KRomStubDir(L"z:\\system\\install\\"); |
|
85 const std::wstring SisRegistry::KRomRegistryVersionMarker(L"z:\\system\\data\\"); |
|
86 |
|
87 const std::string SisRegistry::KRegistryV40string("4.0"); |
|
88 const std::string SisRegistry::KRegistryV50string("5.0"); |
|
89 const std::string SisRegistry::KRegistryV51string("5.1"); |
|
90 const std::string SisRegistry::KRegistryV52string("5.2"); |
|
91 const std::string SisRegistry::KRegistryV53string("5.3"); |
|
92 const std::string SisRegistry::KRegistryV54string("5.4"); |
|
93 |
|
94 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
95 const std::wstring SisRegistry::NativeSoftwareType(L"native"); |
|
96 |
|
97 #ifdef _MSC_VER |
|
98 // "." and ".ctl" |
|
99 // VC does not have ".." entry |
|
100 const int KDirFileCount = 2; |
|
101 |
|
102 #else |
|
103 // "." ".." and ".ctl" |
|
104 const int KDirFileCount = 3; |
|
105 |
|
106 #endif |
|
107 |
|
108 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
109 |
|
110 // KRegDirFileCount is the number of directory entries present |
|
111 // in the reg directory when there is no upgrade is made to the |
|
112 // package. i.e. one .reg and one .ctl file |
|
113 // |
|
114 #ifdef _MSC_VER |
|
115 // "." ".reg" and ".ctl" |
|
116 // VC does not have ".." entry |
|
117 const int KRegDirFileCount = 3; |
|
118 |
|
119 #else |
|
120 // "." ".." ".reg" and ".ctl" |
|
121 const int KRegDirFileCount = 4; |
|
122 |
|
123 #endif |
|
124 |
|
125 // function object for determining if all characters are valid hex chars |
|
126 struct AllHexDigits |
|
127 { |
|
128 bool result; |
|
129 |
|
130 AllHexDigits() : result(true) {} |
|
131 void operator()(char a) |
|
132 { |
|
133 if (!((a >= '0' && a <= '9') || |
|
134 (a >= 'a' && a <= 'f') || |
|
135 (a >= 'A' && a <= 'F'))) |
|
136 { |
|
137 result = false; |
|
138 } |
|
139 } |
|
140 }; |
|
141 |
|
142 // function object for retreiving keys from the sisregistry entry map |
|
143 struct CopyUids |
|
144 { |
|
145 CopyUids(std::vector<TUint32>& uids) : iUids(uids) {} |
|
146 std::vector<TUint32>& iUids; |
|
147 |
|
148 void operator()(SisRegistry::EntryMap::value_type& a) |
|
149 { iUids.push_back(a.first); } |
|
150 }; |
|
151 |
|
152 |
|
153 struct FindFile |
|
154 { |
|
155 FindFile(const std::wstring& aFile) : iFile(aFile), iFileDescr(0) {} |
|
156 |
|
157 bool operator()(const SisRegistry::EntryMap::value_type& val) |
|
158 { |
|
159 const SisRegistryObject& obj = *val.second; |
|
160 return (iFileDescr = obj.GetFile(iFile)) != 0; |
|
161 } |
|
162 |
|
163 std::wstring iFile; |
|
164 const FileDescription* iFileDescr; |
|
165 }; |
|
166 |
|
167 |
|
168 struct FindFile2 |
|
169 { |
|
170 FindFile2(TUint32 aSid, const FileDescription*& aFd) : |
|
171 iSid(aSid), iFileDescr(aFd) {} |
|
172 |
|
173 bool operator()(const SisRegistry::EntryMap::value_type& val) |
|
174 { |
|
175 const SisRegistryObject& obj = *val.second; |
|
176 if (iFileDescr = obj.GetFile(iSid)) |
|
177 { |
|
178 return true; |
|
179 } |
|
180 return false; |
|
181 } |
|
182 |
|
183 TUint32 iSid; |
|
184 const FileDescription*& iFileDescr; |
|
185 }; |
|
186 |
|
187 |
|
188 struct Contains |
|
189 { |
|
190 const std::wstring& iFile; |
|
191 |
|
192 Contains(const std::wstring& aFilename) : iFile(aFilename) |
|
193 {} |
|
194 |
|
195 SisRegistryObject* operator()(const SisRegistry::EntryMap::value_type& aObj) |
|
196 { |
|
197 if (aObj.second->GetFile(iFile) != 0) |
|
198 { |
|
199 return aObj.second; |
|
200 } |
|
201 } |
|
202 }; |
|
203 |
|
204 SisRegistry::SisRegistry( CParameterList& aOptions, RomManager& aRomManager, ConfigManager& aConfigManager) |
|
205 : iParamList( aOptions ), iRomManager( aRomManager ), iConfigManager( aConfigManager ) |
|
206 { |
|
207 // Determine which version of the SisRegistry to generate |
|
208 if (iParamList.RegistryVersionExists() == false) |
|
209 { |
|
210 ReadSisRegistryVersion(); |
|
211 } |
|
212 |
|
213 if(iParamList.RegistryVersionExists()) |
|
214 { |
|
215 LINFO(L"Using SIS Registry v" << iParamList.RegistryMajorVersion() << L"." << iParamList.RegistryMinorVersion()); |
|
216 |
|
217 std::wstring registryPathDriveC = KPathToRegistry; |
|
218 |
|
219 ConvertToLocalPath( registryPathDriveC, iParamList.SystemDrivePath() ); |
|
220 |
|
221 ReadRegistry( registryPathDriveC ); |
|
222 } |
|
223 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
224 // this code is for handling the database registry implementation |
|
225 else |
|
226 { |
|
227 LINFO(L"Using database implementation of SIS Registry"); |
|
228 |
|
229 int val = iParamList.IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet); |
|
230 if ( |
|
231 (iParamList.RomLogFileNames().size() != 0 && iParamList.RomDrivePath().size() == 0 ) || |
|
232 iParamList.IsFlagSet( CParameterList::EFlagsDisableZDriveChecksSet) |
|
233 ) |
|
234 { |
|
235 iDbHelper = new DbHelper(iParamList.SystemDrivePath(), true); |
|
236 } |
|
237 else |
|
238 { |
|
239 iDbHelper = new DbHelper(iParamList.RomDrivePath(), false); |
|
240 } |
|
241 } |
|
242 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
243 |
|
244 GenerateStubRegistry(); |
|
245 } |
|
246 |
|
247 |
|
248 SisRegistry::~SisRegistry() |
|
249 { |
|
250 if(iParamList.RegistryVersionExists()) |
|
251 { |
|
252 EntryMap::const_iterator end = iEntries.end(); |
|
253 for (EntryMap::const_iterator curr = iEntries.begin() ; |
|
254 curr != end; ++curr) |
|
255 { |
|
256 delete curr->second; |
|
257 } |
|
258 } |
|
259 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
260 else |
|
261 { |
|
262 delete iDbHelper; |
|
263 } |
|
264 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
265 } |
|
266 /** |
|
267 * If the ROM drive has been defined, find the marker file in the stub directory |
|
268 * e.g. z:\system\data\. If using the ROM/ROFS logs, find the marker file in the |
|
269 * logs. If not found, then check to see if the marker file exists in the ROM stub directory |
|
270 * specified using the -t option. If still not found, use the default version of the Sis Registry. |
|
271 */ |
|
272 void SisRegistry::ReadSisRegistryVersion() |
|
273 { |
|
274 // ROM drive defined |
|
275 if (iParamList.IsFlagSet(CParameterList::EFlagsZDriveSet)) |
|
276 { |
|
277 // ROM SisRegistry marker file |
|
278 std::wstring stubPathZ = KPathToRegistryVersionMarker; |
|
279 ConvertToLocalPath( stubPathZ, iParamList.RomDrivePath() ); |
|
280 |
|
281 FindMarkerAndSetVersion(stubPathZ); |
|
282 } |
|
283 // ROM/ROFS logs defined |
|
284 else if (iParamList.IsFlagSet(CParameterList::EFlagsRomRofsLogFilesSet)) |
|
285 { |
|
286 // Check the stub dir |
|
287 if (iParamList.IsFlagSet(CParameterList::EFlagsStubDirectorySet)) |
|
288 { |
|
289 // ROM SisRegistry marker file |
|
290 std::wstring customStubPath = iParamList.SisStubPath(); |
|
291 |
|
292 FindMarkerAndSetVersion(customStubPath); |
|
293 } |
|
294 |
|
295 // Search in the ROM/ROFS logs. This takes precedence over the stub dir |
|
296 if(iRomManager.RomFileExists(KPathToRegistryVersionMarker+KRegistryV40)) |
|
297 { |
|
298 iParamList.SetRegistryMajorVersion(4); |
|
299 iParamList.SetRegistryMinorVersion(0); |
|
300 } |
|
301 else if(iRomManager.RomFileExists(KRomRegistryVersionMarker+KRegistryV51)) |
|
302 { |
|
303 iParamList.SetRegistryMajorVersion(5); |
|
304 iParamList.SetRegistryMinorVersion(1); |
|
305 } |
|
306 else if(iRomManager.RomFileExists(KRomRegistryVersionMarker+KRegistryV52)) |
|
307 { |
|
308 iParamList.SetRegistryMajorVersion(5); |
|
309 iParamList.SetRegistryMinorVersion(2); |
|
310 } |
|
311 else if(iRomManager.RomFileExists(KRomRegistryVersionMarker+KRegistryV53)) |
|
312 { |
|
313 iParamList.SetRegistryMajorVersion(5); |
|
314 iParamList.SetRegistryMinorVersion(3); |
|
315 } |
|
316 else if(iRomManager.RomFileExists(KRomRegistryVersionMarker+KRegistryV54)) |
|
317 { |
|
318 iParamList.SetRegistryMajorVersion(5); |
|
319 iParamList.SetRegistryMinorVersion(4); |
|
320 } |
|
321 } |
|
322 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
323 // No valid ROM stub marker (sisregistry_x.x.txt) found! |
|
324 // Revert to the default (5.1) SisRegistry version as defined |
|
325 // by KSisRegistryMajorVersion and KSisRegistryMinorVersion |
|
326 if (iParamList.RegistryMajorVersion() == 0 && iParamList.RegistryMinorVersion() == 0) |
|
327 { |
|
328 iParamList.SetRegistryMajorVersion(KSisRegistryMajorVersion); |
|
329 iParamList.SetRegistryMinorVersion(KSisRegistryMinorVersion); |
|
330 } |
|
331 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
332 } |
|
333 |
|
334 |
|
335 void SisRegistry::FindMarkerAndSetVersion(const std::wstring& aPath) |
|
336 { |
|
337 // Make sure the system\data directory name is properly terminated. |
|
338 std::wstring basePath = StringUtils::EnsureDirectoryTerminated( aPath ); |
|
339 |
|
340 std::list<std::wstring> systemDir; |
|
341 GetDirContents( basePath, systemDir ); |
|
342 |
|
343 // Loop on the system\data files until we find a SisRegistry marker file |
|
344 std::list<std::wstring>::iterator curr = systemDir.begin(); |
|
345 while (curr != systemDir.end()) |
|
346 { |
|
347 std::wstring fileFound ( *curr ); |
|
348 |
|
349 // Found the SisRegistry marker file |
|
350 if (fileFound.compare(KRegistryV40) == 0) |
|
351 { |
|
352 iParamList.SetRegistryMajorVersion(4); |
|
353 iParamList.SetRegistryMinorVersion(0); |
|
354 } |
|
355 else if (fileFound.compare(KRegistryV51) == 0) // introduced isRemovable flag |
|
356 { |
|
357 iParamList.SetRegistryMajorVersion(5); |
|
358 iParamList.SetRegistryMinorVersion(1); |
|
359 } |
|
360 else if (fileFound.compare(KRegistryV52) == 0) // fixed DEF114705 - SIS controller incorrect |
|
361 { |
|
362 iParamList.SetRegistryMajorVersion(5); |
|
363 iParamList.SetRegistryMinorVersion(2); |
|
364 } |
|
365 else if (fileFound.compare(KRegistryV53) == 0) // introduced SU cert flag |
|
366 { |
|
367 iParamList.SetRegistryMajorVersion(5); |
|
368 iParamList.SetRegistryMinorVersion(3); |
|
369 } |
|
370 else if (fileFound.compare(KRegistryV54) == 0) // Support for exact & equivalent device supported languages |
|
371 { |
|
372 iParamList.SetRegistryMajorVersion(5); |
|
373 iParamList.SetRegistryMinorVersion(4); |
|
374 } |
|
375 |
|
376 ++curr; |
|
377 } |
|
378 } |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 bool SisRegistry::IsPackageDir(const std::wstring& aString) |
|
384 { |
|
385 AllHexDigits digits; |
|
386 std::for_each(aString.begin(), aString.end(), digits); |
|
387 return aString.length() == 8 && digits.result; |
|
388 } |
|
389 |
|
390 TBool SisRegistry::IsInstalled(TUint32 aUid) const |
|
391 { |
|
392 if(iParamList.RegistryVersionExists()) |
|
393 { |
|
394 return iEntries.find(aUid) != iEntries.end();; |
|
395 } |
|
396 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
397 else |
|
398 { |
|
399 return iDbHelper->IsInstalled(aUid); |
|
400 } |
|
401 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
402 return false; |
|
403 } |
|
404 |
|
405 |
|
406 const SisRegistryObject& SisRegistry::GetRegistryObject(TUint32 aUid) const |
|
407 { |
|
408 if(iParamList.RegistryVersionExists()) |
|
409 { |
|
410 EntryMap::const_iterator end = iEntries.end(); |
|
411 for (EntryMap::const_iterator curr = iEntries.begin() ; |
|
412 curr != end; ++curr) |
|
413 { |
|
414 if ((curr->first == aUid) && ((*curr->second).GetIndex() == 0)) |
|
415 { |
|
416 return *curr->second; |
|
417 } |
|
418 } |
|
419 } |
|
420 |
|
421 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
422 else |
|
423 { |
|
424 SisRegistryObject* sisRegistryObject = new SisRegistryObject(iConfigManager); |
|
425 if(iDbHelper->InternalizeIfExists(*sisRegistryObject, aUid)) |
|
426 { |
|
427 return *sisRegistryObject; |
|
428 } |
|
429 } |
|
430 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
431 |
|
432 throw std::runtime_error("Couldn't find specified package"); |
|
433 } |
|
434 |
|
435 SisRegistryObject* SisRegistry::GetRegistryObjectPtr(TUint32 aUid) |
|
436 { |
|
437 if(iParamList.RegistryVersionExists()) |
|
438 { |
|
439 EntryMap::const_iterator end = iEntries.end(); |
|
440 for (EntryMap::const_iterator curr = iEntries.begin() ; |
|
441 curr != end; ++curr) |
|
442 { |
|
443 if ((curr->first == aUid) && ((curr->second)->GetIndex() == 0)) |
|
444 { |
|
445 return curr->second; |
|
446 } |
|
447 } |
|
448 } |
|
449 |
|
450 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
451 else |
|
452 { |
|
453 SisRegistryObject* sisRegistryObject = new SisRegistryObject(iConfigManager); |
|
454 if(iDbHelper->InternalizeIfExists(*sisRegistryObject, aUid)) |
|
455 { |
|
456 return sisRegistryObject; |
|
457 } |
|
458 } |
|
459 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
460 |
|
461 throw std::runtime_error("Couldn't find specified package"); |
|
462 } |
|
463 |
|
464 const SisRegistryPackage& SisRegistry::SidToPackage(TUint32 aSid) |
|
465 { |
|
466 const FileDescription* fileDesc = 0; |
|
467 FindFile2 fileFinder(aSid, fileDesc); |
|
468 |
|
469 EntryMap::iterator x = std::find_if(iEntries.begin(), |
|
470 iEntries.end(), |
|
471 fileFinder); |
|
472 |
|
473 if (x != iEntries.end()) |
|
474 { |
|
475 return *x->second; |
|
476 } |
|
477 else |
|
478 { |
|
479 throw std::runtime_error("Couldn't find specified file"); |
|
480 } |
|
481 } |
|
482 |
|
483 |
|
484 void SisRegistry::SidToFileName(TUint32 aSid, std::wstring& aFileName) |
|
485 { |
|
486 if(iParamList.RegistryVersionExists()) |
|
487 { |
|
488 const FileDescription* fileDesc = 0; |
|
489 FindFile2 fileFinder(aSid, fileDesc); |
|
490 |
|
491 EntryMap::iterator x = std::find_if(iEntries.begin(), |
|
492 iEntries.end(), |
|
493 fileFinder); |
|
494 |
|
495 if (x != iEntries.end()) |
|
496 { |
|
497 aFileName = fileFinder.iFileDescr->GetTarget(); |
|
498 } |
|
499 else |
|
500 { |
|
501 throw std::runtime_error("Couldn't find specified file"); |
|
502 } |
|
503 } |
|
504 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
505 else |
|
506 { |
|
507 aFileName = iDbHelper->SidToFileName(aSid); |
|
508 if(aFileName.empty()) |
|
509 { |
|
510 throw std::runtime_error("Couldn't find specified file"); |
|
511 } |
|
512 } |
|
513 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
514 } |
|
515 |
|
516 |
|
517 bool SisRegistry::SidExists(TUint32 aSid) const |
|
518 { |
|
519 if(iParamList.RegistryVersionExists()) |
|
520 { |
|
521 const FileDescription* fileDesc = 0; |
|
522 FindFile2 fileFinder(aSid, fileDesc); |
|
523 |
|
524 EntryMap::const_iterator x = std::find_if(iEntries.begin(), |
|
525 iEntries.end(), |
|
526 fileFinder); |
|
527 |
|
528 return x != iEntries.end(); |
|
529 } |
|
530 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
531 else |
|
532 { |
|
533 return iDbHelper->SidExists(aSid); |
|
534 } |
|
535 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
536 return false; |
|
537 } |
|
538 |
|
539 |
|
540 void SisRegistry::RemoveEntry(const TUint32 aUid, const std::wstring& aPackageName, const std::wstring& aVendorName) |
|
541 { |
|
542 if(iParamList.RegistryVersionExists()) |
|
543 { |
|
544 EntryMap::iterator it = iEntries.find(aUid); |
|
545 |
|
546 while(it != iEntries.end()) |
|
547 { |
|
548 if (aUid == it->first && |
|
549 aPackageName == it->second->GetPackageName() && |
|
550 aVendorName == it->second->GetVendorName()) |
|
551 { |
|
552 LINFO(L"Removing package \"" << it->second->GetPackageName() |
|
553 << L"\" prior to re-installation"); |
|
554 |
|
555 // Remove .reg file |
|
556 std::wstring registryPath = it->second->GetRegistryDir( iParamList.SystemDrivePath() ); |
|
557 RemoveFile(registryPath + StringUtils::BuildSisRegistryFileName( it->second->GetIndex() )); |
|
558 |
|
559 // Remove .ctl file |
|
560 int drive = tolower(it->second->GetSelectedDrive()); |
|
561 std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(drive); |
|
562 registryPath = it->second->GetRegistryDir( localTargetPath ); |
|
563 RemoveFile(registryPath + StringUtils::BuildControllerFileName( it->second->GetIndex(), 0 )); |
|
564 |
|
565 // Remove the installed files for this SisRegistryObject |
|
566 const FileDescriptions& files = it->second->GetFileDescriptions(); |
|
567 |
|
568 RemoveInstalledFiles(files, localTargetPath); |
|
569 |
|
570 // Clean up the SisRegistryObject |
|
571 delete it->second; |
|
572 iEntries.erase(it); |
|
573 |
|
574 return; |
|
575 } |
|
576 ++it; |
|
577 } |
|
578 } |
|
579 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
580 else |
|
581 { |
|
582 |
|
583 // the vendor name here is the unique vendore name |
|
584 TInt32 componentId = iDbHelper->GetComponentId(aUid, aPackageName, aVendorName); |
|
585 if(componentId == DbHelper::Absent) |
|
586 { |
|
587 return; |
|
588 } |
|
589 |
|
590 LINFO(L"Removing package \"" << aPackageName << L"\" prior to re-installation"); |
|
591 |
|
592 // Remove .ctl file |
|
593 int drive = tolower(iDbHelper->GetSelectedDrive(componentId)); |
|
594 std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(drive); |
|
595 std::wstring registryPath = GetRegistryDir( localTargetPath,componentId ); |
|
596 RemoveFile(registryPath + StringUtils::BuildControllerFileName( iDbHelper->GetIndex(componentId), 0 )); |
|
597 |
|
598 // Remove the installed files for this SisRegistryObject |
|
599 const FileDescriptions& files = iDbHelper->GetFileDescriptions(componentId); |
|
600 |
|
601 RemoveInstalledFiles(files, localTargetPath); |
|
602 |
|
603 iDbHelper->RemoveEntry(componentId); |
|
604 |
|
605 } |
|
606 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
607 } |
|
608 void SisRegistry::RemovePkg(const TUint32& aUid, bool aSkipRomStub) |
|
609 { |
|
610 if(iParamList.RegistryVersionExists()) |
|
611 { |
|
612 RemovePkgLegacy(aUid,aSkipRomStub); |
|
613 } |
|
614 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
615 else |
|
616 { |
|
617 RemovePkgWithScr(aUid,aSkipRomStub); |
|
618 } |
|
619 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
620 } |
|
621 |
|
622 void SisRegistry::RemovePkgLegacy(const TUint32& aUid, bool aSkipRomStub) |
|
623 { |
|
624 EntryMap::iterator currObj = iEntries.find(aUid); |
|
625 |
|
626 if (currObj == iEntries.end()) |
|
627 { |
|
628 // No SisRegistry file found!! |
|
629 std::stringstream err; |
|
630 err << " SisRegistry entry for 0x" << std::hex << aUid << L" Not found"; |
|
631 |
|
632 throw std::runtime_error(err.str()); |
|
633 } |
|
634 |
|
635 std::list<std::wstring> regDirFiles; |
|
636 std::wstring path = currObj->second->GetRegistryDir( iParamList.SystemDrivePath() ); |
|
637 |
|
638 GetDirContents(path, regDirFiles); |
|
639 |
|
640 if (regDirFiles.size() == KRegDirFileCount && currObj->second->GetInRom()) |
|
641 { |
|
642 // I.e. there are only .., one .reg and one .ctl file present |
|
643 // check whether it is a ROM stub object (without any upgrades) |
|
644 |
|
645 if (aSkipRomStub) |
|
646 { |
|
647 // Since this is only a ROM stub entry, leave it as it is; |
|
648 // to avoid regenerate it again. |
|
649 return; |
|
650 } |
|
651 |
|
652 std::stringstream err; |
|
653 err << "Illegal uninstall of ROM package 0x" << std::hex << aUid; |
|
654 throw InterpretSisError(err.str(), ATTEMPT_TO_UNINSTALL_ROM_PKG); |
|
655 } |
|
656 |
|
657 std::list<std::wstring>::iterator currFile = regDirFiles.begin(); |
|
658 |
|
659 // Remove all the .reg and .ctl files in the system drive for this package |
|
660 while (currFile != regDirFiles.end()) |
|
661 { |
|
662 if (*currFile != L"." && *currFile != L"..") |
|
663 { |
|
664 RemoveFile(path + *currFile); |
|
665 } |
|
666 |
|
667 ++currFile; |
|
668 } |
|
669 |
|
670 // Remove the installed files for all packages (SA, SP, PU) |
|
671 while (currObj != iEntries.end()) |
|
672 { |
|
673 // For ROM stub, the SelectedDrive = 0; as there could be ROM->SP. |
|
674 // Therefore, the rest can only apply to at least a ROM stub upgrades |
|
675 int drive = tolower(currObj->second->GetSelectedDrive()); |
|
676 |
|
677 if (drive) |
|
678 { |
|
679 std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(drive); |
|
680 path = currObj->second->GetRegistryDir( localTargetPath ); |
|
681 |
|
682 regDirFiles.clear(); |
|
683 GetDirContents(path, regDirFiles); |
|
684 |
|
685 currFile = regDirFiles.begin(); |
|
686 |
|
687 // Remove all the .ctl files for this package |
|
688 while (currFile != regDirFiles.end()) |
|
689 { |
|
690 if (*currFile != L"." && *currFile != L"..") |
|
691 { |
|
692 RemoveFile(path + *currFile); |
|
693 } |
|
694 ++currFile; |
|
695 } |
|
696 |
|
697 // This iterator's object has the same Uid as aUid |
|
698 const FileDescriptions& files = currObj->second->GetFileDescriptions(); |
|
699 |
|
700 RemoveInstalledFiles(files, localTargetPath); |
|
701 } |
|
702 |
|
703 |
|
704 // Clean up the SisRegistryObject |
|
705 delete currObj->second; |
|
706 iEntries.erase(currObj); |
|
707 |
|
708 currObj = iEntries.find(aUid); |
|
709 } |
|
710 } |
|
711 |
|
712 std::wstring SisRegistry::GetRegistryDir( const std::wstring& aDrivePath, TUint32 aUid ) const |
|
713 { |
|
714 std::wstring ret = StringUtils::MakePathFromSID( aDrivePath + L"/sys/install/sisregistry/", aUid ); |
|
715 return ret; |
|
716 } |
|
717 |
|
718 void SisRegistry::RemoveInstalledFiles(const FileDescriptions& aFileDes, std::wstring& aLocalPath) |
|
719 { |
|
720 FileDescriptions::const_iterator curr = aFileDes.begin(); |
|
721 FileDescriptions::const_iterator end = aFileDes.end(); |
|
722 |
|
723 for ( ; curr != end ; ++curr) |
|
724 { |
|
725 std::wstring target((*curr)->GetTarget()); |
|
726 |
|
727 ConvertToLocalPath(target, aLocalPath); |
|
728 RemoveFile(target); |
|
729 RemoveHashForFile(target, iParamList.SystemDriveLetter(), iParamList.SystemDrivePath()); |
|
730 } |
|
731 } |
|
732 |
|
733 |
|
734 void SisRegistry::AddRegistryEntry( const SisFile& aSis, const InstallableFiles& aFiles, |
|
735 const InstallSISFile& aInstallSISFile ) |
|
736 { |
|
737 SisRegistryObject* obj = new SisRegistryObject( aSis, aFiles, aInstallSISFile.iTargetDrive, |
|
738 iParamList.RegistryMajorVersion(), iParamList.RegistryMinorVersion(), aInstallSISFile.iSUFlag, iConfigManager ); |
|
739 |
|
740 // Generate .reg and .ctl file for native installation. |
|
741 // Installation based on database registration, generate only the .ctl file. |
|
742 GenerateRegistryEntry(*obj, aSis); |
|
743 |
|
744 if(iParamList.RegistryVersionExists()) |
|
745 { |
|
746 // Add the registry entry to the registry |
|
747 iEntries.insert(EntryMap::value_type(obj->GetUid(),obj)); |
|
748 } |
|
749 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
750 else |
|
751 { |
|
752 // if the entry already exists then remove it first |
|
753 // this is the case where an in rom application is getting |
|
754 // overwritten by an SA type. |
|
755 // in case of db the entry is stored in the database from where first it has |
|
756 // to be removed and then readded based on the updated registry object which is |
|
757 // in memory. In case of file based registry update this is done is a separate |
|
758 // way, it reads the existing registry entry and store it in memory, and updates the same |
|
759 // entry in memory and then over-writes the old registry entry with the update entry. |
|
760 TInt32 componentId = iDbHelper->GetComponentId(obj->GetUid(), obj->GetInstallType() ); |
|
761 if(componentId != DbHelper::Absent) |
|
762 { |
|
763 iDbHelper->RemoveEntry(componentId); |
|
764 } |
|
765 obj->SetValidationStatus(iParamList.OriginVerificationStatus()); |
|
766 GenerateDbRegistryEntry(*obj, iParamList.OriginVerificationStatus()); |
|
767 } |
|
768 #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
769 } |
|
770 |
|
771 void SisRegistry::UpdateRegistryEntry(const SisFile& aSis, |
|
772 const InstallableFiles& aFiles, const InstallSISFile& aInstallSISFile) |
|
773 { |
|
774 TUint32 pkg = aSis.GetPackageUid(); |
|
775 |
|
776 SisRegistryObject* obj = GetRegistryObjectPtr(pkg); |
|
777 obj->UpgradeEntry(aSis, aFiles, aInstallSISFile.iTargetDrive, aInstallSISFile.iSUFlag, iConfigManager); |
|
778 |
|
779 // Update/Create the .reg and .ctl files |
|
780 GenerateRegistryEntry(*obj, aSis); |
|
781 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
782 |
|
783 if(!iParamList.RegistryVersionExists()) |
|
784 { |
|
785 TUint32 componentId = iDbHelper->GetComponentId(pkg); |
|
786 // remove the application from database |
|
787 iDbHelper->RemoveEntry(componentId); |
|
788 |
|
789 obj->SetValidationStatus(iParamList.OriginVerificationStatus()); |
|
790 GenerateDbRegistryEntry(*obj, iParamList.OriginVerificationStatus()); |
|
791 } |
|
792 |
|
793 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
794 } |
|
795 |
|
796 const SisRegistryObject* SisRegistry::OwningPackage( const std::wstring& aFilename, TUint32& aUid ) const |
|
797 { |
|
798 if(iParamList.RegistryVersionExists()) |
|
799 { |
|
800 // Loop through iEntries, then loop through file desc for spec UID, then return the obj |
|
801 for (EntryMap::const_iterator curr = iEntries.begin() ; |
|
802 curr != iEntries.end() ; |
|
803 ++curr) |
|
804 { |
|
805 // Get the file descriptions |
|
806 if (curr->second->GetFile(aFilename) != 0) |
|
807 { |
|
808 aUid = curr->first; |
|
809 return curr->second; |
|
810 } |
|
811 } |
|
812 } |
|
813 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
814 else |
|
815 { |
|
816 aUid = iDbHelper->GetUidFromFileName(aFilename); |
|
817 if(aUid != 0) |
|
818 { |
|
819 SisRegistryObject* sisRegistryObject = new SisRegistryObject(iConfigManager); |
|
820 if(iDbHelper->InternalizeIfExists(*sisRegistryObject,aUid)) |
|
821 { |
|
822 return sisRegistryObject; |
|
823 } |
|
824 } |
|
825 } |
|
826 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
827 return NULL; |
|
828 } |
|
829 |
|
830 |
|
831 void SisRegistry::RemoveBackupLst() |
|
832 { |
|
833 std::wstring backup = KPathToRegistry + KBackupLst; |
|
834 ConvertToLocalPath( backup, iParamList.SystemDrivePath() ); |
|
835 |
|
836 if ( FileExists( backup ) ) |
|
837 { |
|
838 RemoveFile( backup ); |
|
839 } |
|
840 } |
|
841 |
|
842 |
|
843 void SisRegistry::ReadStubs( const std::wstring& aDirectory ) |
|
844 { |
|
845 // Make sure the directory name is properly terminated. |
|
846 std::wstring basePath = StringUtils::EnsureDirectoryTerminated( aDirectory ); |
|
847 |
|
848 std::list<std::wstring> stubDirs; |
|
849 GetDirContents( basePath, stubDirs ); |
|
850 |
|
851 std::list<std::wstring>::iterator curr; |
|
852 |
|
853 for(curr = stubDirs.begin(); curr!= stubDirs.end(); ++curr) |
|
854 { |
|
855 std::wstring stubPath ( basePath + *curr ); |
|
856 |
|
857 if( !IsSisValid(stubPath) ) |
|
858 continue; |
|
859 |
|
860 _TCHAR* fileName = const_cast<_TCHAR *>(stubPath.c_str()); |
|
861 std::auto_ptr<CSISController> sisController(ReadStubController( fileName )); |
|
862 |
|
863 if (!sisController.get()) |
|
864 { |
|
865 LERROR(L"\tCannot create CSISController for "<< stubPath); |
|
866 continue; |
|
867 } |
|
868 |
|
869 if (IsInstalled(sisController->UID1())) |
|
870 { |
|
871 // Has already been upgraded |
|
872 continue; |
|
873 } |
|
874 |
|
875 SisRegistryObject* aObj = new SisRegistryObject(*sisController, iRomManager, |
|
876 iParamList.RegistryMajorVersion(), |
|
877 iParamList.RegistryMinorVersion(), |
|
878 iConfigManager); |
|
879 GenerateStubRegistry(aObj,sisController.get()); |
|
880 |
|
881 } // for |
|
882 } |
|
883 |
|
884 |
|
885 TBool SisRegistry::IsSisValid(const std::wstring& aStubPath) |
|
886 { |
|
887 int dotIndex = aStubPath.rfind(L"."); |
|
888 if(dotIndex == std::wstring::npos) |
|
889 return false; |
|
890 std::wstring extOfString = aStubPath.substr(dotIndex+1); |
|
891 std::wstring extOfStringUpper = StringUtils::ToUpper(extOfString); |
|
892 if (extOfStringUpper != L"SIS" && extOfStringUpper != L"SISX") |
|
893 return false; |
|
894 return true; |
|
895 } |
|
896 |
|
897 void SisRegistry::GenerateStubRegistry(SisRegistryObject* aSisRegistryObject, CSISController* aSisController) |
|
898 { |
|
899 // create the directory to be used for storing reg and ctl files |
|
900 std::wstring regPath = aSisRegistryObject->GetRegistryDir( L"" ); |
|
901 ConvertToLocalPath( regPath, iParamList.SystemDrivePath() ); |
|
902 if ( !MakeDir( regPath ) ) |
|
903 { |
|
904 throw InterpretSisError(L"Directory Creation Error - "+regPath, DIRECTORY_CREATION_ERROR); |
|
905 } |
|
906 |
|
907 LINFO(L"\tAdding ROM Stub: 0x" << std::hex << aSisRegistryObject->GetUid() << L" \"" << aSisRegistryObject->GetPackageName() << L"\""); |
|
908 |
|
909 if(iParamList.RegistryVersionExists()) |
|
910 { |
|
911 iEntries.insert( EntryMap::value_type( aSisRegistryObject->GetUid(), aSisRegistryObject ) ); |
|
912 |
|
913 // Create the ROM Stub registry entries |
|
914 |
|
915 std::fstream regFile; |
|
916 std::wstring reg = regPath+KRegistryEntry; |
|
917 |
|
918 OpenFile( reg, regFile, std::ios::out | std::ios::binary ); |
|
919 |
|
920 Serialiser s(regFile); |
|
921 |
|
922 // Create the .reg file: |
|
923 s << aSisRegistryObject; |
|
924 |
|
925 regFile.close(); |
|
926 } |
|
927 |
|
928 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
929 else |
|
930 { |
|
931 GenerateDbRegistryEntry(*aSisRegistryObject, iParamList.OriginVerificationStatus()); |
|
932 } |
|
933 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
934 |
|
935 // Create the .ctl file: |
|
936 std::fstream ctlFile; |
|
937 OpenFile( regPath+KControllerEntry, ctlFile, std::ios::out | std::ios::binary ); |
|
938 |
|
939 const unsigned char* ctl = aSisController->RawBuffer(); |
|
940 int len = aSisController->BufferSize(); |
|
941 |
|
942 ctlFile.write((const char*)&len, 4); |
|
943 ctlFile.write((char*)ctl, len); |
|
944 ctlFile.close(); |
|
945 } |
|
946 |
|
947 bool SisRegistry::IsFileWideCard(const std::wstring& aFileName) |
|
948 { |
|
949 return (aFileName.find(L'?') != std::wstring::npos || |
|
950 aFileName.find(L'*') != std::wstring::npos || |
|
951 aFileName[aFileName.length() - 1] == L'\\'); |
|
952 } |
|
953 |
|
954 |
|
955 void SisRegistry::GenerateStubRegistry() |
|
956 { |
|
957 if (!iParamList.IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet)) |
|
958 { |
|
959 // If the -z option were used to launch the tool, then read any |
|
960 // SIS stubs that we have gathered from the emulated z:\system\install |
|
961 // location. |
|
962 if (iParamList.IsFlagSet(CParameterList::EFlagsZDriveSet)) |
|
963 { |
|
964 std::wstring stubPathZ = KPathToRomStubs; |
|
965 ConvertToLocalPath( stubPathZ, iParamList.RomDrivePath() ); |
|
966 ReadStubs( stubPathZ ); |
|
967 } |
|
968 |
|
969 // If an additional SIS stub path were specified, we'll |
|
970 // also handle that here too. |
|
971 if (iParamList.IsFlagSet(CParameterList::EFlagsStubDirectorySet)) |
|
972 { |
|
973 bool readCustomStubPath = true; |
|
974 std::wstring customStubPath = iParamList.SisStubPath(); |
|
975 |
|
976 // But make sure we don't read the same directory twice! |
|
977 const bool haveRomDrive = iParamList.IsFlagSet(CParameterList::EFlagsZDriveSet); |
|
978 if ( haveRomDrive ) |
|
979 { |
|
980 std::wstring stubPathZ = KPathToRomStubs; |
|
981 ConvertToLocalPath( stubPathZ, iParamList.RomDrivePath() ); |
|
982 readCustomStubPath = ( stubPathZ != customStubPath ); |
|
983 } |
|
984 |
|
985 if ( readCustomStubPath ) |
|
986 { |
|
987 ReadStubs( customStubPath ); |
|
988 } |
|
989 } |
|
990 } |
|
991 } |
|
992 |
|
993 |
|
994 void SisRegistry::ReadRegistry( const std::wstring& aRegistryBasePath ) |
|
995 { |
|
996 std::list<std::wstring> regDirs; |
|
997 GetDirContents( aRegistryBasePath, regDirs ); |
|
998 |
|
999 std::list<std::wstring>::iterator curr = regDirs.begin(); |
|
1000 |
|
1001 LINFO(L"Reconstructing SIS Registry..."); |
|
1002 |
|
1003 for( curr = regDirs.begin(); curr != regDirs.end(); ++curr ) |
|
1004 { |
|
1005 struct stat s; |
|
1006 const std::wstring entryPath = aRegistryBasePath + *curr; |
|
1007 const int err = GetStat(entryPath.c_str(), &s); |
|
1008 |
|
1009 if ( err ) |
|
1010 continue; |
|
1011 |
|
1012 const bool isDir = (s.st_mode & S_IFDIR) != 0; |
|
1013 |
|
1014 if (isDir && IsPackageDir(*curr)) |
|
1015 { |
|
1016 ExtractRegistryFiles(entryPath); |
|
1017 } |
|
1018 } |
|
1019 } |
|
1020 |
|
1021 |
|
1022 void SisRegistry::ExtractRegistryFiles(const std::wstring& aPath) |
|
1023 { |
|
1024 std::list<std::wstring> contents; |
|
1025 GetDirContents(aPath, contents); |
|
1026 |
|
1027 for (std::list<std::wstring>::iterator c = contents.begin(); c != contents.end(); ++c) |
|
1028 { |
|
1029 if (c->find(L".reg",0) == std::wstring::npos) |
|
1030 continue; |
|
1031 |
|
1032 std::fstream input; |
|
1033 std::wstring filename(aPath + L"\\" + *c); |
|
1034 |
|
1035 OpenFile(filename.c_str(), input, std::fstream::in | std::fstream::binary); |
|
1036 |
|
1037 if (!input.good()) |
|
1038 continue; |
|
1039 |
|
1040 SisRegistryObject* obj = new SisRegistryObject(iConfigManager); |
|
1041 |
|
1042 if (!obj) |
|
1043 { |
|
1044 throw std::runtime_error("Cannot create SisRegistryObject for " + Ucs2ToUtf8(filename)); |
|
1045 } |
|
1046 Deserialiser des(input); |
|
1047 |
|
1048 des >> *obj; |
|
1049 iEntries.insert(EntryMap::value_type(obj->GetUid(), obj)); |
|
1050 |
|
1051 LINFO(L"\tExtracting: 0x" << std::hex << obj->GetUid() << L" \"" << obj->GetPackageName() << L"\""); |
|
1052 |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 |
|
1057 bool SisRegistry::IsRomStubPackage(const TUint32 aUid) |
|
1058 { |
|
1059 CSISController* sisController = GetStubController(aUid); |
|
1060 |
|
1061 if (sisController) |
|
1062 { |
|
1063 delete sisController; |
|
1064 return true; |
|
1065 } |
|
1066 |
|
1067 return false; |
|
1068 } |
|
1069 |
|
1070 |
|
1071 void SisRegistry::GetStubFileEntries(const TUint32 aUid, std::list<std::wstring>& aFilesEntries) |
|
1072 { |
|
1073 std::auto_ptr<CSISController> sisController(GetStubController(aUid)); |
|
1074 |
|
1075 if (!sisController.get()) |
|
1076 return; |
|
1077 const CSISInstallBlock& installBlock = sisController->InstallBlock(); |
|
1078 int fileCount = installBlock.FileCount(); |
|
1079 |
|
1080 for (int i = 0; i < fileCount; ++i) |
|
1081 { |
|
1082 std::wstring target(installBlock.FileDescription(i).Target().GetString()); |
|
1083 aFilesEntries.push_back(target); |
|
1084 } |
|
1085 } |
|
1086 |
|
1087 |
|
1088 CSISController* SisRegistry::GetStubController(const TUint32 aUid) |
|
1089 { |
|
1090 if (iParamList.IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet)) |
|
1091 { |
|
1092 return NULL; |
|
1093 } |
|
1094 // If the -z option were used to launch the tool, then read any |
|
1095 // SIS stubs that we have gathered from the emulated Z:\System\Install |
|
1096 // location. |
|
1097 if (iParamList.IsFlagSet(CParameterList::EFlagsZDriveSet)) |
|
1098 { |
|
1099 std::wstring stubPathZ = KPathToRomStubs; |
|
1100 ConvertToLocalPath( stubPathZ, iParamList.RomDrivePath() ); |
|
1101 CSISController* sisController = GetStubControllerInDir( stubPathZ, aUid ); |
|
1102 |
|
1103 if (sisController) |
|
1104 { |
|
1105 return sisController; |
|
1106 } |
|
1107 } |
|
1108 |
|
1109 // If an additional SIS stub path were specified, we'll |
|
1110 // also handle that here too. |
|
1111 if (iParamList.IsFlagSet(CParameterList::EFlagsStubDirectorySet)) |
|
1112 { |
|
1113 bool readCustomStubPath = true; |
|
1114 std::wstring customStubPath = iParamList.SisStubPath(); |
|
1115 |
|
1116 // But make sure we don't read the same directory twice! |
|
1117 const bool haveRomDrive = iParamList.IsFlagSet(CParameterList::EFlagsZDriveSet); |
|
1118 if ( haveRomDrive ) |
|
1119 { |
|
1120 std::wstring stubPathZ = KPathToRomStubs; |
|
1121 ConvertToLocalPath( stubPathZ, iParamList.RomDrivePath() ); |
|
1122 readCustomStubPath = ( stubPathZ != customStubPath ); |
|
1123 } |
|
1124 |
|
1125 if ( readCustomStubPath ) |
|
1126 { |
|
1127 CSISController* sisController = GetStubControllerInDir( customStubPath, aUid ); |
|
1128 |
|
1129 if (sisController) |
|
1130 { |
|
1131 return sisController; |
|
1132 } |
|
1133 } |
|
1134 } |
|
1135 return NULL; |
|
1136 } |
|
1137 |
|
1138 |
|
1139 CSISController* SisRegistry::GetStubControllerInDir( const std::wstring& aDirectory, const TUint32 aUid) |
|
1140 { |
|
1141 // Make sure the directory name is properly terminated. |
|
1142 std::wstring basePath = StringUtils::EnsureDirectoryTerminated( aDirectory ); |
|
1143 |
|
1144 std::list<std::wstring> stubDirs; |
|
1145 GetDirContents( basePath, stubDirs ); |
|
1146 |
|
1147 std::list<std::wstring>::iterator curr; |
|
1148 for (curr = stubDirs.begin(); curr != stubDirs.end() ; ++curr) |
|
1149 { |
|
1150 std::wstring stubPath ( basePath + *curr ); |
|
1151 int dotIndex = stubPath.rfind(L"."); |
|
1152 if(dotIndex == std::wstring::npos) |
|
1153 continue; |
|
1154 |
|
1155 std::wstring extOfString = stubPath.substr(dotIndex+1); |
|
1156 |
|
1157 std::wstring extOfStringUpper = StringUtils::ToUpper(extOfString); |
|
1158 if (extOfStringUpper != L"SIS" && extOfStringUpper != L"SISX") |
|
1159 continue; |
|
1160 |
|
1161 _TCHAR* fileName = const_cast<_TCHAR *>(stubPath.c_str()); |
|
1162 CSISController* sisController = ReadStubController( fileName ); |
|
1163 |
|
1164 if (!sisController) |
|
1165 continue; |
|
1166 |
|
1167 if (sisController->UID1() == aUid) |
|
1168 { |
|
1169 return sisController; |
|
1170 } |
|
1171 delete sisController; |
|
1172 } |
|
1173 return NULL; |
|
1174 } |
|
1175 |
|
1176 |
|
1177 CSISController* SisRegistry::ReadStubController( const wchar_t* aFileName ) |
|
1178 { |
|
1179 const bool isSisFile = CSISContents::IsSisFile(aFileName); |
|
1180 CSISController* sisController = NULL; |
|
1181 |
|
1182 if (isSisFile) |
|
1183 { |
|
1184 LWARN(L"\tIgnoring invalid SIS stub: " << aFileName); |
|
1185 return sisController; |
|
1186 } |
|
1187 SisRegistryObject* aObj = NULL; |
|
1188 |
|
1189 TSISStream input; |
|
1190 std::wstring fileName = FixPathDelimiters(aFileName); |
|
1191 HANDLE file = ::MakeSISOpenFile(fileName.c_str(),GENERIC_READ,OPEN_EXISTING); |
|
1192 if (INVALID_HANDLE_VALUE == file) |
|
1193 { |
|
1194 LERROR(L" Error : Cannot open file : " << fileName << std::endl); |
|
1195 throw CSISException(CSISException::EFileProblem, std::wstring (L"cannot open ") + fileName); |
|
1196 } |
|
1197 bool success = input.import (file, NULL); |
|
1198 ::CloseHandle(file); |
|
1199 if(!success) |
|
1200 { |
|
1201 LERROR(L" Error : Cannot read file : " << fileName << std::endl); |
|
1202 throw CSISException(CSISException::EFileProblem, std::wstring (L"cannot read ") + fileName); |
|
1203 } |
|
1204 |
|
1205 sisController = new CSISController; |
|
1206 sisController->Read(input, input.length()); |
|
1207 |
|
1208 return sisController; |
|
1209 } |
|
1210 |
|
1211 void SisRegistry::GenerateRegistryEntry(SisRegistryObject& aObj, const SisFile& aSis) |
|
1212 { |
|
1213 |
|
1214 SetNextIndex(aObj); |
|
1215 |
|
1216 if(iParamList.RegistryVersionExists()) |
|
1217 { |
|
1218 GenerateRegFile(aObj); |
|
1219 } |
|
1220 |
|
1221 GenerateCtlFile(aObj, aSis); |
|
1222 } |
|
1223 |
|
1224 void SisRegistry::SetNextIndex(SisRegistryObject& aObj) const |
|
1225 { |
|
1226 TUint32 pkgUid = aObj.GetUid(); |
|
1227 TUint32 installType = aObj.GetInstallType(); |
|
1228 int index = 0; |
|
1229 |
|
1230 if(iParamList.RegistryVersionExists()) |
|
1231 { |
|
1232 if (installType == CSISInfo::EInstAugmentation) |
|
1233 { |
|
1234 // set the .reg and .ctl file index for SP installation |
|
1235 index = aObj.NextSisRegistryIndex( iParamList.SystemDrivePath() ); |
|
1236 |
|
1237 if (index == 0) |
|
1238 { |
|
1239 // No SisRegistry file found!! |
|
1240 std::wstring msg = StringUtils::MakePathFromSID ( iParamList.SystemDrivePath()+L"\\", pkgUid ); |
|
1241 |
|
1242 msg.append(L" does not have any SisRegistry file"); |
|
1243 |
|
1244 throw std::runtime_error( Ucs2ToUtf8(msg) ); |
|
1245 } |
|
1246 |
|
1247 aObj.SetIndex( index ); |
|
1248 |
|
1249 if ( !CheckSisRegistryDirPresent(iParamList.SystemDrivePath(), pkgUid) ) |
|
1250 { |
|
1251 // c:\sys\install\sisregistry\<UID>\ directory not exist |
|
1252 std::wstring msg = StringUtils::MakePathFromSID ( iParamList.SystemDrivePath()+L"\\", pkgUid ); |
|
1253 |
|
1254 msg.append(L" directory NOT found"); |
|
1255 |
|
1256 throw std::runtime_error( Ucs2ToUtf8(msg) ); |
|
1257 } |
|
1258 } |
|
1259 } |
|
1260 |
|
1261 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1262 |
|
1263 else |
|
1264 { |
|
1265 if (installType == CSISInfo::EInstAugmentation) |
|
1266 { |
|
1267 // set .ctl file index for SP installation |
|
1268 index = iDbHelper->GetIndex(pkgUid); |
|
1269 |
|
1270 int nextIndex = index +1; |
|
1271 aObj.SetIndex( nextIndex ); |
|
1272 |
|
1273 if ( !CheckSisRegistryDirPresent(iParamList.SystemDrivePath(), pkgUid) ) |
|
1274 { |
|
1275 std::wstring msg = StringUtils::MakePathFromSID ( iParamList.SystemDrivePath()+L"\\", pkgUid ); |
|
1276 |
|
1277 msg.append(L" directory NOT found"); |
|
1278 |
|
1279 throw std::runtime_error( Ucs2ToUtf8(msg) ); |
|
1280 } |
|
1281 } |
|
1282 } |
|
1283 |
|
1284 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1285 |
|
1286 } |
|
1287 |
|
1288 void SisRegistry::GenerateRegFile(SisRegistryObject& aObj) const |
|
1289 { |
|
1290 TUint32 installType = aObj.GetInstallType(); |
|
1291 |
|
1292 std::wstring regPath = aObj.GetRegistryDir( L"" ); |
|
1293 ConvertToLocalPath( regPath, iParamList.SystemDrivePath() ); |
|
1294 |
|
1295 if (installType == CSISInfo::EInstInstallation) |
|
1296 { |
|
1297 if ( !MakeDir( regPath ) ) |
|
1298 { |
|
1299 throw InterpretSisError(L"Directory Creation Error - "+regPath, DIRECTORY_CREATION_ERROR); |
|
1300 } |
|
1301 } |
|
1302 |
|
1303 std::fstream regFile; |
|
1304 std::wstring reg = regPath + StringUtils::BuildSisRegistryFileName(aObj.GetIndex()); |
|
1305 |
|
1306 OpenFile( reg, regFile, std::ios::out | std::ios::binary ); |
|
1307 |
|
1308 Serialiser s(regFile); |
|
1309 s << aObj; |
|
1310 |
|
1311 regFile.close(); |
|
1312 } |
|
1313 |
|
1314 void SisRegistry::GenerateCtlFile(SisRegistryObject& aObj, const SisFile& aSis) const |
|
1315 { |
|
1316 TUint32 pkgUid = aObj.GetUid(); |
|
1317 TUint32 installType = aObj.GetInstallType(); |
|
1318 // Controller |
|
1319 int index = 0; |
|
1320 |
|
1321 if (installType == CSISInfo::EInstPartialUpgrade) |
|
1322 { |
|
1323 index = aObj.NextSisControllerIndex( iParamList.SystemDrivePath() ); |
|
1324 |
|
1325 if (index == 0) |
|
1326 { |
|
1327 // No SIS controller file found!! |
|
1328 std::wstring msg = StringUtils::MakePathFromSID ( iParamList.SystemDrivePath()+L"\\", pkgUid ); |
|
1329 |
|
1330 msg.append(L" does not have any Sis Controller file"); |
|
1331 |
|
1332 throw std::runtime_error( Ucs2ToUtf8(msg) ); |
|
1333 } |
|
1334 } |
|
1335 |
|
1336 // Finally, externalise the new controller file |
|
1337 std::fstream ctlFile; |
|
1338 std::wstring ctlPath = aObj.GetRegistryDir( L"" ); |
|
1339 ConvertToLocalPath( ctlPath, iParamList.SystemDrivePath() ); |
|
1340 |
|
1341 if (installType == CSISInfo::EInstInstallation) |
|
1342 { |
|
1343 if ( !MakeDir( ctlPath ) ) |
|
1344 { |
|
1345 throw InterpretSisError(L"Directory Creation Error - "+ctlPath, DIRECTORY_CREATION_ERROR); |
|
1346 } |
|
1347 } |
|
1348 |
|
1349 std::wstring ctrl = ctlPath + StringUtils::BuildControllerFileName( aObj.GetIndex(), index ); |
|
1350 |
|
1351 |
|
1352 OpenFile( ctrl, ctlFile, std::ios::out | std::ios::binary ); |
|
1353 |
|
1354 const char* ctl = 0; |
|
1355 int len = 0; |
|
1356 aSis.GetControllerData(ctl, len); |
|
1357 ctlFile.write((const char*)&len, 4); |
|
1358 ctlFile.write(ctl, len); |
|
1359 ctlFile.close(); |
|
1360 |
|
1361 int targetDrive = tolower(aObj.GetSelectedDrive()); |
|
1362 |
|
1363 if (iConfigManager.IsTargetDriveExt(targetDrive)) |
|
1364 { |
|
1365 // For external target drive, generate the ctl file to that drive also |
|
1366 std::wstring ctlPath = aObj.GetRegistryDir( L"" ); |
|
1367 std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(targetDrive); |
|
1368 |
|
1369 ConvertToLocalPath( ctlPath, localTargetPath ); |
|
1370 |
|
1371 if ( !MakeDir( ctlPath ) ) |
|
1372 { |
|
1373 throw InterpretSisError(L"Directory Creation Error - "+ctlPath, DIRECTORY_CREATION_ERROR); |
|
1374 } |
|
1375 |
|
1376 ctrl = ctlPath + StringUtils::BuildControllerFileName( aObj.GetIndex(), index ); |
|
1377 |
|
1378 OpenFile( ctrl, ctlFile, std::ios::out | std::ios::binary ); |
|
1379 |
|
1380 ctlFile.write((const char*)&len, 4); |
|
1381 ctlFile.write(ctl, len); |
|
1382 ctlFile.close(); |
|
1383 } |
|
1384 } |
|
1385 |
|
1386 |
|
1387 int SisRegistry::GetAugmentationsNumber(TUint32 aUid) |
|
1388 { |
|
1389 int num = 0; |
|
1390 if(iParamList.RegistryVersionExists()) |
|
1391 { |
|
1392 EntryMap::const_iterator x = iEntries.begin(); |
|
1393 |
|
1394 for (;x != iEntries.end(); ++x) |
|
1395 { |
|
1396 if (x->first == aUid && x->second->GetIndex() != 0 ) |
|
1397 ++num; |
|
1398 } |
|
1399 } |
|
1400 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1401 else |
|
1402 { |
|
1403 TInt32 componentId = iDbHelper->GetComponentId(aUid); |
|
1404 TInt index = iDbHelper->GetIndex(componentId); |
|
1405 if( index != DbHelper::Absent ) |
|
1406 num = ++index; |
|
1407 } |
|
1408 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1409 return num; |
|
1410 } |
|
1411 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1412 |
|
1413 std::wstring SisRegistry::FormatVersionToString( const Version& aVersion ) |
|
1414 { |
|
1415 std::wstringstream versionText; |
|
1416 versionText << aVersion.GetMajor() << L"." << aVersion.GetMinor() << L"." << aVersion.GetBuild(); |
|
1417 return versionText.str(); |
|
1418 } |
|
1419 |
|
1420 const DbHelper* SisRegistry::GetDbHelper() const |
|
1421 { |
|
1422 return iDbHelper; |
|
1423 } |
|
1424 |
|
1425 void SisRegistry::GenerateDbRegistryEntry(const SisRegistryObject& aSisRegistryObject, bool aOriginVerified) |
|
1426 { |
|
1427 // store the object in registry database |
|
1428 XmlDetails::TScrPreProvisionDetail scrPreProvisionDetail; |
|
1429 // for sis file entries the software type would always be Native. |
|
1430 scrPreProvisionDetail.iSoftwareTypeName = SisRegistry::NativeSoftwareType; |
|
1431 XmlDetails::TScrPreProvisionDetail::TComponent component = CreateRegistryEntry(aSisRegistryObject); |
|
1432 |
|
1433 SetOriginVerification(component, aOriginVerified); |
|
1434 |
|
1435 scrPreProvisionDetail.iComponents.push_back(component); |
|
1436 UpdateInstallationInformation(scrPreProvisionDetail); |
|
1437 } |
|
1438 |
|
1439 void SisRegistry::SetOriginVerification(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, bool aOriginVerified) |
|
1440 { |
|
1441 // If not origin verified, set so. By default origin is verified. |
|
1442 if (!aOriginVerified) |
|
1443 { |
|
1444 aComponent.iComponentDetails.iOriginVerified = 0; |
|
1445 } |
|
1446 } |
|
1447 |
|
1448 void SisRegistry::UpdateInstallationInformation(XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) |
|
1449 { |
|
1450 CXmlGenerator xmlgenerator; |
|
1451 char* tmpFileName = tmpnam(NULL); |
|
1452 std::wstring filename(string2wstring(tmpFileName)); |
|
1453 |
|
1454 xmlgenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail); |
|
1455 |
|
1456 std::string executable = "scrtool.exe"; |
|
1457 std::string command; |
|
1458 command = executable + " -d " + GetDbPath() + " -p " + tmpFileName; |
|
1459 |
|
1460 int error = system(command.c_str()); |
|
1461 |
|
1462 if(error != 0) |
|
1463 { |
|
1464 std::string err = "Scrtool failed to upload the database registry entry."; |
|
1465 LERROR(L"Scrtool failed to upload the database registry entry."); |
|
1466 throw InterpretSisError(err, DATABASE_UPDATE_FAILED); |
|
1467 } |
|
1468 |
|
1469 error = remove(tmpFileName); |
|
1470 |
|
1471 if(error != 0) |
|
1472 { |
|
1473 LERROR(L"Temporary file removal failed."); |
|
1474 } |
|
1475 |
|
1476 } |
|
1477 |
|
1478 std::string SisRegistry::GetDbPath() |
|
1479 { |
|
1480 if ( |
|
1481 (iParamList.RomLogFileNames().size() != 0 && iParamList.RomDrivePath().size() == 0 ) || |
|
1482 iParamList.IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet) |
|
1483 ) |
|
1484 { |
|
1485 return wstring2string(iParamList.SystemDrivePath()) + "\\sys\\install\\scr\\scr.db"; |
|
1486 } |
|
1487 |
|
1488 return wstring2string(iParamList.RomDrivePath()) + "\\sys\\install\\scr\\provisioned\\scr.db"; |
|
1489 |
|
1490 } |
|
1491 |
|
1492 std::string SisRegistry::GetEpocRoot() |
|
1493 { |
|
1494 const char* epocRoot = getenv("EPOCROOT"); |
|
1495 if(NULL == epocRoot) |
|
1496 { |
|
1497 std::string err = "EPOCROOT environment variable not specified. Please specify it as part of your environment variable." \ |
|
1498 "It should point uptil the start of the epoc32 directory."; |
|
1499 LERROR(L"EPOCROOT environment variable not specified. Please specify it as part of your environment variable." \ |
|
1500 "It should point uptil the start of the epoc32 directory."); |
|
1501 throw InterpretSisError(err, ENV_NOT_SPECIFIED); |
|
1502 } |
|
1503 std::string epocRootStr(epocRoot); |
|
1504 return epocRootStr; |
|
1505 } |
|
1506 |
|
1507 |
|
1508 std::wstring SisRegistry::GetGlobalId( TUint32 aUid , TInt aInstallType, std::wstring aPackageName) |
|
1509 { |
|
1510 wchar_t textGlobalId[20]; |
|
1511 |
|
1512 #ifdef _MSC_VER |
|
1513 swprintf(textGlobalId,L"%08x",aUid); |
|
1514 #else |
|
1515 swprintf(textGlobalId,20,L"%08x",aUid); |
|
1516 #endif |
|
1517 |
|
1518 std::wstring globalId = textGlobalId; |
|
1519 |
|
1520 if( aInstallType == CSISInfo::EInstAugmentation || aInstallType == CSISInfo::EInstPreInstalledPatch ) |
|
1521 { |
|
1522 if(aPackageName.empty()) |
|
1523 { |
|
1524 std::string err = "Package Name not specified for global id creation."; |
|
1525 LERROR(L"Package Name not specified for global id creation."); |
|
1526 throw InterpretSisError(err, GLOBALID_CREATION_ERROR); |
|
1527 } |
|
1528 globalId += L"_" + aPackageName; |
|
1529 } |
|
1530 return globalId; |
|
1531 } |
|
1532 |
|
1533 void SisRegistry::RemovePkgWithScr(TUint32 aUid, bool aSkipRomStub) |
|
1534 { |
|
1535 TUint32 componentId = iDbHelper->GetComponentId(aUid); |
|
1536 |
|
1537 if ( DbHelper::Absent == componentId ) |
|
1538 { |
|
1539 // No database entry found!! |
|
1540 std::stringstream err; |
|
1541 err << " SisRegistry entry for 0x" << std::hex << aUid << L" Not found"; |
|
1542 throw InterpretSisError(err.str(), DATABASE_ENTRY_MISSING); |
|
1543 } |
|
1544 |
|
1545 std::list<std::wstring> regDirFiles; |
|
1546 std::wstring path = GetRegistryDir( iParamList.SystemDrivePath(), aUid ); |
|
1547 |
|
1548 GetDirContents(path, regDirFiles); |
|
1549 |
|
1550 // The directory should only consist of the .ctl file. Comparison with |
|
1551 // 2 is for the ctl file and link to the parent directory. |
|
1552 if ( regDirFiles.size() == KDirFileCount && iDbHelper->GetInRom(componentId)) |
|
1553 { |
|
1554 // I.e. there are only one .ctl file present |
|
1555 // check whether it is a ROM stub object (without any upgrades) |
|
1556 |
|
1557 if (aSkipRomStub) |
|
1558 { |
|
1559 // Since this is only a ROM stub entry, leave it as it is; |
|
1560 // to avoid regenerate it again. |
|
1561 return; |
|
1562 } |
|
1563 |
|
1564 std::stringstream err; |
|
1565 err << "Illegal uninstall of ROM package 0x" << std::hex << aUid; |
|
1566 throw InterpretSisError(err.str(), ATTEMPT_TO_UNINSTALL_ROM_PKG); |
|
1567 } |
|
1568 |
|
1569 std::list<std::wstring>::iterator currFile = regDirFiles.begin(); |
|
1570 |
|
1571 // Remove all .ctl files in the system drive for this package |
|
1572 while (currFile != regDirFiles.end()) |
|
1573 { |
|
1574 if (*currFile != L"." && *currFile != L"..") |
|
1575 { |
|
1576 RemoveFile(path + *currFile); |
|
1577 } |
|
1578 |
|
1579 ++currFile; |
|
1580 } |
|
1581 |
|
1582 // Remove the installed files for all packages (SA, SP, PU) |
|
1583 // retrieve component id for the specified uid |
|
1584 std::vector<TInt32> compIdList = iDbHelper->GetComponentIdList(aUid); |
|
1585 std::vector<TInt32> ::iterator compIter; |
|
1586 for( compIter = compIdList.begin(); compIter != compIdList.end() ; ++compIter ) |
|
1587 { |
|
1588 // For ROM stub, the SelectedDrive = 0; as there could be ROM->SP. |
|
1589 // Therefore, the rest can only apply to at least a ROM stub upgrades |
|
1590 int drive = tolower(iDbHelper->GetSelectedDrive(*compIter)); |
|
1591 |
|
1592 if (drive) |
|
1593 { |
|
1594 std::wstring localTargetPath = iConfigManager.GetLocalDrivePath(drive); |
|
1595 path = GetRegistryDir( localTargetPath, aUid ); |
|
1596 |
|
1597 regDirFiles.clear(); |
|
1598 GetDirContents(path, regDirFiles); |
|
1599 |
|
1600 currFile = regDirFiles.begin(); |
|
1601 |
|
1602 // Remove all the .ctl files for this package |
|
1603 while (currFile != regDirFiles.end()) |
|
1604 { |
|
1605 if (*currFile != L"." && *currFile != L"..") |
|
1606 { |
|
1607 RemoveFile(path + *currFile); |
|
1608 } |
|
1609 ++currFile; |
|
1610 } |
|
1611 |
|
1612 // This iterator's object has the same Uid as aUid |
|
1613 const FileDescriptions& files = iDbHelper->GetFileDescriptions(*compIter); |
|
1614 |
|
1615 RemoveInstalledFiles(files, localTargetPath); |
|
1616 |
|
1617 } |
|
1618 // remove the application from database |
|
1619 iDbHelper->RemoveEntry(*compIter); |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 TUint32 SisRegistry::GetUid(TUint32 aSid) const |
|
1624 { |
|
1625 return iDbHelper->GetUid(aSid); |
|
1626 } |
|
1627 |
|
1628 TUint32 SisRegistry::GetUid(const std::wstring& aSidFile) const |
|
1629 { |
|
1630 return iDbHelper->GetUid(aSidFile); |
|
1631 } |
|
1632 |
|
1633 bool SisRegistry::GetInRom(TUint32 aUid) const |
|
1634 { |
|
1635 TUint32 componentId = iDbHelper->GetComponentId(aUid); |
|
1636 return iDbHelper->GetInRom(componentId); |
|
1637 } |
|
1638 |
|
1639 XmlDetails::TScrPreProvisionDetail::TComponent SisRegistry::CreateRegistryEntry(const SisRegistryObject& aSisRegistryObject) |
|
1640 { |
|
1641 |
|
1642 XmlDetails::TScrPreProvisionDetail::TComponent component; |
|
1643 |
|
1644 // add registry token information |
|
1645 AddSisRegistryToken(component, dynamic_cast<const SisRegistryToken&> (aSisRegistryObject)); |
|
1646 |
|
1647 |
|
1648 // update SisregistryObject |
|
1649 AddLocalizedNames(component,aSisRegistryObject); |
|
1650 |
|
1651 // This flag cannot be made optional as it is used in queries |
|
1652 AddComponentProperty(component, DbConstants::CompInstallType, aSisRegistryObject.GetInstallType(), IGNORE_FORMATTING); |
|
1653 |
|
1654 AddComponentDependencies(component, aSisRegistryObject); |
|
1655 AddEmbeddedPackages(component, aSisRegistryObject.GetEmbeddedPackages()); |
|
1656 AddProperties(component, aSisRegistryObject.GetProperties()); |
|
1657 AddFileDescription(component, aSisRegistryObject.GetFileDescriptions()); |
|
1658 |
|
1659 // inROM |
|
1660 if(DbConstants::KDefaultIsInRom != aSisRegistryObject.GetInRom()) |
|
1661 AddComponentProperty(component, DbConstants::CompInRom, aSisRegistryObject.GetInRom(), IGNORE_FORMATTING ); |
|
1662 |
|
1663 // isSigned |
|
1664 if(DbConstants::KDefaultIsSigned != aSisRegistryObject.GetSigned()) |
|
1665 AddComponentProperty(component, DbConstants::CompIsSigned, aSisRegistryObject.GetSigned(), IGNORE_FORMATTING); |
|
1666 |
|
1667 // SignedBySuCert |
|
1668 if(DbConstants::KDefaultIsSignedBySuCert != aSisRegistryObject.GetSignedBySuCert()) |
|
1669 AddComponentProperty(component, DbConstants::CompSignedBySuCert, aSisRegistryObject.GetSignedBySuCert(), IGNORE_FORMATTING); |
|
1670 |
|
1671 // DeletablePreinstalled |
|
1672 if(DbConstants::KDefaultIsDeletablePreInstalled != aSisRegistryObject.GetPreInstalled()) |
|
1673 AddComponentProperty(component, DbConstants::CompDeletablePreinstalled, aSisRegistryObject.GetPreInstalled(), IGNORE_FORMATTING); |
|
1674 |
|
1675 // iTrust |
|
1676 if(DbConstants::KDefaultTrustValue != aSisRegistryObject.GetTrust()) |
|
1677 AddComponentProperty(component, DbConstants::CompTrust, aSisRegistryObject.GetTrust(), IGNORE_FORMATTING ); |
|
1678 |
|
1679 // iRemoveWithLastDependent |
|
1680 if(DbConstants::KDefaultRemoveWithLastDependent != aSisRegistryObject.GetRemoveWithLastDependent()) |
|
1681 AddComponentProperty(component, DbConstants::CompIsRemoveWithLastDependent, aSisRegistryObject.GetRemoveWithLastDependent(), IGNORE_FORMATTING ); |
|
1682 |
|
1683 // iTrustTimeStamp will be deprecated |
|
1684 // 64 bit value |
|
1685 std::wstring strTimeStamp = Utils::Int64ToWideString(aSisRegistryObject.GetTrustTimeStamp()); |
|
1686 AddComponentProperty(component, DbConstants::CompTrustTimeStamp, strTimeStamp, IGNORE_FORMATTING, false ); |
|
1687 |
|
1688 // iTrustStatus |
|
1689 AddTrustStatus(component, aSisRegistryObject.GetTrustStatus() ); |
|
1690 |
|
1691 // installChainIndices |
|
1692 AddInstallChainIndices(component, aSisRegistryObject.GetInstallChainIndices() ); |
|
1693 |
|
1694 // iIsRemovable |
|
1695 if(aSisRegistryObject.GetIsRemovable() ) |
|
1696 { |
|
1697 component.iComponentDetails.iIsRemovable = 1; |
|
1698 } |
|
1699 else |
|
1700 { |
|
1701 component.iComponentDetails.iIsRemovable = 0; |
|
1702 } |
|
1703 |
|
1704 // iIsHidden |
|
1705 if(aSisRegistryObject.GetIsHidden() ) |
|
1706 { |
|
1707 component.iComponentDetails.iIsHidden = 1; |
|
1708 } |
|
1709 else |
|
1710 { |
|
1711 component.iComponentDetails.iIsHidden = 0; |
|
1712 } |
|
1713 |
|
1714 return component; |
|
1715 } |
|
1716 |
|
1717 void SisRegistry::AddSisRegistryToken ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
1718 const SisRegistryToken& aSisRegistryToken |
|
1719 ) |
|
1720 { |
|
1721 // add sisregistrypackage details |
|
1722 AddSisRegistryPackage( aComponent, dynamic_cast<const SisRegistryPackage&>(aSisRegistryToken), aSisRegistryToken.GetLanguage() ); |
|
1723 |
|
1724 // add sid count |
|
1725 // sids would be added later alongwith their corresponding executables. |
|
1726 int sidCount = aSisRegistryToken.GetSids().size(); |
|
1727 if (DbConstants::KDefaultSidCount != sidCount) |
|
1728 AddComponentProperty( aComponent, DbConstants::CompSidCount, sidCount, IGNORE_FORMATTING); |
|
1729 |
|
1730 if( sidCount > 0) |
|
1731 { |
|
1732 AddComponentProperty(aComponent, DbConstants::CompSidsPresent, ENABLE, IGNORE_FORMATTING); |
|
1733 } |
|
1734 |
|
1735 AddControllerInfo(aComponent, aSisRegistryToken.GetControllerInfo()); |
|
1736 |
|
1737 AddVersion(aComponent, aSisRegistryToken.GetVersion()); |
|
1738 |
|
1739 if (aSisRegistryToken.GetLanguage() != DbConstants::KDefaultInstalledLanguage) |
|
1740 AddComponentProperty( aComponent, DbConstants::CompLanguage, aSisRegistryToken.GetLanguage(), IGNORE_FORMATTING); |
|
1741 |
|
1742 if (aSisRegistryToken.GetSelectedDrive() != DbConstants::KDefaultInstalledDrive) |
|
1743 AddComponentProperty( aComponent, DbConstants::CompSelectedDrive, aSisRegistryToken.GetSelectedDrive(), IGNORE_FORMATTING); |
|
1744 |
|
1745 } |
|
1746 |
|
1747 void SisRegistry::AddSisRegistryPackage ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
1748 const SisRegistryPackage& aSisRegistryPackage, |
|
1749 int aLanguage |
|
1750 ) |
|
1751 { |
|
1752 |
|
1753 // vendor |
|
1754 AddComponentProperty( aComponent, DbConstants::CompUniqueVendorName, aSisRegistryPackage.GetVendorName(),IGNORE_FORMATTING,false); |
|
1755 // uid |
|
1756 std::wstringstream strPropName; |
|
1757 strPropName << DbConstants::CompUid; |
|
1758 |
|
1759 std::wstringstream strPropValue; |
|
1760 TInt32 uid = aSisRegistryPackage.GetUid(); |
|
1761 strPropValue << uid; |
|
1762 |
|
1763 XmlDetails::TScrPreProvisionDetail::TComponentProperty |
|
1764 compProperty = CreateComponentProperty(strPropName.str(), strPropValue.str(), true, false); |
|
1765 |
|
1766 aComponent.iComponentProperties.push_back(compProperty); |
|
1767 |
|
1768 // index |
|
1769 AddComponentProperty( aComponent, DbConstants::CompIndex, aSisRegistryPackage.GetIndex(),IGNORE_FORMATTING ); |
|
1770 |
|
1771 // calculate the globalid for this component |
|
1772 int installType = dynamic_cast<const SisRegistryObject&>(aSisRegistryPackage).GetInstallType(); |
|
1773 std::wstring globalId = GetGlobalId(aSisRegistryPackage.GetUid(), installType, aSisRegistryPackage.GetPackageName()); |
|
1774 |
|
1775 aComponent.iComponentDetails.iGlobalId = globalId; |
|
1776 } |
|
1777 |
|
1778 void SisRegistry::AddControllerInfo ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
1779 const std::vector<ControllerInfo*>& aControllerInfo |
|
1780 ) |
|
1781 { |
|
1782 if(DbConstants::KDefaultControllerCount != aControllerInfo.size()) |
|
1783 AddComponentProperty( aComponent, DbConstants::CompControllerCount, aControllerInfo.size(), IGNORE_FORMATTING); |
|
1784 |
|
1785 std::vector<ControllerInfo*>::const_iterator controllerInfoIter; |
|
1786 int count = 0; |
|
1787 for(controllerInfoIter = aControllerInfo.begin() ; controllerInfoIter != aControllerInfo.end() ; ++controllerInfoIter ) |
|
1788 { |
|
1789 std::wstring version = FormatVersionToString((*controllerInfoIter)->GetVersion()); |
|
1790 AddComponentProperty( aComponent, DbConstants::CompControllerVersion, version, count, false); |
|
1791 |
|
1792 // offset |
|
1793 AddComponentProperty( aComponent, DbConstants::CompControllerOffset, (*controllerInfoIter)->GetOffset(), count ); |
|
1794 |
|
1795 // add hash information |
|
1796 AddHashContainer(aComponent, (*controllerInfoIter)->GetHashContainer(), count ); |
|
1797 ++count; |
|
1798 } |
|
1799 } |
|
1800 |
|
1801 void SisRegistry::AddVersion ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
1802 const Version& aVersion |
|
1803 ) |
|
1804 { |
|
1805 aComponent.iComponentDetails.iVersion.iMajor = Utils::IntegerToWideString(aVersion.GetMajor()); |
|
1806 aComponent.iComponentDetails.iVersion.iMinor = Utils::IntegerToWideString(aVersion.GetMinor()); |
|
1807 aComponent.iComponentDetails.iVersion.iBuild = Utils::IntegerToWideString(aVersion.GetBuild()); |
|
1808 } |
|
1809 |
|
1810 void SisRegistry::AddHashContainer ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
1811 const HashContainer& aHashContainer, |
|
1812 int aCount |
|
1813 ) |
|
1814 { |
|
1815 if (aHashContainer.GetHashId() != HashContainer::EHashSHA) |
|
1816 AddComponentProperty( aComponent, DbConstants::CompControllerHashAlgorithm, aHashContainer.GetHashId(), aCount); |
|
1817 |
|
1818 int algorithmId = aHashContainer.GetHashId(); |
|
1819 // The property is a concatenation of the algorithm id and the hash data |
|
1820 const std::string hashData = aHashContainer.GetData(); |
|
1821 |
|
1822 std::string encodedHashData = Util::Base64Encode(hashData); |
|
1823 std::wstring wideHashData = Utils::string2wstring(encodedHashData); |
|
1824 AddComponentProperty( aComponent, DbConstants::CompControllerHashData, wideHashData, aCount, true); |
|
1825 |
|
1826 } |
|
1827 |
|
1828 |
|
1829 void SisRegistry::AddLocalizedNames(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const SisRegistryObject& aSisRegistryObject) |
|
1830 { |
|
1831 TInt size = aSisRegistryObject.GetMatchingSupportedLanguages().size(); |
|
1832 if ( 0 == size ) |
|
1833 { |
|
1834 XmlDetails::TScrPreProvisionDetail::TComponentLocalizable componentLocalizable; |
|
1835 componentLocalizable.iVendor = aSisRegistryObject.GetVendorLocalizedName(); |
|
1836 componentLocalizable.iName = aSisRegistryObject.GetPackageName(); |
|
1837 componentLocalizable.iLocale = aSisRegistryObject.GetLanguage(); |
|
1838 aComponent.iComponentLocalizables.push_back(componentLocalizable); |
|
1839 } |
|
1840 else |
|
1841 { |
|
1842 for ( TInt i=0; i < size; i++) |
|
1843 { |
|
1844 XmlDetails::TScrPreProvisionDetail::TComponentLocalizable componentLocalizable; |
|
1845 componentLocalizable.iName = aSisRegistryObject.GetLocalizedPackageNames()[i]->GetString(); |
|
1846 componentLocalizable.iLocale = aSisRegistryObject.GetMatchingSupportedLanguages().at(i); |
|
1847 componentLocalizable.iVendor = aSisRegistryObject.GetLocalizedVendorNames()[i]->GetString(); |
|
1848 aComponent.iComponentLocalizables.push_back(componentLocalizable); |
|
1849 } |
|
1850 } |
|
1851 } |
|
1852 |
|
1853 void SisRegistry::AddComponentDependencies(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const SisRegistryObject& aSisRegistryObject) |
|
1854 { |
|
1855 const std::vector<SisRegistryDependency*>& dependencies = aSisRegistryObject.GetDependencies(); |
|
1856 if(dependencies.size() == 0) |
|
1857 return; |
|
1858 |
|
1859 std::wstring dependentGlobalId = GetGlobalId( aSisRegistryObject.GetUid(), aSisRegistryObject.GetInstallType(), aSisRegistryObject.GetPackageName() ); |
|
1860 |
|
1861 XmlDetails::TScrPreProvisionDetail::TComponentDependency componentDependency; |
|
1862 componentDependency.iDependentId = dependentGlobalId; |
|
1863 |
|
1864 |
|
1865 for(std::vector<SisRegistryDependency*>::const_iterator depIter = dependencies.begin() ; depIter != dependencies.end() ; ++depIter) |
|
1866 { |
|
1867 XmlDetails::TScrPreProvisionDetail::TComponentDependency::TComponentDependencyDetail componentDependencyDetail; |
|
1868 |
|
1869 TUint32 uid = (*depIter)->GetUid(); |
|
1870 std::wstring supplierGlobalId = GetGlobalId(uid,CSISInfo::EInstInstallation,L""); |
|
1871 componentDependencyDetail.iSupplierId = supplierGlobalId; |
|
1872 |
|
1873 // add fromVersion |
|
1874 std::wstring fromVersion = FormatVersionToString((*depIter)->GetFromVersion()); |
|
1875 componentDependencyDetail.iFromVersion = fromVersion; |
|
1876 |
|
1877 // add toVersion |
|
1878 std::wstring toVersion = FormatVersionToString((*depIter)->GetToVersion()); |
|
1879 componentDependencyDetail.iToVersion = toVersion; |
|
1880 |
|
1881 componentDependency.iComponentDependencyList.push_back(componentDependencyDetail); |
|
1882 } |
|
1883 aComponent.iComponentDependency = componentDependency; |
|
1884 } |
|
1885 |
|
1886 void SisRegistry::AddEmbeddedPackages(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::vector<SisRegistryPackage*>& aEmbeddedPackages ) |
|
1887 { |
|
1888 // EmbeddedPckgCount |
|
1889 int embeddedPckgCount = aEmbeddedPackages.size(); |
|
1890 if (DbConstants::KDefaultEmbeddedPackageCount != embeddedPckgCount) |
|
1891 AddComponentProperty(aComponent, DbConstants::CompEmbeddedPackageCount, embeddedPckgCount, IGNORE_FORMATTING ); |
|
1892 |
|
1893 if( embeddedPckgCount > 0) |
|
1894 { |
|
1895 AddComponentProperty(aComponent, DbConstants::CompEmbeddedPackagePresent, ENABLE, IGNORE_FORMATTING ); |
|
1896 } |
|
1897 |
|
1898 |
|
1899 std::vector<SisRegistryPackage*>::const_iterator pckgIter; |
|
1900 |
|
1901 int count = 0; |
|
1902 for(pckgIter = aEmbeddedPackages.begin() ; pckgIter != aEmbeddedPackages.end() ; ++pckgIter, ++count) |
|
1903 { |
|
1904 // package uid |
|
1905 AddComponentProperty( aComponent, DbConstants::CompEmbeddedPackageUid, (*pckgIter)->GetUid(), count); |
|
1906 // package name |
|
1907 AddComponentProperty( aComponent, DbConstants::CompEmbeddedPackageName, (*pckgIter)->GetPackageName(), count, false); |
|
1908 // vendor name |
|
1909 AddComponentProperty( aComponent, DbConstants::CompEmbeddedPackageVendor, (*pckgIter)->GetVendorName(), count, false); |
|
1910 // index |
|
1911 AddComponentProperty( aComponent, DbConstants::CompEmbeddedPackageIndex, (*pckgIter)->GetIndex(), count); |
|
1912 } |
|
1913 |
|
1914 } |
|
1915 |
|
1916 |
|
1917 void SisRegistry::AddProperties(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::vector<SisRegistryProperty*>& aProperties ) |
|
1918 { |
|
1919 if (aProperties.size() != DbConstants::KDefaultCompPropertyCount) |
|
1920 AddComponentProperty(aComponent, DbConstants::CompPropertyCount, aProperties.size(), IGNORE_FORMATTING ); |
|
1921 |
|
1922 std::vector<SisRegistryProperty*>::const_iterator propIter; |
|
1923 |
|
1924 int count = 0; |
|
1925 for(propIter = aProperties.begin() ; propIter != aProperties.end() ; ++propIter, ++count) |
|
1926 { |
|
1927 // key |
|
1928 AddComponentProperty( aComponent, DbConstants::CompPropertyKey, (*propIter)->GetKey(), count); |
|
1929 // value |
|
1930 AddComponentProperty( aComponent, DbConstants::CompPropertyValue, (*propIter)->GetValue(), count); |
|
1931 } |
|
1932 } |
|
1933 |
|
1934 |
|
1935 void SisRegistry::AddFileDescription(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::vector<FileDescription*>& aFileDescription ) |
|
1936 { |
|
1937 std::vector<FileDescription*>::const_iterator filedesIter; |
|
1938 int wildcardFileCount = 0; |
|
1939 int exeFileIndex = 0; |
|
1940 for(filedesIter = aFileDescription.begin() ; filedesIter != aFileDescription.end(); ++filedesIter) |
|
1941 { |
|
1942 // if it has wild card characters then add it as part of componentproperties table |
|
1943 if( IsFileWideCard((*filedesIter)->GetTarget()) ) |
|
1944 { |
|
1945 // file target |
|
1946 AddComponentProperty( aComponent, DbConstants::WCFileName, (*filedesIter)->GetTarget(), wildcardFileCount++, false); |
|
1947 continue; |
|
1948 } |
|
1949 |
|
1950 TInt sid = (*filedesIter)->GetSid(); |
|
1951 if( sid != 0 ) |
|
1952 { |
|
1953 // add sid file format |
|
1954 AddComponentProperty(aComponent, DbConstants::CompSidFileName, (*filedesIter)->GetTarget(), exeFileIndex, false); |
|
1955 AddComponentProperty(aComponent, DbConstants::CompSid, sid, exeFileIndex); |
|
1956 ++exeFileIndex; |
|
1957 } |
|
1958 |
|
1959 // add the location in the component files table |
|
1960 XmlDetails::TScrPreProvisionDetail::TComponentFile componentFile; |
|
1961 componentFile.iLocation = (*filedesIter)->GetTarget(); |
|
1962 AddFileDescriptionAsFileProperty(componentFile, *filedesIter); |
|
1963 aComponent.iComponentFiles.push_back(componentFile); |
|
1964 } |
|
1965 |
|
1966 if (DbConstants::KDefaultWildCardFileCount != wildcardFileCount) |
|
1967 AddComponentProperty(aComponent, DbConstants::CompWildCardFileCount, wildcardFileCount, IGNORE_FORMATTING); |
|
1968 } |
|
1969 |
|
1970 void SisRegistry::AddFileDescriptionAsFileProperty ( XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, |
|
1971 const FileDescription* aFileDescription |
|
1972 ) |
|
1973 { |
|
1974 // mime type |
|
1975 if( !aFileDescription->GetMimeType().empty()) |
|
1976 { |
|
1977 AddFileProperty( aComponentFile, DbConstants::FileMimeType, aFileDescription->GetMimeType(), true); |
|
1978 } |
|
1979 // operation |
|
1980 if(aFileDescription->GetOperation() != CSISFileDescription::EOpInstall) |
|
1981 { |
|
1982 AddFileProperty( aComponentFile, DbConstants::FileSisFileOperation, aFileDescription->GetOperation(), false); |
|
1983 } |
|
1984 // operation option |
|
1985 if( aFileDescription->GetOperationOptions() ) |
|
1986 { |
|
1987 AddFileProperty( aComponentFile, DbConstants::FileFileOperationOptions, aFileDescription->GetOperationOptions(), false); |
|
1988 } |
|
1989 |
|
1990 // uncompressed length |
|
1991 if( aFileDescription->GetUncompressedLength() ) |
|
1992 { |
|
1993 AddFileProperty( aComponentFile, DbConstants::FileUncompressedLength, aFileDescription->GetUncompressedLength(), false); |
|
1994 } |
|
1995 |
|
1996 // file index |
|
1997 if( aFileDescription->GetIndex() ) |
|
1998 { |
|
1999 AddFileProperty( aComponentFile, DbConstants::FileIndex, aFileDescription->GetIndex(), false); |
|
2000 } |
|
2001 |
|
2002 // sid |
|
2003 if( aFileDescription->GetSid() ) |
|
2004 { |
|
2005 AddFileProperty( aComponentFile, DbConstants::FileSid, aFileDescription->GetSid(), false); |
|
2006 } |
|
2007 |
|
2008 // filehash algorithm |
|
2009 if (aFileDescription->GetHash().GetHashId() != HashContainer::EHashSHA ) |
|
2010 { |
|
2011 AddFileProperty( aComponentFile, DbConstants::FileHashAlgorithm, aFileDescription->GetHash().GetHashId(), false); |
|
2012 } |
|
2013 // file hash data |
|
2014 if(!aFileDescription->GetHash().GetData().empty()) |
|
2015 { |
|
2016 std::string binHashData = Util::Base64Encode(aFileDescription->GetHash().GetData()); |
|
2017 std::wstring hashData = Utils::string2wstring(binHashData); |
|
2018 AddFileProperty( aComponentFile, DbConstants::FileHashData, hashData, true); |
|
2019 } |
|
2020 } |
|
2021 |
|
2022 void SisRegistry::AddTrustStatus ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
2023 const TrustStatus& aTrustStatus |
|
2024 ) |
|
2025 { |
|
2026 // iValidationStatus |
|
2027 AddComponentProperty( aComponent, DbConstants::CompTrustValidationStatus, aTrustStatus.GetValidationStatus(), IGNORE_FORMATTING); |
|
2028 } |
|
2029 |
|
2030 |
|
2031 void SisRegistry::AddInstallChainIndices ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
2032 const std::vector<TInt>& aInstallChainIndices |
|
2033 ) |
|
2034 { |
|
2035 if (aInstallChainIndices.size() != DbConstants::KDefaultChainIndex) |
|
2036 AddComponentProperty( aComponent, DbConstants::CompInstallChainIndexCount, aInstallChainIndices.size(), IGNORE_FORMATTING); |
|
2037 |
|
2038 std::vector<TInt>::const_iterator chainIndicesIter; |
|
2039 int count = 0; |
|
2040 for(chainIndicesIter = aInstallChainIndices.begin(); chainIndicesIter != aInstallChainIndices.end() ; ++chainIndicesIter) |
|
2041 { |
|
2042 AddComponentProperty(aComponent, DbConstants::CompInstallChainIndex, *chainIndicesIter, count++); |
|
2043 } |
|
2044 } |
|
2045 |
|
2046 void SisRegistry::AddComponentProperty ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
2047 const std::wstring& aPropName, |
|
2048 int aPropValue, |
|
2049 int aCount |
|
2050 ) |
|
2051 { |
|
2052 std::wstringstream strPropName; |
|
2053 |
|
2054 if(aCount != IGNORE_FORMATTING) |
|
2055 { |
|
2056 strPropName << aPropName << aCount; |
|
2057 } |
|
2058 else |
|
2059 { |
|
2060 strPropName << aPropName; |
|
2061 } |
|
2062 |
|
2063 std::wstringstream strPropValue; |
|
2064 strPropValue << aPropValue; |
|
2065 |
|
2066 XmlDetails::TScrPreProvisionDetail::TComponentProperty |
|
2067 compProperty = CreateComponentProperty(strPropName.str(), strPropValue.str(), true, false); |
|
2068 |
|
2069 aComponent.iComponentProperties.push_back(compProperty); |
|
2070 |
|
2071 } |
|
2072 |
|
2073 void SisRegistry::AddComponentProperty ( XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, |
|
2074 const std::wstring& aPropName, |
|
2075 const std::wstring& aPropValue, |
|
2076 int aCount, |
|
2077 bool aIsBinary |
|
2078 ) |
|
2079 { |
|
2080 std::wstringstream strPropName; |
|
2081 |
|
2082 if(aCount != IGNORE_FORMATTING) |
|
2083 { |
|
2084 strPropName << aPropName << aCount; |
|
2085 } |
|
2086 else |
|
2087 { |
|
2088 strPropName << aPropName; |
|
2089 } |
|
2090 |
|
2091 XmlDetails::TScrPreProvisionDetail::TComponentProperty compProperty; |
|
2092 |
|
2093 if(aIsBinary) |
|
2094 { |
|
2095 compProperty = CreateComponentProperty(strPropName.str(), aPropValue,false, true); |
|
2096 } |
|
2097 else |
|
2098 { |
|
2099 compProperty = CreateComponentProperty(strPropName.str(), aPropValue,false, false); |
|
2100 } |
|
2101 |
|
2102 aComponent.iComponentProperties.push_back(compProperty); |
|
2103 } |
|
2104 |
|
2105 void SisRegistry::AddFileProperty ( XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, |
|
2106 const std::wstring& aPropName, |
|
2107 const std::wstring& aPropValue, |
|
2108 bool aIsBinary |
|
2109 ) |
|
2110 { |
|
2111 XmlDetails::TScrPreProvisionDetail::TComponentFile::TFileProperty fileProperty; |
|
2112 |
|
2113 fileProperty.iName = aPropName; |
|
2114 fileProperty.iValue = aPropValue; |
|
2115 fileProperty.iIsIntValue = !aIsBinary; |
|
2116 aComponentFile.iFileProperties.push_back(fileProperty); |
|
2117 } |
|
2118 |
|
2119 void SisRegistry::AddFileProperty ( XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, |
|
2120 const std::wstring& aPropName, |
|
2121 int aPropValue, |
|
2122 bool aIsBinary |
|
2123 ) |
|
2124 { |
|
2125 std::wstringstream strPropValue; |
|
2126 strPropValue << aPropValue; |
|
2127 AddFileProperty(aComponentFile, aPropName, strPropValue.str(), aIsBinary); |
|
2128 } |
|
2129 |
|
2130 XmlDetails::TScrPreProvisionDetail::TComponentProperty |
|
2131 SisRegistry::CreateComponentProperty( const std::wstring& aPropName, const std::wstring& aPropValue, |
|
2132 bool aIsInt, bool aIsStr8Bit, int aLocale |
|
2133 ) |
|
2134 { |
|
2135 XmlDetails::TScrPreProvisionDetail::TComponentProperty componentProperty; |
|
2136 |
|
2137 componentProperty.iName = aPropName; |
|
2138 componentProperty.iLocale = aLocale; |
|
2139 componentProperty.iValue = aPropValue; |
|
2140 componentProperty.iIsIntValue = aIsInt; |
|
2141 componentProperty.iIsStr8Bit = aIsStr8Bit; |
|
2142 |
|
2143 return componentProperty; |
|
2144 } |
|
2145 |
|
2146 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |