Debian Codegraph @

Xpjproject/pjsip/include/pjsip-simple/publish.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #ifndef __PJSIP_SIMPLE_PUBLISH_H__
20 #define __PJSIP_SIMPLE_PUBLISH_H__
21
22 /**
23 * @file publish.h
24 * @brief SIP Extension for Event State Publication (PUBLISH, RFC 3903)
25 */
26
27 #include <pjsip/sip_util.h>
28 #include <pjsip/sip_auth.h>
29
30
31 PJ_BEGIN_DECL
32
33
34 /**
35 @defgroup PJSIP_SIMPLE_PUBLISH SIP Event State Publication (PUBLISH, RFC 3903)
36 @ingroup PJSIP_SIMPLE
37 @brief Support for SIP Event State Publication (PUBLISH, RFC 3903)
38 @{
39
40 This module contains the implementation of Session Initiation Protocol (SIP)
41 Extension for Event State Publication (PUBLISH) as defined by RFC 3903.
42 */
43
44 /**
45 * The SIP PUBLISH method constant.
46 */
47 extern const pjsip_method pjsip_publish_method;
48
49
50 /**
51 * @defgroup PJSIP_SIMPLE_PUBLISH_CLIENT SIP Event State Publication Client
52 * @ingroup PJSIP_SIMPLE
53 * @brief Event State Publication Clien
54 * @{
55 */
56
57
58 /** Expiration not specified. */
59 #define PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED ((pj_uint32_t)0xFFFFFFFFUL)
60
61 /**
62 * Opaque declaration for client side event publication session.
63 */
64 typedef struct pjsip_publishc pjsip_publishc;
65
66
67 /**
68 * Client publication options. Application should initialize this structure
69 * with its default values by calling #pjsip_publishc_opt_default()
70 */
71 typedef struct pjsip_publishc_opt
72 {
73 /**
74 * Specify whether the client publication session should queue the
75 * PUBLISH request should there be another PUBLISH transaction still
76 * pending. If this is set to false, the client will return error
77 * on the PUBLISH request if there is another PUBLISH transaction still
78 * in progress.
79 *
80 * Default: PJSIP_PUBLISHC_QUEUE_REQUEST
81 */
82 pj_bool_t queue_request;
83
84 } pjsip_publishc_opt;
85
86
87 /** Structure to hold parameters when calling application's callback.
88 * The application's callback is called when the client publication process
89 * has finished.
90 */
91 struct pjsip_publishc_cbparam
92 {
93 pjsip_publishc *pubc; /**< Client publication structure. */
94 void *token; /**< Arbitrary token. */
95 pj_status_t status; /**< Error status. */
96 int code; /**< SIP status code received. */
97 pj_str_t reason; /**< SIP reason phrase received. */
98 pjsip_rx_data *rdata; /**< The complete received response. */
99 unsigned expiration;/**< Next expiration interval. If the
100 value is
101 PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED,
102 it means the session will not renew
103 itself. */
104 };
105
106
107 /** Type declaration for callback to receive publication result. */
108 typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param);
109
110
111 /**
112 * Initialize client publication session option with default values.
113 *
114 * @param opt The option.
115 */
116 PJ_DECL(void) pjsip_publishc_opt_default(pjsip_publishc_opt *opt);
117
118
119 /**
120 * Initialize client publication module.
121 *
122 * @param endpt SIP endpoint.
123 *
124 * @return PJ_SUCCESS on success.
125 */
126 PJ_DECL(pj_status_t) pjsip_publishc_init_module(pjsip_endpoint *endpt);
127
128
129 /**
130 * Create client publication structure.
131 *
132 * @param endpt Endpoint, used to allocate pool from.
133 * @param opt Options, or NULL to specify default options.
134 * @param token Opaque data to be associated with the client publication.
135 * @param cb Pointer to callback function to receive publication status.
136 * @param p_pubc Pointer to receive client publication structure.
137 *
138 * @return PJ_SUCCESS on success.
139 */
140 PJ_DECL(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
141 const pjsip_publishc_opt *opt,
142 void *token,
143 pjsip_publishc_cb *cb,
144 pjsip_publishc **p_pubc);
145
146
147 /**
148 * Destroy client publication structure. If a publication transaction is
149 * in progress, then the structure will be deleted only after a final response
150 * has been received, and in this case, the callback won't be called.
151 *
152 * @param pubc The client publication structure.
153 *
154 * @return PJ_SUCCESS on success.
155 */
156 PJ_DECL(pj_status_t) pjsip_publishc_destroy(pjsip_publishc *pubc);
157
158
159
160 /**
161 * Get the memory pool associated with a publication client session.
162 *
163 * @param pubc The client publication structure.
164 * @return pool handle.
165 */
166 PJ_DECL(pj_pool_t*) pjsip_publishc_get_pool(pjsip_publishc *pubc);
167
168
169 /**
170 * Initialize client publication structure with various information needed to
171 * perform the publication.
172 *
173 * @param pubc The client publication structure.
174 * @param event The Event identification (e.g. "presence").
175 * @param target_uri The URI of the presentity which the which the status
176 * is being published.
177 * @param from_uri The URI of the endpoint who sends the event
178 * publication. Normally the value would be the same as
179 * target_uri.
180 * @param to_uri The URI to be put in To header. Normally the value
181 * would be the same as target_uri.
182 * @param expires The default expiration of the event publication.
183 * If the value PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED is
184 * given, then no default expiration will be applied.
185 *
186 * @return PJ_SUCCESS on success.
187 */
188 PJ_DECL(pj_status_t) pjsip_publishc_init(pjsip_publishc *pubc,
189 const pj_str_t *event,
190 const pj_str_t *target_uri,
191 const pj_str_t *from_uri,
192 const pj_str_t *to_uri,
193 pj_uint32_t expires);
194
195
196 /**
197 * Set authentication credentials to use by this publication.
198 *
199 * @param pubc The publication structure.
200 * @param count Number of credentials in the array.
201 * @param c Array of credentials.
202 *
203 * @return PJ_SUCCESS on success.
204 */
205 PJ_DECL(pj_status_t) pjsip_publishc_set_credentials(pjsip_publishc *pubc,
206 int count,
207 const pjsip_cred_info c[]);
208
209 /**
210 * Set shared authentication session for the client publication.
211 * When set, authentication operations will be delegated to the
212 * specified parent session.
213 *
214 * @param pubc The client publication structure.
215 * @param session The parent authentication session, or NULL to remove.
216 *
217 * @return PJ_SUCCESS on success.
218 */
219 PJ_DECL(pj_status_t) pjsip_publishc_set_auth_sess(
220 pjsip_publishc *pubc,
221 pjsip_auth_clt_sess *session);
222
223 /**
224 * Get the authentication client session associated with the publication.
225 *
226 * @param pubc The client publication structure.
227 *
228 * @return The authentication client session.
229 */
230 PJ_DECL(pjsip_auth_clt_sess*) pjsip_publishc_get_auth_sess(
231 pjsip_publishc *pubc);
232
233 /**
234 * Set route set to be used for outgoing requests.
235 *
236 * @param pubc The client publication structure.
237 * @param rs List containing Route headers.
238 *
239 * @return PJ_SUCCESS on success.
240 */
241 PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc,
242 const pjsip_route_hdr *rs);
243
244
245 /**
246 * Set list of headers to be added to each PUBLISH request generated by
247 * the client publication session. Note that application can also add
248 * the headers to the request after calling #pjsip_publishc_publish()
249 * or #pjsip_publishc_unpublish(), but the benefit of this function is
250 * the headers will also be added to requests generated internally by
251 * the session, such as during session renewal/refresh.
252 *
253 * Note that calling this function will clear the previously added list
254 * of headers.
255 *
256 * @param pubc The client publication structure.
257 * @param hdr_list The list of headers.
258 *
259 * @return PJ_SUCCESS on success.
260 */
261 PJ_DECL(pj_status_t) pjsip_publishc_set_headers(pjsip_publishc *pubc,
262 const pjsip_hdr *hdr_list);
263
264 /**
265 * Set the "sent-by" field of the Via header for outgoing requests.
266 *
267 * @param pubc The client publication structure.
268 * @param via_addr Set via_addr to use for the Via header or NULL to use
269 * the transport's published name.
270 * @param via_tp via_addr will only be used if we are using via_tp
271 * transport.
272 *
273 * @return PJ_SUCCESS on success.
274 */
275 PJ_DECL(pj_status_t) pjsip_publishc_set_via_sent_by(pjsip_publishc *pubc,
276 pjsip_host_port *via_addr,
277 pjsip_transport *via_tp);
278
279
280 /**
281 * Create PUBLISH request for the specified client publication structure.
282 * Application can use this function to both create initial publication
283 * or to modify existing publication.
284 *
285 * After the PUBLISH request is created, application MUST fill in the
286 * body part of the request with the appropriate content for the Event
287 * being published.
288 *
289 * Note that publication refresh are handled automatically by the session
290 * (as long as auto_refresh argument below is non-zero), and application
291 * should not use this function to perform publication refresh.
292 *
293 * @param pubc The client publication session.
294 * @param auto_refresh If non zero, the library will automatically
295 * refresh the next publication until application
296 * unpublish.
297 * @param p_tdata Pointer to receive the PUBLISH request. Note that
298 * the request DOES NOT have a message body.
299 *
300 * @return PJ_SUCCESS on success.
301 */
302 PJ_DECL(pj_status_t) pjsip_publishc_publish(pjsip_publishc *pubc,
303 pj_bool_t auto_refresh,
304 pjsip_tx_data **p_tdata);
305
306
307 /**
308 * Create PUBLISH request to unpublish the current client publication.
309 *
310 * @param pubc The client publication structure.
311 * @param p_tdata Pointer to receive the PUBLISH request.
312 *
313 * @return PJ_SUCCESS on success.
314 */
315 PJ_DECL(pj_status_t) pjsip_publishc_unpublish(pjsip_publishc *pubc,
316 pjsip_tx_data **p_tdata);
317
318
319 /**
320 * Update the client publication expiration value. Note that this DOES NOT
321 * automatically send outgoing PUBLISH request to update the publication
322 * session. If application wants to do this, then it must construct a
323 * PUBLISH request and send it to the server.
324 *
325 * @param pubc The client publication structure.
326 * @param expires The new expires value.
327 *
328 * @return PU_SUCCESS on successfull.
329 */
330 PJ_DECL(pj_status_t) pjsip_publishc_update_expires(pjsip_publishc *pubc,
331 pj_uint32_t expires );
332
333
334 /**
335 * Sends outgoing PUBLISH request. The process will complete asynchronously,
336 * and application will be notified via the callback when the process
337 * completes.
338 *
339 * If the session has another PUBLISH request outstanding, the behavior
340 * depends on whether request queueing is enabled in the session (this was
341 * set by setting \a queue_request field of #pjsip_publishc_opt to true
342 * when calling #pjsip_publishc_create(). Default is true). If request
343 * queueing is enabled, the request will be queued and the function will
344 * return PJ_EPENDING. One the outstanding request is complete, the queued
345 * request will be sent automatically. If request queueing is disabled, the
346 * function will reject the request and return PJ_EBUSY.
347 *
348 * @param pubc The client publication structure.
349 * @param tdata Transmit data.
350 *
351 * @return - PJ_SUCCESS on success, or
352 * - PJ_EPENDING if request is queued, or
353 * - PJ_EBUSY if request is rejected because another PUBLISH
354 * request is in progress, or
355 * - other status code to indicate the error.
356 */
357 PJ_DECL(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
358 pjsip_tx_data *tdata);
359
360
361
362 /**
363 * @}
364 */
365
366 /**
367 * @}
368 */
369
370 PJ_END_DECL
371
372
373 #endif /* __PJSIP_SIMPLE_PUBLISH_H__ */
374