[grilo-plugins] upnp: treat operation failure as something expected



commit e0cd9cec5d9946e0d10a4a757974cffebd80833e
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Sep 29 10:56:32 2011 +0000

    upnp: treat operation failure as something expected
    
    When using gupnp_service_proxy_end_action() ignore the returned result, and
    just check if the required data has any value or not.
    
    Reason is that with some versions, not having elements matching the required
    search text means getting an error in that operation, while in others it
    doesn't mean it, but just an empty result.
    
    As we want to treat not having elements as a typical case, better do not print
    the error as a warning, and instead notify that there are no results.
    
    This fixes https://bugzilla.gnome.org/show_bug.cgi?id=653756
    
    Signed-off-by: Juan A. Suarez Romero <jasuarez igalia com>

 src/media/upnp/grl-upnp.c |   50 ++++++++++++++------------------------------
 1 files changed, 16 insertions(+), 34 deletions(-)
---
diff --git a/src/media/upnp/grl-upnp.c b/src/media/upnp/grl-upnp.c
index 9f9a365..c81922a 100644
--- a/src/media/upnp/grl-upnp.c
+++ b/src/media/upnp/grl-upnp.c
@@ -939,7 +939,6 @@ gupnp_browse_cb (GUPnPServiceProxy *service,
   gchar *didl = NULL;
   guint returned = 0;
   guint matches = 0;
-  gboolean result;
   struct OperationSpec *os;
   GUPnPDIDLLiteParser *didl_parser;
 
@@ -948,31 +947,23 @@ gupnp_browse_cb (GUPnPServiceProxy *service,
   os = (struct OperationSpec *) user_data;
   didl_parser = gupnp_didl_lite_parser_new ();
 
-  result =
-    gupnp_service_proxy_end_action (service, action, &error,
-				    "Result", G_TYPE_STRING, &didl,
-				    "NumberReturned", G_TYPE_UINT, &returned,
-				    "TotalMatches", G_TYPE_UINT, &matches,
-				    NULL);
+  gupnp_service_proxy_end_action (service, action, &error,
+                                  "Result", G_TYPE_STRING, &didl,
+                                  "NumberReturned", G_TYPE_UINT, &returned,
+                                  "TotalMatches", G_TYPE_UINT, &matches,
+                                  NULL);
 
-  if (!result) {
-    GRL_WARNING ("Operation (browse, search or query) failed");
-    os->callback (os->source, os->operation_id, NULL, 0, os->user_data, error);
+  if (!didl || !returned) {
+    GRL_DEBUG ("Got no results");
+    os->callback (os->source, os->operation_id,
+                  NULL, 0, os->user_data, error? error: NULL);
     if (error) {
-      GRL_WARNING ("  Reason: %s", error->message);
       g_error_free (error);
     }
 
     goto free_resources;
   }
 
-  if (!didl || !returned) {
-    GRL_DEBUG ("Got no results");
-    os->callback (os->source, os->operation_id, NULL, 0, os->user_data, NULL);
-
-    goto free_resources;
-  }
-
   /* Use os->count to emit "remaining" information */
   if (os->count > returned) {
     os->count = returned;
@@ -1018,7 +1009,6 @@ gupnp_metadata_cb (GUPnPServiceProxy *service,
 {
   GError *error = NULL;
   gchar *didl = NULL;
-  gboolean result;
   GrlMediaSourceMetadataSpec *ms;
   GUPnPDIDLLiteParser *didl_parser;
 
@@ -1027,29 +1017,21 @@ gupnp_metadata_cb (GUPnPServiceProxy *service,
   ms = (GrlMediaSourceMetadataSpec *) user_data;
   didl_parser = gupnp_didl_lite_parser_new ();
 
-  result =
-    gupnp_service_proxy_end_action (service, action, &error,
-				    "Result", G_TYPE_STRING, &didl,
-				    NULL);
+  gupnp_service_proxy_end_action (service, action, &error,
+                                  "Result", G_TYPE_STRING, &didl,
+                                  NULL);
 
-  if (!result) {
-    GRL_WARNING ("Metadata operation failed");
-    ms->callback (ms->source, ms->metadata_id, ms->media, ms->user_data, error);
+  if (!didl) {
+    GRL_DEBUG ("Got no metadata");
+    ms->callback (ms->source, ms->metadata_id,
+                  ms->media, ms->user_data, error? error: NULL);
     if (error) {
-      GRL_WARNING ("  Reason: %s", error->message);
       g_error_free (error);
     }
 
     goto free_resources;
   }
 
-  if (!didl) {
-    GRL_DEBUG ("Got no metadata");
-    ms->callback (ms->source, ms->metadata_id, ms->media,  ms->user_data, NULL);
-
-    goto free_resources;
-  }
-
   g_signal_connect (G_OBJECT (didl_parser),
                     "object-available",
                     G_CALLBACK (gupnp_metadata_result_cb),



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