mwi.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. * @file mwi.h
  22. * @brief SIP Extension for MWI (RFC 3842)
  23. */
  24. #include <pjsip-simple/evsub.h>
  25. #include <pjsip/sip_msg.h>
  26. PJ_BEGIN_DECL
  27. /**
  28. * @defgroup mwi SIP Message Summary and Message Waiting Indication (RFC 3842)
  29. * @ingroup PJSIP_SIMPLE
  30. * @brief Support for SIP MWI Extension (RFC 3842)
  31. * @{
  32. *
  33. * This module implements RFC 3842: A Message Summary and Message Waiting
  34. * Indication Event Package for the Session Initiation Protocol (SIP).
  35. * It uses the SIP Event Notification framework (evsub.h) and extends the
  36. * framework by implementing "message-summary" event package.
  37. */
  38. /**
  39. * Initialize the MWI module and register it as endpoint module and
  40. * package to the event subscription module.
  41. *
  42. * @param endpt The endpoint instance.
  43. * @param mod_evsub The event subscription module instance.
  44. *
  45. * @return PJ_SUCCESS if the module is successfully
  46. * initialized and registered to both endpoint
  47. * and the event subscription module.
  48. */
  49. PJ_DECL(pj_status_t) pjsip_mwi_init_module(pjsip_endpoint *endpt,
  50. pjsip_module *mod_evsub);
  51. /**
  52. * Get the MWI module instance.
  53. *
  54. * @return The MWI module instance.
  55. */
  56. PJ_DECL(pjsip_module*) pjsip_mwi_instance(void);
  57. /**
  58. * Create MWI client subscription session.
  59. *
  60. * @param dlg The underlying dialog to use.
  61. * @param user_cb Pointer to callbacks to receive MWI subscription
  62. * events.
  63. * @param options Option flags. Currently only PJSIP_EVSUB_NO_EVENT_ID
  64. * is recognized.
  65. * @param p_evsub Pointer to receive the MWI subscription
  66. * session.
  67. *
  68. * @return PJ_SUCCESS on success.
  69. */
  70. PJ_DECL(pj_status_t) pjsip_mwi_create_uac( pjsip_dialog *dlg,
  71. const pjsip_evsub_user *user_cb,
  72. unsigned options,
  73. pjsip_evsub **p_evsub );
  74. /**
  75. * Create MWI server subscription session.
  76. *
  77. * @param dlg The underlying dialog to use.
  78. * @param user_cb Pointer to callbacks to receive MWI subscription
  79. * events.
  80. * @param rdata The incoming SUBSCRIBE request that creates the event
  81. * subscription.
  82. * @param p_evsub Pointer to receive the MWI subscription
  83. * session.
  84. *
  85. * @return PJ_SUCCESS on success.
  86. */
  87. PJ_DECL(pj_status_t) pjsip_mwi_create_uas( pjsip_dialog *dlg,
  88. const pjsip_evsub_user *user_cb,
  89. pjsip_rx_data *rdata,
  90. pjsip_evsub **p_evsub );
  91. /**
  92. * Forcefully destroy the MWI subscription. This function should only
  93. * be called on special condition, such as when the subscription
  94. * initialization has failed. For other conditions, application MUST terminate
  95. * the subscription by sending the appropriate un(SUBSCRIBE) or NOTIFY.
  96. *
  97. * @param sub The MWI subscription.
  98. * @param notify Specify whether the state notification callback
  99. * should be called.
  100. *
  101. * @return PJ_SUCCESS if subscription session has been destroyed.
  102. */
  103. PJ_DECL(pj_status_t) pjsip_mwi_terminate( pjsip_evsub *sub,
  104. pj_bool_t notify );
  105. /**
  106. * Call this function to create request to initiate MWI subscription, to
  107. * refresh subcription, or to request subscription termination.
  108. *
  109. * @param sub Client subscription instance.
  110. * @param expires Subscription expiration. If the value is set to zero,
  111. * this will request unsubscription. If the value is
  112. * PJSIP_EXPIRES_NOT_SPECIFIED, default expiration
  113. * as defined by the package will be used.
  114. * @param p_tdata Pointer to receive the request.
  115. *
  116. * @return PJ_SUCCESS on success.
  117. */
  118. PJ_DECL(pj_status_t) pjsip_mwi_initiate( pjsip_evsub *sub,
  119. pj_uint32_t expires,
  120. pjsip_tx_data **p_tdata);
  121. /**
  122. * Accept the incoming subscription request by sending 2xx response to
  123. * incoming SUBSCRIBE request.
  124. *
  125. * @param sub Server subscription instance.
  126. * @param rdata The incoming subscription request message.
  127. * @param st_code Status code, which MUST be final response.
  128. * @param hdr_list Optional list of headers to be added in the response.
  129. *
  130. * @return PJ_SUCCESS on success.
  131. */
  132. PJ_DECL(pj_status_t) pjsip_mwi_accept( pjsip_evsub *sub,
  133. pjsip_rx_data *rdata,
  134. int st_code,
  135. const pjsip_hdr *hdr_list );
  136. /**
  137. * For notifier, create NOTIFY request to subscriber, and set the state
  138. * of the subscription.
  139. *
  140. * @param sub The server subscription (notifier) instance.
  141. * @param state New state to set.
  142. * @param state_str The state string name, if state contains value other
  143. * than active, pending, or terminated. Otherwise this
  144. * argument is ignored.
  145. * @param reason Specify reason if new state is terminated, otherwise
  146. * put NULL.
  147. * @param mime_type MIME type/content type of the message body.
  148. * @param body Message body to be included in the NOTIFY request,
  149. * if NULL, the last body will be used. Note that
  150. * the mime_type must also be set when body is not NULL.
  151. * @param p_tdata Pointer to receive the request.
  152. *
  153. * @return PJ_SUCCESS on success.
  154. */
  155. PJ_DECL(pj_status_t) pjsip_mwi_notify( pjsip_evsub *sub,
  156. pjsip_evsub_state state,
  157. const pj_str_t *state_str,
  158. const pj_str_t *reason,
  159. const pjsip_media_type *mime_type,
  160. const pj_str_t *body,
  161. pjsip_tx_data **p_tdata);
  162. /**
  163. * Create NOTIFY request containing message body from the last NOITFY
  164. * message created.
  165. *
  166. * @param sub Server subscription object.
  167. * @param p_tdata Pointer to receive request.
  168. *
  169. * @return PJ_SUCCESS on success.
  170. */
  171. PJ_DECL(pj_status_t) pjsip_mwi_current_notify( pjsip_evsub *sub,
  172. pjsip_tx_data **p_tdata );
  173. /**
  174. * Send request message that was previously created with initiate(), notify(),
  175. * or current_notify(). Application may also send request created with other
  176. * functions, e.g. authentication. But the request MUST be either request
  177. * that creates/refresh subscription or NOTIFY request.
  178. *
  179. * @param sub The subscription object.
  180. * @param tdata Request message to be sent.
  181. *
  182. * @return PJ_SUCCESS on success.
  183. */
  184. PJ_DECL(pj_status_t) pjsip_mwi_send_request( pjsip_evsub *sub,
  185. pjsip_tx_data *tdata );
  186. /**
  187. * @}
  188. */
  189. PJ_END_DECL
  190. #endif /* __PJSIP_SIMPLE_MWI_H__ */