diff --git a/mozilla/modules/plugin/base/src/nsPluginDirServiceProvider.cpp b/mozilla/modules/plugin/base/src/nsPluginDirServiceProvider.cpp index f3638478763..39af2b36688 100644 --- a/mozilla/modules/plugin/base/src/nsPluginDirServiceProvider.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginDirServiceProvider.cpp @@ -59,7 +59,8 @@ typedef struct structVer WORD wBuild; } verBlock; -static void ClearVersion(verBlock *ver) +static void +ClearVersion(verBlock *ver) { ver->wMajor = 0; ver->wMinor = 0; @@ -67,13 +68,15 @@ static void ClearVersion(verBlock *ver) ver->wBuild = 0; } -static BOOL FileExists(LPCSTR szFile) +static BOOL +FileExists(LPCSTR szFile) { return GetFileAttributes(szFile) != 0xFFFFFFFF; } // Get file version information from a file -static BOOL GetFileVersion(LPSTR szFile, verBlock *vbVersion) +static BOOL +GetFileVersion(LPSTR szFile, verBlock *vbVersion) { UINT uLen; UINT dwLen; @@ -84,35 +87,35 @@ static BOOL GetFileVersion(LPSTR szFile, verBlock *vbVersion) VS_FIXEDFILEINFO *lpBuffer2; ClearVersion(vbVersion); - if(FileExists(szFile)) - { + if (FileExists(szFile)) { bRv = TRUE; dwLen = GetFileVersionInfoSize(szFile, &dwHandle); lpData = (LPVOID)malloc(dwLen); uLen = 0; - if(lpData && GetFileVersionInfo(szFile, dwHandle, dwLen, lpData) != 0) - { - if(VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0) - { - lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer; + if (lpData && GetFileVersionInfo(szFile, dwHandle, dwLen, lpData) != 0) { + if (VerQueryValue(lpData, "\\", &lpBuffer, &uLen) != 0) { + lpBuffer2 = (VS_FIXEDFILEINFO *)lpBuffer; + vbVersion->wMajor = HIWORD(lpBuffer2->dwFileVersionMS); vbVersion->wMinor = LOWORD(lpBuffer2->dwFileVersionMS); vbVersion->wRelease = HIWORD(lpBuffer2->dwFileVersionLS); vbVersion->wBuild = LOWORD(lpBuffer2->dwFileVersionLS); } } + free(lpData); - } - else + } else { /* File does not exist */ bRv = FALSE; + } - return(bRv); + return bRv; } // Will deep copy ver2 into ver1 -static void CopyVersion(verBlock *ver1, verBlock *ver2) +static void +CopyVersion(verBlock *ver1, verBlock *ver2) { ver1->wMajor = ver2->wMajor; ver1->wMinor = ver2->wMinor; @@ -120,8 +123,9 @@ static void CopyVersion(verBlock *ver1, verBlock *ver2) ver1->wBuild = ver2->wBuild; } -// convert a string version to a version struct -static void TranslateVersionStr(const char* szVersion, verBlock *vbVersion) +// Convert a string version to a version struct +static void +TranslateVersionStr(const char* szVersion, verBlock *vbVersion) { LPSTR szNum1 = NULL; LPSTR szNum2 = NULL; @@ -130,16 +134,21 @@ static void TranslateVersionStr(const char* szVersion, verBlock *vbVersion) LPSTR szJavaBuild = NULL; char *strVer = nsnull; - if (szVersion) + if (szVersion) { strVer = PL_strdup(szVersion); - if (!strVer) { // out of memory + } + + if (!strVer) { + // Out of memory ClearVersion(vbVersion); return; } + // Java may be using an underscore instead of a dot for the build ID szJavaBuild = strchr(strVer, '_'); - if (szJavaBuild) + if (szJavaBuild) { szJavaBuild[0] = '.'; + } szNum1 = strtok(strVer, "."); szNum2 = strtok(NULL, "."); @@ -155,30 +164,35 @@ static void TranslateVersionStr(const char* szVersion, verBlock *vbVersion) } // Compare two version struct, return zero if the same -static int CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) +static int +CompareVersion(verBlock vbVersionOld, verBlock vbVersionNew) { - if(vbVersionOld.wMajor > vbVersionNew.wMajor) - return(4); - else if(vbVersionOld.wMajor < vbVersionNew.wMajor) - return(-4); + if (vbVersionOld.wMajor > vbVersionNew.wMajor) { + return 4; + } else if (vbVersionOld.wMajor < vbVersionNew.wMajor) { + return -4; + } - if(vbVersionOld.wMinor > vbVersionNew.wMinor) - return(3); - else if(vbVersionOld.wMinor < vbVersionNew.wMinor) - return(-3); + if (vbVersionOld.wMinor > vbVersionNew.wMinor) { + return 3; + } else if (vbVersionOld.wMinor < vbVersionNew.wMinor) { + return -3; + } - if(vbVersionOld.wRelease > vbVersionNew.wRelease) - return(2); - else if(vbVersionOld.wRelease < vbVersionNew.wRelease) - return(-2); + if (vbVersionOld.wRelease > vbVersionNew.wRelease) { + return 2; + } else if (vbVersionOld.wRelease < vbVersionNew.wRelease) { + return -2; + } - if(vbVersionOld.wBuild > vbVersionNew.wBuild) - return(1); - else if(vbVersionOld.wBuild < vbVersionNew.wBuild) - return(-1); + if (vbVersionOld.wBuild > vbVersionNew.wBuild) { + return 1; + } else if (vbVersionOld.wBuild < vbVersionNew.wBuild) { + return -1; + } /* the versions are all the same */ - return(0); + return 0; } #endif @@ -198,14 +212,16 @@ nsPluginDirServiceProvider::~nsPluginDirServiceProvider() // nsPluginDirServiceProvider::nsISupports //***************************************************************************** -NS_IMPL_THREADSAFE_ISUPPORTS1(nsPluginDirServiceProvider, nsIDirectoryServiceProvider) +NS_IMPL_THREADSAFE_ISUPPORTS1(nsPluginDirServiceProvider, + nsIDirectoryServiceProvider) //***************************************************************************** // nsPluginDirServiceProvider::nsIDirectoryServiceProvider //***************************************************************************** NS_IMETHODIMP -nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval) +nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, + nsIFile **_retval) { nsCOMPtr localFile; nsresult rv = NS_ERROR_FAILURE; @@ -214,31 +230,38 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil *_retval = nsnull; *persistant = PR_TRUE; -#if defined(XP_WIN) +#if defined(XP_WIN) nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (!prefs) return rv; + if (!prefs) { + return rv; + } if (nsCRT::strcmp(prop, 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 + // 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) + if (NS_SUCCEEDED(prefs->GetBoolPref(NS_WIN_4DOTX_SCAN_KEY, &bScan4x)) && + !bScan4x) { return rv; + } - // look for the plugin folder that the user has in their Communicator 4x install - HKEY keyloc; + // Look for the plugin folder that the user has in their + // Communicator 4x install + HKEY keyloc; long result; - DWORD type; + DWORD type; char szKey[_MAX_PATH] = "Software\\Netscape\\Netscape Navigator"; char path[_MAX_PATH]; - result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); + result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { char current_version[80]; DWORD length = sizeof(current_version); - result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, (LPBYTE)¤t_version, &length); + result = ::RegQueryValueEx(keyloc, "CurrentVersion", NULL, &type, + (LPBYTE)¤t_version, &length); ::RegCloseKey(keyloc); PL_strcat(szKey, "\\"); @@ -247,19 +270,24 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, szKey, 0, KEY_READ, &keyloc); if (result == ERROR_SUCCESS) { - DWORD pathlen = sizeof(path); + DWORD pathlen = sizeof(path); - result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen); - if (result == ERROR_SUCCESS) - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile)); - ::RegCloseKey(keyloc); + result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, + (LPBYTE)&path, &pathlen); + if (result == ERROR_SUCCESS) { + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); + } + + ::RegCloseKey(keyloc); } } } else if (nsCRT::strcmp(prop, NS_WIN_JRE_SCAN_KEY) == 0) { PRBool isJavaEnabled; nsXPIDLCString strVer; #ifdef OJI - if ((NS_FAILED(prefs->GetBoolPref("security.enable_java", &isJavaEnabled)) || !isJavaEnabled) || + if ((NS_FAILED(prefs->GetBoolPref("security.enable_java", &isJavaEnabled)) + || !isJavaEnabled) || NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) #endif /* OJI */ return NS_ERROR_FAILURE; @@ -271,7 +299,7 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil HKEY keyloc; HKEY entryloc; FILETIME modTime; - DWORD type; + DWORD type; DWORD index = 0; DWORD numChars = _MAX_PATH; DWORD pathlen; @@ -279,41 +307,50 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil ClearVersion(&maxVer); char curKey[_MAX_PATH] = "Software\\JavaSoft\\Java Runtime Environment"; char path[_MAX_PATH]; - char newestPath[_MAX_PATH + 4]; // to prevent buffer overrun when adding \bin + // Add + 4 to prevent buffer overrun when adding \bin + char newestPath[_MAX_PATH + 4]; const char mozPath[_MAX_PATH] = "Software\\mozilla.org\\Mozilla"; char browserJavaVersion[_MAX_PATH]; newestPath[0] = 0; - LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); + LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, + &baseloc); if (ERROR_SUCCESS != result) return NS_ERROR_FAILURE; - // look for BrowserJavaVersion - if (ERROR_SUCCESS != ::RegQueryValueEx(baseloc, "BrowserJavaVersion", NULL, NULL, (LPBYTE)&browserJavaVersion, &numChars)) + // Look for "BrowserJavaVersion" + if (ERROR_SUCCESS != ::RegQueryValueEx(baseloc, "BrowserJavaVersion", NULL, + NULL, (LPBYTE)&browserJavaVersion, + &numChars)) browserJavaVersion[0] = 0; - // we must enumerate through the keys because what if there is more than one version? + // We must enumerate through the keys because what if there is + // more than one version? do { path[0] = 0; numChars = _MAX_PATH; pathlen = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); + result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, + NULL, &modTime); index++; - // skip major.minor as it always points to latest in its family + // Skip major.minor as it always points to latest in its family numChars = 0; for (char *p = curKey; *p; p++) { if (*p == '.') { numChars++; } } - if (numChars < 2) + if (numChars < 2) continue; if (ERROR_SUCCESS == result) { - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { - // we have a sub key - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, &type, (LPBYTE)&path, &pathlen)) { + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, + KEY_QUERY_VALUE, &keyloc)) { + // We have a sub key + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "JavaHome", NULL, + &type, (LPBYTE)&path, + &pathlen)) { verBlock curVer; TranslateVersionStr(curKey, &curVer); if (CompareVersion(curVer, minVer) >= 0) { @@ -322,11 +359,11 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil ::RegCloseKey(keyloc); break; } - + if (CompareVersion(curVer, maxVer) >= 0) { PL_strcpy(newestPath, path); CopyVersion(&maxVer, &curVer); - } + } } } ::RegCloseKey(keyloc); @@ -336,18 +373,25 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil ::RegCloseKey(baseloc); - // if nothing is found, then don't add \bin dir and don't set CurrentVersion for Mozilla + // If nothing is found, then don't add \bin dir and don't set + // CurrentVersion for Mozilla if (newestPath[0] != 0) { - if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, mozPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE|KEY_QUERY_VALUE, NULL, &entryloc, -NULL)) { - if (ERROR_SUCCESS != ::RegQueryValueEx(entryloc, "CurrentVersion", 0, NULL, NULL, NULL)) { - ::RegSetValueEx(entryloc, "CurrentVersion", 0, REG_SZ, (const BYTE*)MOZILLA_VERSION, sizeof(MOZILLA_VERSION)); + if (ERROR_SUCCESS == ::RegCreateKeyEx(HKEY_LOCAL_MACHINE, mozPath, 0, + NULL, REG_OPTION_NON_VOLATILE, + KEY_SET_VALUE|KEY_QUERY_VALUE, + NULL, &entryloc, NULL)) { + if (ERROR_SUCCESS != ::RegQueryValueEx(entryloc, "CurrentVersion", 0, + NULL, NULL, NULL)) { + ::RegSetValueEx(entryloc, "CurrentVersion", 0, REG_SZ, + (const BYTE*)MOZILLA_VERSION, + sizeof(MOZILLA_VERSION)); } - ::RegCloseKey(entryloc); + ::RegCloseKey(entryloc); } PL_strcat(newestPath,"\\bin"); - rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } } else if (nsCRT::strcmp(prop, NS_WIN_QUICKTIME_SCAN_KEY) == 0) { nsXPIDLCString strVer; @@ -356,18 +400,20 @@ NULL)) { verBlock minVer; TranslateVersionStr(strVer.get(), &minVer); - // look for the Quicktime system installation plugins directory - HKEY keyloc; + // Look for the Quicktime system installation plugins directory + HKEY keyloc; long result; - DWORD type; + DWORD type; verBlock qtVer; ClearVersion(&qtVer); char path[_MAX_PATH]; - DWORD pathlen = sizeof(path); + DWORD pathlen = sizeof(path); - // first we need to check the version of Quicktime via checking the EXE's version table + // First we need to check the version of Quicktime via checking + // the EXE's version table if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\QuickTimePlayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { GetFileVersion((char*)path, &qtVer); } ::RegCloseKey(keyloc); @@ -376,12 +422,14 @@ NULL)) { return rv; if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Apple Computer, Inc.\\QuickTime", 0, KEY_READ, &keyloc)) { - DWORD pathlen = sizeof(path); + DWORD pathlen = sizeof(path); - result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type, (LPBYTE)&path, &pathlen); + result = ::RegQueryValueEx(keyloc, "InstallDir", NULL, &type, + (LPBYTE)&path, &pathlen); PL_strcat(path, "\\Plugins"); if (result == ERROR_SUCCESS) - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); ::RegCloseKey(keyloc); } } else if (nsCRT::strcmp(prop, NS_WIN_WMP_SCAN_KEY) == 0) { @@ -391,17 +439,18 @@ NULL)) { verBlock minVer; TranslateVersionStr(strVer.get(), &minVer); - // look for Windows Media Player system installation plugins directory + // Look for Windows Media Player system installation plugins directory HKEY keyloc; - DWORD type; + DWORD type; verBlock wmpVer; ClearVersion(&wmpVer); char path[_MAX_PATH]; - DWORD pathlen = sizeof(path); + DWORD pathlen = sizeof(path); - // first we need to check the version of WMP + // First we need to check the version of WMP if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\wmplayer.exe", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { GetFileVersion((char*)path, &wmpVer); } ::RegCloseKey(keyloc); @@ -409,23 +458,32 @@ NULL)) { if (CompareVersion(wmpVer, minVer) < 0) return rv; - if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "software\\Microsoft\\MediaPlayer", 0, KEY_READ, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory", NULL, &type, (LPBYTE)&path, &pathlen)) - rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile)); + if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, + "software\\Microsoft\\MediaPlayer", 0, + KEY_READ, &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Installation Directory", + NULL, &type, (LPBYTE)&path, + &pathlen)) { + rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, + getter_AddRefs(localFile)); + } + ::RegCloseKey(keyloc); } } else if (nsCRT::strcmp(prop, NS_WIN_ACROBAT_SCAN_KEY) == 0) { nsXPIDLCString strVer; - if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) + if (NS_FAILED(prefs->GetCharPref(prop, getter_Copies(strVer)))) { return NS_ERROR_FAILURE; + } + verBlock minVer; TranslateVersionStr(strVer.get(), &minVer); - // look for Adobe Acrobat system installation plugins directory + // Look for Adobe Acrobat system installation plugins directory HKEY baseloc; HKEY keyloc; FILETIME modTime; - DWORD type; + DWORD type; DWORD index = 0; DWORD numChars = _MAX_PATH; DWORD pathlen; @@ -433,43 +491,57 @@ NULL)) { ClearVersion(&maxVer); char curKey[_MAX_PATH] = "software\\Adobe\\Acrobat Reader"; char path[_MAX_PATH]; - char newestPath[_MAX_PATH + 8]; // to prevent buffer overrun when adding \browser + // Add + 8 to prevent buffer overrun when adding \browser + char newestPath[_MAX_PATH + 8]; newestPath[0] = 0; - if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) { + if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, + KEY_READ, &baseloc)) { PL_strcpy(curKey, "software\\Adobe\\Adobe Acrobat"); - if (ERROR_SUCCESS != ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc)) + if (ERROR_SUCCESS != ::RegOpenKeyEx(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? + // 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 = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, NULL, &modTime); + result = ::RegEnumKeyEx(baseloc, index, curKey, &numChars, NULL, NULL, + NULL, &modTime); index++; + if (ERROR_SUCCESS == result) { verBlock curVer; TranslateVersionStr(curKey, &curVer); PL_strcat(curKey, "\\InstallPath"); - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { - // we have a sub key - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, (LPBYTE)&path, &pathlen)) { - if (CompareVersion(curVer, maxVer) >= 0 && CompareVersion(curVer, minVer) >= 0) { + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, + KEY_QUERY_VALUE, &keyloc)) { + // We have a sub key + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, NULL, NULL, &type, + (LPBYTE)&path, &pathlen)) { + if (CompareVersion(curVer, maxVer) >= 0 && + CompareVersion(curVer, minVer) >= 0) { PL_strcpy(newestPath, path); CopyVersion(&maxVer, &curVer); } } + ::RegCloseKey(keyloc); } } } + ::RegCloseKey(baseloc); + if (newestPath[0] != 0) { PL_strcat(newestPath,"\\browser"); - rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile)); + rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, + getter_AddRefs(localFile)); } } @@ -494,7 +566,8 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator HKEY keyloc; char curKey[_MAX_PATH] = "Software\\MozillaPlugins"; - LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, &baseloc); + LONG result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, curKey, 0, KEY_READ, + &baseloc); if (ERROR_SUCCESS != result) return NS_ERROR_FAILURE; @@ -506,16 +579,20 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator char path[_MAX_PATH]; DWORD pathlen = sizeof(path); - result = ::RegEnumKeyEx(baseloc, index++, curKey, &numChars, NULL, NULL, NULL, &modTime); + result = ::RegEnumKeyEx(baseloc, index++, curKey, &numChars, NULL, NULL, + NULL, &modTime); - if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, &keyloc)) { - if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Path", NULL, &type, (LPBYTE)&path, &pathlen)) { - + if (ERROR_SUCCESS == ::RegOpenKeyEx(baseloc, curKey, 0, KEY_QUERY_VALUE, + &keyloc)) { + if (ERROR_SUCCESS == ::RegQueryValueEx(keyloc, "Path", NULL, &type, + (LPBYTE)&path, &pathlen)) { nsCOMPtr localFile; - if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile))) && + if (NS_SUCCEEDED(NS_NewNativeLocalFile(nsDependentCString(path), + PR_TRUE, + getter_AddRefs(localFile))) && localFile) { - - // Some vendors use a path directly to the DLL so chop off the filename + // Some vendors use a path directly to the DLL so chop off + // the filename PRBool isDir = PR_FALSE; if (NS_SUCCEEDED(localFile->IsDirectory(&isDir)) && !isDir) { nsCOMPtr temp; @@ -524,8 +601,8 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator localFile = do_QueryInterface(temp); } - // now we check to make sure it's actually on disk and - // to see if we already have this directory in the array + // Now we check to make sure it's actually on disk and + // To see if we already have this directory in the array PRBool isFileThere = PR_FALSE; PRBool isDupEntry = PR_FALSE; if (NS_SUCCEEDED(localFile->Exists(&isFileThere)) && isFileThere) { @@ -550,7 +627,7 @@ nsPluginDirServiceProvider::GetPLIDDirectories(nsISimpleEnumerator **aEnumerator } while (ERROR_SUCCESS == result); ::RegCloseKey(baseloc); - + return NS_NewArrayEnumerator(aEnumerator, dirs); }