Imported Upstream version 0.20.12
[profile/ivi/GUPnP.git] / libgupnp / gupnp-acl.h
1 /*
2  * Copyright (C) 2013,2014 Jens Georg <mail@jensge.org>
3  *
4  * Author: Jens Georg <mail@jensge.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef __GUPNP_ACL_H__
23 #define __GUPNP_ACL_H__
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include <libsoup/soup-session.h>
28
29 G_BEGIN_DECLS
30
31 GType
32 gupnp_acl_get_type (void) G_GNUC_CONST;
33
34 #define GUPNP_TYPE_ACL (gupnp_acl_get_type())
35
36 #define GUPNP_ACL(obj)                  \
37     (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
38      GUPNP_TYPE_ACL,                    \
39      GUPnPAcl))
40
41 #define GUPNP_IS_ACL(obj)               \
42     (G_TYPE_CHECK_INSTANCE_TYPE ((obj),  \
43      GUPNP_TYPE_ACL))
44
45 #define GUPNP_ACL_GET_INTERFACE(obj)      \
46     (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
47      GUPNP_TYPE_ACL, GUPnPAclInterface))
48
49 /**
50  * GUPnPAcl:
51  *
52  * Handle to an object implementing the #GUPnPAclInterface interface.
53  */
54 typedef struct _GUPnPAcl GUPnPAcl;
55
56 /**
57  * GUPnPAclInterface:
58  * @parent: The parent interface.
59  * @is_allowed: Check whether access to the resource is granted.
60  * @is_allowed_async: Asynchronously check whether the access is granted.
61  * @is_allowed_finish: Conclude the @is_allowed_async operation.
62  * @can_sync: Whether the ACL can do sync queries.
63  *
64  * Implement a simple access control list for GUPnP.
65  *
66  * Since: 0.20.11
67  */
68 typedef struct _GUPnPAclInterface GUPnPAclInterface;
69
70 /* Forward declarations to avoid recursive includes */
71 typedef struct _GUPnPDevice GUPnPDevice;
72 typedef struct _GUPnPService GUPnPService;
73
74 struct _GUPnPAclInterface {
75     GTypeInterface parent;
76
77     gboolean (*is_allowed) (GUPnPAcl     *self,
78                             GUPnPDevice  *device,
79                             GUPnPService *service,
80                             const char   *path,
81                             const char   *address,
82                             const char   *agent);
83
84     void     (*is_allowed_async) (GUPnPAcl           *self,
85                                   GUPnPDevice        *device,
86                                   GUPnPService       *service,
87                                   const char         *path,
88                                   const char         *address,
89                                   const char         *agent,
90                                   GCancellable       *cancellable,
91                                   GAsyncReadyCallback callback,
92                                   gpointer            user_data);
93
94     gboolean (*is_allowed_finish) (GUPnPAcl      *self,
95                                    GAsyncResult  *res,
96                                    GError       **error);
97
98     gboolean (*can_sync)          (GUPnPAcl *self);
99
100
101     /*< private >*/
102     /* future padding */
103     void (* _gupnp_reserved1) (void);
104     void (* _gupnp_reserved2) (void);
105     void (* _gupnp_reserved3) (void);
106     void (* _gupnp_reserved4) (void);
107 };
108
109 gboolean
110 gupnp_acl_is_allowed (GUPnPAcl     *self,
111                       GUPnPDevice  *device,
112                       GUPnPService *service,
113                       const char   *path,
114                       const char   *address,
115                       const char   *agent);
116
117 void
118 gupnp_acl_is_allowed_async (GUPnPAcl           *self,
119                             GUPnPDevice        *device,
120                             GUPnPService       *service,
121                             const char         *path,
122                             const char         *address,
123                             const char         *agent,
124                             GCancellable       *cancellable,
125                             GAsyncReadyCallback callback,
126                             gpointer            user_data);
127
128 gboolean
129 gupnp_acl_is_allowed_finish (GUPnPAcl      *self,
130                              GAsyncResult  *res,
131                              GError       **error);
132
133 gboolean
134 gupnp_acl_can_sync (GUPnPAcl *self);
135
136 G_END_DECLS
137
138 #endif