[gupnp/wip/acl] Add User-Agent to information



commit 8ce61d87882b681370c55fdc8f38e6e6d226a26a
Author: Jens Georg <mail jensge org>
Date:   Sun Feb 23 17:22:23 2014 +0100

    Add User-Agent to information

 libgupnp/gupnp-acl.c     |    8 ++++++--
 libgupnp/gupnp-acl.h     |    8 ++++++--
 libgupnp/gupnp-context.c |   18 +++++++++++++++---
 3 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/libgupnp/gupnp-acl.c b/libgupnp/gupnp-acl.c
index 8118965..40f77b4 100644
--- a/libgupnp/gupnp-acl.c
+++ b/libgupnp/gupnp-acl.c
@@ -49,7 +49,8 @@ gupnp_acl_is_allowed (GUPnPAcl     *self,
                       GUPnPDevice  *device,
                       GUPnPService *service,
                       const char   *path,
-                      const char   *address)
+                      const char   *address,
+                      const char   *agent)
 {
         g_return_val_if_fail (GUPNP_IS_ACL (self), FALSE);
 
@@ -57,7 +58,8 @@ gupnp_acl_is_allowed (GUPnPAcl     *self,
                                                            device,
                                                            service,
                                                            path,
-                                                           address);
+                                                           address,
+                                                           agent);
 }
 
 /**
@@ -90,6 +92,7 @@ gupnp_acl_is_allowed_async (GUPnPAcl           *self,
                             GUPnPService       *service,
                             const char         *path,
                             const char         *address,
+                            const char         *agent,
                             GCancellable       *cancellable,
                             GAsyncReadyCallback callback,
                             gpointer            user_data)
@@ -101,6 +104,7 @@ gupnp_acl_is_allowed_async (GUPnPAcl           *self,
                                                           service,
                                                           path,
                                                           address,
+                                                          agent,
                                                           cancellable,
                                                           callback,
                                                           user_data);
diff --git a/libgupnp/gupnp-acl.h b/libgupnp/gupnp-acl.h
index 7aef20c..63cb711 100644
--- a/libgupnp/gupnp-acl.h
+++ b/libgupnp/gupnp-acl.h
@@ -60,13 +60,15 @@ struct _GUPnPAclInterface {
                             GUPnPDevice  *device,
                             GUPnPService *service,
                             const char   *path,
-                            const char   *address);
+                            const char   *address,
+                            const char   *agent);
 
     void     (*is_allowed_async) (GUPnPAcl           *self,
                                   GUPnPDevice        *device,
                                   GUPnPService       *service,
                                   const char         *path,
                                   const char         *address,
+                                  const char         *agent,
                                   GCancellable       *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer            user_data);
@@ -89,7 +91,8 @@ gupnp_acl_is_allowed (GUPnPAcl     *self,
                       GUPnPDevice  *device,
                       GUPnPService *service,
                       const char   *path,
-                      const char   *address);
+                      const char   *address,
+                      const char   *agent);
 
 void
 gupnp_acl_is_allowed_async (GUPnPAcl           *self,
@@ -97,6 +100,7 @@ gupnp_acl_is_allowed_async (GUPnPAcl           *self,
                             GUPnPService       *service,
                             const char         *path,
                             const char         *address,
+                            const char         *agent,
                             GCancellable       *cancellable,
                             GAsyncReadyCallback callback,
                             gpointer            user_data);
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 6aca2eb..1e37ce0 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -1382,19 +1382,25 @@ gupnp_acl_server_handler (SoupServer *server,
                           gpointer user_data)
 {
         AclServerHandler *handler = (AclServerHandler *) user_data;
+        const char *agent;
         GUPnPDevice *device = NULL;
+
         if (handler->service) {
                 g_object_get (handler->service,
                               "root-device", &device,
                               NULL);
         }
 
+        agent = soup_message_headers_get_one (msg->request_headers,
+                                              "User-Agent");
+
         if (gupnp_acl_can_sync (handler->context->priv->acl)) {
                 if (!gupnp_acl_is_allowed (handler->context->priv->acl,
                                            device,
                                            handler->service,
                                            path,
-                                           soup_client_context_get_host (client))) {
+                                           soup_client_context_get_host (client),
+                                           agent)) {
                         soup_message_set_status (msg, SOUP_STATUS_FORBIDDEN);
 
                         return;
@@ -1410,6 +1416,7 @@ gupnp_acl_server_handler (SoupServer *server,
                                             handler->service,
                                             path,
                                             soup_client_context_get_host (client),
+                                            agent,
                                             NULL,
                                             (GAsyncReadyCallback) gupnp_acl_async_callback,
                                             data);
@@ -1476,8 +1483,13 @@ _gupnp_context_add_server_handler_with_data (GUPnPContext *context,
 
 /**
  * gupnp_context_remove_server_handler:
- * @context:
- * @path:
+ * @context: a #GUPnPContext
+ * @use_acl: %TRUE, if the path should query the GUPnPContext::acl before
+ * serving the resource, %FALSE otherwise.
+ * @path: the toplevel path for the handler.
+ *
+ * Add a #SoupServerCallback to the #GUPnPContext<!-- -->'s #SoupServer.
+ *
  */
 void
 gupnp_context_remove_server_handler (GUPnPContext *context, const char *path)


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