Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pluglet status

3 views
Skip to first unread message

edburns

unread,
Oct 5, 2006, 9:21:31 PM10/5/06
to
Wow, the last time I posted on pluglet status was April 12th. Oh well,
I've been busy:the wife and kids, and [1], [2], [3], and of course the
wife and kids. Anyhow, I have decided that the current "correct" way
to write a plugin is via the old NPP API, not XPCOM. Therefore, I have
endeavored to use the plugin SDK to write a plugin that handles the *
type and then use the pluglet API to see if there is a pluglet
installed for that type. To do this, I had to add the following two
prefs:

user_pref("plugin.allow_alien_star_handler", true);
user_pref("plugin.default_plugin_disabled", false);

This enables my plugin for * to get called.

The next step is to bridge between the plugletfacory XPCOM object and
the NPP plugin. Pretty straightforward.

Ed

[1] http://purl.oclc.org/NET/jsfbook/
[2] http://dynafaces.dev.java.net/
[3] http://java.sun.com/javaee/javaserverfaces/

edburns

unread,
Oct 13, 2006, 10:47:22 AM10/13/06
to

edburns wrote:
> Wow, the last time I posted on pluglet status was April 12th. Oh well,
> I've been busy:the wife and kids, and [1], [2], [3], and of course the
> wife and kids. Anyhow, I have decided that the current "correct" way
> to write a plugin is via the old NPP API, not XPCOM. Therefore, I have
> endeavored to use the plugin SDK to write a plugin that handles the *
> type and then use the pluglet API to see if there is a pluglet
> installed for that type. To do this, I had to add the following two
> prefs:

M mozilla/nppluglet.cpp
M mozilla/nppluglet.h
M src/Pluglet.cpp
M src/Pluglet.h
M src/PlugletEngine.cpp

SetWindow works. Next step is to try hook up scriptability.

Ed

edburns

unread,
Oct 14, 2006, 8:30:23 AM10/14/06
to
Tested that create/start/stop/destroy works.

Have scriptability from JavaScript to C++ working. Next step is to get
it working straight through to Java.

M mozilla/Makefile.in

- add nspr to libs

M mozilla/nppluglet.cpp

- make sure to store instance pointer for return to browser, this
enables
shutdown to work properly

- When HasPlugletForMimeType is called multiple times, actually check
the mime type.

M mozilla/nsISimplePlugin.idl

- Fix this so it's callable from JavaScript

M src/PlugletsDir.cpp

- Fix bug for multiple plugin instances

Index: mozilla/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/mozilla/Makefile.in,v
retrieving revision 1.1
diff -u -r1.1 Makefile.in
--- mozilla/Makefile.in 7 Oct 2006 23:31:52 -0000 1.1
+++ mozilla/Makefile.in 14 Oct 2006 12:26:06 -0000
@@ -59,7 +59,7 @@

XPIDLSRCS = nsISimplePlugin.idl

-SHARED_LIBRARY_LIBS =
$(PLUGIN_SDK)/samples/common/$(LIB_PREFIX)plugingate_s.$(LIB_SUFFIX)
../src/$(LIB_PREFIX)pluglet_s.$(LIB_SUFFIX)
+SHARED_LIBRARY_LIBS =
$(PLUGIN_SDK)/samples/common/$(LIB_PREFIX)plugingate_s.$(LIB_SUFFIX)
../src/$(LIB_PREFIX)pluglet.$(LIB_SUFFIX) $(XPCOM_LIBS) $(NSPR_LIBS)

ifeq ($(OS_ARCH),WINNT)
DEFFILE = $(win_srcdir)/nppluglet.def
Index: mozilla/nppluglet.cpp
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/mozilla/nppluglet.cpp,v
retrieving revision 1.3
diff -u -r1.3 nppluglet.cpp
--- mozilla/nppluglet.cpp 13 Oct 2006 14:45:14 -0000 1.3
+++ mozilla/nppluglet.cpp 14 Oct 2006 12:26:07 -0000
@@ -47,6 +47,8 @@

#include "nsServiceManagerUtils.h"

