diff options
author | Juan A. Suarez Romero <jasuarez@igalia.com> | 2011-09-29 10:56:32 +0000 |
---|---|---|
committer | Juan A. Suarez Romero <jasuarez@igalia.com> | 2011-12-13 17:44:10 +0000 |
commit | 13832bcc711342441be2349b72f9a9776d08b6ee (patch) | |
tree | 42667bdef8c2ece86c383ea160df410796043a3b | |
parent | 6c49e1612b064beb011a585a5ac64cf773fc7580 (diff) | |
download | grilo-plugins-13832bcc711342441be2349b72f9a9776d08b6ee.tar.gz |
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>
-rw-r--r-- | 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 a8e990c..744fefb 100644 --- a/src/media/upnp/grl-upnp.c +++ b/src/media/upnp/grl-upnp.c @@ -925,7 +925,6 @@ gupnp_browse_cb (GUPnPServiceProxy *service, gchar *didl = NULL; guint returned = 0; guint matches = 0; - gboolean result; struct OperationSpec *os; GUPnPDIDLLiteParser *didl_parser; @@ -934,31 +933,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; @@ -1004,7 +995,6 @@ gupnp_metadata_cb (GUPnPServiceProxy *service, { GError *error = NULL; gchar *didl = NULL; - gboolean result; GrlMediaSourceMetadataSpec *ms; GUPnPDIDLLiteParser *didl_parser; @@ -1013,29 +1003,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), |