X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fgoogle-plugin.vala;h=65abc6fa992aff582493de62066786eca5fe6c4f;hb=6cec48bf094d167ec7cd82fd0cde885d7b06ff92;hp=d02b7a8f3f1a3f50aa6a36829b61a78acd667acf;hpb=204b335f74d7ee48c46b15fde50df252331787c6;p=cinaest diff --git a/src/plugins/google-plugin.vala b/src/plugins/google-plugin.vala index d02b7a8..65abc6f 100644 --- a/src/plugins/google-plugin.vala +++ b/src/plugins/google-plugin.vala @@ -210,21 +210,27 @@ class GoogleSource : MovieSource { SourceFunc get_movies_callback; public override async int get_movies (MovieFilter filter, MovieSource.ReceiveMovieFunction _callback, int limit, Cancellable? cancellable) { - var conn = DBus.Bus.get (DBus.BusType.SESSION); - string search_path; - - dynamic DBus.Object server = conn.get_object ("org.maemo.cinaest.GoogleShowtimes", - "/org/maemo/cinaest/googleshowtimes", - "org.maemo.cinaest.MovieService"); - server.NewSearch (out search_path); - - search = conn.get_object ("org.maemo.cinaest.GoogleShowtimes", - search_path, - "org.maemo.cinaest.MovieSearch"); - - callback = _callback; - search.MoviesFound += on_movies_found; - search.start (filter.title); + try { + string search_path; + dynamic DBus.Object server; + var conn = DBus.Bus.get (DBus.BusType.SESSION); + + server = conn.get_object ("org.maemo.cinaest.GoogleShowtimes", + "/org/maemo/cinaest/googleshowtimes", + "org.maemo.cinaest.MovieService"); + server.NewSearch (out search_path); + + search = conn.get_object ("org.maemo.cinaest.GoogleShowtimes", + search_path, + "org.maemo.cinaest.MovieSearch"); + + callback = _callback; + search.MoviesFound.connect (on_movies_found); + search.start (filter.title); + } catch (Error e1) { + Banner.show_information (null, null, e1.message); + return 0; + } get_movies_callback = get_movies.callback; if (cancellable != null) @@ -244,6 +250,7 @@ class GoogleSource : MovieSource { private void on_movies_found (DBus.Object sender, string[] movies, bool finished) { print ("found %d movies\n", movies.length); var parser = new Json.Parser (); + var result = new SList (); for (int i = 0; i < movies.length; i++) { var movie = new GoogleMovie (); @@ -265,9 +272,11 @@ class GoogleSource : MovieSource { else movie.secondary = movie.cinema_name + " - " + movie.showtimes; - callback (movie); + result.append (movie); } + callback (result); + if (finished) { search = null; Idle.add (get_movies_callback); @@ -293,13 +302,13 @@ class GoogleSource : MovieSource { return description; } - public override bool get_editable () { - return false; + public override SourceFlags get_flags () { + return SourceFlags.ONLINE; } } [ModuleInit] -public Type register_plugin () { +public Type register_plugin (TypeModule module) { // types are registered automatically return typeof (GooglePlugin); }