using GLib;

[DBus (name="org.maemo.garage.feedhandler")]
public class FeedHandler : Object {
    [DBus (name = "mime_open")]
    public void mime_open(string url) {
        message("URL received: %s", url);
    }
}

void main() {
    var loop = new MainLoop(null, false);
    try {
        var conn = DBus.Bus.get(DBus.BusType.SESSION);
        dynamic DBus.Object bus = conn.get_object("org.freedesktop.DBus",
                                                  "/org/freedesktop/DBus",
                                                  "org.freedesktop.DBus");
        uint request_name_result = bus.RequestName(
                                 "org.maemo.garage.feedhandler", (uint)0);
        if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
            var server = new FeedHandler();
            conn.register_object("/org/maemo/garge/feedhandler", server);
            loop.run();
        }

    }
    catch (Error e) {
        stderr.printf("OOps: %s\n", e.message);
    }
}

