From: Philipp Zabel Date: Tue, 17 Nov 2009 11:01:43 +0000 (+0100) Subject: Google plugin: add "Call cinema" action, using libhildonmime X-Git-Tag: v0.0.9~12 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=74b0343b208c9fa6b882ff76fb6f4f5c24f4c142;p=cinaest Google plugin: add "Call cinema" action, using libhildonmime Using libhildonmime to get the default action for tel:// URIs, this should open the phone UI on the device. --- diff --git a/Makefile.am b/Makefile.am index e9cabbb..a04337b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -141,10 +141,10 @@ libgoogle_plugin_la_VALASOURCES = \ src/plugins/google-parser.vala libgoogle_plugin_la_VALAFLAGS = --vapidir ./vapi --pkg config --pkg cinaest \ - --pkg hildon-1 --pkg libosso -libgoogle_plugin_la_CFLAGS = ${CINAEST_CFLAGS} ${HILDON_CFLAGS} ${OSSO_CFLAGS} + --pkg hildon-1 --pkg libhildonmime --pkg libosso +libgoogle_plugin_la_CFLAGS = ${CINAEST_CFLAGS} ${HILDON_CFLAGS} ${HILDONMIME_CFLAGS} ${OSSO_CFLAGS} libgoogle_plugin_la_CPPFLAGS = ${CALENDAR_CFLAGS} -libgoogle_plugin_la_LIBADD = ${CALENDAR_LIBS} ${CINAEST_LIBS} ${HILDON_LIBS} ${OSSO_LIBS} +libgoogle_plugin_la_LIBADD = ${CALENDAR_LIBS} ${CINAEST_LIBS} ${HILDON_LIBS} ${HILDONMIME_LIBS} ${OSSO_LIBS} libgoogle_plugin_la_LDFLAGS = -module src/plugins/google-plugin.c: ${libgoogle_plugin_la_VALASOURCES} diff --git a/configure.ac b/configure.ac index c43cf87..9fb4b69 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,10 @@ PKG_CHECK_MODULES(HILDON, hildon-1 >= 2.2.0) AC_SUBST(HILDON_LIBS) AC_SUBST(HILDON_CFLAGS) +PKG_CHECK_MODULES(HILDONMIME, libhildonmime >= 2.1.3) +AC_SUBST(HILDONMIME_LIBS) +AC_SUBST(HILDONMIME_CFLAGS) + PKG_CHECK_MODULES(OSSO, libosso >= 2.20) AC_SUBST(OSSO_LIBS) AC_SUBST(OSSO_CFLAGS) diff --git a/src/plugins/google-plugin.vala b/src/plugins/google-plugin.vala index 69a9f29..a99d114 100644 --- a/src/plugins/google-plugin.vala +++ b/src/plugins/google-plugin.vala @@ -66,6 +66,8 @@ class GooglePlugin : Plugin { if (movie != null) { list.append (new MovieAction (_("Add to calendar"), on_add_calendar_event, movie, window)); + if (movie.cinema != null && movie.cinema.phone != null) + list.append (new MovieAction (_("Call cinema"), on_call_cinema, movie, window)); } return list; @@ -112,6 +114,25 @@ class GooglePlugin : Plugin { dialog.destroy (); } + private void on_call_cinema (Movie _movie, Gtk.Window window) { + var movie = (GoogleMovie) _movie; + var url = "tel://" + movie.cinema.phone; + + try { + var action = Hildon.URIAction.get_default_action_by_uri (url); + if (action != null) { + action.open (url); + } else { + var banner = (Banner) Banner.show_information_with_markup (window, null, "Failed to get tel:// URI action"); + banner.set_timeout (1500); + } + } catch (Error e) { + if (e is Hildon.URIError) { + stdout.printf ("Error: %s\n", e.message); + } + } + } + public override void settings_dialog (Gtk.Window window) { GoogleSource source = (GoogleSource) sources.data; var dialog = new Gtk.Dialog ();