зеркало из https://github.com/mozilla/gecko-dev.git
Introducing flags to specify plugins dir location.
Not used yet. Getting ready for 21938.
This commit is contained in:
Родитель
44c1cfd98b
Коммит
56f0cdee15
|
@ -32,12 +32,18 @@
|
||||||
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
|
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
|
||||||
* nsFileSpec returned by the iterator.
|
* 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 {
|
class nsPluginsDir : public nsFileSpec {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Locates the plugins directory in a platform-dependent manner.
|
* Locates the plugins directory in a platform-dependent manner.
|
||||||
*/
|
*/
|
||||||
nsPluginsDir();
|
nsPluginsDir(PRUint16 location = PLUGINS_DIR_LOCATION_AUTO);
|
||||||
virtual ~nsPluginsDir();
|
virtual ~nsPluginsDir();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,7 +51,7 @@ static nsresult getApplicationSpec(FSSpec& outAppSpec)
|
||||||
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
|
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// Use the folder manager to get location of Extensions folder, and
|
// Use the folder manager to get location of Extensions folder, and
|
||||||
|
|
|
@ -107,7 +107,7 @@ static char **BuildStringArray( char *aFlat, PRUint32 &aSize)
|
||||||
|
|
||||||
// nsPluginsDir class
|
// nsPluginsDir class
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
// XXX This isn't right for the embedded case, but it's as close
|
// XXX This isn't right for the embedded case, but it's as close
|
||||||
// as we can do right now.
|
// as we can do right now.
|
||||||
|
|
|
@ -69,7 +69,7 @@ static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||||
|
|
||||||
/* nsPluginsDir implementation */
|
/* nsPluginsDir implementation */
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
// this is somewhat lacking, in that it doesn't fall back to any other directories.
|
// 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
|
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
|
||||||
|
|
|
@ -119,45 +119,46 @@ static char** MakeStringArray(PRUint32 variants, char* data)
|
||||||
|
|
||||||
/* nsPluginsDir implementation */
|
/* nsPluginsDir implementation */
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
HKEY keyloc;
|
DWORD pathlen;
|
||||||
DWORD pathlen, type;
|
|
||||||
long result;
|
|
||||||
char path[2000];
|
char path[2000];
|
||||||
const char* allocPath;
|
const char* allocPath;
|
||||||
//PRDir *dir = nsnull;
|
|
||||||
|
|
||||||
// first, let's look for a plugin folder that exists in the
|
if((location == PLUGINS_DIR_LOCATION_AUTO) || (location == PLUGINS_DIR_LOCATION_MOZ_LOCAL))
|
||||||
// same directory as our executable
|
{
|
||||||
if (::GetModuleFileName(NULL, path, sizeof(path)) > 0)
|
// 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 (path[pathlen] == '\\')
|
pathlen = PL_strlen(path) - 1;
|
||||||
break;
|
|
||||||
|
|
||||||
pathlen--;
|
while (pathlen > 0)
|
||||||
}
|
{
|
||||||
|
if (path[pathlen] == '\\')
|
||||||
|
break;
|
||||||
|
|
||||||
if (pathlen > 0)
|
pathlen--;
|
||||||
{
|
}
|
||||||
PL_strcpy(&path[pathlen + 1], "plugins");
|
|
||||||
//dir = PR_OpenDir(path);
|
|
||||||
|
|
||||||
allocPath = path;//PL_strdup(path);
|
if (pathlen > 0)
|
||||||
*(nsFileSpec*)this = allocPath;
|
{
|
||||||
|
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;
|
path[0] = 0;
|
||||||
//PL_strfree(allocPath);
|
|
||||||
|
|
||||||
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
"Software\\Netscape\\Netscape Navigator\\Main",
|
"Software\\Netscape\\Netscape Navigator\\Main",
|
||||||
|
@ -178,10 +179,9 @@ nsPluginsDir::nsPluginsDir()
|
||||||
::RegCloseKey(keyloc);
|
::RegCloseKey(keyloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//dir = PR_OpenDir(path);
|
|
||||||
allocPath = PL_strdup(path);
|
allocPath = PL_strdup(path);
|
||||||
*(nsFileSpec*)this = allocPath;
|
*(nsFileSpec*)this = allocPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
if (path[0] != 0)
|
if (path[0] != 0)
|
||||||
|
@ -285,12 +285,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||||
DWORD zerome, versionsize;
|
DWORD zerome, versionsize;
|
||||||
char* verbuf = nsnull;
|
char* verbuf = nsnull;
|
||||||
const char* path = this->GetCString();
|
const char* path = this->GetCString();
|
||||||
/*
|
|
||||||
const char* fileName;
|
|
||||||
fileName = PL_strrchr(path, '\\');
|
|
||||||
if(fileName)
|
|
||||||
++fileName;
|
|
||||||
*/
|
|
||||||
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
||||||
if (versionsize > 0)
|
if (versionsize > 0)
|
||||||
verbuf = (char *)PR_Malloc(versionsize);
|
verbuf = (char *)PR_Malloc(versionsize);
|
||||||
|
@ -310,8 +305,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||||
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
||||||
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
||||||
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
||||||
//info.fFileName = PL_strdup(fileName);
|
info.fFileName = PL_strdup(path);
|
||||||
info.fFileName = PL_strdup(path); // don't we need the full path too?
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = NS_ERROR_FAILURE;
|
res = NS_ERROR_FAILURE;
|
||||||
|
|
|
@ -32,12 +32,18 @@
|
||||||
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
|
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
|
||||||
* nsFileSpec returned by the iterator.
|
* 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 {
|
class nsPluginsDir : public nsFileSpec {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Locates the plugins directory in a platform-dependent manner.
|
* Locates the plugins directory in a platform-dependent manner.
|
||||||
*/
|
*/
|
||||||
nsPluginsDir();
|
nsPluginsDir(PRUint16 location = PLUGINS_DIR_LOCATION_AUTO);
|
||||||
virtual ~nsPluginsDir();
|
virtual ~nsPluginsDir();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,7 +51,7 @@ static nsresult getApplicationSpec(FSSpec& outAppSpec)
|
||||||
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
|
return (result == noErr ? NS_OK : NS_ERROR_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// Use the folder manager to get location of Extensions folder, and
|
// Use the folder manager to get location of Extensions folder, and
|
||||||
|
|
|
@ -107,7 +107,7 @@ static char **BuildStringArray( char *aFlat, PRUint32 &aSize)
|
||||||
|
|
||||||
// nsPluginsDir class
|
// nsPluginsDir class
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
// XXX This isn't right for the embedded case, but it's as close
|
// XXX This isn't right for the embedded case, but it's as close
|
||||||
// as we can do right now.
|
// as we can do right now.
|
||||||
|
|
|
@ -69,7 +69,7 @@ static PRUint32 CalculateVariantCount(char* mimeTypes)
|
||||||
|
|
||||||
/* nsPluginsDir implementation */
|
/* nsPluginsDir implementation */
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
// this is somewhat lacking, in that it doesn't fall back to any other directories.
|
// 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
|
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
|
||||||
|
|
|
@ -119,45 +119,46 @@ static char** MakeStringArray(PRUint32 variants, char* data)
|
||||||
|
|
||||||
/* nsPluginsDir implementation */
|
/* nsPluginsDir implementation */
|
||||||
|
|
||||||
nsPluginsDir::nsPluginsDir()
|
nsPluginsDir::nsPluginsDir(PRUint16 location)
|
||||||
{
|
{
|
||||||
HKEY keyloc;
|
DWORD pathlen;
|
||||||
DWORD pathlen, type;
|
|
||||||
long result;
|
|
||||||
char path[2000];
|
char path[2000];
|
||||||
const char* allocPath;
|
const char* allocPath;
|
||||||
//PRDir *dir = nsnull;
|
|
||||||
|
|
||||||
// first, let's look for a plugin folder that exists in the
|
if((location == PLUGINS_DIR_LOCATION_AUTO) || (location == PLUGINS_DIR_LOCATION_MOZ_LOCAL))
|
||||||
// same directory as our executable
|
{
|
||||||
if (::GetModuleFileName(NULL, path, sizeof(path)) > 0)
|
// 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 (path[pathlen] == '\\')
|
pathlen = PL_strlen(path) - 1;
|
||||||
break;
|
|
||||||
|
|
||||||
pathlen--;
|
while (pathlen > 0)
|
||||||
}
|
{
|
||||||
|
if (path[pathlen] == '\\')
|
||||||
|
break;
|
||||||
|
|
||||||
if (pathlen > 0)
|
pathlen--;
|
||||||
{
|
}
|
||||||
PL_strcpy(&path[pathlen + 1], "plugins");
|
|
||||||
//dir = PR_OpenDir(path);
|
|
||||||
|
|
||||||
allocPath = path;//PL_strdup(path);
|
if (pathlen > 0)
|
||||||
*(nsFileSpec*)this = allocPath;
|
{
|
||||||
|
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;
|
path[0] = 0;
|
||||||
//PL_strfree(allocPath);
|
|
||||||
|
|
||||||
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||||
"Software\\Netscape\\Netscape Navigator\\Main",
|
"Software\\Netscape\\Netscape Navigator\\Main",
|
||||||
|
@ -178,10 +179,9 @@ nsPluginsDir::nsPluginsDir()
|
||||||
::RegCloseKey(keyloc);
|
::RegCloseKey(keyloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//dir = PR_OpenDir(path);
|
|
||||||
allocPath = PL_strdup(path);
|
allocPath = PL_strdup(path);
|
||||||
*(nsFileSpec*)this = allocPath;
|
*(nsFileSpec*)this = allocPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
if (path[0] != 0)
|
if (path[0] != 0)
|
||||||
|
@ -285,12 +285,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||||
DWORD zerome, versionsize;
|
DWORD zerome, versionsize;
|
||||||
char* verbuf = nsnull;
|
char* verbuf = nsnull;
|
||||||
const char* path = this->GetCString();
|
const char* path = this->GetCString();
|
||||||
/*
|
|
||||||
const char* fileName;
|
|
||||||
fileName = PL_strrchr(path, '\\');
|
|
||||||
if(fileName)
|
|
||||||
++fileName;
|
|
||||||
*/
|
|
||||||
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
versionsize = ::GetFileVersionInfoSize((char*)path, &zerome);
|
||||||
if (versionsize > 0)
|
if (versionsize > 0)
|
||||||
verbuf = (char *)PR_Malloc(versionsize);
|
verbuf = (char *)PR_Malloc(versionsize);
|
||||||
|
@ -310,8 +305,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
|
||||||
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
|
||||||
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
|
||||||
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
|
||||||
//info.fFileName = PL_strdup(fileName);
|
info.fFileName = PL_strdup(path);
|
||||||
info.fFileName = PL_strdup(path); // don't we need the full path too?
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = NS_ERROR_FAILURE;
|
res = NS_ERROR_FAILURE;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче