summaryrefslogtreecommitdiff
path: root/org
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@hecate.trinhall.cam.ac.uk>2006-12-25 21:14:41 +0000
committerMatthew Johnson <mjj29@hecate.trinhall.cam.ac.uk>2006-12-25 21:14:41 +0000
commit648ce9694ab64115317375f5a779eead513a98ac (patch)
treeae6af0a7f0b18530e87dbf2bdfc03ac6bdb79f4f /org
parentc3ec6f6a6385b4b001559a744145a87e93955c0c (diff)
more fixes
Diffstat (limited to 'org')
-rw-r--r--org/freedesktop/dbus/ArrayFrob.java4
-rw-r--r--org/freedesktop/dbus/BusAddress.java4
-rw-r--r--org/freedesktop/dbus/DBusAsyncReply.java4
-rw-r--r--org/freedesktop/dbus/DBusConnection.java84
-rw-r--r--org/freedesktop/dbus/DBusSignal.java5
-rw-r--r--org/freedesktop/dbus/EfficientQueue.java20
-rw-r--r--org/freedesktop/dbus/Error.java8
-rw-r--r--org/freedesktop/dbus/Marshalling.java6
-rw-r--r--org/freedesktop/dbus/Message.java26
-rw-r--r--org/freedesktop/dbus/MessageReader.java10
-rw-r--r--org/freedesktop/dbus/MessageWriter.java2
-rw-r--r--org/freedesktop/dbus/MethodCall.java2
-rw-r--r--org/freedesktop/dbus/RemoteInvocationHandler.java14
-rw-r--r--org/freedesktop/dbus/Transport.java1
-rw-r--r--org/freedesktop/dbus/UInt64.java5
-rw-r--r--org/freedesktop/dbus/Variant.java8
-rw-r--r--org/freedesktop/dbus/test/test.java11
17 files changed, 109 insertions, 105 deletions
diff --git a/org/freedesktop/dbus/ArrayFrob.java b/org/freedesktop/dbus/ArrayFrob.java
index 49e411a..ce22100 100644
--- a/org/freedesktop/dbus/ArrayFrob.java
+++ b/org/freedesktop/dbus/ArrayFrob.java
@@ -18,6 +18,8 @@ import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
+import cx.ath.matthew.debug.Debug;
+
class ArrayFrob
{
static Hashtable<Class, Class> primitiveToWrapper = new Hashtable<Class, Class>();
@@ -150,7 +152,7 @@ class ArrayFrob
return type((Object[]) o, c.getComponentType());
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new IllegalArgumentException(e);
}
diff --git a/org/freedesktop/dbus/BusAddress.java b/org/freedesktop/dbus/BusAddress.java
index da0cdda..1652e48 100644
--- a/org/freedesktop/dbus/BusAddress.java
+++ b/org/freedesktop/dbus/BusAddress.java
@@ -11,6 +11,7 @@
package org.freedesktop.dbus;
import java.util.Map;
import java.util.HashMap;
+import cx.ath.matthew.debug.Debug;
public class BusAddress
{
@@ -18,14 +19,17 @@ public class BusAddress
private Map<String,String> parameters;
public BusAddress(String address)
{
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Parsing bus address: "+address);
String[] ss = address.split(":", 2);
type = ss[0];
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Transport type: "+type);
String[] ps = ss[1].split(",");
parameters = new HashMap<String,String>();
for (String p: ps) {
String[] kv = p.split("=", 2);
parameters.put(kv[0], kv[1]);
}
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Transport options: "+parameters);
}
public String getType() { return type; }
public String getParameter(String key) { return parameters.get(key); }
diff --git a/org/freedesktop/dbus/DBusAsyncReply.java b/org/freedesktop/dbus/DBusAsyncReply.java
index b39bd0d..6e2be06 100644
--- a/org/freedesktop/dbus/DBusAsyncReply.java
+++ b/org/freedesktop/dbus/DBusAsyncReply.java
@@ -19,6 +19,8 @@ import org.freedesktop.DBus.Error.NoReply;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
+import cx.ath.matthew.debug.Debug;
+
/**
* A handle to an asynchronous method call.
*/
@@ -62,7 +64,7 @@ public class DBusAsyncReply<ReturnType>
} catch (DBusExecutionException DBEe) {
error = DBEe;
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
error = new DBusExecutionException(DBe.getMessage());
}
}
diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java
index 4cbbc9a..836b58e 100644
--- a/org/freedesktop/dbus/DBusConnection.java
+++ b/org/freedesktop/dbus/DBusConnection.java
@@ -33,6 +33,7 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
import java.util.Vector;
@@ -116,18 +117,15 @@ public class DBusConnection
m = null;
}
} catch (IOException IOe) {
- if (EXCEPTION_DEBUG)
- IOe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
try {
handleMessage(new org.freedesktop.DBus.Local.Disconnected("/"));
} catch (Exception e) {
- if (EXCEPTION_DEBUG)
- e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
}
disconnect();
} catch (Exception e) {
- if (EXCEPTION_DEBUG)
- e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
}
// write to the wire
@@ -248,13 +246,13 @@ public class DBusConnection
private String addr;
static final Pattern dollar_pattern = Pattern.compile("[$]");
public static final boolean EXCEPTION_DEBUG;
- public static final boolean DBUS_JAVA_DEBUG;
static {
EXCEPTION_DEBUG = (null != System.getenv("DBUS_JAVA_EXCEPTION_DEBUG"));
- DBUS_JAVA_DEBUG = (null != System.getenv("DBUS_JAVA_DEBUG"));
- if (DBUS_JAVA_DEBUG) Debug.print("Debugging enabled");
- if (EXCEPTION_DEBUG) Debug.print("Debugging of internal exceptions enabled");
- if (Debug.debug && DBUS_JAVA_DEBUG) {
+ if (EXCEPTION_DEBUG) {
+ Debug.print("Debugging of internal exceptions enabled");
+ Debug.setThrowableTraces(true);
+ }
+ if (Debug.debug) {
File f = new File("debug.conf");
if (f.exists()) {
Debug.print("Loading debug config file: "+f);
@@ -262,8 +260,11 @@ public class DBusConnection
Debug.loadConfig(f);
} catch (IOException IOe) {}
} else {
+ Properties p = new Properties();
+ p.setProperty("ALL", "INFO");
Debug.print("debug config file "+f+" does not exist, not loading.");
}
+ Debug.setHexDump(true);
}
}
@@ -352,8 +353,7 @@ public class DBusConnection
try {
transport = new Transport(addr);
} catch (IOException IOe) {
- if (EXCEPTION_DEBUG)
- IOe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
throw new DBusException("Failed to connect to bus "+IOe.getMessage());
}
@@ -371,7 +371,7 @@ public class DBusConnection
try {
busnames.add(_dbus.Hello());
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
throw new DBusException(DBEe.getMessage());
}
}
@@ -457,7 +457,7 @@ public class DBusConnection
importedObjects.put(newi, ro);
return newi;
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusException("Failed to create proxy object for "+path+" exported by "+source+". Reason: "+e.getMessage());
}
}
@@ -484,21 +484,6 @@ public class DBusConnection
}
/**
- * Register a bus name.
- * Register the well known name that this should respond to on the Bus.
- * This function is deprecated in favour of requestBusName.
- * @param busname The name to respond to. MUST be in dot-notation like "org.freedesktop.local"
- * @throws DBusException If the register name failed, or our name already exists on the bus.
- * or if busname is incorrectly formatted.
- * @see #requestBusName
- * @deprecated
- */
- @Deprecated()
- public void registerService(String busname) throws DBusException
- {
- requestBusName(busname);
- }
- /**
* Request a bus name.
* Request the well known name that this should respond to on the Bus.
* @param busname The name to respond to. MUST be in dot-notation like "org.freedesktop.local"
@@ -516,7 +501,7 @@ public class DBusConnection
new UInt32(DBus.DBUS_NAME_FLAG_REPLACE_EXISTING |
DBus.DBUS_NAME_FLAG_DO_NOT_QUEUE));
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
throw new DBusException(DBEe.getMessage());
}
switch (rv.intValue()) {
@@ -843,7 +828,7 @@ public class DBusConnection
try {
_dbus.RemoveMatch(rule.toString());
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
throw new DBusException(DBEe.getMessage());
}
}
@@ -923,7 +908,7 @@ public class DBusConnection
try {
_dbus.AddMatch(rule.toString());
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
throw new DBusException(DBEe.getMessage());
}
SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
@@ -1001,8 +986,7 @@ public class DBusConnection
try {
transport.disconnect();
} catch (IOException IOe) {
- if (EXCEPTION_DEBUG)
- IOe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
}
conn.remove(addr);
@@ -1059,17 +1043,17 @@ public class DBusConnection
me = ro.iface.getMethod(m, types);
return (DBusAsyncReply) RemoteInvocationHandler.executeRemoteMethod(ro, me, this, true, parameters);
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
throw DBEe;
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusExecutionException(e.getMessage());
}
}
private void handleMessage(final MethodCall m) throws DBusException
{
- if (Debug.debug) Debug.print("Handling incoming method call: "+m);
+ if (Debug.debug) Debug.print(Debug.ERR, "Handling incoming method call: "+m);
// get the method signature
Object[] params = m.getParameters();
@@ -1127,7 +1111,7 @@ public class DBusConnection
m.setArgs(Marshalling.deSerializeParameters(m.getParameters(), ts, conn));
if (Debug.debug) Debug.print(Debug.DEBUG, "Deserialised "+Arrays.deepToString(m.getParameters())+" to types "+Arrays.deepToString(ts));
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
try {
synchronized (outqueue) {
outqueue.add(new Error(m, new DBus.Error.UnknownMethod("Failure in de-serializing message ("+e+")")));
@@ -1144,7 +1128,7 @@ public class DBusConnection
try {
result = me.invoke(ob, m.getParameters());
} catch (InvocationTargetException ITe) {
- if (DBusConnection.EXCEPTION_DEBUG) ITe.getCause().printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, ITe.getCause());
throw ITe.getCause();
}
synchronized (infomap) {
@@ -1167,14 +1151,14 @@ public class DBusConnection
}
}
} catch (DBusExecutionException DBEe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
try {
synchronized (outqueue) {
outqueue.add(new Error(m, DBEe));
}
} catch (DBusException DBe) {}
} catch (Throwable e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
try {
synchronized (outqueue) {
outqueue.add(new Error(m, new DBusExecutionException("Error Executing Method "+m.getInterface()+"."+m.getName()+": "+e.getMessage())));
@@ -1187,7 +1171,7 @@ public class DBusConnection
@SuppressWarnings({"unchecked","deprecation"})
private void handleMessage(final DBusSignal s)
{
- if (Debug.debug) Debug.print("Handling incoming signal: "+s);
+ if (Debug.debug) Debug.print(Debug.ERR, "Handling incoming signal: "+s);
Vector<DBusSigHandler> v = new Vector<DBusSigHandler>();
synchronized(handledSignals) {
Vector<DBusSigHandler> t;
@@ -1214,7 +1198,7 @@ public class DBusConnection
rs = s;
h.handle(rs);
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
try {
synchronized (outqueue) {
outqueue.add(new Error(s, new DBusExecutionException("Error handling signal "+s.getInterface()+"."+s.getName()+": "+DBe.getMessage())));
@@ -1226,7 +1210,7 @@ public class DBusConnection
}
private void handleMessage(final Error err)
{
- if (Debug.debug) Debug.print("Handling incoming error: "+err);
+ if (Debug.debug) Debug.print(Debug.ERR, "Handling incoming error: "+err);
MethodCall m = null;
if (null == pendingCalls) return;
synchronized (pendingCalls) {
@@ -1241,7 +1225,7 @@ public class DBusConnection
}
private void handleMessage(final MethodReturn mr)
{
- if (Debug.debug) Debug.print("Handling incoming method return: "+mr);
+ if (Debug.debug) Debug.print(Debug.ERR, "Handling incoming method return: "+mr);
MethodCall m = null;
if (null == pendingCalls) return;
synchronized (pendingCalls) {
@@ -1275,7 +1259,7 @@ public class DBusConnection
}
}
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
if (m instanceof MethodCall && e instanceof DBusExecutionException)
try {
((MethodCall)m).setReply(new Error(m, e));
@@ -1289,11 +1273,9 @@ public class DBusConnection
try {
transport.mout.writeMessage(new Error(m, e));
} catch(IOException IOe) {
- if (EXCEPTION_DEBUG)
- IOe.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
} catch(DBusException IOe) {
- if (EXCEPTION_DEBUG)
- e.printStackTrace();
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
}
}
}
diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java
index bec9da5..68598d9 100644
--- a/org/freedesktop/dbus/DBusSignal.java
+++ b/org/freedesktop/dbus/DBusSignal.java
@@ -129,7 +129,7 @@ public class DBusSignal extends Message
s.bytecounter = wiredata.length;
return s;
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusException(e.getMessage());
}
}
@@ -187,8 +187,7 @@ public class DBusSignal extends Message
headers.put(Message.HeaderField.SIGNATURE,sig);
setArgs(args);
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG)
- e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusException("Failed to add signal parameters: "+e.getMessage());
}
}
diff --git a/org/freedesktop/dbus/EfficientQueue.java b/org/freedesktop/dbus/EfficientQueue.java
index 22480e1..58641c2 100644
--- a/org/freedesktop/dbus/EfficientQueue.java
+++ b/org/freedesktop/dbus/EfficientQueue.java
@@ -46,16 +46,16 @@ class EfficientQueue
public Message[] getKeys()
{
if (start == end) return new Message[0];
- int size;
- if (start < end) size = end-start-1;
- else size = mv.length-(start-end);
- Message[] lv = new Message[size];
- if (Debug.debug) Debug.print(Debug.VERBOSE, "start: "+start+" end: "+end);
- if (Debug.debug) Debug.print(Debug.VERBOSE, "System.arraycopy({0..."+mv.length+"},"+start+",{0..."+lv.length+"},0,"+(mv.length-start)+");");
- System.arraycopy(mv,start,lv,0,mv.length-start);
- if (end != (mv.length-1)) {
- if (Debug.debug) Debug.print(Debug.VERBOSE, "System.arraycopy({0..."+mv.length+"},0,{0..."+lv.length+"},"+(mv.length-start)+","+(end+1)+");");
- System.arraycopy(mv,0,lv,mv.length-start,end+1);
+ Message[] lv;
+ if (start < end) {
+ int size = end-start;
+ lv = new Message[size];
+ System.arraycopy(mv, start, lv, 0, size);
+ } else {
+ int size = mv.length-start+end;
+ lv = new Message[size];
+ System.arraycopy(mv, start, lv, 0, mv.length-start);
+ System.arraycopy(mv, 0, lv, mv.length-start, end);
}
return lv;
}
diff --git a/org/freedesktop/dbus/Error.java b/org/freedesktop/dbus/Error.java
index af17262..663ae6b 100644
--- a/org/freedesktop/dbus/Error.java
+++ b/org/freedesktop/dbus/Error.java
@@ -16,6 +16,8 @@ import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.exceptions.MessageFormatException;
+import cx.ath.matthew.debug.Debug;
+
/**
* Error messages which can be sent over the bus.
*/
@@ -89,9 +91,9 @@ public class Error extends Message
ex.setType(getName());
return ex;
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
- if (DBusConnection.EXCEPTION_DEBUG && null != e.getCause())
- e.getCause().printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug && null != e.getCause())
+ Debug.print(Debug.ERR, e.getCause());
DBusExecutionException ex;
Object[] args = null;
try {
diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java
index a68de13..67bb614 100644
--- a/org/freedesktop/dbus/Marshalling.java
+++ b/org/freedesktop/dbus/Marshalling.java
@@ -116,7 +116,7 @@ public class Marshalling
if (s.length != 1) throw new DBusException("Multi-valued array types not permitted");
out[level].append(s[0]);
} catch (ArrayIndexOutOfBoundsException AIOOBe) {
- if (DBusConnection.EXCEPTION_DEBUG) AIOOBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, AIOOBe);
throw new DBusException("Map must have 2 parameters");
}
out[level].append('}');
@@ -317,7 +317,7 @@ public class Marshalling
}
return i;
} catch (IndexOutOfBoundsException IOOBe) {
- if (DBusConnection.EXCEPTION_DEBUG) IOOBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOOBe);
throw new DBusException("Failed to parse DBus type signature: "+dbus);
}
}
@@ -495,7 +495,7 @@ public class Marshalling
System.arraycopy(parameters, i + newtypes.length, compress, i+1, parameters.length - i - newtypes.length);
parameters = compress;
} catch (ArrayIndexOutOfBoundsException AIOOBe) {
- if (DBusConnection.EXCEPTION_DEBUG) AIOOBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, AIOOBe);
throw new DBusException("Not enough elements to create custom object from serialized data ("+(parameters.length-i)+" < "+(newtypes.length)+")");
}
}
diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java
index 522b613..0edc902 100644
--- a/org/freedesktop/dbus/Message.java
+++ b/org/freedesktop/dbus/Message.java
@@ -12,6 +12,7 @@ package org.freedesktop.dbus;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
+import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -407,8 +408,7 @@ public class Message
try {
args = getParameters();
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG)
- DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
}
if (null == args || 0 == args.length)
sb.append('}');
@@ -509,9 +509,16 @@ public class Message
// Strings are marshalled as a UInt32 with the length,
// followed by the String, followed by a null byte.
String payload = data.toString();
- if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending String of length "+payload.length());
- appendint(payload.length(), 4);
- appendBytes(payload.getBytes());
+ byte[] payloadbytes = null;
+ try {
+ payloadbytes = payload.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException UEe) {
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(UEe);
+ throw new DBusException("System does not support UTF-8 encoding");
+ }
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Appending String of length "+payloadbytes.length);
+ appendint(payloadbytes.length, 4);
+ appendBytes(payloadbytes);
appendBytes(padding[1]);
//pad(ArgumentType.STRING);? do we need this?
break;
@@ -650,7 +657,7 @@ public class Message
}
return i;
} catch (ClassCastException CCe) {
- if (DBusConnection.EXCEPTION_DEBUG) CCe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, CCe);
throw new MarshallingException("Trying to marshall to unconvertable type (from "+data.getClass().getName()+" to "+sigb[sigofs]+")");
}
}
@@ -904,7 +911,12 @@ public class Message
case ArgumentType.STRING:
length = (int) demarshallint(buf, ofs[1], 4);
ofs[1] += 4;
- rv = new String(buf, ofs[1], length);
+ try {
+ rv = new String(buf, ofs[1], length, "UTF-8");
+ } catch (UnsupportedEncodingException UEe) {
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(UEe);
+ throw new DBusException("System does not support UTF-8 encoding");
+ }
ofs[1] += length + 1;
break;
case ArgumentType.OBJECT_PATH:
diff --git a/org/freedesktop/dbus/MessageReader.java b/org/freedesktop/dbus/MessageReader.java
index e415571..8cb4498 100644
--- a/org/freedesktop/dbus/MessageReader.java
+++ b/org/freedesktop/dbus/MessageReader.java
@@ -126,7 +126,7 @@ public class MessageReader
default:
throw new MessageTypeException("Message type "+type+" unsupported");
}
- if (DBusConnection.DBUS_JAVA_DEBUG && Debug.debug) {
+ if (Debug.debug) {
Debug.print(Debug.VERBOSE, Hexdump.format(buf));
Debug.print(Debug.VERBOSE, Hexdump.format(tbuf));
Debug.print(Debug.VERBOSE, Hexdump.format(header));
@@ -135,23 +135,21 @@ public class MessageReader
try {
m.populate(buf, header, body);
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG)
- DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
buf = null;
tbuf = null;
body = null;
header = null;
throw DBe;
} catch (RuntimeException Re) {
- if (DBusConnection.EXCEPTION_DEBUG)
- Re.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, Re);
buf = null;
tbuf = null;
body = null;
header = null;
throw Re;
}
- if (DBusConnection.DBUS_JAVA_DEBUG && Debug.debug) {
+ if (Debug.debug) {
Debug.print(Debug.INFO, "=> "+m);
}
buf = null;
diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java
index 1aff022..773d6cc 100644
--- a/org/freedesktop/dbus/MessageWriter.java
+++ b/org/freedesktop/dbus/MessageWriter.java
@@ -26,7 +26,7 @@ public class MessageWriter
}
public void writeMessage(Message m) throws IOException
{
- if (DBusConnection.DBUS_JAVA_DEBUG && Debug.debug) {
+ if (Debug.debug) {
Debug.print(Debug.INFO, "<= "+m);
}
for (byte[] buf: m.getWireData()) {
diff --git a/org/freedesktop/dbus/MethodCall.java b/org/freedesktop/dbus/MethodCall.java
index bb09f6a..d5bcd92 100644
--- a/org/freedesktop/dbus/MethodCall.java
+++ b/org/freedesktop/dbus/MethodCall.java
@@ -21,7 +21,7 @@ public class MethodCall extends Message
MethodCall() { }
public MethodCall(String dest, String path, String iface, String member, byte flags, String sig, Object... args) throws DBusException
{
- super(Message.Endian.LITTLE, Message.MessageType.METHOD_CALL, flags);
+ super(Message.Endian.BIG, Message.MessageType.METHOD_CALL, flags);
if (null == dest || null == member || null == path)
throw new MessageFormatException("Must specify destination, path and function name to MethodCalls.");
diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java
index d62df31..d38ab62 100644
--- a/org/freedesktop/dbus/RemoteInvocationHandler.java
+++ b/org/freedesktop/dbus/RemoteInvocationHandler.java
@@ -26,6 +26,8 @@ import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.exceptions.NotConnected;
+import cx.ath.matthew.debug.Debug;
+
class RemoteInvocationHandler implements InvocationHandler
{
public static Object convertRV(String sig, Object[] rp, Method m, DBusConnection conn) throws DBusException
@@ -48,7 +50,7 @@ class RemoteInvocationHandler implements InvocationHandler
new Type[] { m.getGenericReturnType() }, conn);
}
catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusExecutionException("Wrong return type (failed to de-serialize correct types: "+e.getMessage()+")");
}
@@ -61,15 +63,14 @@ class RemoteInvocationHandler implements InvocationHandler
try {
rp = Marshalling.deSerializeParameters(rp, ((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments(), conn);
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusExecutionException("Wrong return type (failed to de-serialize correct types: "+e.getMessage()+")");
}
Constructor cons = c.getConstructors()[0];
try {
return cons.newInstance(rp);
} catch (Exception e) {
- if (DBusConnection.EXCEPTION_DEBUG)
- e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusException(e.getMessage());
}
}
@@ -95,8 +96,7 @@ class RemoteInvocationHandler implements InvocationHandler
else
call = new MethodCall(ro.busname, ro.objectpath, DBusConnection.dollar_pattern.matcher(ro.iface.getName()).replaceAll("."), m.getName(), flags, sig, args);
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG)
- DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
throw new DBusExecutionException("Failed to construct outgoing method call: "+DBe.getMessage());
}
if (null == conn.outgoing) throw new NotConnected("Not Connected");
@@ -118,7 +118,7 @@ class RemoteInvocationHandler implements InvocationHandler
try {
return convertRV(reply.getSig(), reply.getParameters(), m, conn);
} catch (DBusException e) {
- if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
throw new DBusExecutionException(e.getMessage());
}
}
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java
index 2f29ece..95b1aec 100644
--- a/org/freedesktop/dbus/Transport.java
+++ b/org/freedesktop/dbus/Transport.java
@@ -67,6 +67,7 @@ public class Transport
}
public void connect(BusAddress address) throws IOException
{
+ if (Debug.debug) Debug.print(Debug.INFO, "Connecting to "+address);
this.address = address;
OutputStream out = null;
InputStream in = null;
diff --git a/org/freedesktop/dbus/UInt64.java b/org/freedesktop/dbus/UInt64.java
index 3402626..a230485 100644
--- a/org/freedesktop/dbus/UInt64.java
+++ b/org/freedesktop/dbus/UInt64.java
@@ -22,11 +22,6 @@ import java.math.BigInteger;
@SuppressWarnings("serial")
public class UInt64 extends Number implements Comparable<UInt64>
{
- /** Maximum allowed value (when accessed as a long)
- * @deprecated You should explicitly compare MAX_LONG_VALUE or MAX_BIG_VALUE
- * depending which you mean. */
- @Deprecated()
- public static final long MAX_VALUE = Long.MAX_VALUE;
/** Maximum allowed value (when accessed as a long) */
public static final long MAX_LONG_VALUE = Long.MAX_VALUE;
/** Maximum allowed value (when accessed as a BigInteger) */
diff --git a/org/freedesktop/dbus/Variant.java b/org/freedesktop/dbus/Variant.java
index dc63bf7..ebbc1e8 100644
--- a/org/freedesktop/dbus/Variant.java
+++ b/org/freedesktop/dbus/Variant.java
@@ -14,6 +14,8 @@ import java.lang.reflect.Type;
import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
+import cx.ath.matthew.debug.Debug;
+
/**
* A Wrapper class for Variant values.
* A method on DBus can send or receive a Variant.
@@ -40,7 +42,7 @@ public class Variant<T>
throw new IllegalArgumentException("Can't wrap a multi-valued type in a Variant ("+type+")");
this.sig = ss[0];
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
throw new IllegalArgumentException("Can't wrap "+o.getClass()+" in an unqualified Variant ("+DBe.getMessage()+")");
}
this.o = o;
@@ -61,7 +63,7 @@ public class Variant<T>
throw new IllegalArgumentException("Can't wrap a multi-valued type in a Variant ("+type+")");
this.sig = ss[0];
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
throw new IllegalArgumentException("Can't wrap a "+type+" in a Variant ("+DBe.getMessage()+")");
}
this.o = o;
@@ -83,7 +85,7 @@ public class Variant<T>
throw new IllegalArgumentException("Can't wrap multiple or no types in a Variant ("+sig+")");
this.type = ts.get(0);
} catch (DBusException DBe) {
- if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace();
+ if (DBusConnection.EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBe);
throw new IllegalArgumentException("Can't wrap a "+sig+" in a Variant ("+DBe.getMessage()+")");
}
this.o = o;
diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java
index 1e51e9f..cbadf13 100644
--- a/org/freedesktop/dbus/test/test.java
+++ b/org/freedesktop/dbus/test/test.java
@@ -18,6 +18,8 @@ import java.util.List;
import java.util.Map;
import java.util.Vector;
+import java.text.Collator;
+
import org.freedesktop.dbus.DBusAsyncReply;
import org.freedesktop.dbus.DBusCallInfo;
import org.freedesktop.dbus.DBusConnection;
@@ -139,7 +141,7 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal
}
public String getName()
{
- return "This Is A Name!!";
+ return "This Is A UTF-8 Name: س !!";
}
public boolean check()
{
@@ -429,7 +431,10 @@ public class test
/** Call the remote object and get a response. */
String rname = tri.getName();
System.out.println("Got Remote Name: "+rname);
- if (!"This Is A Name!!".equals(rname))
+ Collator col = Collator.getInstance();
+ col.setDecomposition(Collator.FULL_DECOMPOSITION);
+ col.setStrength(Collator.PRIMARY);
+ if (0 != col.compare("This Is A UTF-8 Name: ﺱ !!", rname))
fail("getName return value incorrect");
System.out.println("sending it to sleep");
tri.waitawhile();
@@ -560,7 +565,7 @@ public class test
System.out.print("testing recursion...");
- if (!"This Is A Name!!".equals(tri2.recursionTest())) fail("recursion test failed");
+ if (0 != col.compare("This Is A UTF-8 Name: ﺱ !!",tri2.recursionTest())) fail("recursion test failed");
System.out.println("done");