Updated 4x plugin support on the Mac

git-svn-id: svn://10.0.0.236/trunk@31934 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
amusil%netscape.com
1999-05-17 21:26:48 +00:00
parent 28346b8d72
commit 91a29fa7f7
14 changed files with 334 additions and 60 deletions

View File

@@ -25,6 +25,11 @@
#include "nsIServiceManager.h"
#include "nsIAllocator.h"
#include "nsIPluginStreamListener.h"
#include "nsPluginsDir.h"
#ifdef XP_MAC
#include <Resources.h>
#endif
////////////////////////////////////////////////////////////////////////
@@ -115,6 +120,7 @@ ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, ns
ns4xPlugin::~ns4xPlugin(void)
{
}
@@ -148,6 +154,24 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
return NS_NOINTERFACE;
}
#ifdef XP_MAC
static char* p2cstrdup(StringPtr pstr)
{
int len = pstr[0];
char* cstr = new char[len + 1];
if (cstr != NULL) {
::BlockMoveData(pstr + 1, cstr, len);
cstr[len] = '\0';
}
return cstr;
}
void
ns4xPlugin::SetPluginRefNum(short aRefNum)
{
fPluginRefNum = aRefNum;
}
#endif
////////////////////////////////////////////////////////////////////////
// Static factory method.
@@ -161,15 +185,14 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
*/
nsresult
ns4xPlugin::CreatePlugin(PRLibrary *library,
nsIPlugin **result,
nsIServiceManager* serviceMgr)
ns4xPlugin::CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr)
{
CheckClassInitialized();
#ifdef XP_PC
// XXX this only applies on Windows
NP_GETENTRYPOINTS pfnGetEntryPoints =
(NP_GETENTRYPOINTS)PR_FindSymbol(library, "NP_GetEntryPoints");
(NP_GETENTRYPOINTS)PR_FindSymbol(pluginTag->mLibrary, "NP_GetEntryPoints");
if (pfnGetEntryPoints == NULL)
return NS_ERROR_FAILURE;
@@ -182,26 +205,26 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
if (pfnGetEntryPoints(&callbacks) != NS_OK)
return NS_ERROR_FAILURE; // XXX
#ifdef XP_WIN // XXX This is really XP, but we need to figure out how to do HIBYTE()
#ifdef XP_PC // XXX This is really XP, but we need to figure out how to do HIBYTE()
if (HIBYTE(callbacks.version) < NP_VERSION_MAJOR)
return NS_ERROR_FAILURE;
#endif
#endif
NP_PLUGINSHUTDOWN pfnShutdown =
(NP_PLUGINSHUTDOWN)PR_FindSymbol(library, "NP_Shutdown");
(NP_PLUGINSHUTDOWN)PR_FindSymbol(pluginTag->mLibrary, "NP_Shutdown");
// create the new plugin handler
*result = new ns4xPlugin(&callbacks, pfnShutdown, serviceMgr);
pluginTag->mEntryPoint = new ns4xPlugin(&callbacks, pfnShutdown, serviceMgr);
NS_ADDREF(*result);
if (*result == NULL)
if (pluginTag->mEntryPoint == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pluginTag->mEntryPoint);
// we must init here because the plugin may call NPN functions
// when we call into the NP_Initialize entry point - NPN functions
// require that mBrowserManager be set up
(*result)->Initialize();
pluginTag->mEntryPoint->Initialize();
// the NP_Initialize entry point was misnamed as NP_PluginInit,
// early in plugin project development. Its correct name is
@@ -210,11 +233,11 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
// we'll accept either name
NP_PLUGININIT pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_Initialize");
(NP_PLUGININIT)PR_FindSymbol(pluginTag->mLibrary, "NP_Initialize");
if (!pfnInitialize) {
pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_PluginInit");
(NP_PLUGININIT)PR_FindSymbol(pluginTag->mLibrary, "NP_PluginInit");
}
if (pfnInitialize == NULL)
@@ -222,6 +245,66 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
if (pfnInitialize(&(ns4xPlugin::CALLBACKS)) != NS_OK)
return NS_ERROR_UNEXPECTED;
#endif
#ifdef XP_MAC
// get the mainRD entry point
NP_MAIN pfnMain = (NP_MAIN) PR_FindSymbol(pluginTag->mLibrary, "mainRD");
if(pfnMain == NULL)
return NS_ERROR_FAILURE;
NPP_ShutdownUPP pfnShutdown;
NPPluginFuncs callbacks;
memset((void*) &callbacks, 0, sizeof(callbacks));
callbacks.size = sizeof(callbacks);
nsPluginsDir pluginsDir;
if(!pluginsDir.Valid())
return NS_ERROR_FAILURE;
short appRefNum = ::CurResFile();
short pluginRefNum;
for(nsDirectoryIterator iter(pluginsDir); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
if (pluginsDir.IsPluginFile(file))
{
FSSpec spec = file;
char* fileName = p2cstrdup(spec.name);
if(!PL_strcmp(fileName, pluginTag->mFileName))
{
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
}
}
}
// call into the entry point
if(CallNPP_MainEntryProc(pfnMain, &(ns4xPlugin::CALLBACKS), &callbacks, &pfnShutdown) != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
::UseResFile(appRefNum);
if ((callbacks.version >> 8) < NP_VERSION_MAJOR)
return NS_ERROR_FAILURE;
// create the new plugin handler
ns4xPlugin* plugin = new ns4xPlugin(&callbacks, (NP_PLUGINSHUTDOWN)pfnShutdown, serviceMgr);
if(plugin == NULL)
return NS_ERROR_OUT_OF_MEMORY;
plugin->SetPluginRefNum(pluginRefNum);
pluginTag->mEntryPoint = plugin;
NS_ADDREF(pluginTag->mEntryPoint);
#endif
#ifdef XP_UNIX
return NS_ERROR_FAILURE;
#endif
return NS_OK;
}
@@ -288,7 +371,13 @@ ns4xPlugin::Shutdown(void)
#ifdef NS_DEBUG
printf("shutting down plugin %08x\n", this);
#endif
#ifdef XP_MAC
CallNPP_ShutdownProc(fShutdownEntry);
::CloseResFile(fPluginRefNum);
#else
fShutdownEntry();
#endif
fShutdownEntry = nsnull;
}

