app_ivrdemo.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@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. *
  20. * \brief IVR Demo application
  21. *
  22. * \author Mark Spencer <markster@digium.com>
  23. *
  24. * \ingroup applications
  25. */
  26. /*** MODULEINFO
  27. <defaultenabled>no</defaultenabled>
  28. <support_level>extended</support_level>
  29. ***/
  30. #include "asterisk.h"
  31. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  32. #include "asterisk/file.h"
  33. #include "asterisk/channel.h"
  34. #include "asterisk/pbx.h"
  35. #include "asterisk/module.h"
  36. #include "asterisk/lock.h"
  37. #include "asterisk/app.h"
  38. /*** DOCUMENTATION
  39. <application name="IVRDemo" language="en_US">
  40. <synopsis>
  41. IVR Demo Application.
  42. </synopsis>
  43. <syntax>
  44. <parameter name="filename" required="true" />
  45. </syntax>
  46. <description>
  47. <para>This is a skeleton application that shows you the basic structure to create your
  48. own asterisk applications and demonstrates the IVR demo.</para>
  49. </description>
  50. </application>
  51. ***/
  52. static char *app = "IVRDemo";
  53. static int ivr_demo_func(struct ast_channel *chan, void *data)
  54. {
  55. ast_verbose("IVR Demo, data is %s!\n", (char *) data);
  56. return 0;
  57. }
  58. AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0,
  59. {
  60. { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
  61. { "s", AST_ACTION_WAITOPTION },
  62. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  63. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  64. { "1", AST_ACTION_RESTART },
  65. { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
  66. { "3", AST_ACTION_CALLBACK, ivr_demo_func },
  67. { "4", AST_ACTION_TRANSFER, "demo|s|1" },
  68. { "*", AST_ACTION_REPEAT },
  69. { "#", AST_ACTION_UPONE },
  70. { NULL }
  71. });
  72. AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0,
  73. {
  74. { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
  75. { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
  76. { "g", AST_ACTION_WAITOPTION },
  77. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  78. { "1", AST_ACTION_RESTART },
  79. { "2", AST_ACTION_MENU, &ivr_submenu },
  80. { "2", AST_ACTION_RESTART },
  81. { "i", AST_ACTION_PLAYBACK, "invalid" },
  82. { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
  83. { "#", AST_ACTION_EXIT },
  84. { NULL },
  85. });
  86. static int skel_exec(struct ast_channel *chan, const char *data)
  87. {
  88. int res=0;
  89. char *tmp;
  90. if (ast_strlen_zero(data)) {
  91. ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
  92. return -1;
  93. }
  94. tmp = ast_strdupa(data);
  95. /* Do our thing here */
  96. if (ast_channel_state(chan) != AST_STATE_UP)
  97. res = ast_answer(chan);
  98. if (!res)
  99. res = ast_ivr_menu_run(chan, &ivr_demo, tmp);
  100. return res;
  101. }
  102. static int unload_module(void)
  103. {
  104. return ast_unregister_application(app);
  105. }
  106. static int load_module(void)
  107. {
  108. return ast_register_application_xml(app, skel_exec);
  109. }
  110. AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "IVR Demo Application");