blob: b06589d2d5849e6fead82419175815b7943ec543 [file] [log] [blame]
Benny Prijono21b9ad92006-08-15 13:11:22 +00001/* $Id$ */
2/*
3 * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org>
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 */
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000019#ifndef __PJSIP_SIMPLE_PUBLISH_H__
20#define __PJSIP_SIMPLE_PUBLISH_H__
Benny Prijono21b9ad92006-08-15 13:11:22 +000021
22/**
23 * @file publish.h
24 * @brief SIP Extension for Event State Publication (PUBLISH, RFC 3903)
25 */
26
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000027#include <pjsip/sip_util.h>
Benny Prijonoc4c61d02006-08-20 20:47:34 +000028#include <pjsip/sip_auth.h>
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000029
Benny Prijono21b9ad92006-08-15 13:11:22 +000030
31PJ_BEGIN_DECL
32
33
34/**
35 @defgroup PJSIP_SIMPLE_PUBLISH SIP Event State Publication (PUBLISH, RFC 3856)
36 @ingroup PJSIP_SIMPLE
37 @brief Support for SIP Event State Publication (PUBLISH, RFC 3856)
38 @{
39
40 This module contains the implementation of Session Initiation Protocol (SIP)
41 Extension for Event State Publication (PUBLISH) as defined by RFC 3856.
42 */
43
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000044/**
45 * The SIP PUBLISH method constant.
46 */
47extern const pjsip_method pjsip_publish_method;
48
Benny Prijono21b9ad92006-08-15 13:11:22 +000049
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 */
64typedef struct pjsip_publishc pjsip_publishc;
65
66
67
68/** Structure to hold parameters when calling application's callback.
69 * The application's callback is called when the client publication process
70 * has finished.
71 */
72struct pjsip_publishc_cbparam
73{
74 pjsip_publishc *pubc; /**< Client publication structure. */
75 void *token; /**< Arbitrary token. */
76 pj_status_t status; /**< Error status. */
77 int code; /**< SIP status code received. */
78 pj_str_t reason; /**< SIP reason phrase received. */
79 pjsip_rx_data *rdata; /**< The complete received response. */
80 int expiration;/**< Next expiration interval. */
81};
82
83
84/** Type declaration for callback to receive publication result. */
85typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param);
86
87
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000088/**
89 * Initialize client publication module.
90 *
91 * @param endpt SIP endpoint.
92 *
93 * @return PJ_SUCCESS on success.
94 */
95PJ_DECL(pj_status_t) pjsip_publishc_init_module(pjsip_endpoint *endpt);
96
97
Benny Prijono21b9ad92006-08-15 13:11:22 +000098
99/**
100 * Create client publication structure.
101 *
102 * @param endpt Endpoint, used to allocate pool from.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000103 * @param options Option flags.
Benny Prijono21b9ad92006-08-15 13:11:22 +0000104 * @param token Opaque data to be associated with the client publication.
105 * @param cb Pointer to callback function to receive publication status.
106 * @param p_pubc Pointer to receive client publication structure.
107 *
108 * @return PJ_SUCCESS on success.
109 */
110PJ_DECL(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000111 unsigned options,
Benny Prijono21b9ad92006-08-15 13:11:22 +0000112 void *token,
113 pjsip_publishc_cb *cb,
114 pjsip_publishc **p_pubc);
115
116
117/**
118 * Destroy client publication structure. If a publication transaction is
119 * in progress, then the structure will be deleted only after a final response
120 * has been received, and in this case, the callback won't be called.
121 *
122 * @param pubc The client publication structure.
123 *
124 * @return PJ_SUCCESS on success.
125 */
126PJ_DECL(pj_status_t) pjsip_publishc_destroy(pjsip_publishc *pubc);
127
128
129
130/**
131 * Get the memory pool associated with a publication client session.
132 *
133 * @param pubc The client publication structure.
134 * @return pool handle.
135 */
136PJ_DECL(pj_pool_t*) pjsip_publishc_get_pool(pjsip_publishc *pubc);
137
138
139/**
140 * Initialize client publication structure with various information needed to
141 * perform the publication.
142 *
143 * @param pubc The client publication structure.
144 * @param event The Event identification (e.g. "presence").
145 * @param target_uri The URI of the presentity which the which the status
146 * is being published.
147 * @param from_uri The URI of the endpoint who sends the event
148 * publication. Normally the value would be the same as
149 * target_uri.
150 * @param to_uri The URI to be put in To header. Normally the value
151 * would be the same as target_uri.
152 * @param expires The default expiration of the event publication.
153 * If the value PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED is
154 * given, then no default expiration will be applied.
155 *
156 * @return PJ_SUCCESS on success.
157 */
158PJ_DECL(pj_status_t) pjsip_publishc_init(pjsip_publishc *pubc,
159 const pj_str_t *event,
160 const pj_str_t *target_uri,
161 const pj_str_t *from_uri,
162 const pj_str_t *to_uri,
163 pj_uint32_t expires);
164
165
166/**
167 * Set authentication credentials to use by this publication.
168 *
169 * @param pubc The publication structure.
170 * @param count Number of credentials in the array.
171 * @param c Array of credentials.
172 *
173 * @return PJ_SUCCESS on success.
174 */
175PJ_DECL(pj_status_t) pjsip_publishc_set_credentials(pjsip_publishc *pubc,
176 int count,
177 const pjsip_cred_info c[]);
178
179/**
180 * Set route set to be used for outgoing requests.
181 *
182 * @param pubc The client publication structure.
183 * @param rs List containing Route headers.
184 *
185 * @return PJ_SUCCESS on success.
186 */
187PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc,
188 const pjsip_route_hdr *rs);
189
190
191/**
192 * Create PUBLISH request for the specified client publication structure.
193 * Application can use this function to both create initial publication
194 * or to modify existing publication.
195 *
196 * After the PUBLISH request is created, application MUST fill in the
197 * body part of the request with the appropriate content for the Event
198 * being published.
199 *
200 * Note that publication refresh are handled automatically by the session
201 * (as long as auto_refresh argument below is non-zero), and application
202 * should not use this function to perform publication refresh.
203 *
204 * @param pubc The client publication session.
205 * @param auto_refresh If non zero, the library will automatically
206 * refresh the next publication until application
207 * unpublish.
208 * @param p_tdata Pointer to receive the PUBLISH request. Note that
209 * the request DOES NOT have a message body.
210 *
211 * @return PJ_SUCCESS on success.
212 */
213PJ_DECL(pj_status_t) pjsip_publishc_publish(pjsip_publishc *pubc,
214 pj_bool_t auto_refresh,
215 pjsip_tx_data **p_tdata);
216
217
218/**
219 * Create PUBLISH request to unpublish the current client publication.
220 *
221 * @param pubc The client publication structure.
222 * @param p_tdata Pointer to receive the PUBLISH request.
223 *
224 * @return PJ_SUCCESS on success.
225 */
226PJ_DECL(pj_status_t) pjsip_publishc_unpublish(pjsip_publishc *pubc,
227 pjsip_tx_data **p_tdata);
228
229
230/**
231 * Update the client publication expiration value. Note that this DOES NOT
232 * automatically send outgoing PUBLISH request to update the publication
233 * session. If application wants to do this, then it must construct a
234 * PUBLISH request and send it to the server.
235 *
236 * @param pubc The client publication structure.
237 * @param expires The new expires value.
238 *
239 * @return PU_SUCCESS on successfull.
240 */
241PJ_DECL(pj_status_t) pjsip_publishc_update_expires(pjsip_publishc *pubc,
242 pj_uint32_t expires );
243
244
245/**
246 * Sends outgoing PUBLISH request. The process will complete asynchronously,
247 * and application will be notified via the callback when the process
248 * completes.
249 *
250 * @param pubc The client publication structure.
251 * @param tdata Transmit data.
252 *
253 * @return PJ_SUCCESS on success.
254 */
255PJ_DECL(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
256 pjsip_tx_data *tdata);
257
258
259
260/**
261 * @}
262 */
263
264/**
265 * @}
266 */
267
268PJ_END_DECL
269
270
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000271#endif /* __PJSIP_SIMPLE_PUBLISH_H__ */
Benny Prijono21b9ad92006-08-15 13:11:22 +0000272