Fri May 26 01:45:27 2006

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  * \ingroup applications
00024  */
00025 
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <unistd.h>
00029 #include <string.h>
00030 
00031 #include "asterisk.h"
00032 
00033 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00034 
00035 #include "asterisk/file.h"
00036 #include "asterisk/logger.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 STANDARD_LOCAL_USER;
00086 
00087 LOCAL_USER_DECL;
00088 
00089 static int skel_exec(struct ast_channel *chan, void *data)
00090 {
00091    int res=0;
00092    struct localuser *u;
00093    
00094    if (ast_strlen_zero(data)) {
00095       ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
00096       return -1;
00097    }
00098    
00099    LOCAL_USER_ADD(u);
00100 
00101    /* Do our thing here */
00102 
00103    if (chan->_state != AST_STATE_UP)
00104       res = ast_answer(chan);
00105    if (!res)
00106       res = ast_ivr_menu_run(chan, &ivr_demo, data);
00107    
00108    LOCAL_USER_REMOVE(u);
00109 
00110    return res;
00111 }
00112 
00113 int unload_module(void)
00114 {
00115    int res;
00116    
00117    res = ast_unregister_application(app);
00118 
00119    STANDARD_HANGUP_LOCALUSERS;
00120    
00121    return res;
00122 }
00123 
00124 int load_module(void)
00125 {
00126    return ast_register_application(app, skel_exec, tdesc, synopsis);
00127 }
00128 
00129 char *description(void)
00130 {
00131    return tdesc;
00132 }
00133 
00134 int usecount(void)
00135 {
00136    int res;
00137    STANDARD_USECOUNT(res);
00138    return res;
00139 }
00140 
00141 char *key()
00142 {
00143    return ASTERISK_GPL_KEY;
00144 }

Generated on Fri May 26 01:45:27 2006 for Asterisk - the Open Source PBX by  doxygen 1.4.6