} else if (o instanceof ByteStream) {
try {
- sb.append(" <value><base64>");
+ sb.append(" <value><base64>\n");
InputStream is = ((ByteStream)o).getInputStream();
- byte[] buf = new byte[96];
+ byte[] buf = new byte[54];
while(true) {
- int numread = is.read(buf, 0, 96);
+ int numread = is.read(buf, 0, 54);
if (numread == -1) break;
byte[] writebuf = buf;
if (numread < buf.length) {
System.arraycopy(buf, 0, writebuf, 0, numread);
}
sb.append(" ");
- sb.append(Base64.encode(writebuf));
+ sb.append(new String(Base64.encode(writebuf)));
sb.append("\n");
}
- sb.append(((Boolean)o).booleanValue() ? "1" : "0");
sb.append("\n </base64></value>\n");
} catch (IOException e) {
if (Log.on) Log.log(this, "caught IOException while attempting to send a ByteStream via XML-RPC");
public final Object call(Context cx, Scriptable scope, Scriptable thisObj, java.lang.Object[] args) throws JavaScriptException {
- // put ourselves in the background
- Thread thread = Thread.currentThread();
- if (!(thread instanceof ThreadMessage)) {
- if (Log.on) Log.log(this, "RPC calls may only be made from background threads");
- return null;
- }
- ThreadMessage mythread = (ThreadMessage)thread;
- mythread.setPriority(Thread.MIN_PRIORITY);
- mythread.done.release();
+ if (!ThreadMessage.suspendThread()) return null;
try {
return call(args);
-
} catch (IOException se) {
if (Log.on) Log.log(this, se);
if (Log.on) Log.log(this, " at " + cx.interpreterSourceFile + ":" + cx.interpreterLine);
if (Log.on) Log.log(this, " at " + cx.interpreterSourceFile + ":" + cx.interpreterLine);
}
throw jse;
-
} finally {
- // okay, let ourselves be brought to the foreground
- MessageQueue.add(mythread);
- mythread.setPriority(Thread.NORM_PRIORITY);
- mythread.go.block();
+ ThreadMessage.resumeThread();
}
}