Wed Aug 18 22:33:41 2010

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: 89424 $")
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 static char *tdesc = "IVR Demo Application";
00044 static char *app = "IVRDemo";
00045 static char *synopsis = 
00046 "  This is a skeleton application that shows you the basic structure to create your\n"
00047 "own asterisk applications and demonstrates the IVR demo.\n";
00048 
00049 static int ivr_demo_func(struct ast_channel *chan, void *data)
00050 {
00051    ast_verbose("IVR Demo, data is %s!\n", (char *)data);
00052    return 0;
00053 }
00054 
00055 AST_IVR_DECLARE_MENU(ivr_submenu, "IVR Demo Sub Menu", 0, 
00056 {
00057    { "s", AST_ACTION_BACKGROUND, "demo-abouttotry" },
00058    { "s", AST_ACTION_WAITOPTION },
00059    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00060    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00061    { "1", AST_ACTION_RESTART },
00062    { "2", AST_ACTION_PLAYLIST, "digits/2;digits/3" },
00063    { "3", AST_ACTION_CALLBACK, ivr_demo_func },
00064    { "4", AST_ACTION_TRANSFER, "demo|s|1" },
00065    { "*", AST_ACTION_REPEAT },
00066    { "#", AST_ACTION_UPONE  },
00067    { NULL }
00068 });
00069 
00070 AST_IVR_DECLARE_MENU(ivr_demo, "IVR Demo Main Menu", 0, 
00071 {
00072    { "s", AST_ACTION_BACKGROUND, "demo-congrats" },
00073    { "g", AST_ACTION_BACKGROUND, "demo-instruct" },
00074    { "g", AST_ACTION_WAITOPTION },
00075    { "1", AST_ACTION_PLAYBACK, "digits/1" },
00076    { "1", AST_ACTION_RESTART },
00077    { "2", AST_ACTION_MENU, &ivr_submenu },
00078    { "2", AST_ACTION_RESTART },
00079    { "i", AST_ACTION_PLAYBACK, "invalid" },
00080    { "i", AST_ACTION_REPEAT, (void *)(unsigned long)2 },
00081    { "#", AST_ACTION_EXIT },
00082    { NULL },
00083 });
00084 
00085 
00086 static int skel_exec(struct ast_channel *chan, void *data)
00087 {
00088    int res=0;
00089    
00090    if (ast_strlen_zero(data)) {
00091       ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
00092       return -1;
00093    }
00094    
00095    /* Do our thing here */
00096 
00097    if (chan->_state != AST_STATE_UP)
00098       res = ast_answer(chan);
00099    if (!res)
00100       res = ast_ivr_menu_run(chan, &ivr_demo, data);
00101    
00102    return res;
00103 }
00104 
00105 static int unload_module(void)
00106 {
00107    return ast_unregister_application(app);
00108 }
00109 
00110 static int load_module(void)
00111 {
00112    return ast_register_application(app, skel_exec, tdesc, synopsis);
00113 }
00114 
00115 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "IVR Demo Application");

Generated on Wed Aug 18 22:33:41 2010 for Asterisk - the Open Source PBX by  doxygen 1.4.7