app_ivrdemo.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief IVR Demo application
00022  *
00023  * \author Mark Spencer <markster@digium.com>
00024  * 
00025  * \ingroup applications
00026  */
00027 
00028 /*** MODULEINFO
00029    <defaultenabled>no</defaultenabled>
00030    <support_level>extended</support_level>
00031  ***/
00032 
00033 #include "asterisk.h"
00034 
00035 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419592 $")
00036 
00037 #include "asterisk/file.h"
00038 #include "asterisk/channel.h"
00039 #include "asterisk/pbx.h"
00040 #include "asterisk/module.h"
00041 #include "asterisk/lock.h"
00042 #include "asterisk/app.h"
00043 
00044 /*** DOCUMENTATION
00045    <application name="IVRDemo" language="en_US">
00046       <synopsis>
00047          IVR Demo Application.
00048       </synopsis>
00049       <syntax>
00050          <parameter name="filename" required="true" />
00051       </syntax>
00052       <description>
00053          <para>This is a skeleton application that shows you the basic structure to create your
00054          own asterisk applications and demonstrates the IVR demo.</para>
00055       </description>
00056    </application>
00057  ***/
00058 
00059 static char *app = "IVRDemo";
00060 
00061 static int ivr_demo_func(struct ast_channel *chan, void *data)
00062 {
00063    ast_verbose("IVR Demo, data is %s!\n", (char *) data);
00064    return 0;
00065 }
00066 
00067 AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0, 
00068 {
00069    { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
00070    { "s", AST_ACTION_WAITOPTION },
00071    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00072    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00073    { "1", AST_ACTION_RESTART },
00074    { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
00075    { "3", AST_ACTION_CALLBACK, ivr_demo_func },
00076    { "4", AST_ACTION_TRANSFER, "demo|s|1" },
00077    { "*", AST_ACTION_REPEAT },
00078    { "#", AST_ACTION_UPONE  },
00079    { NULL }
00080 });
00081 
00082 AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0, 
00083 {
00084    { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
00085    { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
00086    { "g", AST_ACTION_WAITOPTION },
00087    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00088    { "1", AST_ACTION_RESTART },
00089    { "2", AST_ACTION_MENU, &ivr_submenu },
00090    { "2", AST_ACTION_RESTART },
00091    { "i", AST_ACTION_PLAYBACK, "invalid" },
00092    { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
00093    { "#", AST_ACTION_EXIT },
00094    { NULL },
00095 });
00096 
00097 static int skel_exec(struct ast_channel *chan, const char *data)
00098 {
00099    int res=0;
00100    char *tmp;
00101    
00102    if (ast_strlen_zero(data)) {
00103       ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
00104       return -1;
00105    }
00106    
00107    tmp = ast_strdupa(data);
00108 
00109    /* Do our thing here */
00110 
00111    if (ast_channel_state(chan) != AST_STATE_UP)
00112       res = ast_answer(chan);
00113    if (!res)
00114       res = ast_ivr_menu_run(chan, &ivr_demo, tmp);
00115    
00116    return res;
00117 }
00118 
00119 static int unload_module(void)
00120 {
00121    return ast_unregister_application(app);
00122 }
00123 
00124 static int load_module(void)
00125 {
00126    return ast_register_application_xml(app, skel_exec);
00127 }
00128 
00129 AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "IVR Demo Application");
00130 

Generated on Thu Apr 16 06:27:09 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6