Add implemenataion of PlugletInputStream and PlugletStreamInfo
git-svn-id: svn://10.0.0.236/trunk@45633 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -38,12 +38,12 @@ public interface PlugletStreamListener {
|
||||
* 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);
|
||||
void onDataAvailable(PlugletStreamInfo stremInfo, InputStream input,int length);
|
||||
void onFileAvailable(PlugletStreamInfo streamInfo, String fileName);
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading.
|
||||
*/
|
||||
void onStopBinding(PlugletStreamInfo plugletInfo,int status);
|
||||
void onStopBinding(PlugletStreamInfo streamInfo,int status);
|
||||
int getStreamType();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 PlugletInputStream extends InputStream {
|
||||
private long peer;
|
||||
private PlugletInputStream(long peer) {
|
||||
this.peer = peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
public int read() throws IOException {
|
||||
byte b[] = new byte[1];
|
||||
return read(b,0,1);
|
||||
}
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
if (off>0) {
|
||||
skip(off);
|
||||
}
|
||||
return read(b,len);
|
||||
}
|
||||
public native int available();
|
||||
public native void close();
|
||||
public synchronized void mark(int readlimit) {
|
||||
}
|
||||
public synchronized void reset() throws IOException {
|
||||
}
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 PlugletStreamInfoImpl implements PlugletStreamInfo {
|
||||
private PlugletStreamInfoImpl(long peer) {
|
||||
this.peer = peer;
|
||||
nativeInitialize();
|
||||
}
|
||||
protected long peer;
|
||||
/**
|
||||
* Returns the MIME type.
|
||||
*/
|
||||
public native String getContentType();
|
||||
public native boolean isSeekable();
|
||||
/**
|
||||
* Returns the number of bytes that can be read from this input stream
|
||||
*/
|
||||
public native int getLength();
|
||||
public native int getLastModified();
|
||||
public native String getURL();
|
||||
/**
|
||||
* Request reading from input stream
|
||||
*
|
||||
* @param offset the start point for reading.
|
||||
* @param length the number of bytes to be read.
|
||||
*/
|
||||
public native void requestRead(ByteRanges ranges);
|
||||
protected void finalize() {
|
||||
nativeFinalize();
|
||||
}
|
||||
private native void nativeFinalize();
|
||||
private native void nativeInitialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user