6 [DBus (name = "org.example.Test")]
7 interface Test : Object {
8 public abstract void test_void () throws Error;
9 public abstract int test_int (int i, out int j) throws Error;
10 public abstract string test_string (string s, out string t) throws Error;
11 public abstract void test_cancellable (Cancellable? cancellable = null) throws Error;
16 Test test = Bus.get_proxy_sync (BusType.SESSION, "org.example.Test", "/org/example/test");
20 assert_not_reached ();
26 k = test.test_int (42, out j);
27 assert_not_reached ();
33 u = test.test_string ("hello", out t);
34 assert (t == "world");
36 assert_not_reached ();
41 var cancellable = new Cancellable ();
42 cancellable.cancel ();
43 test.test_cancellable (cancellable);
44 assert_not_reached ();
51 [DBus (name = "org.example.Test")]
53 public void test_void () throws Error {
54 throw new IOError.FAILED ("Operation failed");
57 public int test_int (int i, out int j) throws Error {
58 throw new IOError.FAILED ("Operation failed");
61 public string test_string (string s, out string t) throws Error {
62 throw new IOError.FAILED ("Operation failed");
65 public void test_cancellable (Cancellable? cancellable = null) throws Error {
71 void client_exit (Pid pid, int status) {
72 // client finished, terminate server
78 var conn = Bus.get_sync (BusType.SESSION);
79 conn.register_object ("/org/example/test", new Test ());
81 // try to register service in session bus
82 var request_result = conn.call_sync ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "RequestName",
83 new Variant ("(su)", "org.example.Test", 0x4), null, 0, -1);
84 assert ((uint) request_result.get_child_value (0) == 1);
86 // server ready, spawn client
88 Process.spawn_async (null, { "test", "/dbus/errors/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
89 ChildWatch.add (client_pid, client_exit);
91 main_loop = new MainLoop ();