[gupnp/gupnp-1.0] service: Use SoupURI in call-backs



commit 104b059b5dc8b953cab0be9d82580bf2ad3dfe57
Author: Jens Georg <mail jensge org>
Date:   Tue Jun 16 21:25:03 2020 +0200

    service: Use SoupURI in call-backs

 libgupnp/gupnp-service.c | 56 ++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
---
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index 0417852..b3afe58 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -171,7 +171,7 @@ subscription_data_free (SubscriptionData *data)
         }
        
         /* Further cleanup */
-        g_list_free_full (data->callbacks, g_free);
+        g_list_free_full (data->callbacks, (GDestroyNotify) soup_uri_free);
 
         g_free (data->sid);
 
@@ -1205,8 +1205,13 @@ subscribe (GUPnPService *service,
                         break;
 
                 if (strncmp (start, "http://";, strlen ("http://";)) == 0) {
+                        SoupURI *local_uri;
                         uri = g_strndup (start, end - start);
-                        data->callbacks = g_list_append (data->callbacks, uri);
+                        local_uri = soup_uri_new (uri);
+                        g_free (uri);
+                        if (local_uri != NULL) {
+                            data->callbacks = g_list_append (data->callbacks, local_uri);
+                        }
                 }
 
                 start = end;
@@ -1914,32 +1919,27 @@ notify_got_response (G_GNUC_UNUSED SoupSession *session,
 }
 
 /* Send notification @user_data to subscriber @value */
-static void
-notify_subscriber (G_GNUC_UNUSED gpointer key,
-                   gpointer               value,
-                   gpointer               user_data)
-{
-        SubscriptionData *data;
-        const char *property_set;
-        char *tmp;
-        SoupMessage *msg;
-        SoupSession *session;
-
-        data = value;
-        property_set = user_data;
-
-        /* Subscriber called unsubscribe */
-        if (subscription_data_can_delete (data))
-                return;
-
-        /* Create message */
-        msg = soup_message_new (GENA_METHOD_NOTIFY, data->callbacks->data);
-        if (!msg) {
-                g_warning ("Invalid callback URL: %s",
-                           (char *) data->callbacks->data);
-
-                return;
-        }
+    static void
+    notify_subscriber (G_GNUC_UNUSED gpointer key,
+                       gpointer               value,
+                       gpointer               user_data)
+    {
+            SubscriptionData *data;
+            const char *property_set;
+            char *tmp;
+            SoupMessage *msg;
+            SoupSession *session;
+
+            data = value;
+            property_set = user_data;
+
+            /* Subscriber called unsubscribe */
+            if (subscription_data_can_delete (data))
+                    return;
+
+            /* Create message */
+            msg = soup_message_new_from_uri (GENA_METHOD_NOTIFY,
+                                             data->callbacks->data);
 
         soup_message_headers_append (msg->request_headers,
                                      "NT",


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