[grilo-plugins] upnp: require upnp-av >= 0.5



commit d411891c8811848ff83791db408d9d54bf5a44ed
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Jan 27 11:02:41 2011 +0100

    upnp: require upnp-av >= 0.5
    
    This makes the upnp plugin code much easier to follow and is a
    reasonable requirement.

 configure.ac         |   28 ++----------
 src/upnp/Makefile.am |    5 --
 src/upnp/grl-upnp.c  |  110 ++-----------------------------------------------
 3 files changed, 10 insertions(+), 133 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 13b9e24..240b1a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,7 +113,7 @@ PKG_CHECK_MODULES(GIO, gio-2.0, HAVE_GIO=yes, HAVE_GIO=no)
 
 PKG_CHECK_MODULES(GUPNP, gupnp-1.0 >= 0.13, HAVE_GUPNP=yes, HAVE_GUPNP=no)
 
-PKG_CHECK_MODULES(GUPNPAV, gupnp-av-1.0, HAVE_GUPNPAV=yes, HAVE_GUPNPAV=no)
+PKG_CHECK_MODULES(GUPNPAV, gupnp-av-1.0 >= 0.5, HAVE_GUPNPAV=yes, HAVE_GUPNPAV=no)
 
 PKG_CHECK_MODULES(SQLITE, sqlite3, HAVE_SQLITE=yes, HAVE_SQLITE=no)
 
@@ -132,21 +132,6 @@ PKG_CHECK_MODULES(TRACKER_SPARQL, tracker-sparql-0.10,
                                                                      HAVE_TRACKER_SPARQL=no)])
 
 # ----------------------------------------------------------
-# GUPNP-AV VERSION
-# ----------------------------------------------------------
-
-GUPNPAV_OLD_VERSION=no
-if test "x$HAVE_GUPNPAV" = "xyes"; then
-        gupnpav_version=`${PKG_CONFIG} --modversion gupnp-av-1.0`
-        gupnpav_version_major=`echo $gupnpav_version | awk -F. '{ print $1 }'`
-        gupnpav_version_minor=`echo $gupnpav_version | awk -F. '{ print $2 }'`
-        if test $gupnpav_version_major -eq 0 -a $gupnpav_version_minor -lt 5; then
-           GUPNPAV_OLD_VERSION=yes
-        fi
-fi
-AM_CONDITIONAL(GUPNPAV_OLD_VERSION, test "x$GUPNPAV_OLD_VERSION" = "xyes")
-
-# ----------------------------------------------------------
 # GDATA VERSION
 # ----------------------------------------------------------
 
@@ -290,20 +275,17 @@ AC_ARG_ENABLE(upnp,
                         fi
                         if test "x$HAVE_GUPNPAV" = "xno"; then
                            AC_MSG_ERROR([gupnp-av not found, install it or use --disable-upnp])
-                        elif test "x$GUPNPAV_OLD_VERSION" = "xno" -a "$xHAVE_XML" = "xno"; then
+                        fi
+                        if test "$xHAVE_XML" = "xno"; then
                            AC_MSG_ERROR([xml2 not found, install it or use --disable-upnp])
                         fi
                 esac
         ],
         [
-                if test "x$HAVE_GUPNP" = "xyes" -a "x$HAVE_GUPNPAV" = "xyes"; then
-                   if test "x$GUPNPAV_OLD_VERSION" = "xyes" -o "x$HAVE_XML" = "xyes"; then
+                if test "x$HAVE_GUPNP" = "xyes" -a "x$HAVE_GUPNPAV" = "xyes" -a "x$HAVE_XML" = "xyes"; then
                         enable_upnp=yes
-                   else
-                        enable_upnp=no
-                   fi
                 else
-                   enable_upnp=no
+                        enable_upnp=no
                 fi
         ])
 
diff --git a/src/upnp/Makefile.am b/src/upnp/Makefile.am
index 3e1fba8..b6b09bd 100644
--- a/src/upnp/Makefile.am
+++ b/src/upnp/Makefile.am
@@ -25,16 +25,11 @@ libgrlupnp_la_LDFLAGS = \
 	-module		\
 	-avoid-version
 
-if GUPNPAV_OLD_VERSION
-libgrlupnp_la_CFLAGS +=	\
-	-DGUPNPAV_OLD_VERSION
-else
 libgrlupnp_la_CFLAGS +=	\
 	$(XML_CFLAGS)
 
 libgrlupnp_la_LIBADD +=	\
 	$(XML_LIBS)
-endif
 
 libgrlupnp_la_SOURCES = grl-upnp.c grl-upnp.h
 
