iscomposing.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 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_SIMPLE_ISCOMPOSING_H__
  20. #define __PJSIP_SIMPLE_ISCOMPOSING_H__
  21. /**
  22. * @file iscomposing.h
  23. * @brief Support for Indication of Message Composition (RFC 3994)
  24. */
  25. #include <pjsip-simple/types.h>
  26. #include <pjlib-util/xml.h>
  27. /**
  28. * @defgroup PJSIP_ISCOMPOSING Message Composition Indication (RFC 3994)
  29. * @ingroup PJSIP_SIMPLE
  30. * @brief Support for Indication of Message Composition (RFC 3994)
  31. * @{
  32. *
  33. * This implements message composition indication, as described in
  34. * RFC 3994.
  35. */
  36. PJ_BEGIN_DECL
  37. /**
  38. * Create XML message with MIME type "application/im-iscomposing+xml"
  39. * to indicate the message composition status.
  40. *
  41. * @param pool Pool to allocate memory.
  42. * @param is_composing Message composition indication status. Set to
  43. * PJ_TRUE (or non-zero) to indicate that application
  44. * is currently composing an instant message.
  45. * @param lst_actv Optional attribute to indicate time of last
  46. * activity. If none is to be specified, the value
  47. * MUST be set to NULL.
  48. * @param content_tp Optional attribute to indicate the content type of
  49. * message being composed. If none is to be specified,
  50. * the value MUST be set to NULL.
  51. * @param refresh Optional attribute to indicate the interval when
  52. * next indication will be sent, only when
  53. * is_composing is non-zero. If none is to be
  54. * specified, the value MUST be set to -1.
  55. *
  56. * @return An XML message containing the message indication.
  57. * NULL will be returned when there's not enough
  58. * memory to allocate the message.
  59. */
  60. PJ_DECL(pj_xml_node*) pjsip_iscomposing_create_xml(pj_pool_t *pool,
  61. pj_bool_t is_composing,
  62. const pj_time_val *lst_actv,
  63. const pj_str_t *content_tp,
  64. int refresh);
  65. /**
  66. * Create message body with Content-Type "application/im-iscomposing+xml"
  67. * to indicate the message composition status.
  68. *
  69. * @param pool Pool to allocate memory.
  70. * @param is_composing Message composition indication status. Set to
  71. * PJ_TRUE (or non-zero) to indicate that application
  72. * is currently composing an instant message.
  73. * @param lst_actv Optional attribute to indicate time of last
  74. * activity. If none is to be specified, the value
  75. * MUST be set to NULL.
  76. * @param content_tp Optional attribute to indicate the content type of
  77. * message being composed. If none is to be specified,
  78. * the value MUST be set to NULL.
  79. * @param refresh Optional attribute to indicate the interval when
  80. * next indication will be sent, only when
  81. * is_composing is non-zero. If none is to be
  82. * specified, the value MUST be set to -1.
  83. *
  84. * @return The SIP message body containing XML message
  85. * indication. NULL will be returned when there's not
  86. * enough memory to allocate the message.
  87. */
  88. PJ_DECL(pjsip_msg_body*) pjsip_iscomposing_create_body( pj_pool_t *pool,
  89. pj_bool_t is_composing,
  90. const pj_time_val *lst_actv,
  91. const pj_str_t *content_tp,
  92. int refresh);
  93. /**
  94. * Parse the buffer and return message composition indication in the
  95. * message.
  96. *
  97. * Note that the input string buffer MUST be NULL terminated and have
  98. * length at least len+1 (len MUST NOT include the NULL terminator).
  99. *
  100. * @param pool Pool to allocate memory for the parsing process.
  101. * @param msg The message to be parsed, MUST be NULL terminated.
  102. * @param len Length of the message, excluding NULL terminator.
  103. * @param p_is_composing Optional pointer to receive iscomposing status.
  104. * @param p_last_active Optional pointer to receive last active attribute.
  105. * @param p_content_type Optional pointer to receive content type attribute.
  106. * @param p_refresh Optional pointer to receive refresh time.
  107. *
  108. * @return PJ_SUCCESS if message can be successfully parsed.
  109. */
  110. PJ_DECL(pj_status_t) pjsip_iscomposing_parse( pj_pool_t *pool,
  111. char *msg,
  112. pj_size_t len,
  113. pj_bool_t *p_is_composing,
  114. pj_str_t **p_last_active,
  115. pj_str_t **p_content_type,
  116. int *p_refresh );
  117. /**
  118. * @}
  119. */
  120. PJ_END_DECL
  121. #endif /* __PJSIP_SIMPLE_ISCOMPOSING_H__ */