Add basic dbus implementation
[moonshot-ui.git] / src / dbus-client.vala
1 [DBus (name = "org.janet.Moonshot")]
2 interface Moonshot : Object {
3     public abstract int ping (string msg) throws DBus.Error;
4     public abstract string[] get_identity (string identity, string username, string password) throws DBus.Error;
5 }
6
7 void main () {
8     try {
9         var conn = DBus.Bus.get (DBus.BusType.SESSION);
10         var demo = (Moonshot) conn.get_object ("org.janet.Moonshot",
11                                                "/org/janet/moonshot");
12
13         int pong = demo.ping ("Hello from Vala");
14         stdout.printf ("%d\n", pong);
15
16         var text = demo.get_identity ("identity", "username", "pass");
17         stdout.printf ("%s %s %s\n", text[0], text[1], text[2]);
18
19     } catch (DBus.Error e) {
20         stderr.printf ("%s\n", e.message);
21     }
22 }