app_celgenuserevent.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2008, Digium, Inc
  5. *
  6. * See http://www.asterisk.org for more information about
  7. * the Asterisk project. Please do not directly contact
  8. * any of the maintainers of this project for assistance;
  9. * the project provides a web site, mailing lists and IRC
  10. * channels for your use.
  11. *
  12. * This program is free software, distributed under the terms of
  13. * the GNU General Public License Version 2. See the LICENSE file
  14. * at the top of the source tree.
  15. */
  16. /*! \file
  17. *
  18. * \brief Generate User-Defined CEL event
  19. *
  20. * \author Steve Murphy
  21. *
  22. * \ingroup applications
  23. */
  24. #include "asterisk.h"
  25. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  26. #include "asterisk/module.h"
  27. #include "asterisk/app.h"
  28. #include "asterisk/channel.h"
  29. #include "asterisk/cel.h"
  30. /*** DOCUMENTATION
  31. <application name="CELGenUserEvent" language="en_US">
  32. <synopsis>
  33. Generates a CEL User Defined Event.
  34. </synopsis>
  35. <syntax>
  36. <parameter name="event-name" required="true">
  37. <argument name="event-name" required="true">
  38. </argument>
  39. <argument name="extra" required="false">
  40. <para>Extra text to be included with the event.</para>
  41. </argument>
  42. </parameter>
  43. </syntax>
  44. <description>
  45. <para>A CEL event will be immediately generated by this channel, with the supplied name for a type.</para>
  46. </description>
  47. </application>
  48. ***/
  49. static char *app = "CELGenUserEvent";
  50. static int celgenuserevent_exec(struct ast_channel *chan, const char *data)
  51. {
  52. int res = 0;
  53. char *parse;
  54. AST_DECLARE_APP_ARGS(args,
  55. AST_APP_ARG(event);
  56. AST_APP_ARG(extra);
  57. );
  58. if (ast_strlen_zero(data)) {
  59. return 0;
  60. }
  61. parse = ast_strdupa(data);
  62. AST_STANDARD_APP_ARGS(args, parse);
  63. ast_cel_report_event(chan, AST_CEL_USER_DEFINED, args.event, args.extra, NULL);
  64. return res;
  65. }
  66. static int unload_module(void)
  67. {
  68. int res;
  69. res = ast_unregister_application(app);
  70. ast_module_user_hangup_all();
  71. return res;
  72. }
  73. static int load_module(void)
  74. {
  75. int res = ast_register_application_xml(app, celgenuserevent_exec);
  76. if (res) {
  77. return AST_MODULE_LOAD_DECLINE;
  78. } else {
  79. return AST_MODULE_LOAD_SUCCESS;
  80. }
  81. }
  82. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generate an User-Defined CEL event",
  83. .load = load_module,
  84. .unload = unload_module,
  85. );