// ========================================================================== // Copyright (C) 1995 - 2006 Autodesk, Inc. and/or its licensors. All // rights reserved. // // The coded instructions, statements, computer programs, and/or related // material (collectively the "Data") in these files contain unpublished // information proprietary to Autodesk, Inc. ("Autodesk") and/or its // licensors, which is protected by U.S. and Canadian federal copyright // law and by international treaties. // // The Data is provided for use exclusively by You. You have the right // to use, modify, and incorporate this Data into other products for // purposes authorized by the Autodesk software license agreement, // without fee. // // The copyright notices in the Software and this entire statement, // including the above license grant, this restriction and the // following disclaimer, must be included in all copies of the // Software, in whole or in part, and all derivative works of // the Software, unless such copies or derivative works are solely // in the form of machine-executable object code generated by a // source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. // AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED // WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF // NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR // PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE, OR // TRADE PRACTICE. IN NO EVENT WILL AUTODESK AND/OR ITS LICENSORS // BE LIABLE FOR ANY LOST REVENUES, DATA, OR PROFITS, OR SPECIAL, // DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK // AND/OR ITS LICENSORS HAS BEEN ADVISED OF THE POSSIBILITY // OR PROBABILITY OF SUCH DAMAGES. // // ========================================================================== #include "mcp.h" #include "PluginObject.h" NPNetscapeFuncs *browser; NPNetscapeFuncs NPNFuncs; NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved); NPError NPP_Destroy(NPP instance, NPSavedData** save); NPError NPP_SetWindow(NPP instance, NPWindow* window); NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype); NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason); int32 NPP_WriteReady(NPP instance, NPStream* stream); int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer); void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname); void NPP_Print(NPP instance, NPPrint* platformPrint); int16 NPP_HandleEvent(NPP instance, void* event); void NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData); NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value); NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value); char *NPP_GetMIMEDescription(void) { return "application/x-mcp::MCP Plugin"; } NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs) { if(pFuncs == NULL) return NPERR_INVALID_FUNCTABLE_ERROR; if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR) return NPERR_INCOMPATIBLE_VERSION_ERROR; if(pFuncs->size < sizeof(NPNetscapeFuncs)) return NPERR_INVALID_FUNCTABLE_ERROR; NPNFuncs.size = pFuncs->size; NPNFuncs.version = pFuncs->version; NPNFuncs.geturlnotify = pFuncs->geturlnotify; NPNFuncs.geturl = pFuncs->geturl; NPNFuncs.posturlnotify = pFuncs->posturlnotify; NPNFuncs.posturl = pFuncs->posturl; NPNFuncs.requestread = pFuncs->requestread; NPNFuncs.newstream = pFuncs->newstream; NPNFuncs.write = pFuncs->write; NPNFuncs.destroystream = pFuncs->destroystream; NPNFuncs.status = pFuncs->status; NPNFuncs.uagent = pFuncs->uagent; NPNFuncs.memalloc = pFuncs->memalloc; NPNFuncs.memfree = pFuncs->memfree; NPNFuncs.memflush = pFuncs->memflush; NPNFuncs.reloadplugins = pFuncs->reloadplugins; NPNFuncs.getJavaEnv = pFuncs->getJavaEnv; NPNFuncs.getJavaPeer = pFuncs->getJavaPeer; NPNFuncs.getvalue = pFuncs->getvalue; NPNFuncs.setvalue = pFuncs->setvalue; NPNFuncs.invalidaterect = pFuncs->invalidaterect; NPNFuncs.invalidateregion = pFuncs->invalidateregion; NPNFuncs.forceredraw = pFuncs->forceredraw; NPNFuncs.getstringidentifier = pFuncs->getstringidentifier; NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers; NPNFuncs.getintidentifier = pFuncs->getintidentifier; NPNFuncs.identifierisstring = pFuncs->identifierisstring; NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier; NPNFuncs.intfromidentifier = pFuncs->intfromidentifier; NPNFuncs.createobject = pFuncs->createobject; NPNFuncs.retainobject = pFuncs->retainobject; NPNFuncs.releaseobject = pFuncs->releaseobject; NPNFuncs.invoke = pFuncs->invoke; NPNFuncs.invokeDefault = pFuncs->invokeDefault; NPNFuncs.evaluate = pFuncs->evaluate; NPNFuncs.getproperty = pFuncs->getproperty; NPNFuncs.setproperty = pFuncs->setproperty; NPNFuncs.removeproperty = pFuncs->removeproperty; NPNFuncs.hasproperty = pFuncs->hasproperty; NPNFuncs.hasmethod = pFuncs->hasmethod; NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue; NPNFuncs.setexception = pFuncs->setexception; browser = &NPNFuncs; return NPERR_NO_ERROR; } NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pluginFuncs) { if(pluginFuncs == NULL) return NPERR_INVALID_FUNCTABLE_ERROR; if(pluginFuncs->size < sizeof(NPPluginFuncs)) return NPERR_INVALID_FUNCTABLE_ERROR; pluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; pluginFuncs->size = sizeof(NPPluginFuncs); pluginFuncs->newp = NPP_New; pluginFuncs->destroy = NPP_Destroy; pluginFuncs->setwindow = NPP_SetWindow; pluginFuncs->newstream = NPP_NewStream; pluginFuncs->destroystream = NPP_DestroyStream; pluginFuncs->asfile = NPP_StreamAsFile; pluginFuncs->writeready = NPP_WriteReady; pluginFuncs->write = NPP_Write; pluginFuncs->print = NPP_Print; pluginFuncs->event = NPP_HandleEvent; pluginFuncs->urlnotify = NPP_URLNotify; pluginFuncs->getvalue = NPP_GetValue; pluginFuncs->setvalue = NPP_SetValue; pluginFuncs->javaClass = NULL; return NPERR_NO_ERROR; } NPError OSCALL NP_Shutdown(void) { return NPERR_NO_ERROR; } NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved) { if (browser->version >= 14) instance->pdata = browser->createobject (instance, getPluginClass()); return NPERR_NO_ERROR; } NPError NPP_Destroy(NPP instance, NPSavedData** save) { PluginObject *obj = (PluginObject *)instance->pdata; return NPERR_NO_ERROR; } NPError NPP_SetWindow(NPP instance, NPWindow* window) { PluginObject *obj = (PluginObject *)instance->pdata; // Do nothing if browser didn't support NPN_CreateObject which would have created the PluginObject. if (obj != NULL) { obj->window = window; } return NPERR_NO_ERROR; } NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype) { return NPERR_NO_ERROR; } NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) { return NPERR_NO_ERROR; } int32 NPP_WriteReady(NPP instance, NPStream* stream) { return 0; } int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer) { return 0; } void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) { } void NPP_Print(NPP instance, NPPrint* platformPrint) { } int16 NPP_HandleEvent(NPP instance, void* event) { return 0; } void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) { } NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { if(instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; if (variable == NPPVpluginScriptableNPObject) { void **v = (void **)value; PluginObject *obj = (PluginObject *)instance->pdata; // Increase reference count obj->referenceCount++; *v = obj; return NPERR_NO_ERROR; } return NPERR_GENERIC_ERROR; } NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { return NPERR_GENERIC_ERROR; }