Thu Oct 11 06:47:03 2012

Asterisk developer's documentation


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  ***/
00031 
00032 #include "asterisk.h"
00033 
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 153747 $")
00035 
00036 #include "asterisk/file.h"
00037 #include "asterisk/channel.h"
00038 #include "asterisk/pbx.h"
00039 #include "asterisk/module.h"
00040 #include "asterisk/lock.h"
00041 #include "asterisk/app.h"
00042 
00043 /*** DOCUMENTATION
00044    <application name="IVRDemo" language="en_US">
00045       <synopsis>
00046          IVR Demo Application.
00047       </synopsis>
00048       <syntax>
00049          <parameter name="filename" required="true" />
00050       </syntax>
00051       <description>
00052          <para>This is a skeleton application that shows you the basic structure to create your
00053          own asterisk applications and demonstrates the IVR demo.</para>
00054       </description>
00055    </application>
00056  ***/
00057 
00058 static char *app = "IVRDemo";
00059 
00060 static int ivr_demo_func(struct ast_channel *chan, void *data)
00061 {
00062    ast_verbose("IVR Demo, data is %s!\n", (char *)data);
00063    return 0;
00064 }
00065 
00066 AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0, 
00067 {
00068    { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
00069    { "s", AST_ACTION_WAITOPTION },
00070    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00071    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00072    { "1", AST_ACTION_RESTART },
00073    { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
00074    { "3", AST_ACTION_CALLBACK, ivr_demo_func },
00075    { "4", AST_ACTION_TRANSFER, "demo|s|1" },
00076    { "*", AST_ACTION_REPEAT },
00077    { "#", AST_ACTION_UPONE  },
00078    { NULL }
00079 });
00080 
00081 AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0, 
00082 {
00083    { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
00084    { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
00085    { "g", AST_ACTION_WAITOPTION },
00086    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00087    { "1", AST_ACTION_RESTART },
00088    { "2", AST_ACTION_MENU, &ivr_submenu },
00089    { "2", AST_ACTION_RESTART },
00090    { "i", AST_ACTION_PLAYBACK, "invalid" },
00091    { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
00092    { "#", AST_ACTION_EXIT },
00093    { NULL },
00094 });
00095 
00096 
00097 static int skel_exec(struct ast_channel *chan, void *data)
00098 {
00099    int res=0;
00100    
00101    if (ast_strlen_zero(data)) {
00102       ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
00103       return -1;
00104    }
00105    
00106    /* Do our thing here */
00107 
00108    if (chan->_state != AST_STATE_UP)
00109       res = ast_answer(chan);
00110    if (!res)
00111       res = ast_ivr_menu_run(chan, &ivr_demo, data);
00112    
00113    return res;
00114 }
00115 
00116 static int unload_module(void)
00117 {
00118    return ast_unregister_application(app);
00119 }
00120 
00121 static int load_module(void)
00122 {
00123    return ast_register_application_xml(app, skel_exec);
00124 }
00125 
00126 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application");

Generated on Thu Oct 11 06:47:03 2012 for Asterisk - the Open Source PBX by  doxygen 1.5.6