Wed Oct 28 15:48:06 2009

Asterisk developer's documentation


app_ivrdemo.c File Reference

IVR Demo application. More...

#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"

Include dependency graph for app_ivrdemo.c:

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"


Detailed Description

IVR Demo application.

Definition in file app_ivrdemo.c.


Function Documentation

AST_IVR_DECLARE_MENU ( ivr_demo  ,
"IVR Demo Main Menu"  ,
 
)

AST_IVR_DECLARE_MENU ( ivr_submenu  ,
"IVR Demo Sub Menu"  ,
 
)

char* description ( void   ) 

Provides a description of the module.

Returns:
a short description of your 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;
 }

Returns:
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.

This function is called at module load time. Put all code in here that needs to set up your module's hardware, software, registrations, etc.

Returns:
This function should return 0 on success and non-zero on failure. If the module is not loaded successfully, Asterisk will call its unload_module() function.
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.

Returns:
int Always 0.
TE STUFF END

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(), 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).

Returns:
Zero on success, or non-zero on error.

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.

Returns:
The module's usecount.

Definition at line 134 of file app_ivrdemo.c.

References STANDARD_USECOUNT.

00135 {
00136    int res;
00137    STANDARD_USECOUNT(res);
00138    return res;
00139 }


Variable Documentation

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.


Generated on Wed Oct 28 15:48:07 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6