[gupnp-igd/wip/remove-deprecated-apis: 4/6] Use non-deprecated GAsync style apis to RemovePortMapping call



commit 7c5ebbede4a2a2f4491bb026538ef7d021c58110
Author: Olivier Crête <olivier crete collabora com>
Date:   Wed Mar 18 20:13:20 2020 -0400

    Use non-deprecated GAsync style apis to RemovePortMapping call

 libgupnp-igd/gupnp-simple-igd.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/libgupnp-igd/gupnp-simple-igd.c b/libgupnp-igd/gupnp-simple-igd.c
index 4206607..f7eed73 100644
--- a/libgupnp-igd/gupnp-simple-igd.c
+++ b/libgupnp-igd/gupnp-simple-igd.c
@@ -365,22 +365,26 @@ _external_ip_address_changed (GUPnPServiceProxy *proxy, const gchar *variable,
 }
 
 static void
-_service_proxy_delete_port_mapping (GUPnPServiceProxy *proxy,
-    GUPnPServiceProxyAction *action,
+_service_proxy_delete_port_mapping (GObject *source_object, GAsyncResult *res,
     gpointer user_data)
 {
+  GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY (source_object);
+  GUPnPServiceProxyAction *action;
   GError *error = NULL;
   GUPnPSimpleIgd *self = user_data;
 
+  action = gupnp_service_proxy_call_action_finish (proxy, res, &error);
 
-  if (!gupnp_service_proxy_end_action (proxy, action, &error,
-          NULL))
-  {
+  if (action == NULL ||
+      !gupnp_service_proxy_action_get_result (action, &error, NULL)) {
     g_return_if_fail (error);
     g_warning ("Error deleting port mapping: %s", error->message);
   }
   g_clear_error (&error);
 
+  if (action)
+    gupnp_service_proxy_action_unref (action);
+
   if (self)
   {
     self->priv->deleting_count--;
@@ -395,15 +399,19 @@ free_proxymapping (struct ProxyMapping *pm, GUPnPSimpleIgd *self)
 
   if (pm->mapped && self)
   {
+    GUPnPServiceProxyAction *action;
+
     self->priv->deleting_count++;
     g_object_ref (self);
-    gupnp_service_proxy_begin_action (pm->proxy->proxy,
-        "DeletePortMapping",
-        _service_proxy_delete_port_mapping, self,
+
+    action = gupnp_service_proxy_action_new ("DeletePortMapping",
         "NewRemoteHost", G_TYPE_STRING, "",
         "NewExternalPort", G_TYPE_UINT, pm->actual_external_port,
         "NewProtocol", G_TYPE_STRING, pm->mapping->protocol,
         NULL);
+
+    gupnp_service_proxy_call_action_async (pm->proxy->proxy, action, NULL,
+        _service_proxy_delete_port_mapping, self);
   }
 
   g_slice_free (struct ProxyMapping, pm);


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