[gupnp-tools] all: Fix inconsistency regarding action errors



commit b058d9843b15e3ab3b77b4acc4d72f3ffb332578
Author: Jens Georg <mail jensge org>
Date:   Mon Mar 28 10:56:58 2022 +0200

    all: Fix inconsistency regarding action errors
    
    The current async api is a bit weird, you need try to get results from
    the action to capture SOAP errors

 src/av-cp/renderer-controls.c | 26 +++++++++++++++++++++-----
 src/network-light/upnp.c      | 13 ++++++++++---
 src/upload/transfer.c         | 11 ++++++++---
 3 files changed, 39 insertions(+), 11 deletions(-)
---
diff --git a/src/av-cp/renderer-controls.c b/src/av-cp/renderer-controls.c
index e1250e7..3e03b03 100644
--- a/src/av-cp/renderer-controls.c
+++ b/src/av-cp/renderer-controls.c
@@ -221,10 +221,18 @@ set_av_transport_uri_cb (GObject *object, GAsyncResult *res, gpointer user_data)
 
         udn = gupnp_service_info_get_udn (GUPNP_SERVICE_INFO (object));
 
-        gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
-                                                res,
-                                                &error);
-
+        GUPnPServiceProxyAction *action;
+        action = gupnp_service_proxy_call_action_finish (
+                GUPNP_SERVICE_PROXY (object),
+                res,
+                &error);
+
+        // The above call will only catch issues with the HTTP transport, not
+        // with the call itself. So we need to call an empty get on the action
+        // as well to get any SOAP error
+        if (error == NULL) {
+                gupnp_service_proxy_action_get_result (action, &error, NULL);
+        }
         if (error != NULL) {
                 g_warning ("Failed to set URI '%s' on %s: %s",
                            gupnp_didl_lite_resource_get_uri (data->resource),
@@ -707,9 +715,17 @@ set_volume_cb (GObject *object, GAsyncResult *res, gpointer user_data)
 {
         GError *error;
         GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY (object);
+        GUPnPServiceProxyAction *action;
 
         error = NULL;
-        if (!gupnp_service_proxy_call_action_finish (proxy, res, &error)) {
+        action = gupnp_service_proxy_call_action_finish (proxy, res, &error);
+
+        if (error == NULL) {
+                // No transport error, check for SOAP error
+                gupnp_service_proxy_action_get_result (action, &error, NULL);
+        }
+
+        if (error != NULL) {
                 const char *udn;
 
                 udn = gupnp_service_info_get_udn (GUPNP_SERVICE_INFO (object));
diff --git a/src/network-light/upnp.c b/src/network-light/upnp.c
index 1536d6c..f02b077 100644
--- a/src/network-light/upnp.c
+++ b/src/network-light/upnp.c
@@ -440,10 +440,17 @@ on_service_proxy_action_ret (GObject *object,
                              gpointer user_data)
 {
         GError *error = NULL;
+        GUPnPServiceProxyAction *action;
 
-        gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
-                                                result,
-                                                &error);
+        action = gupnp_service_proxy_call_action_finish (
+                GUPNP_SERVICE_PROXY (object),
+                result,
+                &error);
+
+        if (error == NULL) {
+                // Check for SOAP transport error
+                gupnp_service_proxy_action_get_result (action, &error, NULL);
+        }
 
         if (error != NULL) {
                 GUPnPServiceInfo *info = GUPNP_SERVICE_INFO (object);
diff --git a/src/upload/transfer.c b/src/upload/transfer.c
index d493a3b..64e645b 100644
--- a/src/upload/transfer.c
+++ b/src/upload/transfer.c
@@ -44,15 +44,20 @@ get_transfer_progress_cb (GObject *object,
         TrackTransferData *data;
         guint64 total, length;
         gchar *status;
+        GUPnPServiceProxyAction *action;
 
         data = (TrackTransferData *) user_data;
 
         error = NULL;
         total = length = 0;
         status = NULL;
-        gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
-                                                result,
-                                                &error);
+        action = gupnp_service_proxy_call_action_finish (
+                GUPNP_SERVICE_PROXY (object),
+                result,
+                &error);
+        if (error == NULL) {
+                gupnp_service_proxy_action_get_result (action, &error, NULL);
+        }
         if (error != NULL) {
                 g_critical ("Failed to track file transfer: %s",
                             error->message);


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