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)
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<Movie> ();
for (int i = 0; i < movies.length; i++) {
var movie = new GoogleMovie ();
else
movie.secondary = movie.cinema_name + " - " + movie.showtimes;
- callback (movie);
+ result.append (movie);
}
+ callback (result);
+
if (finished) {
search = null;
Idle.add (get_movies_callback);
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);
}