#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/options.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/manager.h"
Include dependency graph for app_senddtmf.c:
Go to the source code of this file.
Functions | |
char * | description (void) |
Provides a description of the module. | |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
static int | manager_play_dtmf (struct mansession *s, struct message *m) |
static int | senddtmf_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 = "SendDTMF" |
static char * | descrip |
LOCAL_USER_DECL | |
static char | mandescr_playdtmf [] |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Sends arbitrary DTMF digits" |
static char * | tdesc = "Send DTMF digits Application" |
Definition in file app_senddtmf.c.
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 144 of file app_senddtmf.c.
00145 { 00146 return tdesc; 00147 }
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 156 of file app_senddtmf.c.
References ASTERISK_GPL_KEY.
00157 { 00158 return ASTERISK_GPL_KEY; 00159 }
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 138 of file app_senddtmf.c.
References ast_manager_register2(), ast_register_application(), EVENT_FLAG_AGENT, manager_play_dtmf(), and senddtmf_exec().
00139 { 00140 ast_manager_register2( "playDTMF", EVENT_FLAG_AGENT, manager_play_dtmf, "Play DTMF signal on a specific channel.", mandescr_playdtmf); 00141 return ast_register_application(app, senddtmf_exec, synopsis, descrip); 00142 }
static int manager_play_dtmf | ( | struct mansession * | s, | |
struct message * | m | |||
) | [static] |
Definition at line 105 of file app_senddtmf.c.
References ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_senddigit(), astman_get_header(), astman_send_ack(), astman_send_error(), ast_channel::lock, and s.
Referenced by load_module().
00106 { 00107 char *channel, *digit; 00108 00109 channel = astman_get_header(m, "Channel"); 00110 digit = astman_get_header(m, "Digit"); 00111 struct ast_channel *chan = ast_get_channel_by_name_locked(channel); 00112 if (chan == NULL) { 00113 astman_send_error(s, m, "No such channel"); 00114 return 0; 00115 } 00116 if (digit == NULL) { 00117 astman_send_error(s, m, "No digit specified"); 00118 return 0; 00119 } 00120 ast_senddigit(chan, *digit); 00121 ast_mutex_unlock(&chan->lock); 00122 astman_send_ack(s, m, "DTMF successfully sent"); 00123 return 0; 00124 }
static int senddtmf_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 62 of file app_senddtmf.c.
References ast_dtmf_stream(), ast_log(), ast_strdupa, ast_strlen_zero(), localuser::chan, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, and LOG_WARNING.
Referenced by load_module().
00063 { 00064 int res = 0; 00065 struct localuser *u; 00066 char *digits = NULL, *to = NULL; 00067 int timeout = 250; 00068 00069 if (ast_strlen_zero(data)) { 00070 ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n"); 00071 return 0; 00072 } 00073 00074 LOCAL_USER_ADD(u); 00075 00076 digits = ast_strdupa(data); 00077 if (!digits) { 00078 ast_log(LOG_ERROR, "Out of Memory!\n"); 00079 LOCAL_USER_REMOVE(u); 00080 return -1; 00081 } 00082 00083 if ((to = strchr(digits,'|'))) { 00084 *to = '\0'; 00085 to++; 00086 timeout = atoi(to); 00087 } 00088 00089 if(timeout <= 0) 00090 timeout = 250; 00091 00092 res = ast_dtmf_stream(chan,NULL,digits,timeout); 00093 00094 LOCAL_USER_REMOVE(u); 00095 00096 return res; 00097 }
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 126 of file app_senddtmf.c.
References ast_manager_unregister(), ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00127 { 00128 int res; 00129 00130 res = ast_unregister_application(app); 00131 res |= ast_manager_unregister("playDTMF"); 00132 00133 STANDARD_HANGUP_LOCALUSERS; 00134 00135 return res; 00136 }
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 149 of file app_senddtmf.c.
References STANDARD_USECOUNT.
00150 { 00151 int res; 00152 STANDARD_USECOUNT(res); 00153 return res; 00154 }
char* app = "SendDTMF" [static] |
Definition at line 48 of file app_senddtmf.c.
char* descrip [static] |
Initial value:
" SendDTMF(digits[|timeout_ms]): Sends DTMF digits on a channel. \n" " Accepted digits: 0-9, *#abcd, w (.5s pause)\n" " The application will either pass the assigned digits or terminate if it\n" " encounters an error.\n"
Definition at line 52 of file app_senddtmf.c.
Definition at line 60 of file app_senddtmf.c.
char mandescr_playdtmf[] [static] |
Initial value:
"Description: Plays a DTMF digit on the specified channel.\n" "Variables: (all are required)\n" "Channel: Channel name to send digit to\n" "Digit: The dtmf digit to play\n"
Definition at line 99 of file app_senddtmf.c.
Definition at line 58 of file app_senddtmf.c.
char* synopsis = "Sends arbitrary DTMF digits" [static] |
Definition at line 50 of file app_senddtmf.c.
char* tdesc = "Send DTMF digits Application" [static] |
Definition at line 46 of file app_senddtmf.c.