in source/code/scxsystemlib/software/installedsoftwareinstance.cpp [59:215]
void InstalledSoftwareInstance::Update()
{
SCX_LOGTRACE(m_log, L"InstalledSoftwareInstance Update()");
m_evidenceSource = L"M";
#if defined(sun)
vector<wstring> allLines;
m_deps->GetAllLinesOfPkgInfo(GetId(), allLines);
for(vector<wstring>::iterator it = allLines.begin(); it != allLines.end(); it++) {
size_t pos = it->find_first_of('=');
if( pos != wstring::npos ) {
wstring key = it->substr(0, pos);
wstring value = it->substr(pos+1);
std::transform(key.begin(), key.end(), key.begin(), (int (*)(int))std::toupper);
if(key == L"BASEDIR") {
m_installedLocation = value;
}
else if(key == L"PKG") {
m_productName = value;
}
else if(key == L"NAME") {
m_displayName = value;
}
else if(key == L"VERSION") {
m_productVersion = value;
SetDetailedVersion(value);
}
else if(key == L"VENDOR") {
m_publisher = value;
}
else if(key == L"INSTDATE") {
SetInstallDate(value);
}
}
}
//productID consists of productName and productVersion
m_productID.append(m_productName).append(L" ").append(m_productVersion);
#elif defined(linux)
vector<wstring> content;
map<wstring, wstring> contentMap;
m_deps->GetSoftwareInfoRawData(GetId(),content);
m_displayName = GetId();
for (std::vector<wstring>::iterator itSoftwareInfo = content.begin(); itSoftwareInfo != content.end(); itSoftwareInfo++)
{
size_t pos = itSoftwareInfo->find_first_of(':');
if( pos != wstring::npos ) {
wstring key = itSoftwareInfo->substr(0, pos);
wstring value = itSoftwareInfo->substr(pos+1);
contentMap.insert(make_pair(key, value));
}
}
if ( contentMap.find( L"Name" ) != contentMap.end() )
{
m_productName = contentMap[L"Name"];
}
if ( contentMap.find( L"Vendor" ) != contentMap.end() )
{
m_publisher = contentMap[L"Vendor"];
}
if ( contentMap.find( L"InstallTime" ) != contentMap.end() )
{
m_installDate = SCXCalendarTime::FromPosixTime(StrToLong(contentMap[L"InstallTime"]));
}
if ( contentMap.find( L"SourceRPM" ) != contentMap.end() )
{
m_installSource = contentMap[L"SourceRPM"];
}
if ( contentMap.find( L"Version" ) != contentMap.end() )
{
m_productVersion = contentMap[L"Version"];
SetDetailedVersion(m_productVersion);
}
m_productID=m_displayName;
#elif defined(aix)
m_productID = GetId();
if (m_deps->GetProperties(m_productID, m_productVersion, m_displayName, m_installDate))
{
SCX_LOGTRACE(m_log, wstring(L"Collected properties for ") + m_productID);
}
#elif defined(hpux)
InstalledSoftwareDependencies::PROPMAP mapProperties;
wstring indexFileName = GetId() + L"pfiles/INDEX";
m_productID = GetId();
SCX_LOGTRACE(m_log, wstring(L"Collected properties for ") + m_productID);
if (m_deps->GetAllPropertiesOfIndexFile(indexFileName, mapProperties))
{
InstalledSoftwareDependencies::PROPMAP::const_iterator cit;
// Publisher
cit = mapProperties.find(InstalledSoftwareDependencies::keyPublisher);
if (cit != mapProperties.end())
{
// Example: "Hewlett-Packard Company"
m_publisher = cit->second;
}
// DisplayName
cit = mapProperties.find(InstalledSoftwareDependencies::keyTitle);
if (cit != mapProperties.end())
{
// Example: "HPVM Guest AVIO Storage Software"
m_displayName = cit->second;
}
// Version
cit = mapProperties.find(InstalledSoftwareDependencies::keyRevision);
if (cit != mapProperties.end())
{
// Example: "B.11.31.0909"
size_t pos = cit->second.find_first_of(L"0123456789");
if( pos != wstring::npos )
{
wstring majmin(cit->second.substr(pos));
SetDetailedVersion(majmin);
}
// Convert to major/minor.
m_productVersion = cit->second;
}
// InstallDate
cit = mapProperties.find(InstalledSoftwareDependencies::keyInstallDate);
if (cit != mapProperties.end())
{
// Example: "201101021650.58"
SetInstallDate(cit->second);
}
// InstallSource
cit = mapProperties.find(InstalledSoftwareDependencies::keyInstallSource);
if (cit != mapProperties.end())
{
// Example: "hostrhpi05:/var/opt/ignite/depots/Rel_B.11.31/core_media"
m_installSource = cit->second;
}
// InstalledLocation
cit = mapProperties.find(InstalledSoftwareDependencies::keyDirectory);
if (cit != mapProperties.end())
{
// Example: "/"
m_installedLocation = cit->second;
}
// ProductName
cit = mapProperties.find(InstalledSoftwareDependencies::keyTag);
if (cit != mapProperties.end())
{
// Example: "AVIO-GVSD"
m_productName = cit->second;
}
}
#endif
}