diff --git a/mozilla/modules/plugin/Makefile b/mozilla/modules/plugin/Makefile
new file mode 100644
index 00000000000..46dc9f6fe3a
--- /dev/null
+++ b/mozilla/modules/plugin/Makefile
@@ -0,0 +1,31 @@
+#//------------------------------------------------------------------------
+#//
+#// Makefile to build the MODULES/OJI tree
+#//
+#//------------------------------------------------------------------------
+
+#//------------------------------------------------------------------------
+#//
+#// Specify the depth of the current directory relative to the
+#// root of NS
+#//
+#//------------------------------------------------------------------------
+DEPTH=../..
+
+#//------------------------------------------------------------------------
+#//
+#// Specify any "command" targets. (ie. DIRS, INSTALL_FILES, ...)
+#// (these must come before the common makefiles are included)
+#//
+#// DIRS - There are subdirectories to process
+#//
+#//------------------------------------------------------------------------
+DIRS= public src
+
+#//------------------------------------------------------------------------
+#//
+#// Include the common makefile rules
+#//
+#//------------------------------------------------------------------------
+include $(DEPTH)/config/rules.mk
+
diff --git a/mozilla/modules/plugin/base/public/MANIFEST b/mozilla/modules/plugin/base/public/MANIFEST
new file mode 100644
index 00000000000..9f6a56fcb1e
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/MANIFEST
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+#
+# This is a list of local files which get copied to the mozilla:dist directory
+#
+
+nsIFileUtilities.h
+nsIJRILiveConnectPlugin.h
+nsIJRILiveConnectPluginInstancePeer.h
+nsILiveConnectPlugin.h
+nsILiveConnectPluginInstancePeer.h
+nsIPlugin.h
+nsIPluginInstance.h
+nsIPluginInstancePeer.h
+nsIPluginInstancePeer2.h
+nsIPluginManager.h
+nsIPluginManager2.h
+nsIPluginStream.h
+nsIPluginStreamPeer.h
+nsIPluginStreamPeer2.h
+nsIPluginTagInfo.h
+nsIPluginTagInfo2.h
+nsISeekablePluginStreamPeer.h
+nsIWindowlessPluginInstancePeer.h
+nsplugin.h
+nsplugindefs.h
diff --git a/mozilla/modules/plugin/base/public/Makefile b/mozilla/modules/plugin/base/public/Makefile
new file mode 100644
index 00000000000..f87022e6eba
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/Makefile
@@ -0,0 +1,44 @@
+#
+# 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.
+#
+
+DEPTH = ../../..
+
+MODULE = plugin
+
+EXPORTS = \
+ nsIFileUtilities.h \
+ nsIJRILiveConnectPlugin.h \
+ nsIJRILiveConnectPluginInstancePeer.h \
+ nsILiveConnectPlugin.h \
+ nsILiveConnectPluginInstancePeer.h \
+ nsIPlugin.h \
+ nsIPluginInstance.h \
+ nsIPluginInstancePeer.h \
+ nsIPluginInstancePeer2.h \
+ nsIPluginManager.h \
+ nsIPluginManager2.h \
+ nsIPluginStream.h \
+ nsIPluginStreamPeer.h \
+ nsIPluginStreamPeer2.h \
+ nsIPluginTagInfo.h \
+ nsIPluginTagInfo2.h \
+ nsISeekablePluginStreamPeer.h \
+ nsIWindowlessPluginInstancePeer.h \
+ nsplugin.h \
+ nsplugindefs.h
+
+include $(DEPTH)/config/rules.mk
diff --git a/mozilla/modules/plugin/base/public/makefile.win b/mozilla/modules/plugin/base/public/makefile.win
new file mode 100644
index 00000000000..4dae17aff4d
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/makefile.win
@@ -0,0 +1,47 @@
+#!gmake
+#
+# 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.
+
+IGNORE_MANIFEST=1
+
+DEPTH = ..\..\..
+
+MODULE = plugin
+
+EXPORTS = \
+ nsIFileUtilities.h \
+ nsIJRILiveConnectPlugin.h \
+ nsIJRILiveConnectPluginInstancePeer.h \
+ nsILiveConnectPlugin.h \
+ nsILiveConnectPluginInstancePeer.h \
+ nsIPlugin.h \
+ nsIPluginInstance.h \
+ nsIPluginInstancePeer.h \
+ nsIPluginInstancePeer2.h \
+ nsIPluginManager.h \
+ nsIPluginManager2.h \
+ nsIPluginStream.h \
+ nsIPluginStreamPeer.h \
+ nsIPluginStreamPeer2.h \
+ nsIPluginTagInfo.h \
+ nsIPluginTagInfo2.h \
+ nsISeekablePluginStreamPeer.h \
+ nsIWindowlessPluginInstancePeer.h \
+ nsplugin.h \
+ nsplugindefs.h
+
+include <$(DEPTH)/config/rules.mak>
+
diff --git a/mozilla/modules/plugin/base/public/nsIFileUtilities.h b/mozilla/modules/plugin/base/public/nsIFileUtilities.h
new file mode 100644
index 00000000000..880435d4d9f
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIFileUtilities.h
@@ -0,0 +1,75 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIFileUtilities_h___
+#define nsIFileUtilities_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// File Utilities Interface
+// This interface reflects operations only available in Communicator 5.0.
+
+class nsIFileUtilities : public nsISupports {
+public:
+
+ // QueryInterface on nsIPluginManager to get this.
+
+ NS_IMETHOD_(const char*)
+ GetProgramPath(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetTempDirPath(void) = 0;
+
+ enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME };
+
+ NS_IMETHOD_(nsresult)
+ GetFileName(const char* fn, FileNameType type,
+ char* resultBuf, PRUint32 bufLen) = 0;
+
+ NS_IMETHOD_(nsresult)
+ NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0;
+
+};
+
+#define NS_IFILEUTILITIES_IID \
+{ /* 89a31ce0-019a-11d2-815b-006008119d7a */ \
+ 0x89a31ce0, \
+ 0x019a, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIFileUtilities_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIJRILiveConnectPlugin.h b/mozilla/modules/plugin/base/public/nsIJRILiveConnectPlugin.h
new file mode 100644
index 00000000000..bc2382ced4b
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIJRILiveConnectPlugin.h
@@ -0,0 +1,77 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIJRILiveConnectPlugin_h__
+#define nsIJRILiveConnectPlugin_h__
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// JRI-Based LiveConnect Classes
+////////////////////////////////////////////////////////////////////////////////
+//
+// This stuff is here so that the browser can support older JRI-based
+// LiveConnected plugins (when using old plugin to new C++-style plugin
+// adapter code).
+//
+// Warning: Don't use this anymore, unless you're sure that you have to!
+////////////////////////////////////////////////////////////////////////////////
+
+#include "jri.h" // ancient
+
+////////////////////////////////////////////////////////////////////////////////
+// JRILiveConnect Plugin Interface
+// This interface defines additional entry points that a plugin developer needs
+// to implement in order for the plugin to support JRI-based LiveConnect,
+// i.e. be scriptable by Java or JavaScript.
+
+class nsIJRILiveConnectPlugin : public nsIPlugin {
+public:
+
+ // (Corresponds to NPP_GetJavaClass.)
+ NS_IMETHOD_(jref)
+ GetJavaClass(void) = 0;
+
+};
+
+#define NS_IJRILIVECONNECTPLUGIN_IID \
+{ /* c94058e0-f772-11d1-815b-006008119d7a */ \
+ 0xc94058e0, \
+ 0xf772, \
+ 0x11d1, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIJRILiveConnectPlugin_h__ */
diff --git a/mozilla/modules/plugin/base/public/nsIJRILiveConnectPluginInstancePeer.h b/mozilla/modules/plugin/base/public/nsIJRILiveConnectPluginInstancePeer.h
new file mode 100644
index 00000000000..bbd8bac6f1b
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIJRILiveConnectPluginInstancePeer.h
@@ -0,0 +1,86 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIJRILiveConnectPluginInstancePeer_h__
+#define nsIJRILiveConnectPluginInstancePeer_h__
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// JRI-Based LiveConnect Classes
+////////////////////////////////////////////////////////////////////////////////
+//
+// This stuff is here so that the browser can support older JRI-based
+// LiveConnected plugins (when using old plugin to new C++-style plugin
+// adapter code).
+//
+// Warning: Don't use this anymore, unless you're sure that you have to!
+////////////////////////////////////////////////////////////////////////////////
+
+#include "jri.h" // ancient
+
+////////////////////////////////////////////////////////////////////////////////
+// JRILiveConnect Plugin Instance Peer Interface
+// Browsers that support JRI-based LiveConnect implement this subclass of
+// plugin instance peer.
+
+class nsIJRILiveConnectPluginInstancePeer : public nsISupports {
+public:
+
+ // (Corresponds to NPN_GetJavaPeer.)
+ NS_IMETHOD_(jref)
+ GetJavaPeer(void) = 0;
+
+};
+
+#define NS_IJRILIVECONNECTPLUGININSTANCEPEER_IID \
+{ /* 25b63f40-f773-11d1-815b-006008119d7a */ \
+ 0x25b63f40, \
+ 0xf773, \
+ 0x11d1, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+// QueryInterface for this IID on nsIPluginManager to get a JRIEnv
+// XXX change this
+#define NS_IJRIENV_IID \
+{ /* f9d4ea00-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xf9d4ea00, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIJRILiveConnectPluginInstancePeer_h__ */
diff --git a/mozilla/modules/plugin/base/public/nsILiveConnectPlugin.h b/mozilla/modules/plugin/base/public/nsILiveConnectPlugin.h
new file mode 100644
index 00000000000..31753271bcd
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsILiveConnectPlugin.h
@@ -0,0 +1,65 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsILiveConnectPlugin_h__
+#define nsILiveConnectPlugin_h__
+
+#include "nsplugindefs.h"
+#include "jni.h" // standard JVM API
+
+////////////////////////////////////////////////////////////////////////////////
+// LiveConnect Plugin Interface
+// This interface defines additional entry points that a plugin developer needs
+// to implement in order for the plugin to support JNI-based LiveConnect,
+// i.e. be scriptable by Java or JavaScript.
+
+class nsILiveConnectPlugin : public nsIPlugin {
+public:
+
+ // (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.)
+ NS_IMETHOD_(jclass)
+ GetJavaClass(void) = 0;
+
+};
+
+#define NS_ILIVECONNECTPLUGIN_IID \
+{ /* cf134df0-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xcf134df0, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsILiveConnectPlugin_h__ */
diff --git a/mozilla/modules/plugin/base/public/nsILiveConnectPluginInstancePeer.h b/mozilla/modules/plugin/base/public/nsILiveConnectPluginInstancePeer.h
new file mode 100644
index 00000000000..508b51f3e08
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsILiveConnectPluginInstancePeer.h
@@ -0,0 +1,74 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsILiveConnectPluginInstancePeer_h___
+#define nsILiveConnectPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+#include "jni.h" // standard JVM API
+
+////////////////////////////////////////////////////////////////////////////////
+// LiveConnect Plugin Instance Peer Interface
+// Browsers that support JNI-based LiveConnect implement this subclass of
+// plugin instance peer.
+
+class nsILiveConnectPluginInstancePeer : public nsISupports {
+public:
+
+ // (New JNI-based entry point, roughly corresponds to NPN_GetJavaPeer.)
+ NS_IMETHOD_(jobject)
+ GetJavaPeer(void) = 0;
+
+};
+
+#define NS_ILIVECONNECTPLUGININSTANCEPEER_IID \
+{ /* 1e3502a0-a1bd-11d1-85b1-00805f0e4dfe */ \
+ 0x1e3502a0, \
+ 0xa1bd, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+// QueryInterface for this IID on nsIPluginManager to get a JNIEnv
+// XXX change this
+#define NS_IJNIENV_IID \
+{ /* 04610650-a1bd-11d1-85b1-00805f0e4dfe */ \
+ 0x04610650, \
+ 0xa1bd, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsILiveConnectPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPlugin.h b/mozilla/modules/plugin/base/public/nsIPlugin.h
new file mode 100644
index 00000000000..8512a581534
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPlugin.h
@@ -0,0 +1,97 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPlugin_h___
+#define nsIPlugin_h___
+
+#include "nsplugindefs.h"
+#include "nsIFactory.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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. nsILiveConnectPlugin.
+
+struct nsIPlugin : public nsIFactory {
+public:
+
+ // This call initializes the plugin and will be called before any new
+ // instances are created. It is passed browserInterfaces on which QueryInterface
+ // may be used to obtain an nsIPluginManager, and other interfaces.
+ NS_IMETHOD_(nsPluginError)
+ Initialize(nsISupports* browserInterfaces) = 0;
+
+ // (Corresponds to NPP_Shutdown.)
+ // Called when the browser is done with the plugin factory, or when
+ // the plugin is disabled by the user.
+ NS_IMETHOD_(nsPluginError)
+ Shutdown(void) = 0;
+
+ // (Corresponds to NPP_GetMIMEDescription.)
+ NS_IMETHOD_(const char*)
+ GetMIMEDescription(void) = 0;
+
+ // (Corresponds to NPP_GetValue.)
+ NS_IMETHOD_(nsPluginError)
+ GetValue(nsPluginVariable variable, void *value) = 0;
+
+ // (Corresponds to NPP_SetValue.)
+ NS_IMETHOD_(nsPluginError)
+ SetValue(nsPluginVariable variable, void *value) = 0;
+
+ // The old NPP_New call has been factored into two plugin instance methods:
+ //
+ // CreateInstance -- 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).
+ //
+ // nsIPluginInstance::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.
+
+};
+
+#define NS_IPLUGIN_IID \
+{ /* df773070-0199-11d2-815b-006008119d7a */ \
+ 0xdf773070, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPlugin_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginInstance.h b/mozilla/modules/plugin/base/public/nsIPluginInstance.h
new file mode 100644
index 00000000000..29825c92f13
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginInstance.h
@@ -0,0 +1,111 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstance_h___
+#define nsIPluginInstance_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Interface
+
+// (Corresponds to NPP object.)
+class nsIPluginInstance : public nsISupports {
+public:
+
+ NS_IMETHOD_(nsPluginError)
+ Initialize(nsIPluginInstancePeer* peer) = 0;
+
+ // Required backpointer to the peer.
+ NS_IMETHOD_(nsIPluginInstancePeer*)
+ GetPeer(void) = 0;
+
+ // See comment for nsIPlugin::CreateInstance, above.
+ NS_IMETHOD_(nsPluginError)
+ 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_(nsPluginError)
+ Stop(void) = 0;
+
+ NS_IMETHOD_(nsPluginError)
+ Destroy(void) = 0;
+
+ // (Corresponds to NPP_SetWindow.)
+ NS_IMETHOD_(nsPluginError)
+ SetWindow(nsPluginWindow* window) = 0;
+
+ // (Corresponds to NPP_NewStream.)
+ NS_IMETHOD_(nsPluginError)
+ NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
+
+ // (Corresponds to NPP_Print.)
+ NS_IMETHOD_(void)
+ Print(nsPluginPrint* platformPrint) = 0;
+
+ // (Corresponds to NPP_HandleEvent.)
+ // Note that for Unix and Mac the nsPluginEvent 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(nsPluginEvent* event) = 0;
+
+ // (Corresponds to NPP_URLNotify.)
+ NS_IMETHOD_(void)
+ URLNotify(const char* url, const char* target,
+ nsPluginReason reason, void* notifyData) = 0;
+
+};
+
+#define NS_IPLUGININSTANCE_IID \
+{ /* ebe00f40-0199-11d2-815b-006008119d7a */ \
+ 0xebe00f40, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstance_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginInstancePeer.h b/mozilla/modules/plugin/base/public/nsIPluginInstancePeer.h
new file mode 100644
index 00000000000..98229dee428
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginInstancePeer.h
@@ -0,0 +1,80 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstancePeer_h___
+#define nsIPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Peer Interface
+
+enum nsPluginTagType {
+ nsPluginTagType_Unknown,
+ nsPluginTagType_Embed,
+ nsPluginTagType_Object,
+ nsPluginTagType_Applet
+};
+
+class nsIPluginInstancePeer : public nsISupports {
+public:
+
+ // (Corresponds to NPP_New's MIMEType argument.)
+ NS_IMETHOD_(nsMIMEType)
+ GetMIMEType(void) = 0;
+
+ // (Corresponds to NPP_New's mode argument.)
+ NS_IMETHOD_(nsPluginType)
+ GetMode(void) = 0;
+
+ // (Corresponds to NPN_NewStream.)
+ NS_IMETHOD_(nsPluginError)
+ NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) = 0;
+
+ // (Corresponds to NPN_Status.)
+ NS_IMETHOD_(void)
+ ShowStatus(const char* message) = 0;
+
+};
+
+#define NS_IPLUGININSTANCEPEER_IID \
+{ /* 4b7cea20-019b-11d2-815b-006008119d7a */ \
+ 0x4b7cea20, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginInstancePeer2.h b/mozilla/modules/plugin/base/public/nsIPluginInstancePeer2.h
new file mode 100644
index 00000000000..f3b3acbe02f
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginInstancePeer2.h
@@ -0,0 +1,79 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstancePeer2_h___
+#define nsIPluginInstancePeer2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Peer 2 Interface
+// These extensions to nsIPluginManager are only available in Communicator 5.0.
+
+class nsIPluginInstancePeer2 : public nsIPluginInstancePeer {
+public:
+
+ ////////////////////////////////////////////////////////////////////////////
+ // 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;
+
+ // On the mac (and most likely win16), network activity can
+ // only occur on the main thread. Therefore, we provide a hook
+ // here for the case that the main thread needs to tickle itself.
+ // In this case, we make sure that we give up the monitor so that
+ // the tickle code can notify it without freezing.
+ NS_IMETHOD_(PRBool)
+ Tickle(void) = 0;
+
+};
+
+#define NS_IPLUGININSTANCEPEER2_IID \
+{ /* 51b52b80-019b-11d2-815b-006008119d7a */ \
+ 0x51b52b80, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstancePeer2_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginManager.h b/mozilla/modules/plugin/base/public/nsIPluginManager.h
new file mode 100644
index 00000000000..dffd0376f75
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginManager.h
@@ -0,0 +1,128 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginManager_h___
+#define nsIPluginManager_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsIPluginManager : public nsISupports {
+public:
+
+ // (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;
+
+ // (Corresponds to NPN_UserAgent.)
+ NS_IMETHOD_(const char*)
+ UserAgent(void) = 0;
+
+ // (Corresponds to NPN_GetValue.)
+ NS_IMETHOD_(nsPluginError)
+ GetValue(nsPluginManagerVariable variable, void *value) = 0;
+
+ // (Corresponds to NPN_SetValue.)
+ NS_IMETHOD_(nsPluginError)
+ SetValue(nsPluginManagerVariable variable, void *value) = 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:
+ // peer: A plugin instance peer. The peer's window will be used to display
+ // progress information. If NULL, the load happens in the background.
+ // 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_(nsPluginError)
+ GetURL(nsISupports* peer, 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:
+ // peer: A plugin instance peer. The peer's window will be used to display
+ // progress information. If NULL, the load happens in the background.
+ // 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_(nsPluginError)
+ PostURL(nsISupports* peer, 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;
+
+};
+
+#define NS_IPLUGINMANAGER_IID \
+{ /* f10b9600-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xf10b9600, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginManager_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginManager2.h b/mozilla/modules/plugin/base/public/nsIPluginManager2.h
new file mode 100644
index 00000000000..2ac771339e9
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginManager2.h
@@ -0,0 +1,67 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginManager2_h___
+#define nsIPluginManager2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Manager 2 Interface
+// These extensions to nsIPluginManager are only available in Communicator 5.0.
+
+class nsIPluginManager2 : public nsIPluginManager {
+public:
+
+ NS_IMETHOD_(void)
+ BeginWaitCursor(void) = 0;
+
+ NS_IMETHOD_(void)
+ EndWaitCursor(void) = 0;
+
+ NS_IMETHOD_(PRBool)
+ SupportsURLProtocol(const char* protocol) = 0;
+
+};
+
+#define NS_IPLUGINMANAGER2_IID \
+{ /* 29c4ae70-019a-11d2-815b-006008119d7a */ \
+ 0x29c4ae70, \
+ 0x019a, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginManager2_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStream.h b/mozilla/modules/plugin/base/public/nsIPluginStream.h
new file mode 100644
index 00000000000..e3f9b2c7e13
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginStream.h
@@ -0,0 +1,66 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStream_h___
+#define nsIPluginStream_h___
+
+#include "nsplugindefs.h"
+#include "nsIOutputStream.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Stream Interface
+
+class nsIPluginStream : public nsIOutputStream {
+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 NS_IPLUGINSTREAM_IID \
+{ /* f287dd50-0199-11d2-815b-006008119d7a */ \
+ 0xf287dd50, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStream_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h
new file mode 100644
index 00000000000..da46281e8be
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h
@@ -0,0 +1,84 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStreamPeer_h___
+#define nsIPluginStreamPeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsIPluginStreamPeer : public nsISupports {
+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;
+
+ // (Corresponds to NPP_DestroyStream's reason argument.)
+ NS_IMETHOD_(nsPluginReason)
+ GetReason(void) = 0;
+
+ // (Corresponds to NPP_NewStream's MIMEType argument.)
+ NS_IMETHOD_(nsMIMEType)
+ GetMIMEType(void) = 0;
+
+};
+
+#define NS_IPLUGINSTREAMPEER_IID \
+{ /* 717b1e90-019b-11d2-815b-006008119d7a */ \
+ 0x717b1e90, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStreamPeer_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h
new file mode 100644
index 00000000000..30a69a33631
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h
@@ -0,0 +1,70 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStreamPeer2_h___
+#define nsIPluginStreamPeer2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Stream Peer Interface
+// These extensions to nsIPluginStreamPeer are only available in Communicator 5.0.
+
+class nsIPluginStreamPeer2 : public nsIPluginStreamPeer {
+public:
+
+ NS_IMETHOD_(PRUint32)
+ GetContentLength(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetHeaderFieldCount(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetHeaderFieldKey(PRUint32 index) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetHeaderField(PRUint32 index) = 0;
+
+};
+
+#define NS_IPLUGINSTREAMPEER2_IID \
+{ /* 77083af0-019b-11d2-815b-006008119d7a */ \
+ 0x77083af0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStreamPeer2_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h b/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h
new file mode 100644
index 00000000000..3171c135265
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginTagInfo.h
@@ -0,0 +1,74 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginTagInfo_h___
+#define nsIPluginTagInfo_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Tag Info Interface
+// This interface provides information about the HTML tag on the page.
+// Some day this might get superseded by a DOM API.
+
+class nsIPluginTagInfo : public nsISupports {
+public:
+
+ // QueryInterface on nsIPluginInstancePeer to get this.
+
+ // (Corresponds to NPP_New's argc, argn, and argv arguments.)
+ // 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_(nsPluginError)
+ GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) = 0;
+
+ // Get the value for the named attribute. Returns NULL
+ // if the attribute was not set.
+ NS_IMETHOD_(const char*)
+ GetAttribute(const char* name) = 0;
+
+};
+
+#define NS_IPLUGINTAGINFO_IID \
+{ /* 5f1ec1d0-019b-11d2-815b-006008119d7a */ \
+ 0x5f1ec1d0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginTagInfo_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginTagInfo2.h b/mozilla/modules/plugin/base/public/nsIPluginTagInfo2.h
new file mode 100644
index 00000000000..f023e58b7c1
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIPluginTagInfo2.h
@@ -0,0 +1,110 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginTagInfo2_h___
+#define nsIPluginTagInfo2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Tag Info Interface
+// These extensions to nsIPluginTagInfo are only available in Communicator 5.0.
+
+class nsIPluginTagInfo2 : public nsIPluginTagInfo {
+public:
+
+ // QueryInterface on nsIPluginInstancePeer to get this.
+
+ // Get the type of the HTML tag that was used ot instantiate this
+ // plugin. Currently supported tags are EMBED, OBJECT and APPLET.
+ NS_IMETHOD_(nsPluginTagType)
+ GetTagType(void) = 0;
+
+ // Get the complete text of the HTML tag that was
+ // used to instantiate this plugin
+ NS_IMETHOD_(const char *)
+ GetTagText(void) = 0;
+
+ // 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_(nsPluginError)
+ GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) = 0;
+
+ // Get the value for the named parameter. Returns null
+ // if the parameter was not set.
+ NS_IMETHOD_(const char*)
+ GetParameter(const char* name) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetDocumentBase(void) = 0;
+
+ // Return an encoding whose name is specified in:
+ // http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303
+ NS_IMETHOD_(const char*)
+ GetDocumentEncoding(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetAlignment(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetWidth(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetHeight(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetBorderVertSpace(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetBorderHorizSpace(void) = 0;
+
+ // Returns a unique id for the current document on which the
+ // plugin is displayed.
+ NS_IMETHOD_(PRUint32)
+ GetUniqueID(void) = 0;
+
+};
+
+#define NS_IPLUGINTAGINFO2_IID \
+{ /* 6a49c9a0-019b-11d2-815b-006008119d7a */ \
+ 0x6a49c9a0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginTagInfo2_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h b/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h
new file mode 100644
index 00000000000..dcfd07f7519
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h
@@ -0,0 +1,67 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsISeekablePluginStreamPeer_h___
+#define nsISeekablePluginStreamPeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsISeekablePluginStreamPeer : public nsISupports {
+public:
+
+ // QueryInterface for this class corresponds to NPP_NewStream's
+ // seekable argument.
+
+ // (Corresponds to NPN_RequestRead.)
+ NS_IMETHOD_(nsPluginError)
+ RequestRead(nsByteRange* rangeList) = 0;
+
+};
+
+#define NS_ISEEKABLEPLUGINSTREAMPEER_IID \
+{ /* 7e028d20-019b-11d2-815b-006008119d7a */ \
+ 0x7e028d20, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsISeekablePluginStreamPeer_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsIWindowlessPluginInstancePeer.h b/mozilla/modules/plugin/base/public/nsIWindowlessPluginInstancePeer.h
new file mode 100644
index 00000000000..14d4ccac468
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsIWindowlessPluginInstancePeer.h
@@ -0,0 +1,69 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIWindowlessPluginInstancePeer_h___
+#define nsIWindowlessPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Windowless Plugin Instance Peer Interface
+
+class nsIWindowlessPluginInstancePeer : public nsISupports {
+public:
+
+ // (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;
+
+};
+
+#define NS_IWINDOWLESSPLUGININSTANCEPEER_IID \
+{ /* 57b4e2f0-019b-11d2-815b-006008119d7a */ \
+ 0x57b4e2f0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIWindowlessPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/base/public/nsplugin.h b/mozilla/modules/plugin/base/public/nsplugin.h
new file mode 100644
index 00000000000..d4f349501e0
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsplugin.h
@@ -0,0 +1,238 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
This is the master header file that includes most of the other headers
+ * you'll need to write a plugin.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The following diagram depicts the relationships between various objects
+ * implementing the new plugin interfaces. QueryInterface can be used to switch
+ * between interfaces in the same box:
+ *
+ *
+ * the plugin (only 1)
+ * +----------------------+
+ * | nsIPlugin or |<- - - - - -NSGetFactory()
+ * | nsILiveConnectPlugin |
+ * +----------------------+
+ * |
+ * |
+ * | instances (many) streams to receive URL data (many)
+ * | +-------------------+ +-----------------+
+ * | | nsIPluginInstance |+ | nsIPluginStream |+
+ * | | || | ||
+ * | +-------------------+| +-----------------+|
+ * | +------|-----------+ +------|---------+
+ * | | |
+ * | PLUGIN SIDE |peer |peer
+ *~~~~|~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~
+ * | BROWSER SIDE | |
+ * | v v
+ * | +---------------------------------+ +----------------------------+
+ * | | nsIPluginInstancePeer |+ | nsIPluginStreamPeer |+
+ * | | nsIPluginInstancePeer2 || | nsISeekablePluginStreamPeer||
+ * | | nsIWindowlessPluginInstancePeer || | nsIPluginstreamPeer2 ||
+ * | | nsILiveConnectPluginInstancePeer|| +----------------------------+|
+ * | | nsIPluginTagInfo || +---------------------------+
+ * | | nsIPluginTagInfo2 ||
+ * | +---------------------------------+|
+ * | +--------------------------------+
+ * |
+ * |
+ * v the browser (only 1)
+ * +---------------------+
+ * | nsIPluginManager |
+ * | nsIPluginManager2 |
+ * | nsIFileUtilities |
+ * | nsIPref |
+ * | nsICacheManager ... |
+ * +---------------------+
+ *
+ */
+
+#ifndef nsplugins_h___
+#define nsplugins_h___
+
+#include "nsRepository.h" // for NSGetFactory
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces which must be implemented by a plugin
+ * These interfaces have NPP equivalents in pre-5.0 browsers (see npapi.h).
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * NSGetFactory 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 nsIPlugin::CreateInstance.
+ */
+// (Declared in nsRepository.h)
+//extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
+// nsIFactory **aFactory);
+
+/**
+ * A plugin object is used to create new plugin instances. It manages the
+ * global state of all plugins with the same implementation.
+ */
+#include "nsIPlugin.h"
+
+/**
+ * A plugin instance represents a particular activation of a plugin on a page.
+ */
+#include "nsIPluginInstance.h"
+
+/**
+ * A plugin stream gets instantiated when a plugin instance receives data from
+ * the browser.
+ */
+#include "nsIPluginStream.h"
+
+/**
+ * The nsILiveConnectPlugin interface provides additional operations that a
+ * plugin must implement if it is to be controlled by JavaScript through
+ * LiveConnect.
+ *
+ * Note that this interface is part of a new JNI-based LiveConnect
+ * implementation and superceeds that provided prior to Communicator 5.0.
+ */
+#include "nsILiveConnectPlugin.h"
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces implemented by the browser:
+ * These interfaces have NPN equivalents in pre-5.0 browsers (see npapi.h).
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The plugin manager which is the main point of interaction with the browser
+ * and provides general operations needed by a plugin.
+ */
+#include "nsIPluginManager.h"
+
+/**
+ * A plugin instance peer gets created by the browser and associated with each
+ * plugin instance to represent tag information and other callbacks needed by
+ * the plugin instance.
+ */
+#include "nsIPluginInstancePeer.h"
+
+/**
+ * The nsIPluginTagInfo interface provides information about the html tag
+ * that was used to instantiate the plugin instance.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIPluginTagInfo.h"
+
+/**
+ * The nsIWindowlessPluginInstancePeer provides additional operations for
+ * windowless plugins.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIWindowlessPluginInstancePeer.h"
+
+/**
+ * A plugin stream peer gets create by the browser and associated with each
+ * plugin stream to represent stream and URL information, and provides
+ * other callbacks needed by the plugin stream.
+ */
+#include "nsIPluginStreamPeer.h"
+
+/**
+ * The nsISeekablePluginStreamPeer provides additional operations for seekable
+ * plugin streams.
+ *
+ * To obtain: QueryInterface on nsIPluginStreamPeer
+ */
+#include "nsISeekablePluginStreamPeer.h"
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces implemented by the browser (new for 5.0):
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The nsIPluginManager2 interface provides additional plugin manager features
+ * only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginManager
+ */
+#include "nsIPluginManager2.h"
+
+/**
+ * The nsIFileUtilities interface provides operations to manage temporary
+ * files and directories.
+ *
+ * To obtain: QueryInterface on nsIPluginManager
+ */
+#include "nsIFileUtilities.h"
+
+/**
+ * The nsIPluginInstancePeer2 interface provides additional plugin instance
+ * peer features only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIPluginInstancePeer2.h"
+
+/**
+ * The nsILiveConnectPluginInstancePeer allows plugins to be manipulated
+ * by JavaScript, providing basic scriptability.
+ *
+ * Note that this interface is part of a new JNI-based LiveConnect
+ * implementation and superceeds that provided prior to Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsILiveConnectPluginInstancePeer.h"
+
+/**
+ * The nsIPluginStreamPeer2 interface provides additional plugin stream
+ * peer features only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginStreamPeer
+ */
+#include "nsIPluginStreamPeer2.h"
+
+/**
+ * The nsIPluginTagInfo2 interface provides additional html tag information
+ * only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginTagInfo
+ */
+#include "nsIPluginTagInfo2.h"
+
+////////////////////////////////////////////////////////////////////////////////
+#endif // nsplugins_h___
diff --git a/mozilla/modules/plugin/base/public/nsplugindefs.h b/mozilla/modules/plugin/base/public/nsplugindefs.h
new file mode 100644
index 00000000000..3d2e45d9b07
--- /dev/null
+++ b/mozilla/modules/plugin/base/public/nsplugindefs.h
@@ -0,0 +1,365 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsplugindefs_h___
+#define nsplugindefs_h___
+
+#ifdef __OS2__
+#pragma pack(1)
+#endif
+
+#ifdef XP_MAC
+ #include
+ #include
+#endif
+
+#ifdef XP_UNIX
+ #include
+ #include
+#endif
+
+#ifdef XP_PC
+ #include
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+/* 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 NS_INFO_ProductVersion { 1,0,0,1,}
+
+RCDATA NS_INFO_MIMEType { "video/x-video|",
+ "video/x-flick\0" }
+RCDATA NS_INFO_FileExtents { "avi|",
+ "flc\0" }
+RCDATA NS_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
+ "MMOS2 Flc/Fli player(*.flc)\0" }
+
+RCDATA NS_INFO_FileVersion { 1,0,0,1 }
+RCDATA NS_INFO_CompanyName { "Netscape Communications\0" }
+RCDATA NS_INFO_FileDescription { "NPAVI32 Extension DLL\0"
+RCDATA NS_INFO_InternalName { "NPAVI32\0" )
+RCDATA NS_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
+RCDATA NS_INFO_OriginalFilename { "NVAPI32.DLL" }
+RCDATA NS_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
+
+*/
+
+
+/* RC_DATA types for version info - required */
+#define NS_INFO_ProductVersion 1
+#define NS_INFO_MIMEType 2
+#define NS_INFO_FileOpenName 3
+#define NS_INFO_FileExtents 4
+
+/* RC_DATA types for version info - used if found */
+#define NS_INFO_FileDescription 5
+#define NS_INFO_ProductName 6
+
+/* RC_DATA types for version info - optional */
+#define NS_INFO_CompanyName 7
+#define NS_INFO_FileVersion 8
+#define NS_INFO_InternalName 9
+#define NS_INFO_LegalCopyright 10
+#define NS_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
+
+#include
+
+/*
+ * Callback Structures.
+ *
+ * These are used to pass additional platform specific information.
+ */
+enum nsPluginCallbackType {
+ nsPluginCallbackType_SetWindow = 1,
+ nsPluginCallbackType_Print
+};
+
+struct nsPluginAnyCallbackStruct {
+ PRInt32 type;
+};
+
+struct nsPluginSetWindowCallbackStruct {
+ PRInt32 type;
+ Display* display;
+ Visual* visual;
+ Colormap colormap;
+ PRUint32 depth;
+};
+
+struct nsPluginPrintCallbackStruct {
+ PRInt32 type;
+ FILE* fp;
+};
+
+#endif /* XP_UNIX */
+
+////////////////////////////////////////////////////////////////////////////////
+
+// List of variable names for which NPP_GetValue shall be implemented
+enum nsPluginVariable {
+ nsPluginVariable_NameString = 1,
+ nsPluginVariable_DescriptionString,
+ nsPluginVariable_WindowBool, // XXX go away
+ nsPluginVariable_TransparentBool, // XXX go away?
+ nsPluginVariable_JavaClass, // XXX go away
+ nsPluginVariable_WindowSize,
+ nsPluginVariable_TimerInterval
+ // 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 nsPluginManagerVariable {
+ nsPluginManagerVariable_XDisplay = 1,
+ nsPluginManagerVariable_XtAppContext,
+ nsPluginManagerVariable_NetscapeWindow,
+ nsPluginManagerVariable_JavascriptEnabledBool, // XXX prefs accessor api
+ nsPluginManagerVariable_ASDEnabledBool, // XXX prefs accessor api
+ nsPluginManagerVariable_IsOfflineBool // XXX prefs accessor api
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+enum nsPluginType {
+ nsPluginType_Embedded = 1,
+ nsPluginType_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 nsPluginWindowType {
+ nsPluginWindowType_Window = 1,
+ nsPluginWindowType_Drawable
+};
+
+struct nsPluginWindow {
+ 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 */
+ nsPluginWindowType type; /* Is this a window or a drawable? */
+};
+
+struct nsPluginFullPrint {
+ 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 nsPluginEmbedPrint {
+ nsPluginWindow window;
+ void* platformPrint; /* Platform-specific printing info */
+};
+
+struct nsPluginPrint {
+ nsPluginType mode; /* NP_FULL or nsPluginType_Embedded */
+ union
+ {
+ nsPluginFullPrint fullPrint; /* if mode is NP_FULL */
+ nsPluginEmbedPrint embedPrint; /* if mode is nsPluginType_Embedded */
+ } print;
+};
+
+struct nsPluginEvent {
+
+#if defined(XP_MAC)
+ EventRecord* event;
+ void* window;
+
+#elif defined(XP_PC)
+ 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_PC)
+typedef HRGN nsRegion;
+#elif defined(XP_UNIX)
+typedef Region nsRegion;
+#else
+typedef void *nsRegion;
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsPluginError {
+ nsPluginError_Base = 0,
+ nsPluginError_NoError = 0,
+ nsPluginError_GenericError,
+ nsPluginError_InvalidInstanceError,
+ nsPluginError_InvalidFunctableError,
+ nsPluginError_ModuleLoadFailedError,
+ nsPluginError_OutOfMemoryError,
+ nsPluginError_InvalidPluginError,
+ nsPluginError_InvalidPluginDirError,
+ nsPluginError_IncompatibleVersionError,
+ nsPluginError_InvalidParam,
+ nsPluginError_InvalidUrl,
+ nsPluginError_FileNotFound,
+ nsPluginError_NoData,
+ nsPluginError_StreamNotSeekable
+};
+
+#define NPCallFailed( code ) ((code) != nsPluginError_NoError)
+
+enum nsPluginReason {
+ nsPluginReason_Base = 0,
+ nsPluginReason_Done = 0,
+ nsPluginReason_NetworkErr,
+ nsPluginReason_UserBreak,
+ nsPluginReason_NoReason
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Classes
+////////////////////////////////////////////////////////////////////////////////
+
+// Classes that must be implemented by the plugin DLL:
+struct nsIPlugin; // plugin class (MIME-type handler)
+class nsILiveConnectPlugin; // subclass of nsIPlugin
+class nsIPluginInstance; // plugin instance
+class nsIPluginStream; // stream to receive data from the browser
+
+// Classes that are implemented by the browser:
+class nsIPluginManager; // minimum browser requirements
+class nsIFileUtilities; // file utilities (accessible from nsIPluginManager)
+class nsIPluginInstancePeer; // parts of nsIPluginInstance implemented by the browser
+class nsIWindowlessPluginInstancePeer; // subclass of nsIPluginInstancePeer for windowless plugins
+class nsIPluginTagInfo; // describes html tag (accessible from nsIPluginInstancePeer)
+class nsILiveConnectPluginInstancePeer; // subclass of nsIPluginInstancePeer
+class nsIPluginStreamPeer; // parts of nsIPluginStream implemented by the browser
+class nsISeekablePluginStreamPeer; // seekable subclass of nsIPluginStreamPeer
+
+////////////////////////////////////////////////////////////////////////////////
+
+#ifdef XP_MAC
+#pragma options align=reset
+#endif
+
+#endif /* RC_INVOKED */
+#ifdef __OS2__
+#pragma pack()
+#endif
+
+#endif // nsplugindefs_h___
diff --git a/mozilla/modules/plugin/makefile.win b/mozilla/modules/plugin/makefile.win
new file mode 100644
index 00000000000..b4dccf75274
--- /dev/null
+++ b/mozilla/modules/plugin/makefile.win
@@ -0,0 +1,30 @@
+#//------------------------------------------------------------------------
+#//
+#// Makefile to build the MODULES\APPLET tree
+#//
+#//------------------------------------------------------------------------
+
+#//------------------------------------------------------------------------
+#//
+#// Specify the depth of the current directory relative to the
+#// root of NS
+#//
+#//------------------------------------------------------------------------
+DEPTH=..\..
+
+#//------------------------------------------------------------------------
+#//
+#// Specify any "command" targets. (ie. DIRS, INSTALL_FILES, ...)
+#// (these must come before the common makefiles are included)
+#//
+#// DIRS - There are subdirectories to process
+#//
+#//------------------------------------------------------------------------
+DIRS= public src
+
+#//------------------------------------------------------------------------
+#//
+#// Include the common makefile rules
+#//
+#//------------------------------------------------------------------------
+include <$(DEPTH)\config\rules.mak>
diff --git a/mozilla/modules/plugin/public/MANIFEST b/mozilla/modules/plugin/public/MANIFEST
new file mode 100644
index 00000000000..9f6a56fcb1e
--- /dev/null
+++ b/mozilla/modules/plugin/public/MANIFEST
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+#
+# This is a list of local files which get copied to the mozilla:dist directory
+#
+
+nsIFileUtilities.h
+nsIJRILiveConnectPlugin.h
+nsIJRILiveConnectPluginInstancePeer.h
+nsILiveConnectPlugin.h
+nsILiveConnectPluginInstancePeer.h
+nsIPlugin.h
+nsIPluginInstance.h
+nsIPluginInstancePeer.h
+nsIPluginInstancePeer2.h
+nsIPluginManager.h
+nsIPluginManager2.h
+nsIPluginStream.h
+nsIPluginStreamPeer.h
+nsIPluginStreamPeer2.h
+nsIPluginTagInfo.h
+nsIPluginTagInfo2.h
+nsISeekablePluginStreamPeer.h
+nsIWindowlessPluginInstancePeer.h
+nsplugin.h
+nsplugindefs.h
diff --git a/mozilla/modules/plugin/public/Makefile b/mozilla/modules/plugin/public/Makefile
new file mode 100644
index 00000000000..f87022e6eba
--- /dev/null
+++ b/mozilla/modules/plugin/public/Makefile
@@ -0,0 +1,44 @@
+#
+# 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.
+#
+
+DEPTH = ../../..
+
+MODULE = plugin
+
+EXPORTS = \
+ nsIFileUtilities.h \
+ nsIJRILiveConnectPlugin.h \
+ nsIJRILiveConnectPluginInstancePeer.h \
+ nsILiveConnectPlugin.h \
+ nsILiveConnectPluginInstancePeer.h \
+ nsIPlugin.h \
+ nsIPluginInstance.h \
+ nsIPluginInstancePeer.h \
+ nsIPluginInstancePeer2.h \
+ nsIPluginManager.h \
+ nsIPluginManager2.h \
+ nsIPluginStream.h \
+ nsIPluginStreamPeer.h \
+ nsIPluginStreamPeer2.h \
+ nsIPluginTagInfo.h \
+ nsIPluginTagInfo2.h \
+ nsISeekablePluginStreamPeer.h \
+ nsIWindowlessPluginInstancePeer.h \
+ nsplugin.h \
+ nsplugindefs.h
+
+include $(DEPTH)/config/rules.mk
diff --git a/mozilla/modules/plugin/public/makefile.win b/mozilla/modules/plugin/public/makefile.win
new file mode 100644
index 00000000000..4dae17aff4d
--- /dev/null
+++ b/mozilla/modules/plugin/public/makefile.win
@@ -0,0 +1,47 @@
+#!gmake
+#
+# 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.
+
+IGNORE_MANIFEST=1
+
+DEPTH = ..\..\..
+
+MODULE = plugin
+
+EXPORTS = \
+ nsIFileUtilities.h \
+ nsIJRILiveConnectPlugin.h \
+ nsIJRILiveConnectPluginInstancePeer.h \
+ nsILiveConnectPlugin.h \
+ nsILiveConnectPluginInstancePeer.h \
+ nsIPlugin.h \
+ nsIPluginInstance.h \
+ nsIPluginInstancePeer.h \
+ nsIPluginInstancePeer2.h \
+ nsIPluginManager.h \
+ nsIPluginManager2.h \
+ nsIPluginStream.h \
+ nsIPluginStreamPeer.h \
+ nsIPluginStreamPeer2.h \
+ nsIPluginTagInfo.h \
+ nsIPluginTagInfo2.h \
+ nsISeekablePluginStreamPeer.h \
+ nsIWindowlessPluginInstancePeer.h \
+ nsplugin.h \
+ nsplugindefs.h
+
+include <$(DEPTH)/config/rules.mak>
+
diff --git a/mozilla/modules/plugin/public/nsIFileUtilities.h b/mozilla/modules/plugin/public/nsIFileUtilities.h
new file mode 100644
index 00000000000..880435d4d9f
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIFileUtilities.h
@@ -0,0 +1,75 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIFileUtilities_h___
+#define nsIFileUtilities_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// File Utilities Interface
+// This interface reflects operations only available in Communicator 5.0.
+
+class nsIFileUtilities : public nsISupports {
+public:
+
+ // QueryInterface on nsIPluginManager to get this.
+
+ NS_IMETHOD_(const char*)
+ GetProgramPath(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetTempDirPath(void) = 0;
+
+ enum FileNameType { SIGNED_APPLET_DBNAME, TEMP_FILENAME };
+
+ NS_IMETHOD_(nsresult)
+ GetFileName(const char* fn, FileNameType type,
+ char* resultBuf, PRUint32 bufLen) = 0;
+
+ NS_IMETHOD_(nsresult)
+ NewTempFileName(const char* prefix, char* resultBuf, PRUint32 bufLen) = 0;
+
+};
+
+#define NS_IFILEUTILITIES_IID \
+{ /* 89a31ce0-019a-11d2-815b-006008119d7a */ \
+ 0x89a31ce0, \
+ 0x019a, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIFileUtilities_h___ */
diff --git a/mozilla/modules/plugin/public/nsIJRILiveConnectPlugin.h b/mozilla/modules/plugin/public/nsIJRILiveConnectPlugin.h
new file mode 100644
index 00000000000..bc2382ced4b
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIJRILiveConnectPlugin.h
@@ -0,0 +1,77 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIJRILiveConnectPlugin_h__
+#define nsIJRILiveConnectPlugin_h__
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// JRI-Based LiveConnect Classes
+////////////////////////////////////////////////////////////////////////////////
+//
+// This stuff is here so that the browser can support older JRI-based
+// LiveConnected plugins (when using old plugin to new C++-style plugin
+// adapter code).
+//
+// Warning: Don't use this anymore, unless you're sure that you have to!
+////////////////////////////////////////////////////////////////////////////////
+
+#include "jri.h" // ancient
+
+////////////////////////////////////////////////////////////////////////////////
+// JRILiveConnect Plugin Interface
+// This interface defines additional entry points that a plugin developer needs
+// to implement in order for the plugin to support JRI-based LiveConnect,
+// i.e. be scriptable by Java or JavaScript.
+
+class nsIJRILiveConnectPlugin : public nsIPlugin {
+public:
+
+ // (Corresponds to NPP_GetJavaClass.)
+ NS_IMETHOD_(jref)
+ GetJavaClass(void) = 0;
+
+};
+
+#define NS_IJRILIVECONNECTPLUGIN_IID \
+{ /* c94058e0-f772-11d1-815b-006008119d7a */ \
+ 0xc94058e0, \
+ 0xf772, \
+ 0x11d1, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIJRILiveConnectPlugin_h__ */
diff --git a/mozilla/modules/plugin/public/nsIJRILiveConnectPluginInstancePeer.h b/mozilla/modules/plugin/public/nsIJRILiveConnectPluginInstancePeer.h
new file mode 100644
index 00000000000..bbd8bac6f1b
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIJRILiveConnectPluginInstancePeer.h
@@ -0,0 +1,86 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIJRILiveConnectPluginInstancePeer_h__
+#define nsIJRILiveConnectPluginInstancePeer_h__
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// JRI-Based LiveConnect Classes
+////////////////////////////////////////////////////////////////////////////////
+//
+// This stuff is here so that the browser can support older JRI-based
+// LiveConnected plugins (when using old plugin to new C++-style plugin
+// adapter code).
+//
+// Warning: Don't use this anymore, unless you're sure that you have to!
+////////////////////////////////////////////////////////////////////////////////
+
+#include "jri.h" // ancient
+
+////////////////////////////////////////////////////////////////////////////////
+// JRILiveConnect Plugin Instance Peer Interface
+// Browsers that support JRI-based LiveConnect implement this subclass of
+// plugin instance peer.
+
+class nsIJRILiveConnectPluginInstancePeer : public nsISupports {
+public:
+
+ // (Corresponds to NPN_GetJavaPeer.)
+ NS_IMETHOD_(jref)
+ GetJavaPeer(void) = 0;
+
+};
+
+#define NS_IJRILIVECONNECTPLUGININSTANCEPEER_IID \
+{ /* 25b63f40-f773-11d1-815b-006008119d7a */ \
+ 0x25b63f40, \
+ 0xf773, \
+ 0x11d1, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+// QueryInterface for this IID on nsIPluginManager to get a JRIEnv
+// XXX change this
+#define NS_IJRIENV_IID \
+{ /* f9d4ea00-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xf9d4ea00, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIJRILiveConnectPluginInstancePeer_h__ */
diff --git a/mozilla/modules/plugin/public/nsILiveConnectPlugin.h b/mozilla/modules/plugin/public/nsILiveConnectPlugin.h
new file mode 100644
index 00000000000..31753271bcd
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsILiveConnectPlugin.h
@@ -0,0 +1,65 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsILiveConnectPlugin_h__
+#define nsILiveConnectPlugin_h__
+
+#include "nsplugindefs.h"
+#include "jni.h" // standard JVM API
+
+////////////////////////////////////////////////////////////////////////////////
+// LiveConnect Plugin Interface
+// This interface defines additional entry points that a plugin developer needs
+// to implement in order for the plugin to support JNI-based LiveConnect,
+// i.e. be scriptable by Java or JavaScript.
+
+class nsILiveConnectPlugin : public nsIPlugin {
+public:
+
+ // (New JNI-based entry point, roughly corresponds to NPP_GetJavaClass.)
+ NS_IMETHOD_(jclass)
+ GetJavaClass(void) = 0;
+
+};
+
+#define NS_ILIVECONNECTPLUGIN_IID \
+{ /* cf134df0-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xcf134df0, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsILiveConnectPlugin_h__ */
diff --git a/mozilla/modules/plugin/public/nsILiveConnectPluginInstancePeer.h b/mozilla/modules/plugin/public/nsILiveConnectPluginInstancePeer.h
new file mode 100644
index 00000000000..508b51f3e08
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsILiveConnectPluginInstancePeer.h
@@ -0,0 +1,74 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsILiveConnectPluginInstancePeer_h___
+#define nsILiveConnectPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+#include "jni.h" // standard JVM API
+
+////////////////////////////////////////////////////////////////////////////////
+// LiveConnect Plugin Instance Peer Interface
+// Browsers that support JNI-based LiveConnect implement this subclass of
+// plugin instance peer.
+
+class nsILiveConnectPluginInstancePeer : public nsISupports {
+public:
+
+ // (New JNI-based entry point, roughly corresponds to NPN_GetJavaPeer.)
+ NS_IMETHOD_(jobject)
+ GetJavaPeer(void) = 0;
+
+};
+
+#define NS_ILIVECONNECTPLUGININSTANCEPEER_IID \
+{ /* 1e3502a0-a1bd-11d1-85b1-00805f0e4dfe */ \
+ 0x1e3502a0, \
+ 0xa1bd, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+// QueryInterface for this IID on nsIPluginManager to get a JNIEnv
+// XXX change this
+#define NS_IJNIENV_IID \
+{ /* 04610650-a1bd-11d1-85b1-00805f0e4dfe */ \
+ 0x04610650, \
+ 0xa1bd, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsILiveConnectPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPlugin.h b/mozilla/modules/plugin/public/nsIPlugin.h
new file mode 100644
index 00000000000..8512a581534
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPlugin.h
@@ -0,0 +1,97 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPlugin_h___
+#define nsIPlugin_h___
+
+#include "nsplugindefs.h"
+#include "nsIFactory.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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. nsILiveConnectPlugin.
+
+struct nsIPlugin : public nsIFactory {
+public:
+
+ // This call initializes the plugin and will be called before any new
+ // instances are created. It is passed browserInterfaces on which QueryInterface
+ // may be used to obtain an nsIPluginManager, and other interfaces.
+ NS_IMETHOD_(nsPluginError)
+ Initialize(nsISupports* browserInterfaces) = 0;
+
+ // (Corresponds to NPP_Shutdown.)
+ // Called when the browser is done with the plugin factory, or when
+ // the plugin is disabled by the user.
+ NS_IMETHOD_(nsPluginError)
+ Shutdown(void) = 0;
+
+ // (Corresponds to NPP_GetMIMEDescription.)
+ NS_IMETHOD_(const char*)
+ GetMIMEDescription(void) = 0;
+
+ // (Corresponds to NPP_GetValue.)
+ NS_IMETHOD_(nsPluginError)
+ GetValue(nsPluginVariable variable, void *value) = 0;
+
+ // (Corresponds to NPP_SetValue.)
+ NS_IMETHOD_(nsPluginError)
+ SetValue(nsPluginVariable variable, void *value) = 0;
+
+ // The old NPP_New call has been factored into two plugin instance methods:
+ //
+ // CreateInstance -- 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).
+ //
+ // nsIPluginInstance::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.
+
+};
+
+#define NS_IPLUGIN_IID \
+{ /* df773070-0199-11d2-815b-006008119d7a */ \
+ 0xdf773070, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPlugin_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginInstance.h b/mozilla/modules/plugin/public/nsIPluginInstance.h
new file mode 100644
index 00000000000..29825c92f13
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginInstance.h
@@ -0,0 +1,111 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstance_h___
+#define nsIPluginInstance_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Interface
+
+// (Corresponds to NPP object.)
+class nsIPluginInstance : public nsISupports {
+public:
+
+ NS_IMETHOD_(nsPluginError)
+ Initialize(nsIPluginInstancePeer* peer) = 0;
+
+ // Required backpointer to the peer.
+ NS_IMETHOD_(nsIPluginInstancePeer*)
+ GetPeer(void) = 0;
+
+ // See comment for nsIPlugin::CreateInstance, above.
+ NS_IMETHOD_(nsPluginError)
+ 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_(nsPluginError)
+ Stop(void) = 0;
+
+ NS_IMETHOD_(nsPluginError)
+ Destroy(void) = 0;
+
+ // (Corresponds to NPP_SetWindow.)
+ NS_IMETHOD_(nsPluginError)
+ SetWindow(nsPluginWindow* window) = 0;
+
+ // (Corresponds to NPP_NewStream.)
+ NS_IMETHOD_(nsPluginError)
+ NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
+
+ // (Corresponds to NPP_Print.)
+ NS_IMETHOD_(void)
+ Print(nsPluginPrint* platformPrint) = 0;
+
+ // (Corresponds to NPP_HandleEvent.)
+ // Note that for Unix and Mac the nsPluginEvent 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(nsPluginEvent* event) = 0;
+
+ // (Corresponds to NPP_URLNotify.)
+ NS_IMETHOD_(void)
+ URLNotify(const char* url, const char* target,
+ nsPluginReason reason, void* notifyData) = 0;
+
+};
+
+#define NS_IPLUGININSTANCE_IID \
+{ /* ebe00f40-0199-11d2-815b-006008119d7a */ \
+ 0xebe00f40, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstance_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginInstancePeer.h b/mozilla/modules/plugin/public/nsIPluginInstancePeer.h
new file mode 100644
index 00000000000..98229dee428
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginInstancePeer.h
@@ -0,0 +1,80 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstancePeer_h___
+#define nsIPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Peer Interface
+
+enum nsPluginTagType {
+ nsPluginTagType_Unknown,
+ nsPluginTagType_Embed,
+ nsPluginTagType_Object,
+ nsPluginTagType_Applet
+};
+
+class nsIPluginInstancePeer : public nsISupports {
+public:
+
+ // (Corresponds to NPP_New's MIMEType argument.)
+ NS_IMETHOD_(nsMIMEType)
+ GetMIMEType(void) = 0;
+
+ // (Corresponds to NPP_New's mode argument.)
+ NS_IMETHOD_(nsPluginType)
+ GetMode(void) = 0;
+
+ // (Corresponds to NPN_NewStream.)
+ NS_IMETHOD_(nsPluginError)
+ NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result) = 0;
+
+ // (Corresponds to NPN_Status.)
+ NS_IMETHOD_(void)
+ ShowStatus(const char* message) = 0;
+
+};
+
+#define NS_IPLUGININSTANCEPEER_IID \
+{ /* 4b7cea20-019b-11d2-815b-006008119d7a */ \
+ 0x4b7cea20, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginInstancePeer2.h b/mozilla/modules/plugin/public/nsIPluginInstancePeer2.h
new file mode 100644
index 00000000000..f3b3acbe02f
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginInstancePeer2.h
@@ -0,0 +1,79 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginInstancePeer2_h___
+#define nsIPluginInstancePeer2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Instance Peer 2 Interface
+// These extensions to nsIPluginManager are only available in Communicator 5.0.
+
+class nsIPluginInstancePeer2 : public nsIPluginInstancePeer {
+public:
+
+ ////////////////////////////////////////////////////////////////////////////
+ // 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;
+
+ // On the mac (and most likely win16), network activity can
+ // only occur on the main thread. Therefore, we provide a hook
+ // here for the case that the main thread needs to tickle itself.
+ // In this case, we make sure that we give up the monitor so that
+ // the tickle code can notify it without freezing.
+ NS_IMETHOD_(PRBool)
+ Tickle(void) = 0;
+
+};
+
+#define NS_IPLUGININSTANCEPEER2_IID \
+{ /* 51b52b80-019b-11d2-815b-006008119d7a */ \
+ 0x51b52b80, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginInstancePeer2_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginManager.h b/mozilla/modules/plugin/public/nsIPluginManager.h
new file mode 100644
index 00000000000..dffd0376f75
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginManager.h
@@ -0,0 +1,128 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginManager_h___
+#define nsIPluginManager_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsIPluginManager : public nsISupports {
+public:
+
+ // (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;
+
+ // (Corresponds to NPN_UserAgent.)
+ NS_IMETHOD_(const char*)
+ UserAgent(void) = 0;
+
+ // (Corresponds to NPN_GetValue.)
+ NS_IMETHOD_(nsPluginError)
+ GetValue(nsPluginManagerVariable variable, void *value) = 0;
+
+ // (Corresponds to NPN_SetValue.)
+ NS_IMETHOD_(nsPluginError)
+ SetValue(nsPluginManagerVariable variable, void *value) = 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:
+ // peer: A plugin instance peer. The peer's window will be used to display
+ // progress information. If NULL, the load happens in the background.
+ // 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_(nsPluginError)
+ GetURL(nsISupports* peer, 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:
+ // peer: A plugin instance peer. The peer's window will be used to display
+ // progress information. If NULL, the load happens in the background.
+ // 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_(nsPluginError)
+ PostURL(nsISupports* peer, 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;
+
+};
+
+#define NS_IPLUGINMANAGER_IID \
+{ /* f10b9600-a1bc-11d1-85b1-00805f0e4dfe */ \
+ 0xf10b9600, \
+ 0xa1bc, \
+ 0x11d1, \
+ {0x85, 0xb1, 0x00, 0x80, 0x5f, 0x0e, 0x4d, 0xfe} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginManager_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginManager2.h b/mozilla/modules/plugin/public/nsIPluginManager2.h
new file mode 100644
index 00000000000..2ac771339e9
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginManager2.h
@@ -0,0 +1,67 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginManager2_h___
+#define nsIPluginManager2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Manager 2 Interface
+// These extensions to nsIPluginManager are only available in Communicator 5.0.
+
+class nsIPluginManager2 : public nsIPluginManager {
+public:
+
+ NS_IMETHOD_(void)
+ BeginWaitCursor(void) = 0;
+
+ NS_IMETHOD_(void)
+ EndWaitCursor(void) = 0;
+
+ NS_IMETHOD_(PRBool)
+ SupportsURLProtocol(const char* protocol) = 0;
+
+};
+
+#define NS_IPLUGINMANAGER2_IID \
+{ /* 29c4ae70-019a-11d2-815b-006008119d7a */ \
+ 0x29c4ae70, \
+ 0x019a, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginManager2_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginStream.h b/mozilla/modules/plugin/public/nsIPluginStream.h
new file mode 100644
index 00000000000..e3f9b2c7e13
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginStream.h
@@ -0,0 +1,66 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStream_h___
+#define nsIPluginStream_h___
+
+#include "nsplugindefs.h"
+#include "nsIOutputStream.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Stream Interface
+
+class nsIPluginStream : public nsIOutputStream {
+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 NS_IPLUGINSTREAM_IID \
+{ /* f287dd50-0199-11d2-815b-006008119d7a */ \
+ 0xf287dd50, \
+ 0x0199, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStream_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginStreamPeer.h b/mozilla/modules/plugin/public/nsIPluginStreamPeer.h
new file mode 100644
index 00000000000..da46281e8be
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginStreamPeer.h
@@ -0,0 +1,84 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStreamPeer_h___
+#define nsIPluginStreamPeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsIPluginStreamPeer : public nsISupports {
+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;
+
+ // (Corresponds to NPP_DestroyStream's reason argument.)
+ NS_IMETHOD_(nsPluginReason)
+ GetReason(void) = 0;
+
+ // (Corresponds to NPP_NewStream's MIMEType argument.)
+ NS_IMETHOD_(nsMIMEType)
+ GetMIMEType(void) = 0;
+
+};
+
+#define NS_IPLUGINSTREAMPEER_IID \
+{ /* 717b1e90-019b-11d2-815b-006008119d7a */ \
+ 0x717b1e90, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStreamPeer_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h b/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h
new file mode 100644
index 00000000000..30a69a33631
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h
@@ -0,0 +1,70 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginStreamPeer2_h___
+#define nsIPluginStreamPeer2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Stream Peer Interface
+// These extensions to nsIPluginStreamPeer are only available in Communicator 5.0.
+
+class nsIPluginStreamPeer2 : public nsIPluginStreamPeer {
+public:
+
+ NS_IMETHOD_(PRUint32)
+ GetContentLength(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetHeaderFieldCount(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetHeaderFieldKey(PRUint32 index) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetHeaderField(PRUint32 index) = 0;
+
+};
+
+#define NS_IPLUGINSTREAMPEER2_IID \
+{ /* 77083af0-019b-11d2-815b-006008119d7a */ \
+ 0x77083af0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginStreamPeer2_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginTagInfo.h b/mozilla/modules/plugin/public/nsIPluginTagInfo.h
new file mode 100644
index 00000000000..3171c135265
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginTagInfo.h
@@ -0,0 +1,74 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginTagInfo_h___
+#define nsIPluginTagInfo_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Tag Info Interface
+// This interface provides information about the HTML tag on the page.
+// Some day this might get superseded by a DOM API.
+
+class nsIPluginTagInfo : public nsISupports {
+public:
+
+ // QueryInterface on nsIPluginInstancePeer to get this.
+
+ // (Corresponds to NPP_New's argc, argn, and argv arguments.)
+ // 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_(nsPluginError)
+ GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values) = 0;
+
+ // Get the value for the named attribute. Returns NULL
+ // if the attribute was not set.
+ NS_IMETHOD_(const char*)
+ GetAttribute(const char* name) = 0;
+
+};
+
+#define NS_IPLUGINTAGINFO_IID \
+{ /* 5f1ec1d0-019b-11d2-815b-006008119d7a */ \
+ 0x5f1ec1d0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginTagInfo_h___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginTagInfo2.h b/mozilla/modules/plugin/public/nsIPluginTagInfo2.h
new file mode 100644
index 00000000000..f023e58b7c1
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIPluginTagInfo2.h
@@ -0,0 +1,110 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIPluginTagInfo2_h___
+#define nsIPluginTagInfo2_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Plugin Tag Info Interface
+// These extensions to nsIPluginTagInfo are only available in Communicator 5.0.
+
+class nsIPluginTagInfo2 : public nsIPluginTagInfo {
+public:
+
+ // QueryInterface on nsIPluginInstancePeer to get this.
+
+ // Get the type of the HTML tag that was used ot instantiate this
+ // plugin. Currently supported tags are EMBED, OBJECT and APPLET.
+ NS_IMETHOD_(nsPluginTagType)
+ GetTagType(void) = 0;
+
+ // Get the complete text of the HTML tag that was
+ // used to instantiate this plugin
+ NS_IMETHOD_(const char *)
+ GetTagText(void) = 0;
+
+ // 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_(nsPluginError)
+ GetParameters(PRUint16& n, const char*const*& names, const char*const*& values) = 0;
+
+ // Get the value for the named parameter. Returns null
+ // if the parameter was not set.
+ NS_IMETHOD_(const char*)
+ GetParameter(const char* name) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetDocumentBase(void) = 0;
+
+ // Return an encoding whose name is specified in:
+ // http://java.sun.com/products/jdk/1.1/docs/guide/intl/intl.doc.html#25303
+ NS_IMETHOD_(const char*)
+ GetDocumentEncoding(void) = 0;
+
+ NS_IMETHOD_(const char*)
+ GetAlignment(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetWidth(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetHeight(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetBorderVertSpace(void) = 0;
+
+ NS_IMETHOD_(PRUint32)
+ GetBorderHorizSpace(void) = 0;
+
+ // Returns a unique id for the current document on which the
+ // plugin is displayed.
+ NS_IMETHOD_(PRUint32)
+ GetUniqueID(void) = 0;
+
+};
+
+#define NS_IPLUGINTAGINFO2_IID \
+{ /* 6a49c9a0-019b-11d2-815b-006008119d7a */ \
+ 0x6a49c9a0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIPluginTagInfo2_h___ */
diff --git a/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h b/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h
new file mode 100644
index 00000000000..dcfd07f7519
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h
@@ -0,0 +1,67 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsISeekablePluginStreamPeer_h___
+#define nsISeekablePluginStreamPeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsISeekablePluginStreamPeer : public nsISupports {
+public:
+
+ // QueryInterface for this class corresponds to NPP_NewStream's
+ // seekable argument.
+
+ // (Corresponds to NPN_RequestRead.)
+ NS_IMETHOD_(nsPluginError)
+ RequestRead(nsByteRange* rangeList) = 0;
+
+};
+
+#define NS_ISEEKABLEPLUGINSTREAMPEER_IID \
+{ /* 7e028d20-019b-11d2-815b-006008119d7a */ \
+ 0x7e028d20, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsISeekablePluginStreamPeer_h___ */
diff --git a/mozilla/modules/plugin/public/nsIWindowlessPluginInstancePeer.h b/mozilla/modules/plugin/public/nsIWindowlessPluginInstancePeer.h
new file mode 100644
index 00000000000..14d4ccac468
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsIWindowlessPluginInstancePeer.h
@@ -0,0 +1,69 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this interface fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsIWindowlessPluginInstancePeer_h___
+#define nsIWindowlessPluginInstancePeer_h___
+
+#include "nsplugindefs.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// Windowless Plugin Instance Peer Interface
+
+class nsIWindowlessPluginInstancePeer : public nsISupports {
+public:
+
+ // (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;
+
+};
+
+#define NS_IWINDOWLESSPLUGININSTANCEPEER_IID \
+{ /* 57b4e2f0-019b-11d2-815b-006008119d7a */ \
+ 0x57b4e2f0, \
+ 0x019b, \
+ 0x11d2, \
+ {0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+#endif /* nsIWindowlessPluginInstancePeer_h___ */
diff --git a/mozilla/modules/plugin/public/nsplugin.h b/mozilla/modules/plugin/public/nsplugin.h
new file mode 100644
index 00000000000..d4f349501e0
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsplugin.h
@@ -0,0 +1,238 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
This is the master header file that includes most of the other headers
+ * you'll need to write a plugin.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The following diagram depicts the relationships between various objects
+ * implementing the new plugin interfaces. QueryInterface can be used to switch
+ * between interfaces in the same box:
+ *
+ *
+ * the plugin (only 1)
+ * +----------------------+
+ * | nsIPlugin or |<- - - - - -NSGetFactory()
+ * | nsILiveConnectPlugin |
+ * +----------------------+
+ * |
+ * |
+ * | instances (many) streams to receive URL data (many)
+ * | +-------------------+ +-----------------+
+ * | | nsIPluginInstance |+ | nsIPluginStream |+
+ * | | || | ||
+ * | +-------------------+| +-----------------+|
+ * | +------|-----------+ +------|---------+
+ * | | |
+ * | PLUGIN SIDE |peer |peer
+ *~~~~|~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~
+ * | BROWSER SIDE | |
+ * | v v
+ * | +---------------------------------+ +----------------------------+
+ * | | nsIPluginInstancePeer |+ | nsIPluginStreamPeer |+
+ * | | nsIPluginInstancePeer2 || | nsISeekablePluginStreamPeer||
+ * | | nsIWindowlessPluginInstancePeer || | nsIPluginstreamPeer2 ||
+ * | | nsILiveConnectPluginInstancePeer|| +----------------------------+|
+ * | | nsIPluginTagInfo || +---------------------------+
+ * | | nsIPluginTagInfo2 ||
+ * | +---------------------------------+|
+ * | +--------------------------------+
+ * |
+ * |
+ * v the browser (only 1)
+ * +---------------------+
+ * | nsIPluginManager |
+ * | nsIPluginManager2 |
+ * | nsIFileUtilities |
+ * | nsIPref |
+ * | nsICacheManager ... |
+ * +---------------------+
+ *
+ */
+
+#ifndef nsplugins_h___
+#define nsplugins_h___
+
+#include "nsRepository.h" // for NSGetFactory
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces which must be implemented by a plugin
+ * These interfaces have NPP equivalents in pre-5.0 browsers (see npapi.h).
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * NSGetFactory 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 nsIPlugin::CreateInstance.
+ */
+// (Declared in nsRepository.h)
+//extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass,
+// nsIFactory **aFactory);
+
+/**
+ * A plugin object is used to create new plugin instances. It manages the
+ * global state of all plugins with the same implementation.
+ */
+#include "nsIPlugin.h"
+
+/**
+ * A plugin instance represents a particular activation of a plugin on a page.
+ */
+#include "nsIPluginInstance.h"
+
+/**
+ * A plugin stream gets instantiated when a plugin instance receives data from
+ * the browser.
+ */
+#include "nsIPluginStream.h"
+
+/**
+ * The nsILiveConnectPlugin interface provides additional operations that a
+ * plugin must implement if it is to be controlled by JavaScript through
+ * LiveConnect.
+ *
+ * Note that this interface is part of a new JNI-based LiveConnect
+ * implementation and superceeds that provided prior to Communicator 5.0.
+ */
+#include "nsILiveConnectPlugin.h"
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces implemented by the browser:
+ * These interfaces have NPN equivalents in pre-5.0 browsers (see npapi.h).
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The plugin manager which is the main point of interaction with the browser
+ * and provides general operations needed by a plugin.
+ */
+#include "nsIPluginManager.h"
+
+/**
+ * A plugin instance peer gets created by the browser and associated with each
+ * plugin instance to represent tag information and other callbacks needed by
+ * the plugin instance.
+ */
+#include "nsIPluginInstancePeer.h"
+
+/**
+ * The nsIPluginTagInfo interface provides information about the html tag
+ * that was used to instantiate the plugin instance.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIPluginTagInfo.h"
+
+/**
+ * The nsIWindowlessPluginInstancePeer provides additional operations for
+ * windowless plugins.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIWindowlessPluginInstancePeer.h"
+
+/**
+ * A plugin stream peer gets create by the browser and associated with each
+ * plugin stream to represent stream and URL information, and provides
+ * other callbacks needed by the plugin stream.
+ */
+#include "nsIPluginStreamPeer.h"
+
+/**
+ * The nsISeekablePluginStreamPeer provides additional operations for seekable
+ * plugin streams.
+ *
+ * To obtain: QueryInterface on nsIPluginStreamPeer
+ */
+#include "nsISeekablePluginStreamPeer.h"
+
+////////////////////////////////////////////////////////////////////////////////
+/**
+ * Interfaces implemented by the browser (new for 5.0):
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+/**
+ * The nsIPluginManager2 interface provides additional plugin manager features
+ * only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginManager
+ */
+#include "nsIPluginManager2.h"
+
+/**
+ * The nsIFileUtilities interface provides operations to manage temporary
+ * files and directories.
+ *
+ * To obtain: QueryInterface on nsIPluginManager
+ */
+#include "nsIFileUtilities.h"
+
+/**
+ * The nsIPluginInstancePeer2 interface provides additional plugin instance
+ * peer features only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsIPluginInstancePeer2.h"
+
+/**
+ * The nsILiveConnectPluginInstancePeer allows plugins to be manipulated
+ * by JavaScript, providing basic scriptability.
+ *
+ * Note that this interface is part of a new JNI-based LiveConnect
+ * implementation and superceeds that provided prior to Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginInstancePeer
+ */
+#include "nsILiveConnectPluginInstancePeer.h"
+
+/**
+ * The nsIPluginStreamPeer2 interface provides additional plugin stream
+ * peer features only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginStreamPeer
+ */
+#include "nsIPluginStreamPeer2.h"
+
+/**
+ * The nsIPluginTagInfo2 interface provides additional html tag information
+ * only available in Communicator 5.0.
+ *
+ * To obtain: QueryInterface on nsIPluginTagInfo
+ */
+#include "nsIPluginTagInfo2.h"
+
+////////////////////////////////////////////////////////////////////////////////
+#endif // nsplugins_h___
diff --git a/mozilla/modules/plugin/public/nsplugindefs.h b/mozilla/modules/plugin/public/nsplugindefs.h
new file mode 100644
index 00000000000..3d2e45d9b07
--- /dev/null
+++ b/mozilla/modules/plugin/public/nsplugindefs.h
@@ -0,0 +1,365 @@
+/* -*- 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
+ * 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 that
+ * get linked with the plugin. You will however need to link with the "backward
+ * adapter" (badapter.cpp) in order to allow your plugin to run in pre-5.0
+ * browsers.
+ *
+ *
See nsplugin.h for an overview of how this fits with the
+ * overall plugin architecture.
+ */
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef nsplugindefs_h___
+#define nsplugindefs_h___
+
+#ifdef __OS2__
+#pragma pack(1)
+#endif
+
+#ifdef XP_MAC
+ #include
+ #include
+#endif
+
+#ifdef XP_UNIX
+ #include
+ #include
+#endif
+
+#ifdef XP_PC
+ #include
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+/* 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 NS_INFO_ProductVersion { 1,0,0,1,}
+
+RCDATA NS_INFO_MIMEType { "video/x-video|",
+ "video/x-flick\0" }
+RCDATA NS_INFO_FileExtents { "avi|",
+ "flc\0" }
+RCDATA NS_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
+ "MMOS2 Flc/Fli player(*.flc)\0" }
+
+RCDATA NS_INFO_FileVersion { 1,0,0,1 }
+RCDATA NS_INFO_CompanyName { "Netscape Communications\0" }
+RCDATA NS_INFO_FileDescription { "NPAVI32 Extension DLL\0"
+RCDATA NS_INFO_InternalName { "NPAVI32\0" )
+RCDATA NS_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
+RCDATA NS_INFO_OriginalFilename { "NVAPI32.DLL" }
+RCDATA NS_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
+
+*/
+
+
+/* RC_DATA types for version info - required */
+#define NS_INFO_ProductVersion 1
+#define NS_INFO_MIMEType 2
+#define NS_INFO_FileOpenName 3
+#define NS_INFO_FileExtents 4
+
+/* RC_DATA types for version info - used if found */
+#define NS_INFO_FileDescription 5
+#define NS_INFO_ProductName 6
+
+/* RC_DATA types for version info - optional */
+#define NS_INFO_CompanyName 7
+#define NS_INFO_FileVersion 8
+#define NS_INFO_InternalName 9
+#define NS_INFO_LegalCopyright 10
+#define NS_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
+
+#include
+
+/*
+ * Callback Structures.
+ *
+ * These are used to pass additional platform specific information.
+ */
+enum nsPluginCallbackType {
+ nsPluginCallbackType_SetWindow = 1,
+ nsPluginCallbackType_Print
+};
+
+struct nsPluginAnyCallbackStruct {
+ PRInt32 type;
+};
+
+struct nsPluginSetWindowCallbackStruct {
+ PRInt32 type;
+ Display* display;
+ Visual* visual;
+ Colormap colormap;
+ PRUint32 depth;
+};
+
+struct nsPluginPrintCallbackStruct {
+ PRInt32 type;
+ FILE* fp;
+};
+
+#endif /* XP_UNIX */
+
+////////////////////////////////////////////////////////////////////////////////
+
+// List of variable names for which NPP_GetValue shall be implemented
+enum nsPluginVariable {
+ nsPluginVariable_NameString = 1,
+ nsPluginVariable_DescriptionString,
+ nsPluginVariable_WindowBool, // XXX go away
+ nsPluginVariable_TransparentBool, // XXX go away?
+ nsPluginVariable_JavaClass, // XXX go away
+ nsPluginVariable_WindowSize,
+ nsPluginVariable_TimerInterval
+ // 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 nsPluginManagerVariable {
+ nsPluginManagerVariable_XDisplay = 1,
+ nsPluginManagerVariable_XtAppContext,
+ nsPluginManagerVariable_NetscapeWindow,
+ nsPluginManagerVariable_JavascriptEnabledBool, // XXX prefs accessor api
+ nsPluginManagerVariable_ASDEnabledBool, // XXX prefs accessor api
+ nsPluginManagerVariable_IsOfflineBool // XXX prefs accessor api
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+enum nsPluginType {
+ nsPluginType_Embedded = 1,
+ nsPluginType_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 nsPluginWindowType {
+ nsPluginWindowType_Window = 1,
+ nsPluginWindowType_Drawable
+};
+
+struct nsPluginWindow {
+ 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 */
+ nsPluginWindowType type; /* Is this a window or a drawable? */
+};
+
+struct nsPluginFullPrint {
+ 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 nsPluginEmbedPrint {
+ nsPluginWindow window;
+ void* platformPrint; /* Platform-specific printing info */
+};
+
+struct nsPluginPrint {
+ nsPluginType mode; /* NP_FULL or nsPluginType_Embedded */
+ union
+ {
+ nsPluginFullPrint fullPrint; /* if mode is NP_FULL */
+ nsPluginEmbedPrint embedPrint; /* if mode is nsPluginType_Embedded */
+ } print;
+};
+
+struct nsPluginEvent {
+
+#if defined(XP_MAC)
+ EventRecord* event;
+ void* window;
+
+#elif defined(XP_PC)
+ 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_PC)
+typedef HRGN nsRegion;
+#elif defined(XP_UNIX)
+typedef Region nsRegion;
+#else
+typedef void *nsRegion;
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+// 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 nsPluginError {
+ nsPluginError_Base = 0,
+ nsPluginError_NoError = 0,
+ nsPluginError_GenericError,
+ nsPluginError_InvalidInstanceError,
+ nsPluginError_InvalidFunctableError,
+ nsPluginError_ModuleLoadFailedError,
+ nsPluginError_OutOfMemoryError,
+ nsPluginError_InvalidPluginError,
+ nsPluginError_InvalidPluginDirError,
+ nsPluginError_IncompatibleVersionError,
+ nsPluginError_InvalidParam,
+ nsPluginError_InvalidUrl,
+ nsPluginError_FileNotFound,
+ nsPluginError_NoData,
+ nsPluginError_StreamNotSeekable
+};
+
+#define NPCallFailed( code ) ((code) != nsPluginError_NoError)
+
+enum nsPluginReason {
+ nsPluginReason_Base = 0,
+ nsPluginReason_Done = 0,
+ nsPluginReason_NetworkErr,
+ nsPluginReason_UserBreak,
+ nsPluginReason_NoReason
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Classes
+////////////////////////////////////////////////////////////////////////////////
+
+// Classes that must be implemented by the plugin DLL:
+struct nsIPlugin; // plugin class (MIME-type handler)
+class nsILiveConnectPlugin; // subclass of nsIPlugin
+class nsIPluginInstance; // plugin instance
+class nsIPluginStream; // stream to receive data from the browser
+
+// Classes that are implemented by the browser:
+class nsIPluginManager; // minimum browser requirements
+class nsIFileUtilities; // file utilities (accessible from nsIPluginManager)
+class nsIPluginInstancePeer; // parts of nsIPluginInstance implemented by the browser
+class nsIWindowlessPluginInstancePeer; // subclass of nsIPluginInstancePeer for windowless plugins
+class nsIPluginTagInfo; // describes html tag (accessible from nsIPluginInstancePeer)
+class nsILiveConnectPluginInstancePeer; // subclass of nsIPluginInstancePeer
+class nsIPluginStreamPeer; // parts of nsIPluginStream implemented by the browser
+class nsISeekablePluginStreamPeer; // seekable subclass of nsIPluginStreamPeer
+
+////////////////////////////////////////////////////////////////////////////////
+
+#ifdef XP_MAC
+#pragma options align=reset
+#endif
+
+#endif /* RC_INVOKED */
+#ifdef __OS2__
+#pragma pack()
+#endif
+
+#endif // nsplugindefs_h___
diff --git a/mozilla/modules/plugin/src/MANIFEST b/mozilla/modules/plugin/src/MANIFEST
new file mode 100644
index 00000000000..1c3d36794cd
--- /dev/null
+++ b/mozilla/modules/plugin/src/MANIFEST
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+#
+# This is a list of local files which get copied to the mozilla:dist directory
+#
+
+nppg.h
+npupp.h
+npglue.h
+nppriv.h
diff --git a/mozilla/modules/plugin/src/Makefile b/mozilla/modules/plugin/src/Makefile
new file mode 100644
index 00000000000..4d92c13bb44
--- /dev/null
+++ b/mozilla/modules/plugin/src/Makefile
@@ -0,0 +1,46 @@
+#!gmake
+#
+# 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.
+
+DEPTH = ../../..
+
+MODULE = plug
+LIBRARY_NAME = plug
+
+CSRCS = npassoc.c
+
+CPPSRCS = nsplugin.cpp
+
+EXPORTS = nppg.h npupp.h npglue.h nppriv.h
+
+REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom netcnvts oji ojiimpl
+
+ifeq ($(subst /,_,$(shell uname -s)),OS2)
+CPPSRCS = npwplat.cpp
+REQUIRES += xp libfont os2font jtools
+endif
+
+CPPSRCS += npglue.cpp
+
+include $(DEPTH)/config/rules.mk
+
+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)
diff --git a/mozilla/modules/plugin/src/makefile.win b/mozilla/modules/plugin/src/makefile.win
new file mode 100644
index 00000000000..644fd86c80a
--- /dev/null
+++ b/mozilla/modules/plugin/src/makefile.win
@@ -0,0 +1,47 @@
+#!gmake
+#
+# 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.
+
+IGNORE_MANIFEST=1
+
+DEPTH= ..\..\..
+
+MODULE = plugimpl
+
+EXPORTS = \
+ nppg.h \
+ npupp.h \
+ npglue.h \
+ nppriv.h
+
+LIBRARY_NAME = plug
+
+LINCS = -I$(DIST)\include \
+ -I$(PUBLIC)\plugin \
+ -I$(PUBLIC)\java \
+ -I$(PUBLIC)\pref \
+ -I$(PUBLIC)\js \
+ -I$(PUBLIC)\lay \
+ -I$(PUBLIC)\style \
+ -I$(PUBLIC)\xpcom \
+ -I$(PUBLIC)\oji \
+ -I$(PUBLIC)\ojiimpl
+
+OBJS = .\$(OBJDIR)\npassoc.obj \
+ .\$(OBJDIR)\npglue.obj
+
+include <$(DEPTH)/config/rules.mak>
+
diff --git a/mozilla/modules/plugin/src/npassoc.c b/mozilla/modules/plugin/src/npassoc.c
new file mode 100644
index 00000000000..2116011f53e
--- /dev/null
+++ b/mozilla/modules/plugin/src/npassoc.c
@@ -0,0 +1,239 @@
+/* -*- 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.
+ */
+
+/*
+ * npassoc.c $Revision: 1.1 $
+ * some xp mime-type file extension associations
+ */
+
+#include "npassoc.h"
+#include "xp_mem.h"
+#include "xp_mcom.h"
+#include "net.h"
+
+static NPFileTypeAssoc *np_fassoc_list=0; /* should use xp hash */
+
+extern void NET_cdataAdd(NET_cdataStruct *cd);
+
+#define NP_MAX_EXTS 64
+static char *np_array[NP_MAX_EXTS];
+
+/* allocate and fill a null-terminated array of extensions from
+ a comma and space delimited list */
+static char **
+np_parse_exts(const char *exts)
+{
+ char *p, *e, **res;
+ int n=0;
+
+ if(!exts)
+ return 0;
+
+ /* p is the current position, e is the start of the nth extension */
+ for(e=p=(char *)exts; *p; p++)
+ {
+ if( (*p==' ') || (*p==',') )
+ {
+ if(*e == '.') e++;
+ if(p>e)
+ {
+ if(!(np_array[n] = (char *)XP_ALLOC(p-e+1)))
+ return 0;
+ XP_MEMCPY(np_array[n], e, (p-e));
+ *(np_array[n]+(p-e)) = 0;
+ n++;
+ e = p+1;
+ }
+ }
+ }
+ if(*e == '.') e++;
+ if(p>e)
+ {
+ if(!(np_array[n] = (char *)XP_ALLOC(p-e+1)))
+ return 0;
+ XP_MEMCPY(np_array[n], e, (p-e));
+ *(np_array[n]+(p-e)) = 0;
+ n++;
+ }
+
+ if(!(res = (char **)XP_ALLOC((n+1)*sizeof(char *))))
+ return 0;
+ XP_MEMCPY(res, np_array, n*sizeof(char *));
+ res[n] = 0;
+
+ return res;
+}
+
+
+/* construct a file association from a mime type.
+ * - extensions is a list of comma/space separated file extensions
+ * with or without leading .s
+ * - filetype is platform specific data for this list of extensions,
+ * currently creator on mac and open file dialog descriptions on win.
+ * filetype is callee owned data and must remain valid
+ */
+NPFileTypeAssoc *
+NPL_NewFileAssociation(const char *MIMEType, const char *extensions, const char *description, void *fileType)
+{
+ NPFileTypeAssoc *fassoc = 0;
+
+ /* make a file association struct */
+ if(!(fassoc=XP_NEW_ZAP(NPFileTypeAssoc)))
+ return 0;
+
+ StrAllocCopy((fassoc->type), MIMEType ? MIMEType : "");
+ StrAllocCopy((fassoc->description), description ? description : "");
+ StrAllocCopy((fassoc->extentstring), extensions ? extensions : "");
+
+ fassoc->fileType = fileType; /* caller owns this data */
+ fassoc->extentlist = np_parse_exts(extensions);
+ return fassoc;
+}
+
+
+/* deletes a file association. Returns the platform specific fileType
+ data that we dont know how to dispose of.
+*/
+void *
+NPL_DeleteFileAssociation(NPFileTypeAssoc *fassoc)
+{
+ void* fileType;
+
+ if (!fassoc)
+ return NULL;
+
+ fileType = fassoc->fileType;
+
+ NPL_RemoveFileAssociation(fassoc);
+
+ if (fassoc->type)
+ {
+ XP_FREE(fassoc->type);
+ fassoc->type = NULL;
+ }
+
+ if (fassoc->description)
+ {
+ XP_FREE(fassoc->description);
+ fassoc->description = NULL;
+ }
+
+ if (fassoc->extentstring)
+ {
+ XP_FREE(fassoc->extentstring);
+ fassoc->extentstring = NULL;
+ }
+
+ {
+ char** charPtrPtr;
+ for (charPtrPtr = &fassoc->extentlist[0]; *charPtrPtr; *charPtrPtr=0, charPtrPtr++)
+ XP_FREE(*charPtrPtr);
+
+ fassoc->extentlist = NULL;
+ }
+
+ XP_FREE(fassoc);
+
+ return fileType;
+}
+
+
+/* Register a file association with us and netlib.
+ */
+void
+NPL_RegisterFileAssociation(NPFileTypeAssoc *fassoc)
+{
+ if (fassoc)
+ {
+ fassoc->pNext = np_fassoc_list;
+ np_fassoc_list = fassoc;
+
+ NET_cdataCommit(fassoc->type, fassoc->extentstring);
+
+ /*
+ * We need to add the description, too, which unfortunately requires
+ * looking the cinfo up AGAIN and setting the desc field...
+ */
+ if (fassoc->description)
+ {
+ NET_cdataStruct temp;
+ NET_cdataStruct* cdata;
+
+ XP_BZERO(&temp, sizeof(temp));
+ temp.ci.type = fassoc->type;
+ cdata = NET_cdataExist(&temp);
+ XP_ASSERT(cdata);
+ if (cdata)
+ StrAllocCopy(cdata->ci.desc, fassoc->description);
+ }
+ }
+}
+
+
+/* Unregister a file association.
+ */
+NPFileTypeAssoc *
+NPL_RemoveFileAssociation(NPFileTypeAssoc *fassoc)
+{
+ NPFileTypeAssoc *f = np_fassoc_list;
+
+ if(!fassoc)
+ return 0;
+
+ /* unregister with netlib */
+ if(fassoc == np_fassoc_list)
+ np_fassoc_list = np_fassoc_list->pNext;
+ else
+ {
+ for(; f; f=f->pNext)
+ if(f->pNext == fassoc)
+ {
+ NPFileTypeAssoc *ft;
+ ft = f->pNext;
+ f->pNext = f->pNext->pNext;
+ f = ft;
+ break;
+ }
+ }
+ return f;
+}
+
+
+/* returns a linked list of registered associations.
+ * if type is NULL you get the entire list else the association matching
+ * that MIME type
+*/
+NPFileTypeAssoc *
+NPL_GetFileAssociation(const char *type)
+{
+ NPFileTypeAssoc *f=NULL;
+
+ if(!np_fassoc_list)
+ return NULL;
+
+ if(type==NULL)
+ return np_fassoc_list;
+
+ for(f=np_fassoc_list; f; f=f->pNext)
+ if(!(XP_STRCMP(type, f->type)))
+ return f;
+
+ return NULL;
+}
+
+
diff --git a/mozilla/modules/plugin/src/npglue.cpp b/mozilla/modules/plugin/src/npglue.cpp
new file mode 100644
index 00000000000..dcb3d7df0e8
--- /dev/null
+++ b/mozilla/modules/plugin/src/npglue.cpp
@@ -0,0 +1,5501 @@
+/* -*- 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
+ * 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.
+ */
+
+/*
+ *
+ * Function naming conventions:
+ * NPL_ Functions exported to other libs or FEs (prototyped in np.h)
+ * NPN_ Function prototypes exported to plug-ins via our function table (prototyped in npapi.h)
+ * npn_ Function definitions whose addresses are placed in the function table
+ * np_ Miscellaneous functions internal to libplugin (this file)
+ *
+ */
+
+#include "xp.h"
+#include "npglue.h"
+#include "plstr.h"
+#ifdef OJI
+#include "jni.h"
+#include "jvmmgr.h"
+#endif
+
+#ifdef ANTHRAX
+static char* np_FindAppletNForMimeType(const char* mimetype, char index);
+static int32 np_GetNumberOfInstalledApplets(const char* mimetype);
+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;
+
+/* list of all applets for ANTHRAX */
+#ifdef ANTHRAX
+static np_handle *np_alist = NULL;
+#endif
+
+int np_debug = 0;
+
+NPNetscapeFuncs npp_funcs;
+
+/*
+ * Determine whether or not this is a new-style plugin.
+ */
+static inline XP_Bool
+np_is50StylePlugin(np_handle* handle)
+{
+ XP_ASSERT(handle != NULL);
+ return (handle->userPlugin != NULL);
+}
+
+/* Find a mimetype in the handle */
+static np_mimetype *
+np_getmimetype(np_handle *handle, const char *mimeStr, XP_Bool wildCard)
+{
+ np_mimetype *mimetype;
+
+ for (mimetype = handle->mimetypes; mimetype; mimetype = mimetype->next)
+ {
+ if (mimetype->enabled)
+ {
+ if ((wildCard && !strcmp(mimetype->type, "*")) ||
+ !strcasecomp(mimetype->type, mimeStr))
+ return (mimetype);
+ }
+ }
+ return (NULL);
+}
+
+
+/*
+ * Standard conversion from NetLib status
+ * code to plug-in reason code.
+ */
+static NPReason
+np_statusToReason(int status)
+{
+ if (status == MK_DATA_LOADED)
+ return NPRES_DONE;
+ else if (status == MK_INTERRUPTED)
+ return NPRES_USER_BREAK;
+ else
+ return NPRES_NETWORK_ERR;
+}
+
+
+/*
+ * Add a node to the list of URLs for this
+ * plug-in instance. The caller must fill
+ * out the fields of the node, which is returned.
+ */
+static np_urlsnode*
+np_addURLtoList(np_instance* instance)
+{
+ np_urlsnode* node;
+
+ if (!instance)
+ return NULL;
+
+ if (!instance->url_list)
+ instance->url_list = XP_ListNew();
+ if (!instance->url_list)
+ return NULL;
+
+ node = XP_NEW_ZAP(np_urlsnode);
+ if (!node)
+ return NULL;
+
+ XP_ListAddObject(instance->url_list, node);
+
+ return node;
+}
+
+
+/*
+ * Deal with one URL from the list of URLs for the instance
+ * before the URL is removed from the list. If the URL was
+ * locked in the cache, we must unlock it and delete the URL.
+ * Otherwise, notify the plug-in that the URL is done (if
+ * necessary) and break the reference from the URL to the
+ * instance.
+ */
+static void
+np_processURLNode(np_urlsnode* node, np_instance* instance, int status)
+{
+ if (node->cached)
+ {
+ /* Unlock the cache file */
+ XP_ASSERT(!node->notify);
+ if (node->urls)
+ {
+ NET_ChangeCacheFileLock(node->urls, NP_UNLOCK);
+
+ NET_FreeURLStruct(node->urls);
+ node->urls = NULL;
+ }
+
+ return;
+ }
+
+ if (node->notify)
+ {
+ /* Notify the plug-in */
+ XP_ASSERT(!node->cached);
+ if (instance) {
+ TRACEMSG(("npglue.c: CallNPP_URLNotifyProc"));
+ if (np_is50StylePlugin(instance->handle)) {
+ nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata;
+ nsIPluginInstance* userInst = peerInst->GetUserInstance();
+ userInst->URLNotify(node->urls->address, node->urls->window_target,
+ (nsPluginReason)np_statusToReason(status),
+ node->notifyData);
+ }
+ else if (ISFUNCPTR(instance->handle->f->urlnotify)) {
+ CallNPP_URLNotifyProc(instance->handle->f->urlnotify,
+ instance->npp,
+ node->urls->address,
+ np_statusToReason(status),
+ node->notifyData);
+ }
+ }
+ }
+
+ /* Break the reference from the URL to the instance */
+ if (node->urls)
+ node->urls->fe_data = NULL;
+}
+
+
+/*
+ * Remove an individual URL from the list of URLs for this instance.
+ */
+static void
+np_removeURLfromList(np_instance* instance, URL_Struct* urls, int status)
+{
+ XP_List* url_list;
+ np_urlsnode* node;
+
+ if (!instance || !urls || !instance->url_list)
+ return;
+
+ /* Look for the URL in the list */
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
+ {
+ if (node->urls == urls)
+ {
+ XP_ASSERT(!node->cached);
+ np_processURLNode(node, instance, status);
+
+ XP_ListRemoveObject(instance->url_list, node);
+ XP_FREE(node);
+
+ /* If the list is now empty, delete it */
+ if (XP_ListCount(instance->url_list) == 0)
+ {
+ XP_ListDestroy(instance->url_list);
+ instance->url_list = NULL;
+ }
+
+ return;
+ }
+ }
+}
+
+
+/*
+ * Remove all URLs from the list of URLs for this instance.
+ */
+static void
+np_removeAllURLsFromList(np_instance* instance)
+{
+ XP_List* url_list;
+ np_urlsnode* node;
+
+ if (!instance || !instance->url_list)
+ return;
+
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
+ {
+ /* No notification of URLs now: the instance is going away */
+ node->notify = FALSE;
+ np_processURLNode(node, instance, 0);
+ }
+
+ /* Remove all elements from the list */
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListRemoveTopObject(url_list)) != NULL)
+ XP_FREE(node);
+
+ /* The list should now be empty, so delete it */
+ XP_ASSERT(XP_ListCount(instance->url_list) == 0);
+ XP_ListDestroy(instance->url_list);
+ instance->url_list = NULL;
+}
+
+
+
+/* maps from a urls to the corresponding np_stream.
+ you might well ask why not just store the urls in the stream and
+ put the stream in the netlib obj. the reason is that there can be
+ more than one active netlib stream for each plugin stream and
+ netlib specific data for seekable streams (current position and
+ so-on is stored in the urls and not in the stream. what a travesty.
+*/
+static np_stream *
+np_get_stream(URL_Struct *urls)
+{
+ if(urls)
+ {
+ NPEmbeddedApp *pEmbeddedApp = (NPEmbeddedApp*)urls->fe_data;
+ if(pEmbeddedApp)
+ {
+ np_data *ndata = (np_data *)pEmbeddedApp->np_data;
+ if(ndata && ndata->instance)
+ {
+ np_stream *stream;
+ for (stream=ndata->instance->streams; stream; stream=stream->next)
+ {
+ /*
+ * Matching algorithm: Either this URL is the inital URL for
+ * the stream, or it's a URL generated by a subsequent byte-
+ * range request. We don't bother to keep track of all the
+ * URLs for byte-range requests, but we can still detect if
+ * the URL matches this stream: since we know that this URL
+ * belongs to one of the streams for this instance and that
+ * there can only be one seekable stream for an instance
+ * active at a time, then we know if this stream is seekable
+ * and the URL is a byte-range URL then they must match.
+ * NOTE: We check both urls->high_range and urls->range_header
+ * because we could have been called before the range_header
+ * has been parsed and the high_range set.
+ */
+ if ((stream->initial_urls == urls) ||
+ (stream->seek && (urls->high_range || urls->range_header)))
+ return stream;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+
+/*
+ * Create the two plug-in data structures we need to go along
+ * with a netlib stream for a plugin: the np_stream, which is
+ * private to libplugin, and the NPStream, which is exported
+ * to the plug-in. The NPStream has an opaque reference (ndata)
+ * to the associated np_stream. The np_stream as a reference
+ * (pstream) to the NPStream, and another reference (nstream)
+ * to the netlib stream.
+ */
+static np_stream*
+np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Struct* urls)
+{
+ np_stream* stream;
+ NPStream* pstream;
+ XP_List* url_list;
+ np_urlsnode* node;
+ void* notifyData;
+
+ /* check params */
+ if (!instance || !netstream || !urls)
+ return NULL;
+
+ /* make a npglue stream */
+ stream = XP_NEW_ZAP(np_stream);
+ if (!stream)
+ return NULL;
+
+ stream->instance = instance;
+ stream->handle = instance->handle;
+ stream->nstream = netstream;
+ stream->initial_urls = urls;
+
+ XP_ASSERT(urls->address);
+ StrAllocCopy(stream->url, urls->address);
+ stream->len = urls->content_length;
+
+ /* Look for notification data for this URL */
+ notifyData = NULL;
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
+ {
+ if (node->urls == urls && node->notify)
+ {
+ notifyData = node->notifyData;
+ break;
+ }
+ }
+
+ /* make a plugin stream (the thing the plugin sees) */
+ pstream = XP_NEW_ZAP(NPStream);
+ if (!pstream)
+ {
+ XP_FREE(stream);
+ return NULL;
+ }
+ pstream->ndata = stream; /* confused yet? */
+ pstream->url = stream->url;
+ pstream->end = urls->content_length;
+ pstream->lastmodified = (uint32) urls->last_modified;
+ pstream->notifyData = notifyData;
+
+ /* make a record of it */
+ stream->pstream = pstream;
+ stream->next = instance->streams;
+ instance->streams = stream;
+
+ NPTRACE(0,("np: new stream, %s, %s", instance->mimetype->type, urls->address));
+
+ return stream;
+}
+
+/*
+ * Do the reverse of np_makestreamobjects: delete the two plug-in
+ * stream data structures (the NPStream and the np_stream).
+ * We also need to remove the np_stream from the list of streams
+ * associated with its instance.
+ */
+static void
+np_deletestreamobjects(np_stream* stream)
+{
+ np_instance* instance = stream->instance;
+
+ /* remove it from the instance list */
+ if (stream == instance->streams)
+ instance->streams = stream->next;
+ else
+ {
+ np_stream* sx;
+ for (sx = instance->streams; sx; sx = sx->next)
+ if (sx->next == stream)
+ {
+ sx->next = sx->next->next;
+ break;
+ }
+ }
+
+ /* and nuke the stream */
+ if (stream->pstream)
+ {
+ XP_FREE(stream->pstream);
+ stream->pstream = 0;
+ }
+ stream->handle = 0;
+ XP_FREE(stream);
+}
+
+
+
+/*
+ * (a) There should be a delayed load LIST (multiple requests get lost currently!)
+ * (b) We should call NET_GetURL with the app in the fe_data (notification uses it!)
+ * (c) We need to store the target context (may be different than instance context!)
+ */
+static void
+np_dofetch(URL_Struct *urls, int status, MWContext *window_id)
+{
+ np_stream *stream = np_get_stream(urls);
+ if(stream && stream->instance)
+ {
+ FE_GetURL(stream->instance->cx, stream->instance->delayedload);
+ }
+}
+
+
+unsigned int
+NPL_WriteReady(NET_StreamClass *stream)
+{
+ URL_Struct *urls = (URL_Struct *)stream->data_object;
+ np_stream *newstream = nil;
+ int ret = 0;
+
+ if(!(newstream = np_get_stream(urls)))
+ return 0;
+
+ if (newstream->asfile == NP_ASFILEONLY)
+ return NP_MAXREADY;
+
+ /* if prev_stream is not ready to write, then neither is this one... */
+ if (newstream->prev_stream != NULL){
+ ret = (newstream->prev_stream->is_write_ready(newstream->prev_stream));
+ if (ret == FALSE)
+ return FALSE;
+ }
+
+ XP_ASSERT(newstream->instance);
+ newstream->instance->reentrant = 1;
+
+ if (newstream->seek >= 0) {
+ TRACEMSG(("npglue.c: CallNPP_WriteReadyProc"));
+ if (newstream->handle->userPlugin) {
+#if 0 // XXX until we figure out if nsIOutputStream will work for us
+ nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)newstream->pstream->pdata;
+ nsIPluginStream* userStream = peerStream->GetUserStream();
+ ret = userStream->WriteReady();
+#else
+ ret = NP_MAXREADY;
+#endif
+ }
+ else if (ISFUNCPTR(newstream->handle->f->writeready)) {
+ ret = CallNPP_WriteReadyProc(newstream->handle->f->writeready,
+ newstream->instance->npp, newstream->pstream);
+ }
+ }
+ else
+ ret = NP_MAXREADY;
+
+#if defined(XP_WIN) || defined(XP_OS2)
+ /* Prevent WinFE from going to sleep when plug-in blocks */
+ if (ret == 0){
+ if(!newstream->instance->calling_netlib_all_the_time){
+ newstream->instance->calling_netlib_all_the_time = TRUE;
+ NET_SetCallNetlibAllTheTime(newstream->instance->cx, "npglue");
+ }
+ else{
+
+ NET_ClearCallNetlibAllTheTime(newstream->instance->cx, "npglue");
+ newstream->instance->calling_netlib_all_the_time = FALSE;
+ }
+ }
+#endif
+ if(!newstream->instance->reentrant)
+ {
+ urls->pre_exit_fn = np_dofetch;
+ return (unsigned int)-1;
+ }
+ newstream->instance->reentrant = 0;
+
+ return ret;
+}
+
+int
+NPL_Write(NET_StreamClass *stream, const unsigned char *str, int32 len)
+{
+ int ret;
+ URL_Struct *urls = (URL_Struct *)stream->data_object;
+ np_stream *newstream = np_get_stream(urls);
+
+ if(!newstream || !(newstream->handle->userPlugin ? 1 : ISFUNCPTR(newstream->handle->f->write)))
+ return -1;
+
+ if (newstream->asfile == NP_ASFILEONLY)
+ return len;
+
+ if (newstream->prev_stream != NULL){
+ ret = newstream->prev_stream->put_block(newstream->prev_stream,(const char *)str,len);
+ /* should put check here for ret == len? if not, then what? */
+ }
+
+
+ /* if this is the first non seek write after we turned the
+ stream, then abort this (netlib) stream */
+
+ if(!urls->high_range && (newstream->seek == -1))
+ return MK_UNABLE_TO_CONVERT; /* will cause an abort */
+
+ XP_ASSERT(newstream->instance);
+ newstream->instance->reentrant = 1;
+
+ newstream->pstream->end = urls->content_length;
+
+ if(newstream->seek)
+ {
+ /* NPTRACE(0,("seek stream gets %d bytes with high %d low %d pos %d\n", len,
+ urls->high_range, urls->low_range, urls->position)); */
+ /* since we get one range per urls, position will only be non-zero
+ if we are getting additional writes */
+ if(urls->position == 0)
+ urls->position = urls->low_range;
+ }
+ /*TRACEMSG(("npglue.c: CallNPP_WriteProc"));
+ */
+ if (newstream->handle->userPlugin) {
+ nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)newstream->pstream->pdata;
+ nsIPluginStream* userStream = peerStream->GetUserStream();
+ nsresult err;
+ ret = userStream->Write((const char*)str, 0, len, &err);
+ PR_ASSERT(err == NS_OK); // XXX this should go somewhere
+ }
+ else if (ISFUNCPTR(newstream->handle->f->write)) {
+ ret = CallNPP_WriteProc(newstream->handle->f->write, newstream->instance->npp, newstream->pstream,
+ urls->position, len, (void *)str);
+ }
+
+ urls->position += len;
+
+ if(!newstream->instance->reentrant)
+ {
+ urls->pre_exit_fn = np_dofetch;
+ return -1;
+ }
+ newstream->instance->reentrant = 0;
+
+ return ret;
+}
+
+
+static char *
+np_make_byterange_string(NPByteRange *ranges)
+{
+ char *burl;
+ NPByteRange *br;
+ int count, maxlen;
+
+ for(count=0, br=ranges; br; br=br->next)
+ count++;
+ maxlen = count*22 + 64; /* two 32-bit numbers, plus slop */
+
+ burl = (char*)XP_ALLOC(maxlen);
+ if(burl)
+ {
+ char range[64];
+ int len=0;
+ int iBytesEqualsLen;
+
+ iBytesEqualsLen = strlen(RANGE_EQUALS);
+
+ /* the range must begin with bytes=
+ * a final range string looks like:
+ * bytes=5-8,12-56
+ */
+ XP_STRCPY(burl, RANGE_EQUALS);
+
+ for(br=ranges; br; br=br->next)
+ {
+ int32 brlen = br->length;
+ if(len)
+ XP_STRCAT(burl, ",");
+ if(br->offset<0)
+ sprintf(range, "%ld", -((long)(br->length)));
+ else
+ sprintf(range, "%ld-%ld", br->offset, (br->offset+(brlen-1)));
+
+ len += XP_STRLEN(range);
+ if((len + iBytesEqualsLen) >= maxlen)
+ break;
+ XP_STRCAT(burl, range);
+ }
+
+ if(len == 0) /* no ranges added */
+ *burl = 0;
+ }
+ return burl;
+}
+
+static NPByteRange *
+np_copy_rangelist(NPByteRange *rangeList)
+{
+ NPByteRange *r, *rn, *rl=0, *rh=0;
+
+ for(r=rangeList; r; r=r->next)
+ {
+ if(!(rn = XP_NEW_ZAP(NPByteRange)))
+ break;
+ rn->offset = r->offset;
+ rn->length = r->length;
+
+ if(!rh)
+ rh = rn;
+ if(rl)
+ rl->next = rn;
+ rl = rn;
+ }
+ return rh;
+}
+
+
+static void
+np_lock(np_stream *stream)
+{
+ if(!stream->islocked)
+ {
+ NET_ChangeCacheFileLock(stream->initial_urls, NP_LOCK);
+ stream->islocked = 1;
+ }
+}
+
+static void
+np_unlock(np_stream *stream)
+{
+ if(stream->islocked)
+ {
+ NET_ChangeCacheFileLock(stream->initial_urls, NP_UNLOCK);
+ stream->islocked = 0;
+ }
+}
+
+static void
+np_GetURL(URL_Struct *pURL,FO_Present_Types iFormatOut,MWContext *cx, Net_GetUrlExitFunc *pExitFunc, NPBool notify){
+
+ XP_ASSERT(pURL->owner_data == NULL);
+ pURL->owner_id = 0x0000BAC0; /* plugin's unique identifier */
+ pURL->owner_data = pURL->fe_data;
+ pURL->fe_data = NULL;
+ FE_GetURL(cx,pURL);
+}
+
+
+
+NPError NP_EXPORT
+npn_requestread(NPStream *pstream, NPByteRange *rangeList)
+{
+ np_stream *stream;
+
+ if (pstream == NULL || rangeList == NULL)
+ return NPERR_INVALID_PARAM;
+
+ stream = (np_stream *)pstream->ndata;
+
+ if (stream == NULL)
+ return NPERR_INVALID_PARAM;
+
+ /* requestread may be called before newstream has returned */
+ if (stream)
+ {
+ if (!stream->seekable)
+ {
+ /*
+ * If the stream is not seekable, we can only fulfill
+ * the request if we're going to cache it (seek == 2);
+ * otherwise it's an error. If we are caching it,
+ * the request must still wait until the entire file
+ * is cached (when NPL_Complete is finally called).
+ */
+ if (stream->seek == 2)
+ {
+ /* defer the work */
+ NPTRACE(0,("\tdeferred the request"));
+
+ if(!stream->deferred)
+ stream->deferred = np_copy_rangelist(rangeList);
+ else
+ {
+ NPByteRange *r;
+ /* append */
+ for(r=stream->deferred;r && r->next;r++)
+ ;
+ if(r)
+ {
+ XP_ASSERT(!r->next);
+ r->next = np_copy_rangelist(rangeList);
+ }
+ }
+ }
+ else
+ return NPERR_STREAM_NOT_SEEKABLE;
+ }
+ else
+ {
+ char *ranges;
+
+ /* if seeking is ok, we delay this abort until now to get
+ the most out of the existing connection */
+ if(!stream->seek)
+ stream->seek = -1; /* next write aborts */
+
+ if ((ranges = np_make_byterange_string(rangeList)) != NULL)
+ {
+ URL_Struct *urls;
+ urls = NET_CreateURLStruct(stream->url, NET_DONT_RELOAD);
+ urls->range_header = ranges;
+ XP_ASSERT(stream->instance);
+ if(stream->instance)
+ {
+ urls->fe_data = (void *)stream->instance->app;
+ (void) NET_GetURL(urls, FO_CACHE_AND_BYTERANGE, stream->instance->cx, NPL_URLExit);
+ }
+ }
+ }
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+
+static void
+np_destroystream(np_stream *stream, NPError reason)
+{
+ if (stream)
+ {
+ /* Tell the plug-in that the stream is going away, and why */
+ np_instance *instance = stream->instance;
+ TRACEMSG(("npglue.c: CallNPP_DestroyStreamProc"));
+ if (stream->handle->userPlugin) {
+ nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)stream->pstream->pdata;
+ nsIPluginStream* userStream = peerStream->GetUserStream();
+ peerStream->SetReason((nsPluginReason)reason);
+ userStream->Close();
+ peerStream->Release();
+ }
+ else if (ISFUNCPTR(stream->handle->f->destroystream)) {
+ CallNPP_DestroyStreamProc(stream->handle->f->destroystream, instance->npp, stream->pstream, reason);
+ }
+
+ /* Delete the np_stream and associated NPStream objects */
+ np_deletestreamobjects(stream);
+ }
+}
+
+
+void
+np_streamAsFile(np_stream* stream)
+{
+ char* fname = NULL;
+ XP_ASSERT(stream->asfile);
+
+ if (stream->initial_urls)
+ {
+#ifdef XP_MAC
+ /* XXX - we should eventually do this for all platforms, but when I tested it with
+ PC, I encountered an issue w/ EXE files just before shipping, so we're only
+ checking this in for MAC. */
+ if (NET_IsURLInDiskCache(stream->initial_urls))
+#else
+ if (stream->initial_urls->cache_file)
+#endif
+ {
+ np_urlsnode* node;
+
+ /* paranoia check for ifdef mac change above */
+ XP_ASSERT(stream->initial_urls->cache_file != NULL);
+
+ fname = WH_FileName(stream->initial_urls->cache_file, xpCache);
+
+ /* Lock the file in the cache until we're done with it */
+ np_lock(stream);
+ node = np_addURLtoList(stream->instance);
+ if (node)
+ {
+ /* make a copy of the urls */
+ URL_Struct* newurls = NET_CreateURLStruct(stream->initial_urls->address, NET_DONT_RELOAD);
+
+ /* add the struct to the node */
+ node->urls = newurls;
+ node->cached = TRUE;
+ }
+ }
+ else if (NET_IsLocalFileURL(stream->initial_urls->address))
+ {
+ char* pathPart = NET_ParseURL(stream->initial_urls->address, GET_PATH_PART);
+ fname = WH_FileName(pathPart, xpURL);
+ XP_FREE(pathPart);
+ }
+
+ }
+
+ /* fname can be NULL if something went wrong */
+ TRACEMSG(("npglue.c: CallNPP_StreamAsFileProc"));
+ if (stream->handle->userPlugin) {
+ nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)stream->pstream->pdata;
+ nsIPluginStream* userStream = peerStream->GetUserStream();
+ userStream->AsFile(fname);
+ }
+ else if (ISFUNCPTR(stream->handle->f->asfile)) {
+ CallNPP_StreamAsFileProc(stream->handle->f->asfile, stream->instance->npp,
+ stream->pstream, fname);
+ }
+
+ if (fname) XP_FREE(fname);
+}
+
+
+void
+NPL_Complete(NET_StreamClass *stream)
+{
+ URL_Struct *urls = (URL_Struct *)stream->data_object;
+ np_stream *newstream = nil;
+
+ if(!(newstream = np_get_stream(urls)))
+ return;
+
+ if (newstream->prev_stream != NULL)
+ newstream->prev_stream->complete(newstream->prev_stream) ;
+
+ if(newstream->seek)
+ {
+ if(newstream->seek == 2)
+ {
+ /* request all the outstanding reads that had been waiting */
+ newstream->seekable = 1; /* for cgi hack */
+ newstream->seek = 1;
+ np_lock(newstream);
+ npn_requestread(newstream->pstream, newstream->deferred);
+ /* and delete the copies we made */
+ {
+ NPByteRange *r, *rl=0;
+ for(r=newstream->deferred; r; rl=r, r=r->next)
+ if(rl) XP_FREE(rl);
+ if(rl) XP_FREE(rl);
+ newstream->deferred = 0;
+ }
+ np_unlock(newstream);
+ }
+ }
+
+ if (newstream->asfile)
+ np_streamAsFile(newstream);
+
+ newstream->nstream = NULL; /* Remove reference to netlib stream */
+
+ newstream->prev_stream = NULL;
+
+ if (!newstream->dontclose)
+ np_destroystream(newstream, NPRES_DONE);
+}
+
+
+void
+NPL_Abort(NET_StreamClass *stream, int status)
+{
+ URL_Struct *urls = (URL_Struct *)stream->data_object;
+ np_stream *newstream = nil;
+
+ if(!(newstream = np_get_stream(urls)))
+ return;
+
+ if (newstream->prev_stream != NULL)
+ newstream->prev_stream->abort(newstream->prev_stream, status);
+
+ if(newstream->seek == -1)
+ {
+ /* this stream is being turned around */
+ newstream->seek = 1;
+ }
+
+ newstream->nstream = NULL; /* Remove reference to netlib stream */
+
+ /*
+ * MK_UNABLE_TO_CONVERT is the special status code we
+ * return from NPL_Write to cancel the original netlib
+ * stream when we get a byte-range request, so we don't
+ * want to destroy the plug-in stream in this case (we
+ * shouldn't get this status code any other time here).
+ */
+ if (!newstream->dontclose || (status < 0 && status != MK_UNABLE_TO_CONVERT))
+ np_destroystream(newstream, np_statusToReason(status));
+}
+
+extern XP_Bool
+NPL_HandleURL(MWContext *cx, FO_Present_Types iFormatOut, URL_Struct *pURL, Net_GetUrlExitFunc *pExitFunc)
+{
+ /* check the cx for takers */
+ return FALSE;
+}
+
+
+/*
+ * This exit routine is called for embed streams (the
+ * initial stream created when the plug-in is instantiated).
+ * We use a special exit routine in this case because FE's
+ * may want to take additional action when a plug-in stream
+ * finishes (e.g. show special error status indicating why
+ * the stream failed).
+ */
+/* This needs to have all the code in NPL_URLExit in it too! (notification) */
+void
+NPL_EmbedURLExit(URL_Struct *urls, int status, MWContext *cx)
+{
+ if (urls && status != MK_CHANGING_CONTEXT)
+ {
+#if defined(XP_WIN) || defined(XP_OS2)
+ /* WinFE is responsible for deleting the URL_Struct */
+ FE_EmbedURLExit(urls, status, cx);
+#else
+ NET_FreeURLStruct (urls);
+#endif
+ }
+}
+
+/*
+ * This exit routine is used for all streams requested by the
+ * plug-in: byterange request streams, NPN_GetURL streams, and
+ * NPN_PostURL streams. NOTE: If the exit routine gets called
+ * in the course of a context switch, we must NOT delete the
+ * URL_Struct. Example: FTP post with result from server
+ * displayed in new window -- the exit routine will be called
+ * when the upload completes, but before the new context to
+ * display the result is created, since the display of the
+ * results in the new context gets its own completion routine.
+ */
+void
+NPL_URLExit(URL_Struct *urls, int status, MWContext *cx)
+{
+ if (urls && status != MK_CHANGING_CONTEXT)
+ {
+ NPEmbeddedApp* app;
+ np_stream* pstream;
+ /* (part 2 of fix: replace fe_data the way I expect it) */
+ if ((urls->owner_data != NULL) &&
+ (urls->owner_id == 0x0000BAC0))
+ urls->fe_data = urls->owner_data;
+
+ app = (NPEmbeddedApp*) urls->fe_data;
+ pstream = np_get_stream(urls);
+
+ if (pstream)
+ {
+ /*
+ * MK_UNABLE_TO_CONVERT is the special status code we
+ * return from NPL_Write to cancel the original netlib
+ * stream when we get a byte-range request, so we don't
+ * want to destroy the plug-in stream in this case (we
+ * shouldn't get this status code any other time here).
+ */
+ if (!pstream->dontclose || (status < 0 && status != MK_UNABLE_TO_CONVERT))
+ np_destroystream(pstream, np_statusToReason(status));
+
+ /*
+ * If the initial URL_Struct is being deleted, break our
+ * reference to it (we might need to unlock it, too).
+ */
+ if (pstream->initial_urls == urls)
+ {
+ np_unlock(pstream);
+ pstream->initial_urls = NULL;
+ }
+ }
+
+ /*
+ * Check to see if the instance wants
+ * to be notified of the URL completion.
+ */
+ if (app)
+ {
+ np_data* ndata = (np_data*) app->np_data;
+ if (ndata && ndata->instance)
+ np_removeURLfromList(ndata->instance, urls, status);
+ }
+ if (urls->owner_data == NULL)
+ NET_FreeURLStruct(urls);
+
+ }
+}
+
+
+
+static URL_Struct*
+np_makeurlstruct(np_instance* instance, const char* relativeURL,
+ const char* altHost, const char* referrer)
+{
+ History_entry* history;
+ URL_Struct* temp_urls = NULL;
+ char* absoluteURL = NULL;
+ URL_Struct* urls = NULL;
+
+ if (!instance || !relativeURL)
+ return NULL;
+
+ /*
+ * Convert the (possibly) relative URL passed in by the plug-in
+ * to a guaranteed absolute URL. To do this we need the base
+ * URL of the page we're on, which we can get from the history
+ * info in the plug-in's context.
+ */
+ XP_ASSERT(instance->cx);
+ history = SHIST_GetCurrent(&instance->cx->hist);
+ if (history)
+ temp_urls = SHIST_CreateURLStructFromHistoryEntry(instance->cx, history);
+ if (temp_urls)
+ {
+ absoluteURL = NET_MakeAbsoluteURL(temp_urls->address, (char*) relativeURL);
+ NET_FreeURLStruct(temp_urls);
+ }
+
+
+ /*
+ * Now that we've got the absolute URL string, make a NetLib struct
+ * for it. If something went wrong making the absolute URL, fall back
+ * on the relative one.
+ */
+ XP_ASSERT(absoluteURL);
+ if (absoluteURL)
+ {
+ urls = NET_CreateURLStruct(absoluteURL, NET_NORMAL_RELOAD);
+ XP_FREE(absoluteURL);
+ }
+ else
+ urls = NET_CreateURLStruct(relativeURL, NET_NORMAL_RELOAD);
+
+ urls->owner_data = NULL;
+ urls->owner_id = 0x0000BAC0;
+
+ if (altHost && NET_SetURLIPAddressString(urls, altHost)) {
+ NET_FreeURLStruct(urls);
+ return NULL;
+ }
+ if (referrer) {
+ urls->referer = XP_STRDUP((char*)referrer);
+ }
+ return urls;
+}
+
+
+static MWContext*
+np_makecontext(np_instance* instance, const char* window)
+{
+ MWContext* cx;
+
+ /* Figure out which context to do this on */
+ if ((!strcmp(window, "_self")) || (!strcmp(window, "_current")))
+ cx = instance->cx;
+ else
+ cx = XP_FindNamedContextInList(instance->cx, (char*) window);
+
+ /* If we didn't find a context, make a new one */
+ if (!cx)
+ cx = FE_MakeNewWindow(instance->cx, NULL, (char*) window, NULL);
+
+ return cx;
+}
+
+PR_STATIC_CALLBACK(void)
+np_redisable_js(URL_Struct* url_s, int status, MWContext* context)
+{
+ context->forceJSEnabled = PR_FALSE;
+}
+
+NPError
+np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
+ const char* altHost, const char* referrer, PRBool forceJSEnabled,
+ NPBool notify, void* notifyData)
+{
+ URL_Struct* urls = NULL;
+ MWContext* cx;
+ np_instance* instance;
+ np_urlsnode* node = NULL;
+ NPError err = NPERR_NO_ERROR;
+#ifdef XP_WIN32
+ void* pPrevState;
+#endif
+
+ if (!npp || !relativeURL) /* OK for window to be NULL */
+ return NPERR_INVALID_PARAM;
+
+ instance = (np_instance*) npp->ndata;
+ if (!instance)
+ return NPERR_INVALID_PARAM;
+
+ /* Make an abolute URL struct from the (possibly) relative URL passed in */
+ urls = np_makeurlstruct(instance, relativeURL, altHost, referrer);
+ if (!urls)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+
+ /*
+ * Add this URL to the list of URLs for this instance,
+ * and remember if the instance would like notification.
+ */
+ node = np_addURLtoList(instance);
+ if (node)
+ {
+ node->urls = urls;
+ if (notify)
+ {
+ node->notify = TRUE;
+ node->notifyData = notifyData;
+ }
+ }
+ else
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+
+ urls->fe_data = (void*) instance->app;
+
+ /*
+ * If the plug-in passed NULL for the target, load the URL with a special stream
+ * that will deliver the data to the plug-in; otherwise, convert the target name
+ * they passed in to a context and load the URL into that context (possibly unloading
+ * the plug-in in the process, if the target context is the plug-in's context).
+ */
+ if (!target)
+ {
+#ifdef XP_WIN32
+ pPrevState = WFE_BeginSetModuleState();
+#endif
+ (void) NET_GetURL(urls, FO_CACHE_AND_PLUGIN, instance->cx, NPL_URLExit);
+#ifdef XP_WIN32
+ WFE_EndSetModuleState(pPrevState);
+#endif
+ }
+ else
+ {
+ cx = np_makecontext(instance, target);
+ if (!cx)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+
+ /*
+ * Prevent loading "about:" URLs into the plug-in's context: NET_GetURL
+ * for these URLs will complete immediately, and the new layout thus
+ * generated will blow away the plug-in and possibly unload its code,
+ * causing us to crash when we return from this function.
+ */
+ if (cx == instance->cx && NET_URL_Type(urls->address) == ABOUT_TYPE_URL)
+ {
+ err = NPERR_INVALID_URL;
+ goto error;
+ }
+
+ if (forceJSEnabled && !cx->forceJSEnabled) {
+ LM_ForceJSEnabled(cx);
+ urls->pre_exit_fn = np_redisable_js;
+ }
+
+#ifdef XP_MAC
+ /*
+ * One day the code below should call FE_GetURL, and this call will be
+ * unnecessary since the FE will do the right thing. Right now (3.0b6)
+ * starting to use FE_GetURL is not an option so we'll just create
+ * (yet another) FE callback for our purposes: we need to ask the FE
+ * to reset any timer it might have (for META REFRESH) so that the
+ * timer doesn't go off after leaving the original page via plug-in
+ * request.
+ */
+ FE_ResetRefreshURLTimer(cx);
+#endif
+
+ /* reentrancy matters for this case because it will cause the current
+ stream to be unloaded which netlib can't deal with */
+ if (instance->reentrant && (cx == instance->cx))
+ {
+ XP_ASSERT(instance->delayedload == NULL); /* We lose queued requests if this is non-NULL! */
+ if (instance->delayedload)
+ NET_FreeURLStruct(instance->delayedload);
+ instance->delayedload = urls;
+ instance->reentrant = 0;
+ }
+ else
+ {
+ if ((cx == instance->cx) ||
+ (XP_IsChildContext(cx,instance->cx)) )
+ {
+ /* re-target: use this until figure out why thread violation.
+ this method obviates question of self-trouncing... */
+ if ((instance->cx->type == MWContextBrowser ||
+ instance->cx->type == MWContextPane)
+ && ((XP_STRNCMP(urls->address, "mailbox:", 8)==0)
+ || (XP_STRNCMP(urls->address, "mailto:" , 7)==0)
+ || (XP_STRNCMP(urls->address, "news:" , 5)==0)))
+ cx = np_makecontext(instance,"_self");
+ else{
+ /* Since the previous stuff generally worked for this, keep using it */
+ urls->fe_data = NULL;
+#ifdef XP_WIN32
+ pPrevState = WFE_BeginSetModuleState();
+#endif
+ /* clear the exit routine, since the recipient may not be present! */
+ (void) NET_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit);
+#ifdef XP_WIN32
+ WFE_EndSetModuleState(pPrevState);
+#endif
+
+ return NPERR_NO_ERROR;
+ }
+ /* Eventually, we should shut down the current instance and
+ startup a new one */
+ }
+#ifdef XP_WIN32
+ pPrevState = WFE_BeginSetModuleState();
+#endif
+
+ (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
+
+#ifdef XP_WIN32
+ WFE_EndSetModuleState(pPrevState);
+#endif
+ }
+ }
+
+ return NPERR_NO_ERROR;
+
+error:
+ if (node)
+ {
+ node->notify = FALSE; /* Remove node without notification */
+ np_removeURLfromList(instance, urls, 0);
+ }
+ if (urls)
+ NET_FreeURLStruct(urls);
+ return err;
+}
+
+
+static NPError
+np_parsepostbuffer(URL_Struct* urls, const char* buf, uint32 len)
+{
+ /*
+ * Search the buffer passed in for a /n/n. If we find it, break the
+ * buffer in half: the first part is the header, the rest is the body.
+ */
+ uint32 index;
+ for (index = 0; index < len; index++)
+ {
+ if (buf[index] == '\n' && ++index < len && buf[index] == '\n')
+ break;
+ }
+
+ /*
+ * If we found '\n\n' somewhere in the middle of the string then we
+ * have headers, so we need to allocate a new string for the headers,
+ * copy the header data from the plug-in's buffer into it, and put
+ * it in the appropriate place of the URL struct.
+ */
+ if (index > 1 && index < len)
+ {
+ uint32 headerLength = index;
+ char* headers = (char*) XP_ALLOC(headerLength + 1);
+ if (!headers)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ XP_MEMCPY(headers, buf, headerLength);
+ headers[headerLength] = 0;
+ urls->post_headers = headers;
+ }
+
+ /*
+ * If we didn't find '\n\n', then the body starts at the beginning;
+ * otherwise, it starts right after the second '\n'. Make sure the
+ * body is non-emtpy, allocate a new string for it, copy the data
+ * from the plug-in's buffer, and put it in the URL struct.
+ */
+ if (index >= len)
+ index = 0; /* No '\n\n', start body from beginning */
+ else
+ index++; /* Found '\n\n', start body after it */
+
+ if (len - index > 0) /* Non-empty body? */
+ {
+ uint32 bodyLength = len - index + 1;
+ char* body = (char*) XP_ALLOC(bodyLength);
+ if (!body)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ XP_MEMCPY(body, &(buf[index]), bodyLength);
+ urls->post_data = body;
+ urls->post_data_size = bodyLength;
+ urls->post_data_is_file = FALSE;
+ }
+ else
+ {
+ /* Uh-oh, no data to post */
+ return NPERR_NO_DATA;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+
+NPError
+np_posturlinternal(NPP npp, const char* relativeURL, const char *target,
+ const char* altHost, const char* referrer, PRBool forceJSEnabled,
+ uint32 len, const char *buf, NPBool file, NPBool notify, void* notifyData)
+{
+ np_instance* instance;
+ URL_Struct* urls = NULL;
+ char* filename = NULL;
+ XP_Bool ftp;
+ np_urlsnode* node = NULL;
+ NPError err = NPERR_NO_ERROR;
+#ifdef XP_WIN32
+ void* pPrevState;
+#endif
+
+ /* Validate paramters */
+ if (!npp || !relativeURL)
+ return NPERR_INVALID_PARAM;
+
+ instance = (np_instance*) npp->ndata;
+ if (!instance)
+ return NPERR_INVALID_PARAM;
+
+ /* Make an absolute URL struct from the (possibly) relative URL passed in */
+ urls = np_makeurlstruct(instance, relativeURL, altHost, referrer);
+ if (!urls)
+ return NPERR_INVALID_URL;
+
+
+ /*
+ * Add this URL to the list of URLs for this instance,
+ * and remember if the instance would like notification.
+ */
+ node = np_addURLtoList(instance);
+ if (node)
+ {
+ node->urls = urls;
+ if (notify)
+ {
+ node->notify = TRUE;
+ node->notifyData = notifyData;
+ }
+ }
+ else
+ return NPERR_OUT_OF_MEMORY_ERROR;
+
+ /*
+ * FTP protocol requires that the data be in a file.
+ * If we really wanted to, we could write code to dump the buffer to
+ * a temporary file, give the temp file to netlib, and delete it when
+ * the exit routine fires.
+ */
+ ftp = (strncasecomp(urls->address, "ftp:", 4) == 0);
+ if (ftp && !file)
+ {
+ err = NPERR_INVALID_URL;
+ goto error;
+ }
+
+ if (file)
+ {
+ XP_StatStruct stat;
+
+ /* If the plug-in passed a file URL, strip the 'file://' */
+ if (!strncasecomp(buf, "file://", 7))
+ filename = XP_STRDUP((char*) buf + 7);
+ else
+ filename = XP_STRDUP((char*) buf);
+
+ if (!filename)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+
+ /* If the file doesn't exist, return an error NOW before netlib get it */
+ if (XP_Stat(filename, &stat, xpURL))
+ {
+ err = NPERR_FILE_NOT_FOUND;
+ goto error;
+ }
+ }
+
+ /*
+ * NET_GetURL handles FTP posts differently: the post_data fields are
+ * ignored; instead, files_to_post contains an array of the files.
+ */
+ if (ftp)
+ {
+ XP_ASSERT(filename);
+ urls->files_to_post = (char**) XP_ALLOC(sizeof(char*) + sizeof(char*));
+ if (!(urls->files_to_post))
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ urls->files_to_post[0] = filename;
+ urls->files_to_post[1] = NULL;
+ urls->post_data = NULL;
+ urls->post_data_size = 0;
+ urls->post_data_is_file = FALSE;
+ }
+ else if (file)
+ {
+ XP_ASSERT(filename);
+ urls->post_data = filename;
+ urls->post_data_size = XP_STRLEN(filename);
+ urls->post_data_is_file = TRUE;
+ }
+ else
+ {
+ /*
+ * There are two different sets of buffer-parsing code.
+ * The new code is contained within np_parsepostbuffer,
+ * and is used when the plug-in calls NPN_PostURLNotify.
+ * The old code, below, is preserved for compatibility
+ * for when the plug-in calls NPN_PostURL.
+ */
+ if (notify)
+ {
+ NPError err = np_parsepostbuffer(urls, buf, len);
+ if (err != NPERR_NO_ERROR)
+ goto error;
+ }
+ else
+ {
+ urls->post_data = (char*)XP_ALLOC(len);
+ if (!urls->post_data)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ XP_MEMCPY(urls->post_data, buf, len);
+ urls->post_data_size = len;
+ urls->post_data_is_file = FALSE;
+ }
+ }
+
+ urls->method = URL_POST_METHOD;
+
+ if (!target)
+ {
+ urls->fe_data = (void*) instance->app;
+#ifdef XP_WIN32
+ pPrevState = WFE_BeginSetModuleState();
+#endif
+ (void) NET_GetURL(urls, FO_CACHE_AND_PLUGIN, instance->cx, NPL_URLExit);
+#ifdef XP_WIN32
+ WFE_EndSetModuleState(pPrevState);
+#endif
+ }
+ else
+ {
+ MWContext* cx = np_makecontext(instance, target);
+ if (!cx)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ urls->fe_data = (void*) instance->app;
+
+ if (forceJSEnabled && !cx->forceJSEnabled) {
+ LM_ForceJSEnabled(cx);
+ urls->pre_exit_fn = np_redisable_js;
+ }
+
+#ifdef XP_MAC
+ /*
+ * One day the code below should call FE_GetURL, and this call will be
+ * unnecessary since the FE will do the right thing. Right now (3.0b6)
+ * starting to use FE_GetURL is not an option so we'll just create
+ * (yet another) FE callback for our purposes: we need to ask the FE
+ * to reset any timer it might have (for META REFRESH) so that the
+ * timer doesn't go off after leaving the original page via plug-in
+ * request.
+ */
+ FE_ResetRefreshURLTimer(cx);
+#endif
+
+#ifdef XP_WIN32
+ pPrevState = WFE_BeginSetModuleState();
+#endif
+ (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
+
+#ifdef XP_WIN32
+ WFE_EndSetModuleState(pPrevState);
+#endif
+ }
+
+ return NPERR_NO_ERROR;
+
+error:
+ if (node)
+ {
+ node->notify = FALSE; /* Remove node without notification */
+ np_removeURLfromList(instance, urls, 0);
+ }
+ if (urls)
+ NET_FreeURLStruct(urls);
+ return err;
+}
+
+
+
+NPError NP_EXPORT
+npn_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData)
+{
+ return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, TRUE, notifyData);
+}
+
+NPError NP_EXPORT
+npn_getvalue(NPP npp, NPNVariable variable, void *r_value)
+{
+ np_instance* instance;
+ NPError ret = NPERR_NO_ERROR;
+
+ if (r_value == NULL)
+ return NPERR_INVALID_PARAM;
+
+ /* Some of these variabled may be handled by backend. The rest is FE.
+ * So Handle all the backend variables and pass the rest over to FE.
+ */
+
+ switch(variable) {
+ case NPNVjavascriptEnabledBool :
+ ret = PREF_GetBoolPref("javascript.enabled", (XP_Bool*)r_value);
+ break;
+ case NPNVasdEnabledBool :
+ ret = PREF_GetBoolPref("autoupdate.enabled", (XP_Bool*)r_value);
+ break;
+#ifdef MOZ_OFFLINE
+ case NPNVisOfflineBool :{
+ XP_Bool *bptr = (XP_Bool *)r_value;
+ *bptr = NET_IsOffline();
+ ret = NPERR_NO_ERROR;
+ break; }
+#endif /* MOZ_OFFLINE */
+ default:
+ instance = NULL;
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
+#ifdef XP_UNIX
+ ret = FE_PluginGetValue(instance?instance->handle->pdesc:NULL,
+ variable, r_value);
+#else
+ ret = FE_PluginGetValue(instance->cx, instance->app, variable,
+ r_value);
+#endif /* XP_UNIX */
+ }
+
+ return(ret);
+}
+
+NPError NP_EXPORT
+npn_setvalue(NPP npp, NPPVariable variable, void *r_value)
+{
+ np_instance* instance = NULL;
+ NPError ret = NPERR_NO_ERROR;
+
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
+
+ if (!instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ switch(variable) {
+ case NPPVpluginWindowBool:
+ /*
+ * XXX On the Mac, a window has already been allocated by the time NPP_New
+ * has been called - which is fine, since we'll still use the window.
+ * Unfortunately, we can't use the window's presence to determine whether
+ * it's too late to set the windowed property.
+ */
+#ifndef XP_MAC
+ /*
+ * If the window has already been allocated, it's too late
+ * to tell us.
+ */
+ if (!instance->app->wdata->window)
+ instance->windowed = (0 != r_value);
+ else
+ ret = NPERR_INVALID_PARAM;
+#else
+ instance->windowed = (0 != r_value);
+#endif
+ break;
+ case NPPVpluginTransparentBool:
+ instance->transparent = (0 != r_value);
+#ifdef LAYERS
+ if (instance->layer &&
+ (instance->transparent != !(CL_GetLayerFlags(instance->layer) & CL_OPAQUE)))
+ {
+ XP_Rect bbox;
+
+ /* Get the bbox and convert it into its own coordinate space */
+ CL_GetLayerBbox(instance->layer, &bbox);
+
+ CL_ChangeLayerFlag(instance->layer, CL_OPAQUE, (PRBool)!instance->transparent);
+ CL_ChangeLayerFlag(instance->layer,
+ CL_PREFER_DRAW_OFFSCREEN,
+ (PRBool)instance->transparent);
+
+ /* Force drawing of the entire transparent plug-in. */
+ CL_UpdateLayerRect(CL_GetLayerCompositor(instance->layer),
+ instance->layer, &bbox, PR_FALSE);
+ }
+#endif /* LAYERS */
+ break;
+
+ case NPPVpluginTimerInterval:
+ np_SetTimerInterval(npp, *(uint32*)r_value);
+ break;
+
+ case NPPVpluginWindowSize:
+ break;
+ default:
+ break;
+ }
+
+ return(ret);
+}
+
+
+NPError NP_EXPORT
+npn_geturl(NPP npp, const char* relativeURL, const char* target)
+{
+ return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, FALSE, NULL);
+}
+
+
+NPError NP_EXPORT
+npn_posturlnotify(NPP npp, const char* relativeURL, const char *target, uint32 len, const char *buf, NPBool file, void* notifyData)
+{
+ return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, TRUE, notifyData);
+}
+
+
+NPError NP_EXPORT
+npn_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len, const char *buf, NPBool file)
+{
+ return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, FALSE, NULL);
+}
+
+
+
+NPError NP_EXPORT
+npn_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream)
+{
+ np_instance* instance;
+ np_stream* stream;
+ NET_StreamClass* netstream;
+ URL_Struct* urls;
+ MWContext* cx;
+ *pstream = NULL;
+
+ if (!npp || !type)
+ return NPERR_INVALID_PARAM;
+ instance = (np_instance*) npp->ndata;
+ if (!instance)
+ return NPERR_INVALID_PARAM;
+
+ /* Convert the window name to a context */
+ cx = np_makecontext(instance, window);
+ if (!cx)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+
+
+ /*
+ * Make a bogus URL struct. The URL doesn't point to
+ * anything, but we need it to build the stream.
+ */
+ urls = NET_CreateURLStruct("", NET_DONT_RELOAD);
+ if (!urls)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ StrAllocCopy(urls->content_type, type);
+
+ /* Make a netlib stream */
+ netstream = NET_StreamBuilder(FO_PRESENT, urls, cx);
+ if (!netstream)
+ {
+ NET_FreeURLStruct(urls);
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ }
+
+ /* Make the plug-in stream objects */
+ stream = np_makestreamobjects(instance, netstream, urls);
+ if (!stream)
+ {
+ XP_FREE(netstream);
+ NET_FreeURLStruct(urls);
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ }
+
+ *pstream = stream->pstream;
+ return NPERR_NO_ERROR;
+}
+
+
+int32 NP_EXPORT
+npn_write(NPP npp, NPStream *pstream, int32 len, void *buffer)
+{
+ np_instance* instance;
+ np_stream* stream;
+ NET_StreamClass* netstream;
+
+ if (!npp || !pstream || !buffer || len<0)
+ return NPERR_INVALID_PARAM;
+
+ instance = (np_instance*) npp->ndata;
+ stream = (np_stream*) pstream->ndata;
+
+ if (!instance || !stream)
+ return NPERR_INVALID_PARAM;
+
+ netstream = stream->nstream;
+ if (!netstream)
+ return NPERR_INVALID_PARAM;
+
+ return (*netstream->put_block)(netstream, (const char*) buffer, len);
+}
+
+NPError NP_EXPORT
+npn_destroystream(NPP npp, NPStream *pstream, NPError reason)
+{
+ np_instance* instance;
+ np_stream* stream;
+ NET_StreamClass* netstream;
+ URL_Struct* urls = NULL;
+
+ if (!npp || !pstream)
+ return NPERR_INVALID_PARAM;
+
+ instance = (np_instance*) npp->ndata;
+ stream = (np_stream*) pstream->ndata;
+
+ if (!instance || !stream)
+ return NPERR_INVALID_PARAM;
+
+ netstream = stream->nstream;
+ if (netstream)
+ urls = (URL_Struct*) netstream->data_object;
+
+ /*
+ * If we still have a valid netlib stream, ask netlib
+ * to destroy it (it will call us back to inform the
+ * plug-in and delete the plug-in-specific objects).
+ * If we don't have a netlib stream (possible if the
+ * stream was in NP_SEEK mode: the netlib stream might
+ * have been deleted but we would keep the plug-in
+ * stream around because stream->dontclose was TRUE),
+ * just inform the plug-in and delete our objects.
+ */
+ stream->dontclose = FALSE; /* Make sure we really delete */
+ if (urls)
+ {
+ if (NET_InterruptStream(urls) < 0)
+ {
+ /* Netlib doesn't know about this stream; we must have made it */
+ /*MWContext* cx = netstream->window_id;*/
+ switch (reason)
+ {
+ case NPRES_DONE:
+ (*netstream->complete)(netstream);
+ break;
+ case NPRES_USER_BREAK:
+ (*netstream->abort)(netstream, MK_INTERRUPTED);
+ break;
+ case NPRES_NETWORK_ERR:
+ (*netstream->abort)(netstream, MK_BAD_CONNECT);
+ break;
+ default: /* Unknown reason code */
+ (*netstream->abort)(netstream, -1);
+ break;
+ }
+ np_destroystream(stream, reason);
+ XP_FREE(netstream);
+ }
+ }
+ else
+ np_destroystream(stream, reason);
+
+/*
+ * We still need a way to pass the right status code
+ * through to NPL_Abort (NET_InterruptStream doesn't
+ * take a status code, so the plug-in always gets
+ * NPRES_USER_BREAK, not what they passed in here).
+ */
+ return NPERR_NO_ERROR;
+}
+
+
+void NP_EXPORT
+npn_status(NPP npp, const char *message)
+{
+ if(npp)
+ {
+ np_instance *instance = (np_instance *)npp->ndata;
+ if(instance && instance->cx)
+#ifdef XP_MAC
+ /* Special entry point so MacFE can save/restore port state */
+ FE_PluginProgress(instance->cx, message);
+#else
+ FE_Progress(instance->cx, message);
+#endif
+ }
+}
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_D0
+#endif
+const char * NP_EXPORT
+npn_useragent(NPP npp)
+{
+ static char *uabuf = 0;
+ if(!uabuf)
+ uabuf = PR_smprintf("%.100s/%.90s", XP_AppCodeName, XP_AppVersion);
+ return (const char *)uabuf;
+}
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_A0
+#endif
+
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_D0
+#endif
+void * NP_EXPORT
+npn_memalloc (uint32 size)
+{
+ return XP_ALLOC(size);
+}
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_A0
+#endif
+
+
+void NP_EXPORT
+npn_memfree (void *ptr)
+{
+ (void)XP_FREE(ptr);
+}
+
+#ifdef XP_MAC
+/* For the definition of CallCacheFlushers() */
+#ifndef NSPR20
+#include "prmacos.h"
+#else
+#include "MacMemAllocator.h"
+#endif
+#endif
+
+uint32 NP_EXPORT
+npn_memflush(uint32 size)
+{
+#ifdef XP_MAC
+ /* Try to free some memory and return the amount we freed. */
+ if (CallCacheFlushers(size))
+ return size;
+ else
+#endif
+ return 0;
+}
+
+
+
+
+/*
+ * Given an instance, switch its handler from whatever it
+ * currently is to the handler passed in. Assuming the new
+ * handler really is different, to do this we need to destroy
+ * the current NPP instance (so the old plug-in's out of the
+ * picture), then make a new NPP with the new handler
+ */
+NPError
+np_switchHandlers(np_instance* instance,
+ np_handle* newHandle,
+ np_mimetype* newMimeType,
+ char* requestedType)
+{
+ NPEmbeddedApp* app = instance->app;
+ MWContext* cx = instance->cx;
+ np_data* ndata = (np_data*) app->np_data;
+
+ if (app == NULL || cx == NULL || ndata == NULL)
+ return NPERR_INVALID_PARAM;
+
+ /*
+ * If it's a full-page plug-in, just reload the document.
+ * We have to reload the data anyway to send it to the
+ * new instance, and since the instance is the only thing
+ * on the page it's easier to just reload the whole thing.
+ * NOTE: This case shouldn't ever happen, since you can't
+ * have full-page Default plug-ins currently.
+ */
+ XP_ASSERT(app->pagePluginType != NP_FullPage);
+ if (app->pagePluginType == NP_FullPage)
+ {
+ History_entry* history = SHIST_GetCurrent(&cx->hist);
+ URL_Struct* urls = SHIST_CreateURLStructFromHistoryEntry(cx, history);
+ if (urls != NULL)
+ {
+ urls->force_reload = NET_NORMAL_RELOAD;
+ FE_GetURL(cx, urls);
+ return NPERR_NO_ERROR;
+ }
+ else
+ return NPERR_GENERIC_ERROR;
+ }
+
+ /* Nuke the old instance */
+ np_delete_instance(instance);
+ if (ndata != NULL && ndata->instance == instance)
+ ndata->instance = NULL;
+
+ /* Make a new instance */
+ ndata->instance = np_newinstance(newHandle, cx, app, newMimeType, requestedType);
+ NPL_EmbedSize(app);
+
+ if (ndata->instance == NULL)
+ return NPERR_GENERIC_ERROR;
+
+ /* Get the data stream for the new instance, if necessary */
+ if (ndata->lo_struct->embed_src != NULL)
+ {
+ char* address;
+ URL_Struct* urls;
+
+ PA_LOCK(address, char*, ndata->lo_struct->embed_src);
+ XP_ASSERT(address);
+
+ urls = NET_CreateURLStruct(address, NET_DONT_RELOAD);
+
+ PA_UNLOCK(ndata->lo_struct->embed_src);
+
+ if (urls != NULL)
+ {
+ urls->fe_data = (void*) app;
+ (void) NET_GetURL(urls, FO_CACHE_AND_EMBED, cx, NPL_EmbedURLExit);
+ return NPERR_NO_ERROR;
+ }
+ else
+ return NPERR_GENERIC_ERROR;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+
+
+/*
+ * Ask the FE to throw away its old plugin handlers and
+ * re-scan the plugins folder to find new ones. This function
+ * is intended for use by the null plugin to signal that
+ * some new plugin has been installed and we should make a
+ * note of it. If "reloadPages" is true, we should also
+ * reload all open pages with plugins on them (since plugin
+ * handlers could have come or gone as a result of the re-
+ * registration).
+ */
+void NP_EXPORT
+npn_reloadplugins(NPBool reloadPages)
+{
+ np_handle* oldHead = NULL;
+
+ /*
+ * We won't unregister old plug-ins, we just register new ones.
+ * The new plug-ins will go on the front of the list, so to see
+ * if we got any new ones we just need to save a pointer to the
+ * current front of the list.
+ */
+ if (reloadPages)
+ oldHead = np_plist;
+
+ /* Ask the FE to load new plug-ins */
+ FE_RegisterPlugins();
+
+ /*
+ * At least one plug-in was added to the front of the list.
+ * Now we need to find all instances of the default plug-in
+ * to see if they can be handled by one of the new plug-ins.
+ */
+ if (reloadPages && oldHead != np_plist)
+ {
+ np_handle* defaultPlugin = np_plist;
+ np_instance* instance;
+
+ /* First look for the default plug-in */
+ while (defaultPlugin != NULL)
+ {
+ if (defaultPlugin->mimetypes != NULL &&
+ defaultPlugin->mimetypes->type &&
+ XP_STRCMP(defaultPlugin->mimetypes->type, "*") == 0)
+ {
+ break;
+ }
+ defaultPlugin = defaultPlugin->next;
+ }
+
+ if (defaultPlugin == NULL)
+ return;
+
+ /* Found the default plug-in; now check its instances */
+ instance = defaultPlugin->instances;
+ while (instance != NULL)
+ {
+ NPBool switchedHandler = FALSE;
+ char* type = instance->typeString;
+ XP_ASSERT(instance->mimetype == defaultPlugin->mimetypes);
+
+ if (type != NULL)
+ {
+ /*
+ * Try to match this instance's type against the
+ * types of all new plug-ins to see if any of them
+ * can handle it. Since the new plug-is were added
+ * to the front of the list, we only need to look
+ * at plug-ins up to the old head of the list.
+ */
+ np_handle* handle = np_plist;
+ while (handle != NULL && handle != oldHead)
+ {
+ np_mimetype* mimeType;
+ XP_ASSERT(handle != defaultPlugin);
+ mimeType = np_getmimetype(handle, type, FALSE);
+
+ /*
+ * We found a new handler for this type! Now we
+ * can destroy the plug-in instance and make a
+ * new instance handled by the new plug-in.
+ * Note that we have to point "instance" to the
+ * next object NOW, because np_switchHandlers
+ * will remove it from the list.
+ */
+ if (mimeType != NULL)
+ {
+ np_instance* switcher = instance;
+ instance = instance->next;
+ (void) np_switchHandlers(switcher, handle, mimeType, type);
+ switchedHandler = TRUE;
+ break; /* Out of handle "while" loop */
+ }
+
+ handle = handle->next;
+ }
+ }
+
+ /*
+ * In the case where we switch the handler (above),
+ * "instance" already points to the next objTag.
+ */
+ if (!switchedHandler)
+ instance = instance->next;
+ }
+ }
+}
+
+
+NPError
+NPL_RefreshPluginList(XP_Bool reloadPages)
+{
+ npn_reloadplugins(reloadPages);
+ return NPERR_NO_ERROR; /* Always succeeds for now */
+}
+
+
+void NP_EXPORT
+npn_invalidaterect(NPP npp, NPRect *invalidRect)
+{
+ np_instance* instance = NULL;
+ XP_Rect rect;
+
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
+
+ if (instance && !instance->windowed) {
+ rect.left = invalidRect->left;
+ rect.top = invalidRect->top;
+ rect.right = invalidRect->right;
+ rect.bottom = invalidRect->bottom;
+
+ CL_UpdateLayerRect(CL_GetLayerCompositor(instance->layer),
+ instance->layer, &rect, PR_FALSE);
+ }
+}
+
+void NP_EXPORT
+npn_invalidateregion(NPP npp, NPRegion invalidRegion)
+{
+ np_instance* instance = NULL;
+
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
+
+ if (instance && !instance->windowed) {
+ CL_UpdateLayerRegion(CL_GetLayerCompositor(instance->layer),
+ instance->layer, invalidRegion, PR_FALSE);
+ }
+}
+
+void NP_EXPORT
+npn_forceredraw(NPP npp)
+{
+ np_instance* instance = NULL;
+
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
+
+ if (instance && !instance->windowed) {
+ CL_CompositeNow(CL_GetLayerCompositor(instance->layer));
+ }
+}
+
+/******************************************************************************/
+
+#ifdef JAVA
+#define JRI_NO_CPLUSPLUS
+#define IMPLEMENT_netscape_plugin_Plugin
+#include "netscape_plugin_Plugin.h"
+#ifdef MOCHA
+#include "libmocha.h"
+#endif /* MOCHA */
+#endif /* JAVA */
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_D0
+#endif
+#if defined(OJI)
+JNIEnv* NP_EXPORT
+npn_getJavaEnv(PRThread *pPRThread)
+{
+
+#ifdef XP_MAC
+ short resNum1, resNum2;
+ resNum1 = CurResFile();
+#endif /* XP_MAC */
+ JNIEnv *pJNIEnv = NULL;
+
+ /* =-= What do we do with the thread passed in? Looks like we cannot
+ * get a JNIEnv for any arbitrary thread. One can only attach to a
+ * current thread.
+ */
+ pJNIEnv = JVM_GetJNIEnv(); /* This may startup the VM. */
+
+#ifdef XP_MAC
+ /* if Java changed the res file, change it back to the plugin's res file */
+ resNum2 = CurResFile();
+ if(resNum1 != resNum2)
+ UseResFile(resNum1);
+#endif /* XP_MAC */
+
+ return pJNIEnv;
+}
+#else /* OJI */
+JRIEnv* NP_EXPORT
+npn_getJavaEnv(void)
+{
+#ifdef JAVA
+ JRIEnv* env;
+
+#ifdef XP_MAC
+ short resNum1, resNum2;
+ resNum1 = CurResFile();
+#endif /* XP_MAC */
+
+ env = LJ_EnsureJavaEnv(NULL); /* NULL means for the current thread */
+
+#ifdef XP_MAC
+ /* if Java changed the res file, change it back to the plugin's res file */
+ resNum2 = CurResFile();
+ if(resNum1 != resNum2)
+ UseResFile(resNum1);
+#endif /* XP_MAC */
+
+ return env;
+#else /* JAVA */
+ return NULL;
+#endif /* JAVA */
+}
+#endif /* !OJI */
+
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_A0
+#endif
+
+#if defined(OJI)
+#define fieldname_netscape_plugin_Plugin_window "window"
+#define fieldsig_netscape_plugin_Plugin_window "Lnetscape/javascript/JSObject;"
+
+jclass NP_EXPORT
+npn_getJavaClass(np_handle* handle);
+
+void
+np_recover_mochaWindow(JNIEnv * env, np_instance * instance)
+{
+ if (env && instance && instance->mochaWindow && instance->javaInstance){
+ /* Store the JavaScript context as the window object: */
+ env->SetObjectField(instance->javaInstance,
+ env->GetFieldID(npn_getJavaClass(instance->handle),
+ fieldname_netscape_plugin_Plugin_window, fieldsig_netscape_plugin_Plugin_window),
+ (jobject)instance->mochaWindow);
+
+ }
+}
+jobject classPlugin = NULL;
+#define NPN_NO_JAVA_INSTANCE ((jobject)-1)
+
+#elif defined(JAVA)
+void
+np_recover_mochaWindow(JRIEnv * env, np_instance * instance)
+{
+ netscape_plugin_Plugin* javaInstance = NULL;
+
+ if (env && instance && instance->mochaWindow && instance->javaInstance){
+ javaInstance = (struct netscape_plugin_Plugin *)
+ JRI_GetGlobalRef(env, instance->javaInstance);
+ if (javaInstance) {
+ /* Store the JavaScript context as the window object: */
+ set_netscape_plugin_Plugin_window(env, javaInstance,
+ (netscape_javascript_JSObject*)
+ JRI_GetGlobalRef(env, instance->mochaWindow));
+ }
+ }
+}
+jglobal classPlugin = NULL;
+#define NPN_NO_JAVA_INSTANCE ((jglobal)-1)
+
+#endif /* ! OJI */
+
+extern void
+ET_SetPluginWindow(MWContext *cx, void *instance);
+
+NS_DEFINE_IID(kPluginInstanceIID, NS_IPLUGININSTANCE_IID);
+NS_DEFINE_IID(kLiveConnectPluginIID, NS_ILIVECONNECTPLUGIN_IID);
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_D0
+#endif
+
+#if defined(OJI)
+jclass NP_EXPORT
+npn_getJavaClass(np_handle* handle)
+{
+ if (handle->userPlugin) {
+ nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin;
+ nsILiveConnectPlugin* lcPlugin;
+ if (userPluginClass->QueryInterface(kLiveConnectPluginIID,
+ (void**)&lcPlugin) != NS_NOINTERFACE) {
+ jclass clazz = lcPlugin->GetJavaClass();
+
+ // Remember, QueryInterface increments the ref count;
+ // since we're done with it in this scope, release it.
+ lcPlugin->Release();
+
+ return clazz;
+ }
+ return NULL; // not a LiveConnected plugin
+ }
+ else if (handle && handle->f) {
+ JNIEnv* env = npn_getJavaEnv(NULL); /* may start up the java runtime */
+ if (env == NULL) return NULL;
+ return (jclass) env->NewGlobalRef(handle->f->javaClass);
+ }
+ return NULL;
+}
+#elif defined(JAVA)
+java_lang_Class* NP_EXPORT
+npn_getJavaClass(np_handle* handle)
+{
+ if (handle->userPlugin) {
+ nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin;
+ nsILiveConnectPlugin* lcPlugin;
+ if (userPluginClass->QueryInterface(kLiveConnectPluginIID,
+ (void**)&lcPlugin) != NS_NOINTERFACE) {
+ java_lang_Class* clazz = (java_lang_Class*)lcPlugin->GetJavaClass();
+
+ // Remember, QueryInterface increments the ref count;
+ // since we're done with it in this scope, release it.
+ lcPlugin->Release();
+
+ return clazz;
+ }
+ return NULL; // not a LiveConnected plugin
+ }
+ else if (handle && handle->f) {
+ JRIEnv* env = npn_getJavaEnv(); /* may start up the java runtime */
+ if (env == NULL) return NULL;
+ return (java_lang_Class*)JRI_GetGlobalRef(env, handle->f->javaClass);
+ }
+ return NULL;
+}
+#endif /* JAVA */
+
+#if defined(OJI)
+jobject NP_EXPORT
+npn_getJavaPeer(NPP npp)
+{
+ jobject javaInstance = NULL;
+ np_instance* instance;
+
+ if (npp == NULL)
+ return NULL;
+ instance = (np_instance*) npp->ndata;
+ if (instance == NULL) return NULL;
+
+ if (instance->javaInstance == NPN_NO_JAVA_INSTANCE) {
+ /* Been there, done that. */
+ return NULL;
+ }
+ else if (instance->javaInstance != NULL) {
+ /*
+ ** It's ok to get the JNIEnv here -- it won't initialize the
+ ** runtime because it would have already been initialized to
+ ** create the instance that we're just about to return.
+ */
+
+ /* But first, see if we need to recover the mochaWindow... */
+ np_recover_mochaWindow(npn_getJavaEnv(NULL),instance);
+
+ return (jref)instance->javaInstance;
+ }
+ else {
+ jclass clazz = npn_getJavaClass(instance->handle);
+ if (clazz) {
+ JNIEnv* env = npn_getJavaEnv(NULL); /* may start up the java runtime */
+ if (classPlugin == NULL) {
+ /*
+ ** Make sure we never unload the Plugin class. Why? Because
+ ** the method and field IDs we're using below have the same
+ ** lifetime as the class (theoretically):
+ */
+ classPlugin = env->NewGlobalRef(clazz);
+ }
+
+ /* instantiate the plugin's class: */
+#define methodname_netscape_plugin_Plugin_new ""
+#define methodsig_netscape_plugin_Plugin_new "()V"
+
+ javaInstance = env->NewObject(clazz, env->GetMethodID(clazz,
+ methodname_netscape_plugin_Plugin_new, methodsig_netscape_plugin_Plugin_new));
+ if (javaInstance) {
+ instance->javaInstance = env->NewGlobalRef(javaInstance);
+ np_recover_mochaWindow(env,instance);
+
+ /* Store the plugin as the peer: */
+#define fieldname_netscape_plugin_Plugin_peer "peer"
+#define fieldsig_netscape_plugin_Plugin_peer "I"
+ env->SetIntField(javaInstance,
+ env->GetFieldID(clazz,
+ fieldname_netscape_plugin_Plugin_peer, fieldsig_netscape_plugin_Plugin_peer),
+ (jint)instance->npp);
+
+#define methodname_netscape_plugin_Plugin_init "init"
+#define methodsig_netscape_plugin_Plugin_init "()V"
+ env->CallVoidMethod(javaInstance,
+ env->GetMethodID(clazz,
+ methodname_netscape_plugin_Plugin_init, methodsig_netscape_plugin_Plugin_init));
+
+ }
+ if (env->ExceptionOccurred()) {
+ env->DeleteGlobalRef(instance->javaInstance);
+ instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */
+ env->DeleteGlobalRef(classPlugin);
+ classPlugin = NULL;
+ env->ExceptionClear();
+ return NULL;
+ } \
+ }
+ else {
+ instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */
+ return NULL;
+ }
+ }
+ return (jref)javaInstance;
+}
+#elif defined(JAVA)
+jref NP_EXPORT
+npn_getJavaPeer(NPP npp)
+{
+ netscape_plugin_Plugin* javaInstance = NULL;
+ np_instance* instance;
+
+ if (npp == NULL)
+ return NULL;
+ instance = (np_instance*) npp->ndata;
+ if (instance == NULL) return NULL;
+
+ if (instance->javaInstance == NPN_NO_JAVA_INSTANCE) {
+ /* Been there, done that. */
+ return NULL;
+ }
+ else if (instance->javaInstance != NULL) {
+ /*
+ ** It's ok to get the JRIEnv here -- it won't initialize the
+ ** runtime because it would have already been initialized to
+ ** create the instance that we're just about to return.
+ */
+
+ /* But first, see if we need to recover the mochaWindow... */
+ np_recover_mochaWindow(npn_getJavaEnv(),instance);
+
+ return (jref)JRI_GetGlobalRef(npn_getJavaEnv(), instance->javaInstance);
+ }
+ else {
+ struct java_lang_Class* clazz = npn_getJavaClass(instance->handle);
+ if (clazz) {
+ JRIEnv* env = npn_getJavaEnv(); /* may start up the java runtime */
+ if (classPlugin == NULL) {
+ /*
+ ** Make sure we never unload the Plugin class. Why? Because
+ ** the method and field IDs we're using below have the same
+ ** lifetime as the class (theoretically):
+ */
+ classPlugin = JRI_NewGlobalRef(env, use_netscape_plugin_Plugin(env));
+ }
+
+ /* instantiate the plugin's class: */
+ javaInstance = netscape_plugin_Plugin_new(env, clazz);
+ if (javaInstance) {
+
+ instance->javaInstance = JRI_NewGlobalRef(env, javaInstance);
+
+ np_recover_mochaWindow(env,instance);
+
+ /* Store the plugin as the peer: */
+ set_netscape_plugin_Plugin_peer(env, javaInstance, (jint)instance->npp);
+
+
+ netscape_plugin_Plugin_init(env, javaInstance);
+ }
+ }
+ else {
+ instance->javaInstance = NPN_NO_JAVA_INSTANCE; /* prevent trying this every time around */
+ return NULL;
+ }
+ }
+ return (jref)javaInstance;
+}
+#endif /* JAVA */
+
+#if defined(XP_MAC) && !defined(powerc)
+#pragma pointers_in_A0
+#endif
+
+static XP_Bool
+np_IsLiveConnected(np_handle* handle)
+{
+ if (handle->userPlugin) {
+ nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin;
+ nsILiveConnectPlugin* lcPlugin;
+
+ if (userPluginClass->QueryInterface(kLiveConnectPluginIID,
+ (void**)&lcPlugin) != NS_NOINTERFACE) {
+ // Remember, QueryInterface increments the ref count;
+ // since we're done with it in this scope, release it.
+ lcPlugin->Release();
+
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+ }
+ else {
+ return npn_getJavaClass(handle) != NULL;
+ }
+}
+
+/* Is the plugin associated with this embedStruct liveconnected? */
+XP_Bool NPL_IsLiveConnected(LO_EmbedStruct *embed)
+{
+#if defined(JAVA) || defined(OJI)
+ NPEmbeddedApp* app;
+ np_data* ndata;
+
+ if (embed == NULL)
+ return FALSE;
+
+ app = (NPEmbeddedApp*) embed->objTag.FE_Data;
+ if (app == NULL)
+ return FALSE;
+
+ ndata = (np_data*) app->np_data;
+ XP_ASSERT(ndata);
+ return np_IsLiveConnected(ndata->instance->handle);
+#endif
+}
+
+
+
+/******************************************************************************/
+
+/* Returns false if there was an error: */
+static PRBool
+np_setwindow(np_instance *instance, NPWindow *appWin)
+{
+ /*
+ * On Windows and UNIX, we don't want to give a window
+ * to hidden plug-ins. To determine if we're hidden,
+ * we can look at the flag bit of the LO_EmbedStruct.
+ */
+ NPEmbeddedApp* app;
+ np_data* ndata;
+ LO_EmbedStruct* lo_struct;
+
+ if (instance)
+ {
+ app = instance->app;
+ if (app)
+ {
+ ndata = (np_data*) app->np_data;
+ lo_struct = ndata->lo_struct;
+#ifndef XP_MAC
+ if (lo_struct && lo_struct->objTag.ele_attrmask & LO_ELE_HIDDEN)
+ return PR_TRUE;
+#endif
+ }
+ }
+
+ XP_ASSERT(instance);
+ if (instance && appWin)
+ {
+ TRACEMSG(("npglue.c: CallNPP_SetWindowProc"));
+ if (instance->handle->userPlugin) {
+ nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata;
+ nsIPluginInstance* userInst = peerInst->GetUserInstance();
+ userInst->SetWindow((nsPluginWindow*)appWin);
+
+ // If this is the first time we're drawing this, then call
+ // the plugin's Start() method.
+ if (lo_struct && ! (lo_struct->objTag.ele_attrmask & LO_ELE_DRAWN)) {
+ nsPluginError err = userInst->Start();
+ if (err != nsPluginError_NoError) {
+ np_delete_instance(instance);
+ return PR_FALSE;
+ }
+ }
+ }
+ else if (ISFUNCPTR(instance->handle->f->setwindow)) {
+ CallNPP_SetWindowProc(instance->handle->f->setwindow, instance->npp, appWin);
+ }
+ }
+ else
+ {
+ NPTRACE(0,("setwindow before appWin was valid"));
+ }
+ return PR_TRUE;
+}
+
+static void
+np_UnloadPluginClass(np_handle *handle)
+{
+ /* only called when we truly want to dispose the plugin class */
+ XP_ASSERT(handle && handle->refs == 0);
+
+#if defined(OJI)
+ 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. */
+ JNIEnv* env = npn_getJavaEnv(NULL);
+ env->DeleteGlobalRef(handle->f->javaClass);
+ handle->f->javaClass = NULL;
+ }
+#elif defined(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. */
+ JRIEnv* env = npn_getJavaEnv();
+ JRI_DisposeGlobalRef(env, handle->f->javaClass);
+ handle->f->javaClass = NULL;
+ }
+#endif /* JAVA */
+
+ FE_UnloadPlugin(handle->pdesc, handle);
+ handle->f = NULL;
+
+ XP_ASSERT(handle->instances == NULL);
+ handle->instances = NULL;
+}
+
+
+/* this is called from the mocha thread to set the mocha window,
+* in response to getJavaPeer */
+PR_IMPLEMENT(void)
+NPL_SetPluginWindow(void *data)
+{
+#ifdef JAVA
+ JRIEnv * env = NULL;
+ np_instance *instance = (np_instance *) data;
+ struct netscape_javascript_JSObject *mochaWindow = NULL;
+
+ if (instance && instance->cx)
+ mochaWindow = LJ_GetMochaWindow(instance->cx);
+
+ env = LJ_EnsureJavaEnv(PR_CurrentThread());
+
+ if (mochaWindow){
+ instance->mochaWindow = JRI_NewGlobalRef(env, (jref) mochaWindow);
+
+ /* That's done, now stuff it in */
+ np_recover_mochaWindow(env,instance);
+ }
+#endif
+}
+
+
+np_instance*
+np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app,
+ np_mimetype *mimetype, char *requestedType)
+{
+ NPError err = NPERR_GENERIC_ERROR;
+ np_instance* instance = NULL;
+ NPP npp = NULL;
+ void* tmp;
+ np_data* ndata;
+
+ XP_ASSERT(handle && app);
+ if (!handle || !app)
+ return NULL;
+
+ /* make sure the plugin is loaded */
+ if (!handle->refs)
+ {
+#ifdef JAVA
+ JRIEnv* env = NULL;
+#endif
+ 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;
+ }
+#ifdef JAVA
+ /*
+ ** Don't use npn_getJavaEnv here. We don't want to start the
+ ** interpreter, just use env if it already exists.
+ */
+ 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
+ }
+
+ ndata = (np_data*) app->np_data;
+ NPSavedData* savedData = (NPSavedData*) (ndata ? ndata->sdata : NULL);
+
+ if (handle->userPlugin == NULL || savedData == NULL) {
+ // Then we're either an old style plugin that needs to get
+ // (re)created, or a new style plugin that hasn't yet saved
+ // its data, so it needs to get created the first time.
+
+ /* make an instance */
+ if (!(instance = XP_NEW_ZAP(np_instance)))
+ goto error;
+
+ instance->handle = handle;
+ instance->cx = cx;
+ instance->app = app;
+ instance->mimetype = mimetype;
+ instance->type = (app->pagePluginType == NP_FullPage) ? NP_FULL : NP_EMBED;
+ instance->typeString = (char*) (requestedType ? XP_STRDUP(requestedType) : NULL);
+
+ instance->mochaWindow = NULL;
+ instance->javaInstance = NULL;
+
+ app->type = NP_Plugin;
+
+ /* make an NPP */
+ if (!(tmp = XP_NEW_ZAP(NPP_t)))
+ goto error;
+ npp = (NPP) tmp; /* make pc compiler happy */
+ npp->ndata = instance;
+ 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->objTag.layer;
+#endif /* LAYERS */
+
+ /* invite the plugin */
+ TRACEMSG(("npglue.c: CallNPP_NewProc"));
+ if (handle->userPlugin) {
+ nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin;
+ nsPluginInstancePeer* peerInst = new nsPluginInstancePeer(npp);
+ if (peerInst == NULL) {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ }
+ else {
+ peerInst->AddRef();
+ nsIPluginInstance* userInst;
+ nsresult err2 = userPluginClass->CreateInstance(NULL, kPluginInstanceIID,
+ (void**)&userInst);
+ if (err2 == NS_OK && userInst != NULL) {
+ nsPluginError err3 = userInst->Initialize(peerInst);
+ if (err3 == nsPluginError_NoError) {
+ npp->pdata = peerInst;
+ peerInst->SetUserInstance(userInst);
+ ndata->sdata = (NPSavedData*)userInst;
+ err = NPERR_NO_ERROR;
+ }
+ else
+ err = NPERR_INVALID_INSTANCE_ERROR;
+ }
+ else
+ err = NPERR_INVALID_INSTANCE_ERROR;
+ }
+ }
+ else {
+ if (ISFUNCPTR(handle->f->newp))
+ {
+ XP_ASSERT(ndata);
+ 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);
+ }
+ else
+ {
+ /* A full-page plugin must be told its palette may
+ be realized as a foreground palette */
+ char name[] = "PALETTE";
+ char value[] = "foreground";
+ char* names[1];
+ char* values[1];
+ int16 argc = 1;
+ names[0] = name;
+ values[0] = value;
+
+ err = CallNPP_NewProc(handle->f->newp, requestedType, npp,
+ instance->type, argc, names, values, savedData);
+ }
+ }
+ }
+ if (err != NPERR_NO_ERROR)
+ goto error;
+
+ /* add this to the handle chain */
+ instance->next = handle->instances;
+ handle->instances = instance;
+ handle->refs++;
+
+ /*
+ * In the full-page case, FE_DisplayEmbed hasn't been called yet,
+ * so the window hasn't been created and wdata is still NULL.
+ * We don't want to give the plug-in a NULL window.
+ * N.B.: Actually, on the Mac, the window HAS been created (we
+ * need it because even undisplayed/hidden plug-ins may need a
+ * window), so wdata is not NULL; that's why we check the plug-in
+ * type rather than wdata here.
+ */
+#ifndef LAYERS
+ /*
+ * We don't know that layout has set the final position of the plug-in at this
+ * point. The danger is that the plug-in will draw into the window incorrectly
+ * with this call. With layers, we don't display the window until layout
+ * is completely done - at that we can call NPP_SetWindow.
+ */
+ if (app->pagePluginType == NP_Embedded)
+ {
+ XP_ASSERT(app->wdata);
+ PRBool success = np_setwindow(instance, app->wdata);
+ if (!success) goto error;
+ }
+#endif
+ }
+
+ /* XXX This is _not_ where Start() should go (IMO). Start() should be
+ called whenever we re-visit an applet
+
+ // Finally, if it's a 5.0-style (C++) plugin, send it the Start message.
+ // Do this before sending the mocha OnLoad message.
+ if (handle->userPlugin && ndata->sdata) {
+ nsIPluginInstance* userInst = (nsIPluginInstance*)ndata->sdata;
+ nsPluginError err = userInst->Start();
+ if (err != nsPluginError_NoError) goto error;
+ }
+ */
+
+#ifdef MOCHA
+ {
+ /* only wait on applets if onload flag */
+ lo_TopState *top_state = lo_FetchTopState(XP_DOCID(cx));
+ if (top_state != NULL && top_state->mocha_loading_embeds_count)
+ {
+ top_state->mocha_loading_embeds_count--;
+ ET_SendLoadEvent(cx, EVENT_XFER_DONE, NULL, NULL,
+ LO_DOCUMENT_LAYER_ID, FALSE);
+ }
+
+ /* tell the mocha thread to set us up with the window when it can */
+ if (
+#if 0
+ // XXX This is what we really want here, because it doesn't actually
+ // start up the jvm, it just checks that the plugin is LiveConnected.
+ // 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
+ FALSE
+#endif
+ ) { /* for liveconnected plugins only */
+ ET_SetPluginWindow(cx, (void *)instance);
+ }
+ }
+#endif /* MOCHA */
+
+ return instance;
+
+error:
+ /* Unload the plugin if there are no other instances */
+ if (handle->refs == 0)
+ {
+ np_UnloadPluginClass(handle);
+ }
+
+ if (instance)
+ XP_FREE(instance);
+ if (npp)
+ XP_FREE(npp);
+ return NULL;
+}
+
+
+
+NET_StreamClass *
+np_newstream(URL_Struct *urls, np_handle *handle, np_instance *instance)
+{
+ NET_StreamClass *nstream = nil;
+ NPStream *pstream = nil;
+ np_stream *stream = nil;
+ uint16 stype;
+ XP_Bool alreadyLocal;
+ XP_Bool b1;
+ XP_Bool b2;
+
+ /* make a netlib stream */
+ if (!(nstream = XP_NEW_ZAP(NET_StreamClass)))
+ return 0;
+
+ /* make the plugin stream data structures */
+ stream = np_makestreamobjects(instance, nstream, urls);
+ if (!stream)
+ {
+ XP_FREE(nstream);
+ return 0;
+ }
+ pstream = stream->pstream;
+
+ stream->prev_stream = NULL;
+
+ /* Let us treat mailbox as remote too
+ Not doing so causes problems with some attachments (Adobe)
+ */
+ b1 = NET_IsURLInDiskCache(stream->initial_urls);
+ b2 = (XP_STRNCASECMP(urls->address, "mailbox:", 8) == 0) ? 0 : NET_IsLocalFileURL(urls->address);
+
+ alreadyLocal = b1 || b2;
+
+ /* determine if the stream is seekable */
+ if (urls->server_can_do_byteranges || alreadyLocal)
+ {
+ /*
+ * Zero-length streams are never seekable.
+ * This will force us to download the entire
+ * stream if a byterange request is made.
+ */
+ if (urls->content_length > 0)
+ stream->seekable = 1;
+ }
+
+ /* and call the plugin */
+ instance->reentrant = 1;
+ stype = NP_NORMAL;
+ TRACEMSG(("npglue.c: CallNPP_NewStreamProc"));
+ if (handle->userPlugin) {
+ nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata;
+ nsIPluginInstance* userInst = peerInst->GetUserInstance();
+ nsPluginStreamPeer* peerStream = new nsPluginStreamPeer(urls, stream);
+ if (peerStream == NULL) {
+ /* XXX where's the error go? */
+ }
+ else {
+ peerStream->AddRef();
+ nsIPluginStream* userStream;
+ nsPluginError err = userInst->NewStream(peerStream, &userStream);
+ if (err == nsPluginError_NoError && userStream != NULL) {
+ peerStream->SetUserStream(userStream);
+ pstream->pdata = peerStream;
+
+ stype = userStream->GetStreamType();
+ }
+ else {
+ /* XXX where's the error go? */
+ }
+ }
+ }
+ else if (ISFUNCPTR(handle->f->newstream))
+ {
+ /*XXX*/CallNPP_NewStreamProc(handle->f->newstream, instance->npp, urls->content_type,
+ pstream, stream->seekable, &stype);
+ }
+ if(!instance->reentrant)
+ {
+ urls->pre_exit_fn = np_dofetch;
+ XP_FREE(nstream); /* will not call abort */
+ return 0;
+ }
+ instance->reentrant = 0;
+
+ /* see if its hard */
+ if(stype == NP_SEEK)
+ {
+ if(!stream->seekable)
+ {
+ NPTRACE(0,("stream is dumb, force caching"));
+ stream->seek = 2;
+ }
+ /* for a seekable stream that doesn't require caching, in the SSL case, don't cache, because that
+ will leave the supposedly secure file laying around in the cache! */
+ if ( !alreadyLocal
+ && !(XP_STRNCASECMP(urls->address, "https:", 6)==0))
+ urls->must_cache = TRUE;
+ stream->dontclose++;
+ }
+ else if (stype == NP_ASFILE || stype == NP_ASFILEONLY)
+ {
+ NPTRACE(0,("stream as file"));
+ if (!alreadyLocal)
+ urls->must_cache = TRUE;
+ stream->asfile = stype;
+ }
+
+ /*
+ * If they want just the file, and the file is local, there's
+ * no need to continue with the netlib stream: just give them
+ * the file and we're done.
+ */
+ if (stype == NP_ASFILEONLY)
+ {
+ if (urls->cache_file || NET_IsLocalFileURL(urls->address))
+ {
+ np_streamAsFile(stream);
+ np_destroystream(stream, NPRES_DONE);
+ XP_FREE(nstream);
+ return NULL;
+ }
+ }
+
+ /* and populate the netlib stream */
+ nstream->name = "plug-in";
+ nstream->complete = NPL_Complete;
+ nstream->abort = NPL_Abort;
+ nstream->is_write_ready = NPL_WriteReady;
+ nstream->put_block = (MKStreamWriteFunc)NPL_Write;
+ nstream->data_object = (void *)urls;
+ nstream->window_id = instance->cx;
+
+ /* In case of Mailbox->StreamAsFile, use cache code to store, handle... */
+ if ( ((stype == NP_ASFILE) || (stype == NP_ASFILEONLY)) &&
+ ((XP_STRNCASECMP(urls->address, "mailbox:", 8)==0)
+ || (XP_STRNCASECMP(urls->address, "news:" , 5)==0)
+ || (XP_STRNCASECMP(urls->address, "snews:" , 6)==0))
+ &&
+ (stream != NULL) &&
+ (urls->cache_file == NULL)) /* if already cached, is well-handled */
+ {
+ urls->must_cache = TRUE;
+ stream->prev_stream = NET_StreamBuilder(FO_CACHE_ONLY,urls,instance->cx);
+ }
+
+ return nstream;
+}
+
+XP_Bool np_FakeHTMLStream(URL_Struct* urls, MWContext* cx, char * fakehtml)
+{
+ NET_StreamClass* viewstream;
+ char* org_content_type = urls->content_type;
+ XP_Bool ret = FALSE;
+
+ urls->content_type = NULL;
+
+ StrAllocCopy(urls->content_type, TEXT_HTML);
+ if(urls->content_type == NULL) /* StrAllocCopy failed */
+ goto Exit;
+
+ urls->is_binary = 1; /* flag for mailto and saveas */
+
+ if ((viewstream = NET_StreamBuilder(FO_PRESENT, urls, cx)) != 0)
+ {
+ (*viewstream->put_block)(viewstream, fakehtml, XP_STRLEN(fakehtml));
+ (*viewstream->complete)(viewstream);
+
+ XP_FREEIF(viewstream);
+ viewstream = NULL;
+ ret = TRUE;
+ }
+
+ XP_FREE(urls->content_type);
+
+Exit:
+ urls->content_type = org_content_type;
+ return ret;
+}
+
+NET_StreamClass*
+NPL_NewPresentStream(FO_Present_Types format_out, void* type, URL_Struct* urls, MWContext* cx)
+{
+ np_handle* handle = (np_handle*) type;
+ np_instance* instance = NULL;
+ np_data* ndata = NULL;
+ np_mimetype* mimetype = NULL;
+ np_reconnect* reconnect;
+ NPEmbeddedApp *app = NULL;
+
+#ifdef ANTHRAX
+ char* fileName;
+ char* newTag;
+ uint32 strLen;
+#endif /* ANTHRAX */
+
+ XP_ASSERT(type && urls && cx);
+ if (!type || !urls || !cx)
+ return NULL;
+
+ /* fe_data is set by EmbedCreate, which hasn't happed yet for PRESENT streams */
+ XP_ASSERT(urls->fe_data == NULL);
+
+#ifdef ANTHRAX
+ if((fileName = NPL_FindAppletEnabledForMimetype(handle->name)) != NULL)
+ {
+ XP_FREE(fileName); /* we don't need the applet name here, so discard it */
+ fileName = strrchr(urls->address, '/')+1;
+
+ strLen = XP_STRLEN(fileName);
+
+ newTag = XP_ALLOC((36+strLen)*sizeof(char));
+ newTag[0] = 0;
+
+ XP_STRCAT(newTag, "