de30262140140058bb0f54672c97531ef66b828a
[moonshot-ui.git] / src / dbus-client.vala
1 [DBus (name = "org.janet.Moonshot")]
2 interface Moonshot : Object {
3     public abstract bool get_identity (string nai, string password, string service,
4                                        out string nai_out, out string password_out,
5                                        out string server_certificate_hash, out string ca_certificate, out string subject_name_constraint, out string subject_alt_name_constraint) throws DBus.Error;
6     public abstract bool get_default_identity (out string nai_out, out string password_out) throws DBus.Error;
7 }
8
9 void main () {
10     try {
11         string nai_out, password_out, certificate_out;
12         string a, b, c;
13
14         var conn = DBus.Bus.get (DBus.BusType.SESSION);
15         var demo = (Moonshot) conn.get_object ("org.janet.Moonshot",
16                                                "/org/janet/moonshot");
17
18
19         if (demo.get_default_identity (out nai_out, out password_out))
20         {
21             stdout.printf ("default identity: %s %s\n", nai_out, password_out);
22         }
23         else
24         {
25             stdout.printf ("Unable to get default identity.\n");
26         }
27
28
29         if (demo.get_identity ("username@issuer",
30                                "pass",
31                                "",
32                                out nai_out,
33                                out password_out,
34                                out certificate_out,
35                                out a,
36                                out b,
37                                out c))
38         {
39             stdout.printf ("%s %s %s\n", nai_out, password_out, certificate_out);
40         }
41         else
42         {
43             stdout.printf ("The nai, password or service doesnt match the selected id_card\n");
44         }
45
46     } catch (DBus.Error e) {
47         stderr.printf ("%s\n", e.message);
48     }
49 }