#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
Go to the source code of this file.
Functions | |
AST_IVR_DECLARE_MENU (ivr_demo,"IVR Demo Main Menu", 0,{{"s", AST_ACTION_BACKGROUND,"demo-congrats"},{"g", AST_ACTION_BACKGROUND,"demo-instruct"},{"g", AST_ACTION_WAITOPTION},{"1", AST_ACTION_PLAYBACK,"digits/1"},{"1", AST_ACTION_RESTART},{"2", AST_ACTION_MENU,&ivr_submenu},{"2", AST_ACTION_RESTART},{"i", AST_ACTION_PLAYBACK,"invalid"},{"i", AST_ACTION_REPEAT,(void *)(unsigned long) 2},{"#", AST_ACTION_EXIT},{NULL},}) | |
AST_IVR_DECLARE_MENU (ivr_submenu,"IVR Demo Sub Menu", 0,{{"s", AST_ACTION_BACKGROUND,"demo-abouttotry"},{"s", AST_ACTION_WAITOPTION},{"1", AST_ACTION_PLAYBACK,"digits/1"},{"1", AST_ACTION_PLAYBACK,"digits/1"},{"1", AST_ACTION_RESTART},{"2", AST_ACTION_PLAYLIST,"digits/2;digits/3"},{"3", AST_ACTION_CALLBACK, ivr_demo_func},{"4", AST_ACTION_TRANSFER,"demo|s|1"},{"*", AST_ACTION_REPEAT},{"#", AST_ACTION_UPONE},{NULL}}) | |
char * | description (void) |
Provides a description of the module. | |
static int | ivr_demo_func (struct ast_channel *chan, void *data) |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
static int | skel_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "IVRDemo" |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis |
static char * | tdesc = "IVR Demo Application" |
Definition in file app_ivrdemo.c.
AST_IVR_DECLARE_MENU | ( | ivr_demo | , | |
"IVR Demo Main Menu" | , | |||
0 | ||||
) |
AST_IVR_DECLARE_MENU | ( | ivr_submenu | , | |
"IVR Demo Sub Menu" | , | |||
0 | ||||
) |
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 129 of file app_ivrdemo.c.
00130 { 00131 return tdesc; 00132 }
static int ivr_demo_func | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 49 of file app_ivrdemo.c.
References ast_verbose().
00050 { 00051 ast_verbose("IVR Demo, data is %s!\n", (char *)data); 00052 return 0; 00053 }
char* key | ( | void | ) |
Returns the ASTERISK_GPL_KEY.
This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 141 of file app_ivrdemo.c.
References ASTERISK_GPL_KEY.
00142 { 00143 return ASTERISK_GPL_KEY; 00144 }
int load_module | ( | void | ) |
Initialize the module.
Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 124 of file app_ivrdemo.c.
References ast_register_application(), and skel_exec().
00125 { 00126 return ast_register_application(app, skel_exec, tdesc, synopsis); 00127 }
static int skel_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 89 of file app_ivrdemo.c.
References ast_channel::_state, ast_answer(), ast_ivr_menu_run(), ast_log(), AST_STATE_UP, ast_strlen_zero(), localuser::chan, LOCAL_USER_ADD, LOCAL_USER_REMOVE, and LOG_WARNING.
Referenced by load_module().
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 }
int unload_module | ( | void | ) |
Cleanup all module structures, sockets, etc.
This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 113 of file app_ivrdemo.c.
References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00114 { 00115 int res; 00116 00117 res = ast_unregister_application(app); 00118 00119 STANDARD_HANGUP_LOCALUSERS; 00120 00121 return res; 00122 }
int usecount | ( | void | ) |
Provides a usecount.
This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 134 of file app_ivrdemo.c.
References STANDARD_USECOUNT.
00135 { 00136 int res; 00137 STANDARD_USECOUNT(res); 00138 return res; 00139 }
char* app = "IVRDemo" [static] |
Definition at line 44 of file app_ivrdemo.c.
Definition at line 87 of file app_ivrdemo.c.
Definition at line 85 of file app_ivrdemo.c.
char* synopsis [static] |
Initial value:
" This is a skeleton application that shows you the basic structure to create your\n" "own asterisk applications and demonstrates the IVR demo.\n"
Definition at line 45 of file app_ivrdemo.c.
char* tdesc = "IVR Demo Application" [static] |
Definition at line 43 of file app_ivrdemo.c.