blob: 05614c2122cec6c6437f15a2eb5b3c46ccc5281a [file] [log] [blame]
Benny Prijono26ff9062006-02-21 23:47:00 +00001/* $Id$ */
2/*
Benny Prijono32177c02008-06-20 22:44:47 +00003 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono26ff9062006-02-21 23:47:00 +00004 *
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_XFER_H__
20#define __PJSIP_XFER_H__
21
22
23
24/**
25 * @file sip_xfer.h
26 * @brief SIP Transfer (REFER, RFC 3515)
27 */
28#include <pjsip-simple/evsub.h>
29#include <pjsip/sip_msg.h>
30
Benny Prijono312aff92006-06-17 04:08:30 +000031/**
Benny Prijono053f5222006-11-11 16:16:04 +000032 * @defgroup PJSUA_XFER SIP REFER (RFC 3515) for Call Transfer etc.
Benny Prijono312aff92006-06-17 04:08:30 +000033 * @ingroup PJSIP_HIGH_UA
Benny Prijono053f5222006-11-11 16:16:04 +000034 * @brief SIP REFER dialog usage (call transfer, etc.)
Benny Prijono312aff92006-06-17 04:08:30 +000035 * @{
36 *
Benny Prijono053f5222006-11-11 16:16:04 +000037 * This describes a generic handling of SIP REFER request. The SIP REFER
38 * request is described in RFC 3515, and commonly used to perform call
39 * transfer functionality. Other types of SIP REFER usages are described
40 * in draft-worley-sip-many-refers-00 draft, for example:
41 * - Remote Dial: where UAC sends REFER to instruct REFER recipient to
42 * initiate an INVITE session to some target.
43 *
44 * A REFER request can be sent inside or outside existing dialog context,
45 * although for call transfer case, it is more common to send REFER inside
46 * existing INVITE session context. PJSIP supports both sending REFER request
47 * inside or outside dialog context.
Benny Prijono312aff92006-06-17 04:08:30 +000048 *
Benny Prijono053f5222006-11-11 16:16:04 +000049 * The REFER framework uses @ref PJSIP_EVENT_NOT to manage the event
50 * subscription created by the REFER request. Because of this, application
51 * must link with <b>pjsip-ua</b> AND <b>pjsip-simple</b> static libraries
52 * to use REFER functionality.
53 *
54 * Reference:
55 * - <A HREF="http://www.ietf.org/rfc/rfc3515.txt">RFC 3515: The Session
56 * Initiation Protocol (SIP) Refer Method</A>
57 * - @ref PJSIP_EVENT_NOT
Benny Prijono312aff92006-06-17 04:08:30 +000058 */
Benny Prijono26ff9062006-02-21 23:47:00 +000059
60
61PJ_BEGIN_DECL
62
63
Benny Prijono1f61a8f2007-08-16 10:11:44 +000064/** Declaration for REFER method constant. */
65PJ_DECL_DATA(const pjsip_method) pjsip_refer_method;
66
67/** Get REFER method constant */
68PJ_DECL(const pjsip_method*) pjsip_get_refer_method();
Benny Prijono26ff9062006-02-21 23:47:00 +000069
70
71/**
72 * Initialize the REFER subsystem.
73 * This currently does very little (only register REFER as supported method).
74 */
75PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt);
76
77
78
79/**
80 * Create transferer (sender of REFER request).
81 *
82 * @param dlg The underlying dialog to use.
83 * @param user_cb Pointer to callbacks to receive presence subscription
84 * events.
85 * @param p_evsub Pointer to receive the presence subscription
86 * session.
87 *
88 * @return PJ_SUCCESS on success.
89 */
90PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg,
91 const pjsip_evsub_user *user_cb,
92 pjsip_evsub **p_evsub );
93
94
95/**
96 * Create transferee (receiver of REFER request).
97 *
98 * @param dlg The underlying dialog to use.
99 * @param user_cb Pointer to callbacks to receive presence subscription
100 * events.
101 * @param rdata The incoming SUBSCRIBE request that creates the event
102 * subscription.
103 * @param p_evsub Pointer to receive the presence subscription
104 * session.
105 *
106 * @return PJ_SUCCESS on success.
107 */
108PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg,
109 const pjsip_evsub_user *user_cb,
110 pjsip_rx_data *rdata,
111 pjsip_evsub **p_evsub );
112
113/**
114 * Call this function to create request to initiate REFER subscription,
115 * to refresh subscription, or to unsubscribe. For request other than
116 * the initial REFER request, "refer_to_uri" argument may be NULL.
117 *
118 * @param sub Client subscription instance.
119 * @param refer_to_uri URI to be put to the Refer-To header. This argument
120 * may be NULL for subsequent REFER requests.
121 * @param p_tdata Pointer to receive the request.
122 *
123 * @return PJ_SUCCESS on success.
124 */
125PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub,
126 const pj_str_t *refer_to_uri,
127 pjsip_tx_data **p_tdata);
128
129
130/**
131 * Accept the incoming REFER request by sending 2xx response.
132 *
133 * @param sub Server subscription instance.
134 * @param rdata The incoming subscription request message.
135 * @param st_code Status code, which MUST be 2xx.
136 * @param hdr_list Optional list of headers to be added in the response.
137 *
138 * @return PJ_SUCCESS on success.
139 */
140PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub,
141 pjsip_rx_data *rdata,
142 int st_code,
143 const pjsip_hdr *hdr_list );
144
145
146/**
147 * For notifier, create NOTIFY request to subscriber, and set the state
148 * of the subscription.
149 *
150 * @param sub The server subscription (notifier) instance.
151 * @param state New state to set.
152 * @param xfer_st_code The call status code to be reported with the NOTIFY
153 * request.
154 * @param xfer_st_text Optional call status text to be reported with the
155 * NOTIFY request. If the value is NULL, default
156 * status text will be used.
157 * @param p_tdata Pointer to receive the request.
158 *
159 * @return PJ_SUCCESS on success.
160 */
161PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub,
162 pjsip_evsub_state state,
163 int xfer_st_code,
164 const pj_str_t *xfer_st_text,
165 pjsip_tx_data **p_tdata);
166
167
168/**
169 * Create NOTIFY request to reflect current subscription status. Application
170 * can only call this function after it has sent NOTIFY before.
171 * This will also re-send the last "message/sipfrag" body that was sent
172 * in the previous NOTIFY.
173 *
174 * @param sub Server subscription object.
175 * @param p_tdata Pointer to receive request.
176 *
177 * @return PJ_SUCCESS on success.
178 */
179PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub,
180 pjsip_tx_data **p_tdata );
181
182
183
184/**
185 * Send request message that was previously created with initiate(), notify(),
186 * or current_notify(). Application may also send request created with other
187 * functions, e.g. authentication. But the request MUST be either request
188 * that creates/refresh subscription or NOTIFY request.
189 *
190 *
191 * @param sub The event subscription object.
192 * @param tdata Request message to be send.
193 *
194 * @return PJ_SUCCESS on success.
195 */
196PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub,
197 pjsip_tx_data *tdata);
198
199
Benny Prijono26ff9062006-02-21 23:47:00 +0000200PJ_END_DECL
201
Benny Prijono312aff92006-06-17 04:08:30 +0000202/**
203 * @}
204 */
205
Benny Prijono26ff9062006-02-21 23:47:00 +0000206#endif /* __PJSIP_XFER_H__ */
207