Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef __PJSIP_SIMPLE_MWI_H__
19 #define __PJSIP_SIMPLE_MWI_H__
20
21 /**
22 * @file mwi.h
23 * @brief SIP Extension for MWI (RFC 3842)
24 */
25 #include <pjsip-simple/evsub.h>
26 #include <pjsip/sip_msg.h>
27
28
29 PJ_BEGIN_DECL
30
31
32 /**
33 * @defgroup mwi SIP Message Summary and Message Waiting Indication (RFC 3842)
34 * @ingroup PJSIP_SIMPLE
35 * @brief Support for SIP MWI Extension (RFC 3842)
36 * @{
37 *
38 * This module implements RFC 3842: A Message Summary and Message Waiting
39 * Indication Event Package for the Session Initiation Protocol (SIP).
40 * It uses the SIP Event Notification framework (evsub.h) and extends the
41 * framework by implementing "message-summary" event package.
42 */
43
44
45 /**
46 * Initialize the MWI module and register it as endpoint module and
47 * package to the event subscription module.
48 *
49 * @param endpt The endpoint instance.
50 * @param mod_evsub The event subscription module instance.
51 *
52 * @return PJ_SUCCESS if the module is successfully
53 * initialized and registered to both endpoint
54 * and the event subscription module.
55 */
56 PJ_DECL(pj_status_t) pjsip_mwi_init_module(pjsip_endpoint *endpt,
57 pjsip_module *mod_evsub);
58
59 /**
60 * Get the MWI module instance.
61 *
62 * @return The MWI module instance.
63 */
64 PJ_DECL(pjsip_module*) pjsip_mwi_instance(void);
65
66 /**
67 * Create MWI client subscription session.
68 *
69 * @param dlg The underlying dialog to use.
70 * @param user_cb Pointer to callbacks to receive MWI subscription
71 * events.
72 * @param options Option flags. Currently only PJSIP_EVSUB_NO_EVENT_ID
73 * is recognized.
74 * @param p_evsub Pointer to receive the MWI subscription
75 * session.
76 *
77 * @return PJ_SUCCESS on success.
78 */
79 PJ_DECL(pj_status_t) pjsip_mwi_create_uac( pjsip_dialog *dlg,
80 const pjsip_evsub_user *user_cb,
81 unsigned options,
82 pjsip_evsub **p_evsub );
83
84 /**
85 * Create MWI server subscription session.
86 *
87 * @param dlg The underlying dialog to use.
88 * @param user_cb Pointer to callbacks to receive MWI subscription
89 * events.
90 * @param rdata The incoming SUBSCRIBE request that creates the event
91 * subscription.
92 * @param p_evsub Pointer to receive the MWI subscription
93 * session.
94 *
95 * @return PJ_SUCCESS on success.
96 */
97 PJ_DECL(pj_status_t) pjsip_mwi_create_uas( pjsip_dialog *dlg,
98 const pjsip_evsub_user *user_cb,
99 pjsip_rx_data *rdata,
100 pjsip_evsub **p_evsub );
101
102 /**
103 * Forcefully destroy the MWI subscription. This function should only
104 * be called on special condition, such as when the subscription
105 * initialization has failed. For other conditions, application MUST terminate
106 * the subscription by sending the appropriate un(SUBSCRIBE) or NOTIFY.
107 *
108 * @param sub The MWI subscription.
109 * @param notify Specify whether the state notification callback
110 * should be called.
111 *
112 * @return PJ_SUCCESS if subscription session has been destroyed.
113 */
114 PJ_DECL(pj_status_t) pjsip_mwi_terminate( pjsip_evsub *sub,
115 pj_bool_t notify );
116
117 /**
118 * Call this function to create request to initiate MWI subscription, to
119 * refresh subcription, or to request subscription termination.
120 *
121 * @param sub Client subscription instance.
122 * @param expires Subscription expiration. If the value is set to zero,
123 * this will request unsubscription. If the value is
124 * PJSIP_EXPIRES_NOT_SPECIFIED, default expiration
125 * as defined by the package will be used.
126 * @param p_tdata Pointer to receive the request.
127 *
128 * @return PJ_SUCCESS on success.
129 */
130 PJ_DECL(pj_status_t) pjsip_mwi_initiate( pjsip_evsub *sub,
131 pj_uint32_t expires,
132 pjsip_tx_data **p_tdata);
133
134 /**
135 * Accept the incoming subscription request by sending 2xx response to
136 * incoming SUBSCRIBE request.
137 *
138 * @param sub Server subscription instance.
139 * @param rdata The incoming subscription request message.
140 * @param st_code Status code, which MUST be final response.
141 * @param hdr_list Optional list of headers to be added in the response.
142 *
143 * @return PJ_SUCCESS on success.
144 */
145 PJ_DECL(pj_status_t) pjsip_mwi_accept( pjsip_evsub *sub,
146 pjsip_rx_data *rdata,
147 int st_code,
148 const pjsip_hdr *hdr_list );
149
150 /**
151 * For notifier, create NOTIFY request to subscriber, and set the state
152 * of the subscription.
153 *
154 * @param sub The server subscription (notifier) instance.
155 * @param state New state to set.
156 * @param state_str The state string name, if state contains value other
157 * than active, pending, or terminated. Otherwise this
158 * argument is ignored.
159 * @param reason Specify reason if new state is terminated, otherwise
160 * put NULL.
161 * @param mime_type MIME type/content type of the message body.
162 * @param body Message body to be included in the NOTIFY request,
163 * if NULL, the last body will be used. Note that
164 * the mime_type must also be set when body is not NULL.
165 * @param p_tdata Pointer to receive the request.
166 *
167 * @return PJ_SUCCESS on success.
168 */
169 PJ_DECL(pj_status_t) pjsip_mwi_notify( pjsip_evsub *sub,
170 pjsip_evsub_state state,
171 const pj_str_t *state_str,
172 const pj_str_t *reason,
173 const pjsip_media_type *mime_type,
174 const pj_str_t *body,
175 pjsip_tx_data **p_tdata);
176
177 /**
178 * Create NOTIFY request containing message body from the last NOITFY
179 * message created.
180 *
181 * @param sub Server subscription object.
182 * @param p_tdata Pointer to receive request.
183 *
184 * @return PJ_SUCCESS on success.
185 */
186 PJ_DECL(pj_status_t) pjsip_mwi_current_notify( pjsip_evsub *sub,
187 pjsip_tx_data **p_tdata );
188
189
190 /**
191 * Send request message that was previously created with initiate(), notify(),
192 * or current_notify(). Application may also send request created with other
193 * functions, e.g. authentication. But the request MUST be either request
194 * that creates/refresh subscription or NOTIFY request.
195 *
196 * @param sub The subscription object.
197 * @param tdata Request message to be sent.
198 *
199 * @return PJ_SUCCESS on success.
200 */
201 PJ_DECL(pj_status_t) pjsip_mwi_send_request( pjsip_evsub *sub,
202 pjsip_tx_data *tdata );
203
204 /**
205 * @}
206 */
207
208 PJ_END_DECL
209
210
211 #endif /* __PJSIP_SIMPLE_MWI_H__ */