app_ivrdemo.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. ***/
  29. #include "asterisk.h"
  30. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  31. #include "asterisk/file.h"
  32. #include "asterisk/channel.h"
  33. #include "asterisk/pbx.h"
  34. #include "asterisk/module.h"
  35. #include "asterisk/lock.h"
  36. #include "asterisk/app.h"
  37. static char *tdesc = "IVR Demo Application";
  38. static char *app = "IVRDemo";
  39. static char *synopsis =
  40. " This is a skeleton application that shows you the basic structure to create your\n"
  41. "own asterisk applications and demonstrates the IVR demo.\n";
  42. static int ivr_demo_func(struct ast_channel *chan, void *data)
  43. {
  44. ast_verbose("IVR Demo, data is %s!\n", (char *)data);
  45. return 0;
  46. }
  47. AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0,
  48. {
  49. { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
  50. { "s", AST_ACTION_WAITOPTION },
  51. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  52. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  53. { "1", AST_ACTION_RESTART },
  54. { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
  55. { "3", AST_ACTION_CALLBACK, ivr_demo_func },
  56. { "4", AST_ACTION_TRANSFER, "demo|s|1" },
  57. { "*", AST_ACTION_REPEAT },
  58. { "#", AST_ACTION_UPONE },
  59. { NULL }
  60. });
  61. AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0,
  62. {
  63. { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
  64. { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
  65. { "g", AST_ACTION_WAITOPTION },
  66. { "1", AST_ACTION_PLAYBACK, "digits/1" },
  67. { "1", AST_ACTION_RESTART },
  68. { "2", AST_ACTION_MENU, &ivr_submenu },
  69. { "2", AST_ACTION_RESTART },
  70. { "i", AST_ACTION_PLAYBACK, "invalid" },
  71. { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
  72. { "#", AST_ACTION_EXIT },
  73. { NULL },
  74. });
  75. static int skel_exec(struct ast_channel *chan, void *data)
  76. {
  77. int res=0;
  78. if (ast_strlen_zero(data)) {
  79. ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
  80. return -1;
  81. }
  82. /* Do our thing here */
  83. if (chan->_state != AST_STATE_UP)
  84. res = ast_answer(chan);
  85. if (!res)
  86. res = ast_ivr_menu_run(chan, &ivr_demo, data);
  87. return res;
  88. }
  89. static int unload_module(void)
  90. {
  91. return ast_unregister_application(app);
  92. }
  93. static int load_module(void)
  94. {
  95. return ast_register_application(app, skel_exec, tdesc, synopsis);
  96. }
  97. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application");