blob: cbc3a7de70847b7af07883ffb502ecd964c2d41e [file] [log] [blame]
Benny Prijono26ff9062006-02-21 23:47:00 +00001/* $Id$ */
2/*
Benny Prijonoa771a512007-02-19 01:13:53 +00003 * Copyright (C) 2003-2007 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
64/**
65 * Declaration for REFER method constant.
66 */
67extern const pjsip_method pjsip_refer_method;
68
69
70/**
71 * Initialize the REFER subsystem.
72 * This currently does very little (only register REFER as supported method).
73 */
74PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt);
75
76
77
78/**
79 * Create transferer (sender of REFER request).
80 *
81 * @param dlg The underlying dialog to use.
82 * @param user_cb Pointer to callbacks to receive presence subscription
83 * events.
84 * @param p_evsub Pointer to receive the presence subscription
85 * session.
86 *
87 * @return PJ_SUCCESS on success.
88 */
89PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg,
90 const pjsip_evsub_user *user_cb,
91 pjsip_evsub **p_evsub );
92
93
94/**
95 * Create transferee (receiver of REFER request).
96 *
97 * @param dlg The underlying dialog to use.
98 * @param user_cb Pointer to callbacks to receive presence subscription
99 * events.
100 * @param rdata The incoming SUBSCRIBE request that creates the event
101 * subscription.
102 * @param p_evsub Pointer to receive the presence subscription
103 * session.
104 *
105 * @return PJ_SUCCESS on success.
106 */
107PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg,
108 const pjsip_evsub_user *user_cb,
109 pjsip_rx_data *rdata,
110 pjsip_evsub **p_evsub );
111
112/**
113 * Call this function to create request to initiate REFER subscription,
114 * to refresh subscription, or to unsubscribe. For request other than
115 * the initial REFER request, "refer_to_uri" argument may be NULL.
116 *
117 * @param sub Client subscription instance.
118 * @param refer_to_uri URI to be put to the Refer-To header. This argument
119 * may be NULL for subsequent REFER requests.
120 * @param p_tdata Pointer to receive the request.
121 *
122 * @return PJ_SUCCESS on success.
123 */
124PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub,
125 const pj_str_t *refer_to_uri,
126 pjsip_tx_data **p_tdata);
127
128
129/**
130 * Accept the incoming REFER request by sending 2xx response.
131 *
132 * @param sub Server subscription instance.
133 * @param rdata The incoming subscription request message.
134 * @param st_code Status code, which MUST be 2xx.
135 * @param hdr_list Optional list of headers to be added in the response.
136 *
137 * @return PJ_SUCCESS on success.
138 */
139PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub,
140 pjsip_rx_data *rdata,
141 int st_code,
142 const pjsip_hdr *hdr_list );
143
144
145/**
146 * For notifier, create NOTIFY request to subscriber, and set the state
147 * of the subscription.
148 *
149 * @param sub The server subscription (notifier) instance.
150 * @param state New state to set.
151 * @param xfer_st_code The call status code to be reported with the NOTIFY
152 * request.
153 * @param xfer_st_text Optional call status text to be reported with the
154 * NOTIFY request. If the value is NULL, default
155 * status text will be used.
156 * @param p_tdata Pointer to receive the request.
157 *
158 * @return PJ_SUCCESS on success.
159 */
160PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub,
161 pjsip_evsub_state state,
162 int xfer_st_code,
163 const pj_str_t *xfer_st_text,
164 pjsip_tx_data **p_tdata);
165
166
167/**
168 * Create NOTIFY request to reflect current subscription status. Application
169 * can only call this function after it has sent NOTIFY before.
170 * This will also re-send the last "message/sipfrag" body that was sent
171 * in the previous NOTIFY.
172 *
173 * @param sub Server subscription object.
174 * @param p_tdata Pointer to receive request.
175 *
176 * @return PJ_SUCCESS on success.
177 */
178PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub,
179 pjsip_tx_data **p_tdata );
180
181
182
183/**
184 * Send request message that was previously created with initiate(), notify(),
185 * or current_notify(). Application may also send request created with other
186 * functions, e.g. authentication. But the request MUST be either request
187 * that creates/refresh subscription or NOTIFY request.
188 *
189 *
190 * @param sub The event subscription object.
191 * @param tdata Request message to be send.
192 *
193 * @return PJ_SUCCESS on success.
194 */
195PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub,
196 pjsip_tx_data *tdata);
197
198
Benny Prijono26ff9062006-02-21 23:47:00 +0000199PJ_END_DECL
200
Benny Prijono312aff92006-06-17 04:08:30 +0000201/**
202 * @}
203 */
204
Benny Prijono26ff9062006-02-21 23:47:00 +0000205#endif /* __PJSIP_XFER_H__ */
206