summaryrefslogtreecommitdiff
path: root/org
diff options
context:
space:
mode:
authorMatthew Johnson <mjj29@khnemu.(none)>2009-05-21 17:18:05 +0100
committerMatthew Johnson <mjj29@khnemu.(none)>2009-05-21 17:18:05 +0100
commit88467b0d6baed3f10ea8549ce2fb30d2d538ea77 (patch)
treea3959b5bea0dfde0774e962f2eedb7170ebd148e /org
parent7d6099ae891c9018c2d5072bc057bb00f6d9d6e4 (diff)
parent21d7a2cce11b24153932d6c24e2f80c82d75eafb (diff)
Merge branch 'master' of git+ssh://ianthe.matthew.ath.cx/home/mjj29/scm/dbus-java
Conflicts: org/freedesktop/dbus/test/test.java
Diffstat (limited to 'org')
-rw-r--r--org/freedesktop/dbus/AbstractConnection.java41
-rw-r--r--org/freedesktop/dbus/DBusConnection.java9
-rw-r--r--org/freedesktop/dbus/DirectConnection.java1
-rw-r--r--org/freedesktop/dbus/Error.java2
-rw-r--r--org/freedesktop/dbus/Marshalling.java6
-rw-r--r--org/freedesktop/dbus/MessageWriter.java9
-rw-r--r--org/freedesktop/dbus/ObjectPath.java6
-rw-r--r--org/freedesktop/dbus/Path.java4
-rw-r--r--org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java3
-rw-r--r--org/freedesktop/dbus/test/TestRemoteInterface.java4
-rw-r--r--org/freedesktop/dbus/test/TestSignalInterface.java15
-rw-r--r--org/freedesktop/dbus/test/test.java138
-rw-r--r--org/freedesktop/dbus/test/test_p2p_server.java3
13 files changed, 195 insertions, 46 deletions
diff --git a/org/freedesktop/dbus/AbstractConnection.java b/org/freedesktop/dbus/AbstractConnection.java
index 5cdc27e..70eca55 100644
--- a/org/freedesktop/dbus/AbstractConnection.java
+++ b/org/freedesktop/dbus/AbstractConnection.java
@@ -111,11 +111,6 @@ public abstract class AbstractConnection
} catch (Exception e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
if (e instanceof FatalException) {
- try {
- handleMessage(new org.freedesktop.DBus.Local.Disconnected("/"));
- } catch (Exception ee) {
- if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, ee);
- }
disconnect();
}
}
@@ -205,12 +200,14 @@ public abstract class AbstractConnection
if (Debug.debug) Debug.print(Debug.INFO, "Flushing outbound queue and quitting");
// flush the outbound queue before disconnect.
if (null != outgoing) do {
- synchronized (outgoing) {
- if (!outgoing.isEmpty())
- m = outgoing.remove();
- else m = null;
- }
- sendMessage(m);
+ EfficientQueue ogq = outgoing;
+ synchronized (ogq) {
+ outgoing = null;
+ }
+ if (!ogq.isEmpty())
+ m = ogq.remove();
+ else m = null;
+ sendMessage(m);
} while (null != m);
// close the underlying streams
@@ -251,6 +248,7 @@ public abstract class AbstractConnection
static final Pattern dollar_pattern = Pattern.compile("[$]");
public static final boolean EXCEPTION_DEBUG;
static final boolean FLOAT_SUPPORT;
+ protected boolean connected = false;
static {
FLOAT_SUPPORT = (null != System.getenv("DBUS_JAVA_FLOATS"));
EXCEPTION_DEBUG = (null != System.getenv("DBUS_JAVA_EXCEPTION_DEBUG"));
@@ -468,8 +466,8 @@ public abstract class AbstractConnection
}
void queueOutgoing(Message m)
{
- if (null == outgoing) return;
synchronized (outgoing) {
+ if (null == outgoing) return;
outgoing.add(m);
if (Debug.debug) Debug.print(Debug.DEBUG, "Notifying outgoing thread");
outgoing.notifyAll();
@@ -560,6 +558,14 @@ public abstract class AbstractConnection
*/
public void disconnect()
{
+ connected = false;
+ if (Debug.debug) Debug.print(Debug.INFO, "Sending disconnected signal");
+ try {
+ handleMessage(new org.freedesktop.DBus.Local.Disconnected("/"));
+ } catch (Exception ee) {
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, ee);
+ }
+
if (Debug.debug) Debug.print(Debug.INFO, "Disconnecting Abstract Connection");
// run all pending tasks.
while (runnables.size() > 0)
@@ -577,8 +583,10 @@ public abstract class AbstractConnection
// disconnect from the trasport layer
try {
- if (null != transport)
+ if (null != transport) {
transport.disconnect();
+ transport = null;
+ }
} catch (IOException IOe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
}
@@ -926,6 +934,7 @@ public abstract class AbstractConnection
protected void sendMessage(Message m)
{
try {
+ if (!connected) throw new NotConnected(_("Disconnected"));
if (m instanceof DBusSignal)
((DBusSignal) m).appendbody(this);
@@ -942,6 +951,10 @@ public abstract class AbstractConnection
} catch (Exception e) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
+ if (m instanceof MethodCall && e instanceof NotConnected)
+ try {
+ ((MethodCall) m).setReply(new Error("org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.Disconnected", 0, "s", new Object[] { _("Disconnected") }));
+ } catch (DBusException DBe) {}
if (m instanceof MethodCall && e instanceof DBusExecutionException)
try {
((MethodCall)m).setReply(new Error(m, e));
@@ -964,7 +977,7 @@ public abstract class AbstractConnection
}
private Message readIncoming() throws DBusException
{
- if (null == transport) throw new NotConnected(_("No transport present"));
+ if (!connected) throw new NotConnected(_("No transport present"));
Message m = null;
try {
m = transport.min.readMessage();
diff --git a/org/freedesktop/dbus/DBusConnection.java b/org/freedesktop/dbus/DBusConnection.java
index 43a5b04..e2b6d7d 100644
--- a/org/freedesktop/dbus/DBusConnection.java
+++ b/org/freedesktop/dbus/DBusConnection.java
@@ -31,6 +31,7 @@ import java.util.Vector;
import org.freedesktop.DBus;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
+import org.freedesktop.dbus.exceptions.NotConnected;
import cx.ath.matthew.debug.Debug;
@@ -265,6 +266,7 @@ public class DBusConnection extends AbstractConnection
try {
transport = new Transport(addr, AbstractConnection.TIMEOUT);
+ connected = true;
} catch (IOException IOe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
disconnect();
@@ -296,9 +298,11 @@ public class DBusConnection extends AbstractConnection
@SuppressWarnings("unchecked")
DBusInterface dynamicProxy(String source, String path) throws DBusException
{
+ if (Debug.debug) Debug.print(Debug.INFO, "Introspecting "+path+" on "+source+" for dynamic proxy creation");
try {
DBus.Introspectable intro = getRemoteObject(source, path, DBus.Introspectable.class);
String data = intro.Introspect();
+ if (Debug.debug) Debug.print(Debug.VERBOSE, "Got introspection data: "+data);
String[] tags = data.split("[<>]");
Vector<String> ifaces = new Vector<String>();
for (String tag: tags) {
@@ -308,6 +312,7 @@ public class DBusConnection extends AbstractConnection
}
Vector<Class<? extends Object>> ifcs = new Vector<Class<? extends Object>>();
for(String iface: ifaces) {
+ if (Debug.debug) Debug.print(Debug.DEBUG, "Trying interface "+iface);
int j = 0;
while (j >= 0) {
try {
@@ -637,9 +642,11 @@ public class DBusConnection extends AbstractConnection
handledSignals.remove(key);
try {
_dbus.RemoveMatch(rule.toString());
+ } catch (NotConnected NC) {
+ if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, NC);
} catch (DBusExecutionException DBEe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
- throw new DBusException(DBEe.getMessage());
+ throw new DBusException(DBEe.getMessage());
}
}
}
diff --git a/org/freedesktop/dbus/DirectConnection.java b/org/freedesktop/dbus/DirectConnection.java
index 62cf7e8..93ec03f 100644
--- a/org/freedesktop/dbus/DirectConnection.java
+++ b/org/freedesktop/dbus/DirectConnection.java
@@ -43,6 +43,7 @@ public class DirectConnection extends AbstractConnection
try {
transport = new Transport(addr, AbstractConnection.TIMEOUT);
+ connected = true;
} catch (IOException IOe) {
if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
throw new DBusException(_("Failed to connect to bus ")+IOe.getMessage());
diff --git a/org/freedesktop/dbus/Error.java b/org/freedesktop/dbus/Error.java
index 16e1126..9db1e07 100644
--- a/org/freedesktop/dbus/Error.java
+++ b/org/freedesktop/dbus/Error.java
@@ -17,6 +17,7 @@ import java.util.Vector;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.exceptions.DBusExecutionException;
import org.freedesktop.dbus.exceptions.MessageFormatException;
+import org.freedesktop.dbus.exceptions.NotConnected;
import cx.ath.matthew.debug.Debug;
@@ -79,6 +80,7 @@ public class Error extends Message
@SuppressWarnings("unchecked")
private static Class<? extends DBusExecutionException> createExceptionClass(String name)
{
+ if (name == "org.freedesktop.DBus.Local.Disconnected") return NotConnected.class;
Class<? extends DBusExecutionException> c = null;
do {
try {
diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java
index 7116248..7f6797c 100644
--- a/org/freedesktop/dbus/Marshalling.java
+++ b/org/freedesktop/dbus/Marshalling.java
@@ -424,12 +424,12 @@ public class Marshalling
// 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
+ if (type instanceof Class && DBusInterface.class.isAssignableFrom((Class) type))
parameter = conn.getExportedObject(
((ObjectPath) parameter).source,
((ObjectPath) parameter).path);
+ else
+ parameter = new Path(((ObjectPath) parameter).path);
}
// it should be a struct. create it
diff --git a/org/freedesktop/dbus/MessageWriter.java b/org/freedesktop/dbus/MessageWriter.java
index bf19d03..00fb7f2 100644
--- a/org/freedesktop/dbus/MessageWriter.java
+++ b/org/freedesktop/dbus/MessageWriter.java
@@ -20,9 +20,16 @@ import cx.ath.matthew.utils.Hexdump;
public class MessageWriter
{
private OutputStream out;
+ private boolean isunix;
public MessageWriter(OutputStream out)
{
this.out = out;
+ this.isunix = false;
+ try {
+ if (out instanceof USOutputStream)
+ this.isunix = true;
+ } catch (Throwable t) {
+ }
}
public void writeMessage(Message m) throws IOException
{
@@ -34,7 +41,7 @@ public class MessageWriter
if (Debug.debug) Debug.print(Debug.WARN, "Message "+m+" wire-data was null!");
return;
}
- if (out instanceof USOutputStream) {
+ if (isunix) {
if (Debug.debug) {
Debug.print(Debug.DEBUG, "Writing all "+m.getWireData().length+" buffers simultaneously to Unix Socket");
for (byte[] buf: m.getWireData())
diff --git a/org/freedesktop/dbus/ObjectPath.java b/org/freedesktop/dbus/ObjectPath.java
index 2cd177e..409d26d 100644
--- a/org/freedesktop/dbus/ObjectPath.java
+++ b/org/freedesktop/dbus/ObjectPath.java
@@ -10,16 +10,14 @@
*/
package org.freedesktop.dbus;
-class ObjectPath
+class ObjectPath extends Path
{
public String source;
- public String path;
// public DBusConnection conn;
public ObjectPath(String source, String path/*, DBusConnection conn*/)
{
+ super(path);
this.source = source;
- this.path = path;
// this.conn = conn;
}
- public String toString() { return path; }
}
diff --git a/org/freedesktop/dbus/Path.java b/org/freedesktop/dbus/Path.java
index 449604d..baaa7a6 100644
--- a/org/freedesktop/dbus/Path.java
+++ b/org/freedesktop/dbus/Path.java
@@ -10,9 +10,9 @@
*/
package org.freedesktop.dbus;
-public final class Path implements Comparable<Path>
+public class Path implements Comparable<Path>
{
- private String path;
+ protected String path;
public Path(String path)
{
this.path = path;
diff --git a/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java b/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
index b00f5b6..9441e70 100644
--- a/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
+++ b/org/freedesktop/dbus/exceptions/UnknownTypeCodeException.java
@@ -9,12 +9,13 @@
Full licence texts are included in the COPYING file with this program.
*/
package org.freedesktop.dbus.exceptions;
+import static org.freedesktop.dbus.Gettext._;
@SuppressWarnings("serial")
public class UnknownTypeCodeException extends DBusException implements NonFatalException
{
public UnknownTypeCodeException(byte code)
{
- super("Code "+code+" is not a valid D-Bus type.");
+ super(_("Not a valid D-Bus type code: ") + code);
}
}
diff --git a/org/freedesktop/dbus/test/TestRemoteInterface.java b/org/freedesktop/dbus/test/TestRemoteInterface.java
index 0379d4e..4417695 100644
--- a/org/freedesktop/dbus/test/TestRemoteInterface.java
+++ b/org/freedesktop/dbus/test/TestRemoteInterface.java
@@ -49,4 +49,8 @@ public interface TestRemoteInterface extends DBusInterface
public int[][] teststructstruct(TestStruct3 in);
@Description("Regression test for #13291")
public void reg13291(byte[] as, byte[] bs);
+ /* test lots of things involving Path */
+ public Path pathrv(Path a);
+ public List<Path> pathlistrv(List<Path> a);
+ public Map<Path,Path> pathmaprv(Map<Path,Path> a);
}
diff --git a/org/freedesktop/dbus/test/TestSignalInterface.java b/org/freedesktop/dbus/test/TestSignalInterface.java
index 4f20921..1032ec1 100644
--- a/org/freedesktop/dbus/test/TestSignalInterface.java
+++ b/org/freedesktop/dbus/test/TestSignalInterface.java
@@ -14,10 +14,12 @@ import org.freedesktop.DBus.Description;
import org.freedesktop.dbus.DBusInterface;
import org.freedesktop.dbus.DBusMemberName;
import org.freedesktop.dbus.DBusSignal;
+import org.freedesktop.dbus.Path;
import org.freedesktop.dbus.UInt32;
import org.freedesktop.dbus.exceptions.DBusException;
import java.util.List;
+import java.util.Map;
/**
* A sample signal with two parameters
@@ -77,4 +79,17 @@ public interface TestSignalInterface extends DBusInterface
this.otherpath = otherpath;
}
}
+ public static class TestPathSignal extends DBusSignal
+ {
+ public final Path otherpath;
+ public final List<Path> pathlist;
+ public final Map<Path,Path> pathmap;
+ public TestPathSignal(String path, Path otherpath, List<Path> pathlist, Map<Path,Path> pathmap) throws DBusException
+ {
+ super(path, otherpath, pathlist, pathmap);
+ this.otherpath = otherpath;
+ this.pathlist = pathlist;
+ this.pathmap = pathmap;
+ }
+ }
}
diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java
index 5682417..37b1ed5 100644
--- a/org/freedesktop/dbus/test/test.java
+++ b/org/freedesktop/dbus/test/test.java
@@ -37,6 +37,7 @@ 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.exceptions.NotConnected;
import org.freedesktop.DBus;
import org.freedesktop.DBus.Error.MatchRuleInvalid;
@@ -44,6 +45,7 @@ import org.freedesktop.DBus.Error.ServiceUnknown;
import org.freedesktop.DBus.Error.UnknownObject;
import org.freedesktop.DBus.Peer;
import org.freedesktop.DBus.Introspectable;
+import org.freedesktop.DBus.Properties;
class testnewclass implements TestNewInterface
{
@@ -54,7 +56,7 @@ class testnewclass implements TestNewInterface
}
}
-class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignalInterface, TestSignalInterface2
+class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignalInterface, TestSignalInterface2, Properties
{
private DBusConnection conn;
public testclass(DBusConnection conn)
@@ -299,6 +301,16 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal
for (int i = 0; i < as.length; i++)
if (as[i] != bs[i]) test.fail("didn't receive identical byte arrays");
}
+ @SuppressWarnings("unchecked")
+ public <A> A Get (String interface_name, String property_name)
+ {
+ return (A) new Path("/nonexistant/path");
+ }
+ public <A> void Set (String interface_name, String property_name, A value) {}
+ public Map<String, Variant> GetAll (String interface_name) { return new HashMap<String,Variant>(); }
+ public Path pathrv(Path a) { return a; }
+ public List<Path> pathlistrv(List<Path> a) { return a; }
+ public Map<Path,Path> pathmaprv(Map<Path,Path> a) { return a; }
}
/**
@@ -329,12 +341,39 @@ class emptysignalhandler implements DBusSigHandler<TestSignalInterface.EmptySign
/** Handling a signal */
public void handle(TestSignalInterface.EmptySignal t)
{
- if (false == test.done6) {
- test.done6 = true;
+ if (false == test.done7) {
+ test.done7 = true;
} else {
test.fail("SignalHandler E has been run too many times");
}
System.out.println("SignalHandler E Running");
+ }
+}
+/**
+ * Disconnect handler
+ */
+class disconnecthandler implements DBusSigHandler<DBus.Local.Disconnected>
+{
+ private DBusConnection conn;
+ private renamedsignalhandler sh;
+ public disconnecthandler(DBusConnection conn, renamedsignalhandler sh)
+ {
+ this.conn = conn;
+ this.sh = sh;
+ }
+ /** Handling a signal */
+ public void handle(DBus.Local.Disconnected t)
+ {
+ if (false == test.done6) {
+ test.done6 = true;
+ System.out.println("Handling disconnect, unregistering handler");
+ try {
+ conn.removeSigHandler(TestSignalInterface2.TestRenamedSignal.class, sh);
+ } catch (DBusException DBe) {
+ DBe.printStackTrace();
+ test.fail("Disconnect handler threw an exception: "+DBe);
+ }
+ }
}
}
@@ -342,6 +381,18 @@ class emptysignalhandler implements DBusSigHandler<TestSignalInterface.EmptySign
/**
* Typed signal handler
*/
+class pathsignalhandler implements DBusSigHandler<TestSignalInterface.TestPathSignal>
+{
+ /** Handling a signal */
+ public void handle(TestSignalInterface.TestPathSignal t)
+ {
+ System.out.println("Path sighandler: "+t);
+ }
+}
+
+/**
+ * Typed signal handler
+ */
class signalhandler implements DBusSigHandler<TestSignalInterface.TestSignal>
{
/** Handling a signal */
@@ -452,6 +503,7 @@ public class test
public static boolean done4 = false;
public static boolean done5 = false;
public static boolean done6 = false;
+ public static boolean done7 = false;
public static void fail(String message)
{
System.out.println("Test Failed: "+message);
@@ -479,14 +531,18 @@ public class test
DBus dbus = clientconn.getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class);
System.out.print("Listening for signals...");
+ signalhandler sigh = new signalhandler();
+ renamedsignalhandler rsh = new renamedsignalhandler();
try {
/** This registers an instance of the test class as the signal handler for the TestSignal class. */
- clientconn.addSigHandler(TestSignalInterface.TestSignal.class, new signalhandler());
clientconn.addSigHandler(TestSignalInterface.EmptySignal.class, new emptysignalhandler());
- clientconn.addSigHandler(TestSignalInterface2.TestRenamedSignal.class, new renamedsignalhandler());
+ clientconn.addSigHandler(TestSignalInterface.TestSignal.class, sigh);
+ clientconn.addSigHandler(TestSignalInterface2.TestRenamedSignal.class, rsh);
+ clientconn.addSigHandler(DBus.Local.Disconnected.class, new disconnecthandler(clientconn, rsh));
String source = dbus.GetNameOwner("foo.bar.Test");
clientconn.addSigHandler(TestSignalInterface.TestArraySignal.class, source, peer, new arraysignalhandler());
clientconn.addSigHandler(TestSignalInterface.TestObjectSignal.class, new objectsignalhandler());
+ clientconn.addSigHandler(TestSignalInterface.TestPathSignal.class, new pathsignalhandler());
badarraysignalhandler<TestSignalInterface.TestSignal> bash = new badarraysignalhandler<TestSignalInterface.TestSignal>();
clientconn.addSigHandler(TestSignalInterface.TestSignal.class, bash);
clientconn.removeSigHandler(TestSignalInterface.TestSignal.class, bash);
@@ -532,10 +588,10 @@ public class test
/** This gets a remote object matching our bus name and exported object path. */
Introspectable intro = clientconn.getRemoteObject("foo.bar.Test", "/", Introspectable.class);
/** Get introspection data */
- String data = intro.Introspect();
+ String data;/* = intro.Introspect();
if (null == data || !data.startsWith("<!DOCTYPE"))
fail("Introspection data invalid");
- System.out.println("Got Introspection Data: \n"+data);
+ System.out.println("Got Introspection Data: \n"+data);*/
intro = clientconn.getRemoteObject("foo.bar.Test", "/Test", Introspectable.class);
/** Get introspection data */
data = intro.Introspect();
@@ -543,7 +599,14 @@ public class test
fail("Introspection data invalid");
System.out.println("Got Introspection Data: \n"+data);
- System.out.println("Pinging ourselves");
+ // setup bus name set
+ Set<String> peers = serverconn.new PeerSet();
+ peers.add("org.freedesktop.DBus");
+ clientconn.requestBusName("test.testclient");
+ peers.add("test.testclient");
+ clientconn.releaseBusName("test.testclient");
+
+ System.out.println("Pinging ourselves");
/** Call ping. */
for (int i = 0; i < 10; i++) {
long then = System.currentTimeMillis();
@@ -559,6 +622,30 @@ public class test
/** Call the remote object and get a response. */
String rname = tri.getName();
System.out.println("Got Remote Name: "+rname);
+
+ Path path = new Path("/nonexistantwooooooo");
+ Path p = tri.pathrv(path);
+ System.out.println(path.toString()+" => "+p.toString());
+ if (!path.equals(p)) fail("pathrv incorrect");
+ List<Path> paths = new Vector<Path>();
+ paths.add(path);
+ List<Path> ps = tri.pathlistrv(paths);
+ System.out.println(paths.toString()+" => "+ps.toString());
+ if (!paths.equals(ps)) fail("pathlistrv incorrect");
+ Map<Path, Path> pathm = new HashMap<Path, Path>();
+ pathm.put(path, path);
+ Map<Path, Path> pm = tri.pathmaprv(pathm);
+ System.out.println(pathm.toString()+" => "+pm.toString());
+ System.out.println(pm.containsKey(path)+" "+pm.get(path)+" "+path.equals(pm.get(path)));
+ System.out.println(pm.containsKey(p)+" "+pm.get(p)+" "+p.equals(pm.get(p)));
+ for (Path q: pm.keySet()) {
+ System.out.println(q);
+ System.out.println(pm.get(q));
+ }
+ if (!pm.containsKey(path) || !path.equals(pm.get(path))) fail("pathmaprv incorrect");
+
+ serverconn.sendSignal(new TestSignalInterface.TestPathSignal("/Test", path, paths, pathm));
+
Collator col = Collator.getInstance();
col.setDecomposition(Collator.FULL_DECOMPOSITION);
col.setStrength(Collator.PRIMARY);
@@ -669,6 +756,10 @@ public class test
System.out.println("Got Fallback Name: "+tri.getName());
System.out.println("Fallback Introspection Data: \n"+intro.Introspect());
+ System.out.println("Testing Properties returning Paths");
+ Properties prop = clientconn.getRemoteObject("foo.bar.Test", "/Test", Properties.class);
+ Path prv = (Path) prop.Get("foo.bar", "foo");
+ System.out.println("Got path "+prv);
System.out.println("Calling Method7--9");
/** This gets a remote object matching our bus name and exported object path. */
TestRemoteInterface2 tri2 = clientconn.getRemoteObject("foo.bar.Test", "/Test", TestRemoteInterface2.class);
@@ -794,19 +885,12 @@ public class test
/* send an object in a signal */
serverconn.sendSignal(new TestSignalInterface.TestObjectSignal("/foo/bar/Wibble", tclass));
- // setup bus name set
- Set<String> peers = serverconn.new PeerSet();
- peers.add("org.freedesktop.DBus");
- clientconn.requestBusName("test.testclient");
- peers.add("test.testclient");
- clientconn.releaseBusName("test.testclient");
-
/** Pause while we wait for the DBus messages to go back and forth. */
Thread.sleep(1000);
// check that bus name set has been trimmed
- //if (peers.size() != 1) fail("peers hasn't been trimmed");
- //if (!peers.contains("org.freedesktop.DBus")) fail ("peers contains the wrong name");
+ if (peers.size() != 1) fail("peers hasn't been trimmed");
+ if (!peers.contains("org.freedesktop.DBus")) fail ("peers contains the wrong name");
System.out.println("Checking for outstanding errors");
DBusExecutionException DBEe = serverconn.getError();
@@ -817,8 +901,21 @@ public class test
System.out.println("Disconnecting");
/** Disconnect from the bus. */
clientconn.disconnect();
- clientconn = null;
serverconn.disconnect();
+
+ System.out.println("Trying to do things after disconnection");
+
+ /** Remove sig handler */
+ clientconn.removeSigHandler(TestSignalInterface.TestSignal.class, sigh);
+
+ /** Call a method when disconnected */
+ try {
+ System.out.println("getName() suceeded and returned: "+tri.getName());
+ fail("Should not succeed when disconnected");
+ } catch (NotConnected NC) {
+ System.out.println("getName() failed with exception "+NC);
+ }
+ clientconn = null;
serverconn = null;
if (!done1) fail("Signal handler 1 failed to be run");
@@ -826,10 +923,11 @@ public class test
if (!done3) fail("Signal handler 3 failed to be run");
if (!done4) fail("Callback handler failed to be run");
if (!done5) fail("Signal handler R failed to be run");
- if (!done6) fail("Signal handler E failed to be run");
+ if (!done6) fail("Disconnect handler failed to be run");
+ if (!done7) fail("Signal handler E failed to be run");
} catch (Exception e) {
e.printStackTrace();
- fail("Unexpected Exception Occurred");
+ fail("Unexpected Exception Occurred: "+e);
}}
}
diff --git a/org/freedesktop/dbus/test/test_p2p_server.java b/org/freedesktop/dbus/test/test_p2p_server.java
index 1025bda..10201a9 100644
--- a/org/freedesktop/dbus/test/test_p2p_server.java
+++ b/org/freedesktop/dbus/test/test_p2p_server.java
@@ -65,6 +65,9 @@ public class test_p2p_server implements TestRemoteInterface
public void reg13291(byte[] as, byte[] bs)
{
}
+ public Path pathrv(Path a) { return a; }
+ public List<Path> pathlistrv(List<Path> a) { return a; }
+ public Map<Path,Path> pathmaprv(Map<Path,Path> a) { return a; }
public boolean isRemote() { return false; }
public float testfloat(float[] f)
{