Not part of the build. Adding files needed for the layout-debug object

This commit is contained in:
dcone%netscape.com 2002-03-12 22:29:58 +00:00
Родитель 5d9debacdd
Коммит 1caa14a4f9
4 изменённых файлов: 929 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,44 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..\..\..
include <$(DEPTH)\config\config.mak>
MAKE_OBJ_TYPE = LIB
LIBRARY_NAME = plugingate
LIB=.\$(OBJDIR)\$(LIBRARY_NAME).lib
CFLAGS = $(CFLAGS) -I..\include -I..\..\include
OBJS = \
.\$(OBJDIR)\npn_gate.obj \
.\$(OBJDIR)\npp_gate.obj \
.\$(OBJDIR)\np_entry.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
# it will export the lib to the dist/lib dir, so do not forget to remove it
libs:: $(LIB)
$(RM) $(DIST)\lib\$(LIBRARY_NAME).lib
clobber::
$(RM) *.sbr

Просмотреть файл

@ -0,0 +1,316 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//////////////////////////////////////////////////////////////
//
// Main plugin entry point implementation -- exports from the
// plugin library
//
#include "npplat.h"
#include "pluginbase.h"
NPNetscapeFuncs NPNFuncs;
NPError OSCALL NP_Shutdown()
{
NS_PluginShutdown();
return NPERR_NO_ERROR;
}
static NPError fillPluginFunctionTable(NPPluginFuncs* aNPPFuncs)
{
if(aNPPFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
// Set up the plugin function table that Netscape will use to
// call us. Netscape needs to know about our version and size
// and have a UniversalProcPointer for every function we implement.
aNPPFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
#ifdef XP_MAC
aNPPFuncs->newp = NewNPP_NewProc(Private_New);
aNPPFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
aNPPFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
aNPPFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
aNPPFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
aNPPFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
aNPPFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
aNPPFuncs->write = NewNPP_WriteProc(Private_Write);
aNPPFuncs->print = NewNPP_PrintProc(Private_Print);
aNPPFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
aNPPFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
aNPPFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
aNPPFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
#else
aNPPFuncs->newp = NPP_New;
aNPPFuncs->destroy = NPP_Destroy;
aNPPFuncs->setwindow = NPP_SetWindow;
aNPPFuncs->newstream = NPP_NewStream;
aNPPFuncs->destroystream = NPP_DestroyStream;
aNPPFuncs->asfile = NPP_StreamAsFile;
aNPPFuncs->writeready = NPP_WriteReady;
aNPPFuncs->write = NPP_Write;
aNPPFuncs->print = NPP_Print;
aNPPFuncs->event = NPP_HandleEvent;
aNPPFuncs->urlnotify = NPP_URLNotify;
aNPPFuncs->getvalue = NPP_GetValue;
aNPPFuncs->setvalue = NPP_SetValue;
#endif
aNPPFuncs->javaClass = NULL;
return NPERR_NO_ERROR;
}
static NPError fillNetscapeFunctionTable(NPNetscapeFuncs* aNPNFuncs)
{
if(aNPNFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(HIBYTE(aNPNFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
if(aNPNFuncs->size < sizeof(NPNetscapeFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
NPNFuncs.size = aNPNFuncs->size;
NPNFuncs.version = aNPNFuncs->version;
NPNFuncs.geturlnotify = aNPNFuncs->geturlnotify;
NPNFuncs.geturl = aNPNFuncs->geturl;
NPNFuncs.posturlnotify = aNPNFuncs->posturlnotify;
NPNFuncs.posturl = aNPNFuncs->posturl;
NPNFuncs.requestread = aNPNFuncs->requestread;
NPNFuncs.newstream = aNPNFuncs->newstream;
NPNFuncs.write = aNPNFuncs->write;
NPNFuncs.destroystream = aNPNFuncs->destroystream;
NPNFuncs.status = aNPNFuncs->status;
NPNFuncs.uagent = aNPNFuncs->uagent;
NPNFuncs.memalloc = aNPNFuncs->memalloc;
NPNFuncs.memfree = aNPNFuncs->memfree;
NPNFuncs.memflush = aNPNFuncs->memflush;
NPNFuncs.reloadplugins = aNPNFuncs->reloadplugins;
NPNFuncs.getJavaEnv = aNPNFuncs->getJavaEnv;
NPNFuncs.getJavaPeer = aNPNFuncs->getJavaPeer;
NPNFuncs.getvalue = aNPNFuncs->getvalue;
NPNFuncs.setvalue = aNPNFuncs->setvalue;
NPNFuncs.invalidaterect = aNPNFuncs->invalidaterect;
NPNFuncs.invalidateregion = aNPNFuncs->invalidateregion;
NPNFuncs.forceredraw = aNPNFuncs->forceredraw;
return NPERR_NO_ERROR;
}
//
// Some exports are different on different platforms
//
/**************************************************/
/* */
/* Windows */
/* */
/**************************************************/
#ifdef XP_WIN
NPError OSCALL NP_Initialize(NPNetscapeFuncs* aNPNFuncs)
{
NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
if(rv != NPERR_NO_ERROR)
return rv;
return NS_PluginInitialize();
}
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* aNPPFuncs)
{
return fillPluginFunctionTable(aNPPFuncs);
}
#endif //XP_WIN
/**************************************************/
/* */
/* Unix */
/* */
/**************************************************/
#ifdef XP_UNIX
NPError NP_Initialize(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs)
{
NPError rv = fillNetscapeFunctionTable(aNPNFuncs);
if(rv != NPERR_NO_ERROR)
return rv;
rv = fillPluginFunctionTable(aNPPFuncs);
if(rv != NPERR_NO_ERROR)
return rv;
return NS_PluginInitialize();
}
char * NP_GetMIMEDescription(void)
{
return NPP_GetMIMEDescription();
}
NPError NP_GetValue(void *future, NPPVariable aVariable, void *aValue)
{
return NPP_GetValue((NPP_t *)future, aVariable, aValue);
}
#endif //XP_UNIX
/**************************************************/
/* */
/* Mac */
/* */
/**************************************************/
#ifdef XP_MAC
#if !TARGET_API_MAC_CARBON
QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
#endif
short gResFile; // Refnum of the plugin's resource file
NPError Private_Initialize(void)
{
NPError rv = NS_PluginInitialize();
return rv;
}
void Private_Shutdown(void)
{
NS_PluginShutdown();
__destroy_global_chain();
}
void SetUpQD(void);
void SetUpQD(void)
{
ProcessSerialNumber PSN;
FSSpec myFSSpec;
Str63 name;
ProcessInfoRec infoRec;
OSErr result = noErr;
CFragConnectionID connID;
Str255 errName;
// Memorize the plugin¹s resource file refnum for later use.
gResFile = CurResFile();
#if !TARGET_API_MAC_CARBON
// Ask the system if CFM is available.
long response;
OSErr err = Gestalt(gestaltCFMAttr, &response);
Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
if (hasCFM) {
// GetProcessInformation takes a process serial number and
// will give us back the name and FSSpec of the application.
// See the Process Manager in IM.
infoRec.processInfoLength = sizeof(ProcessInfoRec);
infoRec.processName = name;
infoRec.processAppSpec = &myFSSpec;
PSN.highLongOfPSN = 0;
PSN.lowLongOfPSN = kCurrentProcess;
result = GetProcessInformation(&PSN, &infoRec);
}
else
// If no CFM installed, assume it must be a 68K app.
result = -1;
if (result == noErr) {
// Now that we know the app name and FSSpec, we can call GetDiskFragment
// to get a connID to use in a subsequent call to FindSymbol (it will also
// return the address of ³main² in app, which we ignore). If GetDiskFragment
// returns an error, we assume the app must be 68K.
Ptr mainAddr;
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
}
if (result == noErr) {
// The app is a PPC code fragment, so call FindSymbol
// to get the exported ³qd² symbol so we can access its
// QuickDraw globals.
CFragSymbolClass symClass;
result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
}
else {
// The app is 68K, so use its A5 to compute the address
// of its QuickDraw globals.
gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
}
#endif /* !TARGET_API_MAC_CARBON */
}
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
#if !TARGET_API_MAC_CARBON
#pragma export on
#if GENERATINGCFM
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
#endif
#pragma export off
#endif /* !TARGET_API_MAC_CARBON */
NPError main(NPNetscapeFuncs* aNPNFuncs, NPPluginFuncs* aNPPFuncs, NPP_ShutdownUPP* aUnloadUpp)
{
NPError rv = NPERR_NO_ERROR;
if (aUnloadUpp == NULL)
rv = NPERR_INVALID_FUNCTABLE_ERROR;
if (rv == NPERR_NO_ERROR)
rv = fillNetscapeFunctionTable(aNPNFuncs);
if (rv == NPERR_NO_ERROR) {
// defer static constructors until the global functions are initialized.
__InitCode__();
rv = fillPluginFunctionTable(aNPPFuncs);
}
*aUnloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
SetUpQD();
rv = Private_Initialize();
return rv;
}
#endif //XP_MAC

Просмотреть файл

@ -0,0 +1,213 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
////////////////////////////////////////////////////////////
//
// Implementation of Netscape entry points (NPN_*)
//
#include "npplat.h"
extern NPNetscapeFuncs NPNFuncs;
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(NPNFuncs.version);
*netscape_minor = LOBYTE(NPNFuncs.version);
}
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
return rv;
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
return rv;
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
return rv;
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
int32 rv = 0;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
else
rv = -1;
return rv;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
void NPN_Status(NPP instance, const char *message)
{
CallNPN_StatusProc(NPNFuncs.status, instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
const char * rv = NULL;
rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
return rv;
}
void* NPN_MemAlloc(uint32 size)
{
void * rv = NULL;
rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
return rv;
}
void NPN_MemFree(void* ptr)
{
CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
}
uint32 NPN_MemFlush(uint32 size)
{
uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
return rv;
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
JRIEnv * rv = NULL;
rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
return rv;
}
jref NPN_GetJavaPeer(NPP instance)
{
jref rv;
rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
return rv;
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
return rv;
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
return rv;
}
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
}
void NPN_ForceRedraw(NPP instance)
{
CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
}

Просмотреть файл

@ -0,0 +1,356 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
////////////////////////////////////////////////////////////
//
// Implementation of plugin entry points (NPP_*)
//
#include "pluginbase.h"
// here the plugin creates a plugin instance object which
// will be associated with this newly created NPP instance and
// will do all the neccessary job
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
// create a new plugin instance object
// initialization will be done when the associated window is ready
nsPluginCreateData ds;
ds.instance = instance;
ds.type = pluginType;
ds.mode = mode;
ds.argc = argc;
ds.argn = argn;
ds.argv = argv;
ds.saved = saved;
nsPluginInstanceBase * plugin = NS_NewPluginInstance(&ds);
if(plugin == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
// associate the plugin instance object with NPP instance
instance->pdata = (void *)plugin;
return rv;
}
// here is the place to clean up and destroy the nsPluginInstance object
NPError NPP_Destroy (NPP instance, NPSavedData** save)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin != NULL) {
plugin->shut();
NS_DestroyPluginInstance(plugin);
}
return rv;
}
// during this call we know when the plugin window is ready or
// is about to be destroyed so we can do some gui specific
// initialization and shutdown
NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
if(pNPWindow == NULL)
return NPERR_GENERIC_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return NPERR_GENERIC_ERROR;
// window just created
if(!plugin->isInitialized() && (pNPWindow->window != NULL)) {
if(!plugin->init(pNPWindow)) {
NS_DestroyPluginInstance(plugin);
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
// window goes away
if((pNPWindow->window == NULL) && plugin->isInitialized())
return plugin->SetWindow(pNPWindow);
// window resized?
if(plugin->isInitialized() && (pNPWindow->window != NULL))
return plugin->SetWindow(pNPWindow);
// this should not happen, nothing to do
if((pNPWindow->window == NULL) && !plugin->isInitialized())
return plugin->SetWindow(pNPWindow);
return rv;
}
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return NPERR_GENERIC_ERROR;
NPError rv = plugin->NewStream(type, stream, seekable, stype);
return rv;
}
int32 NPP_WriteReady (NPP instance, NPStream *stream)
{
if(instance == NULL)
return 0x0fffffff;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return 0x0fffffff;
int32 rv = plugin->WriteReady(stream);
return rv;
}
int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
if(instance == NULL)
return len;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return len;
int32 rv = plugin->Write(stream, offset, len, buffer);
return rv;
}
NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return NPERR_GENERIC_ERROR;
NPError rv = plugin->DestroyStream(stream, reason);
return rv;
}
void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
{
if(instance == NULL)
return;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return;
plugin->StreamAsFile(stream, fname);
}
void NPP_Print (NPP instance, NPPrint* printInfo)
{
if(instance == NULL)
return;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return;
plugin->Print(printInfo);
}
void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
if(instance == NULL)
return;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return;
plugin->URLNotify(url, reason, notifyData);
}
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return NPERR_GENERIC_ERROR;
NPError rv = plugin->GetValue(variable, value);
return rv;
}
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return NPERR_GENERIC_ERROR;
NPError rv = plugin->SetValue(variable, value);
return rv;
}
int16 NPP_HandleEvent(NPP instance, void* event)
{
if(instance == NULL)
return 0;
nsPluginInstanceBase * plugin = (nsPluginInstanceBase *)instance->pdata;
if(plugin == NULL)
return 0;
uint16 rv = plugin->HandleEvent(event);
return rv;
}
jref NPP_GetJavaClass (void)
{
return NULL;
}
/**************************************************/
/* */
/* Mac */
/* */
/**************************************************/
// Mac needs these wrappers, see npplat.h for more info
#ifdef XP_MAC
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
NPError rv = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return rv;
}
NPError Private_Destroy(NPP instance, NPSavedData** save)
{
NPError rv = NPP_Destroy(instance, save);
return rv;
}
NPError Private_SetWindow(NPP instance, NPWindow* window)
{
NPError rv = NPP_SetWindow(instance, window);
return rv;
}
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
{
NPError rv = NPP_NewStream(instance, type, stream, seekable, stype);
return rv;
}
int32 Private_WriteReady(NPP instance, NPStream* stream)
{
int32 rv = NPP_WriteReady(instance, stream);
return rv;
}
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
{
int32 rv = NPP_Write(instance, stream, offset, len, buffer);
return rv;
}
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
NPP_StreamAsFile(instance, stream, fname);
}
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
NPError rv = NPP_DestroyStream(instance, stream, reason);
return rv;
}
int16 Private_HandleEvent(NPP instance, void* event)
{
int16 rv = NPP_HandleEvent(instance, event);
return rv;
}
void Private_Print(NPP instance, NPPrint* platformPrint)
{
NPP_Print(instance, platformPrint);
}
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
NPP_URLNotify(instance, url, reason, notifyData);
}
jref Private_GetJavaClass(void)
{
return NULL;
}
NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
{
NPError rv = NPP_GetValue(instance, variable, result);
return rv;
}
NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
{
NPError rv = NPP_SetValue(instance, variable, value);
return rv;
}
#endif //XP_MAC