[totem] youtube: Add optional support for compiling against libgdata 0.9.x



commit 05ba9e12ddcfb12bc2af695726e24712a2767ea0
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Jun 20 18:23:30 2011 +0100

    youtube: Add optional support for compiling against libgdata 0.9.x
    
    This migrates Totem to the API changes in libgdata 0.9.0 and (unreleased)
    0.9.1 if they're available.

 configure.in                        |    7 +++++++
 src/plugins/youtube/totem-youtube.c |   16 ++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/configure.in b/configure.in
index 178976d..ec81d4a 100644
--- a/configure.in
+++ b/configure.in
@@ -481,6 +481,13 @@ for plugin in ${used_plugins}; do
 				AC_DEFINE([HAVE_LIBGDATA_0_7],[1],[Define if libgdata >= 0.7.0 is available])
 			fi
 
+			# For the API breaks in libgdata 0.9. Remove this once we depend on libgdata >= 0.9.1
+			PKG_CHECK_MODULES(LIBGDATA_0_9, libgdata >= 0.9.1,
+				[HAVE_LIBGDATA_0_9=yes], [HAVE_LIBGDATA_0_9=no])
+			if test "${HAVE_LIBGDATA_0_9}" = "yes" ; then
+				AC_DEFINE([HAVE_LIBGDATA_0_9],[1],[Define if libgdata >= 0.9.1 is available])
+			fi
+
 			PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4,
 				[HAVE_LIBSOUP=yes], [HAVE_LIBSOUP=no])
 			if test "${HAVE_LIBSOUP}" != "yes" ; then
diff --git a/src/plugins/youtube/totem-youtube.c b/src/plugins/youtube/totem-youtube.c
index 710ce75..bc19a2a 100644
--- a/src/plugins/youtube/totem-youtube.c
+++ b/src/plugins/youtube/totem-youtube.c
@@ -591,6 +591,17 @@ execute_query (TotemYouTubePlugin *self, guint tree_view, gboolean clear_tree_vi
 	if (clear_tree_view == TRUE)
 		gtk_list_store_clear (self->priv->list_store[tree_view]);
 
+#ifdef HAVE_LIBGDATA_0_9
+	if (tree_view == SEARCH_TREE_VIEW) {
+		gdata_youtube_service_query_videos_async (self->priv->service, self->priv->query[tree_view], data->query_cancellable,
+		                                          (GDataQueryProgressCallback) query_progress_cb, data, NULL,
+		                                          (GAsyncReadyCallback) query_finished_cb, data);
+	} else {
+		gdata_youtube_service_query_related_async (self->priv->service, self->priv->playing_video, self->priv->query[tree_view],
+		                                           data->query_cancellable, (GDataQueryProgressCallback) query_progress_cb, data, NULL,
+		                                           (GAsyncReadyCallback) query_finished_cb, data);
+	}
+#else
 	if (tree_view == SEARCH_TREE_VIEW) {
 		gdata_youtube_service_query_videos_async (self->priv->service, self->priv->query[tree_view], data->query_cancellable,
 		                                          (GDataQueryProgressCallback) query_progress_cb, data,
@@ -600,6 +611,7 @@ execute_query (TotemYouTubePlugin *self, guint tree_view, gboolean clear_tree_vi
 		                                           data->query_cancellable, (GDataQueryProgressCallback) query_progress_cb, data,
 		                                           (GAsyncReadyCallback) query_finished_cb, data);
 	}
+#endif /* !HAVE_LIBGDATA_0_9 */
 }
 
 void
@@ -634,7 +646,11 @@ search_button_clicked_cb (GtkButton *button, TotemYouTubePlugin *self)
 		g_assert (priv->regex != NULL);
 
 		/* Set up the GData service (needed for the tree views' queries) */
+#ifdef HAVE_LIBGDATA_0_9
+		priv->service = gdata_youtube_service_new (DEVELOPER_KEY, NULL);
+#else
 		priv->service = gdata_youtube_service_new (DEVELOPER_KEY, CLIENT_ID);
+#endif /* !HAVE_LIBGDATA_0_9 */
 
 		/* Set up network timeouts, if they're supported by our version of libgdata.
 		 * This will return from queries with %GDATA_SERVICE_ERROR_NETWORK_ERROR if network operations take longer than 30 seconds. */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]