+#include "plstr.h"
+
// service manager which will give the access to all public browser
services
// we will use memory service as an illustration
nsIServiceManager * gServiceManager = NULL;
@@ -153,17 +155,21 @@
// nsPluginInstance class implementation
//
nsPluginInstance::nsPluginInstance(nsPluginCreateData *
aCreateDataStruct) : nsPluginInstanceBase(),
- mInstance(aCreateDataStruct->instance),
mInitialized(PR_FALSE),
mScriptablePeer(nsnull),
mPluglet(nsnull)
{
+ mInstance = aCreateDataStruct->instance;
+
mCreateDataStruct.instance = aCreateDataStruct->instance;
mCreateDataStruct.type = aCreateDataStruct->type;
mCreateDataStruct.mode = aCreateDataStruct->mode;
mCreateDataStruct.argc = aCreateDataStruct->argc;
mCreateDataStruct.argn = aCreateDataStruct->argn;
mCreateDataStruct.saved = aCreateDataStruct->saved;
+
+ mCreateDataStruct.instance->pdata = this;
+ mInstance->pdata = this;
mString[0] = '\0';
}

@@ -256,19 +262,27 @@
PRBool
*outResult)
{
nsresult rv = NS_ERROR_FAILURE;
-
- nsCOMPtr<nsIPlugin> plugletEngine =
- do_GetService(PLUGLETENGINE_ContractID, &rv);
*outResult = PR_FALSE;
+ nsCOMPtr<nsIPlugin> plugletEngine = nsnull;
nsIID scriptableIID = NS_ISIMPLEPLUGIN_IID;
+
+ if (!mPluglet) {
+ plugletEngine = do_GetService(PLUGLETENGINE_ContractID, &rv);

- if (NS_SUCCEEDED(rv)) {
- rv = plugletEngine->CreatePluginInstance(nsnull,
scriptableIID,
- aMimeType,
-
getter_AddRefs(mPluglet));
- if (NS_SUCCEEDED(rv) && mPluglet) {
+ if (NS_SUCCEEDED(rv)) {
+ rv = plugletEngine->CreatePluginInstance(nsnull,
scriptableIID,
+ aMimeType,
+
getter_AddRefs(mPluglet));
+ if (NS_SUCCEEDED(rv) && mPluglet) {
+ *outResult = PR_TRUE;
+ }
+ }
+ }
+ else {
+ if (0 == PL_strcmp(aMimeType, mCreateDataStruct.type)) {
*outResult = PR_TRUE;
}
+ rv = NS_OK;
}

return rv;
Index: mozilla/nsISimplePlugin.idl
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/mozilla/nsISimplePlugin.idl,v
retrieving revision 1.2
diff -u -r1.2 nsISimplePlugin.idl
--- mozilla/nsISimplePlugin.idl 12 Oct 2006 21:22:47 -0000 1.2
+++ mozilla/nsISimplePlugin.idl 14 Oct 2006 12:26:07 -0000
@@ -40,5 +40,5 @@

[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
interface nsISimplePlugin : nsISupports {
- void hasPlugletForMimeType(in string aMimeType, out boolean
isSupported);
+ boolean hasPlugletForMimeType(in string aMimeType);
};
Index: src/PlugletsDir.cpp
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/src/PlugletsDir.cpp,v
retrieving revision 1.10
diff -u -r1.10 PlugletsDir.cpp
--- src/PlugletsDir.cpp 12 Oct 2006 21:22:47 -0000 1.10
+++ src/PlugletsDir.cpp 14 Oct 2006 12:26:07 -0000
@@ -124,6 +124,9 @@
if(!mMimeTypeToPlugletFacoryHash) {
res = LoadPluglets();
}
+ else {
+ res = NS_OK;
+ }
if (NS_SUCCEEDED(res) && mMimeTypeToPlugletFacoryHash) {
*plugletFactory = (PlugletFactory *)
PL_HashTableLookup(mMimeTypeToPlugletFacoryHash,

edburns

unread,
Oct 16, 2006, 9:55:44 AM10/16/06
to
I'm happy to report that on win32 I am able to display the simple
pluglet. Next step is to get the streams working so the mediaplayer
pluglet works.

Ed

edburns

unread,
Oct 23, 2006, 1:00:31 AM10/23/06
to

I have the basic media player working, with sound too. However, the
only reason the stream works is that the design of the MediaPlayer
pluglet simply gets the URL of the media file from the OnStartRequest
callback, which it then fetches directly rather than using the stream
APIs to get the data. This is inefficient and not a general purpose
solution. The next step will be to implement the general stream APIs
all the way.

Ed

edburns

unread,
Oct 26, 2006, 12:23:11 AM10/26/06
to
True streaming works, but I still don't have the File streaming
working.

I'm getting an intermittent bug on pluglin unload, so fixing that will
be the next step.

SECTION: Changes

A mozilla/npAPInsIInputStreamShim.cpp
A mozilla/npAPInsIInputStreamShim.h

- Shim to allow the np4xplugin API to call pass stream data to pluglet

M mozilla/Makefile.in

- Add the shim to the source files

M mozilla/nppluglet.cpp

- implement the layer that calls the shim

M test/test.html

- Pass the plugin a src of its .java file.

M test/test.java

- additional debug printout info

SECTION: Diffs

Index: mozilla/Makefile.in
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/mozilla/Makefile.in,v

retrieving revision 1.2
diff -u -r1.2 Makefile.in
--- mozilla/Makefile.in 14 Oct 2006 12:28:14 -0000 1.2
+++ mozilla/Makefile.in 26 Oct 2006 04:16:08 -0000
@@ -55,6 +55,7 @@

CPPSRCS = nsScriptablePeer.cpp \
nppluglet.cpp \
+ npAPInsIInputStreamShim.cpp \
$(NULL)

XPIDLSRCS = nsISimplePlugin.idl
@@ -89,4 +90,5 @@

LOCAL_INCLUDES = -I./$(XPIDL_GEN_DIR) \
-I$(PLUGIN_SDK)/samples/include \
+ -I$(PLUGIN_SDK)/../../base/src \
$(NULL)


Index: mozilla/nppluglet.cpp
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/mozilla/nppluglet.cpp,v

retrieving revision 1.5
diff -u -r1.5 nppluglet.cpp
--- mozilla/nppluglet.cpp 23 Oct 2006 05:18:19 -0000 1.5
+++ mozilla/nppluglet.cpp 26 Oct 2006 04:16:08 -0000
@@ -51,6 +51,8 @@

#include "plstr.h"

+#include "npAPInsIInputStreamShim.h"


+
// service manager which will give the access to all public browser
services
// we will use memory service as an illustration
nsIServiceManager * gServiceManager = NULL;

@@ -283,11 +285,10 @@
if (hostStreamInfo) {
rv = listener->OnStartBinding(hostStreamInfo);
if (NS_SUCCEEDED(rv)) {
- stream->pdata = (void *) listener.get();
- nsCOMPtr<nsISupports> toCast =
- do_QueryInterface(listener);
- nsISupports *toAddRef = (nsISupports *)
toCast.get();
- NS_ADDREF(toAddRef);
+ npAPInsIInputStreamShim *shim =
+ new npAPInsIInputStreamShim(listener,
+ hostStreamInfo);
+ stream->pdata = (void *) shim;
}
}
}
@@ -304,12 +305,9 @@
return rv;
}

- nsCOMPtr<nsIPluginStreamListener> listener =
- (nsIPluginStreamListener *) stream->pdata;
- nsCOMPtr<nsISupports> toCast = do_QueryInterface(listener);
- nsISupports *toRelease = (nsISupports *) toCast.get();
- NS_RELEASE(toRelease);
- listener = nsnull;
+ npAPInsIInputStreamShim *shim =
+ (npAPInsIInputStreamShim *) stream->pdata;
+ delete shim;
stream->pdata = nsnull;

return NS_OK;
@@ -324,8 +322,15 @@
int32 len, void *buffer)
{
int32 result = len;
- nsCOMPtr<nsIPluginStreamListener> listener =
- (nsIPluginStreamListener *) stream->pdata;
+ npAPInsIInputStreamShim *shim =
+ (npAPInsIInputStreamShim *) stream->pdata;
+ nsCOMPtr<nsIPluginStreamListener> listener = nsnull;
+ nsresult rv = NS_ERROR_NULL_POINTER;
+
+ rv = shim->AllowStreamToReadFromBuffer(len, buffer, &result);
+ if (NS_SUCCEEDED(rv)) {
+ printf("debug: edburns: passed %d bytes to pluglet\n",
result);
+ }

return result;
}
Index: test/test.html
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/test/test.html,v
retrieving revision 1.3
diff -u -r1.3 test.html
--- test/test.html 23 Dec 2001 23:21:35 -0000 1.3
+++ test/test.html 26 Oct 2006 04:16:08 -0000
@@ -1,5 +1,7 @@
<html>
+<head><title>TestPluglet that loads its source file</title><head>
<body>
-<EMBED type="application/x-simple-pluglet" name="test" width=400
height=200>
+<EMBED type="application/x-simple-pluglet" name="test"
+ src="test.java" width=400 height=200>
</body>
</html>
Index: test/test.java
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/test/test.java,v
retrieving revision 1.9
diff -u -r1.9 test.java
--- test/test.java 11 Dec 1999 00:08:00 -0000 1.9
+++ test/test.java 26 Oct 2006 04:16:08 -0000
@@ -185,6 +185,9 @@

org.mozilla.util.DebugPluglet.print("--TestStreamListener.onStartBinding
");
org.mozilla.util.DebugPluglet.print("length
"+streamInfo.getLength());
org.mozilla.util.DebugPluglet.print(" contenet type "+
streamInfo.getContentType());
+ org.mozilla.util.DebugPluglet.print(" url "+
streamInfo.getURL());
+ org.mozilla.util.DebugPluglet.print(" seekable "+
streamInfo.isSeekable());
+
}
/**
* Notify the client that data is available in the input stream.
This
@@ -199,12 +202,18 @@
try{

org.mozilla.util.DebugPluglet.print("--TestStreamListener.onDataAvailable
");
org.mozilla.util.DebugPluglet.print("--length
"+input.available()+"\n");
+ String cur = null;
+ BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(input));
+ while (null != (cur = bufferedReader.readLine())) {
+ org.mozilla.util.DebugPluglet.print(cur);
+ }
} catch(Exception e) {
;
}
}
public void onFileAvailable(PlugletStreamInfo plugletInfo, String
fileName) {

org.mozilla.util.DebugPluglet.print("--TestStreamListener.onFileAvailable\n");
+ org.mozilla.util.DebugPluglet.print(" fileName" + fileName);
}
/**
* Notify the observer that the URL has finished loading.

edburns

unread,
Nov 2, 2006, 1:59:22 PM11/2/06
to
This change-bundle fixes memory allocation in streams. Next step is to
make a final pass to make sure we are not leaking memory. After that,
I
want to clean up the build system, and the samples.

M build.xml

- Call make export in mozilla directory

- Fix clean target

M mozilla/Makefile.in

- Added export target
M classes/org/mozilla/pluglet/PlugletLoader.java

- avoid ambiguity by casting

+ CodeSource codesource = new
CodeSource(url,(java.security.cert.Certificate []) null);

M examples/MediaPlayer/JMPlayer.java

- remove debug printfs

M mozilla/npAPInsIInputStreamShim.cpp
M mozilla/npAPInsIInputStreamShim.h

- remove debug printfs

- fix buffer allocation, refactor into its own method.

- Use NPN_Mem* methods for memory allocation.

- isolate lock access to private methods. Avoids locking when we
already own the lock, which would cause an assertion.

M mozilla/nppluglet.cpp

- in dtor, check for null mScriptablePeer ivar before accessing it.

M mozilla/nsScriptablePeer.cpp

- whitespace

M src/Pluglet.cpp

- get the plugletEngine from do_GetService().

M src/PlugletEngine.cpp
M src/PlugletFactory.cpp
M src/PlugletLoader.cpp

- remove debug printfs

M test/test.java

- added test finalize.

edburns

unread,
Nov 9, 2006, 3:11:44 PM11/9/06
to

edburns wrote:
> This change-bundle fixes memory allocation in streams. Next step is to
> make a final pass to make sure we are not leaking memory.

Memory audit of code in src directory. Found and fixed some leaks.
Declaring this directory memory clean.

M src/Pluglet.cpp
M src/Pluglet.h

- use do_GetService instead of servman->GetServiceByContractID

- do not keep a reference to plugletEngine as an ivar

M src/PlugletFactory.cpp
M src/PlugletFactory.h

- use nsnull instead of NULL

- do not keep a reference to plugletEngine as an ivar

- use PL_strdup and PL_strfree to duplicate and free strings

M src/PlugletsDir.cpp

- use PL_strdup and PL_strfree to duplicate and free strings

edburns

unread,
Nov 9, 2006, 3:19:17 PM11/9/06
to

edburns wrote:
> edburns wrote:
> > This change-bundle fixes memory allocation in streams. Next step is to
> > make a final pass to make sure we are not leaking memory.
>
> Memory audit of code in src directory. Found and fixed some leaks.
> Declaring this directory memory clean

Next step is to audit the plugins/mozilla directory. Following that I
will clean up the build system.

Ed

edburns

unread,
Nov 14, 2006, 8:16:18 PM11/14/06
to
Add new first argument to PlugletFactory.initialize(): the string that
is the path to the jar from which the pluglet is loaded.

SECTION: Changes

M classes/org/mozilla/pluglet/PlugletFactory.java
M classes/org/mozilla/pluglet/PlugletFactoryAdaptor.java

- Add new first argument to PlugletFactory.initialize(): the string
that
is the path to the jar from which the pluglet is loaded.

M examples/MediaPlayer/JMPlayer.java
M test/test.java

- Account for new first argument

M src/PlugletFactory.cpp

- new JNI signature for initialize.

SECTION: Diffs

Index: classes/org/mozilla/pluglet/PlugletFactory.java
===================================================================
RCS file:
/cvsroot/mozilla/java/plugins/classes/org/mozilla/pluglet/PlugletFactory.java,v
retrieving revision 1.2
diff -u -r1.2 PlugletFactory.java
--- classes/org/mozilla/pluglet/PlugletFactory.java 13 Jan 2000
22:54:42 -0000 1.2
+++ classes/org/mozilla/pluglet/PlugletFactory.java 15 Nov 2006
01:05:36 -0000
@@ -56,7 +56,7 @@
* @param manager This is an instance of
<code>PlugletManager</code> that is passed
* to this method.
*/
- public void initialize(PlugletManager manager);
+ public void initialize(String plugletJarFileName, PlugletManager
manager);
/**
* Called when the browser is done with a
<code>PlugletFactory</code> instance. Normally
* there is only one <code>PlugletFactory</code> instance.
Index: classes/org/mozilla/pluglet/PlugletFactoryAdaptor.java
===================================================================
RCS file:
/cvsroot/mozilla/java/plugins/classes/org/mozilla/pluglet/PlugletFactoryAdaptor.java,v
retrieving revision 1.1
diff -u -r1.1 PlugletFactoryAdaptor.java
--- classes/org/mozilla/pluglet/PlugletFactoryAdaptor.java 24 May 2000
02:01:56 -0000 1.1
+++ classes/org/mozilla/pluglet/PlugletFactoryAdaptor.java 15 Nov 2006
01:05:36 -0000
@@ -26,7 +26,7 @@
public Pluglet createPluglet(String mimeType) {
return null;
}
- public void initialize(PlugletManager manager) {
+ public void initialize(String plugletPath, PlugletManager manager)
{
}
public void shutdown() {
}
Index: examples/MediaPlayer/JMPlayer.java
===================================================================
RCS file:
/cvsroot/mozilla/java/plugins/examples/MediaPlayer/JMPlayer.java,v
retrieving revision 1.6
diff -u -r1.6 JMPlayer.java
--- examples/MediaPlayer/JMPlayer.java 2 Nov 2006 18:55:50 -0000 1.6
+++ examples/MediaPlayer/JMPlayer.java 15 Nov 2006 01:05:36 -0000
@@ -27,7 +27,7 @@
}
return player;
}
- public void initialize(PlugletManager manager) {
+ public void initialize(String plugletPath, PlugletManager manager)
{
}
public void shutdown() {
}
Index: src/PlugletFactory.cpp
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/src/PlugletFactory.cpp,v
retrieving revision 1.9
diff -u -r1.9 PlugletFactory.cpp
--- src/PlugletFactory.cpp 9 Nov 2006 20:10:17 -0000 1.9
+++ src/PlugletFactory.cpp 15 Nov 2006 01:05:36 -0000
@@ -99,7 +99,8 @@
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
}
- initializeMID =
env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
+ initializeMID = env->GetMethodID(clazz,"initialize",
+
"(Ljava/lang/String;Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
if (!initializeMID) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;
@@ -116,7 +117,9 @@
if (NS_FAILED(rv)) {
return rv;
}
- env->CallVoidMethod(jthis,initializeMID,plugletEngineObj);
+ jstring jpath = env->NewStringUTF(path);
+ env->CallVoidMethod(jthis,initializeMID, jpath, plugletEngineObj);
+ env->ReleaseStringUTFChars(jpath, path);
if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
return NS_ERROR_FAILURE;


Index: test/test.java
===================================================================
RCS file: /cvsroot/mozilla/java/plugins/test/test.java,v

retrieving revision 1.11
diff -u -r1.11 test.java
--- test/test.java 2 Nov 2006 18:55:50 -0000 1.11
+++ test/test.java 15 Nov 2006 01:05:36 -0000
@@ -42,8 +42,9 @@
* Initializes the pluglet and will be called before any new
instances are
* created.
*/
- public void initialize(PlugletManager manager) {
- org.mozilla.util.DebugPluglet.print("--test.initialize\n");
+ public void initialize(String plugletPath, PlugletManager manager)
{
+ org.mozilla.util.DebugPluglet.print("--test.initialize(" +
+ plugletPath + ")\n");
}
/**
* Called when the browser is done with the pluglet factory, or
when

edburns

unread,
Nov 22, 2006, 10:16:58 PM11/22/06
to
Hello, I have added sketchy instructions and cobbled together binary a
distribution that works only on Firefox 1.5.0.1 on Win32.

You can read about it at
<http://purl.oclc.org/NET/edburns/plugletStatus/>.

Please post here if you have trouble running it, but this is by no
means supported.

Ed

0 new messages