View File

@@ -22,6 +22,7 @@
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
@@ -38,9 +39,16 @@
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
@@ -99,10 +107,14 @@ public:
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(PRLibrary *library,
nsIPlugin **result,
nsIServiceManager* serviceMgr);
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
@@ -212,6 +224,10 @@ protected:
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.

View File

@@ -518,14 +518,28 @@ nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener,
NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint)
{
printf("instance print called\n");
printf("instance print called\n");
return NS_OK;
}
NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
{
printf("instance handleevent called\n");
*handled = PR_FALSE;
printf("instance handleevent called\n");
PRInt16 res = 0;
if (fCallbacks->event)
{
#if !TARGET_CARBON
// pinkerton
// relies on routine descriptors, not present in carbon. We need to fix this.
res = CallNPP_HandleEventProc(fCallbacks->event,
&fNPP,
(void*) event->event);
#endif
*handled = res;
}
return NS_OK;
}

View File

@@ -1325,6 +1325,13 @@ NS_IMETHODIMP nsPluginHostImpl::Destroy(void)
{
nsPluginTag *plug = mPlugins;
PRUint32 i;
for(i=0; i<mNumActivePlugins; i++)
{
if(mActivePluginList[i].mInstance)
mActivePluginList[i].mInstance->Destroy();
}
while (nsnull != plug)
{
if (nsnull != plug->mEntryPoint)
@@ -1456,6 +1463,9 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURL* aURL, nsIPluginInstan
{
PRUint32 i;
const char* url;
if(!aURL)
return NS_ERROR_FAILURE;
(void)aURL->GetSpec(&url);
for(i=0; i<mNumActivePlugins; i++)
@@ -1486,6 +1496,9 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURL* aURL, nsIPluginInstan
void nsPluginHostImpl::AddInstanceToActiveList(nsIPluginInstance* aInstance, nsIURL* aURL)
{
const char* url;
if(!aURL)
return;
(void)aURL->GetSpec(&url);
if(mNumActivePlugins < MAX_ACTIVE_PLUGINS)
@@ -1526,12 +1539,16 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
nsIPlugin* plugin = NULL;
const char* mimetype;
if(!aURL)
return NS_ERROR_FAILURE;
// if don't have a mimetype, check by file extension
if(!aMimeType)
{
const char* filename;
char* extension;
aURL->GetFile(&filename);
extension = PL_strrchr(filename, '.');
if(extension)
@@ -1546,7 +1563,7 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
mimetype = aMimeType;
if(GetPluginFactory(mimetype, &plugin) == NS_OK)
if(GetPluginFactory(mimetype, &plugin) == NS_OK)
{
// instantiate a plugin.
nsIPluginInstance* instance = NULL;
@@ -1855,11 +1872,9 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
}
else
{
rv = ns4xPlugin::CreatePlugin(pluginTag->mLibrary,
(nsIPlugin **)&pluginTag->mEntryPoint,
mServiceMgr);
rv = ns4xPlugin::CreatePlugin(pluginTag, mServiceMgr);
plugin = pluginTag->mEntryPoint;
pluginTag->mFlags |= NS_PLUGIN_FLAG_OLDSCHOOL;
pluginTag->mFlags |= NS_PLUGIN_FLAG_OLDSCHOOL;
// no need to initialize, already done by CreatePlugin()
}
@@ -1907,6 +1922,7 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
pluginTag->mMimeTypeArray = info.fMimeTypeArray;
pluginTag->mMimeDescriptionArray = info.fMimeDescriptionArray;
pluginTag->mExtensionsArray = info.fExtensionArray;
pluginTag->mFileName = info.fFileName;
}
pluginTag->mLibrary = pluginLibrary;

View File

@@ -52,6 +52,7 @@ public:
PRLibrary *mLibrary;
nsIPlugin *mEntryPoint;
PRUint32 mFlags;
char *mFileName;
};
#define MAX_ACTIVE_PLUGINS 10

View File

@@ -55,6 +55,7 @@ struct nsPluginInfo {
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**

View File

@@ -74,7 +74,7 @@ PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
const FSSpec& spec = fileSpec;
OSErr result = FSpGetFInfo(&spec, &info);
if (result == noErr)
return (info.fdType == 'shlb' && info.fdCreator == 'MOSS');
return ((info.fdType == 'shlb' && info.fdCreator == 'MOSS') || info.fdType == 'NSPL');
return false;
}
@@ -91,8 +91,7 @@ nsPluginFile::~nsPluginFile() {}
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
// How can we convert to a full path names for using with NSPR?
nsFilePath path(*this);
const char* path = this->GetCString();
outLibrary = PR_LoadLibrary(path);
return NS_OK;
}
@@ -154,6 +153,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
info.fMimeTypeArray = new char*[variantCount];
info.fMimeDescriptionArray = new char*[variantCount];
info.fExtensionArray = new char*[variantCount];
info.fFileName = p2cstrdup(spec.name);
short mimeIndex = 1, descriptionIndex = 1;
for (int i = 0; i < variantCount; i++) {

View File

@@ -25,6 +25,11 @@
#include "nsIServiceManager.h"
#include "nsIAllocator.h"
#include "nsIPluginStreamListener.h"
#include "nsPluginsDir.h"
#ifdef XP_MAC
#include <Resources.h>
#endif
////////////////////////////////////////////////////////////////////////
@@ -115,6 +120,7 @@ ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, ns
ns4xPlugin::~ns4xPlugin(void)
{
}
@@ -148,6 +154,24 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
return NS_NOINTERFACE;
}
#ifdef XP_MAC
static char* p2cstrdup(StringPtr pstr)
{
int len = pstr[0];
char* cstr = new char[len + 1];
if (cstr != NULL) {
::BlockMoveData(pstr + 1, cstr, len);
cstr[len] = '\0';
}
return cstr;
}
void
ns4xPlugin::SetPluginRefNum(short aRefNum)
{
fPluginRefNum = aRefNum;
}
#endif
////////////////////////////////////////////////////////////////////////
// Static factory method.
@@ -161,15 +185,14 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
*/
nsresult
ns4xPlugin::CreatePlugin(PRLibrary *library,
nsIPlugin **result,
nsIServiceManager* serviceMgr)
ns4xPlugin::CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr)
{
CheckClassInitialized();
#ifdef XP_PC
// XXX this only applies on Windows
NP_GETENTRYPOINTS pfnGetEntryPoints =
(NP_GETENTRYPOINTS)PR_FindSymbol(library, "NP_GetEntryPoints");
(NP_GETENTRYPOINTS)PR_FindSymbol(pluginTag->mLibrary, "NP_GetEntryPoints");
if (pfnGetEntryPoints == NULL)
return NS_ERROR_FAILURE;
@@ -182,26 +205,26 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
if (pfnGetEntryPoints(&callbacks) != NS_OK)
return NS_ERROR_FAILURE; // XXX
#ifdef XP_WIN // XXX This is really XP, but we need to figure out how to do HIBYTE()
#ifdef XP_PC // XXX This is really XP, but we need to figure out how to do HIBYTE()
if (HIBYTE(callbacks.version) < NP_VERSION_MAJOR)
return NS_ERROR_FAILURE;
#endif
#endif
NP_PLUGINSHUTDOWN pfnShutdown =
(NP_PLUGINSHUTDOWN)PR_FindSymbol(library, "NP_Shutdown");
(NP_PLUGINSHUTDOWN)PR_FindSymbol(pluginTag->mLibrary, "NP_Shutdown");
// create the new plugin handler
*result = new ns4xPlugin(&callbacks, pfnShutdown, serviceMgr);
pluginTag->mEntryPoint = new ns4xPlugin(&callbacks, pfnShutdown, serviceMgr);
NS_ADDREF(*result);
if (*result == NULL)
if (pluginTag->mEntryPoint == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(pluginTag->mEntryPoint);
// we must init here because the plugin may call NPN functions
// when we call into the NP_Initialize entry point - NPN functions
// require that mBrowserManager be set up
(*result)->Initialize();
pluginTag->mEntryPoint->Initialize();
// the NP_Initialize entry point was misnamed as NP_PluginInit,
// early in plugin project development. Its correct name is
@@ -210,11 +233,11 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
// we'll accept either name
NP_PLUGININIT pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_Initialize");
(NP_PLUGININIT)PR_FindSymbol(pluginTag->mLibrary, "NP_Initialize");
if (!pfnInitialize) {
pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_PluginInit");
(NP_PLUGININIT)PR_FindSymbol(pluginTag->mLibrary, "NP_PluginInit");
}
if (pfnInitialize == NULL)
@@ -222,6 +245,66 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
if (pfnInitialize(&(ns4xPlugin::CALLBACKS)) != NS_OK)
return NS_ERROR_UNEXPECTED;
#endif
#ifdef XP_MAC
// get the mainRD entry point
NP_MAIN pfnMain = (NP_MAIN) PR_FindSymbol(pluginTag->mLibrary, "mainRD");
if(pfnMain == NULL)
return NS_ERROR_FAILURE;
NPP_ShutdownUPP pfnShutdown;
NPPluginFuncs callbacks;
memset((void*) &callbacks, 0, sizeof(callbacks));
callbacks.size = sizeof(callbacks);
nsPluginsDir pluginsDir;
if(!pluginsDir.Valid())
return NS_ERROR_FAILURE;
short appRefNum = ::CurResFile();
short pluginRefNum;
for(nsDirectoryIterator iter(pluginsDir); iter.Exists(); iter++)
{
const nsFileSpec& file = iter;
if (pluginsDir.IsPluginFile(file))
{
FSSpec spec = file;
char* fileName = p2cstrdup(spec.name);
if(!PL_strcmp(fileName, pluginTag->mFileName))
{
Boolean targetIsFolder, wasAliased;
OSErr err = ::ResolveAliasFile(&spec, true, &targetIsFolder, &wasAliased);
pluginRefNum = ::FSpOpenResFile(&spec, fsRdPerm);
}
}
}
// call into the entry point
if(CallNPP_MainEntryProc(pfnMain, &(ns4xPlugin::CALLBACKS), &callbacks, &pfnShutdown) != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
::UseResFile(appRefNum);
if ((callbacks.version >> 8) < NP_VERSION_MAJOR)
return NS_ERROR_FAILURE;
// create the new plugin handler
ns4xPlugin* plugin = new ns4xPlugin(&callbacks, (NP_PLUGINSHUTDOWN)pfnShutdown, serviceMgr);
if(plugin == NULL)
return NS_ERROR_OUT_OF_MEMORY;
plugin->SetPluginRefNum(pluginRefNum);
pluginTag->mEntryPoint = plugin;
NS_ADDREF(pluginTag->mEntryPoint);
#endif
#ifdef XP_UNIX
return NS_ERROR_FAILURE;
#endif
return NS_OK;
}
@@ -288,7 +371,13 @@ ns4xPlugin::Shutdown(void)
#ifdef NS_DEBUG
printf("shutting down plugin %08x\n", this);
#endif
#ifdef XP_MAC
CallNPP_ShutdownProc(fShutdownEntry);
::CloseResFile(fPluginRefNum);
#else
fShutdownEntry();
#endif
fShutdownEntry = nsnull;
}

View File

@@ -22,6 +22,7 @@
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
@@ -38,9 +39,16 @@
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
@@ -99,10 +107,14 @@ public:
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(PRLibrary *library,
nsIPlugin **result,
nsIServiceManager* serviceMgr);
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
@@ -212,6 +224,10 @@ protected:
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.

View File

@@ -518,14 +518,28 @@ nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener,
NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint)
{
printf("instance print called\n");
printf("instance print called\n");
return NS_OK;
}
NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
{
printf("instance handleevent called\n");
*handled = PR_FALSE;
printf("instance handleevent called\n");
PRInt16 res = 0;
if (fCallbacks->event)
{
#if !TARGET_CARBON
// pinkerton
// relies on routine descriptors, not present in carbon. We need to fix this.
res = CallNPP_HandleEventProc(fCallbacks->event,
&fNPP,
(void*) event->event);
#endif
*handled = res;
}
return NS_OK;
}

View File

@@ -1325,6 +1325,13 @@ NS_IMETHODIMP nsPluginHostImpl::Destroy(void)
{
nsPluginTag *plug = mPlugins;
PRUint32 i;
for(i=0; i<mNumActivePlugins; i++)
{
if(mActivePluginList[i].mInstance)
mActivePluginList[i].mInstance->Destroy();
}
while (nsnull != plug)
{
if (nsnull != plug->mEntryPoint)
@@ -1456,6 +1463,9 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURL* aURL, nsIPluginInstan
{
PRUint32 i;
const char* url;
if(!aURL)
return NS_ERROR_FAILURE;
(void)aURL->GetSpec(&url);
for(i=0; i<mNumActivePlugins; i++)
@@ -1486,6 +1496,9 @@ nsresult nsPluginHostImpl::FindStoppedPluginForURL(nsIURL* aURL, nsIPluginInstan
void nsPluginHostImpl::AddInstanceToActiveList(nsIPluginInstance* aInstance, nsIURL* aURL)
{
const char* url;
if(!aURL)
return;
(void)aURL->GetSpec(&url);
if(mNumActivePlugins < MAX_ACTIVE_PLUGINS)
@@ -1526,12 +1539,16 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
nsIPlugin* plugin = NULL;
const char* mimetype;
if(!aURL)
return NS_ERROR_FAILURE;
// if don't have a mimetype, check by file extension
if(!aMimeType)
{
const char* filename;
char* extension;
aURL->GetFile(&filename);
extension = PL_strrchr(filename, '.');
if(extension)
@@ -1546,7 +1563,7 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
mimetype = aMimeType;
if(GetPluginFactory(mimetype, &plugin) == NS_OK)
if(GetPluginFactory(mimetype, &plugin) == NS_OK)
{
// instantiate a plugin.
nsIPluginInstance* instance = NULL;
@@ -1855,11 +1872,9 @@ NS_IMETHODIMP nsPluginHostImpl::GetPluginFactory(const char *aMimeType, nsIPlugi
}
else
{
rv = ns4xPlugin::CreatePlugin(pluginTag->mLibrary,
(nsIPlugin **)&pluginTag->mEntryPoint,
mServiceMgr);
rv = ns4xPlugin::CreatePlugin(pluginTag, mServiceMgr);
plugin = pluginTag->mEntryPoint;
pluginTag->mFlags |= NS_PLUGIN_FLAG_OLDSCHOOL;
pluginTag->mFlags |= NS_PLUGIN_FLAG_OLDSCHOOL;
// no need to initialize, already done by CreatePlugin()
}
@@ -1907,6 +1922,7 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins()
pluginTag->mMimeTypeArray = info.fMimeTypeArray;
pluginTag->mMimeDescriptionArray = info.fMimeDescriptionArray;
pluginTag->mExtensionsArray = info.fExtensionArray;
pluginTag->mFileName = info.fFileName;
}
pluginTag->mLibrary = pluginLibrary;

View File

@@ -52,6 +52,7 @@ public:
PRLibrary *mLibrary;
nsIPlugin *mEntryPoint;
PRUint32 mFlags;
char *mFileName;
};
#define MAX_ACTIVE_PLUGINS 10

View File

@@ -55,6 +55,7 @@ struct nsPluginInfo {
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**

View File

@@ -74,7 +74,7 @@ PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
const FSSpec& spec = fileSpec;
OSErr result = FSpGetFInfo(&spec, &info);
if (result == noErr)
return (info.fdType == 'shlb' && info.fdCreator == 'MOSS');
return ((info.fdType == 'shlb' && info.fdCreator == 'MOSS') || info.fdType == 'NSPL');
return false;
}
@@ -91,8 +91,7 @@ nsPluginFile::~nsPluginFile() {}
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
// How can we convert to a full path names for using with NSPR?
nsFilePath path(*this);
const char* path = this->GetCString();
outLibrary = PR_LoadLibrary(path);
return NS_OK;
}
@@ -154,6 +153,7 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
info.fMimeTypeArray = new char*[variantCount];
info.fMimeDescriptionArray = new char*[variantCount];
info.fExtensionArray = new char*[variantCount];
info.fFileName = p2cstrdup(spec.name);
short mimeIndex = 1, descriptionIndex = 1;
for (int i = 0; i < variantCount; i++) {