00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "asterisk.h"
00033
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 40722 $")
00035
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <unistd.h>
00039 #include <string.h>
00040
00041 #include "asterisk/file.h"
00042 #include "asterisk/logger.h"
00043 #include "asterisk/channel.h"
00044 #include "asterisk/pbx.h"
00045 #include "asterisk/module.h"
00046 #include "asterisk/lock.h"
00047 #include "asterisk/app.h"
00048
00049 static char *tdesc = "IVR Demo Application";
00050 static char *app = "IVRDemo";
00051 static char *synopsis =
00052 " This is a skeleton application that shows you the basic structure to create your\n"
00053 "own asterisk applications and demonstrates the IVR demo.\n";
00054
00055 static int ivr_demo_func(struct ast_channel *chan, void *data)
00056 {
00057 ast_verbose("IVR Demo, data is %s!\n", (char *)data);
00058 return 0;
00059 }
00060
00061 AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0,
00062 {
00063 { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
00064 { "s", AST_ACTION_WAITOPTION },
00065 { "1", AST_ACTION_PLAYBACK, "digits/1" },
00066 { "1", AST_ACTION_PLAYBACK, "digits/1" },
00067 { "1", AST_ACTION_RESTART },
00068 { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
00069 { "3", AST_ACTION_CALLBACK, ivr_demo_func },
00070 { "4", AST_ACTION_TRANSFER, "demo|s|1" },
00071 { "*", AST_ACTION_REPEAT },
00072 { "#", AST_ACTION_UPONE },
00073 { NULL }
00074 });
00075
00076 AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0,
00077 {
00078 { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
00079 { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
00080 { "g", AST_ACTION_WAITOPTION },
00081 { "1", AST_ACTION_PLAYBACK, "digits/1" },
00082 { "1", AST_ACTION_RESTART },
00083 { "2", AST_ACTION_MENU, &ivr_submenu },
00084 { "2", AST_ACTION_RESTART },
00085 { "i", AST_ACTION_PLAYBACK, "invalid" },
00086 { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
00087 { "#", AST_ACTION_EXIT },
00088 { NULL },
00089 });
00090
00091
00092 static int skel_exec(struct ast_channel *chan, void *data)
00093 {
00094 int res=0;
00095 struct ast_module_user *u;
00096
00097 if (ast_strlen_zero(data)) {
00098 ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
00099 return -1;
00100 }
00101
00102 u = ast_module_user_add(chan);
00103
00104
00105
00106 if (chan->_state != AST_STATE_UP)
00107 res = ast_answer(chan);
00108 if (!res)
00109 res = ast_ivr_menu_run(chan, &ivr_demo, data);
00110
00111 ast_module_user_remove(u);
00112
00113 return res;
00114 }
00115
00116 static int unload_module(void)
00117 {
00118 int res;
00119
00120 res = ast_unregister_application(app);
00121
00122 ast_module_user_hangup_all();
00123
00124 return res;
00125 }
00126
00127 static int load_module(void)
00128 {
00129 return ast_register_application(app, skel_exec, tdesc, synopsis);
00130 }
00131
00132 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application");