res_mwi_external.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * Richard Mudgett <rmudgett@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*!
  19. * \file
  20. * \brief Core external MWI support.
  21. *
  22. * \author Richard Mudgett <rmudgett@digium.com>
  23. *
  24. * See Also:
  25. * \arg \ref AstCREDITS
  26. */
  27. #ifndef _ASTERISK_RES_MWI_EXTERNAL_H
  28. #define _ASTERISK_RES_MWI_EXTERNAL_H
  29. #if defined(__cplusplus) || defined(c_plusplus)
  30. extern "C"
  31. {
  32. #endif
  33. /* ------------------------------------------------------------------- */
  34. /*!
  35. * \brief Increase the external MWI resource module reference count.
  36. * \since 12.1.0
  37. *
  38. * \return Nothing
  39. */
  40. void ast_mwi_external_ref(void);
  41. /*!
  42. * \brief Decrease the external MWI resource module reference count.
  43. * \since 12.1.0
  44. *
  45. * \return Nothing
  46. */
  47. void ast_mwi_external_unref(void);
  48. struct ast_mwi_mailbox_object;
  49. /*! \brief Convienience unref function for mailbox object. */
  50. #define ast_mwi_mailbox_unref(mailbox) ao2_ref((struct ast_mwi_mailbox_object *) mailbox, -1)
  51. /*!
  52. * \brief Allocate an external MWI object.
  53. * \since 12.1.0
  54. *
  55. * \param mailbox_id Name of mailbox.
  56. *
  57. * \retval object on success. The object is an ao2 object.
  58. * \retval NULL on error.
  59. */
  60. struct ast_mwi_mailbox_object *ast_mwi_mailbox_alloc(const char *mailbox_id);
  61. /*!
  62. * \brief Get mailbox id.
  63. * \since 12.1.0
  64. *
  65. * \param mailbox Object to get id.
  66. *
  67. * \return mailbox_id of the object.
  68. *
  69. * \note This should never return NULL unless there is a bug in sorcery.
  70. */
  71. const char *ast_mwi_mailbox_get_id(const struct ast_mwi_mailbox_object *mailbox);
  72. /*!
  73. * \brief Get the number of new messages.
  74. * \since 12.1.0
  75. *
  76. * \param mailbox Object to get number of new messages.
  77. *
  78. * \return Number of new messages.
  79. */
  80. unsigned int ast_mwi_mailbox_get_msgs_new(const struct ast_mwi_mailbox_object *mailbox);
  81. /*!
  82. * \brief Get the number of old messages.
  83. * \since 12.1.0
  84. *
  85. * \param mailbox Object to get number of old messages.
  86. *
  87. * \return Number of old messages.
  88. */
  89. unsigned int ast_mwi_mailbox_get_msgs_old(const struct ast_mwi_mailbox_object *mailbox);
  90. /*!
  91. * \brief Copy the external MWI counts object.
  92. * \since 12.1.0
  93. *
  94. * \param mailbox What to copy.
  95. *
  96. * \retval copy on success. The object is an ao2 object.
  97. * \retval NULL on error.
  98. */
  99. struct ast_mwi_mailbox_object *ast_mwi_mailbox_copy(const struct ast_mwi_mailbox_object *mailbox);
  100. /*!
  101. * \brief Set the number of new messages.
  102. * \since 12.1.0
  103. *
  104. * \param mailbox Object to set number of new messages.
  105. * \param num_msgs Number of messages to set.
  106. *
  107. * \return Nothing
  108. */
  109. void ast_mwi_mailbox_set_msgs_new(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs);
  110. /*!
  111. * \brief Set the number of old messages.
  112. * \since 12.1.0
  113. *
  114. * \param mailbox Object to set number of old messages.
  115. * \param num_msgs Number of messages to set.
  116. *
  117. * \return Nothing
  118. */
  119. void ast_mwi_mailbox_set_msgs_old(struct ast_mwi_mailbox_object *mailbox, unsigned int num_msgs);
  120. /*!
  121. * \brief Update the external MWI counts with the given object.
  122. * \since 12.1.0
  123. *
  124. * \param mailbox What to update.
  125. *
  126. * \retval 0 on success.
  127. * \retval -1 on error.
  128. */
  129. int ast_mwi_mailbox_update(struct ast_mwi_mailbox_object *mailbox);
  130. /*!
  131. * \brief Delete matching external MWI object.
  132. * \since 12.1.0
  133. *
  134. * \param mailbox_id Name of mailbox to delete.
  135. *
  136. * \retval 0 on success.
  137. * \retval -1 on error.
  138. */
  139. int ast_mwi_mailbox_delete(const char *mailbox_id);
  140. /*!
  141. * \brief Delete all external MWI objects selected by the regular expression.
  142. * \since 12.1.0
  143. *
  144. * \param regex Regular expression in extended syntax. (NULL is same as "")
  145. *
  146. * \note The provided regex is treated as extended case sensitive.
  147. *
  148. * \retval 0 on success.
  149. * \retval -1 on error.
  150. */
  151. int ast_mwi_mailbox_delete_by_regex(const char *regex);
  152. /*!
  153. * \brief Delete all external MWI objects.
  154. * \since 12.1.0
  155. *
  156. * \retval 0 on success.
  157. * \retval -1 on error.
  158. */
  159. int ast_mwi_mailbox_delete_all(void);
  160. /*!
  161. * \brief Get matching external MWI object.
  162. * \since 12.1.0
  163. *
  164. * \param mailbox_id Name of mailbox to retrieve.
  165. *
  166. * \retval requested mailbox on success. The object is an ao2 object.
  167. * \retval NULL on error or no mailbox.
  168. *
  169. * \note The object must be treated as read-only.
  170. */
  171. const struct ast_mwi_mailbox_object *ast_mwi_mailbox_get(const char *mailbox_id);
  172. /*!
  173. * \brief Get all external MWI objects selected by the regular expression.
  174. * \since 12.1.0
  175. *
  176. * \param regex Regular expression in extended syntax. (NULL is same as "")
  177. *
  178. * \note The provided regex is treated as extended case sensitive.
  179. *
  180. * \retval container of struct ast_mwi_mailbox_object on success.
  181. * \retval NULL on error.
  182. *
  183. * \note The objects in the container must be treated as read-only.
  184. */
  185. struct ao2_container *ast_mwi_mailbox_get_by_regex(const char *regex);
  186. /*!
  187. * \brief Get all external MWI objects.
  188. * \since 12.1.0
  189. *
  190. * \retval container of struct ast_mwi_mailbox_object on success.
  191. * \retval NULL on error.
  192. *
  193. * \note The objects in the container must be treated as read-only.
  194. */
  195. struct ao2_container *ast_mwi_mailbox_get_all(void);
  196. /* ------------------------------------------------------------------- */
  197. #if defined(__cplusplus) || defined(c_plusplus)
  198. }
  199. #endif
  200. #endif /* _ASTERISK_RES_MWI_EXTERNAL_H */