func_callcompletion.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2010, 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. /*! \file
  19. * \brief Call Completion Supplementary Services implementation
  20. * \author Mark Michelson <mmichelson@digium.com>
  21. */
  22. /*** MODULEINFO
  23. <support_level>core</support_level>
  24. ***/
  25. #include "asterisk.h"
  26. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  27. #include "asterisk/module.h"
  28. #include "asterisk/channel.h"
  29. #include "asterisk/ccss.h"
  30. #include "asterisk/pbx.h"
  31. /*** DOCUMENTATION
  32. <function name="CALLCOMPLETION" language="en_US">
  33. <synopsis>
  34. Get or set a call completion configuration parameter for a channel.
  35. </synopsis>
  36. <syntax>
  37. <parameter name="option" required="true">
  38. <para>The allowable options are:</para>
  39. <enumlist>
  40. <enum name="cc_agent_policy" />
  41. <enum name="cc_monitor_policy" />
  42. <enum name="cc_offer_timer" />
  43. <enum name="ccnr_available_timer" />
  44. <enum name="ccbs_available_timer" />
  45. <enum name="cc_recall_timer" />
  46. <enum name="cc_max_agents" />
  47. <enum name="cc_max_monitors" />
  48. <enum name="cc_callback_macro" />
  49. <enum name="cc_agent_dialstring" />
  50. </enumlist>
  51. </parameter>
  52. </syntax>
  53. <description>
  54. <para>The CALLCOMPLETION function can be used to get or set a call
  55. completion configuration parameter for a channel. Note that setting
  56. a configuration parameter will only change the parameter for the
  57. duration of the call.
  58. For more information see <filename>doc/AST.pdf</filename>.
  59. For more information on call completion parameters, see <filename>configs/ccss.conf.sample</filename>.</para>
  60. </description>
  61. </function>
  62. ***/
  63. static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
  64. char *buf, size_t buf_len)
  65. {
  66. struct ast_cc_config_params *cc_params;
  67. int res;
  68. if (!chan) {
  69. ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name);
  70. return -1;
  71. }
  72. ast_channel_lock(chan);
  73. if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
  74. ast_channel_unlock(chan);
  75. return -1;
  76. }
  77. res = ast_cc_get_param(cc_params, data, buf, buf_len);
  78. ast_channel_unlock(chan);
  79. return res;
  80. }
  81. static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
  82. const char *value)
  83. {
  84. struct ast_cc_config_params *cc_params;
  85. int res;
  86. if (!chan) {
  87. ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
  88. return -1;
  89. }
  90. ast_channel_lock(chan);
  91. if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
  92. ast_channel_unlock(chan);
  93. return -1;
  94. }
  95. res = ast_cc_set_param(cc_params, data, value);
  96. ast_channel_unlock(chan);
  97. return res;
  98. }
  99. static struct ast_custom_function cc_function = {
  100. .name = "CALLCOMPLETION",
  101. .read = acf_cc_read,
  102. .write = acf_cc_write,
  103. };
  104. static int unload_module(void)
  105. {
  106. return ast_custom_function_unregister(&cc_function);
  107. }
  108. static int load_module(void)
  109. {
  110. return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE;
  111. }
  112. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call Control Configuration Function");