diff --git a/src/upnp/grl-upnp.c b/src/upnp/grl-upnp.c
index 0292d10..a3485e1 100644
--- a/src/upnp/grl-upnp.c
+++ b/src/upnp/grl-upnp.c
@@ -32,10 +32,7 @@
 #include <libgupnp-av/gupnp-av.h>
 #include <string.h>
 #include <stdlib.h>
-
-#ifndef GUPNPAV_OLD_VERSION
 #include <libxml/tree.h>
-#endif
 
 #include "grl-upnp.h"
 
@@ -526,12 +523,7 @@ didl_res_get_protocol_info (xmlNode* res_node, gint field)
   gchar* value;
   gchar** array;
 
-#ifdef GUPNPAV_OLD_VERSION
-  pinfo = gupnp_didl_lite_property_get_attribute (res_node, "protocolInfo");
-#else
   pinfo = (gchar *) xmlGetProp (res_node, (const xmlChar *) "protocolInfo");
-#endif
-
   if (pinfo == NULL) {
     return NULL;
   }
@@ -551,22 +543,13 @@ didl_res_get_protocol_info (xmlNode* res_node, gint field)
 }
 
 static GList *
-didl_get_supported_resources (
-#ifdef GUPNPAV_OLD_VERSION
-                              xmlNode *didl_node)
-#else
-                              GUPnPDIDLLiteObject *didl)
-#endif
+didl_get_supported_resources (GUPnPDIDLLiteObject *didl)
 {
   GList *properties, *node;
   xmlNode *xml_node;
   gchar *protocol;
 
-#ifdef GUPNPAV_OLD_VERSION
-  properties = gupnp_didl_lite_object_get_property (didl_node, "res");
-#else
   properties = gupnp_didl_lite_object_get_properties (didl, "res");
-#endif
 
   node = properties;
   while (node) {
@@ -749,68 +732,31 @@ get_thumbnail (GList *nodes)
 
 static gchar *
 get_value_for_key (GrlKeyID key_id,
-#ifdef GUPNPAV_OLD_VERSION
-                   xmlNode *didl_node,
-#else
                    GUPnPDIDLLiteObject *didl,
-#endif
                    GList *props)
 {
   GList* list;
   gchar* val = NULL;
   const gchar* upnp_key;
 
-#ifndef GUPNPAV_OLD_VERSION
   xmlNode *didl_node = gupnp_didl_lite_object_get_xml_node (didl);
-#endif
-
   upnp_key = get_upnp_key (key_id);
 
   if (key_id == GRL_METADATA_KEY_CHILDCOUNT) {
-
-#ifdef GUPNPAV_OLD_VERSION
-    val = gupnp_didl_lite_property_get_attribute (didl_node, "childCount");
-#else
-    val = (gchar *) xmlGetProp (didl_node, (const xmlChar *) "childCount");
-#endif
-
+    val = (gchar *) xmlGetProp (didl_node,
+                                (const xmlChar *) "childCount");
   } else if (key_id == GRL_METADATA_KEY_MIME && props) {
     val = didl_res_get_protocol_info ((xmlNode *) props->data, 2);
   } else if (key_id == GRL_METADATA_KEY_DURATION && props) {
-
-#ifdef GUPNPAV_OLD_VERSION
-    val = gupnp_didl_lite_property_get_attribute ((xmlNode *) props->data,
-                                                  "duration");
-#else
     val = (gchar *) xmlGetProp ((xmlNodePtr) props->data,
                                 (const xmlChar *) "duration");
-#endif
-
   } else if (key_id == GRL_METADATA_KEY_URL && props) {
-
-#ifdef GUPNPAV_OLD_VERSION
-    val = gupnp_didl_lite_property_get_value ((xmlNode *) props->data);
-#else
     val = (gchar *) xmlNodeGetContent ((xmlNode *) props->data);
-#endif
-
   } else if (key_id == GRL_METADATA_KEY_THUMBNAIL && props) {
     val = g_strdup (gupnp_didl_lite_object_get_album_art (didl));
     if (!val)
       val = get_thumbnail (props);
-
   } else if (upnp_key) {
-
-#ifdef GUPNPAV_OLD_VERSION
-    list = gupnp_didl_lite_object_get_property (didl_node, upnp_key);
-    if (list) {
-      val = gupnp_didl_lite_property_get_value ((xmlNode*) list->data);
-      g_list_free (list);
-    } else if (props && props->data) {
-      val = gupnp_didl_lite_property_get_attribute ((xmlNode *) props->data,
-                                                    upnp_key);
-    }
-#else
     list = gupnp_didl_lite_object_get_properties (didl, upnp_key);
     if (list) {
       val = (gchar *) xmlNodeGetContent ((xmlNode*) list->data);
@@ -819,8 +765,6 @@ get_value_for_key (GrlKeyID key_id,
       val = (gchar *) xmlGetProp ((xmlNodePtr) props->data,
                                   (const xmlChar *) upnp_key);
     }
-#endif
-
   }
 
   return val;
@@ -859,20 +803,11 @@ set_metadata_value (GrlMedia *media,
 
 static GrlMedia *
 build_media_from_didl (GrlMedia *content,
-#ifdef GUPNPAV_OLD_VERSION
-                       xmlNode *didl_node,
-#else
                        GUPnPDIDLLiteObject *didl_node,
-#endif
                        GList *keys)
 {
-#ifdef GUPNPAV_OLD_VERSION
-  gchar *id;
-  gchar *class;
-#else
   const gchar *id;
   const gchar *class;
-#endif
 
   GrlMedia *media = NULL;
   GList *didl_props;
@@ -884,12 +819,7 @@ build_media_from_didl (GrlMedia *content,
     media = content;
   } else {
 
-#ifdef GUPNPAV_OLD_VERSION
-    if (gupnp_didl_lite_object_is_container (didl_node)) {
-#else
     if (GUPNP_IS_DIDL_LITE_CONTAINER (didl_node)) {
-#endif
-
       media = grl_media_box_new ();
     } else {
       if (!media) {
@@ -930,10 +860,6 @@ build_media_from_didl (GrlMedia *content,
     iter = g_list_next (iter);
   }
 
-#ifdef GUPNPAV_OLD_VERSION
-  g_free (id);
-#endif
-
   g_list_free (didl_props);
 
   return media;
@@ -941,11 +867,7 @@ build_media_from_didl (GrlMedia *content,
 
 static void
 gupnp_browse_result_cb (GUPnPDIDLLiteParser *parser,
-#ifdef GUPNPAV_OLD_VERSION
-			xmlNode *didl,
-#else
-                        GUPnPDIDLLiteObject *didl,
-#endif
+			GUPnPDIDLLiteObject *didl,
 			gpointer user_data)
 {
   GrlMedia *media;
@@ -1009,13 +931,6 @@ gupnp_browse_cb (GUPnPServiceProxy *service,
     os->count = returned;
   }
 
-#ifdef GUPNPAV_OLD_VERSION
-  gupnp_didl_lite_parser_parse_didl (didl_parser,
-				     didl,
-				     gupnp_browse_result_cb,
-				     os,
-				     &error);
-#else
   g_signal_connect (G_OBJECT (didl_parser),
                     "object-available",
                     G_CALLBACK (gupnp_browse_result_cb),
@@ -1023,8 +938,6 @@ gupnp_browse_cb (GUPnPServiceProxy *service,
   gupnp_didl_lite_parser_parse_didl (didl_parser,
                                      didl,
                                      &error);
-#endif
-
   if (error) {
     GRL_WARNING ("Failed to parse DIDL result: %s", error->message);
     os->callback (os->source, os->operation_id, NULL, 0, os->user_data, error);
@@ -1041,11 +954,7 @@ gupnp_browse_cb (GUPnPServiceProxy *service,
 
 static void
 gupnp_metadata_result_cb (GUPnPDIDLLiteParser *parser,
-#ifdef GUPNPAV_OLD_VERSION
-			  xmlNode *didl,
-#else
-                          GUPnPDIDLLiteObject *didl,
-#endif
+			  GUPnPDIDLLiteObject *didl,
 			  gpointer user_data)
 {
   GrlMediaSourceMetadataSpec *ms = (GrlMediaSourceMetadataSpec *) user_data;
@@ -1094,13 +1003,6 @@ gupnp_metadata_cb (GUPnPServiceProxy *service,
     goto free_resources;
   }
 
-#ifdef GUPNPAV_OLD_VERSION
-  gupnp_didl_lite_parser_parse_didl (didl_parser,
-				     didl,
-				     gupnp_metadata_result_cb,
-				     ms,
-				     &error);
-#else
   g_signal_connect (G_OBJECT (didl_parser),
                     "object-available",
                     G_CALLBACK (gupnp_metadata_result_cb),
@@ -1108,8 +1010,6 @@ gupnp_metadata_cb (GUPnPServiceProxy *service,
   gupnp_didl_lite_parser_parse_didl (didl_parser,
                                      didl,
                                      &error);
-#endif
-
   if (error) {
     GRL_WARNING ("Failed to parse DIDL result: %s", error->message);
     ms->callback (ms->source, ms->media, ms->user_data, error);



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