1
/* $Id: mwi.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
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.
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.
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
19
#ifndef __PJSIP_SIMPLE_MWI_H__
20
#define __PJSIP_SIMPLE_MWI_H__
24
* @brief SIP Extension for MWI (RFC 3842)
26
#include <pjsip-simple/evsub.h>
27
#include <pjsip/sip_msg.h>
34
* @defgroup mwi SIP Message Summary and Message Waiting Indication (RFC 3842)
35
* @ingroup PJSIP_SIMPLE
36
* @brief Support for SIP MWI Extension (RFC 3842)
39
* This module implements RFC 3842: A Message Summary and Message Waiting
40
* Indication Event Package for the Session Initiation Protocol (SIP).
41
* It uses the SIP Event Notification framework (evsub.h) and extends the
42
* framework by implementing "message-summary" event package.
47
* Initialize the MWI module and register it as endpoint module and
48
* package to the event subscription module.
50
* @param endpt The endpoint instance.
51
* @param mod_evsub The event subscription module instance.
53
* @return PJ_SUCCESS if the module is successfully
54
* initialized and registered to both endpoint
55
* and the event subscription module.
57
PJ_DECL(pj_status_t) pjsip_mwi_init_module(pjsip_endpoint *endpt,
58
pjsip_module *mod_evsub);
61
* Get the MWI module instance.
63
* @return The MWI module instance.
65
PJ_DECL(pjsip_module*) pjsip_mwi_instance(void);
68
* Create MWI client subscription session.
70
* @param dlg The underlying dialog to use.
71
* @param user_cb Pointer to callbacks to receive MWI subscription
73
* @param options Option flags. Currently only PJSIP_EVSUB_NO_EVENT_ID
75
* @param p_evsub Pointer to receive the MWI subscription
78
* @return PJ_SUCCESS on success.
80
PJ_DECL(pj_status_t) pjsip_mwi_create_uac( pjsip_dialog *dlg,
81
const pjsip_evsub_user *user_cb,
83
pjsip_evsub **p_evsub );
86
* Create MWI server subscription session.
88
* @param dlg The underlying dialog to use.
89
* @param user_cb Pointer to callbacks to receive MWI subscription
91
* @param rdata The incoming SUBSCRIBE request that creates the event
93
* @param p_evsub Pointer to receive the MWI subscription
96
* @return PJ_SUCCESS on success.
98
PJ_DECL(pj_status_t) pjsip_mwi_create_uas( pjsip_dialog *dlg,
99
const pjsip_evsub_user *user_cb,
100
pjsip_rx_data *rdata,
101
pjsip_evsub **p_evsub );
104
* Forcefully destroy the MWI subscription. This function should only
105
* be called on special condition, such as when the subscription
106
* initialization has failed. For other conditions, application MUST terminate
107
* the subscription by sending the appropriate un(SUBSCRIBE) or NOTIFY.
109
* @param sub The MWI subscription.
110
* @param notify Specify whether the state notification callback
113
* @return PJ_SUCCESS if subscription session has been destroyed.
115
PJ_DECL(pj_status_t) pjsip_mwi_terminate( pjsip_evsub *sub,
119
* Call this function to create request to initiate MWI subscription, to
120
* refresh subcription, or to request subscription termination.
122
* @param sub Client subscription instance.
123
* @param expires Subscription expiration. If the value is set to zero,
124
* this will request unsubscription.
125
* @param p_tdata Pointer to receive the request.
127
* @return PJ_SUCCESS on success.
129
PJ_DECL(pj_status_t) pjsip_mwi_initiate( pjsip_evsub *sub,
131
pjsip_tx_data **p_tdata);
134
* Accept the incoming subscription request by sending 2xx response to
135
* incoming SUBSCRIBE request.
137
* @param sub Server subscription instance.
138
* @param rdata The incoming subscription request message.
139
* @param st_code Status code, which MUST be final response.
140
* @param hdr_list Optional list of headers to be added in the response.
142
* @return PJ_SUCCESS on success.
144
PJ_DECL(pj_status_t) pjsip_mwi_accept( pjsip_evsub *sub,
145
pjsip_rx_data *rdata,
147
const pjsip_hdr *hdr_list );
150
* For notifier, create NOTIFY request to subscriber, and set the state
151
* of the subscription.
153
* @param sub The server subscription (notifier) instance.
154
* @param state New state to set.
155
* @param state_str The state string name, if state contains value other
156
* than active, pending, or terminated. Otherwise this
157
* argument is ignored.
158
* @param reason Specify reason if new state is terminated, otherwise
160
* @param mime_type MIME type/content type of the message body.
161
* @param body Message body to be included in the NOTIFY request.
162
* @param p_tdata Pointer to receive the request.
164
* @return PJ_SUCCESS on success.
166
PJ_DECL(pj_status_t) pjsip_mwi_notify( pjsip_evsub *sub,
167
pjsip_evsub_state state,
168
const pj_str_t *state_str,
169
const pj_str_t *reason,
170
const pjsip_media_type *mime_type,
171
const pj_str_t *body,
172
pjsip_tx_data **p_tdata);
175
* Create NOTIFY request containing message body from the last NOITFY
178
* @param sub Server subscription object.
179
* @param p_tdata Pointer to receive request.
181
* @return PJ_SUCCESS on success.
183
PJ_DECL(pj_status_t) pjsip_mwi_current_notify( pjsip_evsub *sub,
184
pjsip_tx_data **p_tdata );
188
* Send request message that was previously created with initiate(), notify(),
189
* or current_notify(). Application may also send request created with other
190
* functions, e.g. authentication. But the request MUST be either request
191
* that creates/refresh subscription or NOTIFY request.
193
* @param sub The subscription object.
194
* @param tdata Request message to be sent.
196
* @return PJ_SUCCESS on success.
198
PJ_DECL(pj_status_t) pjsip_mwi_send_request( pjsip_evsub *sub,
199
pjsip_tx_data *tdata );
208
#endif /* __PJSIP_SIMPLE_MWI_H__ */