diff options
-rw-r--r-- | changelog | 5 | ||||
-rw-r--r-- | org/freedesktop/dbus/Marshalling.java | 19 | ||||
-rw-r--r-- | org/freedesktop/dbus/Message.java | 1 | ||||
-rw-r--r-- | org/freedesktop/dbus/Transport.java | 24 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/TestRemoteInterface.java | 2 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/TestStruct3.java | 31 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/test.java | 34 | ||||
-rw-r--r-- | org/freedesktop/dbus/test/test_p2p_server.java | 11 |
8 files changed, 114 insertions, 13 deletions
@@ -8,6 +8,11 @@ Version 2.3.2: * Make Marshalling more verbose and descriptive in the presence of mismatched parameter lists (suggested by Anibal Sanchez <anibal -dot- sanchez -at- sunya -dot- com -dot- ar>) + * Fix struct type parsing error (spotted by Gunnar Aastrand Grimnes + <gunnar -dot- grimnes -at- dfki -dot- de> and Frank Benoit + <keinfarbton -at- googlemail -dot- com>) + * Fix parsing of serializable classes + * Anonymous SASL (needs testing) Version 2.3.1: diff --git a/org/freedesktop/dbus/Marshalling.java b/org/freedesktop/dbus/Marshalling.java index 9c75275..c0f2518 100644 --- a/org/freedesktop/dbus/Marshalling.java +++ b/org/freedesktop/dbus/Marshalling.java @@ -552,20 +552,19 @@ public class Marshalling static Object[] deSerializeParameters(Object[] parameters, Type[] types, AbstractConnection conn) throws Exception { - if (Debug.debug) Debug.print(Debug.VERBOSE, "Deserializing from "+parameters+" to "+types); + if (Debug.debug) Debug.print(Debug.VERBOSE, "Deserializing from "+Arrays.deepToString(parameters)+" to "+Arrays.deepToString(types)); if (null == parameters) return null; - // CHECK IF ARRAYS HAVE THE SAME LENGTH - if (types.length != parameters.length) { - if (Debug.debug) { - for (int i = 0; i < parameters.length; i++) { - Debug.print(Debug.ERR, String.format("Error, Parameters difference (%1d, '%2s')", i, parameters[i].toString())); + for (int i = 0; i < parameters.length; i++) { + // CHECK IF ARRAYS HAVE THE SAME LENGTH <-- has to happen after expanding parameters + if (i >= types.length) { + if (Debug.debug) { + for (int j = 0; j < parameters.length; j++) { + Debug.print(Debug.ERR, String.format("Error, Parameters difference (%1d, '%2s')", j, parameters[j].toString())); + } } + throw new DBusException("Error deserializing message: number of parameters didn't match receiving signature"); } - throw new DBusException("Error deserializing message: number parameters didn't match receiving signature"); - } - - for (int i = 0; i < parameters.length; i++) { if (null == parameters[i]) continue; if (types[i] instanceof Class && diff --git a/org/freedesktop/dbus/Message.java b/org/freedesktop/dbus/Message.java index 11f0416..186604f 100644 --- a/org/freedesktop/dbus/Message.java +++ b/org/freedesktop/dbus/Message.java @@ -933,7 +933,6 @@ public class Message Vector<Object> contents = new Vector<Object>(); while (sigb[++ofs[0]] != ArgumentType.STRUCT2) contents.add(extractone(sigb, buf, ofs, true)); - ofs[0]++; rv = contents.toArray(); break; case ArgumentType.DICT_ENTRY1: diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java index 9dd86f3..9c25d5a 100644 --- a/org/freedesktop/dbus/Transport.java +++ b/org/freedesktop/dbus/Transport.java @@ -63,6 +63,8 @@ public class Transport mechs = AUTH_EXTERNAL; else if (0 == col.compare(ss[1], "DBUS_COOKIE_SHA1")) mechs = AUTH_SHA; + else if (0 == col.compare(ss[1], "ANONYMOUS")) + mechs = AUTH_ANON; } if (ss.length > 2) data = ss[2]; @@ -76,6 +78,8 @@ public class Transport mechs |= AUTH_EXTERNAL; else if (0 == col.compare(ss[i], "DBUS_COOKIE_SHA1")) mechs |= AUTH_SHA; + else if (0 == col.compare(ss[i], "ANONYMOUS")) + mechs |= AUTH_ANON; } else if (0 == col.compare(ss[0], "BEGIN")) { command = COMMAND_BEGIN; } else if (0 == col.compare(ss[0], "CANCEL")) { @@ -236,6 +240,7 @@ public class Transport public static final int AUTH_NONE=0; public static final int AUTH_EXTERNAL=1; public static final int AUTH_SHA=2; + public static final int AUTH_ANON=4; public static final int COMMAND_AUTH=1; public static final int COMMAND_DATA=2; @@ -376,6 +381,8 @@ public class Transport switch (auth) { case AUTH_NONE: switch (c.getMechs()) { + case AUTH_ANON: + return OK; case AUTH_EXTERNAL: if (0 == col.compare(Uid, c.getData())) return OK; @@ -424,8 +431,16 @@ public class Transport return new String[] { "EXTERNAL" }; case AUTH_SHA: return new String[] { "DBUS_COOKIE_SHA1" }; + case AUTH_ANON: + return new String[] { "ANONYMOUS" }; case AUTH_SHA+AUTH_EXTERNAL: return new String[] { "EXTERNAL", "DBUS_COOKIE_SHA1" }; + case AUTH_SHA+AUTH_ANON: + return new String[] { "ANONYMOUS", "DBUS_COOKIE_SHA1" }; + case AUTH_EXTERNAL+AUTH_ANON: + return new String[] { "ANONYMOUS", "EXTERNAL" }; + case AUTH_EXTERNAL+AUTH_ANON+AUTH_SHA: + return new String[] { "ANONYMOUS", "EXTERNAL", "DBUS_COOKIE_SHA1" }; default: return new String[] { }; } @@ -490,6 +505,9 @@ public class Transport } else if (0 != (available & AUTH_SHA)) { send(out, COMMAND_AUTH, "DBUS_COOKIE_SHA1", Uid); current = AUTH_SHA; + } else if (0 != (available & AUTH_ANON)) { + send(out, COMMAND_AUTH, "ANONYMOUS"); + current = AUTH_ANON; } else state = FAILED; break; @@ -528,6 +546,9 @@ public class Transport } else if (0 != (available & AUTH_SHA)) { send(out, COMMAND_AUTH, "DBUS_COOKIE_SHA1", Uid); current = AUTH_SHA; + } else if (0 != (available & AUTH_ANON)) { + send(out, COMMAND_AUTH, "ANONYMOUS"); + current = AUTH_ANON; } else state = FAILED; break; @@ -548,6 +569,9 @@ public class Transport } else if (0 != (available & AUTH_SHA)) { send(out, COMMAND_AUTH, "DBUS_COOKIE_SHA1", Uid); current = AUTH_SHA; + } else if (0 != (available & AUTH_ANON)) { + send(out, COMMAND_AUTH, "ANONYMOUS"); + current = AUTH_ANON; } else state = FAILED; break; diff --git a/org/freedesktop/dbus/test/TestRemoteInterface.java b/org/freedesktop/dbus/test/TestRemoteInterface.java index 6556071..25a637f 100644 --- a/org/freedesktop/dbus/test/TestRemoteInterface.java +++ b/org/freedesktop/dbus/test/TestRemoteInterface.java @@ -45,4 +45,6 @@ public interface TestRemoteInterface extends DBusInterface public void newpathtest(Path p); @Description("Testing the float type") public float testfloat(float[] f); + @Description("Testing structs of structs") + public int[][] teststructstruct(TestStruct3 in); } diff --git a/org/freedesktop/dbus/test/TestStruct3.java b/org/freedesktop/dbus/test/TestStruct3.java new file mode 100644 index 0000000..8b9d502 --- /dev/null +++ b/org/freedesktop/dbus/test/TestStruct3.java @@ -0,0 +1,31 @@ +/* + D-Bus Java Implementation + Copyright (c) 2005-2006 Matthew Johnson + + This program is free software; you can redistribute it and/or modify it + under the terms of either the GNU General Public License Version 2 or the + Academic Free Licence Version 2.1. + + Full licence texts are included in the COPYING file with this program. +*/ +package org.freedesktop.dbus.test; + +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; + +public final class TestStruct3 extends Struct +{ + @Position(0) + public final TestStruct2 a; + @Position(1) + public final List<List<Integer>> b; + public TestStruct3(TestStruct2 a, List<List<Integer>> b) throws DBusException + { + this.a = a; + this.b = b; + } +} diff --git a/org/freedesktop/dbus/test/test.java b/org/freedesktop/dbus/test/test.java index c076ef0..f1d1a30 100644 --- a/org/freedesktop/dbus/test/test.java +++ b/org/freedesktop/dbus/test/test.java @@ -13,6 +13,7 @@ package org.freedesktop.dbus.test; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -60,6 +61,17 @@ class testclass implements TestRemoteInterface, TestRemoteInterface2, TestSignal { this.conn = conn; } + public int[][] teststructstruct(TestStruct3 in) + { + List<List<Integer>> lli = in.b; + int[][] out = new int[lli.size()][]; + for (int j = 0; j < out.length; j++) { + out[j] = new int[lli.get(j).size()]; + for (int k = 0; k < out[j].length; k++) + out[j][k] = lli.get(j).get(k); + } + return out; + } public float testfloat(float[] f) { if (f.length < 4 || @@ -485,6 +497,24 @@ public class test System.out.println("testing floats"); if (17.093f != tri.testfloat(new float[] { 17.093f, -23f, 0.0f, 31.42f })) fail("testfloat returned the wrong thing"); + System.out.println("Structs of Structs"); + List<List<Integer>> lli = new Vector<List<Integer>>(); + List<Integer> li = new Vector<Integer>(); + li.add(1); + li.add(2); + li.add(3); + lli.add(li); + lli.add(li); + lli.add(li); + TestStruct3 ts3 = new TestStruct3(new TestStruct2(new Vector<String>(), new Variant<Integer>(0)), lli); + int[][] out = tri.teststructstruct(ts3); + if (out.length != 3) fail("teststructstruct returned the wrong thing: "+Arrays.deepToString(out)); + for (int[] o: out) + if (o.length != 3 + ||o[0] != 1 + ||o[1] != 2 + ||o[2] != 3) fail("teststructstruct returned the wrong thing: "+Arrays.deepToString(out)); + System.out.println("frobnicating"); List<Long> ls = new Vector<Long>(); ls.add(2L); @@ -626,8 +656,8 @@ public class test System.out.println("done"); System.out.print("Testing nested lists..."); - List<List<Integer>> lli = new Vector<List<Integer>>(); - List<Integer> li = new Vector<Integer>(); + lli = new Vector<List<Integer>>(); + li = new Vector<Integer>(); li.add(1); lli.add(li); List<List<Integer>> reti = tri2.checklist(lli); diff --git a/org/freedesktop/dbus/test/test_p2p_server.java b/org/freedesktop/dbus/test/test_p2p_server.java index f089251..cea5ac3 100644 --- a/org/freedesktop/dbus/test/test_p2p_server.java +++ b/org/freedesktop/dbus/test/test_p2p_server.java @@ -24,6 +24,17 @@ import org.freedesktop.dbus.UInt16; public class test_p2p_server implements TestRemoteInterface { + public int[][] teststructstruct(TestStruct3 in) + { + List<List<Integer>> lli = in.b; + int[][] out = new int[lli.size()][]; + for (int j = 0; j < out.length; j++) { + out[j] = new int[lli.get(j).size()]; + for (int k = 0; k < out[j].length; k++) + out[j][k] = lli.get(j).get(k); + } + return out; + } public String getName() { System.out.println("getName called"); |