Debian Codegraph @

apps/app_ivrdemo.c

raw symbols SCIP
1 /*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 1999 - 2005, Digium, Inc.
5 *
6 * Mark Spencer <[email protected]>
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
19 /*! \file
20 *
21 * \brief IVR Demo application
22 *
23 * \author Mark Spencer <[email protected]>
24 *
25 * \ingroup applications
26 */
27
28 /*** MODULEINFO
29 <defaultenabled>no</defaultenabled>
30 <support_level>extended</support_level>
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 /*** DOCUMENTATION
43 <application name="IVRDemo" language="en_US">
44 <since>
45 <version>1.2.0</version>
46 </since>
47 <synopsis>
48 IVR Demo Application.
49 </synopsis>
50 <syntax>
51 <parameter name="filename" required="true" />
52 </syntax>
53 <description>
54 <para>This is a skeleton application that shows you the basic structure to create your
55 own asterisk applications and demonstrates the IVR demo.</para>
56 </description>
57 </application>
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 /* Do our thing here */
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");