-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
- * The contents of this file are subject to the Mozilla 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/MPL/
+ * Mozilla/Firefox plugin for VLC
+ * Copyright (C) 2009, Jean-Paul Saman <jpsaman@videolan.org>
*
- * 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.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* The Original Code is Mozilla Communicator client code.
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+ */
+
+#include "config.h"
+
+//#define OJI 1
+
+#ifdef HAVE_MOZILLA_CONFIG_H
+# include <mozilla-config.h>
+#endif
#ifndef _NPAPI_H_
-#include "npapi.h"
+# include "npapi.h"
#endif
-#ifndef _NPUPP_H_
-#include "npupp.h"
+#ifdef HAVE_NPFUNCTIONS_H
+# include "npfunctions.h"
+#else
+# ifndef _NPUPP_H_
+# include "npupp.h"
+# endif
#endif
-#include "nsDefaultPlugin.h"
+#include "../vlcshell.h"
//\\// DEFINE
#define NP_EXPORT
//\\// GLOBAL DATA
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
+
#ifdef OJI
JRIGlobalRef Private_GetJavaClass(void);
{
jref clazz = NPP_GetJavaClass();
if (clazz) {
- JRIEnv* env = NPN_GetJavaEnv();
- return JRI_NewGlobalRef(env, clazz);
+ JRIEnv* env = NPN_GetJavaEnv();
+ return JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
#endif /* OJI */
+
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// PLUGIN DLL entry points
// plugin DLL. Note that these entry points ensure that DS is loaded
// by using the NP_LOADDS macro, when compiling for Win16
//
+#ifdef __MINGW32__
+extern "C" __declspec(dllexport) NPError WINAPI
+#else
NPError WINAPI NP_EXPORT
+#endif
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
// trap a NULL ptr
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
- pFuncs->event = 0; /// reserved
+ pFuncs->event = 0; /// reserved
+ pFuncs->getvalue = NPP_GetValue;
+ pFuncs->setvalue = NPP_SetValue;
- g_pluginFuncs = pFuncs;
+ g_pluginFuncs = pFuncs;
return NPERR_NO_ERROR;
}
//
// called immediately after the plugin DLL is loaded
//
-NPError WINAPI NP_EXPORT
+#ifdef __MINGW32__
+extern "C" __declspec(dllexport) NPError WINAPI
+#else
+NPError WINAPI NP_EXPORT
+#endif
NP_Initialize(NPNetscapeFuncs* pFuncs)
{
// trap a NULL ptr
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
- // We have to defer these assignments until g_pNavigatorFuncs is set
+ // We have to defer these assignments until g_pNavigatorFuncs is set
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- g_pluginFuncs->urlnotify = NPP_URLNotify;
- }
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ g_pluginFuncs->urlnotify = NPP_URLNotify;
+ }
#ifdef OJI
- if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
- g_pluginFuncs->javaClass = Private_GetJavaClass();
- }
+ if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
+ g_pluginFuncs->javaClass = Private_GetJavaClass();
+ }
#endif
- // NPP_Initialize is a standard (cross-platform) initialize function.
+ // NPP_Initialize is a standard (cross-platform) initialize function.
return NPP_Initialize();
}
// This function should check for some ref count on the dll to see if it is
// unloadable or it needs to stay in memory.
//
+#ifdef __MINGW32__
+extern "C" __declspec(dllexport) NPError WINAPI
+#else
NPError WINAPI NP_EXPORT
+#endif
NP_Shutdown()
{
NPP_Shutdown();
char * NP_GetMIMEDescription()
{
- static char mimetype[] = NS_PLUGIN_DEFAULT_MIME_DESCRIPTION;
- return mimetype;
+ return NPP_GetMIMEDescription();
}
// END - PLUGIN DLL entry points
plugin's DLL data segment. Don't call these functions from outside
the plugin without ensuring DS is set to the DLLs data segment first,
typically using the NP_LOADDS macro
-*/
+ */
/* returns the major/minor version numbers of the Plugin API for the plugin
and the Navigator
-*/
+ */
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
return g_pNavigatorFuncs->getvalue(instance, variable, result);
}
+NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
+{
+ return g_pNavigatorFuncs->setvalue(instance, variable, value);
+}
+
+void NPN_InvalidateRect(NPP instance, NPRect *rect)
+{
+ g_pNavigatorFuncs->invalidaterect(instance, rect);
+}
+
+void NPN_InvalidateRegion(NPP instance, NPRegion region)
+{
+ g_pNavigatorFuncs->invalidateregion(instance, region);
+}
+
+void NPN_ForceRedraw(NPP instance)
+{
+ g_pNavigatorFuncs->forceredraw(instance);
+}
+
+NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->getstringidentifier(name);
+ }
+ return NULL;
+}
+
+void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ g_pNavigatorFuncs->getstringidentifiers(names, nameCount, identifiers);
+ }
+}
+
+NPIdentifier NPN_GetIntIdentifier(int32_t intid)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->getintidentifier(intid);
+ }
+ return NULL;
+}
+
+bool NPN_IdentifierIsString(NPIdentifier identifier)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->identifierisstring(identifier);
+ }
+ return false;
+}
+
+NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->utf8fromidentifier(identifier);
+ }
+ return NULL;
+}
+
+int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->intfromidentifier(identifier);
+ }
+ return 0;
+}
+
+NPObject *NPN_CreateObject(NPP instance, NPClass *aClass)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->createobject(instance, aClass);
+ }
+ return NULL;
+}
+
+NPObject *NPN_RetainObject(NPObject *npobj)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->retainobject(npobj);
+ }
+ return NULL;
+}
+
+void NPN_ReleaseObject(NPObject *npobj)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ g_pNavigatorFuncs->releaseobject(npobj);
+ }
+}
+
+bool NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->invoke(instance, npobj, methodName, args, argCount, result);
+ }
+ return false;
+}
+
+bool NPN_InvokeDefault(NPP instance, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->invokeDefault(instance, npobj, args, argCount, result);
+ }
+ return false;
+}
+
+bool NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *result)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->evaluate(instance, npobj, script, result);
+ }
+ return false;
+}
+
+bool NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, NPVariant *result)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->getproperty(instance, npobj, propertyName, result);
+ }
+ return false;
+}
+
+bool NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->setproperty(instance, npobj, propertyName, value);
+ }
+ return false;
+}
+
+bool NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->removeproperty(instance, npobj, propertyName);
+ }
+ return false;
+}
+
+bool NPN_HasProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->hasproperty(instance, npobj, propertyName);
+ }
+ return false;
+}
+
+bool NPN_HasMethod(NPP instance, NPObject *npobj, NPIdentifier methodName)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ return g_pNavigatorFuncs->hasmethod(instance, npobj, methodName);
+ }
+ return false;
+}
+
+void NPN_ReleaseVariantValue(NPVariant *variant)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ g_pNavigatorFuncs->releasevariantvalue(variant);
+ }
+}
+
+void NPN_SetException(NPObject *npobj, const NPUTF8 *message)
+{
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ if( navMinorVers >= 14 )
+ {
+ g_pNavigatorFuncs->setexception(npobj, message);
+ }
+}
/* causes the specified URL to be fetched and streamed in
-*/
+ */
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
- int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
-
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
return g_pNavigatorFuncs->geturl(instance, url, target);
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
- int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
- if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
- err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
+ if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
+ err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
/* Requests that a number of bytes be provided on a stream. Typically
this would be used if a stream was in "pull" mode. An optional
position can be provided for streams which are seekable.
-*/
+ */
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return g_pNavigatorFuncs->requestread(stream, rangeList);
}
/* Creates a new stream of data from the plug-in to be interpreted
- by Netscape in the current window.
-*/
+ * by Netscape in the current window.
+ */
NPError NPN_NewStream(NPP instance, NPMIMEType type,
- const char* target, NPStream** stream)
+ const char* target, NPStream** stream)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
/* Provides len bytes of data.
-*/
+ */
int32 NPN_Write(NPP instance, NPStream *stream,
int32 len, void *buffer)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- int32 result;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ int32 result;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
- }
- else {
- result = -1;
- }
- return result;
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
+ }
+ else {
+ result = -1;
+ }
+ return result;
}
-/* Closes a stream object.
-reason indicates why the stream was closed.
-*/
+/* Closes a stream object.
+ * reason indicates why the stream was closed.
+ */
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
- int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
- NPError err;
+ int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
+ NPError err;
- if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
- err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
- }
- else {
- err = NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
- return err;
+ if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
+ err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
+ }
+ else {
+ err = NPERR_INCOMPATIBLE_VERSION_ERROR;
+ }
+ return err;
}
/* Provides a text status message in the Netscape client user interface
-*/
+ */
void NPN_Status(NPP instance, const char *message)
{
g_pNavigatorFuncs->status(instance, message);
}
/* returns the user agent string of Navigator, which contains version info
-*/
+ */
const char* NPN_UserAgent(NPP instance)
{
return g_pNavigatorFuncs->uagent(instance);
}
/* allocates memory from the Navigator's memory space. Necessary so that
- saved instance data may be freed by Navigator when exiting.
-*/
-
-
+ * saved instance data may be freed by Navigator when exiting.
+ */
void* NPN_MemAlloc(uint32 size)
{
return g_pNavigatorFuncs->memalloc(size);
}
/* reciprocal of MemAlloc() above
-*/
+ */
void NPN_MemFree(void* ptr)
{
g_pNavigatorFuncs->memfree(ptr);
}
+
#ifdef OJI
/* private function to Netscape. do not use!
-*/
+ */
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
JRIEnv* NPN_GetJavaEnv(void)
{
- return g_pNavigatorFuncs->getJavaEnv();
+ return g_pNavigatorFuncs->getJavaEnv();
}
jref NPN_GetJavaPeer(NPP instance)
{
- return g_pNavigatorFuncs->getJavaPeer(instance);
+ return g_pNavigatorFuncs->getJavaPeer(instance);
}
#endif
-