From 56f0cdee15c74911d2652ed9085d1f015ced257e Mon Sep 17 00:00:00 2001 From: "av%netscape.com" Date: Fri, 28 Jan 2000 00:49:09 +0000 Subject: [PATCH] Introducing flags to specify plugins dir location. Not used yet. Getting ready for 21938. --- modules/plugin/base/src/nsPluginsDir.h | 8 ++- modules/plugin/base/src/nsPluginsDirMac.cpp | 2 +- modules/plugin/base/src/nsPluginsDirOS2.cpp | 2 +- modules/plugin/base/src/nsPluginsDirUNIX.cpp | 2 +- modules/plugin/base/src/nsPluginsDirWin.cpp | 70 +++++++++----------- modules/plugin/nglsrc/nsPluginsDir.h | 8 ++- modules/plugin/nglsrc/nsPluginsDirMac.cpp | 2 +- modules/plugin/nglsrc/nsPluginsDirOS2.cpp | 2 +- modules/plugin/nglsrc/nsPluginsDirUNIX.cpp | 2 +- modules/plugin/nglsrc/nsPluginsDirWin.cpp | 70 +++++++++----------- 10 files changed, 84 insertions(+), 84 deletions(-) diff --git a/modules/plugin/base/src/nsPluginsDir.h b/modules/plugin/base/src/nsPluginsDir.h index 01345f4f9d23..2565e2548b33 100644 --- a/modules/plugin/base/src/nsPluginsDir.h +++ b/modules/plugin/base/src/nsPluginsDir.h @@ -32,12 +32,18 @@ * scan the plugins directory. An nsPluginFileSpec can be constructed from the * nsFileSpec returned by the iterator. */ + +/* Where to seek for plugins dir */ +#define PLUGINS_DIR_LOCATION_AUTO 0 +#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1 +#define PLUGINS_DIR_LOCATION_4DOTX 2 + class nsPluginsDir : public nsFileSpec { public: /** * Locates the plugins directory in a platform-dependent manner. */ - nsPluginsDir(); + nsPluginsDir(PRUint16 location = PLUGINS_DIR_LOCATION_AUTO); virtual ~nsPluginsDir(); /** diff --git a/modules/plugin/base/src/nsPluginsDirMac.cpp b/modules/plugin/base/src/nsPluginsDirMac.cpp index da29e889b097..74e30a6e4322 100644 --- a/modules/plugin/base/src/nsPluginsDirMac.cpp +++ b/modules/plugin/base/src/nsPluginsDirMac.cpp @@ -51,7 +51,7 @@ static nsresult getApplicationSpec(FSSpec& outAppSpec) return (result == noErr ? NS_OK : NS_ERROR_FAILURE); } -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { #if 0 // Use the folder manager to get location of Extensions folder, and diff --git a/modules/plugin/base/src/nsPluginsDirOS2.cpp b/modules/plugin/base/src/nsPluginsDirOS2.cpp index 4b427d357570..a86a80cce9cb 100644 --- a/modules/plugin/base/src/nsPluginsDirOS2.cpp +++ b/modules/plugin/base/src/nsPluginsDirOS2.cpp @@ -107,7 +107,7 @@ static char **BuildStringArray( char *aFlat, PRUint32 &aSize) // nsPluginsDir class -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { // XXX This isn't right for the embedded case, but it's as close // as we can do right now. diff --git a/modules/plugin/base/src/nsPluginsDirUNIX.cpp b/modules/plugin/base/src/nsPluginsDirUNIX.cpp index 5c4fa8b2761c..f7dcefc5b877 100644 --- a/modules/plugin/base/src/nsPluginsDirUNIX.cpp +++ b/modules/plugin/base/src/nsPluginsDirUNIX.cpp @@ -69,7 +69,7 @@ static PRUint32 CalculateVariantCount(char* mimeTypes) /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { // this is somewhat lacking, in that it doesn't fall back to any other directories. // then again, I'm not sure we should be falling back at all. plugins have been (and probably diff --git a/modules/plugin/base/src/nsPluginsDirWin.cpp b/modules/plugin/base/src/nsPluginsDirWin.cpp index ef067fb2818c..4ce8fdb3630c 100644 --- a/modules/plugin/base/src/nsPluginsDirWin.cpp +++ b/modules/plugin/base/src/nsPluginsDirWin.cpp @@ -119,45 +119,46 @@ static char** MakeStringArray(PRUint32 variants, char* data) /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { - HKEY keyloc; - DWORD pathlen, type; - long result; + DWORD pathlen; char path[2000]; const char* allocPath; - //PRDir *dir = nsnull; - // first, let's look for a plugin folder that exists in the - // same directory as our executable - if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) - { - pathlen = PL_strlen(path) - 1; - - while (pathlen > 0) + if((location == PLUGINS_DIR_LOCATION_AUTO) || (location == PLUGINS_DIR_LOCATION_MOZ_LOCAL)) + { + // look for a plugin folder that exists in the same directory as our executable + if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) { - if (path[pathlen] == '\\') - break; + pathlen = PL_strlen(path) - 1; - pathlen--; - } + while (pathlen > 0) + { + if (path[pathlen] == '\\') + break; - if (pathlen > 0) - { - PL_strcpy(&path[pathlen + 1], "plugins"); - //dir = PR_OpenDir(path); + pathlen--; + } - allocPath = path;//PL_strdup(path); - *(nsFileSpec*)this = allocPath; + if (pathlen > 0) + { + PL_strcpy(&path[pathlen + 1], "plugins"); + + allocPath = path; + *(nsFileSpec*)this = allocPath; + } } - } + } + + if(((location == PLUGINS_DIR_LOCATION_AUTO) && !Exists()) || + (location == PLUGINS_DIR_LOCATION_4DOTX)) + { + // look for the plugin folder that the user has in their Communicator 4x install + HKEY keyloc; + long result; + DWORD type; - // if we didn't find it, let's look for the plugin folder - // that the user has in their Communicator 4x install - if(!Exists()) - { path[0] = 0; - //PL_strfree(allocPath); result = ::RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Netscape\\Netscape Navigator\\Main", @@ -178,10 +179,9 @@ nsPluginsDir::nsPluginsDir() ::RegCloseKey(keyloc); } - //dir = PR_OpenDir(path); allocPath = PL_strdup(path); *(nsFileSpec*)this = allocPath; - } + } #ifdef NS_DEBUG if (path[0] != 0) @@ -285,12 +285,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) DWORD zerome, versionsize; char* verbuf = nsnull; const char* path = this->GetCString(); -/* - const char* fileName; - fileName = PL_strrchr(path, '\\'); - if(fileName) - ++fileName; -*/ + versionsize = ::GetFileVersionInfoSize((char*)path, &zerome); if (versionsize > 0) verbuf = (char *)PR_Malloc(versionsize); @@ -310,8 +305,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType); info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription); info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions); - //info.fFileName = PL_strdup(fileName); - info.fFileName = PL_strdup(path); // don't we need the full path too? + info.fFileName = PL_strdup(path); } else res = NS_ERROR_FAILURE; diff --git a/modules/plugin/nglsrc/nsPluginsDir.h b/modules/plugin/nglsrc/nsPluginsDir.h index 01345f4f9d23..2565e2548b33 100644 --- a/modules/plugin/nglsrc/nsPluginsDir.h +++ b/modules/plugin/nglsrc/nsPluginsDir.h @@ -32,12 +32,18 @@ * scan the plugins directory. An nsPluginFileSpec can be constructed from the * nsFileSpec returned by the iterator. */ + +/* Where to seek for plugins dir */ +#define PLUGINS_DIR_LOCATION_AUTO 0 +#define PLUGINS_DIR_LOCATION_MOZ_LOCAL 1 +#define PLUGINS_DIR_LOCATION_4DOTX 2 + class nsPluginsDir : public nsFileSpec { public: /** * Locates the plugins directory in a platform-dependent manner. */ - nsPluginsDir(); + nsPluginsDir(PRUint16 location = PLUGINS_DIR_LOCATION_AUTO); virtual ~nsPluginsDir(); /** diff --git a/modules/plugin/nglsrc/nsPluginsDirMac.cpp b/modules/plugin/nglsrc/nsPluginsDirMac.cpp index da29e889b097..74e30a6e4322 100644 --- a/modules/plugin/nglsrc/nsPluginsDirMac.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirMac.cpp @@ -51,7 +51,7 @@ static nsresult getApplicationSpec(FSSpec& outAppSpec) return (result == noErr ? NS_OK : NS_ERROR_FAILURE); } -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { #if 0 // Use the folder manager to get location of Extensions folder, and diff --git a/modules/plugin/nglsrc/nsPluginsDirOS2.cpp b/modules/plugin/nglsrc/nsPluginsDirOS2.cpp index 4b427d357570..a86a80cce9cb 100644 --- a/modules/plugin/nglsrc/nsPluginsDirOS2.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirOS2.cpp @@ -107,7 +107,7 @@ static char **BuildStringArray( char *aFlat, PRUint32 &aSize) // nsPluginsDir class -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { // XXX This isn't right for the embedded case, but it's as close // as we can do right now. diff --git a/modules/plugin/nglsrc/nsPluginsDirUNIX.cpp b/modules/plugin/nglsrc/nsPluginsDirUNIX.cpp index 5c4fa8b2761c..f7dcefc5b877 100644 --- a/modules/plugin/nglsrc/nsPluginsDirUNIX.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirUNIX.cpp @@ -69,7 +69,7 @@ static PRUint32 CalculateVariantCount(char* mimeTypes) /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { // this is somewhat lacking, in that it doesn't fall back to any other directories. // then again, I'm not sure we should be falling back at all. plugins have been (and probably diff --git a/modules/plugin/nglsrc/nsPluginsDirWin.cpp b/modules/plugin/nglsrc/nsPluginsDirWin.cpp index ef067fb2818c..4ce8fdb3630c 100644 --- a/modules/plugin/nglsrc/nsPluginsDirWin.cpp +++ b/modules/plugin/nglsrc/nsPluginsDirWin.cpp @@ -119,45 +119,46 @@ static char** MakeStringArray(PRUint32 variants, char* data) /* nsPluginsDir implementation */ -nsPluginsDir::nsPluginsDir() +nsPluginsDir::nsPluginsDir(PRUint16 location) { - HKEY keyloc; - DWORD pathlen, type; - long result; + DWORD pathlen; char path[2000]; const char* allocPath; - //PRDir *dir = nsnull; - // first, let's look for a plugin folder that exists in the - // same directory as our executable - if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) - { - pathlen = PL_strlen(path) - 1; - - while (pathlen > 0) + if((location == PLUGINS_DIR_LOCATION_AUTO) || (location == PLUGINS_DIR_LOCATION_MOZ_LOCAL)) + { + // look for a plugin folder that exists in the same directory as our executable + if (::GetModuleFileName(NULL, path, sizeof(path)) > 0) { - if (path[pathlen] == '\\') - break; + pathlen = PL_strlen(path) - 1; - pathlen--; - } + while (pathlen > 0) + { + if (path[pathlen] == '\\') + break; - if (pathlen > 0) - { - PL_strcpy(&path[pathlen + 1], "plugins"); - //dir = PR_OpenDir(path); + pathlen--; + } - allocPath = path;//PL_strdup(path); - *(nsFileSpec*)this = allocPath; + if (pathlen > 0) + { + PL_strcpy(&path[pathlen + 1], "plugins"); + + allocPath = path; + *(nsFileSpec*)this = allocPath; + } } - } + } + + if(((location == PLUGINS_DIR_LOCATION_AUTO) && !Exists()) || + (location == PLUGINS_DIR_LOCATION_4DOTX)) + { + // look for the plugin folder that the user has in their Communicator 4x install + HKEY keyloc; + long result; + DWORD type; - // if we didn't find it, let's look for the plugin folder - // that the user has in their Communicator 4x install - if(!Exists()) - { path[0] = 0; - //PL_strfree(allocPath); result = ::RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Netscape\\Netscape Navigator\\Main", @@ -178,10 +179,9 @@ nsPluginsDir::nsPluginsDir() ::RegCloseKey(keyloc); } - //dir = PR_OpenDir(path); allocPath = PL_strdup(path); *(nsFileSpec*)this = allocPath; - } + } #ifdef NS_DEBUG if (path[0] != 0) @@ -285,12 +285,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) DWORD zerome, versionsize; char* verbuf = nsnull; const char* path = this->GetCString(); -/* - const char* fileName; - fileName = PL_strrchr(path, '\\'); - if(fileName) - ++fileName; -*/ + versionsize = ::GetFileVersionInfoSize((char*)path, &zerome); if (versionsize > 0) verbuf = (char *)PR_Malloc(versionsize); @@ -310,8 +305,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType); info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription); info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions); - //info.fFileName = PL_strdup(fileName); - info.fFileName = PL_strdup(path); // don't we need the full path too? + info.fFileName = PL_strdup(path); } else res = NS_ERROR_FAILURE;