mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Initial pluglets checkin.
This commit is contained in:
parent
7514e48dfd
commit
767abe9d28
61
java/plugins/README
Normal file
61
java/plugins/README
Normal file
@ -0,0 +1,61 @@
|
||||
Java-Implemented Plug-ins.
|
||||
================================
|
||||
|
||||
This directory contains the beginnings of the Java-Implemented plug-uns.
|
||||
|
||||
The sources is divided into four directories
|
||||
|
||||
classes
|
||||
Java source files
|
||||
src
|
||||
Native code (c++/c)
|
||||
jni
|
||||
Implamentations of java native methods
|
||||
test
|
||||
Test code, including simple pluglet.
|
||||
|
||||
========================================================================
|
||||
Win32 Build Directions:
|
||||
========================================================================
|
||||
Requirements:
|
||||
|
||||
* built M8 mozilla tree for WinNT4.0
|
||||
|
||||
* JDK1.2 or greater
|
||||
|
||||
* Perl 5 perl.exe must be in your path
|
||||
|
||||
How To Build:
|
||||
|
||||
* Follow the directions in ..\README
|
||||
|
||||
* type "nmake /f makefile.win"
|
||||
|
||||
* apply the patch to mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp
|
||||
by executing : patch nsPluginHostImpl.cpp < nsPluginHostImpl.patch
|
||||
and execute "nmake /f makefile.win" inside mozilla/modules/plugin/nglsrc
|
||||
directory
|
||||
|
||||
|
||||
How to Run:
|
||||
|
||||
* Add following directories to to your path:
|
||||
%MOZILLA_FIVE_HOME%, %JDKHOME%\jre\bin\classic
|
||||
|
||||
How to build and run test
|
||||
* go to the test directory and type "nmake /f makefile.win"
|
||||
|
||||
* Set PLUGLET environment to the directory you have test.jar
|
||||
|
||||
* Run appletviewer and load page test.html from test directory and if evething is ok you will see
|
||||
some output from the test pluglet on the stdout.
|
||||
|
||||
Problems:
|
||||
|
||||
* clobber_all doesn't remove the .class files from dist\classes. You
|
||||
have to do this manually.
|
||||
|
||||
* post to netscape.public.mozilla.java newsgroup
|
||||
|
||||
|
||||
|
27
java/plugins/classes/makefile.win
Normal file
27
java/plugins/classes/makefile.win
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH = ..\..\..
|
||||
|
||||
DIRS = org\mozilla\util org\mozilla\pluglet org\mozilla\pluglet\mozilla
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
42
java/plugins/classes/org/mozilla/pluglet/Pluglet.java
Normal file
42
java/plugins/classes/org/mozilla/pluglet/Pluglet.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
|
||||
import org.mozilla.pluglet.mozilla.*;
|
||||
|
||||
public interface Pluglet {
|
||||
/**
|
||||
* Creates a new pluglet instance, based on a MIME type. This
|
||||
* allows different impelementations to be created depending on
|
||||
* the specified MIME type.
|
||||
*/
|
||||
public PlugletInstance createPlugletInstance(String mimeType);
|
||||
/**
|
||||
* Initializes the pluglet and will be called before any new instances are
|
||||
* created.
|
||||
*/
|
||||
public void initialize(PlugletManager manager);
|
||||
/**
|
||||
* Called when the browser is done with the pluglet factory, or when
|
||||
* the pluglet is disabled by the user.
|
||||
*/
|
||||
public void shutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
import org.mozilla.pluglet.mozilla.*;
|
||||
import java.awt.Panel;
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
public interface PlugletInstance {
|
||||
/**
|
||||
* Initializes a newly created pluglet instance, passing to it the pluglet
|
||||
* instance peer which it should use for all communication back to the browser.
|
||||
*
|
||||
* @param peer the corresponding pluglet instance peer
|
||||
*/
|
||||
void initialize(PlugletInstancePeer peer);
|
||||
/**
|
||||
* Called to instruct the pluglet instance to start. This will be called after
|
||||
* the pluglet is first created and initialized, and may be called after the
|
||||
* pluglet is stopped (via the Stop method) if the pluglet instance is returned
|
||||
* to in the browser window's history.
|
||||
*/
|
||||
void start();
|
||||
/**
|
||||
* Called to instruct the pluglet instance to stop, thereby suspending its state.
|
||||
* This method will be called whenever the browser window goes on to display
|
||||
* another page and the page containing the pluglet goes into the window's history
|
||||
* list.
|
||||
*/
|
||||
void stop();
|
||||
/**
|
||||
* Called to instruct the pluglet instance to destroy itself. This is called when
|
||||
* it become no longer possible to return to the pluglet instance, either because
|
||||
* the browser window's history list of pages is being trimmed, or because the
|
||||
* window containing this page in the history is being closed.
|
||||
*/
|
||||
void destroy();
|
||||
/**
|
||||
* Called to tell the pluglet that the initial src/data stream is
|
||||
* ready.
|
||||
*
|
||||
* @result PlugletStreamListener
|
||||
*/
|
||||
PlugletStreamListener newStream();
|
||||
/**
|
||||
* Called when the window containing the pluglet instance changes.
|
||||
*
|
||||
* @param frame the pluglet panel
|
||||
*/
|
||||
void setWindow(Panel frame);
|
||||
/**
|
||||
* Called to instruct the pluglet instance to print itself to a printer.
|
||||
*
|
||||
* @param print printer information.
|
||||
*/
|
||||
void print(PrinterJob printerJob);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
71
java/plugins/classes/org/mozilla/pluglet/PlugletLoader.java
Normal file
71
java/plugins/classes/org/mozilla/pluglet/PlugletLoader.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URL;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.jar.Attributes;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PlugletLoader {
|
||||
// path to jar file. Name of main class sould to be in MANIFEST.
|
||||
public static Pluglet getPluglet(String path) {
|
||||
try {
|
||||
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet("+path+")\n");
|
||||
URL url = new URL("file://"+path);
|
||||
URLClassLoader loader = URLClassLoader.newInstance(new URL[]{url});
|
||||
URL manifestURL = new URL("jar:file://"+path+"!/META-INF/MANIFEST.MF");
|
||||
InputStream inputStream = manifestURL.openStream();
|
||||
Manifest manifest = new Manifest(inputStream);
|
||||
Attributes attr = manifest.getMainAttributes();
|
||||
String plugletClassName = attr.getValue("Pluglet-Class");
|
||||
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet class name "+plugletClassName+"\n");
|
||||
org.mozilla.util.Debug.print("-- PL url[0] "+loader.getURLs()[0]);
|
||||
if (plugletClassName == null) {
|
||||
//nb
|
||||
return null;
|
||||
}
|
||||
Object pluglet = loader.loadClass(plugletClassName).newInstance();
|
||||
if (pluglet instanceof Pluglet) {
|
||||
return (Pluglet) pluglet;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
org.mozilla.util.Debug.print("-- PlugletLoader.getPluglet exc "+e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMIMEDescription(String path) {
|
||||
try {
|
||||
org.mozilla.util.Debug.print("-- PlugletLoader.getMIMEDescription("+path+")\n");
|
||||
URL manifestURL = new URL("jar:file://"+path+"!/META-INF/MANIFEST.MF");
|
||||
InputStream inputStream = manifestURL.openStream();
|
||||
Manifest manifest = new Manifest(inputStream);
|
||||
Attributes attr = manifest.getMainAttributes();
|
||||
String mimeDescription = attr.getValue("MIMEDescription");
|
||||
org.mozilla.util.Debug.print("-- PlugletLoader.getMIMEDescription desc "+mimeDescription+"\n");
|
||||
return mimeDescription;
|
||||
} catch (Exception e) {
|
||||
org.mozilla.util.Debug.print(e+"\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
|
||||
import java.io.InputStream;
|
||||
import org.mozilla.pluglet.mozilla.*;
|
||||
public interface PlugletStreamListener {
|
||||
// matches values in modules/plugin/public/plugindefs.h
|
||||
public static final int STREAM_TYPE_NORMAL = 1;
|
||||
public static final int STREAM_TYPE_SEEK = 2;
|
||||
public static final int STREAM_TYPE_AS_FILE = 3;
|
||||
public static final int STREAM_TYPE_AS_FILE_ONLY = 4;
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*/
|
||||
void onStartBinding(PlugletStreamInfo plugletInfo);
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param input The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
*/
|
||||
void onDataAvailable(PlugletStreamInfo plugletInfo, InputStream input,int length);
|
||||
void onFileAvailable(PlugletStreamInfo plugletInfo, String fileName);
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading.
|
||||
*/
|
||||
void onStopBinding(PlugletStreamInfo plugletInfo,int status);
|
||||
int getStreamType();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
37
java/plugins/classes/org/mozilla/pluglet/makefile.win
Normal file
37
java/plugins/classes/org/mozilla/pluglet/makefile.win
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..\..\..\..
|
||||
|
||||
# PENDING(edburns): find out where this should really get defined
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# for compatibility
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
JDIRS = .
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVA_SOURCEPATH=$(JAVA_SOURCEPATH)$(PATH_SEPARATOR)$(DEPTH)\java\plugins\classes
|
||||
include <$(DEPTH)\config\rules.mak>
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet.mozilla;
|
||||
import java.io.OutputStream;
|
||||
|
||||
|
||||
public interface PlugletInstancePeer {
|
||||
public static final int NETSCAPE_WINDOW = 3;
|
||||
/**
|
||||
* Returns the MIME type of the pluglet instance.
|
||||
*/
|
||||
public String getMIMEType();
|
||||
/**
|
||||
* Returns the mode of the pluglet instance, i.e. whether the pluglet
|
||||
* is embedded in the html, or full page.
|
||||
*/
|
||||
public int getMode();
|
||||
/**
|
||||
* Returns the value of a variable associated with the pluglet manager.
|
||||
* @param variable the pluglet manager variable to get
|
||||
*/
|
||||
public String getValue(int variable);
|
||||
/**
|
||||
* This operation is called by the pluglet instance when it wishes to send a stream of data to the browser. It constructs a
|
||||
* new output stream to which the pluglet may send the data. When complete, the Close and Release methods should be
|
||||
* called on the output stream.
|
||||
* @param type type MIME type of the stream to create
|
||||
* @param target the target window name to receive the data
|
||||
*/
|
||||
public OutputStream newStream(String type, String target);
|
||||
/** This operation causes status information to be displayed on the window associated with the pluglet instance.
|
||||
* @param message the status message to display
|
||||
*/
|
||||
public void showStatus(String message);
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet.mozilla;
|
||||
import org.mozilla.pluglet.*;
|
||||
import java.net.URL;
|
||||
public interface PlugletManager {
|
||||
public static final int APPCONTEXT = 2;
|
||||
public static final int DISPLAY = 1;
|
||||
/**
|
||||
* Returns the value of a variable associated with the pluglet manager.
|
||||
*
|
||||
* @param variable the pluglet manager variable to get
|
||||
*/
|
||||
public String getValue(int variable);
|
||||
|
||||
/**
|
||||
* Causes the pluglets directory to be searched again for new pluglet
|
||||
* libraries.
|
||||
*
|
||||
* @param reloadPages indicates whether currently visible pages should
|
||||
* also be reloaded
|
||||
*/
|
||||
public void reloadPluglets(boolean reloadPages);
|
||||
|
||||
/**
|
||||
* Returns the user agent string for the browser.
|
||||
*
|
||||
*/
|
||||
public String userAgent();
|
||||
/**
|
||||
* Fetches a URL.
|
||||
* @param plugletInst the pluglet making the request.
|
||||
* If null, the URL is fetched in the background.
|
||||
* @param url the URL to fetch
|
||||
* @param target the target window into which to load the URL
|
||||
* @param notifyData when present, URLNotify is called passing the
|
||||
* notifyData back to the client.
|
||||
* @param altHost an IP-address string that will be used instead of
|
||||
* the host specified in the URL. This is used to
|
||||
* @param prevent DNS-spoofing attacks. Can be defaulted to null
|
||||
* meaning use the host in the URL.
|
||||
* @param referrer the referring URL (may be null)
|
||||
* @param forceJSEnabled forces JavaScript to be enabled for
|
||||
* 'javascript:' URLs, even if the user currently has JavaScript
|
||||
* disabled (usually specify false)
|
||||
*/
|
||||
public void getURL(PlugletInstance plugletInst,
|
||||
URL url, String target,
|
||||
PlugletStreamListener streamListener,
|
||||
String altHost, URL referrer,
|
||||
boolean forceJSEnabled);
|
||||
/**
|
||||
* Posts to a URL with post data and/or post headers.
|
||||
*
|
||||
* @param plugletInst the pluglet making the request. If null, the URL
|
||||
* is fetched in the background.
|
||||
* @param url the URL to fetch
|
||||
* @param target the target window into which to load the URL
|
||||
* @param postDataLength the length of postData (if non-null)
|
||||
* @param postData the data to POST. null specifies that there is not post
|
||||
* data
|
||||
* @param isFile whether the postData specifies the name of a file to
|
||||
* post instead of data. The file will be deleted afterwards.
|
||||
* @param notifyData when present, URLNotify is called passing the
|
||||
* notifyData back to the client.
|
||||
* @param altHost n 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.
|
||||
* @param referrer the referring URL (may be null)
|
||||
* @param forceJSEnabled forces JavaScript to be enabled for 'javascript:'
|
||||
* URLs, even if the user currently has JavaScript disabled (usually
|
||||
* specify false)
|
||||
* @param postHeadersLength the length of postHeaders (if non-null)
|
||||
* @param postHeaders the headers to POST. null specifies that there
|
||||
* are no post headers
|
||||
*/
|
||||
|
||||
public void postURL(PlugletInstance plugletInst,
|
||||
URL url,
|
||||
int postDataLen,
|
||||
byte[] postData,
|
||||
boolean isFile,
|
||||
String target,
|
||||
PlugletStreamListener streamListener,
|
||||
String altHost,
|
||||
URL referrer,
|
||||
boolean forceJSEnabled,
|
||||
int postHeadersLength,
|
||||
byte[] postHeaders);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet.mozilla;
|
||||
import java.net.URL;
|
||||
public interface PlugletManager2 extends PlugletManager {
|
||||
/**
|
||||
* Puts up a wait cursor.
|
||||
*/
|
||||
public void beginWaitCursor();
|
||||
/**
|
||||
* Restores the previous (non-wait) cursor.
|
||||
*/
|
||||
public void endWaitCursor();
|
||||
/**
|
||||
* Returns true if a URL protocol (e.g. "http") is supported.
|
||||
*
|
||||
* @param protocol the protocol name
|
||||
*/
|
||||
public boolean supportsURLProtocol(String protocol);
|
||||
/**
|
||||
* Returns the proxy info for a given URL. The result will be in the
|
||||
* following format
|
||||
*
|
||||
* i) "DIRECT" -- no proxy
|
||||
* ii) "PROXY xxx.xxx.xxx.xxx" -- use proxy
|
||||
* iii) "SOCKS xxx.xxx.xxx.xxx" -- use SOCKS
|
||||
* iv) Mixed. e.g. "PROXY 111.111.111.111;PROXY 112.112.112.112",
|
||||
* "PROXY 111.111.111.111;SOCKS 112.112.112.112"....
|
||||
*
|
||||
* Which proxy/SOCKS to use is determined by the plugin.
|
||||
*/
|
||||
public String findProxyForURL(URL url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet.mozilla;
|
||||
|
||||
public interface PlugletStreamInfo {
|
||||
/**
|
||||
* Returns the MIME type.
|
||||
*/
|
||||
public String getContentType();
|
||||
public boolean isSeekable();
|
||||
/**
|
||||
* Returns the number of bytes that can be read from this input stream
|
||||
*/
|
||||
public int getLength();
|
||||
public int getLastModified();
|
||||
public String getURL();
|
||||
/**
|
||||
* Request reading from input stream
|
||||
*/
|
||||
public void requestRead(ByteRanges ranges );
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..\..\..\..\..
|
||||
|
||||
# PENDING(edburns): find out where this should really get defined
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# for compatibility
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
JDIRS = .
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
JAVA_SOURCEPATH=$(JAVA_SOURCEPATH)$(PATH_SEPARATOR)$(DEPTH)\java\plugins\classes
|
||||
include <$(DEPTH)\config\rules.mak>
|
24
java/plugins/classes/org/mozilla/util/Debug.java
Normal file
24
java/plugins/classes/org/mozilla/util/Debug.java
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.util;
|
||||
|
||||
public class Debug {
|
||||
public static native void print(String str);
|
||||
static {
|
||||
System.loadLibrary("plugletjni");
|
||||
}
|
||||
}
|
||||
|
39
java/plugins/classes/org/mozilla/util/makefile.win
Normal file
39
java/plugins/classes/org/mozilla/util/makefile.win
Normal file
@ -0,0 +1,39 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH= ..\..\..\..\..\..
|
||||
|
||||
# PENDING(edburns): find out where this should really get defined
|
||||
JAVA_OR_NSJVM=1
|
||||
NO_CAFE=1
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
# for compatibility
|
||||
include <$(DEPTH)\java\config\localdefs.mak>
|
||||
|
||||
JDIRS = .
|
||||
|
||||
JAVAC_PROG=$(JDKHOME)\bin\javac
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
JAVA_CLASSPATH=$(JAVA_CLASSPATH)$(PATH_SEPARATOR)$(DEPTH)\java\plugins\classes\
|
||||
|
60
java/plugins/jni/makefile.win
Normal file
60
java/plugins/jni/makefile.win
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
MODULE = plugletjni
|
||||
|
||||
LIBRARY_NAME = plugletjni
|
||||
|
||||
DEPTH= ..\..\..
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\org_mozilla_util_Debug.obj
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DLLNAME=plugletjni
|
||||
|
||||
DLL = .\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\
|
||||
|
||||
|
||||
|
32
java/plugins/jni/org_mozilla_util_Debug.cpp
Normal file
32
java/plugins/jni/org_mozilla_util_Debug.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "org_mozilla_util_Debug.h"
|
||||
/*
|
||||
* Class: org_mozilla_util_Debug
|
||||
* Method: print
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_util_Debug_print
|
||||
(JNIEnv *env, jclass, jstring jval) {
|
||||
jboolean iscopy = JNI_FALSE;
|
||||
const char* cvalue = env->GetStringUTFChars(jval, &iscopy);
|
||||
printf("%s",cvalue);
|
||||
if (iscopy == JNI_TRUE) {
|
||||
env->ReleaseStringUTFChars(jval, cvalue);
|
||||
}
|
||||
}
|
||||
|
||||
|
36
java/plugins/jni/org_mozilla_util_Debug.h
Normal file
36
java/plugins/jni/org_mozilla_util_Debug.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_mozilla_util_Debug */
|
||||
|
||||
#ifndef _Included_org_mozilla_util_Debug
|
||||
#define _Included_org_mozilla_util_Debug
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_mozilla_util_Debug
|
||||
* Method: print
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_util_Debug_print
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
27
java/plugins/makefile.win
Normal file
27
java/plugins/makefile.win
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Specify the depth of the current directory relative to the
|
||||
#// root of NS
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DEPTH = ..\..
|
||||
|
||||
DIRS = src jni classes
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
9
java/plugins/nsPluginHostImpl.patch
Normal file
9
java/plugins/nsPluginHostImpl.patch
Normal file
@ -0,0 +1,9 @@
|
||||
Index: nsPluginHostImpl.cpp
|
||||
===================================================================
|
||||
RCS file: /cvsroot/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp,v
|
||||
retrieving revision 1.73
|
||||
diff -r1.73 nsPluginHostImpl.cpp
|
||||
1867a1868,1870
|
||||
> if (NS_FAILED(result)) {
|
||||
> result = plugin->CreatePluginInstance(NULL, kIPluginInstanceIID,mimeType, (void **)&instance);
|
||||
> }
|
145
java/plugins/src/Pluglet.cpp
Normal file
145
java/plugins/src/Pluglet.cpp
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "Pluglet.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "PlugletLoader.h"
|
||||
#include "PlugletInstance.h"
|
||||
#include "string.h"
|
||||
|
||||
jmethodID Pluglet::createPlugletInstanceMID = NULL;
|
||||
jmethodID Pluglet::initializeMID = NULL;
|
||||
jmethodID Pluglet::shutdownMID = NULL;
|
||||
|
||||
|
||||
nsresult Pluglet::CreatePluginInstance(const char* aPluginMIMEType, void **aResult) {
|
||||
if(!aResult
|
||||
|| Initialize() != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
jstring jstr = env->NewStringUTF(aPluginMIMEType);
|
||||
jobject obj = env->CallObjectMethod(jthis,createPlugletInstanceMID, jstr);
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*aResult = new PlugletInstance(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::Initialize(void) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!initializeMID) {
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/Pluglet");
|
||||
if(!clazz) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
createPlugletInstanceMID = env->GetMethodID(clazz,"createPlugletInstance","(Ljava/lang/String;)Lorg/mozilla/pluglet/PlugletInstance;");
|
||||
if (!createPlugletInstanceMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
shutdownMID = env->GetMethodID(clazz,"shutdown","()V");
|
||||
if (!shutdownMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
|
||||
if (!initializeMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
if (!jthis) {
|
||||
jthis = PlugletLoader::GetPluglet(path);
|
||||
if (!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,initializeMID,PlugletEngine::GetPlugletManager());
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::Shutdown(void) {
|
||||
|
||||
if(!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,shutdownMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::GetMIMEDescription(const char* *result) {
|
||||
if(!result) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*result = mimeDescription;
|
||||
return (*result) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
Pluglet::Pluglet(const char *mimeDescription, const char *path) {
|
||||
jthis = NULL;
|
||||
this->path = new char[strlen(path)+1];
|
||||
strcpy(this->path,path);
|
||||
this->mimeDescription = new char[strlen(mimeDescription)+1];
|
||||
strcpy(this->mimeDescription,mimeDescription);
|
||||
}
|
||||
|
||||
Pluglet::~Pluglet(void) {
|
||||
delete[] path;
|
||||
delete[] mimeDescription;
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
env->DeleteGlobalRef(jthis);
|
||||
}
|
||||
|
||||
Pluglet * Pluglet::Load(const char * path) {
|
||||
char * mime = PlugletLoader::GetMIMEDescription(path);
|
||||
Pluglet * result = NULL;
|
||||
if (mime) {
|
||||
result = new Pluglet(mime,path);
|
||||
//delete[] mime; //nb we have a strange exception here
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int Pluglet::Compare(const char *mimeType) {
|
||||
return 1; //nb urgent
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
42
java/plugins/src/Pluglet.h
Normal file
42
java/plugins/src/Pluglet.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __Pluglet_h__
|
||||
#define __Pluglet_h__
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
|
||||
class Pluglet {
|
||||
public:
|
||||
nsresult CreatePluginInstance(const char* aPluginMIMEType, void **aResult);
|
||||
nsresult Initialize(void);
|
||||
nsresult Shutdown(void);
|
||||
nsresult GetMIMEDescription(const char* *result);
|
||||
/*****************************************/
|
||||
~Pluglet(void);
|
||||
int Compare(const char * mimeType);
|
||||
static Pluglet * Load(const char * path);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID createPlugletInstanceMID;
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID shutdownMID;
|
||||
/*****************************************/
|
||||
char *mimeDescription;
|
||||
char *path;
|
||||
Pluglet(const char *mimeDescription,const char * path);
|
||||
};
|
||||
|
||||
#endif /* __Pluglet_h__ */
|
257
java/plugins/src/PlugletEngine.cpp
Normal file
257
java/plugins/src/PlugletEngine.cpp
Normal file
@ -0,0 +1,257 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "PlugletEngine.h"
|
||||
#include "Pluglet.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "prenv.h"
|
||||
|
||||
static NS_DEFINE_IID(kIPluginIID,NS_IPLUGIN_IID);
|
||||
static NS_DEFINE_CID(kPluginCID,NS_PLUGIN_CID);
|
||||
static NS_DEFINE_IID(kIServiceManagerIID, NS_ISERVICEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIJVMManagerIID,NS_IJVMMANAGER_IID);
|
||||
static NS_DEFINE_CID(kJVMManagerCID,NS_JVMMANAGER_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
#define PLUGIN_MIME_DESCRIPTION "*:*:Pluglet Engine"
|
||||
|
||||
//nsJVMManager * PlugletEngine::jvmManager = NULL;
|
||||
int PlugletEngine::objectCount = 0;
|
||||
PlugletsDir * PlugletEngine::dir = NULL;
|
||||
PRInt32 PlugletEngine::lockCount = 0;
|
||||
PlugletEngine * PlugletEngine::engine = NULL;
|
||||
NS_IMPL_ISUPPORTS(PlugletEngine,kIPluginIID);
|
||||
NS_METHOD PlugletEngine::Initialize(void) {
|
||||
//nb ???
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::Shutdown(void) {
|
||||
//nb ???
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID aIID, void **aResult) {
|
||||
return NS_ERROR_FAILURE; //nb to do
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
|
||||
const char* aPluginMIMEType, void **aResult) {
|
||||
if (!aResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
Pluglet * pluglet = NULL;
|
||||
nsresult res = NS_ERROR_NULL_POINTER;
|
||||
if ((res = dir->GetPluglet(aPluginMIMEType,&pluglet)) != NS_OK
|
||||
|| !pluglet) {
|
||||
return res;
|
||||
}
|
||||
//we do not delete pluglet because we do not allocate new memory in dir->GetPluglet()
|
||||
return pluglet->CreatePluginInstance(aPluginMIMEType,aResult);
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::GetMIMEDescription(const char* *result) {
|
||||
if (!result) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*result = PLUGIN_MIME_DESCRIPTION;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::GetValue(nsPluginVariable variable, void *value) {
|
||||
//nb ????
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::LockFactory(PRBool aLock) {
|
||||
if(aLock) {
|
||||
PR_AtomicIncrement(&lockCount);
|
||||
} else {
|
||||
PR_AtomicDecrement(&lockCount);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PlugletEngine::PlugletEngine(nsISupports* aService) {
|
||||
NS_INIT_REFCNT();
|
||||
dir = new PlugletsDir();
|
||||
nsresult res = NS_OK;
|
||||
#if 0
|
||||
nsIServiceManager *sm;
|
||||
res = aService->QueryInterface(nsIServiceManager::GetIID(),(void**)&sm);
|
||||
if (NS_FAILED(res)) {
|
||||
jvmManager = NULL;
|
||||
return;
|
||||
}
|
||||
res = sm->GetService(kJVMManagerCID,kIJVMManagerIID,(nsISupports**)&jvmManager);
|
||||
//nb
|
||||
if (NS_FAILED(res)) {
|
||||
jvmManager = NULL;
|
||||
}
|
||||
NS_RELEASE(sm);
|
||||
#endif
|
||||
engine = this;
|
||||
objectCount++;
|
||||
}
|
||||
|
||||
PlugletEngine::~PlugletEngine(void) {
|
||||
delete dir;
|
||||
objectCount--;
|
||||
}
|
||||
|
||||
//nb for debug only
|
||||
#ifndef PATH_SEPARATOR
|
||||
#define PATH_SEPARATOR ';'
|
||||
#endif
|
||||
|
||||
JavaVM *jvm = NULL;
|
||||
|
||||
static void StartJVM() {
|
||||
JNIEnv *env = NULL;
|
||||
jint res;
|
||||
JDK1_1InitArgs vm_args;
|
||||
char classpath[1024];
|
||||
vm_args.version = 0x00010001;
|
||||
JNI_GetDefaultJavaVMInitArgs(&vm_args);
|
||||
/* Append USER_CLASSPATH to the default system class path */
|
||||
//nb todo urgent
|
||||
|
||||
sprintf(classpath, "%s%c%s",
|
||||
vm_args.classpath, PATH_SEPARATOR, PR_GetEnv("CLASSPATH"));
|
||||
printf("-- classpath %s\n",classpath);
|
||||
vm_args.classpath = classpath;
|
||||
/* Create the Java VM */
|
||||
res = JNI_CreateJavaVM(&jvm, &env, &vm_args);
|
||||
}
|
||||
|
||||
JNIEnv * PlugletEngine::GetJNIEnv(void) {
|
||||
JNIEnv * res;
|
||||
#if 0
|
||||
if (!jvmManager) {
|
||||
//nb it is bad :(
|
||||
return NULL;
|
||||
}
|
||||
jvmManager->CreateProxyJNI(NULL,&res);
|
||||
//nb error handling
|
||||
#endif
|
||||
//#if 0
|
||||
if (!jvm) {
|
||||
printf(":) starting jvm\n");
|
||||
StartJVM();
|
||||
}
|
||||
jvm->AttachCurrentThread(&res,NULL);
|
||||
//#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
jobject PlugletEngine::GetPlugletManager(void) {
|
||||
//nb todo urgent
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PlugletEngine * PlugletEngine::GetEngine(void) {
|
||||
return engine;
|
||||
}
|
||||
void PlugletEngine::IncObjectCount(void) {
|
||||
objectCount++;
|
||||
}
|
||||
|
||||
void PlugletEngine::DecObjectCount(void) {
|
||||
objectCount--;
|
||||
}
|
||||
|
||||
PRBool PlugletEngine::IsUnloadable(void) {
|
||||
return (lockCount == 0
|
||||
&& objectCount == 0);
|
||||
}
|
||||
|
||||
// ******************************************
|
||||
extern "C" NS_EXPORT nsresult
|
||||
NSGetFactory(nsISupports* serviceMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (aClass.Equals(kPluginCID)) {
|
||||
if (PlugletEngine::GetEngine()) {
|
||||
*aFactory = PlugletEngine::GetEngine();
|
||||
return NS_OK;
|
||||
}
|
||||
PlugletEngine * engine = new PlugletEngine(serviceMgr);
|
||||
if (!engine)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
engine->AddRef();
|
||||
*aFactory = engine;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(nsISupports* serviceMgr)
|
||||
{
|
||||
return (PlugletEngine::IsUnloadable());
|
||||
}
|
||||
|
||||
|
||||
extern "C" char*
|
||||
NP_GetMIMEDescription(void)
|
||||
{
|
||||
return PLUGIN_MIME_DESCRIPTION;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
24
java/plugins/src/PlugletEngine.def
Normal file
24
java/plugins/src/PlugletEngine.def
Normal file
@ -0,0 +1,24 @@
|
||||
; -*- 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.
|
||||
|
||||
LIBRARY nppluglet
|
||||
|
||||
CODE PRELOAD MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD SINGLE
|
||||
|
||||
EXPORTS
|
||||
NSGetFactory @1
|
53
java/plugins/src/PlugletEngine.h
Normal file
53
java/plugins/src/PlugletEngine.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletEngine_h__
|
||||
#define __PlugletEngine_h__
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
#include "nsJVMManager.h"
|
||||
#include "PlugletsDir.h"
|
||||
|
||||
class PlugletEngine : public nsIPlugin {
|
||||
public:
|
||||
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
|
||||
const char* aPluginMIMEType,
|
||||
void **aResult);
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, const nsIID & iid, void * *_retval);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
NS_IMETHOD Initialize(void);
|
||||
NS_IMETHOD Shutdown(void);
|
||||
NS_IMETHOD GetMIMEDescription(const char* *result);
|
||||
NS_IMETHOD GetValue(nsPluginVariable variable, void *value);
|
||||
NS_DECL_ISUPPORTS
|
||||
PlugletEngine(nsISupports* aService);
|
||||
virtual ~PlugletEngine(void);
|
||||
static JNIEnv * GetJNIEnv(void);
|
||||
static jobject GetPlugletManager(void);
|
||||
static void IncObjectCount(void);
|
||||
static void DecObjectCount(void);
|
||||
static PRBool IsUnloadable(void);
|
||||
static PlugletEngine * GetEngine(void);
|
||||
private:
|
||||
static int objectCount;
|
||||
static PRInt32 lockCount;
|
||||
static PlugletsDir *dir;
|
||||
static PlugletEngine * engine;
|
||||
//nb static nsJVMManager * jvmManager;
|
||||
};
|
||||
|
||||
#endif /* __PlugletEngine_h__ */
|
||||
|
||||
|
125
java/plugins/src/PlugletEngine.rc
Normal file
125
java/plugins/src/PlugletEngine.rc
Normal file
@ -0,0 +1,125 @@
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_OLE_RESOURCES\r\n"
|
||||
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
|
||||
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
|
||||
"\r\n"
|
||||
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
|
||||
"#ifdef _WIN32\r\n"
|
||||
"LANGUAGE 9, 1\r\n"
|
||||
"#pragma code_page(1252)\r\n"
|
||||
"#endif\r\n"
|
||||
"#include ""res\\CharFlipper.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
|
||||
"#include ""afxres.rc"" // Standard components\r\n"
|
||||
"#endif\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifndef _MAC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,1
|
||||
PRODUCTVERSION 1,0,0,1
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "PlugletEngine\0"
|
||||
VALUE "FileExtents", "*\0"
|
||||
VALUE "FileOpenName", "Pluglet file (*.*)\0"
|
||||
VALUE "FileVersion", "1, 0, 0, 1\0"
|
||||
VALUE "InternalName", "PlugletEngine\0"
|
||||
VALUE "LegalCopyright", "Copyright © 1999\0"
|
||||
VALUE "MIMEType", "*\0"
|
||||
VALUE "OriginalFilename", "nppluglet.dll\0"
|
||||
VALUE "ProductName", "Pluglet Engine\0"
|
||||
VALUE "ProductVersion", "1, 0, 0, 1\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#endif // !_MAC
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
#define _AFX_NO_SPLITTER_RESOURCES
|
||||
#define _AFX_NO_OLE_RESOURCES
|
||||
#define _AFX_NO_TRACKER_RESOURCES
|
||||
#define _AFX_NO_PROPERTY_RESOURCES
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE 9, 1
|
||||
#pragma code_page(1252)
|
||||
#endif
|
||||
#include "afxres.rc" // Standard components
|
||||
#endif
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
119
java/plugins/src/PlugletInstance.cpp
Normal file
119
java/plugins/src/PlugletInstance.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "PlugletInstance.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "PlugletStreamListener.h"
|
||||
|
||||
jmethodID PlugletInstance::initializeMID = NULL;
|
||||
jmethodID PlugletInstance::startMID = NULL;
|
||||
jmethodID PlugletInstance::stopMID = NULL;
|
||||
jmethodID PlugletInstance::destroyMID = NULL;
|
||||
jmethodID PlugletInstance::newStreamMID = NULL;
|
||||
jmethodID PlugletInstance::setWindowMID = NULL;
|
||||
jmethodID PlugletInstance::printMID = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(PlugletInstance, kIPluginInstanceIID);
|
||||
|
||||
PlugletInstance::PlugletInstance(jobject object) {
|
||||
NS_INIT_REFCNT();
|
||||
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
|
||||
//nb check for null
|
||||
peer = NULL;
|
||||
}
|
||||
|
||||
PlugletInstance::~PlugletInstance() {
|
||||
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
|
||||
//nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
|
||||
if (!printMID) {
|
||||
//nb check for null after each and every JNI call
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletInstance");
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletInstancePeer;)V");
|
||||
startMID = env->GetMethodID(clazz,"start","()V");
|
||||
stopMID = env->GetMethodID(clazz,"stop","()V");
|
||||
destroyMID = env->GetMethodID(clazz,"destroy","()V");
|
||||
newStreamMID = env->GetMethodID(clazz,"newStream","()Lorg/mozilla/pluglet/PlugletStreamListener;");
|
||||
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Panel;)V");
|
||||
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
|
||||
}
|
||||
peer = _peer;
|
||||
peer->AddRef();
|
||||
//nb call java
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::GetPeer(nsIPluginInstancePeer* *result) {
|
||||
peer->AddRef();
|
||||
*result = peer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Start(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,startMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD PlugletInstance::Stop(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,stopMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD PlugletInstance::Destroy(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,destroyMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::NewStream(nsIPluginStreamListener** listener) {
|
||||
if(!listener) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jobject obj = env->CallObjectMethod(jthis,newStreamMID);
|
||||
//nb check for JNI exception
|
||||
if (obj) {
|
||||
*listener = new PlugletStreamListener(obj);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::GetValue(nsPluginInstanceVariable variable, void *value) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::SetWindow(nsPluginWindow* window) {
|
||||
//nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Print(nsPluginPrint* platformPrint) {
|
||||
//nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
56
java/plugins/src/PlugletInstance.h
Normal file
56
java/plugins/src/PlugletInstance.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletInstance_h__
|
||||
#define __PlugletInstance_h__
|
||||
#include "jni.h"
|
||||
#include "nsplugin.h"
|
||||
|
||||
class PlugletInstance : public nsIPluginInstance {
|
||||
public:
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
|
||||
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
|
||||
NS_IMETHOD Start(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
|
||||
NS_IMETHOD SetWindow(nsPluginWindow* window);
|
||||
NS_IMETHOD Print(nsPluginPrint* platformPrint);
|
||||
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PlugletInstance(jobject object);
|
||||
virtual ~PlugletInstance(void);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID startMID;
|
||||
static jmethodID stopMID;
|
||||
static jmethodID destroyMID;
|
||||
static jmethodID newStreamMID;
|
||||
static jmethodID setWindowMID;
|
||||
static jmethodID printMID;
|
||||
static jmethodID getValueMID;
|
||||
nsIPluginInstancePeer *peer;
|
||||
};
|
||||
#endif /* __PlugletInstance_h__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
67
java/plugins/src/PlugletList.cpp
Normal file
67
java/plugins/src/PlugletList.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include"PlugletList.h"
|
||||
|
||||
PlugletList::PlugletList() {
|
||||
head = tail = NULL;
|
||||
}
|
||||
|
||||
PlugletList::~PlugletList() {
|
||||
for(PlugletListNode * current=head;!current;delete current,current = current->next)
|
||||
;
|
||||
}
|
||||
|
||||
PlugletList::PlugletListNode::PlugletListNode(Pluglet *v,PlugletList::PlugletListNode *n) {
|
||||
value = v; next = n;
|
||||
}
|
||||
|
||||
void PlugletList::Add(Pluglet *pluglet) {
|
||||
if (!pluglet) {
|
||||
return;
|
||||
}
|
||||
if (!tail) {
|
||||
head = tail = new PlugletListNode(pluglet);
|
||||
} else {
|
||||
tail->next = new PlugletListNode(pluglet);
|
||||
if (tail->next) {
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlugletListIterator * PlugletList::GetIterator(void) {
|
||||
return new PlugletListIterator(this);
|
||||
}
|
||||
|
||||
PlugletListIterator::PlugletListIterator(PlugletList *list) {
|
||||
current = list->head;
|
||||
}
|
||||
Pluglet * PlugletListIterator::Get(void) {
|
||||
Pluglet * result = NULL;
|
||||
if (current) {
|
||||
result = current->value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Pluglet * PlugletListIterator::Next(void) {
|
||||
Pluglet * result = NULL;
|
||||
if (current) {
|
||||
current = current->next;
|
||||
result = Get();
|
||||
}
|
||||
return result;
|
||||
}
|
46
java/plugins/src/PlugletList.h
Normal file
46
java/plugins/src/PlugletList.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletList_h__
|
||||
#define __PlugletList_h__
|
||||
#include "Pluglet.h"
|
||||
class PlugletListIterator;
|
||||
|
||||
class PlugletList {
|
||||
friend class PlugletListIterator;
|
||||
public:
|
||||
PlugletList();
|
||||
~PlugletList();
|
||||
void Add(Pluglet *pluglet);
|
||||
PlugletListIterator * GetIterator(void);
|
||||
private:
|
||||
struct PlugletListNode {
|
||||
PlugletListNode(Pluglet *v,PlugletListNode *n = NULL);
|
||||
Pluglet * value;
|
||||
PlugletListNode * next;
|
||||
};
|
||||
PlugletListNode * head;
|
||||
PlugletListNode * tail;
|
||||
};
|
||||
class PlugletListIterator {
|
||||
public:
|
||||
PlugletListIterator(PlugletList *list);
|
||||
Pluglet * Get(void);
|
||||
Pluglet * Next(void);
|
||||
private:
|
||||
PlugletList::PlugletListNode *current;
|
||||
};
|
||||
|
||||
#endif /* __PlugletList_h__ */
|
124
java/plugins/src/PlugletLoader.cpp
Normal file
124
java/plugins/src/PlugletLoader.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "PlugletLoader.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "string.h"
|
||||
|
||||
jclass PlugletLoader::clazz = NULL;
|
||||
jmethodID PlugletLoader::getMIMEDescriptionMID = NULL;
|
||||
jmethodID PlugletLoader::getPlugletMID = NULL;
|
||||
|
||||
//nb for debug only
|
||||
static char *ToString(jobject obj,JNIEnv *env) {
|
||||
static jmethodID toStringID = NULL;
|
||||
if (!toStringID) {
|
||||
jclass clazz = env->FindClass("java/lang/Object");
|
||||
toStringID = env->GetMethodID(clazz,"toString","()Ljava/lang/String;");
|
||||
}
|
||||
jstring jstr = (jstring) env->CallObjectMethod(obj,toStringID);
|
||||
//nb check for jni exception
|
||||
const char * str = env->GetStringUTFChars(jstr,NULL);
|
||||
//nb check for jni exception
|
||||
char * res = new char[strlen(str)];
|
||||
strcpy(res,str);
|
||||
env->ReleaseStringUTFChars(jstr,str);
|
||||
return res;
|
||||
}
|
||||
|
||||
void PlugletLoader::Initialize(void) {
|
||||
//nb erors handling
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
clazz = env->FindClass("org/mozilla/pluglet/PlugletLoader");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
clazz = (jclass) env->NewGlobalRef(clazz);
|
||||
//nb check for jni exception
|
||||
getMIMEDescriptionMID = env->GetStaticMethodID(clazz,"getMIMEDescription","(Ljava/lang/String;)Ljava/lang/String;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
getPlugletMID = env->GetStaticMethodID(clazz,"getPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/Pluglet;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void PlugletLoader::Destroy(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->DeleteGlobalRef(clazz);
|
||||
}
|
||||
|
||||
char * PlugletLoader::GetMIMEDescription(const char * path) {
|
||||
if (!clazz) {
|
||||
Initialize();
|
||||
if (!clazz) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jstring jpath = env->NewStringUTF(path);
|
||||
//nb check for null
|
||||
jstring mimeDescription = (jstring)env->CallStaticObjectMethod(clazz,getMIMEDescriptionMID,jpath);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NULL;
|
||||
}
|
||||
if (!mimeDescription) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* str = env->GetStringUTFChars(mimeDescription,NULL);
|
||||
char *res = NULL;
|
||||
if(str) {
|
||||
res = new char[strlen(str)+1];
|
||||
strcpy(res,str);
|
||||
env->ReleaseStringUTFChars(mimeDescription,str);
|
||||
}
|
||||
return res;
|
||||
//nb possible memory leak - talk to Mozilla
|
||||
}
|
||||
|
||||
jobject PlugletLoader::GetPluglet(const char * path) {
|
||||
if (!clazz) {
|
||||
Initialize();
|
||||
if (!clazz) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jstring jpath = env->NewStringUTF(path);
|
||||
jobject jpluglet = env->CallStaticObjectMethod(clazz,getPlugletMID,jpath);
|
||||
//nb check for jni exc
|
||||
if (jpluglet) {
|
||||
jpluglet = env->NewGlobalRef(jpluglet);
|
||||
}
|
||||
return jpluglet;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
32
java/plugins/src/PlugletLoader.h
Normal file
32
java/plugins/src/PlugletLoader.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletLoader_h__
|
||||
#define __PlulgetLoader_h__
|
||||
#include "jni.h"
|
||||
#include "Pluglet.h"
|
||||
|
||||
class PlugletLoader {
|
||||
public:
|
||||
static char * GetMIMEDescription(const char * path);
|
||||
static jobject GetPluglet(const char * path);
|
||||
static void Initialize(void);
|
||||
static void Destroy(void);
|
||||
private:
|
||||
static jclass clazz;
|
||||
static jmethodID getMIMEDescriptionMID;
|
||||
static jmethodID getPlugletMID;
|
||||
};
|
||||
#endif /* __PlulgetLoader_h__ */
|
87
java/plugins/src/PlugletStreamListener.cpp
Normal file
87
java/plugins/src/PlugletStreamListener.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include "PlugletStreamListener.h"
|
||||
#include "PlugletEngine.h"
|
||||
|
||||
|
||||
|
||||
jmethodID PlugletStreamListener::onStartBindingMID = NULL;
|
||||
jmethodID PlugletStreamListener::onDataAvailableMID = NULL;
|
||||
jmethodID PlugletStreamListener::onFileAvailableMID = NULL;
|
||||
jmethodID PlugletStreamListener::onStopBindingMID = NULL;
|
||||
jmethodID PlugletStreamListener::getStreamTypeMID = NULL;
|
||||
|
||||
void PlugletStreamListener::Initialize(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletStreamListener");
|
||||
onStartBindingMID = env->GetMethodID(clazz, "onStartBinding","(Lorg/mozilla/pluglet/mozilla/PlugletStreamInfo;)V");
|
||||
onDataAvailableMID = env->GetMethodID(clazz,"onDataAvailable","(Lorg/mozilla/pluglet/mozilla/PlugletStreamInfo;Ljava/io/InputStream;I)V");
|
||||
onFileAvailableMID = env->GetMethodID(clazz,"onFileAvailable","(Lorg/mozilla/pluglet/mozilla/PlugletStreamInfo;Ljava/lang/String;)V");
|
||||
getStreamTypeMID = env->GetMethodID(clazz,"getStreamType","()I");
|
||||
onStopBindingMID = env->GetMethodID(clazz,"onStopBinding","(Lorg/mozilla/pluglet/mozilla/PlugletStreamInfo;I)V");
|
||||
}
|
||||
|
||||
PlugletStreamListener::PlugletStreamListener(jobject object) {
|
||||
NS_INIT_REFCNT();
|
||||
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
|
||||
if (!onStopBindingMID) {
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
PlugletStreamListener::~PlugletStreamListener(void) {
|
||||
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
|
||||
}
|
||||
|
||||
NS_METHOD PlugletStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
//nb env->CallVoidMethod(jthis,onStartBindingMID,NewPluginStreamInfo(Plugin::env,pluginInfo));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
//nb env->CallVoidMethod(jthis,onDataAvailableMID,NewPluginStreamInfo(Plugin::env,pluginInfo),
|
||||
// NewInputStream(Plugin::env,input),(jint)length);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
//nb Plugin::env->CallVoidMethod(jthis,onFileAvailableMID,NewPluginStreamInfo(Plugin::env,pluginInfo),
|
||||
// Plugin::env->NewStringUTF(fileName));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
//nb env->CallVoidMethod(jthis,onStopBindingMID,NewPluginStreamInfo(Plugin::env,pluginInfo),status);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD PlugletStreamListener::GetStreamType(nsPluginStreamType *result) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
*result = (nsPluginStreamType)env->CallIntMethod(jthis,getStreamTypeMID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(PlugletStreamListener, kIPluginStreamListenerIID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
53
java/plugins/src/PlugletStreamListener.h
Normal file
53
java/plugins/src/PlugletStreamListener.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletStreamListener_h__
|
||||
#define __PlugletStreamListener_h__
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "jni.h"
|
||||
|
||||
class PlugletStreamListener : public nsIPluginStreamListener {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMETHOD
|
||||
OnStartBinding(nsIPluginStreamInfo* pluginInfo);
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName);
|
||||
NS_IMETHOD
|
||||
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
NS_IMETHOD
|
||||
GetStreamType(nsPluginStreamType *result);
|
||||
|
||||
PlugletStreamListener(jobject jthis);
|
||||
virtual ~PlugletStreamListener(void);
|
||||
static void Initialize(void);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID onStartBindingMID;
|
||||
static jmethodID onDataAvailableMID;
|
||||
static jmethodID onFileAvailableMID;
|
||||
static jmethodID onStopBindingMID;
|
||||
static jmethodID getStreamTypeMID;
|
||||
};
|
||||
|
||||
#endif /* __PlugletStreanListener_h__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
21
java/plugins/src/PlugletView.h
Normal file
21
java/plugins/src/PlugletView.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletView_h__
|
||||
#define __PlugletView_h__
|
||||
class PlugletView {
|
||||
//nb
|
||||
};
|
||||
#endif /* __PlugletView_h__ */
|
82
java/plugins/src/PlugletsDir.cpp
Normal file
82
java/plugins/src/PlugletsDir.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include"PlugletsDir.h"
|
||||
#include "prenv.h"
|
||||
|
||||
PlugletsDir::PlugletsDir(void) {
|
||||
list = NULL;
|
||||
//nb ???
|
||||
}
|
||||
|
||||
PlugletsDir::~PlugletsDir(void) {
|
||||
if (list) {
|
||||
for (PlugletListIterator *iter = list->GetIterator();iter->Get();delete iter->Get(),iter->Next())
|
||||
;
|
||||
delete list;
|
||||
}
|
||||
}
|
||||
|
||||
void PlugletsDir::LoadPluglets() {
|
||||
if (!list) {
|
||||
list = new PlugletList();
|
||||
char * path = PR_GetEnv("PLUGLET");
|
||||
int pathLength = strlen(path);
|
||||
Pluglet *pluglet;
|
||||
for (nsDirectoryIterator iter(nsFileSpec(path),PR_TRUE); iter.Exists(); iter++) {
|
||||
const nsFileSpec& file = iter;
|
||||
const char* name = file.GetCString();
|
||||
int length;
|
||||
if((length = strlen(name)) <= 4 // if it's shorter than ".jar"
|
||||
|| strcmp(name+length - 4,".jar") ) {
|
||||
continue;
|
||||
}
|
||||
if ( (pluglet = Pluglet::Load(name)) ) {
|
||||
list->Add(pluglet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult PlugletsDir::GetPluglet(const char * mimeType, Pluglet **pluglet) {
|
||||
if(!pluglet) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*pluglet = NULL;
|
||||
nsresult res = NS_OK;
|
||||
if(!list) {
|
||||
LoadPluglets();
|
||||
}
|
||||
for (PlugletListIterator *iter = list->GetIterator();iter->Get();iter->Next()) {
|
||||
if(iter->Get()->Compare(mimeType)) {
|
||||
*pluglet = iter->Get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
38
java/plugins/src/PlugletsDir.h
Normal file
38
java/plugins/src/PlugletsDir.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __PlugletsDir_h__
|
||||
#define __PlugletsDir_h__
|
||||
#include "Pluglet.h"
|
||||
#include "PlugletList.h"
|
||||
|
||||
class PlugletsDir {
|
||||
friend class PlugletsDirIterator;
|
||||
public:
|
||||
PlugletsDir(void);
|
||||
~PlugletsDir(void);
|
||||
void LoadPluglets();
|
||||
nsresult GetPluglet(const char * mimeType,Pluglet **pluglet);
|
||||
private:
|
||||
PlugletList * list;
|
||||
};
|
||||
#endif /* __PlugletsDir_h__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
91
java/plugins/src/makefile.win
Normal file
91
java/plugins/src/makefile.win
Normal file
@ -0,0 +1,91 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
# -*- 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) 1999 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
MODULE = nppluglet
|
||||
|
||||
LIBRARY_NAME = nppluglet
|
||||
|
||||
DEPTH= ..\..\..\
|
||||
|
||||
REQUIRES = java plug xpcom raptor oji
|
||||
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\Pluglet.obj \
|
||||
.\$(OBJDIR)\PlugletEngine.obj \
|
||||
.\$(OBJDIR)\PlugletList.obj \
|
||||
.\$(OBJDIR)\PlugletLoader.obj \
|
||||
.\$(OBJDIR)\PlugletsDir.obj \
|
||||
.\$(OBJDIR)\PlugletInstance.obj \
|
||||
.\$(OBJDIR)\PlugletStreamListener.obj
|
||||
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any Public Targets here (ie. PROGRAM, LIBRARY, DLL, ...)
|
||||
#// (these must be defined before the common makefiles are included)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
DLLNAME=nppluglet
|
||||
PDBFILE=nppluglet.pdb
|
||||
MAPFILE=nppluglet.map
|
||||
DEFFILE=PlugletEngine.def
|
||||
RESFILE=PlugletEngine.res
|
||||
|
||||
DLL = .\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define any local options for the make tools
|
||||
#// (ie. LCFLAGS, LLFLAGS, LLIBS, LINCS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
LLIBS=$(LLIBS) $(LIBNSPR) $(DIST)\lib\xpcom.lib $(DIST)\lib\oji.lib $(JDKHOME)\lib\jvm.lib
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Include the common makefile rules
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
|
||||
|
||||
|
||||
|
81
java/plugins/test/PlugletInstance.java
Normal file
81
java/plugins/test/PlugletInstance.java
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
package org.mozilla.pluglet;
|
||||
import org.mozilla.pluglet.mozilla.*;
|
||||
import java.awt.Panel;
|
||||
import java.awt.print.PrinterJob;
|
||||
|
||||
public interface PlugletInstance {
|
||||
/**
|
||||
* Initializes a newly created pluglet instance, passing to it the pluglet
|
||||
* instance peer which it should use for all communication back to the browser.
|
||||
*
|
||||
* @param peer the corresponding pluglet instance peer
|
||||
*/
|
||||
void initialize(PlugletInstancePeer peer);
|
||||
/**
|
||||
* Called to instruct the pluglet instance to start. This will be called after
|
||||
* the pluglet is first created and initialized, and may be called after the
|
||||
* pluglet is stopped (via the Stop method) if the pluglet instance is returned
|
||||
* to in the browser window's history.
|
||||
*/
|
||||
void start();
|
||||
/**
|
||||
* Called to instruct the pluglet instance to stop, thereby suspending its state.
|
||||
* This method will be called whenever the browser window goes on to display
|
||||
* another page and the page containing the pluglet goes into the window's history
|
||||
* list.
|
||||
*/
|
||||
void stop();
|
||||
/**
|
||||
* Called to instruct the pluglet instance to destroy itself. This is called when
|
||||
* it become no longer possible to return to the pluglet instance, either because
|
||||
* the browser window's history list of pages is being trimmed, or because the
|
||||
* window containing this page in the history is being closed.
|
||||
*/
|
||||
void destroy();
|
||||
/**
|
||||
* Called to tell the pluglet that the initial src/data stream is
|
||||
* ready.
|
||||
*
|
||||
* @result PlugletStreamListener
|
||||
*/
|
||||
PlugletStreamListener newStream();
|
||||
/**
|
||||
* Called when the window containing the pluglet instance changes.
|
||||
*
|
||||
* @param frame the pluglet panel
|
||||
*/
|
||||
void setWindow(Panel frame);
|
||||
/**
|
||||
* Called to instruct the pluglet instance to print itself to a printer.
|
||||
*
|
||||
* @param print printer information.
|
||||
*/
|
||||
void print(PrinterJob printerJob);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
24
java/plugins/test/makefile.win
Normal file
24
java/plugins/test/makefile.win
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
# the License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Sun Microsystems,
|
||||
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
# Inc. All Rights Reserved.
|
||||
|
||||
.SUFFIXES: .java .class
|
||||
.java.class:
|
||||
$(JDKHOME)\bin\javac -classpath ../classes $<
|
||||
default: test.jar
|
||||
test.jar: test.class manifest
|
||||
$(JDKHOME)\bin\jar cvfm test.jar manifest *.class
|
||||
|
||||
clobber:
|
||||
-del *.class *.jar
|
2
java/plugins/test/manifest
Normal file
2
java/plugins/test/manifest
Normal file
@ -0,0 +1,2 @@
|
||||
MIMEDescription: "*:*:Pluglet Test"
|
||||
Pluglet-Class: test
|
148
java/plugins/test/test.java
Normal file
148
java/plugins/test/test.java
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
* the License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
import org.mozilla.pluglet.*;
|
||||
import org.mozilla.pluglet.mozilla.*;
|
||||
import java.awt.*;
|
||||
import java.awt.print.*;
|
||||
import java.io.*;
|
||||
|
||||
public class test implements Pluglet {
|
||||
/**
|
||||
* Creates a new pluglet instance, based on a MIME type. This
|
||||
* allows different impelementations to be created depending on
|
||||
* the specified MIME type.
|
||||
*/
|
||||
public PlugletInstance createPlugletInstance(String mimeType) {
|
||||
org.mozilla.util.Debug.print("--test.createPlugletInstance\n");
|
||||
return new TestInstance();
|
||||
}
|
||||
/**
|
||||
* Initializes the pluglet and will be called before any new instances are
|
||||
* created.
|
||||
*/
|
||||
public void initialize(PlugletManager manager) {
|
||||
org.mozilla.util.Debug.print("--test.initialize\n");
|
||||
}
|
||||
/**
|
||||
* Called when the browser is done with the pluglet factory, or when
|
||||
* the pluglet is disabled by the user.
|
||||
*/
|
||||
public void shutdown() {
|
||||
org.mozilla.util.Debug.print("--test.shutdown\n");
|
||||
}
|
||||
}
|
||||
|
||||
class TestInstance implements PlugletInstance{
|
||||
/**
|
||||
* Initializes a newly created pluglet instance, passing to it the pluglet
|
||||
* instance peer which it should use for all communication back to the browser.
|
||||
*
|
||||
* @param peer the corresponding pluglet instance peer
|
||||
*/
|
||||
public void initialize(PlugletInstancePeer peer) {
|
||||
org.mozilla.util.Debug.print("--TestInstance.initialize\n");
|
||||
}
|
||||
/**
|
||||
* Called to instruct the pluglet instance to start. This will be called after
|
||||
* the pluglet is first created and initialized, and may be called after the
|
||||
* pluglet is stopped (via the Stop method) if the pluglet instance is returned
|
||||
* to in the browser window's history.
|
||||
*/
|
||||
public void start() {
|
||||
org.mozilla.util.Debug.print("--TestInstance.start\n");
|
||||
}
|
||||
/**
|
||||
* Called to instruct the pluglet instance to stop, thereby suspending its state.
|
||||
* This method will be called whenever the browser window goes on to display
|
||||
* another page and the page containing the pluglet goes into the window's history
|
||||
* list.
|
||||
*/
|
||||
public void stop() {
|
||||
org.mozilla.util.Debug.print("--TestInstance.stop\n");
|
||||
}
|
||||
/**
|
||||
* Called to instruct the pluglet instance to destroy itself. This is called when
|
||||
* it become no longer possible to return to the pluglet instance, either because
|
||||
* the browser window's history list of pages is being trimmed, or because the
|
||||
* window containing this page in the history is being closed.
|
||||
*/
|
||||
public void destroy() {
|
||||
}
|
||||
/**
|
||||
* Called to tell the pluglet that the initial src/data stream is
|
||||
* ready.
|
||||
*
|
||||
* @result PlugletStreamListener
|
||||
*/
|
||||
public PlugletStreamListener newStream() {
|
||||
org.mozilla.util.Debug.print("--TestInstance.newStream\n");
|
||||
return new TestStreamListener();
|
||||
}
|
||||
/**
|
||||
* Called when the window containing the pluglet instance changes.
|
||||
*
|
||||
* @param frame the pluglet panel
|
||||
*/
|
||||
public void setWindow(Panel frame) {
|
||||
}
|
||||
/**
|
||||
* Called to instruct the pluglet instance to print itself to a printer.
|
||||
*
|
||||
* @param print printer information.
|
||||
*/
|
||||
public void print(PrinterJob printerJob) {
|
||||
}
|
||||
}
|
||||
|
||||
class TestStreamListener implements PlugletStreamListener {
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*/
|
||||
public void onStartBinding(PlugletStreamInfo plugletInfo) {
|
||||
org.mozilla.util.Debug.print("--TestStreamListener.onStartBinding\n");
|
||||
}
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param input The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
*/
|
||||
public void onDataAvailable(PlugletStreamInfo plugletInfo, InputStream input,int length) {
|
||||
org.mozilla.util.Debug.print("--TestStreamListener.onDataAvailable\n");
|
||||
}
|
||||
public void onFileAvailable(PlugletStreamInfo plugletInfo, String fileName) {
|
||||
org.mozilla.util.Debug.print("--TestStreamListener.onFileAvailable\n");
|
||||
}
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading.
|
||||
*/
|
||||
public void onStopBinding(PlugletStreamInfo plugletInfo,int status) {
|
||||
org.mozilla.util.Debug.print("--TestStreamListener.onStopBinding\n");
|
||||
}
|
||||
public int getStreamType() {
|
||||
org.mozilla.util.Debug.print("--TestStreamListener.getStreamType\n");
|
||||
return 1; //:)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user