[gupnp/wip/acl: 14/15] WIP



commit 5209d56e38727003debc8a5673fd31381740ba0c
Author: Jens Georg <mail jensge org>
Date:   Sat Feb 1 10:35:24 2014 +0100

    WIP

 libgupnp/gupnp-context.c |   45 +++++++++++++++++++++++----------------------
 libgupnp/gupnp-service.c |    4 ++--
 2 files changed, 25 insertions(+), 24 deletions(-)
---
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index fa66f26..2919aa3 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -62,18 +62,18 @@
 typedef struct _GUPnPContextAclServerHandler
 {
     GUPnPContext *context;
-    SoupServerHandler callback;
+    SoupServerCallback callback;
     gpointer user_data;
     GDestroyNotify notify;
 } GUPnPContextAclServerHandler;
 
-static GUPnPAclServerHandler *
+static GUPnPContextAclServerHandler *
 gupnp_acl_server_handler_new (GUPnPContext *context,
-                              SoupServerHandler callback,
+                              SoupServerCallback callback,
                               gpointer user_data,
                               GDestroyNotify notify)
 {
-    GUPnPAclServerHandler *handler = g_new0 (GUPnPContextAclServerHandler);
+    GUPnPContextAclServerHandler *handler = g_new0 (GUPnPContextAclServerHandler, 1);
 
     handler->context = g_object_ref (context);
     handler->callback = callback;
@@ -84,9 +84,9 @@ gupnp_acl_server_handler_new (GUPnPContext *context,
 }
 
 static void
-gupnp_acl_server_handler_free (GUPnPAclServerHandler *handler)
+gupnp_acl_server_handler_free (GUPnPContextAclServerHandler *handler)
 {
-    g_clear_object (handler->context);
+    g_clear_object (&handler->context);
 
     if (handler->notify != NULL)
         handler->notify (handler->user_data);
@@ -1388,23 +1388,24 @@ gupnp_acl_server_handler (SoupServer *server,
                           SoupClientContext *client,
                           gpointer user_data)
 {
-    GUPnPContextAclServerHandler *handler = (GUPnPContextAclServerHandler *) user_data;
+        GUPnPContextAclServerHandler *handler = (GUPnPContextAclServerHandler *) user_data;
 
-    if (gupnp_acl_can_sync (handler->context->priv->acl)) {
-        if (!gupnp_acl_is_allowed (acl, soup_client_context_get_host (client))) {
-            soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
+        if (gupnp_acl_can_sync (handler->context->priv->acl)) {
+                if (!gupnp_acl_is_allowed (handler->context->priv->acl,
+                                           soup_client_context_get_host (client))) {
+                        soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
 
-            return;
-        }
-    } else {
-        g_warning ("TBD: Handle async ACL");
-        soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
+                        return;
+                }
+        } else {
+                g_warning ("TBD: Handle async ACL");
+                soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
 
-        return;
-    }
+                return;
+        }
 
-    /* Delegate to orignal callback */
-    handler->callback (server, msg, path, query, client, handler->user_data);
+        /* Delegate to orignal callback */
+        handler->callback (server, msg, path, query, client, handler->user_data);
 }
 
 /**
@@ -1432,14 +1433,14 @@ gupnp_context_add_server_handler (GUPnPContext *context,
 
         if (use_acl) {
                 GUPnPContextAclServerHandler *handler;
-                handler = gupnp_acl_server_handler_new (callback, user_data, destroy);
-                soup_server_add_handler (self->priv->server,
+                handler = gupnp_acl_server_handler_new (context, callback, user_data, destroy);
+                soup_server_add_handler (context->priv->server,
                                          path,
                                          gupnp_acl_server_handler,
                                          handler,
                                          (GDestroyNotify) gupnp_acl_server_handler_free);
         } else
-                soup_server_add_handler (self->priv->server,
+                soup_server_add_handler (context->priv->server,
                                          path,
                                          callback,
                                          user_data,
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index 22e3cd6..f904cbe 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -1575,14 +1575,14 @@ gupnp_service_dispose (GObject *object)
         /* Remove listener on controlURL */
         url = gupnp_service_info_get_control_url (info);
         path = path_from_url (url);
-        gupnp_context_remove_server_handler (server, path);
+        gupnp_context_remove_server_handler (context, path);
         g_free (path);
         g_free (url);
 
         /* Remove listener on eventSubscriptionURL */
         url = gupnp_service_info_get_event_subscription_url (info);
         path = path_from_url (url);
-        gupnp_context_remove_server_handler (server, path);
+        gupnp_context_remove_server_handler (context, path);
         g_free (path);
         g_free (url);
 


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