Asterisk - The Open Source Telephony Project GIT-master-f36a736
app_ivrdemo.c
Go to the documentation of this file.
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#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 <synopsis>
45 IVR Demo Application.
46 </synopsis>
47 <syntax>
48 <parameter name="filename" required="true" />
49 </syntax>
50 <description>
51 <para>This is a skeleton application that shows you the basic structure to create your
52 own asterisk applications and demonstrates the IVR demo.</para>
53 </description>
54 </application>
55 ***/
56
57static char *app = "IVRDemo";
58
59static int ivr_demo_func(struct ast_channel *chan, void *data)
60{
61 ast_verbose("IVR Demo, data is %s!\n", (char *) data);
62 return 0;
63}
64
65AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0,
66{
67 { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
68 { "s", AST_ACTION_WAITOPTION },
69 { "1", AST_ACTION_PLAYBACK, "digits/1" },
70 { "1", AST_ACTION_PLAYBACK, "digits/1" },
71 { "1", AST_ACTION_RESTART },
72 { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
74 { "4", AST_ACTION_TRANSFER, "demo|s|1" },
75 { "*", AST_ACTION_REPEAT },
76 { "#", AST_ACTION_UPONE },
77 { NULL }
78});
79
80AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0,
81{
82 { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
83 { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
84 { "g", AST_ACTION_WAITOPTION },
85 { "1", AST_ACTION_PLAYBACK, "digits/1" },
86 { "1", AST_ACTION_RESTART },
88 { "2", AST_ACTION_RESTART },
89 { "i", AST_ACTION_PLAYBACK, "invalid" },
90 { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
91 { "#", AST_ACTION_EXIT },
92 { NULL },
93});
94
95static int skel_exec(struct ast_channel *chan, const char *data)
96{
97 int res=0;
98 char *tmp;
99
100 if (ast_strlen_zero(data)) {
101 ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
102 return -1;
103 }
104
105 tmp = ast_strdupa(data);
106
107 /* Do our thing here */
108
109 if (ast_channel_state(chan) != AST_STATE_UP)
110 res = ast_answer(chan);
111 if (!res)
112 res = ast_ivr_menu_run(chan, &ivr_demo, tmp);
113
114 return res;
115}
116
117static int unload_module(void)
118{
120}
121
122static int load_module(void)
123{
125}
126
static struct ast_ivr_menu ivr_submenu
Definition: app_ivrdemo.c:78
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "IVR Demo Application")
static int skel_exec(struct ast_channel *chan, const char *data)
Definition: app_ivrdemo.c:95
static char * app
Definition: app_ivrdemo.c:57
static struct ast_ivr_menu ivr_demo
Definition: app_ivrdemo.c:93
static int ivr_demo_func(struct ast_channel *chan, void *data)
Definition: app_ivrdemo.c:59
static int load_module(void)
Definition: app_ivrdemo.c:122
static int unload_module(void)
Definition: app_ivrdemo.c:117
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
static int tmp()
Definition: bt_open.c:389
General Asterisk PBX channel definitions.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2824
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2206
Generic File Format Support. Should be included by clients of the file handling routines....
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
Definition: main/app.c:2942
@ AST_ACTION_UPONE
@ AST_ACTION_PLAYBACK
@ AST_ACTION_RESTART
@ AST_ACTION_PLAYLIST
@ AST_ACTION_CALLBACK
@ AST_ACTION_EXIT
@ AST_ACTION_BACKGROUND
@ AST_ACTION_WAITOPTION
@ AST_ACTION_MENU
@ AST_ACTION_REPEAT
@ AST_ACTION_TRANSFER
#define AST_IVR_DECLARE_MENU(holder, title, flags, foo...)
#define LOG_WARNING
Asterisk locking-related definitions:
Asterisk module definitions.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640
Core PBX routines and definitions.
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Main Channel structure associated with a channel.