merge from OJI branch

git-svn-id: svn://10.0.0.236/trunk@2980 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jgellman
1998-06-03 00:37:20 +00:00
parent 1ccdb802f9
commit cb4014892b
106 changed files with 4652 additions and 3197 deletions

View File

@@ -24,9 +24,9 @@ CSRCS = npassoc.c
CPPSRCS = nsplugin.cpp
EXPORTS = nppg.h npupp.h nsplugin.h nsjvm.h npglue.h nppriv.h
EXPORTS = nppg.h npupp.h nsIPlug.h nsILCPlg.h npglue.h nppriv.h
REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom netcnvts
REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom netcnvts oji
ifeq ($(subst /,_,$(shell uname -s)),OS2)
CPPSRCS = npwplat.cpp
@@ -41,4 +41,6 @@ ifeq ($(subst /,_,$(shell uname -s)),OS2)
INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe -I$(DEPTH)/cmd/winfe
endif
INCLUDES += -I.
$(LIBRARY): $(OBJS)

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -36,6 +36,12 @@ static void np_ReplaceChars(char* word, char oldChar, char newChar);
static char* np_CreateMimePref(const char* mimetype, const char* pref);
#endif /* ANTHRAX */
#ifdef PLUGIN_TIMER_EVENT
static void np_SetTimerInterval(NPP npp, uint32 msecs);
static void np_TimerCallback(void* app);
#define DEFAULT_TIMER_INTERVAL 1000
#endif
/* list of all plugins */
static np_handle *np_plist = 0;
@@ -60,7 +66,7 @@ np_is50StylePlugin(np_handle* handle)
/* Find a mimetype in the handle */
static np_mimetype *
np_getmimetype(np_handle *handle, char *mimeStr, XP_Bool wildCard)
np_getmimetype(np_handle *handle, const char *mimeStr, XP_Bool wildCard)
{
np_mimetype *mimetype;
@@ -522,7 +528,7 @@ NPL_Write(NET_StreamClass *stream, const unsigned char *str, int32 len)
if (newstream->handle->userPlugin) {
nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)newstream->pstream->pdata;
NPIPluginStream* userStream = peerStream->GetUserStream();
ret = userStream->Write(len, (void*)&str[urls->position]);
ret = userStream->Write(len, (const char*)str);
}
else if (ISFUNCPTR(newstream->handle->f->write)) {
ret = CallNPP_WriteProc(newstream->handle->f->write, newstream->instance->npp, newstream->pstream,
@@ -1056,7 +1062,6 @@ np_makecontext(np_instance* instance, const char* window)
return cx;
}
PR_STATIC_CALLBACK(void)
np_redisable_js(URL_Struct* url_s, int status, MWContext* context)
{
@@ -1608,6 +1613,11 @@ npn_setvalue(NPP npp, NPPVariable variable, void *r_value)
}
#endif /* LAYERS */
break;
case NPPVpluginTimerInterval:
np_SetTimerInterval(npp, *(uint32*)r_value);
break;
case NPPVpluginWindowSize:
break;
default:
@@ -2043,7 +2053,7 @@ npn_reloadplugins(NPBool reloadPages)
/*
* In the case where we switch the handler (above),
* "instance" already points to the next object.
* "instance" already points to the next objTag.
*/
if (!switchedHandler)
instance = instance->next;
@@ -2186,10 +2196,10 @@ NS_DEFINE_IID(kLiveConnectPluginIID, NP_ILIVECONNECTPLUGIN_IID);
#pragma pointers_in_D0
#endif
struct java_lang_Class* NP_EXPORT
#ifdef JAVA
java_lang_Class* NP_EXPORT
npn_getJavaClass(np_handle* handle)
{
#ifdef JAVA
if (handle->userPlugin) {
NPIPlugin* userPluginClass = (NPIPlugin*)handle->userPlugin;
NPILiveConnectPlugin* lcPlugin;
@@ -2210,9 +2220,9 @@ npn_getJavaClass(np_handle* handle)
if (env == NULL) return NULL;
return (java_lang_Class*)JRI_GetGlobalRef(env, handle->f->javaClass);
}
#endif
return NULL;
}
#endif
jref NP_EXPORT
npn_getJavaPeer(NPP npp)
@@ -2303,7 +2313,11 @@ np_IsLiveConnected(np_handle* handle)
}
}
else {
#ifdef JAVA
return npn_getJavaClass(handle) != NULL;
#else
return FALSE;
#endif
}
}
@@ -2317,7 +2331,7 @@ XP_Bool NPL_IsLiveConnected(LO_EmbedStruct *embed)
if (embed == NULL)
return FALSE;
app = (NPEmbeddedApp*) embed->FE_Data;
app = (NPEmbeddedApp*) embed->objTag.FE_Data;
if (app == NULL)
return FALSE;
@@ -2333,9 +2347,8 @@ XP_Bool NPL_IsLiveConnected(LO_EmbedStruct *embed)
/******************************************************************************/
static void
/* Returns false if there was an error: */
static PRBool
np_setwindow(np_instance *instance, NPWindow *appWin)
{
/*
@@ -2355,10 +2368,9 @@ np_setwindow(np_instance *instance, NPWindow *appWin)
ndata = (np_data*) app->np_data;
lo_struct = ndata->lo_struct;
#ifndef XP_MAC
if (lo_struct && lo_struct->ele_attrmask & LO_ELE_HIDDEN)
return;
if (lo_struct && lo_struct->objTag.ele_attrmask & LO_ELE_HIDDEN)
return PR_TRUE;
#endif
}
}
@@ -2373,8 +2385,13 @@ np_setwindow(np_instance *instance, NPWindow *appWin)
// If this is the first time we're drawing this, then call
// the plugin's Start() method.
if (lo_struct && ! (lo_struct->ele_attrmask & LO_ELE_DRAWN))
userInst->Start();
if (lo_struct && ! (lo_struct->objTag.ele_attrmask & LO_ELE_DRAWN)) {
NPPluginError err = userInst->Start();
if (err != NPPluginError_NoError) {
np_delete_instance(instance);
return PR_FALSE;
}
}
}
else if (ISFUNCPTR(instance->handle->f->setwindow)) {
CallNPP_SetWindowProc(instance->handle->f->setwindow, instance->npp, appWin);
@@ -2384,6 +2401,7 @@ np_setwindow(np_instance *instance, NPWindow *appWin)
{
NPTRACE(0,("setwindow before appWin was valid"));
}
return PR_TRUE;
}
static void
@@ -2392,7 +2410,7 @@ np_UnloadPluginClass(np_handle *handle)
/* only called when we truly want to dispose the plugin class */
XP_ASSERT(handle && handle->refs == 0);
#ifdef JAVA
#ifdef JAVA
if (handle->userPlugin == NULL && handle->f && handle->f->javaClass != NULL) {
/* Don't get the environment unless there is a Java class,
because this would cause the java runtime to start up. */
@@ -2415,6 +2433,7 @@ np_UnloadPluginClass(np_handle *handle)
PR_IMPLEMENT(void)
NPL_SetPluginWindow(void *data)
{
#ifdef JAVA
JRIEnv * env = NULL;
np_instance *instance = (np_instance *) data;
struct netscape_javascript_JSObject *mochaWindow = NULL;
@@ -2422,7 +2441,6 @@ NPL_SetPluginWindow(void *data)
if (instance && instance->cx)
mochaWindow = LJ_GetMochaWindow(instance->cx);
#ifdef JAVA
env = LJ_EnsureJavaEnv(PR_CurrentThread());
if (mochaWindow){
@@ -2513,10 +2531,15 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
instance->npp = npp;
instance->windowed = TRUE;
instance->transparent = FALSE;
#ifdef PLUGIN_TIMER_EVENT
instance->timeout = NULL;
instance->interval = DEFAULT_TIMER_INTERVAL;
#endif
#ifdef LAYERS
if (ndata)
instance->layer = ndata->lo_struct->layer;
instance->layer = ndata->lo_struct->objTag.layer;
#endif /* LAYERS */
/* invite the plugin */
@@ -2548,10 +2571,15 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
if (instance->type == NP_EMBED)
{
/* Embedded plug-ins get their attributes passed in from layout */
#ifdef OJI
int16 argc = (int16) ndata->lo_struct->attributes.n;
char** names = ndata->lo_struct->attributes.names;
char** values = ndata->lo_struct->attributes.values;
#else
int16 argc = (int16) ndata->lo_struct->attribute_cnt;
char** names = ndata->lo_struct->attribute_list;
char** values = ndata->lo_struct->value_list;
#endif
err = CallNPP_NewProc(handle->f->newp, requestedType, npp,
instance->type, argc, names, values, savedData);
}
@@ -2599,7 +2627,8 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
if (app->pagePluginType == NP_Embedded)
{
XP_ASSERT(app->wdata);
np_setwindow(instance, app->wdata);
PRBool success = np_setwindow(instance, app->wdata);
if (!success) goto error;
}
#endif
}
@@ -2635,8 +2664,10 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
// The problem is that by deferring the jvm startup, we cause it to
// happen later on the wrong thread.
np_IsLiveConnected(handle)
#elif defined(JAVA)
npn_getJavaClass(handle)
#else
npn_getJavaClass(handle)
FALSE
#endif
) { /* for liveconnected plugins only */
ET_SetPluginWindow(cx, (void *)instance);
@@ -2957,7 +2988,7 @@ NPL_NewPresentStream(FO_Present_Types format_out, void* type, URL_Struct* urls,
/*
* To actually create the instance we need to create a stream of
* fake HTML to cause layout to create a new embedded object.
* fake HTML to cause layout to create a new embedded objTag.
* EmbedCreate will be called, which will created the NPEmbeddedApp
* and put it into urls->fe_data, where we can retrieve it.
*/
@@ -3529,7 +3560,7 @@ np_delete_instance(np_instance *instance)
#ifdef JAVA
/*
** Break any association we have made between this instance and
** its corresponding Java object. That way other java objects
** its corresponding Java objTag. That way other java objects
** still referring to it will be able to detect that the plugin
** went away (by calling isActive).
*/
@@ -3595,6 +3626,12 @@ np_delete_instance(np_instance *instance)
if (instance->typeString)
XP_FREE(instance->typeString);
#ifdef PLUGIN_TIMER_EVENT
if(instance->timeout)
FE_ClearTimeout(instance->timeout);
#endif
XP_FREE(instance);
}
}
@@ -3719,7 +3756,7 @@ NPL_SameElement(LO_EmbedStruct* embed_struct)
{
if (embed_struct)
{
NPEmbeddedApp* app = (NPEmbeddedApp*) embed_struct->FE_Data;
NPEmbeddedApp* app = (NPEmbeddedApp*) embed_struct->objTag.FE_Data;
if (app)
{
np_data* ndata = (np_data*) app->np_data;
@@ -3935,7 +3972,6 @@ np_deleteapp(MWContext* cx, NPEmbeddedApp* app)
}
}
/*
* This is called by the front-end via layout when the plug-in's
* context is going away. Based on what kind of plugin this is, what
@@ -3949,17 +3985,17 @@ NPL_EmbedDelete(MWContext* cx, LO_EmbedStruct* embed_struct)
NPEmbeddedApp* app;
np_data* ndata;
if (!cx || !embed_struct || !embed_struct->FE_Data)
if (!cx || !embed_struct || !embed_struct->objTag.FE_Data)
return;
app = (NPEmbeddedApp*) embed_struct->FE_Data;
embed_struct->FE_Data = NULL;
app = (NPEmbeddedApp*) embed_struct->objTag.FE_Data;
embed_struct->objTag.FE_Data = NULL;
ndata = (np_data*) app->np_data;
if (ndata)
{
embed_struct->session_data = (void*) ndata;
embed_struct->objTag.session_data = (void*) ndata;
ndata->refs--;
@@ -4006,21 +4042,28 @@ NPL_EmbedDelete(MWContext* cx, LO_EmbedStruct* embed_struct)
nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*) ndata->instance->npp->pdata;
NPIPluginInstance* userInst = peerInst->GetUserInstance();
/* XXX Where should this error go? */
NPPluginError err = userInst->Stop();
XP_ASSERT(err == NPPluginError_NoError);
if (err == NPPluginError_NoError) {
/* XXX So I'm going out on a limb here and saying that
by keeping the plugin in a "cached" state, we
should pretty much not need to perturb much
else... */
ndata->state = NPDataCached;
ndata->lo_struct = NULL;
np_unbindContext(app, cx);
/* XXX So I'm going out on a limb here and saying that
by keeping the plugin in a "cached" state, we
should pretty much not need to perturb much
else... */
ndata->state = NPDataCached;
ndata->lo_struct = NULL;
np_unbindContext(app, cx);
/* Tell the front-end to save the embedded window for us */
FE_SaveEmbedWindow(cx, app);
return;
/* Tell the front-end to save the embedded window for us */
FE_SaveEmbedWindow(cx, app);
return;
}
else {
// the plugin failed to stop properly
// XXX is the following right?...
np_delete_instance(ndata->instance);
embed_struct->objTag.session_data = NULL;
app->np_data = NULL;
XP_FREE(ndata);
}
} else {
/* It's a normal old-fashioned plugin. Destroy the instance */
np_delete_instance(ndata->instance);
@@ -4035,7 +4078,7 @@ NPL_EmbedDelete(MWContext* cx, LO_EmbedStruct* embed_struct)
else
{
/* If there's no instance, there's no need to save session data */
embed_struct->session_data = NULL;
embed_struct->objTag.session_data = NULL;
app->np_data = NULL;
XP_FREE(ndata);
}
@@ -4043,7 +4086,7 @@ NPL_EmbedDelete(MWContext* cx, LO_EmbedStruct* embed_struct)
/* XXX This is pretty convoluted how this just all falls through
to here. Clean it up sometime... */
np_deleteapp(cx, app); /* unlink app from context and delete app */
np_deleteapp(cx, app); /* unlink app from context and delete app */
}
@@ -4091,6 +4134,16 @@ np_findTypeAttribute(LO_EmbedStruct* embed_struct)
int i;
/* Look for the TYPE attribute */
#ifdef OJI
for (i = 0; i < embed_struct->attributes.n; i++)
{
if (XP_STRCASECMP(embed_struct->attributes.names[i], "TYPE") == 0)
{
typeAttribute = embed_struct->attributes.values[i];
break;
}
}
#else
for (i = 0; i < embed_struct->attribute_cnt; i++)
{
if (XP_STRCASECMP(embed_struct->attribute_list[i], "TYPE") == 0)
@@ -4099,10 +4152,86 @@ np_findTypeAttribute(LO_EmbedStruct* embed_struct)
break;
}
}
#endif
return typeAttribute;
}
void
np_FindHandleByType(const char* typeAttribute, np_handle* *resultingHandle,
np_mimetype* *resultingMimetype)
{
np_handle* handle = NULL;
np_mimetype* mimetype = NULL;
for (handle = np_plist; handle; handle = handle->next) {
mimetype = np_getmimetype(handle, typeAttribute, FALSE);
if (mimetype) break;
}
/* No handler with an exactly-matching name, so check for a wildcard */
if (!mimetype)
{
for (handle = np_plist; handle; handle = handle->next) {
mimetype = np_getmimetype(handle, typeAttribute, TRUE);
if (mimetype) break;
}
}
*resultingHandle = handle;
*resultingMimetype = mimetype;
}
// Used by OJI to load the Java VM plugin
PR_IMPLEMENT(struct NPIPlugin*)
NPL_LoadPluginByType(const char* typeAttribute)
{
np_handle* handle = NULL;
np_mimetype* mimetype = NULL;
np_FindHandleByType(typeAttribute, &handle, &mimetype);
if (mimetype == NULL)
return NULL;
PR_ASSERT(handle);
PRBool loaded = PR_FALSE;
if (handle->refs == 0) {
// FE_Progress(cx, XP_GetString(XP_PLUGIN_LOADING_PLUGIN));
if (!(handle->f = FE_LoadPlugin(handle->pdesc, &npp_funcs, handle)))
{
// char* msg = PR_smprintf(XP_GetString(XP_PLUGIN_CANT_LOAD_PLUGIN), handle->name, mimetype->type);
// FE_Alert(cx, msg);
// XP_FREE(msg);
return NULL;
}
loaded = PR_TRUE;
#ifdef JAVA
/*
** Don't use npn_getJavaEnv here. We don't want to start the
** interpreter, just use env if it already exists.
*/
JRIEnv* env = JRI_GetCurrentEnv();
/*
** An exception could have occurred when the plugin tried to load
** it's class file. We'll print any exception to the console.
*/
if (env && JRI_ExceptionOccurred(env)) {
JRI_ExceptionDescribe(env);
JRI_ExceptionClear(env);
}
#endif
}
if (handle->userPlugin) {
// refcount was incremented
return handle->userPlugin;
}
else {
// old style plugin -- we failed so unload it
if (loaded)
FE_UnloadPlugin(handle->pdesc, handle);
return NULL;
}
}
/*
* This is called by the front-end to create a new plug-in. It will
@@ -4127,10 +4256,10 @@ NPL_EmbedCreate(MWContext* cx, LO_EmbedStruct* embed_struct)
* attach it to a new app. If there is nothing in the session
* data, then we must create both a np_data object and an app.
*/
if (embed_struct->session_data)
if (embed_struct->objTag.session_data)
{
ndata = (np_data*) embed_struct->session_data;
embed_struct->session_data = NULL;
ndata = (np_data*) embed_struct->objTag.session_data;
embed_struct->objTag.session_data = NULL;
if (ndata->state == NPDataCached) /* We cached this app, so don't create another */
{
@@ -4166,7 +4295,7 @@ NPL_EmbedCreate(MWContext* cx, LO_EmbedStruct* embed_struct)
ndata->state = NPDataNormal;
#ifdef LAYERS
if (ndata->instance) {
ndata->instance->layer = embed_struct->layer;
ndata->instance->layer = embed_struct->objTag.layer;
LO_SetEmbedType(ndata->lo_struct,
(PRBool)ndata->instance->windowed);
}
@@ -4191,11 +4320,11 @@ NPL_EmbedCreate(MWContext* cx, LO_EmbedStruct* embed_struct)
/* Make the front-end restore the embedded window from
it's saved context. */
if (! (embed_struct->ele_attrmask & LO_ELE_HIDDEN))
if (! (embed_struct->objTag.ele_attrmask & LO_ELE_HIDDEN))
FE_RestoreEmbedWindow(cx, ndata->app);
/* Tie the app to the layout struct. */
embed_struct->FE_Data = ndata->app;
embed_struct->objTag.FE_Data = ndata->app;
return ndata->app;
}
@@ -4233,11 +4362,11 @@ NPL_EmbedCreate(MWContext* cx, LO_EmbedStruct* embed_struct)
np_bindContext(app, cx);
/* Tell the front-end to create the plugin window for us. */
if (! (embed_struct->ele_attrmask & LO_ELE_HIDDEN))
if (! (embed_struct->objTag.ele_attrmask & LO_ELE_HIDDEN))
FE_CreateEmbedWindow(cx, app);
/* Attach the app to the layout info */
embed_struct->FE_Data = ndata->app;
embed_struct->objTag.FE_Data = ndata->app;
return app;
error:
@@ -4287,22 +4416,7 @@ NPL_EmbedStart(MWContext* cx, LO_EmbedStruct* embed_struct, NPEmbeddedApp* app)
app->pagePluginType = NP_Embedded;
/* Found the TYPE attribute, so look for a matching handler */
mimetype = NULL;
for (handle = np_plist; handle; handle = handle->next)
{
mimetype = np_getmimetype(handle, typeAttribute, FALSE);
if (mimetype) break;
}
/* No handler with an exactly-matching name, so check for a wildcard */
if (!mimetype)
{
for (handle = np_plist; handle; handle = handle->next)
{
mimetype = np_getmimetype(handle, typeAttribute, TRUE);
if (mimetype) break;
}
}
np_FindHandleByType(typeAttribute, &handle, &mimetype);
/*
* If we found a handler, now we can create an instance.
@@ -4389,7 +4503,7 @@ NPL_EmbedStart(MWContext* cx, LO_EmbedStruct* embed_struct, NPEmbeddedApp* app)
*/
app->pagePluginType = NP_Embedded;
if ((embed_struct->ele_attrmask & LO_ELE_STREAM_STARTED) == 0)
if ((embed_struct->objTag.ele_attrmask & LO_ELE_STREAM_STARTED) == 0)
{
URL_Struct* pURL;
pURL = NET_CreateURLStruct(theURL, NET_DONT_RELOAD);
@@ -4421,11 +4535,12 @@ error:
void
NPL_EmbedSize(NPEmbeddedApp *app)
{
if(app)
{
if (app) {
np_data *ndata = (np_data *)app->np_data;
if(ndata && ndata->instance && app->wdata)
np_setwindow(ndata->instance, app->wdata);
if (ndata && ndata->instance && app->wdata) {
PRBool success = np_setwindow(ndata->instance, app->wdata);
if (!success) return; // XXX deal with the error
}
}
}
@@ -5067,3 +5182,37 @@ static void np_ReplaceChars(char* word, char oldChar, char newChar)
#endif /* ANTHRAX */
#ifdef PLUGIN_TIMER_EVENT
static void np_SetTimerInterval(NPP npp, uint32 msecs)
{
if(npp) {
np_instance* instance = (np_instance*) npp->ndata;
if(instance)
{
instance->interval = msecs;
instance->timeout = FE_SetTimeout(np_TimerCallback, (void*)instance, instance->interval);
}
}
}
static void np_TimerCallback(void* data)
{
NPEvent event;
np_instance* instance = (np_instance*) data;
#ifdef XP_MAC
((EventRecord)event).what = nullEvent;
#elif defined(XP_WIN)
event.event = 0; // ?
#elif defined(XP_OS2)
event.event = 0; // ?
#elif defined(XP_UNIX)
// not sure what to do here
#endif
instance->timeout = FE_SetTimeout(np_TimerCallback, (void*)instance, instance->interval);
NPL_HandleEvent(instance->app, &event, NULL);
}
#endif

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -34,7 +34,9 @@ extern "C" {
#include "gui.h" /* For XP_AppCodeName */
#include "merrors.h"
#include "xpgetstr.h"
#ifdef JAVA
#include "java.h"
#endif
#include "nppriv.h"
#include "shist.h"
@@ -51,8 +53,16 @@ extern "C" {
#include "layers.h"
#endif /* LAYERS */
#include "nsAgg.h" // nsPluginManager aggregates nsJVMManager
#include "nsILCPlg.h"
#include "nsAgg.h" /* nsPluginManager aggregates nsJVMManager */
#ifdef OJI
#include "nsjvm.h"
#else /* OJI */
/* Just define a dummy struct for NPIJVMPluginManager. In the
plugin code, it is never actually dereferenced outside of an
`#ifdef OJI'. */
struct NPIJVMPluginManager;
#endif /* OJI */
extern int XP_PLUGIN_LOADING_PLUGIN;
extern int MK_BAD_CONNECT;
@@ -307,7 +317,6 @@ protected:
// aggregated sub-intefaces:
NPIJVMPluginManager* GetJVMMgr(const nsIID& aIID);
nsISupports* fJVMMgr;
};
extern nsPluginManager* thePluginManager;
@@ -344,17 +353,42 @@ public:
NS_IMETHOD_(NPPluginType)
GetMode(void);
// (Corresponds to NPP_New's argc argument.)
NS_IMETHOD_(PRUint16)
GetArgCount(void);
// Get a ptr to the paired list of attribute names and values,
// returns the length of the array.
//
// Each name or value is a null-terminated string.
//
NS_IMETHOD_(NPPluginError)
GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values);
// (Corresponds to NPP_New's argn argument.)
NS_IMETHOD_(const char**)
GetArgNames(void);
// Get the value for the named attribute. Returns null
// if the attribute was not set.
NS_IMETHOD_(const char*)
GetAttribute(const char* name);
// (Corresponds to NPP_New's argv argument.)
NS_IMETHOD_(const char**)
GetArgValues(void);
// Get a ptr to the paired list of parameter names and values,
// returns the length of the array.
//
// Each name or value is a null-terminated string.
NS_IMETHOD_(NPPluginError)
GetParameters(PRUint16& n, const char*const*& names, const char*const*& values);
// Get the value for the named parameter. Returns null
// if the parameter was not set.
NS_IMETHOD_(const char*)
GetParameter(const char* name);
// Get the complete text of the HTML tag that was
// used to instantiate this plugin
NS_IMETHOD_(const char *)
GetTagText(void);
// Get the type of the HTML tag that was used ot instantiate this
// plugin. Currently supported tags are EMBED, OBJECT and APPLET.
//
// returns a NPTagType.
NS_IMETHOD_(NPTagType)
GetTagType(void);
NS_IMETHOD_(NPIPluginManager*)
GetPluginManager(void);
@@ -409,7 +443,7 @@ public:
NS_IMETHOD_(void)
UnregisterWindow(void* window);
NS_IMETHOD_(PRInt16)
AllocateMenuID(PRBool isSubmenu);
@@ -452,7 +486,7 @@ public:
// (Corresponds to NPP_Write and NPN_Write.)
NS_IMETHOD_(PRInt32)
Write(PRInt32 len, void* buffer);
Write(PRInt32 len, const char* buffer);
////////////////////////////////////////////////////////////////////////////
// from NPIPluginManagerStream:
@@ -504,6 +538,22 @@ public:
////////////////////////////////////////////////////////////////////////////
// from NPIPluginStreamPeer:
// (Corresponds to NPStream's url field.)
NS_IMETHOD_(const char*)
GetURL(void);
// (Corresponds to NPStream's end field.)
NS_IMETHOD_(PRUint32)
GetEnd(void);
// (Corresponds to NPStream's lastmodified field.)
NS_IMETHOD_(PRUint32)
GetLastModified(void);
// (Corresponds to NPStream's notifyData field.)
NS_IMETHOD_(void*)
GetNotifyData(void);
// (Corresponds to NPP_DestroyStream's reason argument.)
NS_IMETHOD_(NPPluginReason)
GetReason(void);
@@ -514,31 +564,7 @@ public:
NS_IMETHOD_(PRUint32)
GetContentLength(void);
#if 0
NS_IMETHOD_(const char*)
GetContentEncoding(void);
NS_IMETHOD_(const char*)
GetCharSet(void);
NS_IMETHOD_(const char*)
GetBoundary(void);
NS_IMETHOD_(const char*)
GetContentName(void);
NS_IMETHOD_(time_t)
GetExpires(void);
NS_IMETHOD_(time_t)
GetLastModified(void);
NS_IMETHOD_(time_t)
GetServerDate(void);
NS_IMETHOD_(NPServerStatus)
GetServerStatus(void);
#endif
NS_IMETHOD_(PRUint32)
GetHeaderFieldCount(void);

View File

@@ -31,6 +31,8 @@
#define ISFUNCPTR(x) (x != NULL)
#define PLUGIN_TIMER_EVENT
typedef struct _np_handle np_handle;
typedef struct _np_mimetype np_mimetype;
typedef struct _np_instance np_instance;
@@ -69,7 +71,6 @@ struct _np_handle {
char *name;
char *filename;
char *description;
XP_Bool usesNewAPI;
struct NPIPlugin* userPlugin;
};
@@ -100,6 +101,12 @@ struct _np_instance {
XP_Bool transparent; /* TRUE = transparent, FALSE = opaque */
XP_Bool calling_netlib_all_the_time;
JRIGlobalRef mochaWindow;
#ifdef PLUGIN_TIMER_EVENT
void* timeout;
uint32 interval;
#endif
#ifdef LAYERS
CL_Layer *layer;
#endif /* LAYERS */

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -37,7 +37,9 @@
#include "plgindll.h"
#include "np.h"
#include "helper.h"
#ifdef JAVA
#include "java.h"
#endif
#include "edt.h"
#include "npglue.h"
@@ -446,11 +448,28 @@ void fe_RegisterPlugins(char* pszPluginDir)
CString csPluginSpec;
csPluginSpec = pszPluginDir;
#ifdef JAVA
// add directory to the java path no matter what
#if defined(xOJI) // XXX not yet -- ordering problem here between loading the vm and adding to the classpath
JVMMgr* jvmMgr = JVM_GetJVMMgr();
if (jvmMgr) {
NPIJVMPlugin* jvm = jvmMgr->GetJVM();
if (jvm) {
jvm->AddToClassPath(pszPluginDir);
}
jvmMgr->Release();
}
#elif defined(JAVA)
LJ_AddToClassPath(pszPluginDir);
#endif
if (thePluginManager == NULL) {
static NS_DEFINE_IID(kIPluginManagerIID, NP_IPLUGINMANAGER_IID);
nsresult rslt = nsPluginManager::Create(NULL, kIPluginManagerIID, (void**)&thePluginManager);
// XXX Out of memory already? This function should return an error code!
PR_ASSERT(rslt == NS_OK);
// keep going anyway...
}
csPluginSpec += "\\*.*";
#ifndef _WIN32
@@ -616,7 +635,17 @@ NPPluginFuncs* FE_LoadPlugin(void* pluginType, NPNetscapeFuncs* pNavigatorFuncs,
NPPMgtBlk* pNPMgtBlock = (NPPMgtBlk*)pluginType;
CString csPluginDir;
#ifdef OJI
char* szExplicitDLL = strrchr(pNPMgtBlock->pPluginFilename, '\\');
if( szExplicitDLL ) {
csPluginDir = pNPMgtBlock->pPluginFilename; // MFC copies the string
csPluginDir.SetAt( szExplicitDLL - pNPMgtBlock->pPluginFilename, '\0');
} else {
wfe_GetPluginsDirectory(csPluginDir);
}
#else
wfe_GetPluginsDirectory(csPluginDir);
#endif /* OJI */
LPSTR pPathSave = NULL; // storage for one dir spec
@@ -649,11 +678,7 @@ NPPluginFuncs* FE_LoadPlugin(void* pluginType, NPNetscapeFuncs* pNavigatorFuncs,
(NP_CREATEPLUGIN)PR_FindSymbol(pNPMgtBlock->pLibrary, "NP_CreatePlugin");
#endif
if (npCreatePlugin != NULL) {
if (thePluginManager == NULL) {
static NS_DEFINE_IID(kIPluginManagerIID, NP_IPLUGINMANAGER_IID);
if (nsPluginManager::Create(NULL, kIPluginManagerIID, (void**)&thePluginManager) != NS_OK)
return NULL;
}
PR_ASSERT(thePluginManager != NULL);
NPIPlugin* plugin = NULL;
NPPluginError err = npCreatePlugin(thePluginManager, &plugin);
handle->userPlugin = plugin;
@@ -775,7 +800,8 @@ void FE_UnloadPlugin(void* pluginType, struct _np_handle* handle)
// if this DLL is the last one, call its shutdown entry point
if (pNPMgtBlk->uRefCount == 0) {
if (handle->userPlugin) {
handle->userPlugin->Release();
nsrefcnt cnt = handle->userPlugin->Release();
PR_ASSERT(cnt == 0);
}
else {
// the NP_Shutdown entry point was misnamed as NP_PluginShutdown, early
@@ -804,8 +830,6 @@ void FE_UnloadPlugin(void* pluginType, struct _np_handle* handle)
}
}
// XXX Shouldn't the rest of this be inside the if statement, above?...
PR_UnloadLibrary(pNPMgtBlk->pLibrary);
pNPMgtBlk->pLibrary = NULL;

View File

@@ -755,7 +755,6 @@ public:
UnregisterWindow(void* window) = 0;
// Menu ID allocation calls for Mac:
NS_IMETHOD_(PRInt16)
AllocateMenuID(PRBool isSubmenu) = 0;

View File

@@ -1,351 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
////////////////////////////////////////////////////////////////////////////////
// Plugin Manager Methods to support the JVM Plugin API
////////////////////////////////////////////////////////////////////////////////
#include "npglue.h"
#include "prefapi.h"
#include "xp_str.h"
#include "libmocha.h"
#include "nsjvm.h"
#if 0 // XXX for now
static int PR_CALLBACK
JavaPrefChanged(const char *prefStr, void* data)
{
nsPluginManager* mgr = (nsPluginManager*)data;
PRBool prefBool;
PREF_GetBoolPref(prefStr, &prefBool);
mgr->SetJVMEnabled(prefBool);
return 0;
}
void
nsPluginManager::EnsurePrefCallbackRegistered(void)
{
if (fRegisteredJavaPrefChanged != PR_TRUE) {
fRegisteredJavaPrefChanged = PR_TRUE;
PREF_RegisterCallback("security.enable_java", JavaPrefChanged, this);
JavaPrefChanged("security.enable_java", this);
}
}
PRBool
nsPluginManager::GetJVMEnabled(void)
{
EnsurePrefCallbackRegistered();
return fJVM->GetJVMEnabled();
}
void
nsPluginManager::SetJVMEnabled(PRBool enable)
{
return fJVM->SetJVMEnabled(enable);
}
JVMStatus
nsPluginManager::GetJVMStatus(void)
{
EnsurePrefCallbackRegistered();
return fJVM->GetJVMStatus();
}
////////////////////////////////////////////////////////////////////////////////
// Should be in a header; must solve build-order problem first
extern void VR_Initialize(JRIEnv* env);
extern void SU_Initialize(JRIEnv * env);
JVMStatus
nsPluginManager::StartupJVM()
{
// Be sure to check the prefs first before asking java to startup.
if (GetJVMStatus() == JVMStatus_Disabled) {
return JVMStatus_Disabled;
}
JVMStatus status = fJVM->StartupJVM();
if (status == JVMStatus_Ok) {
JRIEnv* env = fJVM->EnsureExecEnv();
/* initialize VersionRegistry native routines */
/* it is not an error that prevents java from starting if this stuff throws exceptions */
VR_Initialize(env);
if (JRI_ExceptionOccurred(env)) {
#if DEBUG
fJVM->PrintToConsole("LJ: VR_Initialize failed. Bugs to dveditz.\n");
#endif
goto error;
}
SU_Initialize(env);
if (JRI_ExceptionOccurred(env)) {
#if DEBUG
fJVM->PrintToConsole("LJ: SU_Initialize failed. Bugs to atotic.\n");
#endif
goto error;
}
}
return status;
error:
#if DEBUG
JRI_ExceptionDescribe(env);
#endif
JRI_ExceptionClear(env);
ShutdownJVM();
return JVMStatus_JavaError;
}
JVMStatus
nsPluginManager::ShutdownJVM(PRBool fullShutdown = PR_TRUE)
{
return fJVM->ShutdownJVM();
}
#endif // 0
////////////////////////////////////////////////////////////////////////////////
void NP_LOADDS
nsPluginManager::BeginWaitCursor(void)
{
if (fWaiting == 0) {
#ifdef XP_PC
fOldCursor = (void*)GetCursor();
HCURSOR newCursor = LoadCursor(NULL, IDC_WAIT);
if (newCursor)
SetCursor(newCursor);
#endif
#ifdef XP_MAC
startAsyncCursors();
#endif
}
fWaiting++;
}
void NP_LOADDS
nsPluginManager::EndWaitCursor(void)
{
fWaiting--;
if (fWaiting == 0) {
#ifdef XP_PC
if (fOldCursor)
SetCursor((HCURSOR)fOldCursor);
#endif
#ifdef XP_MAC
stopAsyncCursors();
#endif
fOldCursor = NULL;
}
}
////////////////////////////////////////////////////////////////////////////////
const char* NP_LOADDS
nsPluginManager::GetProgramPath(void)
{
return fProgramPath;
}
const char* NP_LOADDS
nsPluginManager::GetTempDirPath(void)
{
// XXX I don't need a static really, the browser holds the tempDir name
// as a static string -- it's just the XP_TempDirName that strdups it.
static const char* tempDirName = NULL;
if (tempDirName == NULL)
tempDirName = XP_TempDirName();
return tempDirName;
}
nsresult NP_LOADDS
nsPluginManager::GetFileName(const char* fn, FileNameType type,
char* resultBuf, PRUint32 bufLen)
{
// XXX This should be rewritten so that we don't have to malloc the name.
XP_FileType filetype;
if (type == SIGNED_APPLET_DBNAME)
filetype = xpSignedAppletDB;
else if (type == TEMP_FILENAME)
filetype = xpTemporary;
else
return NS_ERROR_ILLEGAL_VALUE;
char* tempName = WH_FileName(fn, filetype);
if (tempName != NULL) return NS_ERROR_OUT_OF_MEMORY;
XP_STRNCPY_SAFE(resultBuf, tempName, bufLen);
XP_FREE(tempName);
return NS_OK;
}
nsresult NP_LOADDS
nsPluginManager::NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen)
{
// XXX This should be rewritten so that we don't have to malloc the name.
char* tempName = WH_TempName(xpTemporary, prefix);
if (tempName != NULL) return NS_ERROR_OUT_OF_MEMORY;
XP_STRNCPY_SAFE(resultBuf, tempName, bufLen);
XP_FREE(tempName);
return NS_OK;
}
PRBool NP_LOADDS
nsPluginManager::HandOffJSLock(PRThread* oldOwner, PRThread* newOwner)
{
return LM_HandOffJSLock(oldOwner, newOwner);
}
////////////////////////////////////////////////////////////////////////////
// Debugger Stuff
extern "C" HWND FindNavigatorHiddenWindow(void);
PRBool NP_LOADDS
nsPluginManager::SetDebugAgentPassword(PRInt32 pwd)
{
#if defined(XP_PC) && defined(_WIN32)
HWND win = FindNavigatorHiddenWindow();
HANDLE sem;
long err;
/* set up by aHiddenFrameClass in CNetscapeApp::InitInstance */
err = SetWindowLong(win, 0, pwd);
if (err == 0) {
// PR_LOG(NSJAVA, PR_LOG_ALWAYS,
// ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError()));
/* continue so that we try to wake up the debugger */
}
sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger");
if (sem) {
ReleaseSemaphore(sem, 1, NULL);
CloseHandle(sem);
}
return PR_TRUE;
#else
return PR_FALSE;
#endif
}
////////////////////////////////////////////////////////////////////////////////
#if 0 // XXX for now
PRBool
nsPluginManager::StartDebugger(JVMDebugPort port)
{
JVMError err = fJVM->StartDebugger(port);
if (err != JVMError_NoError) {
JRIEnv* env = fJVM->EnsureJNIEnv();
ReportJVMError(env, err);
return PR_FALSE;
}
return PR_TRUE;
}
void
nsPluginManager::ReportJVMError(JRIEnv* env, JVMError err)
{
MWContext* cx = XP_FindSomeContext();
char *s;
switch (err) {
case LJStartupError_NoClasses: {
const char* cp = CLASSPATH();
cp = lj_ConvertToPlatformPathList(cp);
s = PR_smprintf(XP_GetString(XP_JAVA_NO_CLASSES),
lj_jar_name, lj_jar_name,
(cp ? cp : "<none>"));
free((void*)cp);
break;
}
case LJStartupError_JavaError: {
const char* msg = GetJavaErrorString(env);
#ifdef DEBUG
JRI_ExceptionDescribe(env);
#endif
s = PR_smprintf(XP_GetString(XP_JAVA_STARTUP_FAILED),
(msg ? msg : ""));
if (msg) free((void*)msg);
break;
}
case LJStartupError_NoDebugger: {
s = PR_smprintf(XP_GetString(XP_JAVA_DEBUGGER_FAILED));
break;
}
default:
return; /* don't report anything */
}
if (s) {
FE_Alert(cx, s);
free(s);
}
}
/* stolen from java_lang_Object.h (jri version) */
#define classname_java_lang_Object "java/lang/Object"
#define name_java_lang_Object_toString "toString"
#define sig_java_lang_Object_toString "()Ljava/lang/String;"
const char*
nsPluginManager::GetJavaErrorString(JRIEnv* env)
{
/* XXX javah is a pain wrt mixing JRI and JDK native methods.
Since we need to call a method on Object, we'll do it the hard way
to avoid using javah for this.
Maybe we need a new JRI entry point for toString. Yikes! */
const char* msg;
struct java_lang_Class* classObject;
JRIMethodID toString;
struct java_lang_String* excString;
struct java_lang_Throwable* exc = JRI_ExceptionOccurred(env);
if (exc == NULL) {
return strdup(""); /* XXX better "no error" message? */
}
/* Got to do this before trying to find a class (like Object).
This is because the runtime refuses to do this with a pending
exception! I think it's broken. */
JRI_ExceptionClear(env);
classObject = (struct java_lang_Class*)
JRI_FindClass(env, classname_java_lang_Object);
toString = JRI_GetMethodID(env, classObject,
name_java_lang_Object_toString,
sig_java_lang_Object_toString);
excString = (struct java_lang_String *)
JRI_CallMethod(env)(env, JRI_CallMethod_op,
(struct java_lang_Object*)exc, toString);
/* XXX change to JRI_GetStringPlatformChars */
msg = JRI_GetStringPlatformChars(env, excString, NULL, 0);
if (msg == NULL) return NULL;
return strdup(msg);
}
#endif // 0
////////////////////////////////////////////////////////////////////////////////

View File

@@ -1,212 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
////////////////////////////////////////////////////////////////////////////////
// NETSCAPE JAVA VM PLUGIN EXTENSIONS
//
// This interface allows a Java virtual machine to be plugged into
// Communicator to implement the APPLET tag and host applets.
////////////////////////////////////////////////////////////////////////////////
#ifndef nsjvm_h___
#define nsjvm_h___
#include "nsplugin.h"
#include "jri.h" // XXX for now
#include "jni.h"
#include "prthread.h"
////////////////////////////////////////////////////////////////////////////////
// Java VM Plugin Manager
// This interface defines additional entry points that are available
// to JVM plugins for browsers that support JVM plugins.
class NPIJVMPluginManager : public NPIPluginManager {
public:
virtual void NP_LOADDS
BeginWaitCursor(void) = 0;
virtual void NP_LOADDS
EndWaitCursor(void) = 0;
virtual const char* NP_LOADDS
GetProgramPath(void) = 0;
virtual const char* NP_LOADDS
GetTempDirPath(void) = 0;
enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME };
virtual nsresult NP_LOADDS
GetFileName(const char* fn, FileNameType type,
char* resultBuf, PRUint32 bufLen) = 0;
virtual nsresult NP_LOADDS
NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0;
virtual PRBool NP_LOADDS
HandOffJSLock(PRThread* oldOwner, PRThread* newOwner) = 0;
////////////////////////////////////////////////////////////////////////////
// Debugger Stuff (XXX move to subclass)
virtual PRBool NP_LOADDS
SetDebugAgentPassword(PRInt32 pwd) = 0;
};
#define NP_IJVMPLUGINMANAGER_IID \
{ /* a1e5ed50-aa4a-11d1-85b2-00805f0e4dfe */ \
0xa1e5ed50, \
0xaa4a, \
0x11d1, \
{0x85, 0xb2, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
enum JVMStatus {
JVMStatus_Enabled, // but not Running
JVMStatus_Disabled, // explicitly disabled
JVMStatus_Running, // enabled and started
JVMStatus_Failed // enabled but failed to start
};
enum JVMError {
JVMError_Ok = NPPluginError_NoError,
JVMError_Base = 0x1000,
JVMError_InternalError = JVMError_Base,
JVMError_NoClasses,
JVMError_WrongClasses,
JVMError_JavaError,
JVMError_NoDebugger
};
enum JVMDebugPort {
JVMDebugPort_None = 0,
JVMDebugPort_SharedMemory = -1
// anything else is a port number
};
////////////////////////////////////////////////////////////////////////////////
// Java VM Plugin Interface
// This interface defines additional entry points that a plugin developer needs
// to implement in order to implement a Java virtual machine plugin.
class NPIJVMPlugin : public NPIPlugin {
public:
virtual JVMStatus NP_LOADDS
StartupJVM() = 0;
virtual JVMStatus NP_LOADDS
ShutdownJVM(PRBool fullShutdown = PR_TRUE) = 0;
virtual PRBool NP_LOADDS
GetJVMEnabled() = 0;
virtual void NP_LOADDS
SetJVMEnabled(PRBool enable) = 0;
virtual JVMStatus NP_LOADDS
GetJVMStatus() = 0;
// Find or create a JNIEnv for the specified thread. The thread
// parameter may be NULL indicating the current thread.
// XXX JNIEnv*
virtual JRIEnv* NP_LOADDS
EnsureExecEnv(PRThread* thread = NULL) = 0;
virtual void NP_LOADDS
AddToClassPath(const char* dirPath) = 0;
virtual void NP_LOADDS
ShowConsole() = 0;
virtual void NP_LOADDS
HideConsole() = 0;
virtual PRBool NP_LOADDS
IsConsoleVisible() = 0;
virtual void NP_LOADDS
PrintToConsole(const char* msg) = 0;
////////////////////////////////////////////////////////////////////////////
// Debugger Stuff (XXX move to subclass)
virtual JVMError NP_LOADDS
StartDebugger(JVMDebugPort port) = 0;
};
#define NP_IJVMPLUGIN_IID \
{ /* da6f3bc0-a1bc-11d1-85b1-00805f0e4dfe */ \
0xda6f3bc0, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Java VM Plugin Instance Peer Interface
// This interface provides additional hooks into the plugin manager that allow
// a plugin to implement the plugin manager's Java virtual machine.
enum NPTagAttributeName {
NPTagAttributeName_Width,
NPTagAttributeName_Height,
NPTagAttributeName_Classid,
NPTagAttributeName_Code,
NPTagAttributeName_Codebase,
NPTagAttributeName_Docbase,
NPTagAttributeName_Archive,
NPTagAttributeName_Name,
NPTagAttributeName_MayScript
};
class NPIJVMPluginInstancePeer : public NPIPluginInstancePeer {
public:
// XXX Does this overlap with GetArgNames/GetArgValues?
// XXX What happens if someone says something like:
// <object codebase=...> <param name=codebase value=...>
// Which takes precedent?
virtual char* NP_LOADDS
GetAttribute(NPTagAttributeName name) = 0;
// XXX reload method?
// Returns a unique id for the current document on which the
// plugin is displayed.
virtual PRUint32 NP_LOADDS
GetDocumentID() = 0;
};
#define NP_IJVMPLUGININSTANCEPEER_IID \
{ /* 27b42df0-a1bd-11d1-85b1-00805f0e4dfe */ \
0x27b42df0, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
#endif /* nsjvm_h___ */

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@@ -25,15 +25,21 @@
////////////////////////////////////////////////////////////////////////////////
#include "npglue.h"
#ifdef OJI
#include "nsIPlug.h"
#include "jvmmgr.h"
#endif
#include "plstr.h" /* PL_strcasecmp */
#include "xp_mem.h"
#include "xpassert.h"
#ifdef XP_MAC
#include "MacMemAllocator.h"
#endif
////////////////////////////////////////////////////////////////////////////////
// THINGS IMPLEMENTED BY THE BROWSER...
////////////////////////////////////////////////////////////////////////////////
@@ -63,6 +69,8 @@ NS_IMPL_AGGREGATED(nsPluginManager);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
#include "nsRepository.h"
NS_METHOD
nsPluginManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr)
{
@@ -206,7 +214,7 @@ nsPluginInstancePeer::AggregatedQueryInterface(const nsIID& aIID, void** aInstan
np_data* ndata = (np_data*) app->np_data;
nsresult result =
JVMInstancePeer::Create((nsISupports*)this, kISupportsIID, (void**)&fJVMInstancePeer,
cx, (struct LO_JavaAppStruct_struct*)ndata->lo_struct); // XXX wrong kind of LO_Struct!
cx, (LO_CommonPluginStruct*)ndata->lo_struct);
if (result != NS_OK) return result;
}
#endif
@@ -233,49 +241,176 @@ nsPluginInstancePeer::GetMode(void)
return (NPPluginType)instance->type;
}
NS_METHOD_(PRUint16)
nsPluginInstancePeer::GetArgCount(void)
static char* empty_list[] = { "", NULL };
NS_METHOD_(NPPluginError)
nsPluginInstancePeer::GetAttributes(PRUint16& n,
const char*const*& names,
const char*const*& values)
{
np_instance* instance = (np_instance*)npp->ndata;
#if 0
// defense
PR_ASSERT( 0 != names );
PR_ASSERT( 0 != values );
if( 0 == names || 0 == values )
return 0;
#endif
if (instance->type == NP_EMBED) {
np_data* ndata = (np_data*)instance->app->np_data;
return (PRUint16)ndata->lo_struct->attribute_cnt;
}
else {
return 1;
#ifdef OJI
names = (const char*const*)ndata->lo_struct->attributes.names;
values = (const char*const*)ndata->lo_struct->attributes.values;
n = (PRUint16)ndata->lo_struct->attributes.n;
#else
// XXX I think all the parameters and attributes just get
// munged together under MOZ_JAVA...
names = (const char*const*) ndata->lo_struct->attribute_list;
values = (const char*const*) ndata->lo_struct->value_list;
n = (PRUint16) ndata->lo_struct->attribute_cnt;
#endif
return NPPluginError_NoError;
} else {
static char _name[] = "PALETTE";
static char* _names[1];
static char _value[] = "foreground";
static char* _values[1];
_names[0] = _name;
_values[0] = _value;
names = (const char*const*) _names;
values = (const char*const*) _values;
n = 1;
return NPPluginError_NoError;
}
// random, sun-spot induced error
PR_ASSERT( 0 );
n = 0;
// const char* const* empty_list = { { '\0' } };
names = values = empty_list;
return NPPluginError_GenericError;
}
NS_METHOD_(const char**)
nsPluginInstancePeer::GetArgNames(void)
NS_METHOD_(const char*)
nsPluginInstancePeer::GetAttribute(const char* name)
{
np_instance* instance = (np_instance*)npp->ndata;
if (instance->type == NP_EMBED) {
np_data* ndata = (np_data*)instance->app->np_data;
return (const char**)ndata->lo_struct->attribute_list;
}
else {
static char name[] = "PALETTE";
static char* names[1];
names[0] = name;
return (const char**)names;
PRUint16 nAttrs, i;
const char*const* names;
const char*const* values;
if( NPCallFailed( GetAttributes( nAttrs, names, values )) )
return 0;
for( i = 0; i < nAttrs; i++ ) {
if( PL_strcasecmp( name, names[i] ) == 0 )
return values[i];
}
return 0;
}
NS_METHOD_(const char**)
nsPluginInstancePeer::GetArgValues(void)
NS_METHOD_(NPPluginError)
nsPluginInstancePeer::GetParameters(PRUint16& n,
const char*const*& names,
const char*const*& values)
{
np_instance* instance = (np_instance*)npp->ndata;
if (instance->type == NP_EMBED) {
np_data* ndata = (np_data*)instance->app->np_data;
return (const char**)ndata->lo_struct->value_list;
#ifdef OJI
names = (const char*const*)ndata->lo_struct->parameters.names;
values = (const char*const*)ndata->lo_struct->parameters.values;
n = (PRUint16)ndata->lo_struct->parameters.n;
#else
// XXX I think all the parameters and attributes just get
// munged together under MOZ_JAVA...
names = (const char*const*) ndata->lo_struct->attribute_list;
values = (const char*const*) ndata->lo_struct->value_list;
n = (PRUint16)ndata->lo_struct->attribute_cnt;
#endif
return NPPluginError_NoError;
} else {
static char _name[] = "PALETTE";
static char* _names[1];
static char _value[] = "foreground";
static char* _values[1];
_names[0] = _name;
_values[0] = _value;
names = (const char*const*) _names;
values = (const char*const*) _values;
n = 1;
return NPPluginError_NoError;
}
else {
static char value[] = "foreground";
static char* values[1];
values[0] = value;
return (const char**)values;
// random, sun-spot induced error
PR_ASSERT( 0 );
n = 0;
// static const char* const* empty_list = { { '\0' } };
names = values = empty_list;
return NPPluginError_GenericError;
}
NS_METHOD_(const char*)
nsPluginInstancePeer::GetParameter(const char* name)
{
PRUint16 nParams, i;
const char*const* names;
const char*const* values;
if( NPCallFailed( GetParameters( nParams, names, values )) )
return 0;
for( i = 0; i < nParams; i++ ) {
if( PL_strcasecmp( name, names[i] ) == 0 )
return values[i];
}
return 0;
}
NS_METHOD_(NPTagType)
nsPluginInstancePeer::GetTagType(void)
{
#ifdef XXX
switch (fLayoutElement->lo_element.type) {
case LO_JAVA:
return NPTagType_Applet;
case LO_EMBED:
return NPTagType_Embed;
case LO_OBJECT:
return NPTagType_Object;
default:
return NPTagType_Unknown;
}
#endif
return NPTagType_Unknown;
}
NS_METHOD_(const char *)
nsPluginInstancePeer::GetTagText(void)
{
// XXX
return NULL;
}
NS_METHOD_(NPIPluginManager*)
@@ -310,7 +445,12 @@ nsPluginInstancePeer::NewStream(nsMIMEType type, const char* target,
{
NPStream* pstream;
NPPluginError err = (NPPluginError)
npn_newstream(npp, (char*)type, (char*)target, &pstream);
#ifdef OJI
npn_newstream(npp, const_cast<char*>(type),
const_cast<char*>(target), &pstream);
#else
npn_newstream(npp, (char*)type,(char*)target, &pstream);
#endif
if (err != NPPluginError_NoError)
return err;
*result = new nsPluginManagerStream(npp, pstream);
@@ -362,19 +502,23 @@ nsPluginInstancePeer::ForceRedraw(void)
NS_METHOD_(void)
nsPluginInstancePeer::RegisterWindow(void* window)
{
npn_registerwindow(npp, window);
npn_registerwindow(npp, window);
}
NS_METHOD_(void)
nsPluginInstancePeer::UnregisterWindow(void* window)
{
npn_unregisterwindow(npp, window);
npn_unregisterwindow(npp, window);
}
NS_METHOD_(PRInt16)
nsPluginInstancePeer::AllocateMenuID(PRBool isSubmenu)
{
return npn_allocateMenuID(npp, isSubmenu);
#ifdef XP_MAC
return npn_allocateMenuID(npp, isSubmenu);
#else
return -1;
#endif
}
NS_METHOD_(jref)
@@ -396,6 +540,8 @@ nsPluginManagerStream::nsPluginManagerStream(NPP npp, NPStream* pstr)
nsPluginManagerStream::~nsPluginManagerStream(void)
{
NPError err = npn_destroystream(npp, pstream, NPPluginReason_Done);
PR_ASSERT(err == NPPluginError_NoError);
}
NS_METHOD_(PRInt32)
@@ -407,9 +553,9 @@ nsPluginManagerStream::WriteReady(void)
}
NS_METHOD_(PRInt32)
nsPluginManagerStream::Write(PRInt32 len, void* buffer)
nsPluginManagerStream::Write(PRInt32 len, const char* buffer)
{
return npn_write(npp, pstream, len, buffer);
return npn_write(npp, pstream, len, (void*)buffer);
}
NS_METHOD_(const char*)
@@ -453,6 +599,34 @@ nsPluginStreamPeer::nsPluginStreamPeer(URL_Struct *urls, np_stream *stream)
nsPluginStreamPeer::~nsPluginStreamPeer(void)
{
#if 0
NPError err = npn_destroystream(stream->instance->npp, stream->pstream, reason);
PR_ASSERT(err == NPPluginError_NoError);
#endif
}
NS_METHOD_(const char*)
nsPluginStreamPeer::GetURL(void)
{
return stream->pstream->url;
}
NS_METHOD_(PRUint32)
nsPluginStreamPeer::GetEnd(void)
{
return stream->pstream->end;
}
NS_METHOD_(PRUint32)
nsPluginStreamPeer::GetLastModified(void)
{
return stream->pstream->lastmodified;
}
NS_METHOD_(void*)
nsPluginStreamPeer::GetNotifyData(void)
{
return stream->pstream->notifyData;
}
NS_METHOD_(NPPluginReason)

View File

@@ -1,939 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
////////////////////////////////////////////////////////////////////////////////
// INTERFACE TO NETSCAPE COMMUNICATOR PLUGINS (NEW C++ API).
//
// This superscedes the old plugin API (npapi.h, npupp.h), and
// eliminates the need for glue files: npunix.c, npwin.cpp and npmac.cpp.
// Correspondences to the old API are shown throughout the file.
////////////////////////////////////////////////////////////////////////////////
// XXX THIS HEADER IS A BETA VERSION OF THE NEW PLUGIN INTERFACE.
// USE ONLY FOR EXPERIMENTAL PURPOSES!
#ifndef nsplugin_h___
#define nsplugin_h___
#ifdef __OS2__
#pragma pack(1)
#endif
// XXX Move this XP_ defining stuff to xpcom or nspr...
#if defined (__OS2__ ) || defined (OS2)
# ifndef XP_OS2
# define XP_OS2 1
# endif /* XP_OS2 */
#endif /* __OS2__ */
#ifdef _WINDOWS
# ifndef XP_WIN
# define XP_WIN 1
# endif /* XP_WIN */
#endif /* _WINDOWS */
#ifdef __MWERKS__
# define _declspec __declspec
# ifdef macintosh
# ifndef XP_MAC
# define XP_MAC 1
# endif /* XP_MAC */
# endif /* macintosh */
# ifdef __INTEL__
# undef NULL
# ifndef XP_WIN
# define XP_WIN 1
# endif /* __INTEL__ */
# endif /* XP_PC */
#endif /* __MWERKS__ */
#ifdef XP_MAC
#include <Quickdraw.h>
#include <Events.h>
#endif
#ifdef XP_UNIX
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#endif
#include "jri.h" // XXX change to jni.h
#include "nsISupports.h"
////////////////////////////////////////////////////////////////////////////////
/* The OS/2 version of Netscape uses RC_DATA to define the
mime types, file extentions, etc that are required.
Use a vertical bar to seperate types, end types with \0.
FileVersion and ProductVersion are 32bit ints, all other
entries are strings the MUST be terminated wwith a \0.
AN EXAMPLE:
RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
RCDATA NP_INFO_MIMEType { "video/x-video|",
"video/x-flick\0" }
RCDATA NP_INFO_FileExtents { "avi|",
"flc\0" }
RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
"MMOS2 Flc/Fli player(*.flc)\0" }
RCDATA NP_INFO_FileVersion { 1,0,0,1 }
RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
RCDATA NP_INFO_InternalName { "NPAVI32\0" )
RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
*/
/* RC_DATA types for version info - required */
#define NP_INFO_ProductVersion 1
#define NP_INFO_MIMEType 2
#define NP_INFO_FileOpenName 3
#define NP_INFO_FileExtents 4
/* RC_DATA types for version info - used if found */
#define NP_INFO_FileDescription 5
#define NP_INFO_ProductName 6
/* RC_DATA types for version info - optional */
#define NP_INFO_CompanyName 7
#define NP_INFO_FileVersion 8
#define NP_INFO_InternalName 9
#define NP_INFO_LegalCopyright 10
#define NP_INFO_OriginalFilename 11
#ifndef RC_INVOKED
////////////////////////////////////////////////////////////////////////////////
// Structures and definitions
#ifdef XP_MAC
#pragma options align=mac68k
#endif
typedef const char* nsMIMEType;
struct nsByteRange {
PRInt32 offset; /* negative offset means from the end */
PRUint32 length;
struct nsByteRange* next;
};
struct nsRect {
PRUint16 top;
PRUint16 left;
PRUint16 bottom;
PRUint16 right;
};
////////////////////////////////////////////////////////////////////////////////
// Unix specific structures and definitions
#ifdef XP_UNIX
/*
* Callback Structures.
*
* These are used to pass additional platform specific information.
*/
enum NPPluginCallbackType {
NPPluginCallbackType_SetWindow = 1,
NPPluginCallbackType_Print
};
struct NPPluginAnyCallbackStruct {
PRInt32 type;
};
struct NPPluginSetWindowCallbackStruct {
PRInt32 type;
Display* display;
Visual* visual;
Colormap colormap;
PRUint32 depth;
};
struct NPPluginPrintCallbackStruct {
PRInt32 type;
FILE* fp;
};
#endif /* XP_UNIX */
////////////////////////////////////////////////////////////////////////////////
// List of variable names for which NPP_GetValue shall be implemented
enum NPPluginVariable {
NPPluginVariable_NameString = 1,
NPPluginVariable_DescriptionString,
NPPluginVariable_WindowBool, // XXX go away
NPPluginVariable_TransparentBool, // XXX go away?
NPPluginVariable_JavaClass, // XXX go away
NPPluginVariable_WindowSize
// XXX add MIMEDescription (for unix) (but GetValue is on the instance, not the class)
};
// List of variable names for which NPN_GetValue is implemented by Mozilla
enum NPPluginManagerVariable {
NPPluginManagerVariable_XDisplay = 1,
NPPluginManagerVariable_XtAppContext,
NPPluginManagerVariable_NetscapeWindow,
NPPluginManagerVariable_JavascriptEnabledBool, // XXX prefs accessor api
NPPluginManagerVariable_ASDEnabledBool, // XXX prefs accessor api
NPPluginManagerVariable_IsOfflineBool // XXX prefs accessor api
};
////////////////////////////////////////////////////////////////////////////////
enum NPPluginType {
NPPluginType_Embedded = 1,
NPPluginType_Full
};
// XXX this can go away now
enum NPStreamType {
NPStreamType_Normal = 1,
NPStreamType_Seek,
NPStreamType_AsFile,
NPStreamType_AsFileOnly
};
#define NP_STREAM_MAXREADY (((unsigned)(~0)<<1)>>1)
/*
* The type of a NPWindow - it specifies the type of the data structure
* returned in the window field.
*/
enum NPPluginWindowType {
NPPluginWindowType_Window = 1,
NPPluginWindowType_Drawable
};
struct NPPluginWindow {
void* window; /* Platform specific window handle */
/* OS/2: x - Position of bottom left corner */
/* OS/2: y - relative to visible netscape window */
PRUint32 x; /* Position of top left corner relative */
PRUint32 y; /* to a netscape page. */
PRUint32 width; /* Maximum window size */
PRUint32 height;
nsRect clipRect; /* Clipping rectangle in port coordinates */
/* Used by MAC only. */
#ifdef XP_UNIX
void* ws_info; /* Platform-dependent additonal data */
#endif /* XP_UNIX */
NPPluginWindowType type; /* Is this a window or a drawable? */
};
struct NPPluginFullPrint {
PRBool pluginPrinted; /* Set TRUE if plugin handled fullscreen */
/* printing */
PRBool printOne; /* TRUE if plugin should print one copy */
/* to default printer */
void* platformPrint; /* Platform-specific printing info */
};
struct NPPluginEmbedPrint {
NPPluginWindow window;
void* platformPrint; /* Platform-specific printing info */
};
struct NPPluginPrint {
NPPluginType mode; /* NP_FULL or NPPluginType_Embedded */
union
{
NPPluginFullPrint fullPrint; /* if mode is NP_FULL */
NPPluginEmbedPrint embedPrint; /* if mode is NPPluginType_Embedded */
} print;
};
struct NPPluginEvent {
#if defined(XP_MAC)
EventRecord* event;
void* window;
#elif defined(XP_WIN)
uint16 event;
uint32 wParam;
uint32 lParam;
#elif defined(XP_OS2)
uint32 event;
uint32 wParam;
uint32 lParam;
#elif defined(XP_UNIX)
XEvent event;
#endif
};
#ifdef XP_MAC
typedef RgnHandle nsRegion;
#elif defined(XP_WIN)
typedef HRGN nsRegion;
#elif defined(XP_UNIX)
typedef Region nsRegion;
#else
typedef void *nsRegion;
#endif /* XP_MAC */
////////////////////////////////////////////////////////////////////////////////
// Mac-specific structures and definitions.
#ifdef XP_MAC
struct NPPort {
CGrafPtr port; /* Grafport */
PRInt32 portx; /* position inside the topmost window */
PRInt32 porty;
};
/*
* Non-standard event types that can be passed to HandleEvent
*/
#define getFocusEvent (osEvt + 16)
#define loseFocusEvent (osEvt + 17)
#define adjustCursorEvent (osEvt + 18)
#define menuCommandEvent (osEvt + 19)
#endif /* XP_MAC */
////////////////////////////////////////////////////////////////////////////////
// Error and Reason Code definitions
enum NPPluginError {
NPPluginError_Base = 0,
NPPluginError_NoError = 0,
NPPluginError_GenericError,
NPPluginError_InvalidInstanceError,
NPPluginError_InvalidFunctableError,
NPPluginError_ModuleLoadFailedError,
NPPluginError_OutOfMemoryError,
NPPluginError_InvalidPluginError,
NPPluginError_InvalidPluginDirError,
NPPluginError_IncompatibleVersionError,
NPPluginError_InvalidParam,
NPPluginError_InvalidUrl,
NPPluginError_FileNotFound,
NPPluginError_NoData,
NPPluginError_StreamNotSeekable
};
enum NPPluginReason {
NPPluginReason_Base = 0,
NPPluginReason_Done = 0,
NPPluginReason_NetworkErr,
NPPluginReason_UserBreak,
NPPluginReason_NoReason
};
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
class NPIStream; // base class for all streams
// Classes that must be implemented by the plugin DLL:
class NPIPlugin; // plugin class (MIME-type handler)
class NPILiveConnectPlugin; // subclass of NPIPlugin
class NPIPluginInstance; // plugin instance
class NPIPluginStream; // stream to receive data from the browser
// Classes that are implemented by the browser:
class NPIPluginManager; // minimum browser requirements
class NPIPluginManagerStream; // stream to send data to the browser
class NPIPluginInstancePeer; // parts of NPIPluginInstance implemented by the browser
class NPILiveConnectPluginInstancePeer; // subclass of NPIPluginInstancePeer
class NPIPluginStreamPeer; // parts of NPIPluginStream implemented by the browser
class NPISeekablePluginStreamPeer; // seekable subclass of NPIPluginStreamPeer
// Plugin DLL Side Browser Side
//
//
// +-----------+ +-----------------------+
// | Plugin / | | Plugin Manager |
// | LC Plugin | | |
// +-----------+ +-----------------------+
// ^ ^
// | |
// | +-----------------------+
// | | Plugin Manager Stream |
// | +-----------------------+
// |
// |
// +-----------------+ peer +-----------------------+
// | Plugin Instance |---------->| Plugin Instance Peer |
// | | | / LC Plugin Inst Peer |
// +-----------------+ +-----------------------+
//
// +-----------------+ peer +-----------------------+
// | Plugin Stream |---------->| Plugin Stream Peer / |
// | | | Seekable P Stream Peer|
// +-----------------+ +-----------------------+
////////////////////////////////////////////////////////////////////////////////
// This is the main entry point to the plugin's DLL. The plugin manager finds
// this symbol and calls it to create the plugin class. Once the plugin object
// is returned to the plugin manager, instances on the page are created by
// calling NPIPlugin::NewInstance.
// (Corresponds to NPP_Initialize.)
extern "C" NS_EXPORT NPPluginError
NP_CreatePlugin(NPIPluginManager* mgr, NPIPlugin* *result);
////////////////////////////////////////////////////////////////////////////////
// Plugin Stream Interface
// This base class is shared by both the plugin and the plugin manager.
class NPIStream : public nsISupports {
public:
// The Release method on NPIPlugin corresponds to NPP_DestroyStream.
// (Corresponds to NPP_WriteReady.)
NS_IMETHOD_(PRInt32)
WriteReady(void) = 0;
// (Corresponds to NPP_Write and NPN_Write.)
NS_IMETHOD_(PRInt32)
Write(PRInt32 len, void* buffer) = 0;
};
#define NP_ISTREAM_IID \
{ /* 5d852ef0-a1bc-11d1-85b1-00805f0e4dfe */ \
0x5d852ef0, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// THINGS THAT MUST BE IMPLEMENTED BY THE PLUGIN...
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Plugin Interface
// This is the minimum interface plugin developers need to support in order to
// implement a plugin. The plugin manager may QueryInterface for more specific
// plugin types, e.g. NPILiveConnectPlugin.
class NPIPlugin : public nsISupports {
public:
// The Release method on NPIPlugin corresponds to NPP_Shutdown.
// The old NPP_New call has been factored into two plugin instance methods:
//
// NewInstance -- called once, after the plugin instance is created. This
// method is used to initialize the new plugin instance (although the actual
// plugin instance object will be created by the plugin manager).
//
// NPIPluginInstance::Start -- called when the plugin instance is to be
// started. This happens in two circumstances: (1) after the plugin instance
// is first initialized, and (2) after a plugin instance is returned to
// (e.g. by going back in the window history) after previously being stopped
// by the Stop method.
NS_IMETHOD_(NPPluginError)
NewInstance(NPIPluginInstancePeer* peer, NPIPluginInstance* *result) = 0;
#ifdef XP_UNIX // XXX why can't this be XP?
// (Corresponds to NPP_GetMIMEDescription.)
NS_IMETHOD_(const char*)
GetMIMEDescription(void) = 0;
#endif /* XP_UNIX */
};
#define NP_IPLUGIN_IID \
{ /* 8a623430-a1bc-11d1-85b1-00805f0e4dfe */ \
0x8a623430, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// LiveConnect Plugin Interface
// This interface defines additional entry points that a plugin developer needs
// to implement in order for the plugin to support LiveConnect, i.e. be
// scriptable by Java or JavaScript.
class NPILiveConnectPlugin : public NPIPlugin {
public:
// (Corresponds to NPP_GetJavaClass.)
NS_IMETHOD_(jclass)
GetJavaClass(void) = 0;
};
#define NP_ILIVECONNECTPLUGIN_IID \
{ /* cf134df0-a1bc-11d1-85b1-00805f0e4dfe */ \
0xcf134df0, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Plugin Instance Interface
// (Corresponds to NPP object.)
class NPIPluginInstance : public nsISupports {
public:
// The Release method on NPIPluginInstance corresponds to NPP_Destroy.
// See comment for NPIPlugin::NewInstance, above.
NS_IMETHOD_(NPPluginError)
Start(void) = 0;
// The old NPP_Destroy call has been factored into two plugin instance
// methods:
//
// Stop -- called when the plugin instance is to be stopped (e.g. by
// displaying another plugin manager window, causing the page containing
// the plugin to become removed from the display).
//
// Release -- called once, before the plugin instance peer is to be
// destroyed. This method is used to destroy the plugin instance.
NS_IMETHOD_(NPPluginError)
Stop(void) = 0;
// (Corresponds to NPP_SetWindow.)
NS_IMETHOD_(NPPluginError)
SetWindow(NPPluginWindow* window) = 0;
// (Corresponds to NPP_NewStream.)
NS_IMETHOD_(NPPluginError)
NewStream(NPIPluginStreamPeer* peer, NPIPluginStream* *result) = 0;
// (Corresponds to NPP_Print.)
NS_IMETHOD_(void)
Print(NPPluginPrint* platformPrint) = 0;
// (Corresponds to NPP_HandleEvent.)
// Note that for Unix and Mac the NPPluginEvent structure is different
// from the old NPEvent structure -- it's no longer the native event
// record, but is instead a struct. This was done for future extensibility,
// and so that the Mac could receive the window argument too. For Windows
// and OS2, it's always been a struct, so there's no change for them.
NS_IMETHOD_(PRInt16)
HandleEvent(NPPluginEvent* event) = 0;
// (Corresponds to NPP_URLNotify.)
NS_IMETHOD_(void)
URLNotify(const char* url, const char* target,
NPPluginReason reason, void* notifyData) = 0;
// (Corresponds to NPP_GetValue.)
NS_IMETHOD_(NPPluginError)
GetValue(NPPluginVariable variable, void *value) = 0;
// (Corresponds to NPP_SetValue.)
NS_IMETHOD_(NPPluginError)
SetValue(NPPluginManagerVariable variable, void *value) = 0;
};
#define NP_IPLUGININSTANCE_IID \
{ /* b62f3a10-a1bc-11d1-85b1-00805f0e4dfe */ \
0xb62f3a10, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Plugin Stream Interface
class NPIPluginStream : public NPIStream {
public:
// (Corresponds to NPP_NewStream's stype return parameter.)
NS_IMETHOD_(NPStreamType)
GetStreamType(void) = 0;
// (Corresponds to NPP_StreamAsFile.)
NS_IMETHOD_(void)
AsFile(const char* fname) = 0;
};
#define NP_IPLUGINSTREAM_IID \
{ /* e7a97340-a1bc-11d1-85b1-00805f0e4dfe */ \
0xe7a97340, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// THINGS IMPLEMENTED BY THE BROWSER...
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Plugin Manager Interface
// This interface defines the minimum set of functionality that a plugin
// manager will support if it implements plugins. Plugin implementations can
// QueryInterface to determine if a plugin manager implements more specific
// APIs for the plugin to use.
class NPIPluginManager : public nsISupports {
public:
// QueryInterface may be used to obtain a JRIEnv or JNIEnv
// from an NPIPluginManager.
// (Corresponds to NPN_GetJavaEnv.)
// (Corresponds to NPN_ReloadPlugins.)
NS_IMETHOD_(void)
ReloadPlugins(PRBool reloadPages) = 0;
// (Corresponds to NPN_MemAlloc.)
NS_IMETHOD_(void*)
MemAlloc(PRUint32 size) = 0;
// (Corresponds to NPN_MemFree.)
NS_IMETHOD_(void)
MemFree(void* ptr) = 0;
// (Corresponds to NPN_MemFlush.)
NS_IMETHOD_(PRUint32)
MemFlush(PRUint32 size) = 0;
};
#define NP_IPLUGINMANAGER_IID \
{ /* f10b9600-a1bc-11d1-85b1-00805f0e4dfe */ \
0xf10b9600, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
#define NP_IJRIENV_IID \
{ /* f9d4ea00-a1bc-11d1-85b1-00805f0e4dfe */ \
0xf9d4ea00, \
0xa1bc, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
#define NP_IJNIENV_IID \
{ /* 04610650-a1bd-11d1-85b1-00805f0e4dfe */ \
0x04610650, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Plugin Instance Peer Interface
class NPIPluginInstancePeer : public nsISupports {
public:
NS_IMETHOD_(NPIPlugin*)
GetClass(void) = 0;
// (Corresponds to NPP_New's MIMEType argument.)
NS_IMETHOD_(nsMIMEType)
GetMIMEType(void) = 0;
// (Corresponds to NPP_New's mode argument.)
NS_IMETHOD_(NPPluginType)
GetMode(void) = 0;
// (Corresponds to NPP_New's argc argument.)
NS_IMETHOD_(PRUint16)
GetArgCount(void) = 0;
// (Corresponds to NPP_New's argn argument.)
NS_IMETHOD_(const char**)
GetArgNames(void) = 0;
// (Corresponds to NPP_New's argv argument.)
NS_IMETHOD_(const char**)
GetArgValues(void) = 0;
NS_IMETHOD_(NPIPluginManager*)
GetPluginManager(void) = 0;
// (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
// notifyData: When present, URLNotify is called passing the notifyData back
// to the client. When NULL, this call behaves like NPN_GetURL.
// New arguments:
// altHost: An IP-address string that will be used instead of the host
// specified in the URL. This is used to prevent DNS-spoofing attacks.
// Can be defaulted to NULL meaning use the host in the URL.
// referrer:
// forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs,
// even if the user currently has JavaScript disabled.
NS_IMETHOD_(NPPluginError)
GetURL(const char* url, const char* target, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE) = 0;
// (Corresponds to NPN_PostURL and NPN_PostURLNotify.)
// notifyData: When present, URLNotify is called passing the notifyData back
// to the client. When NULL, this call behaves like NPN_GetURL.
// New arguments:
// altHost: An IP-address string that will be used instead of the host
// specified in the URL. This is used to prevent DNS-spoofing attacks.
// Can be defaulted to NULL meaning use the host in the URL.
// referrer:
// forceJSEnabled: Forces JavaScript to be enabled for 'javascript:' URLs,
// even if the user currently has JavaScript disabled.
// postHeaders: A string containing post headers.
// postHeadersLength: The length of the post headers string.
NS_IMETHOD_(NPPluginError)
PostURL(const char* url, const char* target, PRUint32 bufLen,
const char* buf, PRBool file, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
// (Corresponds to NPN_NewStream.)
NS_IMETHOD_(NPPluginError)
NewStream(nsMIMEType type, const char* target,
NPIPluginManagerStream* *result) = 0;
// (Corresponds to NPN_Status.)
NS_IMETHOD_(void)
ShowStatus(const char* message) = 0;
// (Corresponds to NPN_UserAgent.)
NS_IMETHOD_(const char*)
UserAgent(void) = 0;
// (Corresponds to NPN_GetValue.)
NS_IMETHOD_(NPPluginError)
GetValue(NPPluginManagerVariable variable, void *value) = 0;
// (Corresponds to NPN_SetValue.)
NS_IMETHOD_(NPPluginError)
SetValue(NPPluginVariable variable, void *value) = 0;
////////////////////////////////////////////////////////////////////////////
// XXX Only used by windowless plugin instances?...
// (Corresponds to NPN_InvalidateRect.)
NS_IMETHOD_(void)
InvalidateRect(nsRect *invalidRect) = 0;
// (Corresponds to NPN_InvalidateRegion.)
NS_IMETHOD_(void)
InvalidateRegion(nsRegion invalidRegion) = 0;
// (Corresponds to NPN_ForceRedraw.)
NS_IMETHOD_(void)
ForceRedraw(void) = 0;
// New top-level window handling calls for Mac:
NS_IMETHOD_(void)
RegisterWindow(void* window) = 0;
NS_IMETHOD_(void)
UnregisterWindow(void* window) = 0;
// Menu ID allocation calls for Mac:
NS_IMETHOD_(PRInt16)
AllocateMenuID(PRBool isSubmenu) = 0;
};
#define NP_IPLUGININSTANCEPEER_IID \
{ /* 15c75de0-a1bd-11d1-85b1-00805f0e4dfe */ \
0x15c75de0, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// LiveConnect Plugin Instance Peer Interface
// Browsers that support LiveConnect implement this subclass of plugin instance
// peer.
// XXX Should this really be a separate subclass?
class NPILiveConnectPluginInstancePeer : public NPIPluginInstancePeer {
public:
// (Corresponds to NPN_GetJavaPeer.)
NS_IMETHOD_(jobject)
GetJavaPeer(void) = 0;
};
#define NP_ILIVECONNECTPLUGININSTANCEPEER_IID \
{ /* 1e3502a0-a1bd-11d1-85b1-00805f0e4dfe */ \
0x1e3502a0, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Plugin Manager Stream Interface
class NPIPluginManagerStream : public NPIStream {
public:
// (Corresponds to NPStream's url field.)
NS_IMETHOD_(const char*)
GetURL(void) = 0;
// (Corresponds to NPStream's end field.)
NS_IMETHOD_(PRUint32)
GetEnd(void) = 0;
// (Corresponds to NPStream's lastmodified field.)
NS_IMETHOD_(PRUint32)
GetLastModified(void) = 0;
// (Corresponds to NPStream's notifyData field.)
NS_IMETHOD_(void*)
GetNotifyData(void) = 0;
};
#define NP_IPLUGINMANAGERSTREAM_IID \
{ /* 30c24560-a1bd-11d1-85b1-00805f0e4dfe */ \
0x30c24560, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Plugin Stream Peer Interface
// A plugin stream peer is passed to a plugin instance's NewStream call in
// order to indicate that a new stream is to be created and be read by the
// plugin instance.
class NPIPluginStreamPeer : public nsISupports {
public:
// (Corresponds to NPP_DestroyStream's reason argument.)
NS_IMETHOD_(NPPluginReason)
GetReason(void) = 0;
// (Corresponds to NPP_NewStream's MIMEType argument.)
NS_IMETHOD_(nsMIMEType)
GetMIMEType(void) = 0;
NS_IMETHOD_(PRUint32)
GetContentLength(void) = 0;
#if 0
NS_IMETHOD_(const char*)
GetContentEncoding(void) = 0;
NS_IMETHOD_(const char*)
GetCharSet(void) = 0;
NS_IMETHOD_(const char*)
GetBoundary(void) = 0;
NS_IMETHOD_(const char*)
GetContentName(void) = 0;
NS_IMETHOD_(time_t)
GetExpires(void) = 0;
NS_IMETHOD_(time_t)
GetLastModified(void) = 0;
NS_IMETHOD_(time_t)
GetServerDate(void) = 0;
NS_IMETHOD_(NPServerStatus)
GetServerStatus(void) = 0;
#endif
NS_IMETHOD_(PRUint32)
GetHeaderFieldCount(void) = 0;
NS_IMETHOD_(const char*)
GetHeaderFieldKey(PRUint32 index) = 0;
NS_IMETHOD_(const char*)
GetHeaderField(PRUint32 index) = 0;
};
#define NP_IPLUGINSTREAMPEER_IID \
{ /* 38278eb0-a1bd-11d1-85b1-00805f0e4dfe */ \
0x38278eb0, \
0xa1bd, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
}
////////////////////////////////////////////////////////////////////////////////
// Seekable Plugin Stream Peer Interface
// The browser implements this subclass of plugin stream peer if a stream
// is seekable. Plugins can query interface for this type, and call the
// RequestRead method to seek to a particular position in the stream.
class NPISeekablePluginStreamPeer : public NPIPluginStreamPeer {
public:
// QueryInterface for this class corresponds to NPP_NewStream's
// seekable argument.
// (Corresponds to NPN_RequestRead.)
NS_IMETHOD_(NPPluginError)
RequestRead(nsByteRange* rangeList) = 0;
};
#define NP_ISEEKABLEPLUGINSTREAMPEER_IID \
{ /* f55c8250-a73e-11d1-85b1-00805f0e4dfe */ \
0xf55c8250, \
0xa73e, \
0x11d1, \
{0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
} \
////////////////////////////////////////////////////////////////////////////////
#ifdef XP_MAC
#pragma options align=reset
#endif
#endif /* RC_INVOKED */
#ifdef __OS2__
#pragma pack()
#endif
#endif /* nsplugin_h___ */