Imported Upstream version 0.20.12
[profile/ivi/GUPnP.git] / libgupnp / gupnp-context.h
1 /*
2  * Copyright (C) 2006, 2007, 2008 OpenedHand Ltd.
3  *
4  * Author: Jorn Baayen <jorn@openedhand.com>
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_CONTEXT_H__
23 #define __GUPNP_CONTEXT_H__
24
25 #include <libgssdp/gssdp-client.h>
26 #include <libsoup/soup-server.h>
27 #include <libsoup/soup-session.h>
28
29 #include "gupnp-acl.h"
30
31 G_BEGIN_DECLS
32
33 GType
34 gupnp_context_get_type (void) G_GNUC_CONST;
35
36 #define GUPNP_TYPE_CONTEXT \
37                 (gupnp_context_get_type ())
38 #define GUPNP_CONTEXT(obj) \
39                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
40                  GUPNP_TYPE_CONTEXT, \
41                  GUPnPContext))
42 #define GUPNP_CONTEXT_CLASS(obj) \
43                 (G_TYPE_CHECK_CLASS_CAST ((obj), \
44                  GUPNP_TYPE_CONTEXT, \
45                  GUPnPContextClass))
46 #define GUPNP_IS_CONTEXT(obj) \
47                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
48                  GUPNP_TYPE_CONTEXT))
49 #define GUPNP_IS_CONTEXT_CLASS(obj) \
50                 (G_TYPE_CHECK_CLASS_TYPE ((obj), \
51                  GUPNP_TYPE_CONTEXT))
52 #define GUPNP_CONTEXT_GET_CLASS(obj) \
53                 (G_TYPE_INSTANCE_GET_CLASS ((obj), \
54                  GUPNP_TYPE_CONTEXT, \
55                  GUPnPContextClass))
56
57 typedef struct _GUPnPContextPrivate GUPnPContextPrivate;
58 typedef struct _GUPnPContext GUPnPContext;
59 typedef struct _GUPnPContextClass GUPnPContextClass;
60
61 /**
62  * GUPnPContext:
63  *
64  * This struct contains private data only, and should be accessed using the
65  * functions below.
66  */
67 struct _GUPnPContext {
68         GSSDPClient parent;
69
70         GUPnPContextPrivate *priv;
71 };
72
73 struct _GUPnPContextClass {
74         GSSDPClientClass parent_class;
75
76         /* future padding */
77         void (* _gupnp_reserved1) (void);
78         void (* _gupnp_reserved2) (void);
79         void (* _gupnp_reserved3) (void);
80         void (* _gupnp_reserved4) (void);
81 };
82
83 GUPnPContext *
84 gupnp_context_new                      (GMainContext *main_context,
85                                         const char   *iface,
86                                         guint         port,
87                                         GError      **error);
88
89 #ifndef GUPNP_DISABLE_DEPRECATED
90
91 const char *
92 gupnp_context_get_host_ip              (GUPnPContext *context);
93
94 #endif /* GUPNP_DISABLE_DEPRECATED */
95
96 guint
97 gupnp_context_get_port                 (GUPnPContext *context);
98
99 SoupServer *
100 gupnp_context_get_server               (GUPnPContext *context);
101
102 SoupSession *
103 gupnp_context_get_session              (GUPnPContext *context);
104
105 void
106 gupnp_context_set_subscription_timeout (GUPnPContext *context,
107                                         guint         timeout);
108
109 guint
110 gupnp_context_get_subscription_timeout (GUPnPContext *context);
111
112 void
113 gupnp_context_set_default_language     (GUPnPContext *context,
114                                         const char   *language);
115
116 const char *
117 gupnp_context_get_default_language     (GUPnPContext *context);
118
119 void
120 gupnp_context_host_path                (GUPnPContext *context,
121                                         const char   *local_path,
122                                         const char   *server_path);
123
124 gboolean
125 gupnp_context_host_path_for_agent      (GUPnPContext *context,
126                                         const char   *local_path,
127                                         const char   *server_path,
128                                         GRegex       *user_agent);
129
130 void
131 gupnp_context_unhost_path              (GUPnPContext *context,
132                                         const char   *server_path);
133
134 GUPnPAcl *
135 gupnp_context_get_acl                  (GUPnPContext *context);
136
137 void
138 gupnp_context_set_acl                  (GUPnPContext *context,
139                                         GUPnPAcl     *acl);
140
141 void
142 gupnp_context_add_server_handler       (GUPnPContext *context,
143                                         gboolean use_acl,
144                                         const char *path,
145                                         SoupServerCallback callback,
146                                         gpointer user_data,
147                                         GDestroyNotify destroy);
148 G_END_DECLS
149
150 #endif /* __GUPNP_CONTEXT_H__ */