summaryrefslogtreecommitdiff
path: root/npapi
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2009-11-13 11:52:33 +0100
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-02 22:30:14 +0100
commit50da8fca4a1111f67a20312ddd004da4627d688e (patch)
tree505ac19030482c0ff41ee26c1e469b345a46ae6f /npapi
parentcc0127f2c5c36492e7acc12f0ca912fdd19cefa7 (diff)
downloadfribid-50da8fca4a1111f67a20312ddd004da4627d688e.tar.gz
fribid-50da8fca4a1111f67a20312ddd004da4627d688e.tar.bz2
fribid-50da8fca4a1111f67a20312ddd004da4627d688e.zip
Added license headers to files that lacked them
Diffstat (limited to 'npapi')
-rw-r--r--npapi/CHANGELOG8
-rw-r--r--npapi/np_entry.c202
-rw-r--r--npapi/npn_gate.c317
3 files changed, 527 insertions, 0 deletions
diff --git a/npapi/CHANGELOG b/npapi/CHANGELOG
new file mode 100644
index 0000000..7e7e889
--- /dev/null
+++ b/npapi/CHANGELOG
@@ -0,0 +1,8 @@
+
+2009-11-13 Samuel Lidén Borell:
+
+ * Added a dummy function for compatibility with Opera
+ * Changed the syntax mode in the header to C, and changed
+ the indentation to 4 spaces.
+ * Disabled Java support (didn't compile and wasn't needed)
+
diff --git a/npapi/np_entry.c b/npapi/np_entry.c
new file mode 100644
index 0000000..e42b4e6
--- /dev/null
+++ b/npapi/np_entry.c
@@ -0,0 +1,202 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** 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
+//
+#include <npapi.h>
+#include <npupp.h>
+#include <string.h>
+
+#ifndef HIBYTE
+#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
+#endif
+
+#define EXPORT __attribute((visibility("default")))
+
+NPNetscapeFuncs NPNFuncs;
+
+#ifdef XP_WIN
+
+EXPORT NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
+{
+ if(pFuncs == NULL)
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ if(pFuncs->size < sizeof(NPPluginFuncs))
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ memset(pFuncs, 0, sizeof(NPPluginFuncs));
+ pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
+ pFuncs->newp = NPP_New;
+ pFuncs->destroy = NPP_Destroy;
+ pFuncs->setwindow = NPP_SetWindow;
+ //pFuncs->newstream = NPP_NewStream;
+ //pFuncs->destroystream = NPP_DestroyStream;
+ //pFuncs->asfile = NPP_StreamAsFile;
+ //pFuncs->writeready = NPP_WriteReady;
+ //pFuncs->write = NPP_Write;
+ //pFuncs->print = NPP_Print;
+ //pFuncs->event = NPP_HandleEvent;
+ //pFuncs->urlnotify = NPP_URLNotify;
+ pFuncs->getvalue = NPP_GetValue;
+ //pFuncs->setvalue = NPP_SetValue;
+ //pFuncs->javaClass = NULL;
+
+ return NPERR_NO_ERROR;
+}
+
+#endif /* XP_WIN */
+
+char *NPP_GetMIMEDescription();
+
+EXPORT char *
+NP_GetMIMEDescription()
+{
+ return NPP_GetMIMEDescription();
+}
+
+EXPORT NPError
+NP_GetValue(void* future, NPPVariable variable, void *value)
+{
+ return NPP_GetValue((NPP_t *)future, variable, value);
+}
+
+EXPORT NPError OSCALL
+NP_Initialize(NPNetscapeFuncs* pFuncs
+#ifdef XP_UNIX
+ , NPPluginFuncs* pluginFuncs
+#endif
+ )
+{
+ 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 = NULL;
+ NPNFuncs.getJavaPeer = NULL;
+ 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;
+
+#ifdef XP_UNIX
+ /*
+ * 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.
+ */
+ memset(pluginFuncs, 0, sizeof(NPPluginFuncs));
+ 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->urlnotify = NPP_URLNotify;
+ //pluginFuncs->event = NULL;
+ pluginFuncs->getvalue = NPP_GetValue;
+ //pluginFuncs->javaClass = NULL;
+
+ NPP_Initialize();
+#endif
+
+ return NPERR_NO_ERROR;
+}
+
+EXPORT NPError OSCALL NP_Shutdown()
+{
+ return NPERR_NO_ERROR;
+}
+
+/* Dummy functions */
+NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window) {
+ return NPERR_NO_ERROR;
+}
+
+
+
+
+
diff --git a/npapi/npn_gate.c b/npapi/npn_gate.c
new file mode 100644
index 0000000..bbef7be
--- /dev/null
+++ b/npapi/npn_gate.c
@@ -0,0 +1,317 @@
+/* -*- 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 <npapi.h>
+//#include "npfunctions.h"
+#include <npupp.h>
+
+#ifndef HIBYTE
+#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
+#endif
+
+#ifndef LOBYTE
+#define LOBYTE(W) ((W) & 0xFF)
+#endif
+
+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 = 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 = NPNFuncs.geturl(instance, url, target);
+ return rv;
+}
+
+NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file, void* notifyData)
+{
+ int navMinorVers = NPNFuncs.version & 0xFF;
+ NPError rv = NPERR_NO_ERROR;
+
+ if (navMinorVers >= NPVERS_HAS_NOTIFICATION)
+ rv = 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_t len, const char* buf, NPBool file)
+{
+ NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
+ return rv;
+}
+
+NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
+{
+ NPError rv = 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 = NPNFuncs.newstream(instance, type, target, stream);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+int32_t NPN_Write(NPP instance, NPStream *stream, int32_t len, void *buffer)
+{
+ int navMinorVersion = NPNFuncs.version & 0xFF;
+ int32_t rv = 0;
+
+ if (navMinorVersion >= NPVERS_HAS_STREAMOUTPUT)
+ rv = 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 = NPNFuncs.destroystream(instance, stream, reason);
+ else
+ rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
+
+ return rv;
+}
+
+void NPN_Status(NPP instance, const char *message)
+{
+ NPNFuncs.status(instance, message);
+}
+
+const char* NPN_UserAgent(NPP instance)
+{
+ const char * rv = NULL;
+ rv = NPNFuncs.uagent(instance);
+ return rv;
+}
+
+void* NPN_MemAlloc(uint32_t size)
+{
+ void * rv = NULL;
+ rv = NPNFuncs.memalloc(size);
+ return rv;
+}
+
+void NPN_MemFree(void* ptr)
+{
+ NPNFuncs.memfree(ptr);
+}
+
+uint32_t NPN_MemFlush(uint32_t size)
+{
+ uint32_t rv = NPNFuncs.memflush(size);
+ return rv;
+}
+
+void NPN_ReloadPlugins(NPBool reloadPages)
+{
+ NPNFuncs.reloadplugins(reloadPages);
+}
+
+NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
+{
+ NPError rv = NPNFuncs.getvalue(instance, variable, value);
+ return rv;
+}
+
+NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
+{
+ NPError rv = NPNFuncs.setvalue(instance, variable, value);
+ return rv;
+}
+
+void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
+{
+ NPNFuncs.invalidaterect(instance, invalidRect);
+}
+
+void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
+{
+ NPNFuncs.invalidateregion(instance, invalidRegion);
+}
+
+void NPN_ForceRedraw(NPP instance)
+{
+ NPNFuncs.forceredraw(instance);
+}
+
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
+{
+ return NPNFuncs.getstringidentifier(name);
+}
+
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
+ NPIdentifier *identifiers)
+{
+ NPNFuncs.getstringidentifiers(names, nameCount, identifiers);
+}
+
+bool NPN_IdentifierIsString(NPIdentifier identifier)
+{
+ return NPNFuncs.identifierisstring(identifier);
+}
+
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
+{
+ return NPNFuncs.utf8fromidentifier(identifier);
+}
+
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
+{
+ return NPNFuncs.intfromidentifier(identifier);
+}
+
+NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
+{
+ return NPNFuncs.createobject(npp, aClass);
+}
+
+NPObject *NPN_RetainObject(NPObject *obj)
+{
+ return NPNFuncs.retainobject(obj);
+}
+
+void NPN_ReleaseObject(NPObject *obj)
+{
+ NPNFuncs.releaseobject(obj);
+}
+
+bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
+ const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+ return NPNFuncs.invoke(npp, obj, methodName, args, argCount, result);
+}
+
+bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
+ uint32_t argCount, NPVariant *result)
+{
+ return NPNFuncs.invokeDefault(npp, obj, args, argCount, result);
+}
+
+bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
+ NPVariant *result)
+{
+ return NPNFuncs.evaluate(npp, obj, script, result);
+}
+
+bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
+ NPVariant *result)
+{
+ return NPNFuncs.getproperty(npp, obj, propertyName, result);
+}
+
+bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
+ const NPVariant *value)
+{
+ return NPNFuncs.setproperty(npp, obj, propertyName, value);
+}
+
+bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
+{
+ return NPNFuncs.removeproperty(npp, obj, propertyName);
+}
+
+bool NPN_Enumerate(NPP npp, NPObject *obj, NPIdentifier **identifier,
+ uint32_t *count)
+{
+ return NPNFuncs.enumerate(npp, obj, identifier, count);
+}
+
+bool NPN_Construct(NPP npp, NPObject *obj, const NPVariant *args,
+ uint32_t argCount, NPVariant *result)
+{
+ return NPNFuncs.construct(npp, obj, args, argCount, result);
+}
+
+bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
+{
+ return NPNFuncs.hasproperty(npp, obj, propertyName);
+}
+
+bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
+{
+ return NPNFuncs.hasmethod(npp, obj, methodName);
+}
+
+void NPN_ReleaseVariantValue(NPVariant *variant)
+{
+ NPNFuncs.releasevariantvalue(variant);
+}
+
+void NPN_SetException(NPObject* obj, const NPUTF8 *message)
+{
+ NPNFuncs.setexception(obj, message);
+}
+