reworked initialization/termination routines, now adds MRJPlugin.jar to the class path, assuming same directory as plugin, removes event filters upon termination.
This commit is contained in:
Родитель
3852d7338c
Коммит
49f058fd75
|
@ -40,6 +40,7 @@
|
||||||
#include "nsIWindowlessPlugInstPeer.h"
|
#include "nsIWindowlessPlugInstPeer.h"
|
||||||
#include "LiveConnectNativeMethods.h"
|
#include "LiveConnectNativeMethods.h"
|
||||||
#include "CSecureEnv.h"
|
#include "CSecureEnv.h"
|
||||||
|
#include "EventFilter.h"
|
||||||
|
|
||||||
nsIServiceManager* theServiceManager = NULL;
|
nsIServiceManager* theServiceManager = NULL;
|
||||||
|
|
||||||
|
@ -69,13 +70,6 @@ static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININST
|
||||||
|
|
||||||
#pragma export on
|
#pragma export on
|
||||||
|
|
||||||
/* NS_METHOD NP_CreatePlugin(NPIPluginManager* manager, NPIPlugin* *result)
|
|
||||||
{
|
|
||||||
thePluginManager = manager;
|
|
||||||
*result = new MRJPlugin(manager);
|
|
||||||
return nsPluginError_NoError;
|
|
||||||
} */
|
|
||||||
|
|
||||||
nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const char *aClassName, const char *aProgID, nsIFactory **aFactory)
|
nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const char *aClassName, const char *aProgID, nsIFactory **aFactory)
|
||||||
{
|
{
|
||||||
nsresult result = NS_OK;
|
nsresult result = NS_OK;
|
||||||
|
@ -102,15 +96,40 @@ nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const ch
|
||||||
|
|
||||||
#pragma export off
|
#pragma export off
|
||||||
|
|
||||||
extern "C" void cfm_NSShutdownPlugin(void);
|
extern "C" {
|
||||||
|
|
||||||
void cfm_NSShutdownPlugin()
|
pascal OSErr __initialize(const CFragInitBlock *initBlock);
|
||||||
|
pascal void __terminate(void);
|
||||||
|
|
||||||
|
pascal OSErr MRJPlugin__initialize(const CFragInitBlock *initBlock);
|
||||||
|
pascal void MRJPlugin__terminate(void);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static FSSpec thePluginSpec;
|
||||||
|
|
||||||
|
pascal OSErr MRJPlugin__initialize(const CFragInitBlock *initBlock)
|
||||||
{
|
{
|
||||||
|
if (initBlock->fragLocator.where == kDataForkCFragLocator)
|
||||||
|
thePluginSpec = *initBlock->fragLocator.u.onDisk.fileSpec;
|
||||||
|
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
pascal void MRJPlugin__terminate()
|
||||||
|
{
|
||||||
|
// Is this strictly necessary?
|
||||||
if (thePlugin != NULL) {
|
if (thePlugin != NULL) {
|
||||||
nsrefcnt refs = thePlugin->Release();
|
nsrefcnt refs = thePlugin->Release();
|
||||||
while (refs > 0 && thePlugin != NULL)
|
while (refs > 0 && thePlugin != NULL)
|
||||||
refs = thePlugin->Release();
|
refs = thePlugin->Release();
|
||||||
|
thePlugin = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MRJPLUGIN_4X
|
||||||
|
// Make sure the event filters are removed.
|
||||||
|
RemoveEventFilters();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -236,11 +255,13 @@ NS_METHOD MRJPlugin::Initialize()
|
||||||
mThreadManager->GetCurrentThread(&mPluginThreadID);
|
mThreadManager->GetCurrentThread(&mPluginThreadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a console, only if we can register windows.
|
#ifndef MRJPLUGIN_4X
|
||||||
|
// create a console, only if there's user interface for it.
|
||||||
if (thePluginManager2 != NULL) {
|
if (thePluginManager2 != NULL) {
|
||||||
mConsole = new MRJConsole(this);
|
mConsole = new MRJConsole(this);
|
||||||
mConsole->AddRef();
|
mConsole->AddRef();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -314,6 +335,10 @@ NS_METHOD MRJPlugin::StartupJVM()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Add "MRJPlugin.jar" to the class path.
|
||||||
|
FSSpec jarFileSpec = { thePluginSpec.vRefNum, thePluginSpec.parID, "\pMRJPlugin.jar" };
|
||||||
|
mSession->addToClassPath(jarFileSpec);
|
||||||
|
|
||||||
InitLiveConnectSupport(this);
|
InitLiveConnectSupport(this);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -530,6 +555,7 @@ MRJPluginInstance::~MRJPluginInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* kGetCodeBaseScriptURL = "javascript:var href = window.location.href; href.substring(0, href.lastIndexOf('/') + 1)";
|
static const char* kGetCodeBaseScriptURL = "javascript:var href = window.location.href; href.substring(0, href.lastIndexOf('/') + 1)";
|
||||||
|
static const char* kGetDocumentBaseScriptURL = "javascript:window.location";
|
||||||
|
|
||||||
static bool hasTagInfo(nsISupports* supports)
|
static bool hasTagInfo(nsISupports* supports)
|
||||||
{
|
{
|
||||||
|
@ -562,7 +588,7 @@ NS_METHOD MRJPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||||
// fire up a JavaScript URL to get the current document's location.
|
// fire up a JavaScript URL to get the current document's location.
|
||||||
nsIPluginInstance* pluginInstance = this;
|
nsIPluginInstance* pluginInstance = this;
|
||||||
nsIPluginStreamListener* listener = this;
|
nsIPluginStreamListener* listener = this;
|
||||||
result = thePluginManager->GetURL(pluginInstance, kGetCodeBaseScriptURL, NULL, listener);
|
result = thePluginManager->GetURL(pluginInstance, kGetDocumentBaseScriptURL, NULL, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -571,18 +597,21 @@ NS_METHOD MRJPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||||
NS_METHOD MRJPluginInstance::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
NS_METHOD MRJPluginInstance::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||||
{
|
{
|
||||||
// hopefully all our data is available.
|
// hopefully all our data is available.
|
||||||
char* codeBase = new char[length + 1];
|
char* documentBase = new char[length + 1];
|
||||||
if (codeBase != NULL) {
|
if (documentBase != NULL) {
|
||||||
if (input->Read(codeBase, length, &length) == NS_OK) {
|
if (input->Read(documentBase, length, &length) == NS_OK) {
|
||||||
// We've delayed processing the applet tag, because we
|
// We've delayed processing the applet tag, because we
|
||||||
// don't know the location of the curren document yet.
|
// don't know the location of the current document yet.
|
||||||
codeBase[length] = '\0';
|
documentBase[length] = '\0';
|
||||||
|
|
||||||
|
// set up the default document location, which can be used to compute relative CODEBASE, etc.
|
||||||
|
mContext->setDocumentBase(documentBase);
|
||||||
|
delete[] documentBase;
|
||||||
|
|
||||||
mContext->setCodeBase(codeBase);
|
|
||||||
mContext->processAppletTag();
|
mContext->processAppletTag();
|
||||||
mContext->createContext();
|
mContext->createContext();
|
||||||
|
|
||||||
// SetWindow is called at an inopportune time.
|
// SetWindow may be called at an inopportune time.
|
||||||
if (mPluginWindow != NULL)
|
if (mPluginWindow != NULL)
|
||||||
mContext->setWindow(mPluginWindow);
|
mContext->setWindow(mPluginWindow);
|
||||||
}
|
}
|
||||||
|
@ -683,6 +712,16 @@ NS_METHOD MRJPluginInstance::HandleEvent(nsPluginEvent* pluginEvent, PRBool* eve
|
||||||
if (event->what == nullEvent) {
|
if (event->what == nullEvent) {
|
||||||
// Give MRJ another quantum of time.
|
// Give MRJ another quantum of time.
|
||||||
mSession->idle(kDefaultJMTime); // now SpendTime does this.
|
mSession->idle(kDefaultJMTime); // now SpendTime does this.
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// check for pending update events.
|
||||||
|
if (CheckUpdate(event)) {
|
||||||
|
MRJFrame* frame = mContext->findFrame(WindowRef(event->message));
|
||||||
|
if (frame != NULL)
|
||||||
|
frame->update();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MRJFrame* frame = mContext->findFrame(WindowRef(pluginEvent->window));
|
MRJFrame* frame = mContext->findFrame(WindowRef(pluginEvent->window));
|
||||||
if (frame != NULL) {
|
if (frame != NULL) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче