/* function to build a linked list of GRE supersede versions */ HRESULT GetGreSupersedeVersionList(siC *siCObject, grever **aGreSupersedeList) { grever *gverTmp = NULL; grever *gverTail = NULL; char key[MAX_BUF_TINY]; char versionString[MAX_BUF_TINY]; DWORD index; if(*aGreSupersedeList) /* list already built, just return */ return(WIZ_OK); index = 0; wsprintf(key, "SupersedeVersion%d", index); GetConfigIniProfileString(siCObject->szReferenceName, key, "", versionString, sizeof(versionString)); while(*versionString != '\0') { gverTmp = CreateGVerNode(); if(!gverTmp) // error has already been displayed. exit(WIZ_OUT_OF_MEMORY); TranslateVersionStr(versionString, &gverTmp->version); if(*aGreSupersedeList == NULL) { /* brand new list */ *aGreSupersedeList = gverTmp; gverTail = *aGreSupersedeList; } else if(gverTail) { /* append the new node to the end of the list */ gverTail->next = gverTmp; gverTail = gverTail->next; } wsprintf(key, "SupersedeVersion%d", ++index); GetConfigIniProfileString(siCObject->szReferenceName, key, "", versionString, sizeof(versionString)); } return(WIZ_OK); }
NS_IMETHODIMP nsPluginDirServiceProvider::GetFile(const char *charProp, PRBool *persistant, nsIFile **_retval) { nsCOMPtr<nsILocalFile> localFile; nsresult rv = NS_ERROR_FAILURE; NS_ENSURE_ARG(charProp); *_retval = nsnull; *persistant = PR_FALSE; nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (!prefs) return NS_ERROR_FAILURE; if (nsCRT::strcmp(charProp, NS_WIN_4DOTX_SCAN_KEY) == 0) { // Check our prefs to see if scanning the 4.x folder has been // explictly overriden failure to get the pref is okay, we'll do // what we've been doing -- a filtered scan PRBool bScan4x; if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) && !bScan4x) { return NS_ERROR_FAILURE; } // Look for the plugin folder that the user has in their // Communicator 4x install HKEY keyloc; long result; DWORD type; WCHAR szKey[_MAX_PATH] = L"Software\\Netscape\\Netscape Navigator"; WCHAR path[_MAX_PATH]; result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { WCHAR current_version[80]; DWORD length = NS_ARRAY_LENGTH(current_version); result = ::RegQueryValueExW(keyloc, L"CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length); ::RegCloseKey(keyloc); wcscat(szKey, L"\\"); wcscat(szKey, current_version); wcscat(szKey, L"\\Main"); result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { DWORD pathlen = NS_ARRAY_LENGTH(path); result = ::RegQueryValueExW(keyloc, L"Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen); if (result == ERROR_SUCCESS) { rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } } } else if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for the Java OJI plugin via the JRE install path HKEY baseloc; HKEY keyloc; HKEY entryloc; FILETIME modTime; DWORD type; DWORD index = 0; DWORD numChars = _MAX_PATH; DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); WCHAR curKey[_MAX_PATH] = L"Software\\JavaSoft\\Java Runtime Environment"; WCHAR path[_MAX_PATH]; // Add + 15 to prevent buffer overrun when adding \bin (+ optionally // \new_plugin) #define JAVA_PATH_SIZE _MAX_PATH + 15 WCHAR newestPath[JAVA_PATH_SIZE]; const WCHAR mozPath[_MAX_PATH] = L"Software\\mozilla.org\\Mozilla"; WCHAR browserJavaVersion[_MAX_PATH]; newestPath[0] = 0; LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); if (ERROR_SUCCESS != result) return NS_ERROR_FAILURE; // Look for "BrowserJavaVersion" if (ERROR_SUCCESS != ::RegQueryValueExW(baseloc, L"BrowserJavaVersion", NULL, NULL, (LPBYTE)&browserJavaVersion, &numChars)) browserJavaVersion[0] = 0; // We must enumerate through the keys because what if there is // more than one version? do { path[0] = 0; numChars = _MAX_PATH; pathlen = NS_ARRAY_LENGTH(path); result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; // Skip major.minor as it always points to latest in its family numChars = 0; for (WCHAR *p = curKey; *p; p++) { if (*p == '.') { numChars++; } } if (numChars < 2) continue; if (ERROR_SUCCESS == result) { if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) { verBlock curVer; TranslateVersionStr(curKey, &curVer); if (CompareVersion(curVer, minVer) >= 0) { if (!wcsncmp(browserJavaVersion, curKey, _MAX_PATH)) { wcscpy(newestPath, path); ::RegCloseKey(keyloc); break; } if (CompareVersion(curVer, maxVer) >= 0) { wcscpy(newestPath, path); CopyVersion(&maxVer, &curVer); } } } ::RegCloseKey(keyloc); } } } while (ERROR_SUCCESS == result); ::RegCloseKey(baseloc); static const WCHAR kMozillaVersion[] = NS_L(MOZILLA_VERSION); // If nothing is found, then don't add \bin dir and don't set // CurrentVersion for Mozilla if (newestPath[0] != 0) { if (ERROR_SUCCESS == ::RegCreateKeyExW(HKEY_LOCAL_MACHINE, mozPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE|KEY_QUERY_VALUE, NULL, &entryloc, NULL)) { if (ERROR_SUCCESS != ::RegQueryValueExW(entryloc, L"CurrentVersion", 0, NULL, NULL, NULL)) { ::RegSetValueExW(entryloc, L"CurrentVersion", 0, REG_SZ, (const BYTE*) kMozillaVersion, NS_ARRAY_LENGTH(kMozillaVersion)); } ::RegCloseKey(entryloc); } wcscat(newestPath, L"\\bin"); // See whether the "new_plugin" directory exists WCHAR tmpPath[JAVA_PATH_SIZE]; nsCOMPtr<nsILocalFile> tmpFile; wcscpy(tmpPath, newestPath); wcscat(tmpPath, L"\\new_plugin"); rv = NS_NewLocalFile(nsDependentString(tmpPath), PR_TRUE, getter_AddRefs(tmpFile)); if (NS_SUCCEEDED(rv) && tmpFile) { PRBool exists = PR_FALSE; PRBool isDir = PR_FALSE; if (NS_SUCCEEDED(tmpFile->Exists(&exists)) && exists && NS_SUCCEEDED(tmpFile->IsDirectory(&isDir)) && isDir) { // Assume we're supposed to use this as the search // directory for the Java Plug-In instead of the normal // one wcscpy(newestPath, tmpPath); } } rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, getter_AddRefs(localFile)); } } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for the Quicktime system installation plugins directory HKEY keyloc; long result; DWORD type; verBlock qtVer; ClearVersion(&qtVer); WCHAR path[_MAX_PATH]; DWORD pathlen = NS_ARRAY_LENGTH(path); // First we need to check the version of Quicktime via checking // the EXE's version table if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { GetFileVersion(path, &qtVer); } ::RegCloseKey(keyloc); } if (CompareVersion(qtVer, minVer) < 0) return rv; if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { DWORD pathlen = NS_ARRAY_LENGTH(path); result = ::RegQueryValueExW(keyloc, L"InstallDir", NULL, &type, (LPBYTE)&path, &pathlen); wcscat(path, L"\\Plugins"); if (result == ERROR_SUCCESS) rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, getter_AddRefs(localFile)); ::RegCloseKey(keyloc); } } else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for Windows Media Player system installation plugins directory HKEY keyloc; DWORD type; verBlock wmpVer; ClearVersion(&wmpVer); WCHAR path[_MAX_PATH]; DWORD pathlen = NS_ARRAY_LENGTH(path); // First we need to check the version of WMP if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { GetFileVersion(path, &wmpVer); } ::RegCloseKey(keyloc); } if (CompareVersion(wmpVer, minVer) < 0) return rv; if (ERROR_SUCCESS == ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"software\\Microsoft\\MediaPlayer", 0, KEY_READ, &keyloc)) { if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, L"Installation Directory", NULL, &type, (LPBYTE)&path, &pathlen)) { rv = NS_NewLocalFile(nsDependentString(path), PR_TRUE, getter_AddRefs(localFile)); } ::RegCloseKey(keyloc); } } else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) { return NS_ERROR_FAILURE; } verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for Adobe Acrobat system installation plugins directory HKEY baseloc; HKEY keyloc; FILETIME modTime; DWORD type; DWORD index = 0; DWORD numChars = _MAX_PATH; DWORD pathlen; verBlock maxVer; ClearVersion(&maxVer); WCHAR curKey[_MAX_PATH] = L"software\\Adobe\\Acrobat Reader"; WCHAR path[_MAX_PATH]; // Add + 8 to prevent buffer overrun when adding \browser WCHAR newestPath[_MAX_PATH + 8]; newestPath[0] = 0; if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { wcscpy(curKey, L"software\\Adobe\\Adobe Acrobat"); if (ERROR_SUCCESS != ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { return NS_ERROR_FAILURE; } } // We must enumerate through the keys because what if there is // more than one version? LONG result = ERROR_SUCCESS; while (ERROR_SUCCESS == result) { path[0] = 0; numChars = _MAX_PATH; pathlen = NS_ARRAY_LENGTH(path); result = ::RegEnumKeyExW(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); index++; if (ERROR_SUCCESS == result) { verBlock curVer; TranslateVersionStr(curKey, &curVer); wcscat(curKey, L"\\InstallPath"); if (ERROR_SUCCESS == ::RegOpenKeyExW(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { // We have a sub key if (ERROR_SUCCESS == ::RegQueryValueExW(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { if (CompareVersion(curVer, maxVer) >= 0 && CompareVersion(curVer, minVer) >= 0) { wcscpy(newestPath, path); CopyVersion(&maxVer, &curVer); } } ::RegCloseKey(keyloc); } } } ::RegCloseKey(baseloc); if (newestPath[0] != 0) { wcscat(newestPath, L"\\browser"); rv = NS_NewLocalFile(nsDependentString(newestPath), PR_TRUE, getter_AddRefs(localFile)); } } if (localFile && NS_SUCCEEDED(rv)) return CallQueryInterface(localFile, _retval); return rv; }
NS_IMETHODIMP nsPluginDirServiceProvider::GetFile(const char *charProp, PRBool *persistant, nsIFile **_retval) { nsCOMPtr<nsILocalFile> localFile; nsresult rv = NS_ERROR_FAILURE; NS_ENSURE_ARG(charProp); *_retval = nsnull; *persistant = PR_FALSE; nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (!prefs) return NS_ERROR_FAILURE; nsCOMPtr<nsIWindowsRegKey> regKey = do_CreateInstance("@mozilla.org/windows-registry-key;1"); NS_ENSURE_TRUE(regKey, NS_ERROR_FAILURE); if (nsCRT::strcmp(charProp, NS_WIN_4DOTX_SCAN_KEY) == 0) { // Check our prefs to see if scanning the 4.x folder has been // explictly overriden failure to get the pref is okay, we'll do // what we've been doing -- a filtered scan PRBool bScan4x; if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) && !bScan4x) { return NS_ERROR_FAILURE; } // Look for the plugin folder that the user has in their // Communicator 4x install rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("Software\\Netscape\\Netscape Navigator"), nsIWindowsRegKey::ACCESS_READ); if (NS_SUCCEEDED(rv)) { nsAutoString currentVersion; rv = regKey->ReadStringValue(NS_LITERAL_STRING("CurrentVersion"), currentVersion); if (NS_SUCCEEDED(rv)) { nsAutoString childName = currentVersion; childName.Append(NS_LITERAL_STRING("\\Main")); nsCOMPtr<nsIWindowsRegKey> childKey; rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_READ, getter_AddRefs(childKey)); if (NS_SUCCEEDED(rv) && childKey) { nsAutoString pluginsDirectory; rv = childKey->ReadStringValue(NS_LITERAL_STRING("Plugins Directory"), pluginsDirectory); if (NS_SUCCEEDED(rv)) { rv = NS_NewLocalFile(pluginsDirectory, PR_TRUE, getter_AddRefs(localFile)); } } } } } else if (nsCRT::strcmp(charProp, NS_WIN_JRE_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("Software\\JavaSoft\\Java Runtime Environment"), nsIWindowsRegKey::ACCESS_READ); NS_ENSURE_SUCCESS(rv, rv); verBlock maxVer; ClearVersion(&maxVer); nsAutoString newestPath; nsAutoString browserJavaVersion; regKey->ReadStringValue(NS_LITERAL_STRING("BrowserJavaVersion"), browserJavaVersion); PRUint32 childCount = 0; regKey->GetChildCount(&childCount); // We must enumerate through the keys because what if there is // more than one version? for (PRUint32 index = 0; index < childCount; ++index) { nsAutoString childName; rv = regKey->GetChildName(index, childName); if (NS_SUCCEEDED(rv)) { // Skip major.minor as it always points to latest in its family PRUint32 numChars = 0; PRInt32 offset = 0; while ((offset = childName.FindChar(L'.', offset + 1)) >= 0) { ++numChars; } if (numChars < 2) continue; nsCOMPtr<nsIWindowsRegKey> childKey; rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE, getter_AddRefs(childKey)); if (NS_SUCCEEDED(rv) && childKey) { nsAutoString path; rv = childKey->ReadStringValue(NS_LITERAL_STRING("JavaHome"), path); if (NS_SUCCEEDED(rv)) { verBlock curVer; TranslateVersionStr(PromiseFlatString(childName).get(), &curVer); if (CompareVersion(curVer, minVer) >= 0) { if (browserJavaVersion == childName) { newestPath = path; break; } if (CompareVersion(curVer, maxVer) >= 0) { newestPath = path; CopyVersion(&maxVer, &curVer); } } } } } } if (newestPath.IsEmpty()) { return NS_ERROR_FAILURE; } // We require the newer NPAPI Java plugin. newestPath += NS_LITERAL_STRING("\\bin\\new_plugin"); rv = NS_NewLocalFile(newestPath, PR_TRUE, getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { nsCOMPtr<nsIWindowsRegKey> newKey = do_CreateInstance("@mozilla.org/windows-registry-key;1"); NS_ENSURE_TRUE(newKey, NS_ERROR_FAILURE); rv = newKey->Create(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("Software\\mozilla.org\\Mozilla"), nsIWindowsRegKey::ACCESS_QUERY_VALUE | nsIWindowsRegKey::ACCESS_SET_VALUE); if (NS_SUCCEEDED(rv)) { PRBool currentVersionExists = PR_FALSE; newKey->HasValue(NS_LITERAL_STRING("CurrentVersion"), ¤tVersionExists); if (!currentVersionExists) { newKey->WriteStringValue(NS_LITERAL_STRING("CurrentVersion"), NS_LITERAL_STRING(MOZILLA_VERSION)); } } } } else if (nsCRT::strcmp(charProp, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for the Quicktime system installation plugins directory verBlock qtVer; ClearVersion(&qtVer); // First we need to check the version of Quicktime via checking // the EXE's version table rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe"), nsIWindowsRegKey::ACCESS_READ); if (NS_SUCCEEDED(rv)) { nsAutoString path; rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path); if (NS_SUCCEEDED(rv)) { GetFileVersion(PromiseFlatString(path).get(), &qtVer); } regKey->Close(); } if (CompareVersion(qtVer, minVer) < 0) return rv; rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Apple Computer, Inc.\\QuickTime"), nsIWindowsRegKey::ACCESS_READ); if (NS_SUCCEEDED(rv)) { nsAutoString path; rv = regKey->ReadStringValue(NS_LITERAL_STRING("InstallDir"), path); if (NS_SUCCEEDED(rv)) { path += NS_LITERAL_STRING("\\Plugins"); rv = NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(localFile)); } } } else if (nsCRT::strcmp(charProp, NS_WIN_WMP_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) return NS_ERROR_FAILURE; verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for Windows Media Player system installation plugins directory verBlock wmpVer; ClearVersion(&wmpVer); // First we need to check the version of WMP rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe"), nsIWindowsRegKey::ACCESS_READ); if (NS_SUCCEEDED(rv)) { nsAutoString path; rv = regKey->ReadStringValue(NS_LITERAL_STRING(""), path); if (NS_SUCCEEDED(rv)) { GetFileVersion(PromiseFlatString(path).get(), &wmpVer); } regKey->Close(); } if (CompareVersion(wmpVer, minVer) < 0) return rv; rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Microsoft\\MediaPlayer"), nsIWindowsRegKey::ACCESS_READ); if (NS_SUCCEEDED(rv)) { nsAutoString path; rv = regKey->ReadStringValue(NS_LITERAL_STRING("Installation Directory"), path); if (NS_SUCCEEDED(rv)) { rv = NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(localFile)); } } } else if (nsCRT::strcmp(charProp, NS_WIN_ACROBAT_SCAN_KEY) == 0) { nsXPIDLCString strVer; if (NS_FAILED(prefs->GetCharPref(charProp, getter_Copies(strVer)))) { return NS_ERROR_FAILURE; } verBlock minVer; TranslateVersionStr(NS_ConvertASCIItoUTF16(strVer).get(), &minVer); // Look for Adobe Acrobat system installation plugins directory verBlock maxVer; ClearVersion(&maxVer); nsAutoString newestPath; rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Adobe\\Acrobat Reader"), nsIWindowsRegKey::ACCESS_READ); if (NS_FAILED(rv)) { rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, NS_LITERAL_STRING("software\\Adobe\\Adobe Acrobat"), nsIWindowsRegKey::ACCESS_READ); if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } } // We must enumerate through the keys because what if there is // more than one version? PRUint32 childCount = 0; regKey->GetChildCount(&childCount); for (PRUint32 index = 0; index < childCount; ++index) { nsAutoString childName; rv = regKey->GetChildName(index, childName); if (NS_SUCCEEDED(rv)) { verBlock curVer; TranslateVersionStr(PromiseFlatString(childName).get(), &curVer); childName += NS_LITERAL_STRING("\\InstallPath"); nsCOMPtr<nsIWindowsRegKey> childKey; rv = regKey->OpenChild(childName, nsIWindowsRegKey::ACCESS_QUERY_VALUE, getter_AddRefs(childKey)); if (NS_SUCCEEDED(rv)) { // We have a sub key nsAutoString path; rv = childKey->ReadStringValue(NS_LITERAL_STRING(""), path); if (NS_SUCCEEDED(rv)) { if (CompareVersion(curVer, maxVer) >= 0 && CompareVersion(curVer, minVer) >= 0) { newestPath = path; CopyVersion(&maxVer, &curVer); } } } } } if (!newestPath.IsEmpty()) { newestPath += NS_LITERAL_STRING("\\browser"); rv = NS_NewLocalFile(newestPath, PR_TRUE, getter_AddRefs(localFile)); } } if (localFile && NS_SUCCEEDED(rv)) return CallQueryInterface(localFile, _retval); return rv; }
BOOL ResolveSupersede(siC *siCObject, greInfo *aGre) { DWORD dwIndex; char szFilePath[MAX_BUF]; char szSupersedeFile[MAX_BUF]; char szSupersedeVersion[MAX_BUF]; char szType[MAX_BUF_TINY]; char szKey[MAX_BUF_TINY]; verBlock vbVersionNew; verBlock vbFileVersion; siCObject->bSupersede = FALSE; if(siCObject->dwAttributes & SIC_SUPERSEDE) { dwIndex = 0; GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeType", "", szType, sizeof(szType)); if(*szType !='\0') { if(lstrcmpi(szType, "File Exists") == 0) { wsprintf(szKey, "SupersedeFile%d", dwIndex); GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile)); while(*szSupersedeFile != '\0') { DecryptString(szFilePath, szSupersedeFile); if(FileExists(szFilePath)) { wsprintf(szKey, "SupersedeMinVersion%d",dwIndex); GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeVersion, sizeof(szSupersedeVersion)); if(*szSupersedeVersion != '\0') { if(GetFileVersion(szFilePath,&vbFileVersion)) { /* If we can get the version, and it is greater than or equal to the SupersedeVersion * set supersede. If we cannot get the version, do not supersede the file. */ TranslateVersionStr(szSupersedeVersion, &vbVersionNew); if(CompareVersion(vbFileVersion,vbVersionNew) >= 0) { siCObject->bSupersede = TRUE; break; /* Found at least one file, so break out of while loop */ } } } else { /* The file exists, and there's no version to check. set Supersede */ siCObject->bSupersede = TRUE; break; /* Found at least one file, so break out of while loop */ } } wsprintf(szKey, "SupersedeFile%d", ++dwIndex); GetConfigIniProfileString(siCObject->szReferenceName, szKey, "", szSupersedeFile, sizeof(szSupersedeFile)); } } else if(lstrcmpi(szType, "GRE") == 0) { /* save the GRE component */ aGre->siCGreComponent = siCObject; /* If -fgre is passed in, and the current product to install is !GRE, * and the current component is 'Component GRE' then select and * disable it to force it to be installed regardless of supersede * rules. * * If the product is GRE, then it won't have a 'Component GRE', but * rather a 'Component XPCOM', in which case it will always get * installed */ if((gbForceInstallGre) && (lstrcmpi(sgProduct.szProductNameInternal, "GRE") != 0)) { siCObject->dwAttributes |= SIC_SELECTED; siCObject->dwAttributes |= SIC_DISABLED; } else ResolveSupersedeGre(siCObject, aGre); } } if(siCObject->bSupersede) { siCObject->dwAttributes &= ~SIC_SELECTED; siCObject->dwAttributes |= SIC_DISABLED; siCObject->dwAttributes |= SIC_INVISIBLE; } else /* Make sure to unset the DISABLED bit. If the Setup Type is other than * Custom, then we don't care if it's DISABLED or not because this flag * is only used in the Custom dialogs. * * If the Setup Type is Custom and this component is DISABLED by default * via the config.ini, it's default value will be restored in the * SiCNodeSetItemsSelected() function that called ResolveSupersede(). */ siCObject->dwAttributes &= ~SIC_DISABLED; } return(siCObject->bSupersede); }
void ResolveSupersedeGre(siC *siCObject, greInfo *aGre) { grever *greSupersedeListTmp = NULL; grever *greInstalledListTmp = NULL; char versionStr[MAX_BUF_TINY]; siC *siCTmp = NULL; BOOL foundVersionWithinRange = FALSE; BOOL minVerRead = FALSE; BOOL maxVerRead = FALSE; BOOL stillInRange = FALSE; if(GetGreSupersedeVersionList(siCObject, &aGre->greSupersedeList)) return; if(GetGreInstalledVersionList(siCObject, &aGre->greInstalledList)) return; if(!aGre->greSupersedeList || !aGre->greInstalledList) // nothing to compare, return return; GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeMinVersion", "", versionStr, sizeof(versionStr)); if(*versionStr != '\0') { TranslateVersionStr(versionStr, &aGre->minVersion); minVerRead = TRUE; } GetConfigIniProfileString(siCObject->szReferenceName, "SupersedeMaxVersion", "", versionStr, sizeof(versionStr)); if(*versionStr != '\0') { TranslateVersionStr(versionStr, &aGre->maxVersion); maxVerRead = TRUE; } // do the version comparison here. greInstalledListTmp = aGre->greInstalledList; while(greInstalledListTmp) { greSupersedeListTmp = aGre->greSupersedeList; while(greSupersedeListTmp) { if(CompareVersion(greInstalledListTmp->version, greSupersedeListTmp->version) == 0) { SaveGreInfo(greInstalledListTmp, aGre); siCObject->bSupersede = TRUE; aGre->siCGreComponent = siCObject; break; } else if(!foundVersionWithinRange && (minVerRead || maxVerRead)) { stillInRange = TRUE; if(minVerRead) stillInRange = CompareVersion(greInstalledListTmp->version, aGre->minVersion) >= 0; if(stillInRange && maxVerRead) stillInRange = CompareVersion(greInstalledListTmp->version, aGre->maxVersion) <= 0; if(stillInRange) { // Find the first version within the range. SaveGreInfo(greInstalledListTmp, aGre); foundVersionWithinRange = TRUE; } } greSupersedeListTmp = greSupersedeListTmp->next; } if(siCObject->bSupersede) break; greInstalledListTmp = greInstalledListTmp->next; } if(!siCObject->bSupersede && foundVersionWithinRange) siCObject->bSupersede = TRUE; if(siCObject->bSupersede) { siCObject->dwAttributes &= ~SIC_SELECTED; siCObject->dwAttributes |= SIC_DISABLED; siCObject->dwAttributes |= SIC_INVISIBLE; } else /* Make sure to unset the DISABLED bit. If the Setup Type is other than * Custom, then we don't care if it's DISABLED or not because this flag * is only used in the Custom dialogs. * * If the Setup Type is Custom and this component is DISABLED by default * via the config.ini, it's default value will be restored in the * SiCNodeSetItemsSelected() function that called ResolveSupersede(). */ siCObject->dwAttributes &= ~SIC_DISABLED; }