| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
#include "asterisk.h" |
| 34 |
|
| 35 |
#include "asterisk/file.h" |
| 36 |
#include "asterisk/channel.h" |
| 37 |
#include "asterisk/pbx.h" |
| 38 |
#include "asterisk/module.h" |
| 39 |
#include "asterisk/lock.h" |
| 40 |
#include "asterisk/app.h" |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
static char *app = "IVRDemo"; |
| 61 |
|
| 62 |
static int ivr_demo_func(struct ast_channel *chan, void *data) |
| 63 |
{ |
| 64 |
ast_verbose("IVR Demo, data is %s!\n", (char *) data); |
| 65 |
return 0; |
| 66 |
} |
| 67 |
|
| 68 |
AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0, |
| 69 |
{ |
| 70 |
{ "s", AST_ACTION_BACKGROUND, "demo-abouttotry" }, |
| 71 |
{ "s", AST_ACTION_WAITOPTION }, |
| 72 |
{ "1", AST_ACTION_PLAYBACK, "digits/1" }, |
| 73 |
{ "1", AST_ACTION_PLAYBACK, "digits/1" }, |
| 74 |
{ "1", AST_ACTION_RESTART }, |
| 75 |
{ "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" }, |
| 76 |
{ "3", AST_ACTION_CALLBACK, ivr_demo_func }, |
| 77 |
{ "4", AST_ACTION_TRANSFER, "demo|s|1" }, |
| 78 |
{ "*", AST_ACTION_REPEAT }, |
| 79 |
{ "#", AST_ACTION_UPONE }, |
| 80 |
{ NULL } |
| 81 |
}); |
| 82 |
|
| 83 |
AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0, |
| 84 |
{ |
| 85 |
{ "s", AST_ACTION_BACKGROUND, "demo-congrats" }, |
| 86 |
{ "g", AST_ACTION_BACKGROUND, "demo-instruct" }, |
| 87 |
{ "g", AST_ACTION_WAITOPTION }, |
| 88 |
{ "1", AST_ACTION_PLAYBACK, "digits/1" }, |
| 89 |
{ "1", AST_ACTION_RESTART }, |
| 90 |
{ "2", AST_ACTION_MENU, &ivr_submenu }, |
| 91 |
{ "2", AST_ACTION_RESTART }, |
| 92 |
{ "i", AST_ACTION_PLAYBACK, "invalid" }, |
| 93 |
{ "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 }, |
| 94 |
{ "#", AST_ACTION_EXIT }, |
| 95 |
{ NULL }, |
| 96 |
}); |
| 97 |
|
| 98 |
static int skel_exec(struct ast_channel *chan, const char *data) |
| 99 |
{ |
| 100 |
int res=0; |
| 101 |
char *tmp; |
| 102 |
|
| 103 |
if (ast_strlen_zero(data)) { |
| 104 |
ast_log(LOG_WARNING, "skel requires an argument (filename)\n"); |
| 105 |
return -1; |
| 106 |
} |
| 107 |
|
| 108 |
tmp = ast_strdupa(data); |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
if (ast_channel_state(chan) != AST_STATE_UP) |
| 113 |
res = ast_answer(chan); |
| 114 |
if (!res) |
| 115 |
res = ast_ivr_menu_run(chan, &ivr_demo, tmp); |
| 116 |
|
| 117 |
return res; |
| 118 |
} |
| 119 |
|
| 120 |
static int unload_module(void) |
| 121 |
{ |
| 122 |
return ast_unregister_application(app); |
| 123 |
} |
| 124 |
|
| 125 |
static int load_module(void) |
| 126 |
{ |
| 127 |
return ast_register_application_xml(app, skel_exec); |
| 128 |
} |
| 129 |
|
| 130 |
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "IVR Demo Application"); |