A src/nsIPluglet.idl
M classes/org/mozilla/pluglet/Registry.java M dist/build.xml M examples/simple/src/main/java/simple/SimplePluglet.java M examples/simple/src/main/web/index.html M mozilla/Makefile.in M mozilla/nppluglet.cpp M mozilla/nppluglet.h M mozilla/nsScriptablePeer.cpp M netbeans/nbproject/build-impl.xml M netbeans/nbproject/genfiles.properties M netbeans/nbproject/project.properties M netbeans/nbproject/project.xml M src/Makefile.in M src/Pluglet.cpp M src/Pluglet.h M src/PlugletEngine.cpp M src/PlugletFactory.cpp M src/Registry.cpp M src/Registry.h R mozilla/nsIPluglet.idl - At this point, I can call from JavaScript and locate an arbitratily named method on the Pluglet instance that conforms to the signature of returning String, and taking 0 or more Strings as arguments. git-svn-id: svn://10.0.0.236/trunk@242001 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
public class Registry {
|
||||
@@ -46,5 +47,66 @@ public class Registry {
|
||||
table.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
public static String findMatchingPlugletMethod(Pluglet pluglet,
|
||||
String methodName, int numStringArgs) {
|
||||
String result = null;
|
||||
Class plugletClass = pluglet.getClass();
|
||||
Method [] methods = plugletClass.getMethods();
|
||||
boolean foundMatch = false;
|
||||
Method matchingMethod = null;
|
||||
// For each of the methods on the Pluglet
|
||||
for (Method cur : methods) {
|
||||
if (foundMatch) {
|
||||
break;
|
||||
}
|
||||
// See if the name of the method matches the name we
|
||||
// are looking for.
|
||||
if (cur.getName().equals(methodName)) {
|
||||
// If so, does it return String?
|
||||
if (String.class == cur.getReturnType()) {
|
||||
// If so, do the number of arguments match?
|
||||
Class [] paramTypes = cur.getParameterTypes();
|
||||
if (numStringArgs == paramTypes.length) {
|
||||
foundMatch = true;
|
||||
matchingMethod = cur;
|
||||
// If so, are all the arguments of type String?
|
||||
for (Class curClass : paramTypes) {
|
||||
if (String.class != curClass) {
|
||||
// If not, this method is not a match.
|
||||
foundMatch = false;
|
||||
matchingMethod = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// No, the number of arguments do not match, not a match
|
||||
else {
|
||||
foundMatch = false;
|
||||
}
|
||||
}
|
||||
// No, it does not return String, not a match.
|
||||
else {
|
||||
foundMatch = false;
|
||||
}
|
||||
}
|
||||
// No, the name does not match, not a match
|
||||
else {
|
||||
foundMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (foundMatch) {
|
||||
StringBuilder signature = new StringBuilder();
|
||||
signature.append('(');
|
||||
for (int i = 0; i < numStringArgs; i++) {
|
||||
signature.append("Ljava/lang/String;");
|
||||
}
|
||||
signature.append(")Ljava/lang/String;");
|
||||
result = signature.toString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
mozilla/java/plugins/dist/build.xml
vendored
4
mozilla/java/plugins/dist/build.xml
vendored
@@ -269,15 +269,13 @@
|
||||
<target name="copy.binaries" depends="prepare">
|
||||
<copy todir="${dist.home}/bin/${platform}/bin/components"
|
||||
file="${objdir}/java/plugins/src/${so.prefix}pluglet.${so.extension}" />
|
||||
<copy todir="${dist.home}/bin/${platform}/bin/components"
|
||||
file="${objdir}/java/plugins/src/_xpidlgen/pluglet.xpt" />
|
||||
<copy todir="${dist.home}/bin/${platform}/bin"
|
||||
file="${objdir}/java/plugins/jni/${so.prefix}plugletjni.${so.extension}" />
|
||||
<copy todir="${dist.home}/bin/${platform}/bin/plugins"
|
||||
file="${objdir}/java/plugins/mozilla/${so.prefix}nppluglet.${so.extension}" />
|
||||
|
||||
<copy todir="${dist.home}/bin/xp/bin/components">
|
||||
<fileset dir="${objdir}/java/plugins/mozilla/_xpidlgen">
|
||||
<fileset dir="${objdir}/java/plugins/src/_xpidlgen">
|
||||
<include name="*.xpt" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
@@ -192,6 +192,11 @@ class SimplePlugletInstance implements Pluglet {
|
||||
protected void finalize() {
|
||||
org.mozilla.util.DebugPluglet.print("--SimplePlugletInstance.finalize()\n");
|
||||
}
|
||||
|
||||
public String calledFromJavaScript1(String arg1, String arg2) {
|
||||
org.mozilla.util.DebugPluglet.print("calledFromJavaScript1\n");
|
||||
return "hard coded result";
|
||||
}
|
||||
}
|
||||
|
||||
class TestStreamListener implements PlugletStreamListener {
|
||||
|
||||
@@ -10,14 +10,14 @@ var embed = document.embeds[0];
|
||||
function callPluglet()
|
||||
{
|
||||
var strs2 = {
|
||||
value : ["double","me","please"]
|
||||
value : ["double","me"]
|
||||
};
|
||||
|
||||
var strslen2 = {
|
||||
value : strs2.value.length
|
||||
};
|
||||
|
||||
embed.callPlugletMethod("methodName", strslen2, strs2);
|
||||
embed.callPlugletMethod("calledFromJavaScript1", strslen2, strs2);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -60,8 +60,6 @@ CPPSRCS = nsScriptablePeer.cpp \
|
||||
npAPInsIInputStreamShim.cpp \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = nsIPluglet.idl
|
||||
|
||||
SHARED_LIBRARY_LIBS = $(PLUGIN_SDK_OBJDIR)/samples/common/$(LIB_PREFIX)plugingate_s.$(LIB_SUFFIX) ../src/$(LIB_PREFIX)pluglet.$(LIB_SUFFIX) $(XPCOM_LIBS) $(NSPR_LIBS)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
||||
@@ -376,6 +376,16 @@ NS_IMETHODIMP nsPluginInstance::HasPlugletForMimeType(const char *aMimeType,
|
||||
|
||||
return rv;
|
||||
}
|
||||
NS_IMETHODIMP nsPluginInstance::CallPlugletMethod(const char *methodName, PRUint32 *inArgc,
|
||||
char ***inArgv)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIPluglet> pluglet = do_QueryInterface(mPluglet);
|
||||
if (pluglet) {
|
||||
rv = pluglet->CallPlugletMethod(methodName, inArgc, inArgv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsPluginInstance::CopyNPWindowToNsPluginWindow(NPWindow *aWindow,
|
||||
nsPluginWindow *pluginWindow)
|
||||
|
||||
@@ -72,6 +72,7 @@ public:
|
||||
|
||||
// locals
|
||||
NS_IMETHOD HasPlugletForMimeType(const char *aMimeType, PRBool *outResult);
|
||||
NS_IMETHOD CallPlugletMethod(const char *methodName, PRUint32 *inArgc, char ***inArgv);
|
||||
|
||||
nsScriptablePeer* getScriptablePeer();
|
||||
|
||||
|
||||
@@ -122,23 +122,13 @@ void nsScriptablePeer::SetInstance(nsPluginInstance* plugin)
|
||||
// return NS_OK;
|
||||
//}
|
||||
|
||||
NS_IMETHODIMP nsScriptablePeer::HasPlugletForMimeType(const char *aMimeType, PRBool *isSupported)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (mPlugin) {
|
||||
rv = mPlugin->HasPlugletForMimeType(aMimeType, isSupported);
|
||||
}
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScriptablePeer::CallPlugletMethod(const char *methodName,
|
||||
PRUint32 *inArgc, char ***inArgv)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PR_LOG(log, PR_LOG_DEBUG,
|
||||
("nppluglet CallPlugletMethod: methodName: %s\n", methodName));
|
||||
*inArgc = 0;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (mPlugin) {
|
||||
rv = mPlugin->CallPlugletMethod(methodName, inArgc, inArgv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,36 +44,6 @@ is divided into following sections:
|
||||
<property file="nbproject/project.properties"/>
|
||||
</target>
|
||||
<target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
|
||||
<j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
|
||||
<j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
|
||||
<j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>
|
||||
<j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>
|
||||
<condition property="platform.javac" value="${platform.home}/bin/javac">
|
||||
<equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>
|
||||
</condition>
|
||||
<property name="platform.javac" value="${platform.javac.tmp}"/>
|
||||
<j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>
|
||||
<condition property="platform.java" value="${platform.home}/bin/java">
|
||||
<equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>
|
||||
</condition>
|
||||
<property name="platform.java" value="${platform.java.tmp}"/>
|
||||
<j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>
|
||||
<condition property="platform.javadoc" value="${platform.home}/bin/javadoc">
|
||||
<equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>
|
||||
</condition>
|
||||
<property name="platform.javadoc" value="${platform.javadoc.tmp}"/>
|
||||
<condition property="platform.invalid" value="true">
|
||||
<or>
|
||||
<contains string="${platform.javac}" substring="$${platforms."/>
|
||||
<contains string="${platform.java}" substring="$${platforms."/>
|
||||
<contains string="${platform.javadoc}" substring="$${platforms."/>
|
||||
</or>
|
||||
</condition>
|
||||
<fail unless="platform.home">Must set platform.home</fail>
|
||||
<fail unless="platform.bootcp">Must set platform.bootcp</fail>
|
||||
<fail unless="platform.java">Must set platform.java</fail>
|
||||
<fail unless="platform.javac">Must set platform.javac</fail>
|
||||
<fail if="platform.invalid">Platform is not correctly set up</fail>
|
||||
<available file="${manifest.file}" property="manifest.available"/>
|
||||
<condition property="manifest.available+main.class">
|
||||
<and>
|
||||
@@ -95,6 +65,7 @@ is divided into following sections:
|
||||
</condition>
|
||||
<condition property="have.sources">
|
||||
<or>
|
||||
<available file="${src.classes.dir}"/>
|
||||
<available file="${src.EmptyMainClass.dir}"/>
|
||||
<available file="${src.java.dir}"/>
|
||||
<available file="${src.java2.dir}"/>
|
||||
@@ -125,6 +96,7 @@ is divided into following sections:
|
||||
<!-- You can override this target in the ../build.xml file. -->
|
||||
</target>
|
||||
<target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
|
||||
<fail unless="src.classes.dir">Must set src.classes.dir</fail>
|
||||
<fail unless="src.EmptyMainClass.dir">Must set src.EmptyMainClass.dir</fail>
|
||||
<fail unless="src.java.dir">Must set src.java.dir</fail>
|
||||
<fail unless="src.java2.dir">Must set src.java2.dir</fail>
|
||||
@@ -148,13 +120,13 @@ is divided into following sections:
|
||||
</target>
|
||||
<target name="-init-macrodef-javac">
|
||||
<macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="srcdir" default="${src.EmptyMainClass.dir}:${src.java.dir}:${src.java2.dir}"/>
|
||||
<attribute name="srcdir" default="${src.classes.dir}:${src.EmptyMainClass.dir}:${src.java.dir}:${src.java2.dir}"/>
|
||||
<attribute name="destdir" default="${build.classes.dir}"/>
|
||||
<attribute name="classpath" default="${javac.classpath}"/>
|
||||
<attribute name="debug" default="${javac.debug}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" fork="yes" executable="${platform.javac}" tempdir="${java.io.tmpdir}" includeantruntime="false">
|
||||
<javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false">
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
@@ -168,7 +140,7 @@ is divided into following sections:
|
||||
<macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<attribute name="includes" default="**/*Test.java"/>
|
||||
<sequential>
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed" jvm="${platform.java}">
|
||||
<junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed">
|
||||
<batchtest todir="${build.test.results.dir}"/>
|
||||
<classpath>
|
||||
<path path="${run.test.classpath}"/>
|
||||
@@ -194,9 +166,6 @@ is divided into following sections:
|
||||
<classpath>
|
||||
<path path="@{classpath}"/>
|
||||
</classpath>
|
||||
<bootclasspath>
|
||||
<path path="${platform.bootcp}"/>
|
||||
</bootclasspath>
|
||||
</nbjpdastart>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
@@ -215,7 +184,7 @@ is divided into following sections:
|
||||
<attribute name="classpath" default="${debug.classpath}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xnoagent"/>
|
||||
<jvmarg value="-Djava.compiler=none"/>
|
||||
@@ -238,7 +207,7 @@ is divided into following sections:
|
||||
<attribute name="classname" default="${main.class}"/>
|
||||
<element name="customize" optional="true"/>
|
||||
<sequential>
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
|
||||
<java fork="true" classname="@{classname}" dir="${work.dir}">
|
||||
<jvmarg line="${run.jvmargs}"/>
|
||||
<classpath>
|
||||
<path path="${run.classpath}"/>
|
||||
@@ -276,6 +245,7 @@ is divided into following sections:
|
||||
<target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
|
||||
<j2seproject3:javac/>
|
||||
<copy todir="${build.classes.dir}">
|
||||
<fileset dir="${src.classes.dir}" excludes="${build.classes.excludes}"/>
|
||||
<fileset dir="${src.EmptyMainClass.dir}" excludes="${build.classes.excludes}"/>
|
||||
<fileset dir="${src.java.dir}" excludes="${build.classes.excludes}"/>
|
||||
<fileset dir="${src.java2.dir}" excludes="${build.classes.excludes}"/>
|
||||
@@ -335,7 +305,7 @@ is divided into following sections:
|
||||
<path path="${run.classpath}"/>
|
||||
<map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
|
||||
</pathconvert>
|
||||
<echo>${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
<echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
|
||||
</target>
|
||||
<target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
|
||||
<property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
|
||||
@@ -360,7 +330,7 @@ is divided into following sections:
|
||||
</copylibs>
|
||||
<echo>To run this application from the command line without Ant, try:</echo>
|
||||
<property name="dist.jar.resolved" location="${dist.jar}"/>
|
||||
<echo>${platform.java} -jar "${dist.jar.resolved}"</echo>
|
||||
<echo>java -jar "${dist.jar.resolved}"</echo>
|
||||
</target>
|
||||
<target name="-post-jar">
|
||||
<!-- Empty placeholder for easier customization. -->
|
||||
@@ -423,18 +393,21 @@ is divided into following sections:
|
||||
-->
|
||||
<target name="-javadoc-build" depends="init">
|
||||
<mkdir dir="${dist.javadoc.dir}"/>
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true" executable="${platform.javadoc}">
|
||||
<javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true">
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<sourcepath>
|
||||
<pathelement location="${src.classes.dir}"/>
|
||||
<pathelement location="${src.EmptyMainClass.dir}"/>
|
||||
<pathelement location="${src.java.dir}"/>
|
||||
<pathelement location="${src.java2.dir}"/>
|
||||
</sourcepath>
|
||||
<packageset dir="${src.classes.dir}" includes="*/**"/>
|
||||
<packageset dir="${src.EmptyMainClass.dir}" includes="*/**"/>
|
||||
<packageset dir="${src.java.dir}" includes="*/**"/>
|
||||
<packageset dir="${src.java2.dir}" includes="*/**"/>
|
||||
<fileset dir="${src.classes.dir}" includes="*.java"/>
|
||||
<fileset dir="${src.EmptyMainClass.dir}" includes="*.java"/>
|
||||
<fileset dir="${src.java.dir}" includes="*.java"/>
|
||||
<fileset dir="${src.java2.dir}" includes="*.java"/>
|
||||
|
||||
@@ -3,6 +3,6 @@ build.xml.script.CRC32=4cc13411
|
||||
build.xml.stylesheet.CRC32=240b97a2
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=c09404ce
|
||||
nbproject/build-impl.xml.script.CRC32=d63e7ed7
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=20b9345e
|
||||
nbproject/build-impl.xml.data.CRC32=ea24ec3b
|
||||
nbproject/build-impl.xml.script.CRC32=dd66d43e
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=65d7ca21
|
||||
|
||||
@@ -20,10 +20,10 @@ file.reference.examples-EmptyMainClass=../examples/EmptyMainClass
|
||||
file.reference.main-java=../examples/simple/src/main/java
|
||||
file.reference.main-java-1=../examples/jmf-player/src/main/java
|
||||
file.reference.main-java-2=../examples/jmfplayer/src/main/java
|
||||
file.reference.plugins-classes=../classes
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${libs.JMF.classpath}:\
|
||||
${file.reference.pluglet-1_1_a2.jar}
|
||||
${libs.JMF.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
@@ -47,7 +47,7 @@ javadoc.windowtitle=
|
||||
main.class=EmptyMainClass
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
platform.active=Java_HotSpot_TM__Client_VM_1.5.0_11-b03
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
@@ -58,6 +58,7 @@ run.jvmargs=
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
src.classes.dir=${file.reference.plugins-classes}
|
||||
src.EmptyMainClass.dir=${file.reference.examples-EmptyMainClass}
|
||||
src.java.dir=${file.reference.main-java}
|
||||
src.java2.dir=${file.reference.main-java-2}
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>pluglet</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<explicit-platform explicit-source-supported="true"/>
|
||||
<source-roots>
|
||||
<root id="src.classes.dir" name="pluglet-core"/>
|
||||
<root id="src.EmptyMainClass.dir" name="EmptyMainClass"/>
|
||||
<root id="src.java.dir" name="SimplePluglet"/>
|
||||
<root id="src.java2.dir" name="jmfplayer"/>
|
||||
|
||||
@@ -34,17 +34,17 @@ IS_COMPONENT = 1
|
||||
|
||||
ifeq ($(OS_ARCH),Linux)
|
||||
INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/linux $(INCLUDES) \
|
||||
-I$(DEPTH)/widget/src/gtk -I../src_share
|
||||
-I$(DEPTH)/widget/src/gtk
|
||||
else
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/win32 $(INCLUDES) \
|
||||
-I../src_share -I.
|
||||
-I -I.
|
||||
else
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
INCLUDES := -I$(MOZ_JDKHOME)/include $(INCLUDES) -I../src_share -I.
|
||||
INCLUDES := -I$(MOZ_JDKHOME)/include $(INCLUDES) -I.
|
||||
else
|
||||
INCLUDES := -I$(MOZ_JDKHOME)/include -I$(MOZ_JDKHOME)/include/solaris $(INCLUDES) \
|
||||
-I$(DEPTH)/widget/src/gtk -I../src_share
|
||||
-I$(DEPTH)/widget/src/gtk
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@@ -81,6 +81,7 @@ endif
|
||||
endif
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIPluglet.idl \
|
||||
iPlugletEngine.idl \
|
||||
iPlugletManager.idl \
|
||||
$(NULL)
|
||||
|
||||
@@ -40,7 +40,10 @@ jmethodID Pluglet::printMID = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS1(Pluglet,nsIPluginInstance);
|
||||
NS_IMPL_ISUPPORTS2(Pluglet,
|
||||
nsIPluginInstance,
|
||||
nsIPluglet)
|
||||
|
||||
|
||||
Pluglet::Pluglet(jobject object) : peer(nsnull) {
|
||||
nsresult rv;
|
||||
@@ -299,6 +302,34 @@ NS_METHOD Pluglet::Print(nsPluginPrint* platformPrint) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP Pluglet::CallPlugletMethod(const char *methodName, PRUint32 *inArgc,
|
||||
char ***inArgv)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (NULL != methodName && 0 < strlen(methodName) && NULL != inArgc && NULL != inArgv) {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("Pluglet::CallPlugletMethod: methodName: %s\n", methodName));
|
||||
|
||||
jmethodID plugletMethodMID = Registry::GetMethodIDForPlugletMethod(jthis, methodName,
|
||||
(jint) *inArgc);
|
||||
if (NULL != plugletMethodMID) {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("Pluglet::CallPlugletMethod: found match for methodName: %s\n", methodName));
|
||||
}
|
||||
else {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("Pluglet::CallPlugletMethod: no match for methodName: %s\n", methodName));
|
||||
}
|
||||
}
|
||||
else {
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
("Pluglet::CallPlugletMethod: invalid arguments\n"));
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
#include "PlugletView.h"
|
||||
#include "nsIPluglet.h"
|
||||
|
||||
class iPlugletEngine;
|
||||
|
||||
class Pluglet : public nsIPluginInstance {
|
||||
class Pluglet : public nsIPluginInstance, public nsIPluglet {
|
||||
public:
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
|
||||
@@ -38,6 +39,7 @@ class Pluglet : public nsIPluginInstance {
|
||||
NS_IMETHOD SetWindow(nsPluginWindow* window);
|
||||
NS_IMETHOD Print(nsPluginPrint* platformPrint);
|
||||
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
NS_DECL_NSIPLUGLET
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
Pluglet(jobject object);
|
||||
|
||||
@@ -202,7 +202,7 @@ void PlugletEngine::StartJVM() {
|
||||
options[3].optionString=""; //-Djava.compiler=NONE";
|
||||
vm_args.version = JNI_VERSION_1_4;
|
||||
vm_args.options = options;
|
||||
vm_args.nOptions = 1; // EDBURNS: Change to 3 for debugging
|
||||
vm_args.nOptions = 1; // EDBURNS: Change to 3 for debugging, 1 for non-debuging
|
||||
vm_args.ignoreUnrecognized = JNI_FALSE;
|
||||
/* Create the Java VM */
|
||||
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
|
||||
|
||||
@@ -62,7 +62,7 @@ nsresult PlugletFactory::CreatePluginInstance(const char* aPluginMIMEType, void
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsISupports * instance = new Pluglet(obj);
|
||||
Pluglet * instance = new Pluglet(obj);
|
||||
NS_ADDREF(instance);
|
||||
*aResult = instance;
|
||||
return NS_OK;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
jclass Registry::clazz = NULL;
|
||||
jmethodID Registry::setPeerMID = NULL;
|
||||
jmethodID Registry::removeMID = NULL;
|
||||
jmethodID Registry::findMatchingPlugletMethodMID = NULL;
|
||||
|
||||
void Registry::SetPeer(jobject key, jlong peer) {
|
||||
if (!clazz) {
|
||||
@@ -81,6 +82,71 @@ void Registry::Remove(jobject key) {
|
||||
}
|
||||
}
|
||||
|
||||
jmethodID Registry::GetMethodIDForPlugletMethod(jobject plugletInstance, const char *methodName,
|
||||
jint numStringArgs)
|
||||
{
|
||||
jmethodID result = NULL;
|
||||
|
||||
if (!clazz) { // it is impossible
|
||||
Initialize();
|
||||
if(!clazz) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == methodName || 0 == strlen(methodName)) {
|
||||
return result;
|
||||
}
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<iPlugletEngine> plugletEngine =
|
||||
do_GetService(PLUGLETENGINE_ContractID, &rv);;
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
JNIEnv *env = nsnull;
|
||||
rv = plugletEngine->GetJNIEnv(&env);
|
||||
if (NS_FAILED(rv)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
env->ExceptionClear();
|
||||
|
||||
jstring methodNameJstr = env->NewStringUTF(methodName);
|
||||
jstring methodSignatureJstr;
|
||||
methodSignatureJstr = (jstring)
|
||||
env->CallStaticObjectMethod(clazz, findMatchingPlugletMethodMID,
|
||||
plugletInstance, methodNameJstr, numStringArgs);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
return result;
|
||||
}
|
||||
|
||||
if (NULL != methodSignatureJstr) {
|
||||
jboolean isCopy;
|
||||
const char *signature = env->GetStringUTFChars(methodSignatureJstr, &isCopy);
|
||||
|
||||
if (NULL != signature) {
|
||||
jclass plugletClass = env->GetObjectClass(plugletInstance);
|
||||
result = env->GetMethodID(plugletClass, methodName, signature);
|
||||
if (isCopy == JNI_TRUE) {
|
||||
env->ReleaseStringUTFChars(methodSignatureJstr, signature);
|
||||
}
|
||||
}
|
||||
env->DeleteLocalRef(methodSignatureJstr);
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(methodNameJstr);
|
||||
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Registry::Initialize() {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<iPlugletEngine> plugletEngine =
|
||||
@@ -114,6 +180,14 @@ void Registry::Initialize() {
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
findMatchingPlugletMethodMID = env->GetStaticMethodID(clazz,"findMatchingPlugletMethod","(Lorg/mozilla/pluglet/Pluglet;Ljava/lang/String;I)Ljava/lang/String;");
|
||||
if (!findMatchingPlugletMethodMID) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,14 @@ class Registry {
|
||||
public:
|
||||
static void SetPeer(jobject key, jlong peer);
|
||||
static void Remove(jobject key);
|
||||
static jmethodID GetMethodIDForPlugletMethod(jobject plugletInstance, const char *methodName,
|
||||
jint numStringArgs);
|
||||
private:
|
||||
static void Initialize();
|
||||
static jclass clazz;
|
||||
static jmethodID setPeerMID;
|
||||
static jmethodID removeMID;
|
||||
static jmethodID findMatchingPlugletMethodMID;
|
||||
};
|
||||
#endif /* __Registry_h__ */
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
|
||||
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
|
||||
interface nsIPluglet : nsISupports {
|
||||
boolean hasPlugletForMimeType(in string aMimeType);
|
||||
void callPlugletMethod(in string methodName,
|
||||
inout PRUint32 inArgc,
|
||||
[array, size_is(inArgc)] inout string inArgv);
|
||||
Reference in New Issue
Block a user