namespace Birdie.DBUS {

    [DBus (name = "org.birdieapp.birdie")]
    public class Server : Object {

        Birdie birdie;
        this.birdie = birdie;

        public void show_tweet_dialog() {
            Widgets.TweetDialog dialog = new Widgets.TweetDialog (birdie);
            dialog.show_all ();
        }
        
        public void switch_timeline (string timeline) {
            stdout.printf ("Switching timeline to %s\n", timeline);
            this.birdie.switch_timeline (timeline);
            this.birdie.home.set_active (true);
            this.birdie.activate ();
        }
        
        public void ping_error () throws Error {
            throw new BirdieError.SOME_ERROR ("There was an error!");
        }        

        public signal void pong (int count, string msg);
    }

    [DBus (name = "org.birdieapp.birdie")]
    public errordomain BirdieError {
        SOME_ERROR
    }
    
    
    void on_bus_aquired (DBusConnection conn) {
        try {
            conn.register_object ("/org/birdieapp/birdie", new Server());
        } catch (IOError e) {
            stderr.printf ("Could not register service\n");
        }
    }

}
