Merge "pjproject_bundled: Allow IPv4/IPv6 (Dual Stack) configurations."
[asterisk/asterisk.git] / apps / app_ivrdemo.c
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
19 /*! \file
20  *
21  * \brief IVR Demo application
22  *
23  * \author Mark Spencer <markster@digium.com>
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 ASTERISK_REGISTER_FILE()
36
37 #include "asterisk/file.h"
38 #include "asterisk/channel.h"
39 #include "asterisk/pbx.h"
40 #include "asterisk/module.h"
41 #include "asterisk/lock.h"
42 #include "asterisk/app.h"
43
44 /*** DOCUMENTATION
45         <application name="IVRDemo" language="en_US">
46                 <synopsis>
47                         IVR Demo Application.
48                 </synopsis>
49                 <syntax>
50                         <parameter name="filename" required="true" />
51                 </syntax>
52                 <description>
53                         <para>This is a skeleton application that shows you the basic structure to create your
54                         own asterisk applications and demonstrates the IVR demo.</para>
55                 </description>
56         </application>
57  ***/
58
59 static char *app = "IVRDemo";
60
61 static int ivr_demo_func(struct ast_channel *chan, void *data)
62 {
63         ast_verbose("IVR Demo, data is %s!\n", (char *) data);
64         return 0;
65 }
66
67 AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0, 
68 {
69         { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
70         { "s", AST_ACTION_WAITOPTION },
71         { "1", AST_ACTION_PLAYBACK, "digits/1" },
72         { "1", AST_ACTION_PLAYBACK, "digits/1" },
73         { "1", AST_ACTION_RESTART },
74         { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
75         { "3", AST_ACTION_CALLBACK, ivr_demo_func },
76         { "4", AST_ACTION_TRANSFER, "demo|s|1" },
77         { "*", AST_ACTION_REPEAT },
78         { "#", AST_ACTION_UPONE  },
79         { NULL }
80 });
81
82 AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0, 
83 {
84         { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
85         { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
86         { "g", AST_ACTION_WAITOPTION },
87         { "1", AST_ACTION_PLAYBACK, "digits/1" },
88         { "1", AST_ACTION_RESTART },
89         { "2", AST_ACTION_MENU, &ivr_submenu },
90         { "2", AST_ACTION_RESTART },
91         { "i", AST_ACTION_PLAYBACK, "invalid" },
92         { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
93         { "#", AST_ACTION_EXIT },
94         { NULL },
95 });
96
97 static int skel_exec(struct ast_channel *chan, const char *data)
98 {
99         int res=0;
100         char *tmp;
101         
102         if (ast_strlen_zero(data)) {
103                 ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
104                 return -1;
105         }
106         
107         tmp = ast_strdupa(data);
108
109         /* Do our thing here */
110
111         if (ast_channel_state(chan) != AST_STATE_UP)
112                 res = ast_answer(chan);
113         if (!res)
114                 res = ast_ivr_menu_run(chan, &ivr_demo, tmp);
115         
116         return res;
117 }
118
119 static int unload_module(void)
120 {
121         return ast_unregister_application(app);
122 }
123
124 static int load_module(void)
125 {
126         return ast_register_application_xml(app, skel_exec);
127 }
128
129 AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "IVR Demo Application");
130