diff options
28 files changed, 239 insertions, 153 deletions
@@ -57,11 +57,11 @@ testclasses: .testclasses viewerclasses: .viewerclasses .testclasses: $(SRCDIR)/dbus/test/*.java .classes mkdir -p classes - $(JAVAC) -d classes $(JCFLAGS) $(SRCDIR)/dbus/test/*.java + $(JAVAC) -cp classes:${JAVAUNIXJARDIR}/debug-$(DEBUG).jar:${JAVAUNIXJARDIR}/hexdump.jar:$(CLASSPATH) -d classes $(JCFLAGS) $(SRCDIR)/dbus/test/*.java touch .testclasses .viewerclasses: $(SRCDIR)/dbus/viewer/*.java .classes mkdir -p classes - $(JAVAC) -d classes $(JCFLAGS) $(SRCDIR)/dbus/viewer/*.java + $(JAVAC) -cp classes:$(CLASSPATH) -d classes $(JCFLAGS) $(SRCDIR)/dbus/viewer/*.java touch .viewerclasses .classes: $(SRCDIR)/*.java $(SRCDIR)/dbus/*.java $(SRCDIR)/dbus/exceptions/*.java $(SRCDIR)/dbus/types/*.java $(SRCDIR)/dbus/bin/*.java mkdir -p classes @@ -107,25 +107,25 @@ bin/%: %.sh .bin sed 's,\%JARPATH\%,$(JARPREFIX),;s,\%JAVAUNIXJARPATH\%,$(JAVAUNIXJARDIR),;s,\%JAVAUNIXLIBPATH\%,$(JAVAUNIXLIBDIR),' < $< > $@ testrun: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.test + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.test cross-test-server: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.cross_test_server + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.cross_test_server cross-test-client: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.cross_test_client + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.cross_test_client two-part-server: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.two_part_test_server + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.two_part_test_server two-part-client: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.two_part_test_client + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.two_part_test_client profilerun: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.profile $(PROFILE) + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-test-$(VERSION).jar org.freedesktop.dbus.test.profile $(PROFILE) viewer: libdbus-java-$(VERSION).jar dbus-java-viewer-$(VERSION).jar - $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:libdbus-java-$(VERSION).jar:dbus-java-viewer-$(VERSION).jar org.freedesktop.dbus.viewer.DBusViewer + $(JAVA) $(JFLAGS) $(CPFLAG) $(CLASSPATH):$(JAVAUNIXJARDIR)/unix.jar:$(JAVAUNIXJARDIR)/hexdump.jar:$(JAVAUNIXJARDIR)/debug-$(DEBUG).jar:libdbus-java-$(VERSION).jar:dbus-java-viewer-$(VERSION).jar org.freedesktop.dbus.viewer.DBusViewer check: libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar ( PASS=false; \ diff --git a/org/freedesktop/dbus/DBusAsyncReply.java b/org/freedesktop/dbus/DBusAsyncReply.java index 6d21d6b..b39bd0d 100644 --- a/org/freedesktop/dbus/DBusAsyncReply.java +++ b/org/freedesktop/dbus/DBusAsyncReply.java @@ -42,10 +42,12 @@ public class DBusAsyncReply<ReturnType> private DBusExecutionException error = null; private MethodCall mc; private Method me; - DBusAsyncReply(MethodCall mc, Method me) + private DBusConnection conn; + DBusAsyncReply(MethodCall mc, Method me, DBusConnection conn) { this.mc = mc; this.me = me; + this.conn = conn; } @SuppressWarnings("unchecked") private synchronized void checkReply() @@ -56,7 +58,7 @@ public class DBusAsyncReply<ReturnType> error = ((Error) m).getException(); else if (m instanceof MethodReturn) { try { - rval = (ReturnType) RemoteInvocationHandler.convertRV(m.getSig(), m.getParameters(), me); + rval = (ReturnType) RemoteInvocationHandler.convertRV(m.getSig(), m.getParameters(), me, conn); } catch (DBusExecutionException DBEe) { error = DBEe; } catch (DBusException DBe) { diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java index e8eaaa8..6bf5695 100644 --- a/org/freedesktop/dbus/DBusConnection.java +++ b/org/freedesktop/dbus/DBusConnection.java @@ -25,6 +25,8 @@ import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; +import java.io.IOException; + import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; @@ -56,19 +58,21 @@ public class DBusConnection public void handle(DBusSignal s) { if (s instanceof org.freedesktop.DBus.Local.Disconnected) { - Error err = new Error( - busnames.get(0), "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { "Disconnected" }); - synchronized (pendingCalls) { - long[] set = pendingCalls.getKeys(); - for (long l: set) if (-1 != l) { - MethodCall m = pendingCalls.remove(l); - if (null != m) - m.setReply(err); + try { + Error err = new Error( + busnames.get(0), "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { "Disconnected" }); + synchronized (pendingCalls) { + long[] set = pendingCalls.getKeys(); + for (long l: set) if (-1 != l) { + MethodCall m = pendingCalls.remove(l); + if (null != m) + m.setReply(err); + } } - } - synchronized (pendingErrors) { - pendingErrors.add(err); - } + synchronized (pendingErrors) { + pendingErrors.add(err); + } + } catch (DBusException DBe) {} } else if (s instanceof org.freedesktop.DBus.NameAcquired) { busnames.add(((org.freedesktop.DBus.NameAcquired) s).name); } @@ -105,6 +109,10 @@ public class DBusConnection m = null; } + } catch (IOException IOe) { + try { + handleMessage(new org.freedesktop.DBus.Local.Disconnected("/")); + } catch (Exception e) {} } catch (Exception e) { } // write to the wire @@ -225,8 +233,10 @@ 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")); } /** @@ -311,7 +321,11 @@ public class DBusConnection } addr = address; - transport = new Transport(addr); + try { + transport = new Transport(addr); + } catch (IOException IOe) { + throw new DBusException("Failed to connect to bus "+IOe.getMessage()); + } // start listening thread = new _thread(); @@ -893,7 +907,9 @@ public class DBusConnection try { synchronized (thread) { thread.wait(); } } catch (InterruptedException Ie) {} - transport.disconnect(); + try { + transport.disconnect(); + } catch (IOException IOe) {} conn.remove(addr); synchronized(workers) { for (_workerthread t: workers) @@ -979,14 +995,18 @@ public class DBusConnection } if (null == eo) { - synchronized (outgoing) { - outgoing.add(new Error(m, new DBus.Error.UnknownObject(m.getPath()+" is not an object provided by this process."))); } + try { + synchronized (outgoing) { + outgoing.add(new Error(m, new DBus.Error.UnknownObject(m.getPath()+" is not an object provided by this process."))); } + } catch (DBusException DBe) {} return; } meth = eo.methods.get(new MethodTuple(m.getName(), m.getSig())); if (null == meth) { - synchronized (outgoing) { - outgoing.add(new Error(m, new DBus.Error.UnknownMethod("The method `"+m.getInterface()+"."+m.getName()+"' does not exist on this object."))); } + try { + synchronized (outgoing) { + outgoing.add(new Error(m, new DBus.Error.UnknownMethod("The method `"+m.getInterface()+"."+m.getName()+"' does not exist on this object."))); } + } catch (DBusException DBe) {} return; } o = eo.object; @@ -998,17 +1018,21 @@ public class DBusConnection final EfficientQueue outqueue = outgoing; final boolean noreply = (1 == (m.getFlags() & Message.Flags.NO_REPLY_EXPECTED)); final DBusCallInfo info = new DBusCallInfo(m); + final DBusConnection conn = this; addRunnable(new Runnable() { public void run() { try { Type[] ts = me.getGenericParameterTypes(); - m.args = Marshalling.deSerializeParameters(m.args, ts); + m.args = Marshalling.deSerializeParameters(m.args, ts, conn); } catch (Exception e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); - synchronized (outqueue) { - outqueue.add(new Error(m, new DBus.Error.UnknownMethod("Failure in de-serializing message ("+e+")"))); } + try { + synchronized (outqueue) { + outqueue.add(new Error(m, new DBus.Error.UnknownMethod("Failure in de-serializing message ("+e+")"))); + } + } catch (DBusException DBe) {} return; } @@ -1031,7 +1055,10 @@ public class DBusConnection if (Void.TYPE.equals(me.getReturnType())) reply = new MethodReturn(m, null); else { - reply = new MethodReturn(m, Marshalling.getDBusType(me. getGenericReturnType()),result); + StringBuffer sb = new StringBuffer(); + for (String s: Marshalling.getDBusType(me. getGenericReturnType())) + sb.append(s); + reply = new MethodReturn(m, sb.toString(),result); } synchronized (outqueue) { outqueue.add(reply); @@ -1039,14 +1066,18 @@ public class DBusConnection } } catch (DBusExecutionException DBEe) { if (DBusConnection.EXCEPTION_DEBUG) DBEe.printStackTrace(); - synchronized (outqueue) { - outqueue.add(new Error(m, DBEe)); - } + try { + synchronized (outqueue) { + outqueue.add(new Error(m, DBEe)); + } + } catch (DBusException DBe) {} } catch (Throwable e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); - synchronized (outqueue) { - outqueue.add(new Error(m, new DBusExecutionException("Error Executing Method "+m.getInterface()+"."+m.getName()+": "+e.getMessage()))); - } + try { + synchronized (outqueue) { + outqueue.add(new Error(m, new DBusExecutionException("Error Executing Method "+m.getInterface()+"."+m.getName()+": "+e.getMessage()))); + } + } catch (DBusException DBe) {} } } }); @@ -1076,9 +1107,11 @@ public class DBusConnection h.handle(rs); } catch (DBusException DBe) { if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace(); - synchronized (outqueue) { - outqueue.add(new Error(s, new DBusExecutionException("Error handling signal "+s.getInterface()+"."+s.getName()+": "+DBe.getMessage()))); - } + try { + synchronized (outqueue) { + outqueue.add(new Error(s, new DBusExecutionException("Error handling signal "+s.getInterface()+"."+s.getName()+": "+DBe.getMessage()))); + } + } catch (DBusException DBe2) {} } } } }); @@ -1107,9 +1140,11 @@ public class DBusConnection m.setReply(mr); mr.setCall(m); } else - synchronized (outgoing) { - outgoing.add(new Error(mr, new DBusExecutionException("Spurious reply. No message with the given serial id was awaiting a reply."))); - } + try { + synchronized (outgoing) { + outgoing.add(new Error(mr, new DBusExecutionException("Spurious reply. No message with the given serial id was awaiting a reply."))); + } + } catch (DBusException DBe) {} } private void sendMessage(Message m) { @@ -1124,15 +1159,21 @@ public class DBusConnection } catch (Exception e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); if (m instanceof MethodCall && e instanceof DBusExecutionException) - m.setReply(new Error(m, e)); + try { + ((MethodCall)m).setReply(new Error(m, e)); + } catch (DBusException DBe) {} else if (m instanceof MethodCall) - - m.setReply(new Error(m, new DBusExecutionException("Message Failed to Send: "+e.getMessage()))); + try { + ((MethodCall)m).setReply(new Error(m, new DBusExecutionException("Message Failed to Send: "+e.getMessage()))); + } catch (DBusException DBe) {} else if (m instanceof MethodReturn) - transport.mout.write(new Error(m, Message.ArgumentType.STRING_STRING, "Error sending reply: "+e. getMessage())); + try { + transport.mout.writeMessage(new Error(m, e)); + } catch(IOException IOe) { + } catch(DBusException IOe) {} } } - private Message readIncoming(int timeoutms, EfficientQueue outgoing) + private Message readIncoming(int timeoutms, EfficientQueue outgoing) throws IOException, DBusException { // TODO do something with timeoutms and outgoing Message m = transport.min.readMessage(); diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java index 1b652b5..ac9d3c0 100644 --- a/org/freedesktop/dbus/DBusSignal.java +++ b/org/freedesktop/dbus/DBusSignal.java @@ -22,7 +22,7 @@ import org.freedesktop.dbus.exceptions.DBusException; public class DBusSignal extends Message { DBusSignal() { } - public DBusSignal(String path, String iface, String member, String sig, Object... args) + public DBusSignal(String path, String iface, String member, String sig, Object... args) throws DBusException { super(Message.Endian.BIG, Message.MessageType.SIGNAL, (byte) 0); @@ -52,7 +52,7 @@ public class DBusSignal extends Message } private static class internalsig extends DBusSignal { - public internalsig(String source, String objectpath, String type, String name, String sig, Object[] parameters, long serial) + public internalsig(String source, String objectpath, String type, String name, String sig, Object[] parameters, long serial) throws DBusException { super(source, objectpath, type, name, sig, parameters, serial); } diff --git a/org/freedesktop/dbus/Error.java b/org/freedesktop/dbus/Error.java index 9fe3e47..f7fa2b1 100644 --- a/org/freedesktop/dbus/Error.java +++ b/org/freedesktop/dbus/Error.java @@ -10,7 +10,9 @@ */ package org.freedesktop.dbus; +import java.lang.reflect.Constructor; import java.util.Vector; +import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.DBusExecutionException; /** @@ -19,7 +21,7 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException; public class Error extends Message { Error() { } - public Error(String dest, String errorName, long replyserial, String sig, Object... args) + public Error(String dest, String errorName, long replyserial, String sig, Object... args) throws DBusException { super(Message.Endian.BIG, Message.MessageType.ERROR, (byte) 0); @@ -46,19 +48,33 @@ public class Error extends Message if (null != sig) append(sig, args); marshallint(bytecounter-c, blen, 0, 4); } - /* TODO NotNative! */ - private static native Class<? extends DBusExecutionException> createExceptionClass(String name); + public Error(Message m, Exception e) throws DBusException + { + this(m.getSource(), DBusConnection.dollar_pattern.matcher(e.getClass().getName()).replaceAll("."), m.getSerial(), "s", e.getMessage()); + } + @SuppressWarnings("unchecked") + private static Class<? extends DBusExecutionException> createExceptionClass(String name) + { + Class<? extends DBusExecutionException> c = null; + do { + try { + c = (Class<? extends org.freedesktop.dbus.exceptions.DBusExecutionException>) Class.forName(name); + } catch (ClassNotFoundException CNFe) {} + name = name.replaceAll("\\.([^\\.]*)$", "$$$1"); + } while (null == c && name.matches(".*\\..*")); + return c; + } /** * Turns this into an exception of the correct type */ public DBusExecutionException getException() { try { - Class<? extends DBusExecutionException> c = createExceptionClass(type); + Class<? extends DBusExecutionException> c = createExceptionClass(getName()); if (null == c) c = DBusExecutionException.class; Constructor<? extends DBusExecutionException> con = c.getConstructor(String.class); DBusExecutionException ex; - if (null == parameters || 0 == parameters.length) + if (null == args || 0 == args.length) ex = con.newInstance(""); else { String s = ""; @@ -66,12 +82,12 @@ public class Error extends Message s += o + " "; ex = con.newInstance(s.trim()); } - ex.setType(type); + ex.setType(getName()); return ex; } catch (Exception e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); DBusExecutionException ex; - if (null == parameters || 0 == parameters.length) + if (null == args || 0 == args.length) ex = new DBusExecutionException(""); else { String s = ""; @@ -79,7 +95,7 @@ public class Error extends Message s += o + " "; ex = new DBusExecutionException(s.trim()); } - ex.setType(type); + ex.setType(getName()); return ex; } } diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java index b31eee7..e90b649 100644 --- a/org/freedesktop/dbus/Marshalling.java +++ b/org/freedesktop/dbus/Marshalling.java @@ -39,6 +39,22 @@ public class Marshalling * Will return the DBus type corresponding to the given Java type. * Note, container type should have their ParameterizedType not their * Class passed in here. + * @param c The Java types. + * @return The DBus types. + * @throws DBusException If the given type cannot be converted to a DBus type. + */ + public static String getDBusType(Type[] c) throws DBusException + { + StringBuffer sb = new StringBuffer(); + for (Type t: c) + for (String s: getDBusType(t)) + sb.append(s); + return sb.toString(); + } + /** + * Will return the DBus type corresponding to the given Java type. + * Note, container type should have their ParameterizedType not their + * Class passed in here. * @param c The Java type. * @return The DBus type. * @throws DBusException If the given type cannot be converted to a DBus type. @@ -326,45 +342,23 @@ public class Marshalling return parameters; } @SuppressWarnings("unchecked") - static Object deSerializeParameter(Object parameter, Type type) throws Exception + static Object deSerializeParameter(Object parameter, Type type, DBusConnection conn) throws Exception { if (null == parameter) return null; - // it's a TypeSignature, turn it into a Type[] - if (parameter instanceof TypeSignature) { - Vector<Type> ts = new Vector<Type>(); - getJavaType(((TypeSignature) parameter).sig, ts, -1); - parameter = ts.toArray(new Type[0]); - } // its a wrapped variant, unwrap it if (type instanceof TypeVariable && parameter instanceof Variant) { parameter = ((Variant)parameter).getValue(); } - // recurse on these - if (parameter instanceof Variant) { - parameter = new Variant(deSerializeParameter(((Variant) parameter).getValue(), - ((Variant) parameter).getType()), - ((Variant) parameter).getType()); - } - - // its a wrapped map, unwrap it - if (parameter instanceof MapContainer) - parameter = ((MapContainer) parameter).getMap(type); - - // its a wrapped list, unwrap it - if (parameter instanceof ListContainer) { - parameter = ((ListContainer) parameter).getList(type); - } - // its an object path, get/create the proxy if (parameter instanceof ObjectPath) { if (type instanceof Class && Path.class.equals((Class) type)) parameter = new Path(((ObjectPath) parameter).path); else - parameter = ((ObjectPath) parameter).conn.getExportedObject( + parameter = conn.getExportedObject( ((ObjectPath) parameter).source, ((ObjectPath) parameter).path); } @@ -386,7 +380,7 @@ public class Marshalling } // recurse over struct contents - parameter = deSerializeParameters((Object[]) parameter, ts); + parameter = deSerializeParameters((Object[]) parameter, ts, conn); for (Constructor con: ((Class) type).getDeclaredConstructors()) { try { parameter = con.newInstance((Object[]) parameter); @@ -400,7 +394,7 @@ public class Marshalling Type[] ts = new Type[((Object[]) parameter).length]; Arrays.fill(ts, parameter.getClass().getComponentType()); parameter = deSerializeParameters((Object[]) parameter, - ts); + ts, conn); } // make sure arrays are in the correct format @@ -430,7 +424,7 @@ public class Marshalling } return parameter; } - static Object[] deSerializeParameters(Object[] parameters, Type[] types) throws Exception + static Object[] deSerializeParameters(Object[] parameters, Type[] types, DBusConnection conn) throws Exception { if (null == parameters) return null; for (int i = 0; i < parameters.length; i++) { @@ -444,7 +438,7 @@ public class Marshalling try { Object[] sub = new Object[newtypes.length]; System.arraycopy(parameters, i, sub, 0, newtypes.length); - sub = deSerializeParameters(sub, newtypes); + sub = deSerializeParameters(sub, newtypes, conn); DBusSerializable sz = (DBusSerializable) ((Class) types[i]).newInstance(); m.invoke(sz, sub); Object[] compress = new Object[parameters.length - newtypes.length + 1]; @@ -458,7 +452,7 @@ public class Marshalling } } } else - parameters[i] = deSerializeParameter(parameters[i], types[i]); + parameters[i] = deSerializeParameter(parameters[i], types[i], conn); } return parameters; } diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java index 2e0d29b..f1627bf 100644 --- a/org/freedesktop/dbus/Message.java +++ b/org/freedesktop/dbus/Message.java @@ -147,7 +147,7 @@ public class Message * @param type The message type. * @param flags Any message flags. */ - protected Message(byte endian, byte type, byte flags) + protected Message(byte endian, byte type, byte flags) throws DBusException { wiredata = new byte[BUFFERINCREMENT][]; headers = new HashMap<Byte, Object>(); @@ -174,7 +174,7 @@ public class Message * @param headers D-Bus serialized data of type a(yv) * @param body D-Bus serialized data of the signature defined in headers. */ - void populate(byte[] msg, byte[] headers, byte[] body) + void populate(byte[] msg, byte[] headers, byte[] body) throws DBusException { big = (msg[0] == Endian.BIG); type = msg[1]; @@ -550,7 +550,7 @@ public class Message appendone(new byte[] {ArgumentType.SIGNATURE}, 0, contents[0]); appendone(((String) contents[0]).getBytes(), 0, contents[1]); } else { - String sig = Marshalling.getDBusType(data.getClass()); + String sig = Marshalling.getDBusType(data.getClass())[0]; appendone(new byte[] {ArgumentType.SIGNATURE}, 0, sig); appendone((sig).getBytes(), 0, data); } @@ -622,7 +622,7 @@ public class Message * @param sig The signature(s) of the value(s). * @param data The value(s). */ - public void append(String sig, Object... data) + public void append(String sig, Object... data) throws DBusException { byte[] sigb = sig.getBytes(); int j = 0; @@ -651,7 +651,7 @@ public class Message * updated to the start of the next value ofter demarshalling. * @return The demarshalled value. */ - private Object extractone(byte[] sigb, byte[] buf, int[] ofs) + private Object extractone(byte[] sigb, byte[] buf, int[] ofs) throws DBusException { Debug.print("Extracting type: "+((char)sigb[ofs[0]])+" from offset "+ofs[1]); Object rv = null; @@ -773,6 +773,7 @@ public class Message entries.add((Object[]) extractone(sigb, buf, ofs)); } rv = new DBusMap(entries.toArray(new Object[0][])); + break; default: ofssave = ofs[0]; end = ofs[1]+size; @@ -807,15 +808,22 @@ public class Message ofs[1] = newofs[1]; break; case ArgumentType.STRING: - case ArgumentType.OBJECT_PATH: length = (int) demarshallint(buf, ofs[1], 4); ofs[1] += 4; rv = new String(buf, ofs[1], length); ofs[1] += length + 1; break; + case ArgumentType.OBJECT_PATH: + length = (int) demarshallint(buf, ofs[1], 4); + ofs[1] += 4; + rv = new ObjectPath(new String(buf, ofs[1], length), getSource()); + ofs[1] += length + 1; + break; case ArgumentType.SIGNATURE: length = (buf[ofs[1]++] & 0xFF); - rv = Marshalling.getJavaType(new String(buf, ofs[1], (int)length)); + Vector<Type> types = new Vector<Type>(); + Marshalling.getJavaType(new String(buf, ofs[1], (int)length), types, -1); + rv = types.toArray(new Type[0]); ofs[1] += length + 1; break; default: @@ -831,7 +839,7 @@ public class Message * @param ofs The offset into the data buffer to start. * @return The demarshalled value(s). */ - public Object[] extract(String sig, byte[] buf, int ofs) + public Object[] extract(String sig, byte[] buf, int ofs) throws DBusException { return extract(sig, buf, new int[] { 0, ofs }); } @@ -844,7 +852,7 @@ public class Message * updated to the start of the next value ofter demarshalling. * @return The demarshalled value(s). */ - public Object[] extract(String sig, byte[] buf, int[] ofs) + public Object[] extract(String sig, byte[] buf, int[] ofs) throws DBusException { Debug.print("extract("+sig+",#"+buf.length+", {"+ofs[0]+","+ofs[1]+"}"); Vector<Object> rv = new Vector<Object>(); diff --git a/org/freedesktop/dbus/MessageReader.java b/org/freedesktop/dbus/MessageReader.java index dbd99e7..3b68894 100644 --- a/org/freedesktop/dbus/MessageReader.java +++ b/org/freedesktop/dbus/MessageReader.java @@ -16,6 +16,7 @@ import java.io.IOException; import cx.ath.matthew.debug.Debug; import cx.ath.matthew.utils.Hexdump; +import org.freedesktop.dbus.exceptions.DBusException; import org.freedesktop.dbus.exceptions.MessageTypeException; import org.freedesktop.dbus.exceptions.MessageProtocolVersionException; @@ -26,7 +27,7 @@ public class MessageReader { this.in = in; } - public Message readMessage() throws IOException + public Message readMessage() throws IOException, DBusException { byte[] buf = new byte[12]; in.read(buf); @@ -64,9 +65,12 @@ public class MessageReader throw new MessageTypeException("Message type "+type+" unsupported"); } m.populate(buf, header, body); + if (DBusConnection.DBUS_JAVA_DEBUG && Debug.debug) { + Debug.print("=> "+m); + } return m; } - public void close() + public void close() throws IOException { in.close(); } diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java index ddff3fe..321a358 100644 --- a/org/freedesktop/dbus/MessageWriter.java +++ b/org/freedesktop/dbus/MessageWriter.java @@ -25,6 +25,9 @@ public class MessageWriter } public void writeMessage(Message m) throws IOException { + if (DBusConnection.DBUS_JAVA_DEBUG && Debug.debug) { + Debug.print("<= "+m); + } for (byte[] buf: m.getWireData()) { if (null == buf) break; Hexdump.print(buf); @@ -32,7 +35,7 @@ public class MessageWriter } out.flush(); } - public void close() + public void close() throws IOException { out.close(); } diff --git a/org/freedesktop/dbus/MethodCall.java b/org/freedesktop/dbus/MethodCall.java index 7b7ea90..215d320 100644 --- a/org/freedesktop/dbus/MethodCall.java +++ b/org/freedesktop/dbus/MethodCall.java @@ -11,11 +11,12 @@ package org.freedesktop.dbus; import java.util.Vector; +import org.freedesktop.dbus.exceptions.DBusException; public class MethodCall extends Message { MethodCall() { } - public MethodCall(String dest, String path, String iface, String member, byte flags, String sig, Object... args) + public MethodCall(String dest, String path, String iface, String member, byte flags, String sig, Object... args) throws DBusException { super(Message.Endian.BIG, Message.MessageType.METHOD_CALL, flags); diff --git a/org/freedesktop/dbus/MethodReturn.java b/org/freedesktop/dbus/MethodReturn.java index 84bf874..0ac1d51 100644 --- a/org/freedesktop/dbus/MethodReturn.java +++ b/org/freedesktop/dbus/MethodReturn.java @@ -11,11 +11,12 @@ package org.freedesktop.dbus; import java.util.Vector; +import org.freedesktop.dbus.exceptions.DBusException; public class MethodReturn extends Message { MethodReturn() { } - public MethodReturn(String dest, long replyserial, String sig, Object... args) + public MethodReturn(String dest, long replyserial, String sig, Object... args) throws DBusException { super(Message.Endian.BIG, Message.MessageType.METHOD_RETURN, (byte) 0); @@ -41,7 +42,7 @@ public class MethodReturn extends Message if (null != sig) append(sig, args); marshallint(bytecounter-c, blen, 0, 4); } - public MethodReturn(MethodCall mc, String sig, Object... args) + public MethodReturn(MethodCall mc, String sig, Object... args) throws DBusException { this(mc.getSource(), mc.getReplySerial(), sig, args); this.call = mc; diff --git a/org/freedesktop/dbus/ObjectPath.java b/org/freedesktop/dbus/ObjectPath.java index ffcc84e..cb9756d 100644 --- a/org/freedesktop/dbus/ObjectPath.java +++ b/org/freedesktop/dbus/ObjectPath.java @@ -14,11 +14,11 @@ class ObjectPath { public String source; public String path; - public DBusConnection conn; - public ObjectPath(String source, String path, DBusConnection conn) +// public DBusConnection conn; + public ObjectPath(String source, String path/*, DBusConnection conn*/) { - this.conn = conn; this.source = source; this.path = path; + // this.conn = conn; } } diff --git a/org/freedesktop/dbus/RemoteInvocationHandler.java b/org/freedesktop/dbus/RemoteInvocationHandler.java index 3740c16..7cb8072 100644 --- a/org/freedesktop/dbus/RemoteInvocationHandler.java +++ b/org/freedesktop/dbus/RemoteInvocationHandler.java @@ -27,7 +27,7 @@ import org.freedesktop.dbus.exceptions.DBusExecutionException; class RemoteInvocationHandler implements InvocationHandler { - public static Object convertRV(String sig, Object[] rp, Method m) throws DBusException + public static Object convertRV(String sig, Object[] rp, Method m, DBusConnection conn) throws DBusException { Class c = m.getReturnType(); @@ -45,7 +45,7 @@ class RemoteInvocationHandler implements InvocationHandler try { rp = Marshalling.deSerializeParameters(rp, - new Type[] { m.getGenericReturnType() }); + new Type[] { m.getGenericReturnType() }, conn); } catch (Exception e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); @@ -59,7 +59,7 @@ class RemoteInvocationHandler implements InvocationHandler if (!Tuple.class.isAssignableFrom(c)) throw new DBusExecutionException("Wrong return type (not expecting Tuple)"); try { - rp = Marshalling.deSerializeParameters(rp, ((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments()); + rp = Marshalling.deSerializeParameters(rp, ((ParameterizedType) m.getGenericReturnType()).getActualTypeArguments(), conn); } catch (Exception e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); throw new DBusExecutionException("Wrong return type (failed to de-serialize correct types: "+e.getMessage()+")"); @@ -77,21 +77,30 @@ class RemoteInvocationHandler implements InvocationHandler public static Object executeRemoteMethod(RemoteObject ro, Method m, DBusConnection conn, boolean async, Object... args) throws DBusExecutionException { Type[] ts = m.getGenericParameterTypes(); - String sig = Marshalling.getDBusType(ts); + String sig = null; + try { + sig = Marshalling.getDBusType(ts); + } catch (DBusException DBe) { + throw new DBusExecutionException("Failed to construct D-Bus type: "+DBe.getMessage()); + } MethodCall call; - byte flags; + byte flags = 0; if (!ro.autostart) flags |= Message.Flags.NO_AUTO_START; if (async) flags |= Message.Flags.ASYNC; if (m.isAnnotationPresent(DBus.Method.NoReply.class)) flags |= Message.Flags.NO_REPLY_EXPECTED; - if (null == ro.iface) - call = new MethodCall(ro.busname, ro.objectpath, null, m.getName(),flags, sig, args); - else - call = new MethodCall(ro.busname, ro.objectpath, DBusConnection.dollar_pattern.matcher(ro.iface.getName()).replaceAll("."), m.getName(), flags, sig, args); + try { + if (null == ro.iface) + call = new MethodCall(ro.busname, ro.objectpath, null, m.getName(),flags, sig, args); + else + call = new MethodCall(ro.busname, ro.objectpath, DBusConnection.dollar_pattern.matcher(ro.iface.getName()).replaceAll("."), m.getName(), flags, sig, args); + } catch (DBusException DBe) { + throw new DBusExecutionException("Failed to construct outgoing method call: "+DBe.getMessage()); + } synchronized (conn.outgoing) { conn.outgoing.add(call); } - if (async) return new DBusAsyncReply(call, m); + if (async) return new DBusAsyncReply(call, m, conn); // get reply if (m.isAnnotationPresent(DBus.Method.NoReply.class)) return null; @@ -103,7 +112,7 @@ class RemoteInvocationHandler implements InvocationHandler ((Error) reply).throwException(); try { - return convertRV(reply.getSig(), reply.getParameters(), m); + return convertRV(reply.getSig(), reply.getParameters(), m, conn); } catch (DBusException e) { if (DBusConnection.EXCEPTION_DEBUG) e.printStackTrace(); throw new DBusExecutionException(e.getMessage()); diff --git a/org/freedesktop/dbus/exceptions/DBusExecutionException.java b/org/freedesktop/dbus/exceptions/DBusExecutionException.java index 711e63d..18d7983 100644 --- a/org/freedesktop/dbus/exceptions/DBusExecutionException.java +++ b/org/freedesktop/dbus/exceptions/DBusExecutionException.java @@ -24,7 +24,7 @@ public class DBusExecutionException extends RuntimeException { super(message); } - void setType(String type) + public void setType(String type) { this.type = type; } diff --git a/org/freedesktop/dbus/test/Profiler.java b/org/freedesktop/dbus/test/Profiler.java index df04d25..c8f7799 100644 --- a/org/freedesktop/dbus/test/Profiler.java +++ b/org/freedesktop/dbus/test/Profiler.java @@ -10,9 +10,9 @@ */ package org.freedesktop.dbus.test; -import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.DBusInterface; import org.freedesktop.dbus.DBusSignal; +import org.freedesktop.dbus.exceptions.DBusException; import java.util.List; import java.util.Map; diff --git a/org/freedesktop/dbus/test/TestException.java b/org/freedesktop/dbus/test/TestException.java index bc4eb4b..a0c696f 100644 --- a/org/freedesktop/dbus/test/TestException.java +++ b/org/freedesktop/dbus/test/TestException.java @@ -10,8 +10,8 @@ */ package org.freedesktop.dbus.test; -import org.freedesktop.dbus.DBusExecutionException; import org.freedesktop.DBus.Description; +import org.freedesktop.dbus.exceptions.DBusExecutionException; @Description("A test exception to throw over DBus") @SuppressWarnings("serial") diff --git a/org/freedesktop/dbus/test/TestSerializable.java b/org/freedesktop/dbus/test/TestSerializable.java index 3ac3086..426b2dc 100644 --- a/org/freedesktop/dbus/test/TestSerializable.java +++ b/org/freedesktop/dbus/test/TestSerializable.java @@ -16,8 +16,9 @@ import java.util.List; import java.util.Vector; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.DBusSerializable; +import org.freedesktop.dbus.Marshalling; +import org.freedesktop.dbus.exceptions.DBusException; public class TestSerializable<A> implements DBusSerializable { @@ -39,7 +40,7 @@ public class TestSerializable<A> implements DBusSerializable } public Object[] serialize() throws DBusException { - return DBusConnection.convertParameters(new Object[] { a, b, c }, new Type[] { TestSerializable.class }); + return Marshalling.convertParameters(new Object[] { a, b, c }, new Type[] { TestSerializable.class }); } public int getInt() { return a; } public String getString() { return b; } diff --git a/org/freedesktop/dbus/test/TestSignalInterface.java b/org/freedesktop/dbus/test/TestSignalInterface.java index 35ccec8..fb35b86 100644 --- a/org/freedesktop/dbus/test/TestSignalInterface.java +++ b/org/freedesktop/dbus/test/TestSignalInterface.java @@ -10,12 +10,12 @@ */ package org.freedesktop.dbus.test; -import org.freedesktop.dbus.DBusException; +import org.freedesktop.DBus.Description; import org.freedesktop.dbus.DBusInterface; import org.freedesktop.dbus.DBusSignal; import org.freedesktop.dbus.UInt32; import org.freedesktop.dbus.Variant; -import org.freedesktop.DBus.Description; +import org.freedesktop.dbus.exceptions.DBusException; import java.util.List; diff --git a/org/freedesktop/dbus/test/TestStruct2.java b/org/freedesktop/dbus/test/TestStruct2.java index a39a727..adea4d9 100644 --- a/org/freedesktop/dbus/test/TestStruct2.java +++ b/org/freedesktop/dbus/test/TestStruct2.java @@ -10,10 +10,10 @@ */ package org.freedesktop.dbus.test; -import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.Position; import org.freedesktop.dbus.Struct; import org.freedesktop.dbus.Variant; +import org.freedesktop.dbus.exceptions.DBusException; import java.util.List; diff --git a/org/freedesktop/dbus/test/TwoPartInterface.java b/org/freedesktop/dbus/test/TwoPartInterface.java index d52bf3e..829b8e6 100644 --- a/org/freedesktop/dbus/test/TwoPartInterface.java +++ b/org/freedesktop/dbus/test/TwoPartInterface.java @@ -10,9 +10,9 @@ */ package org.freedesktop.dbus.test; -import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.DBusInterface; import org.freedesktop.dbus.DBusSignal; +import org.freedesktop.dbus.exceptions.DBusException; public interface TwoPartInterface extends DBusInterface { diff --git a/org/freedesktop/dbus/test/cross_test_client.java b/org/freedesktop/dbus/test/cross_test_client.java index 98b21d9..4bac5e2 100644 --- a/org/freedesktop/dbus/test/cross_test_client.java +++ b/org/freedesktop/dbus/test/cross_test_client.java @@ -28,17 +28,17 @@ import java.util.Vector; import org.freedesktop.DBus; import org.freedesktop.dbus.DBusCallInfo; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; -import org.freedesktop.dbus.DBusExecutionException; import org.freedesktop.dbus.DBusInterface; -import org.freedesktop.dbus.DBusListType; -import org.freedesktop.dbus.DBusMapType; import org.freedesktop.dbus.DBusSigHandler; import org.freedesktop.dbus.Struct; import org.freedesktop.dbus.UInt16; import org.freedesktop.dbus.UInt32; import org.freedesktop.dbus.UInt64; import org.freedesktop.dbus.Variant; +import org.freedesktop.dbus.exceptions.DBusException; +import org.freedesktop.dbus.exceptions.DBusExecutionException; +import org.freedesktop.dbus.types.DBusListType; +import org.freedesktop.dbus.types.DBusMapType; public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHandler<DBus.Binding.TestSignals.Triggered> { @@ -62,12 +62,12 @@ public class cross_test_client implements DBus.Binding.TestCallbacks, DBusSigHan public void handle(DBus.Binding.TestSignals.Triggered t) { failed.remove("org.freedesktop.DBus.Binding.TestSignals.Triggered"); - if (new UInt64(21389479283L).equals(t.a) && "/Test".equals(t.getObjectPath())) + if (new UInt64(21389479283L).equals(t.a) && "/Test".equals(t.getPath())) pass("org.freedesktop.DBus.Binding.TestSignals.Triggered"); else if (!new UInt64(21389479283L).equals(t.a)) fail("org.freedesktop.DBus.Binding.TestSignals.Triggered", "Incorrect signal content; expected 21389479283 got "+t.a); - else if (!"/Test".equals(t.getObjectPath())) - fail("org.freedesktop.DBus.Binding.TestSignals.Triggered", "Incorrect signal source object; expected /Test got "+t.getObjectPath()); + else if (!"/Test".equals(t.getPath())) + fail("org.freedesktop.DBus.Binding.TestSignals.Triggered", "Incorrect signal source object; expected /Test got "+t.getPath()); } public void Response(UInt16 a, double b) { diff --git a/org/freedesktop/dbus/test/cross_test_server.java b/org/freedesktop/dbus/test/cross_test_server.java index 069e3a0..5b01be4 100644 --- a/org/freedesktop/dbus/test/cross_test_server.java +++ b/org/freedesktop/dbus/test/cross_test_server.java @@ -22,8 +22,6 @@ import java.util.Vector; import org.freedesktop.DBus; import org.freedesktop.dbus.DBusCallInfo; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; -import org.freedesktop.dbus.DBusExecutionException; import org.freedesktop.dbus.DBusInterface; import org.freedesktop.dbus.DBusSigHandler; import org.freedesktop.dbus.Struct; @@ -31,6 +29,8 @@ import org.freedesktop.dbus.UInt16; import org.freedesktop.dbus.UInt32; import org.freedesktop.dbus.UInt64; import org.freedesktop.dbus.Variant; +import org.freedesktop.dbus.exceptions.DBusException; +import org.freedesktop.dbus.exceptions.DBusExecutionException; public class cross_test_server implements DBus.Binding.Tests, DBus.Binding.SingleTests, DBusSigHandler<DBus.Binding.TestSignals.Trigger> { diff --git a/org/freedesktop/dbus/test/profile.java b/org/freedesktop/dbus/test/profile.java index 7acb830..f3e95e5 100644 --- a/org/freedesktop/dbus/test/profile.java +++ b/org/freedesktop/dbus/test/profile.java @@ -14,13 +14,13 @@ import java.util.Random; import java.util.HashMap; import java.util.Vector; +import org.freedesktop.DBus.Peer; +import org.freedesktop.DBus.Introspectable; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.DBusInterface; import org.freedesktop.dbus.DBusSigHandler; import org.freedesktop.dbus.UInt32; -import org.freedesktop.DBus.Peer; -import org.freedesktop.DBus.Introspectable; +import org.freedesktop.dbus.exceptions.DBusException; class ProfileHandler implements DBusSigHandler<Profiler.ProfileSignal> { diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index b4ca6b9..d5b6f7f 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -21,17 +21,18 @@ import java.util.Vector; import org.freedesktop.dbus.DBusAsyncReply; import org.freedesktop.dbus.DBusCallInfo; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; -import org.freedesktop.dbus.DBusExecutionException; import org.freedesktop.dbus.DBusInterface; -import org.freedesktop.dbus.DBusListType; import org.freedesktop.dbus.DBusSigHandler; import org.freedesktop.dbus.DBusSignal; +import org.freedesktop.dbus.Marshalling; import org.freedesktop.dbus.Path; import org.freedesktop.dbus.UInt16; import org.freedesktop.dbus.UInt32; import org.freedesktop.dbus.UInt64; import org.freedesktop.dbus.Variant; +import org.freedesktop.dbus.exceptions.DBusException; +import org.freedesktop.dbus.exceptions.DBusExecutionException; +import org.freedesktop.dbus.types.DBusListType; import org.freedesktop.DBus; import org.freedesktop.DBus.Error.MatchRuleInvalid; @@ -460,7 +461,7 @@ public class test /* Test type signatures */ Vector<Type> ts = new Vector<Type>(); - DBusConnection.getJavaType("ya{si}", ts, -1); + Marshalling.getJavaType("ya{si}", ts, -1); tri.sig(ts.toArray(new Type[0])); tri.newpathtest(new Path("/new/path/test")); diff --git a/org/freedesktop/dbus/test/test_low_level.java b/org/freedesktop/dbus/test/test_low_level.java index 553880b..9b33a75 100644 --- a/org/freedesktop/dbus/test/test_low_level.java +++ b/org/freedesktop/dbus/test/test_low_level.java @@ -1,12 +1,17 @@ package org.freedesktop.dbus.test; import cx.ath.matthew.debug.Debug; import cx.ath.matthew.utils.Hexdump; +import org.freedesktop.dbus.BusAddress; +import org.freedesktop.dbus.DBusSignal; +import org.freedesktop.dbus.Message; +import org.freedesktop.dbus.MethodCall; +import org.freedesktop.dbus.Transport; -public class test +public class test_low_level { public static void main(String[] args) throws Exception { - Message test = new MethodCall(":1.0", "/", "org.foo", "Hiii", null); + Message test = new MethodCall(":1.0", "/", "org.foo", "Hiii", (byte) 0, null); //System.exit(0); @@ -16,7 +21,7 @@ public class test Transport conn = new Transport(address); - Message m = new MethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "Hello", null); + Message m = new MethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "Hello", (byte) 0, null); conn.mout.writeMessage(m); m = conn.min.readMessage(); Debug.print(m.getClass()); @@ -24,16 +29,16 @@ public class test m = conn.min.readMessage(); Debug.print(m.getClass()); Debug.print(m); - m = new MethodCall("org.freedesktop.DBus", "/", null, "Hello", null); + m = new MethodCall("org.freedesktop.DBus", "/", null, "Hello", (byte) 0, null); conn.mout.writeMessage(m); m = conn.min.readMessage(); Debug.print(m); - m = new MethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName", "s", "org.testname"); + m = new MethodCall("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName", (byte) 0, "s", "org.testname"); conn.mout.writeMessage(m); m = conn.min.readMessage(); Debug.print(m); - m = new Signal("/foo", "org.foo", "Foo", null); + m = new DBusSignal("/foo", "org.foo", "Foo", null); conn.mout.writeMessage(m); m = conn.min.readMessage(); Debug.print(m); diff --git a/org/freedesktop/dbus/viewer/DBusViewer.java b/org/freedesktop/dbus/viewer/DBusViewer.java index a407bbb..ffabb4a 100644 --- a/org/freedesktop/dbus/viewer/DBusViewer.java +++ b/org/freedesktop/dbus/viewer/DBusViewer.java @@ -30,9 +30,9 @@ import javax.swing.table.TableModel; import org.freedesktop.DBus; import org.freedesktop.DBus.Introspectable; import org.freedesktop.dbus.DBusConnection; -import org.freedesktop.dbus.DBusException; -import org.freedesktop.dbus.DBusExecutionException; import org.freedesktop.dbus.UInt32; +import org.freedesktop.dbus.exceptions.DBusException; +import org.freedesktop.dbus.exceptions.DBusExecutionException; /** * A viewer for DBus diff --git a/org/freedesktop/dbus/viewer/IntrospectAction.java b/org/freedesktop/dbus/viewer/IntrospectAction.java index 0a6ba9e..43d68a7 100644 --- a/org/freedesktop/dbus/viewer/IntrospectAction.java +++ b/org/freedesktop/dbus/viewer/IntrospectAction.java @@ -30,7 +30,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.freedesktop.DBus.Introspectable; -import org.freedesktop.dbus.CreateInterface; +import org.freedesktop.dbus.bin.CreateInterface; @SuppressWarnings("serial") final class IntrospectAction extends AbstractAction implements ListSelectionListener diff --git a/org/freedesktop/dbus/viewer/StringStreamFactory.java b/org/freedesktop/dbus/viewer/StringStreamFactory.java index d3718c7..9960614 100644 --- a/org/freedesktop/dbus/viewer/StringStreamFactory.java +++ b/org/freedesktop/dbus/viewer/StringStreamFactory.java @@ -16,7 +16,7 @@ import java.io.PrintStream; import java.util.HashMap; import java.util.Map; -import org.freedesktop.dbus.CreateInterface.PrintStreamFactory; +import org.freedesktop.dbus.bin.CreateInterface.PrintStreamFactory; /** * A factory using a byte array input stream |