6 [DBus (name = "org.example.Test")]
7 public interface Test : Object {
8 public abstract string test_property { owned get; set; }
10 public signal void test_signal (int i);
12 public abstract int test_method (int j, int k) throws IOError;
15 [DBus (name = "org.example.Test")]
16 public interface TestRaw : Object {
17 [DBus (signature = "s")]
18 public abstract Variant test_property { owned get; set; }
20 public signal void test_signal ([DBus (signature = "i")] Variant i);
22 [DBus (signature = "i")]
23 public abstract Variant test_method ([DBus (signature = "i")] Variant j, [DBus (signature = "i")] Variant k) throws IOError;
26 void test_raw (TestRaw test) {
27 var main_loop = new MainLoop ();
29 var id = test.test_signal.connect ((var_i) => {
35 int j = (int) test.test_method (23, 11);
41 test.test_property = "hello";
42 var s = (string) test.test_property;
43 assert (s == "hello");
46 void test (Test test) {
47 var main_loop = new MainLoop ();
49 var id = test.test_signal.connect ((i) => {
54 int j = test.test_method (23, 11);
60 test.test_property = "hello";
61 var s = test.test_property;
62 assert (s == "hello");
66 // raw variant server, standard client
67 Test test1 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/testraw", DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
70 // standard server, raw variant client
71 TestRaw test2 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test", DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
74 // raw variant server, raw variant client
75 TestRaw test3 = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/testraw", DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
81 [DBus (name = "org.example.Test")]
82 public class Test : Object {
83 public string test_property { owned get; set; }
85 public signal void test_signal (int i);
87 public int test_method (int j, int k) {
95 [DBus (name = "org.example.Test")]
96 public class TestRaw : Object {
97 [DBus (signature = "s")]
98 public Variant test_property { owned get; set; }
100 public signal void test_signal ([DBus (signature = "i")] Variant i);
102 [DBus (signature = "i")]
103 public Variant test_method ([DBus (signature = "i")] Variant j, [DBus (signature = "i")] Variant k) {
104 assert ((int) j == 23);
105 assert ((int) k == 11);
113 void client_exit (Pid pid, int status) {
114 // client finished, terminate server
115 assert (status == 0);
120 var conn = Bus.get_sync (BusType.SESSION);
121 conn.register_object ("/org/example/test", new Test ());
122 conn.register_object ("/org/example/testraw", new TestRaw ());
124 // try to register service in session bus
125 var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
126 new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
127 assert ((uint) request_result.get_child_value (0) == 1);
129 // server ready, spawn client
131 Process.spawn_async (null, { "test", "/dbus/rawvariants/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
132 ChildWatch.add (client_pid, client_exit);
134 main_loop = new MainLoop ();