blob: ebbd1cf1b87a1fb7d89c19838d75c62b79f29e35 [file] [log] [blame]
Benny Prijono21b9ad92006-08-15 13:11:22 +00001/* $Id$ */
2/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono21b9ad92006-08-15 13:11:22 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000020#ifndef __PJSIP_SIMPLE_PUBLISH_H__
21#define __PJSIP_SIMPLE_PUBLISH_H__
Benny Prijono21b9ad92006-08-15 13:11:22 +000022
23/**
24 * @file publish.h
25 * @brief SIP Extension for Event State Publication (PUBLISH, RFC 3903)
26 */
27
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000028#include <pjsip/sip_util.h>
Benny Prijonoc4c61d02006-08-20 20:47:34 +000029#include <pjsip/sip_auth.h>
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000030
Benny Prijono21b9ad92006-08-15 13:11:22 +000031
32PJ_BEGIN_DECL
33
34
35/**
Benny Prijonoca1447f2007-04-28 04:13:11 +000036 @defgroup PJSIP_SIMPLE_PUBLISH SIP Event State Publication (PUBLISH, RFC 3903)
Benny Prijono21b9ad92006-08-15 13:11:22 +000037 @ingroup PJSIP_SIMPLE
Benny Prijonoca1447f2007-04-28 04:13:11 +000038 @brief Support for SIP Event State Publication (PUBLISH, RFC 3903)
Benny Prijono21b9ad92006-08-15 13:11:22 +000039 @{
40
41 This module contains the implementation of Session Initiation Protocol (SIP)
Benny Prijonoca1447f2007-04-28 04:13:11 +000042 Extension for Event State Publication (PUBLISH) as defined by RFC 3903.
Benny Prijono21b9ad92006-08-15 13:11:22 +000043 */
44
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000045/**
46 * The SIP PUBLISH method constant.
47 */
48extern const pjsip_method pjsip_publish_method;
49
Benny Prijono21b9ad92006-08-15 13:11:22 +000050
51/*****************************************************************************
52 * @defgroup PJSIP_SIMPLE_PUBLISH_CLIENT SIP Event State Publication Client
53 * @ingroup PJSIP_SIMPLE
54 * @brief Event State Publication Clien
55 * @{
56 */
57
58
59/** Expiration not specified. */
60#define PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED ((pj_uint32_t)0xFFFFFFFFUL)
61
62/**
63 * Opaque declaration for client side event publication session.
64 */
65typedef struct pjsip_publishc pjsip_publishc;
66
67
68
69/** Structure to hold parameters when calling application's callback.
70 * The application's callback is called when the client publication process
71 * has finished.
72 */
73struct pjsip_publishc_cbparam
74{
75 pjsip_publishc *pubc; /**< Client publication structure. */
76 void *token; /**< Arbitrary token. */
77 pj_status_t status; /**< Error status. */
78 int code; /**< SIP status code received. */
79 pj_str_t reason; /**< SIP reason phrase received. */
80 pjsip_rx_data *rdata; /**< The complete received response. */
81 int expiration;/**< Next expiration interval. */
82};
83
84
85/** Type declaration for callback to receive publication result. */
86typedef void pjsip_publishc_cb(struct pjsip_publishc_cbparam *param);
87
88
Benny Prijono3a5e1ab2006-08-15 20:26:34 +000089/**
90 * Initialize client publication module.
91 *
92 * @param endpt SIP endpoint.
93 *
94 * @return PJ_SUCCESS on success.
95 */
96PJ_DECL(pj_status_t) pjsip_publishc_init_module(pjsip_endpoint *endpt);
97
98
Benny Prijono21b9ad92006-08-15 13:11:22 +000099
100/**
101 * Create client publication structure.
102 *
103 * @param endpt Endpoint, used to allocate pool from.
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000104 * @param options Option flags.
Benny Prijono21b9ad92006-08-15 13:11:22 +0000105 * @param token Opaque data to be associated with the client publication.
106 * @param cb Pointer to callback function to receive publication status.
107 * @param p_pubc Pointer to receive client publication structure.
108 *
109 * @return PJ_SUCCESS on success.
110 */
111PJ_DECL(pj_status_t) pjsip_publishc_create( pjsip_endpoint *endpt,
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000112 unsigned options,
Benny Prijono21b9ad92006-08-15 13:11:22 +0000113 void *token,
114 pjsip_publishc_cb *cb,
115 pjsip_publishc **p_pubc);
116
117
118/**
119 * Destroy client publication structure. If a publication transaction is
120 * in progress, then the structure will be deleted only after a final response
121 * has been received, and in this case, the callback won't be called.
122 *
123 * @param pubc The client publication structure.
124 *
125 * @return PJ_SUCCESS on success.
126 */
127PJ_DECL(pj_status_t) pjsip_publishc_destroy(pjsip_publishc *pubc);
128
129
130
131/**
132 * Get the memory pool associated with a publication client session.
133 *
134 * @param pubc The client publication structure.
135 * @return pool handle.
136 */
137PJ_DECL(pj_pool_t*) pjsip_publishc_get_pool(pjsip_publishc *pubc);
138
139
140/**
141 * Initialize client publication structure with various information needed to
142 * perform the publication.
143 *
144 * @param pubc The client publication structure.
145 * @param event The Event identification (e.g. "presence").
146 * @param target_uri The URI of the presentity which the which the status
147 * is being published.
148 * @param from_uri The URI of the endpoint who sends the event
149 * publication. Normally the value would be the same as
150 * target_uri.
151 * @param to_uri The URI to be put in To header. Normally the value
152 * would be the same as target_uri.
153 * @param expires The default expiration of the event publication.
154 * If the value PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED is
155 * given, then no default expiration will be applied.
156 *
157 * @return PJ_SUCCESS on success.
158 */
159PJ_DECL(pj_status_t) pjsip_publishc_init(pjsip_publishc *pubc,
160 const pj_str_t *event,
161 const pj_str_t *target_uri,
162 const pj_str_t *from_uri,
163 const pj_str_t *to_uri,
164 pj_uint32_t expires);
165
166
167/**
168 * Set authentication credentials to use by this publication.
169 *
170 * @param pubc The publication structure.
171 * @param count Number of credentials in the array.
172 * @param c Array of credentials.
173 *
174 * @return PJ_SUCCESS on success.
175 */
176PJ_DECL(pj_status_t) pjsip_publishc_set_credentials(pjsip_publishc *pubc,
177 int count,
178 const pjsip_cred_info c[]);
179
180/**
181 * Set route set to be used for outgoing requests.
182 *
183 * @param pubc The client publication structure.
184 * @param rs List containing Route headers.
185 *
186 * @return PJ_SUCCESS on success.
187 */
188PJ_DECL(pj_status_t) pjsip_publishc_set_route_set(pjsip_publishc *pubc,
189 const pjsip_route_hdr *rs);
190
191
192/**
193 * Create PUBLISH request for the specified client publication structure.
194 * Application can use this function to both create initial publication
195 * or to modify existing publication.
196 *
197 * After the PUBLISH request is created, application MUST fill in the
198 * body part of the request with the appropriate content for the Event
199 * being published.
200 *
201 * Note that publication refresh are handled automatically by the session
202 * (as long as auto_refresh argument below is non-zero), and application
203 * should not use this function to perform publication refresh.
204 *
205 * @param pubc The client publication session.
206 * @param auto_refresh If non zero, the library will automatically
207 * refresh the next publication until application
208 * unpublish.
209 * @param p_tdata Pointer to receive the PUBLISH request. Note that
210 * the request DOES NOT have a message body.
211 *
212 * @return PJ_SUCCESS on success.
213 */
214PJ_DECL(pj_status_t) pjsip_publishc_publish(pjsip_publishc *pubc,
215 pj_bool_t auto_refresh,
216 pjsip_tx_data **p_tdata);
217
218
219/**
220 * Create PUBLISH request to unpublish the current client publication.
221 *
222 * @param pubc The client publication structure.
223 * @param p_tdata Pointer to receive the PUBLISH request.
224 *
225 * @return PJ_SUCCESS on success.
226 */
227PJ_DECL(pj_status_t) pjsip_publishc_unpublish(pjsip_publishc *pubc,
228 pjsip_tx_data **p_tdata);
229
230
231/**
232 * Update the client publication expiration value. Note that this DOES NOT
233 * automatically send outgoing PUBLISH request to update the publication
234 * session. If application wants to do this, then it must construct a
235 * PUBLISH request and send it to the server.
236 *
237 * @param pubc The client publication structure.
238 * @param expires The new expires value.
239 *
240 * @return PU_SUCCESS on successfull.
241 */
242PJ_DECL(pj_status_t) pjsip_publishc_update_expires(pjsip_publishc *pubc,
243 pj_uint32_t expires );
244
245
246/**
247 * Sends outgoing PUBLISH request. The process will complete asynchronously,
248 * and application will be notified via the callback when the process
249 * completes.
250 *
251 * @param pubc The client publication structure.
252 * @param tdata Transmit data.
253 *
254 * @return PJ_SUCCESS on success.
255 */
256PJ_DECL(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc,
257 pjsip_tx_data *tdata);
258
259
260
261/**
262 * @}
263 */
264
265/**
266 * @}
267 */
268
269PJ_END_DECL
270
271
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000272#endif /* __PJSIP_SIMPLE_PUBLISH_H__ */
Benny Prijono21b9ad92006-08-15 13:11:22 +0000273