6 [DBus (name = "org.example.Test")]
7 interface Test : Object {
8 public abstract string test_property { owned get; set; }
9 public abstract int test_int_property { get; set; }
11 public abstract void test_void () throws IOError;
12 public abstract int test_int (int i, out int j) throws IOError;
13 public abstract string test_string (string s, out string t) throws IOError;
18 Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test", DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
23 k = test.test_int (42, out j);
28 u = test.test_string ("hello", out t);
29 assert (t == "world");
32 test.test_property = "hello";
33 t = test.test_property;
34 assert (t == "hello");
36 test.test_int_property = 42;
37 j = test.test_int_property;
43 [DBus (name = "org.example.Test")]
45 public string test_property { owned get; set; }
46 public int test_int_property { get; set; }
48 public void test_void () {
51 public int test_int (int i, out int j) {
57 public string test_string (string s, out string t) {
58 assert (s == "hello");
66 void client_exit (Pid pid, int status) {
67 // client finished, terminate server
73 var conn = Bus.get_sync (BusType.SESSION);
74 conn.register_object ("/org/example/test", new Test ());
76 // try to register service in session bus
77 var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
78 new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
79 assert ((uint) request_result.get_child_value (0) == 1);
81 // server ready, spawn client
83 Process.spawn_async (null, { "test", "/dbus/basic-types/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
84 ChildWatch.add (client_pid, client_exit);
86 main_loop = new MainLoop ();