2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
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.
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.
21 * \brief IVR Demo application
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
29 <defaultenabled>no</defaultenabled>
34 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
41 #include "asterisk/file.h"
42 #include "asterisk/logger.h"
43 #include "asterisk/channel.h"
44 #include "asterisk/pbx.h"
45 #include "asterisk/module.h"
46 #include "asterisk/lock.h"
47 #include "asterisk/app.h"
49 static char *tdesc
= "IVR Demo Application";
50 static char *app
= "IVRDemo";
51 static char *synopsis
=
52 " This is a skeleton application that shows you the basic structure to create your\n"
53 "own asterisk applications and demonstrates the IVR demo.\n";
55 static int ivr_demo_func(struct ast_channel
*chan
, void *data
)
57 ast_verbose("IVR Demo, data is %s!\n", (char *)data
);
61 AST_IVR_DECLARE_MENU(ivr_submenu
, "IVR Demo Sub Menu", 0,
63 { "s", AST_ACTION_BACKGROUND
, "demo-abouttotry" },
64 { "s", AST_ACTION_WAITOPTION
},
65 { "1", AST_ACTION_PLAYBACK
, "digits/1" },
66 { "1", AST_ACTION_PLAYBACK
, "digits/1" },
67 { "1", AST_ACTION_RESTART
},
68 { "2", AST_ACTION_PLAYLIST
, "digits/2;digits/3" },
69 { "3", AST_ACTION_CALLBACK
, ivr_demo_func
},
70 { "4", AST_ACTION_TRANSFER
, "demo|s|1" },
71 { "*", AST_ACTION_REPEAT
},
72 { "#", AST_ACTION_UPONE
},
76 AST_IVR_DECLARE_MENU(ivr_demo
, "IVR Demo Main Menu", 0,
78 { "s", AST_ACTION_BACKGROUND
, "demo-congrats" },
79 { "g", AST_ACTION_BACKGROUND
, "demo-instruct" },
80 { "g", AST_ACTION_WAITOPTION
},
81 { "1", AST_ACTION_PLAYBACK
, "digits/1" },
82 { "1", AST_ACTION_RESTART
},
83 { "2", AST_ACTION_MENU
, &ivr_submenu
},
84 { "2", AST_ACTION_RESTART
},
85 { "i", AST_ACTION_PLAYBACK
, "invalid" },
86 { "i", AST_ACTION_REPEAT
, (void *)(unsigned long)2 },
87 { "#", AST_ACTION_EXIT
},
92 static int skel_exec(struct ast_channel
*chan
, void *data
)
95 struct ast_module_user
*u
;
97 if (ast_strlen_zero(data
)) {
98 ast_log(LOG_WARNING
, "skel requires an argument (filename)\n");
102 u
= ast_module_user_add(chan
);
104 /* Do our thing here */
106 if (chan
->_state
!= AST_STATE_UP
)
107 res
= ast_answer(chan
);
109 res
= ast_ivr_menu_run(chan
, &ivr_demo
, data
);
111 ast_module_user_remove(u
);
116 static int unload_module(void)
120 res
= ast_unregister_application(app
);
122 ast_module_user_hangup_all();
127 static int load_module(void)
129 return ast_register_application(app
, skel_exec
, tdesc
, synopsis
);
132 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "IVR Demo Application");