public class GoogleMovie : Movie {
public string cinema_name;
public string cinema_phone;
- public string runtime;
+ public int runtime;
public string showtimes;
}
timeinfo.hour = hour;
showtime = timeinfo.mktime ();
- int runtime = 3600 * movie.runtime.to_int () + 60 * movie.runtime.str ("hr ").offset (3).to_int ();
+ int runtime = movie.runtime;
if (runtime == 0) {
// Default to 120min if we failed to parse the runtime
runtime = 7200;
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)
movie.rating = (int) object.get_double_member ("rating");
movie.cinema_name = object.get_string_member ("cinema_name");
movie.cinema_phone = object.get_string_member ("cinema_phone");
+ movie.runtime = (int) object.get_int_member ("runtime");
movie.showtimes = object.get_string_member ("showtimes");
- movie.secondary = movie.cinema_name + " - " + movie.showtimes;
+ if (movie.runtime > 0)
+ movie.secondary = "%d min - %s - %s".printf (movie.runtime / 60, movie.cinema_name, movie.showtimes);
+ else
+ movie.secondary = movie.cinema_name + " - " + movie.showtimes;
callback (movie);
}
}
[ModuleInit]
-public Type register_plugin () {
+public Type register_plugin (TypeModule module) {
// types are registered automatically
return typeof (GooglePlugin);
}