~michael.lazarski/contractor/master

« back to all changes in this revision

Viewing changes to src/test_client.vala

  • Committer: michael lampe
  • Date: 2013-02-04 23:34:18 UTC
  • Revision ID: mgoldhand@gmail.com-20130204233418-77vgb3rx4l6atl51
test client now works with a simple contract

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
[DBus (name = "org.elementary.contractor")]
 
2
using GLib;
 
3
[DBus (name = "org.elementary.Contractor")]
3
4
interface Demo : Object {
4
 
    public abstract GLib.HashTable<string,string>[] GetServicesByLocation (string strlocation, string? file_mime="")    throws IOError;
 
5
    public abstract string GetServicesByLocation (string strlocation) throws IOError;
 
6
     public signal void pong (int count, string msg);
5
7
}
6
8
 
7
9
void main () {
 
10
    var loop = new MainLoop();
8
11
    try {
9
 
        Demo demo = Bus.get_proxy_sync (BusType.SESSION, "org.elementary.contractor",
10
 
                                        "/org/elementary/contractor");
 
12
        message("trying");
 
13
        Demo demo = Bus.get_proxy_sync (BusType.SESSION, "org.elementary.Contractor", "/org/elementary/contractor");
 
14
       demo.pong.connect((m) => {
 
15
            stdout.printf ("Got pong for msg '%d'\n", m);
 
16
            loop.quit ();
 
17
        });
11
18
 
12
 
        var contracts = demo.GetServicesByLocation ("file:///home/kitkat/plop.tar");
13
 
        foreach(var entry in contracts)
14
 
        {
15
 
            message ("desc: %s icon: %s", entry.lookup ("Description"), entry.lookup ("IconName"));
16
 
        }
17
 
    } catch (IOError e) {
 
19
        var contract = demo.GetServicesByLocation ("file:///home/michael/plop.tar");
 
20
    } catch (Error e) {
18
21
        stderr.printf ("%s\n", e.message);
19
22
    }
20
23
}