1 /* |
1 /* |
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
1445 } |
1447 } |
1446 } |
1448 } |
1447 |
1449 |
1448 void SisRegistry::UpdateInstallationInformation(XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) |
1450 void SisRegistry::UpdateInstallationInformation(XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) |
1449 { |
1451 { |
1450 CXmlGenerator xmlgenerator; |
1452 CXmlGenerator xmlGenerator; |
1451 char* tmpFileName = tmpnam(NULL); |
1453 char* tmpFileName = tmpnam(NULL); |
1452 std::wstring filename(string2wstring(tmpFileName)); |
1454 std::wstring filename(string2wstring(tmpFileName)); |
1453 |
1455 |
1454 xmlgenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail); |
1456 int isRomApplication = 0; |
|
1457 xmlGenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail, isRomApplication); |
1455 |
1458 |
1456 std::string executable = "scrtool.exe"; |
1459 std::string executable = "scrtool.exe"; |
1457 std::string command; |
1460 std::string command; |
1458 command = executable + " -d " + GetDbPath() + " -p " + tmpFileName; |
1461 command = executable + " -d " + GetDbPath() + " -p " + tmpFileName; |
1459 |
1462 |
1460 int error = system(command.c_str()); |
1463 int error = system(command.c_str()); |
1461 |
1464 |
|
1465 int err = remove(tmpFileName); |
|
1466 if(err != 0) |
|
1467 LERROR(L"Temporary file removal failed."); |
|
1468 |
1462 if(error != 0) |
1469 if(error != 0) |
1463 { |
1470 { |
1464 std::string err = "Scrtool failed to upload the database registry entry."; |
1471 std::string err = "Scrtool failed to upload the database registry entry."; |
1465 LERROR(L"Scrtool failed to upload the database registry entry."); |
1472 LERROR(L"Scrtool failed to upload the database registry entry."); |
1466 throw InterpretSisError(err, DATABASE_UPDATE_FAILED); |
1473 throw InterpretSisError(err, DATABASE_UPDATE_FAILED); |
1467 } |
1474 } |
1468 |
|
1469 error = remove(tmpFileName); |
|
1470 |
|
1471 if(error != 0) |
|
1472 { |
|
1473 LERROR(L"Temporary file removal failed."); |
|
1474 } |
|
1475 |
|
1476 } |
1475 } |
1477 |
1476 |
1478 std::string SisRegistry::GetDbPath() |
1477 std::string SisRegistry::GetDbPath() |
1479 { |
1478 { |
1480 if ( |
1479 if ( |
1617 } |
1624 } |
1618 // remove the application from database |
1625 // remove the application from database |
1619 iDbHelper->RemoveEntry(*compIter); |
1626 iDbHelper->RemoveEntry(*compIter); |
1620 } |
1627 } |
1621 } |
1628 } |
|
1629 |
|
1630 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1631 void SisRegistry::BackupCtl(TUint32 aUid) |
|
1632 { |
|
1633 std::list<std::wstring> regDirFiles; |
|
1634 std::wstring path = GetRegistryDir( iParamList.SystemDrivePath(), aUid ); |
|
1635 GetDirContents(path, regDirFiles); |
|
1636 std::list<std::wstring>::iterator currFile = regDirFiles.begin(); |
|
1637 |
|
1638 std::wstring path1 = FixPathDelimiterstap(path); |
|
1639 // Backup all .ctl files in the system drive for this package |
|
1640 while (currFile != regDirFiles.end()) |
|
1641 { |
|
1642 if (*currFile != L"." && *currFile != L"..") |
|
1643 { |
|
1644 std::string ifile = wstring2string(path1 +*currFile); |
|
1645 std::string ibackupfile(ifile); |
|
1646 ibackupfile.append("_backup"); |
|
1647 |
|
1648 int err=FileCopyA(ifile.c_str(),ibackupfile.c_str(),0); |
|
1649 if (err == 0) |
|
1650 LERROR(L"Failed to Backup .ctl "); |
|
1651 } |
|
1652 ++currFile; |
|
1653 } |
|
1654 } |
|
1655 |
|
1656 void SisRegistry::RestoreCtl(TUint32 aUid, TBool& aBackupFlag) |
|
1657 { |
|
1658 std::list<std::wstring> regDirFiles; |
|
1659 std::wstring path = GetRegistryDir( iParamList.SystemDrivePath(), aUid ); |
|
1660 GetDirContents(path, regDirFiles); |
|
1661 std::list<std::wstring>::iterator currFile = regDirFiles.begin(); |
|
1662 |
|
1663 // Restore all .ctl files in the system drive for this package |
|
1664 while (currFile != regDirFiles.end()) |
|
1665 { |
|
1666 if (*currFile != L"." && *currFile != L"..") |
|
1667 { |
|
1668 if(aBackupFlag) |
|
1669 { |
|
1670 int pos =0; |
|
1671 if((pos = currFile->find(L".ctl_backup", 0)) == std::wstring::npos) |
|
1672 { |
|
1673 std::string ifile = wstring2string(path +*currFile); |
|
1674 std::string ibackupfile(ifile); |
|
1675 ibackupfile.append("_backup"); |
|
1676 |
|
1677 RemoveFile(path + *currFile); |
|
1678 int err = FileMoveA(ibackupfile.c_str(),ifile.c_str()); |
|
1679 if (err == 0) |
|
1680 LERROR(L"Failed to Restore .ctl "); |
|
1681 } |
|
1682 } |
|
1683 else |
|
1684 { |
|
1685 RemoveFile(path + *currFile); |
|
1686 } |
|
1687 } |
|
1688 ++currFile; |
|
1689 } |
|
1690 } |
|
1691 |
|
1692 void SisRegistry::RemoveCtlBackup(TUint32 aUid) |
|
1693 { |
|
1694 std::list<std::wstring> regDirFiles; |
|
1695 std::wstring path = GetRegistryDir( iParamList.SystemDrivePath(), aUid ); |
|
1696 GetDirContents(path, regDirFiles); |
|
1697 std::list<std::wstring>::iterator currFile = regDirFiles.begin(); |
|
1698 |
|
1699 // Remove all .ctl backup files in the system drive for this package |
|
1700 while (currFile != regDirFiles.end()) |
|
1701 { |
|
1702 if (*currFile != L"." && *currFile != L"..") |
|
1703 { |
|
1704 std::wstring ifile(path +*currFile); |
|
1705 ifile.append(L"_backup"); |
|
1706 |
|
1707 if (FileExists(ifile)) |
|
1708 RemoveFile(ifile); |
|
1709 } |
|
1710 ++currFile; |
|
1711 } |
|
1712 } |
|
1713 #endif |
1622 |
1714 |
1623 TUint32 SisRegistry::GetUid(TUint32 aSid) const |
1715 TUint32 SisRegistry::GetUid(TUint32 aSid) const |
1624 { |
1716 { |
1625 return iDbHelper->GetUid(aSid); |
1717 return iDbHelper->GetUid(aSid); |
1626 } |
1718 } |
1653 |
1745 |
1654 AddComponentDependencies(component, aSisRegistryObject); |
1746 AddComponentDependencies(component, aSisRegistryObject); |
1655 AddEmbeddedPackages(component, aSisRegistryObject.GetEmbeddedPackages()); |
1747 AddEmbeddedPackages(component, aSisRegistryObject.GetEmbeddedPackages()); |
1656 AddProperties(component, aSisRegistryObject.GetProperties()); |
1748 AddProperties(component, aSisRegistryObject.GetProperties()); |
1657 AddFileDescription(component, aSisRegistryObject.GetFileDescriptions()); |
1749 AddFileDescription(component, aSisRegistryObject.GetFileDescriptions()); |
|
1750 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
1751 AddApplicationRegistrationInfoL(component, aSisRegistryObject.GetFileDescriptions(), aSisRegistryObject.GetInRom()); |
|
1752 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
1658 |
1753 |
1659 // inROM |
1754 // inROM |
1660 if(DbConstants::KDefaultIsInRom != aSisRegistryObject.GetInRom()) |
1755 if(DbConstants::KDefaultIsInRom != aSisRegistryObject.GetInRom()) |
1661 AddComponentProperty(component, DbConstants::CompInRom, aSisRegistryObject.GetInRom(), IGNORE_FORMATTING ); |
1756 AddComponentProperty(component, DbConstants::CompInRom, aSisRegistryObject.GetInRom(), IGNORE_FORMATTING ); |
1662 |
1757 |
1957 } |
2052 } |
1958 |
2053 |
1959 // add the location in the component files table |
2054 // add the location in the component files table |
1960 XmlDetails::TScrPreProvisionDetail::TComponentFile componentFile; |
2055 XmlDetails::TScrPreProvisionDetail::TComponentFile componentFile; |
1961 componentFile.iLocation = (*filedesIter)->GetTarget(); |
2056 componentFile.iLocation = (*filedesIter)->GetTarget(); |
|
2057 |
1962 AddFileDescriptionAsFileProperty(componentFile, *filedesIter); |
2058 AddFileDescriptionAsFileProperty(componentFile, *filedesIter); |
1963 aComponent.iComponentFiles.push_back(componentFile); |
2059 aComponent.iComponentFiles.push_back(componentFile); |
1964 } |
2060 } |
1965 |
2061 |
1966 if (DbConstants::KDefaultWildCardFileCount != wildcardFileCount) |
2062 if (DbConstants::KDefaultWildCardFileCount != wildcardFileCount) |
1967 AddComponentProperty(aComponent, DbConstants::CompWildCardFileCount, wildcardFileCount, IGNORE_FORMATTING); |
2063 AddComponentProperty(aComponent, DbConstants::CompWildCardFileCount, wildcardFileCount, IGNORE_FORMATTING); |
1968 } |
2064 } |
|
2065 |
|
2066 |
|
2067 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
|
2068 void SisRegistry::AddApplicationRegistrationInfoL(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, const std::vector<FileDescription*>& aFileDescription, int aInRom ) |
|
2069 { |
|
2070 std::vector<FileDescription*>::const_iterator filedesIter; |
|
2071 std::wstring iLocalFile; |
|
2072 std::string RegistrationFileName; |
|
2073 |
|
2074 //Find Registration File from list of filelist |
|
2075 for(filedesIter = aFileDescription.begin() ; filedesIter != aFileDescription.end(); ++filedesIter) |
|
2076 { |
|
2077 // if it has wild card characters then donot process. Continue. |
|
2078 if( IsFileWideCard((*filedesIter)->GetLocalFile()) ) |
|
2079 { |
|
2080 continue; |
|
2081 } |
|
2082 |
|
2083 iLocalFile = (*filedesIter)->GetLocalFile(); |
|
2084 RegistrationFileName = wstring2string(iLocalFile); |
|
2085 |
|
2086 std::string iRomPath = wstring2string(iParamList.RomDrivePath()); |
|
2087 if(aInRom) |
|
2088 { |
|
2089 std::string localpath = FullNameWithoutDrive(RegistrationFileName); |
|
2090 RegistrationFileName = iRomPath + localpath; |
|
2091 } |
|
2092 |
|
2093 //Return 0 for Registration file else 1 |
|
2094 TInt err = FindRegistrationResourceFileL(RegistrationFileName); |
|
2095 |
|
2096 if(err) |
|
2097 continue; |
|
2098 |
|
2099 size_t found; |
|
2100 std::string folder; |
|
2101 found=RegistrationFileName.find("private\\10003a3f\\"); |
|
2102 |
|
2103 if( found != string::npos ) |
|
2104 folder = RegistrationFileName.substr(0,found); |
|
2105 else |
|
2106 folder = RegistrationFileName; |
|
2107 |
|
2108 CAppInfoReader* appInfoReader = NULL; |
|
2109 appInfoReader = CAppInfoReader::NewL(RegistrationFileName, NullUid, folder); |
|
2110 if (!appInfoReader) |
|
2111 { |
|
2112 std::string errMsg= "Error in Reading File. Memory Allocation Failed"; |
|
2113 throw CResourceFileException(errMsg); |
|
2114 } |
|
2115 else |
|
2116 { |
|
2117 TBool readSuccessful=EFalse; |
|
2118 |
|
2119 readSuccessful= appInfoReader->ReadL(aFileDescription, iRomPath, aInRom); |
|
2120 |
|
2121 if (readSuccessful) |
|
2122 { |
|
2123 CreateApplicationRegistrationInfoL(aComponent,appInfoReader); |
|
2124 } |
|
2125 else |
|
2126 { |
|
2127 delete appInfoReader; |
|
2128 std::string errMsg= "Reading Resource File failed."; |
|
2129 throw CResourceFileException(errMsg); |
|
2130 } |
|
2131 } |
|
2132 delete appInfoReader; |
|
2133 } |
|
2134 } |
|
2135 #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK |
1969 |
2136 |
1970 void SisRegistry::AddFileDescriptionAsFileProperty ( XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, |
2137 void SisRegistry::AddFileDescriptionAsFileProperty ( XmlDetails::TScrPreProvisionDetail::TComponentFile& aComponentFile, |
1971 const FileDescription* aFileDescription |
2138 const FileDescription* aFileDescription |
1972 ) |
2139 ) |
1973 { |
2140 { |