Add this files
git-svn-id: svn://10.0.0.236/trunk@46266 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
class ByteRangesImpl implements ByteRanges {
|
||||
//why not [][] ? Because it is simpler & faster from jni
|
||||
private int offset[];
|
||||
private int length[];
|
||||
//this is the index for next available free cell in the array
|
||||
private int current = 0;
|
||||
//size increment for offset and length arrays
|
||||
private final static int STEP = 10;
|
||||
ByteRangesImpl() {
|
||||
offset = new int[STEP];
|
||||
length = new int[STEP];
|
||||
}
|
||||
public void addRange(int off, int len) {
|
||||
if (current >= offset.length) {
|
||||
int tmpOffset[] = new int[offset.length+STEP];
|
||||
int tmpLength[] = new int[offset.length+STEP];
|
||||
System.arraycopy(offset,0,tmpOffset,0,offset.length);
|
||||
System.arraycopy(length,0,tmpLength,0,length.length);
|
||||
offset = tmpOffset;
|
||||
length = tmpLength;
|
||||
}
|
||||
offset[current] = off;
|
||||
length[current] = len;
|
||||
current++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,19 +19,25 @@ import java.io.*;
|
||||
|
||||
class PlugletInputStream extends InputStream {
|
||||
private long peer;
|
||||
private byte buf[] = new byte[1];
|
||||
|
||||
private PlugletInputStream(long peer) {
|
||||
this.peer = peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
public int read() throws IOException {
|
||||
byte b[] = new byte[1];
|
||||
return read(b,0,1);
|
||||
return read(buf,0,1);
|
||||
}
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
if (off>0) {
|
||||
skip(off);
|
||||
}
|
||||
return read(b,len);
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > b.length) || (len < 0) ||
|
||||
((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
return nativeRead(b,off,len);
|
||||
}
|
||||
public native int available();
|
||||
public native void close();
|
||||
@@ -42,10 +48,13 @@ class PlugletInputStream extends InputStream {
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
private native int read(byte b[], int len);
|
||||
protected void finalize() {
|
||||
nativeFinalize();
|
||||
}
|
||||
private native void nativeFinalize();
|
||||
private native void nativeInitialize();
|
||||
private native int nativeRead(byte b[], int off, int len) throws IOException;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,4 +45,12 @@ public interface PlugletInstancePeer {
|
||||
* @param message the status message to display
|
||||
*/
|
||||
public void showStatus(String message);
|
||||
}
|
||||
/**
|
||||
* Set the desired size of the window in which the plugin instance lives.
|
||||
*
|
||||
* @param width - new window width
|
||||
* @param height - new window height
|
||||
*/
|
||||
public void setWindowSize(int width, int height);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
class PlugletInstancePeerImpl implements PlugletInstancePeer {
|
||||
private long peer = 0;
|
||||
private PlugletInstancePeerImpl(long peer) {
|
||||
this.peer = peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
/**
|
||||
* Returns the MIME type of the pluglet instance.
|
||||
*/
|
||||
public native String getMIMEType();
|
||||
/**
|
||||
* Returns the mode of the pluglet instance, i.e. whether the pluglet
|
||||
* is embedded in the html, or full page.
|
||||
*/
|
||||
public native int getMode();
|
||||
/**
|
||||
* Returns the value of a variable associated with the pluglet manager.
|
||||
* @param variable the pluglet manager variable to get
|
||||
*/
|
||||
public native 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 native 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 native void showStatus(String message);
|
||||
/**
|
||||
* Set the desired size of the window in which the plugin instance lives.
|
||||
*
|
||||
* @param width - new window width
|
||||
* @param height - new window height
|
||||
*/
|
||||
public native void setWindowSize(int width, int height);
|
||||
private native void nativeFinalize();
|
||||
private native void nativeInitialize();
|
||||
};
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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;
|
||||
class PlugletManagerImpl implements PlugletManager {
|
||||
private long peer = 0;
|
||||
private PlugletManagerImpl(long _peer) {
|
||||
peer = _peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
/**
|
||||
* Returns the value of a variable associated with the pluglet manager.
|
||||
*
|
||||
* @param variable the pluglet manager variable to get
|
||||
*/
|
||||
public native 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 native void reloadPluglets(boolean reloadPages);
|
||||
|
||||
/**
|
||||
* Returns the user agent string for the browser.
|
||||
*
|
||||
*/
|
||||
public native 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 native 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 native 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);
|
||||
protected void finalize() {
|
||||
nativeFinalize();
|
||||
}
|
||||
private native void nativeFinalize();
|
||||
private native void nativeInitialize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.*;
|
||||
|
||||
class PlugletOutputStream extends OutputStream {
|
||||
private long peer;
|
||||
private byte buf[] = new byte[1];
|
||||
private PlugletOutputStream(long peer) {
|
||||
this.peer = peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
public void write(int b) throws IOException {
|
||||
buf[0] = (byte)b;
|
||||
write(buf,0,1);
|
||||
}
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
} else if ((off < 0) || (off > b.length) || (len < 0) ||
|
||||
((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
} else if (len == 0) {
|
||||
return;
|
||||
}
|
||||
nativeWrite(b,off,len);
|
||||
}
|
||||
|
||||
public native void flush();
|
||||
public native void close();
|
||||
private native void nativeWrite(byte b[], int off, int len) throws IOException;
|
||||
private native void nativeFinalize();
|
||||
private native void nativeInitialize();
|
||||
}
|
||||
Reference in New Issue
Block a user