Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame^] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 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 | |
| 31 | |
| 32 | |
| 33 | PJ_BEGIN_DECL |
| 34 | |
| 35 | |
| 36 | /** |
| 37 | * Declaration for REFER method constant. |
| 38 | */ |
| 39 | extern const pjsip_method pjsip_refer_method; |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * Initialize the REFER subsystem. |
| 44 | * This currently does very little (only register REFER as supported method). |
| 45 | */ |
| 46 | PJ_DECL(pj_status_t) pjsip_xfer_init_module(pjsip_endpoint *endpt); |
| 47 | |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * Create transferer (sender of REFER request). |
| 52 | * |
| 53 | * @param dlg The underlying dialog to use. |
| 54 | * @param user_cb Pointer to callbacks to receive presence subscription |
| 55 | * events. |
| 56 | * @param p_evsub Pointer to receive the presence subscription |
| 57 | * session. |
| 58 | * |
| 59 | * @return PJ_SUCCESS on success. |
| 60 | */ |
| 61 | PJ_DECL(pj_status_t) pjsip_xfer_create_uac( pjsip_dialog *dlg, |
| 62 | const pjsip_evsub_user *user_cb, |
| 63 | pjsip_evsub **p_evsub ); |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * Create transferee (receiver of REFER request). |
| 68 | * |
| 69 | * @param dlg The underlying dialog to use. |
| 70 | * @param user_cb Pointer to callbacks to receive presence subscription |
| 71 | * events. |
| 72 | * @param rdata The incoming SUBSCRIBE request that creates the event |
| 73 | * subscription. |
| 74 | * @param p_evsub Pointer to receive the presence subscription |
| 75 | * session. |
| 76 | * |
| 77 | * @return PJ_SUCCESS on success. |
| 78 | */ |
| 79 | PJ_DECL(pj_status_t) pjsip_xfer_create_uas( pjsip_dialog *dlg, |
| 80 | const pjsip_evsub_user *user_cb, |
| 81 | pjsip_rx_data *rdata, |
| 82 | pjsip_evsub **p_evsub ); |
| 83 | |
| 84 | /** |
| 85 | * Call this function to create request to initiate REFER subscription, |
| 86 | * to refresh subscription, or to unsubscribe. For request other than |
| 87 | * the initial REFER request, "refer_to_uri" argument may be NULL. |
| 88 | * |
| 89 | * @param sub Client subscription instance. |
| 90 | * @param refer_to_uri URI to be put to the Refer-To header. This argument |
| 91 | * may be NULL for subsequent REFER requests. |
| 92 | * @param p_tdata Pointer to receive the request. |
| 93 | * |
| 94 | * @return PJ_SUCCESS on success. |
| 95 | */ |
| 96 | PJ_DECL(pj_status_t) pjsip_xfer_initiate( pjsip_evsub *sub, |
| 97 | const pj_str_t *refer_to_uri, |
| 98 | pjsip_tx_data **p_tdata); |
| 99 | |
| 100 | |
| 101 | /** |
| 102 | * Accept the incoming REFER request by sending 2xx response. |
| 103 | * |
| 104 | * @param sub Server subscription instance. |
| 105 | * @param rdata The incoming subscription request message. |
| 106 | * @param st_code Status code, which MUST be 2xx. |
| 107 | * @param hdr_list Optional list of headers to be added in the response. |
| 108 | * |
| 109 | * @return PJ_SUCCESS on success. |
| 110 | */ |
| 111 | PJ_DECL(pj_status_t) pjsip_xfer_accept( pjsip_evsub *sub, |
| 112 | pjsip_rx_data *rdata, |
| 113 | int st_code, |
| 114 | const pjsip_hdr *hdr_list ); |
| 115 | |
| 116 | |
| 117 | /** |
| 118 | * For notifier, create NOTIFY request to subscriber, and set the state |
| 119 | * of the subscription. |
| 120 | * |
| 121 | * @param sub The server subscription (notifier) instance. |
| 122 | * @param state New state to set. |
| 123 | * @param xfer_st_code The call status code to be reported with the NOTIFY |
| 124 | * request. |
| 125 | * @param xfer_st_text Optional call status text to be reported with the |
| 126 | * NOTIFY request. If the value is NULL, default |
| 127 | * status text will be used. |
| 128 | * @param p_tdata Pointer to receive the request. |
| 129 | * |
| 130 | * @return PJ_SUCCESS on success. |
| 131 | */ |
| 132 | PJ_DECL(pj_status_t) pjsip_xfer_notify( pjsip_evsub *sub, |
| 133 | pjsip_evsub_state state, |
| 134 | int xfer_st_code, |
| 135 | const pj_str_t *xfer_st_text, |
| 136 | pjsip_tx_data **p_tdata); |
| 137 | |
| 138 | |
| 139 | /** |
| 140 | * Create NOTIFY request to reflect current subscription status. Application |
| 141 | * can only call this function after it has sent NOTIFY before. |
| 142 | * This will also re-send the last "message/sipfrag" body that was sent |
| 143 | * in the previous NOTIFY. |
| 144 | * |
| 145 | * @param sub Server subscription object. |
| 146 | * @param p_tdata Pointer to receive request. |
| 147 | * |
| 148 | * @return PJ_SUCCESS on success. |
| 149 | */ |
| 150 | PJ_DECL(pj_status_t) pjsip_xfer_current_notify( pjsip_evsub *sub, |
| 151 | pjsip_tx_data **p_tdata ); |
| 152 | |
| 153 | |
| 154 | |
| 155 | /** |
| 156 | * Send request message that was previously created with initiate(), notify(), |
| 157 | * or current_notify(). Application may also send request created with other |
| 158 | * functions, e.g. authentication. But the request MUST be either request |
| 159 | * that creates/refresh subscription or NOTIFY request. |
| 160 | * |
| 161 | * |
| 162 | * @param sub The event subscription object. |
| 163 | * @param tdata Request message to be send. |
| 164 | * |
| 165 | * @return PJ_SUCCESS on success. |
| 166 | */ |
| 167 | PJ_DECL(pj_status_t) pjsip_xfer_send_request( pjsip_evsub *sub, |
| 168 | pjsip_tx_data *tdata); |
| 169 | |
| 170 | |
| 171 | |
| 172 | PJ_END_DECL |
| 173 | |
| 174 | #endif /* __PJSIP_XFER_H__ */ |
| 175 | |