diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | changelog | 5 | ||||
-rw-r--r-- | org/freedesktop/DBus.java | 11 | ||||
-rw-r--r-- | org/freedesktop/dbus/DBusConnection.java | 11 | ||||
-rw-r--r-- | org/freedesktop/dbus/DBusSignal.java | 14 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/TestSignalInterface.java | 10 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/TwoPartInterface.java | 11 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/test.java | 26 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/two_part_test_client.java | 13 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/two_part_test_server.java | 11 |
10 files changed, 109 insertions, 8 deletions
@@ -153,6 +153,7 @@ check: ( PASS=false; \ dbus-daemon --config-file=tmp-session.conf --print-pid --print-address=5 --fork >pid 5>address ; \ export DBUS_SESSION_BUS_ADDRESS=$$(cat address) ;\ + dbus-monitor &> monitor.log & \ if make testrun ; then export PASS=true; fi ; \ kill $$(cat pid) ; \ if [[ "$$PASS" == "true" ]]; then exit 0; else exit 1; fi ) @@ -169,9 +170,9 @@ internal-cross-test: libdbus-java.so libdbus-java-$(VERSION).jar dbus-java-test- two-part-test: libdbus-java.so libdbus-java-$(VERSION).jar dbus-java-test-$(VERSION).jar ( dbus-daemon --config-file=tmp-session.conf --print-pid --print-address=5 --fork >pid 5>address ; \ export DBUS_SESSION_BUS_ADDRESS=$$(cat address) ;\ - make -s two-part-server &\ + make -s two-part-server | tee server.log &\ sleep 1;\ - make -s two-part-client ;\ + make -s two-part-client | tee client.log ;\ kill $$(cat pid) ; ) profile: @@ -1,5 +1,8 @@ Version 1.13: - + + * add AccessDenied signal + * fix deadlock issue when sending objectpaths in signals + Version 1.12: * fix internal-cross-test bugs and increase error verbosity diff --git a/org/freedesktop/DBus.java b/org/freedesktop/DBus.java index c31e579..2a078d8 100644 --- a/org/freedesktop/DBus.java +++ b/org/freedesktop/DBus.java @@ -287,6 +287,17 @@ public interface DBus extends DBusInterface super(message); } } + /** + * Thrown if a message is denied due to a security policy + */ + @SuppressWarnings("serial") + public class AccessDenied extends DBusExecutionException + { + public AccessDenied(String message) + { + super(message); + } + } } /** * Description of the interface or method, returned in the introspection data diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java index 2209e63..5b7d971 100644 --- a/org/freedesktop/dbus/DBusConnection.java +++ b/org/freedesktop/dbus/DBusConnection.java @@ -1736,10 +1736,19 @@ public class DBusConnection if (null != t) v.addAll(t); } if (0 == v.size()) return; + final EfficientQueue outqueue = outgoing; for (final DBusSigHandler h: v) addRunnable(new Runnable() { public void run() { { - h.handle(s); + try { + DBusSignal rs = s.createReal(); + h.handle(rs); + } catch (DBusException DBe) { + if (DBusConnection.EXCEPTION_DEBUG) DBe.printStackTrace(); + synchronized (outqueue) { + outqueue.add(new DBusErrorMessage(s, new DBusExecutionException("Error handling signal "+s.getType()+"."+s.getName()+": "+DBe.getMessage()))); + } + } } } }); } diff --git a/org/freedesktop/dbus/DBusSignal.java b/org/freedesktop/dbus/DBusSignal.java index 5f4486c..79e92aa 100644 --- a/org/freedesktop/dbus/DBusSignal.java +++ b/org/freedesktop/dbus/DBusSignal.java @@ -27,10 +27,18 @@ import java.lang.reflect.TypeVariable; */ public abstract class DBusSignal extends DBusMessage { + private static class internalsig extends DBusSignal + { + public internalsig(String source, String objectpath, String type, String name, String sig, Object[] parameters, long serial) + { + super(source, objectpath, type, name, sig, parameters, serial); + } + } private static Map<Class, Type[]> typeCache = new HashMap<Class, Type[]>(); private static Map<Class, Constructor> conCache = new HashMap<Class, Constructor>(); /** The path to the object this is emitted from */ protected String objectpath; + private Class<? extends DBusSignal> c; DBusSignal(String source, String objectpath, String type, String name, String sig, Object[] parameters, long serial) { super(source, type, name, sig, parameters, serial); @@ -38,6 +46,12 @@ public abstract class DBusSignal extends DBusMessage } static DBusSignal createSignal(Class<? extends DBusSignal> c, String source, String objectpath, String sig, long serial, Object... parameters) throws DBusException { + DBusSignal s = new internalsig(source, objectpath, c.getEnclosingClass().getName(), c.getSimpleName(), sig, parameters, serial); + s.c = c; + return s; + } + DBusSignal createReal() throws DBusException + { Type[] types = typeCache.get(c); Constructor con = conCache.get(c); if (null == types) { diff --git a/org/freedesktop/dbus/test/TestSignalInterface.java b/org/freedesktop/dbus/test/TestSignalInterface.java index c142937..35ccec8 100644 --- a/org/freedesktop/dbus/test/TestSignalInterface.java +++ b/org/freedesktop/dbus/test/TestSignalInterface.java @@ -50,4 +50,14 @@ public interface TestSignalInterface extends DBusInterface this.v = v; } } + @Description("Test signal sending an object path") + public static class TestObjectSignal extends DBusSignal + { + public final DBusInterface otherpath; + public TestObjectSignal(String path, DBusInterface otherpath) throws DBusException + { + super(path, otherpath); + this.otherpath = otherpath; + } + } } diff --git a/org/freedesktop/dbus/test/TwoPartInterface.java b/org/freedesktop/dbus/test/TwoPartInterface.java index b799f87..d52bf3e 100644 --- a/org/freedesktop/dbus/test/TwoPartInterface.java +++ b/org/freedesktop/dbus/test/TwoPartInterface.java @@ -10,9 +10,20 @@ */ package org.freedesktop.dbus.test; +import org.freedesktop.dbus.DBusException; import org.freedesktop.dbus.DBusInterface; +import org.freedesktop.dbus.DBusSignal; public interface TwoPartInterface extends DBusInterface { public TwoPartObject getNew(); + public class TwoPartSignal extends DBusSignal + { + public final TwoPartObject o; + public TwoPartSignal(String path, TwoPartObject o) throws DBusException + { + super (path, o); + this.o = o; + } + } } diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index 4ffcaf8..11f3a7f 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -310,6 +310,22 @@ class arraysignalhandler implements DBusSigHandler } /** + * Object path signal handler + */ +class objectsignalhandler implements DBusSigHandler<TestSignalInterface.TestObjectSignal> +{ + public void handle(TestSignalInterface.TestObjectSignal s) + { + if (false == test.done3) { + test.done3 = true; + } else { + test.fail("SignalHandler 3 has been run too many times"); + } + System.out.println(s.otherpath); + } +} + +/** * handler which should never be called */ class badarraysignalhandler implements DBusSigHandler @@ -328,6 +344,7 @@ public class test { public static boolean done1 = false; public static boolean done2 = false; + public static boolean done3 = false; public static void fail(String message) { System.err.println("Test Failed: "+message); @@ -354,6 +371,7 @@ public class test conn.addSigHandler(TestSignalInterface.TestSignal.class, new signalhandler()); String source = dbus.GetNameOwner("foo.bar.Test"); conn.addSigHandler(TestSignalInterface.TestArraySignal.class, source, peer, new arraysignalhandler()); + conn.addSigHandler(TestSignalInterface.TestObjectSignal.class, new objectsignalhandler()); badarraysignalhandler bash = new badarraysignalhandler(); conn.addSigHandler(TestSignalInterface.TestSignal.class, bash); conn.removeSigHandler(TestSignalInterface.TestSignal.class, bash); @@ -469,11 +487,11 @@ public class test /** Call the remote object and get a response. */ TestTuple<String,List<Integer>,Boolean> rv = tri2.show(234); System.out.println("Show returned: "+rv); - if (!":1.0".equals(rv.a) || + if (!":1.1".equals(rv.a) || 1 != rv.b.size() || 1953 != rv.b.get(0) || true != rv.c.booleanValue()) - fail("show return value incorrect ("+rv+")"); + fail("show return value incorrect ("+rv.a+","+rv.b+","+rv.c+")"); System.out.println("Doing stuff asynchronously"); DBusAsyncReply<Boolean> stuffreply = (DBusAsyncReply<Boolean>) conn.callMethodAsync(tri2, "dostuff", new TestStruct("bar", new UInt32(52), new Variant<Boolean>(new Boolean(true)))); @@ -562,6 +580,9 @@ public class test System.out.print(tni.getName()+" "); System.out.println("done"); + /* send an object in a signal */ + conn.sendSignal(new TestSignalInterface.TestObjectSignal("/foo/bar/Wibble", tclass)); + /** Pause while we wait for the DBus messages to go back and forth. */ Thread.sleep(1000); @@ -576,6 +597,7 @@ public class test if (!done1) fail("Signal handler 1 failed to be run"); if (!done2) fail("Signal handler 2 failed to be run"); + if (!done3) fail("Signal handler 3 failed to be run"); } catch (Exception e) { e.printStackTrace(); diff --git a/org/freedesktop/dbus/test/two_part_test_client.java b/org/freedesktop/dbus/test/two_part_test_client.java index 5129ebc..fba4df1 100644 --- a/org/freedesktop/dbus/test/two_part_test_client.java +++ b/org/freedesktop/dbus/test/two_part_test_client.java @@ -14,6 +14,15 @@ import org.freedesktop.dbus.DBusConnection; public class two_part_test_client { + public static class two_part_test_object implements TwoPartObject + { + public boolean isRemote() { return false; } + public String getName() + { + System.out.println("client name"); + return toString(); + } + } public static void main(String[] args) throws Exception { System.out.println("get conn"); @@ -24,6 +33,10 @@ public class two_part_test_client TwoPartObject o = remote.getNew(); System.out.println("get name"); System.out.println(o.getName()); + two_part_test_object tpto = new two_part_test_object(); + conn.exportObject("/TestObject", tpto); + conn.sendSignal(new TwoPartInterface.TwoPartSignal("/FromObject", tpto)); + try { Thread.sleep(1000); } catch (InterruptedException Ie) {} conn.disconnect(); } } diff --git a/org/freedesktop/dbus/test/two_part_test_server.java b/org/freedesktop/dbus/test/two_part_test_server.java index 62d2392..99bff5d 100644 --- a/org/freedesktop/dbus/test/two_part_test_server.java +++ b/org/freedesktop/dbus/test/two_part_test_server.java @@ -11,8 +11,9 @@ package org.freedesktop.dbus.test; import org.freedesktop.dbus.DBusConnection; +import org.freedesktop.dbus.DBusSigHandler; -public class two_part_test_server implements TwoPartInterface +public class two_part_test_server implements TwoPartInterface, DBusSigHandler<TwoPartInterface.TwoPartSignal> { public class two_part_test_object implements TwoPartObject { @@ -37,11 +38,17 @@ public class two_part_test_server implements TwoPartInterface System.out.println("give new"); return o; } + public void handle(TwoPartInterface.TwoPartSignal s) + { + System.out.println("Got: "+s.o); + } public static void main(String[] args) throws Exception { DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION); conn.requestBusName("org.freedesktop.dbus.test.two_part_server"); - conn.exportObject("/", new two_part_test_server(conn)); + two_part_test_server server = new two_part_test_server(conn); + conn.exportObject("/", server); + conn.addSigHandler(TwoPartInterface.TwoPartSignal.class, server); while (true) try { Thread.sleep(10000); } catch (InterruptedException Ie) {} } } |