features_config.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * Mark Michelson <mmichelson@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. #ifndef _FEATURES_CONFIG_H
  19. #define _FEATURES_CONFIG_H
  20. #include "asterisk/stringfields.h"
  21. struct ast_channel;
  22. /*!
  23. * \brief General features configuration items
  24. */
  25. struct ast_features_general_config {
  26. AST_DECLARE_STRING_FIELDS(
  27. /*! Sound played when automon or automixmon features are used */
  28. AST_STRING_FIELD(courtesytone);
  29. /*! Sound played when automon or automixmon features fail when used */
  30. AST_STRING_FIELD(recordingfailsound);
  31. );
  32. /*! Milliseconds allowed between digit presses when entering feature code */
  33. unsigned int featuredigittimeout;
  34. };
  35. /*!
  36. * \brief Get the general configuration options for a channel
  37. *
  38. * \note The channel should be locked before calling this function.
  39. * \note The returned value has its reference count incremented.
  40. *
  41. * If no channel is provided, then the global features configuration is returned.
  42. *
  43. * \param chan The channel to get configuration options for
  44. * \retval NULL Failed to get configuration
  45. * \retval non-NULL The general features configuration
  46. */
  47. struct ast_features_general_config *ast_get_chan_features_general_config(struct ast_channel *chan);
  48. /*!
  49. * \brief Feature configuration relating to transfers
  50. */
  51. struct ast_features_xfer_config {
  52. AST_DECLARE_STRING_FIELDS (
  53. /*! Sound to play when transfer succeeds */
  54. AST_STRING_FIELD(xfersound);
  55. /*! Sound to play when transfer fails */
  56. AST_STRING_FIELD(xferfailsound);
  57. /*! DTMF sequence used to abort an attempted atxfer */
  58. AST_STRING_FIELD(atxferabort);
  59. /*! DTMF sequence used to complete an attempted atxfer */
  60. AST_STRING_FIELD(atxfercomplete);
  61. /*! DTMF sequence used to turn an attempted atxfer into a three-way call */
  62. AST_STRING_FIELD(atxferthreeway);
  63. /*! DTMF sequence used to swap which party the transferer is talking to */
  64. AST_STRING_FIELD(atxferswap);
  65. /*! Sound played when an invalid extension is dialed, and the transferer should retry. */
  66. AST_STRING_FIELD(transferretrysound);
  67. /*! Sound played when an invalid extension is dialed, and the transferer is being returned to the call. */
  68. AST_STRING_FIELD(transferinvalidsound);
  69. );
  70. /*! Seconds allowed between digit presses when dialing transfer destination */
  71. unsigned int transferdigittimeout;
  72. /*! Seconds to wait for the transfer target to answer a transferred call */
  73. unsigned int atxfernoanswertimeout;
  74. /*! Seconds to wait before attempting to re-dial the transfer target */
  75. unsigned int atxferloopdelay;
  76. /*! Number of times to re-attempt dialing the transfer target */
  77. unsigned int atxfercallbackretries;
  78. /*! Determines if the call is dropped on attended transfer failure */
  79. unsigned int atxferdropcall;
  80. /*! Number of dial attempts allowed for blind/attended transfers */
  81. unsigned int transferdialattempts;
  82. };
  83. /*!
  84. * \brief Get the transfer configuration options for a channel
  85. *
  86. * \note The channel should be locked before calling this function.
  87. * \note The returned value has its reference count incremented.
  88. *
  89. * If no channel is provided, then the global transfer configuration is returned.
  90. *
  91. * \param chan The channel to get configuration options for
  92. * \retval NULL Failed to get configuration
  93. * \retval non-NULL The transfer features configuration
  94. */
  95. struct ast_features_xfer_config *ast_get_chan_features_xfer_config(struct ast_channel *chan);
  96. /*!
  97. * \brief Get the transfer configuration option xferfailsound
  98. *
  99. * \note The channel should be locked before calling this function.
  100. * \note The returned value has to be freed.
  101. *
  102. * If no channel is provided, then option is pulled from the global
  103. * transfer configuration.
  104. *
  105. * \param chan The channel to get configuration options for
  106. * \retval NULL Failed to get configuration
  107. * \retval non-NULL The xferfailsound
  108. */
  109. char *ast_get_chan_features_xferfailsound(struct ast_channel *chan);
  110. /*!
  111. * \brief Get the transfer configuration option atxferabort
  112. *
  113. * \note The channel should be locked before calling this function.
  114. * \note The returned value has to be freed.
  115. *
  116. * If no channel is provided, then option is pulled from the global
  117. * transfer configuration.
  118. *
  119. * \param chan The channel to get configuration options for
  120. * \retval NULL Failed to get configuration
  121. * \retval non-NULL The atxferabort
  122. */
  123. char *ast_get_chan_features_atxferabort(struct ast_channel *chan);
  124. /*!
  125. * \brief Configuration relating to call pickup
  126. */
  127. struct ast_features_pickup_config {
  128. AST_DECLARE_STRING_FIELDS (
  129. /*! Digit sequence to press to pick up a ringing call */
  130. AST_STRING_FIELD(pickupexten);
  131. /*! Sound to play to picker when pickup succeeds */
  132. AST_STRING_FIELD(pickupsound);
  133. /*! Sound to play to picker when pickup fails */
  134. AST_STRING_FIELD(pickupfailsound);
  135. );
  136. };
  137. /*!
  138. * \brief Get the pickup configuration options for a channel
  139. *
  140. * \note The channel should be locked before calling this function.
  141. * \note The returned value has its reference count incremented.
  142. *
  143. * If no channel is provided, then the global pickup configuration is returned.
  144. *
  145. * \param chan The channel to get configuration options for
  146. * \retval NULL Failed to get configuration
  147. * \retval non-NULL The pickup features configuration
  148. */
  149. struct ast_features_pickup_config *ast_get_chan_features_pickup_config(struct ast_channel *chan);
  150. /*!
  151. * \brief Configuration for the builtin features
  152. */
  153. struct ast_featuremap_config {
  154. AST_DECLARE_STRING_FIELDS (
  155. /*! Blind transfer DTMF code */
  156. AST_STRING_FIELD(blindxfer);
  157. /*! Disconnect DTMF code */
  158. AST_STRING_FIELD(disconnect);
  159. /*! Automon DTMF code */
  160. AST_STRING_FIELD(automon);
  161. /*! Attended Transfer DTMF code */
  162. AST_STRING_FIELD(atxfer);
  163. /*! One-touch parking DTMF code */
  164. AST_STRING_FIELD(parkcall);
  165. /*! Automixmon DTMF code */
  166. AST_STRING_FIELD(automixmon);
  167. );
  168. };
  169. /*!
  170. * \brief Get the featuremap configuration options for a channel
  171. *
  172. * \note The channel should be locked before calling this function.
  173. * \note The returned value has its reference count incremented.
  174. *
  175. * If no channel is provided, then the global featuremap configuration is returned.
  176. *
  177. * \param chan The channel to get configuration options for
  178. * \retval NULL Failed to get configuration
  179. * \retval non-NULL The pickup features configuration
  180. */
  181. struct ast_featuremap_config *ast_get_chan_featuremap_config(struct ast_channel *chan);
  182. /*!
  183. * \brief Get the DTMF code for a builtin feature
  184. *
  185. * \note The channel should be locked before calling this function
  186. *
  187. * If no channel is provided, then the global setting for the option is returned.
  188. *
  189. * \param chan The channel to get the option from
  190. * \param feature The short name of the feature (as it appears in features.conf)
  191. * \param[out] buf The buffer to write the DTMF value into
  192. * \param size The size of the buffer in bytes
  193. * \retval 0 Success
  194. * \retval non-zero Unrecognized builtin feature name
  195. */
  196. int ast_get_builtin_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);
  197. /*!
  198. * \brief Get the DTMF code for a call feature
  199. *
  200. * \note The channel should be locked before calling this function
  201. *
  202. * If no channel is provided, then the global setting for the option is returned.
  203. *
  204. * This function is like \ref ast_get_builtin_feature except that it will
  205. * also check the applicationmap in addition to the builtin features.
  206. *
  207. * \param chan The channel to get the option from
  208. * \param feature The short name of the feature
  209. * \param[out] buf The buffer to write the DTMF value into
  210. * \param size The size of the buffer in bytes
  211. * \retval 0 Success
  212. * \retval non-zero Unrecognized feature name
  213. */
  214. int ast_get_feature(struct ast_channel *chan, const char *feature, char *buf, size_t len);
  215. #define AST_FEATURE_MAX_LEN 11
  216. /*!
  217. * \brief An applicationmap configuration item
  218. */
  219. struct ast_applicationmap_item {
  220. AST_DECLARE_STRING_FIELDS (
  221. /* Name of the item */
  222. AST_STRING_FIELD(name);
  223. /* Name Dialplan application that is invoked by the feature */
  224. AST_STRING_FIELD(app);
  225. /* Data to pass to the application */
  226. AST_STRING_FIELD(app_data);
  227. /* Music-on-hold class to play to party on which feature is not activated */
  228. AST_STRING_FIELD(moh_class);
  229. );
  230. /* DTMF key sequence used to activate the feature */
  231. char dtmf[AST_FEATURE_MAX_LEN];
  232. /* If true, activate on party that input the sequence, otherwise activate on the other party */
  233. unsigned int activate_on_self;
  234. };
  235. /*!
  236. * \brief Get the applicationmap for a given channel.
  237. *
  238. * \note The channel should be locked before calling this function.
  239. *
  240. * This uses the value of the DYNAMIC_FEATURES channel variable to build a
  241. * custom applicationmap for this channel. The returned container has
  242. * applicationmap_items inside.
  243. *
  244. * \param chan The channel for which applicationmap is being retrieved.
  245. * \retval NULL An error occurred or the channel has no dynamic features.
  246. * \retval non-NULL A container of applicationmap_items pertaining to the channel.
  247. */
  248. struct ao2_container *ast_get_chan_applicationmap(struct ast_channel *chan);
  249. void ast_features_config_shutdown(void);
  250. int ast_features_config_reload(void);
  251. int ast_features_config_init(void);
  252. #endif /* _FEATURES_CONFIG_H */