From ce47d41510edcdf1f7d36852350df02afc5f6014 Mon Sep 17 00:00:00 2001 From: mmichelson Date: Mon, 1 Jun 2009 20:57:31 +0000 Subject: Add the ability to execute connected line interception macros. When connected line updates are received or generated in the middle of an application call, it is now possible to execute a macro to manipulate the connected line data. This way, phone numbers may be manipulated to be more presentable to users, names may be changed for...whatever reason, or whatever else needs to be done may be. Review: https://reviewboard.asterisk.org/r/256 AST-165 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@198727 f38db490-d61c-443f-a65b-d21fe96a405b --- main/app.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'main/app.c') diff --git a/main/app.c b/main/app.c index 72af3e085..eacefabd0 100644 --- a/main/app.c +++ b/main/app.c @@ -203,6 +203,28 @@ int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int return res; } +int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char * const macro_name, const char * const macro_args) +{ + struct ast_app *macro_app; + int res; + char buf[1024]; + + macro_app = pbx_findapp("Macro"); + if (!macro_app) { + ast_log(LOG_WARNING, "Cannot run macro '%s' because the 'Macro' application in not available\n", macro_name); + return -1; + } + snprintf(buf, sizeof(buf), "%s%s%s", macro_name, ast_strlen_zero(macro_args) ? "" : ",", S_OR(macro_args, "")); + if (autoservice_chan) { + ast_autoservice_start(autoservice_chan); + } + res = pbx_exec(macro_chan, macro_app, buf); + if (autoservice_chan) { + ast_autoservice_stop(autoservice_chan); + } + return res; +} + static int (*ast_has_voicemail_func)(const char *mailbox, const char *folder) = NULL; static int (*ast_inboxcount_func)(const char *mailbox, int *newmsgs, int *oldmsgs) = NULL; static int (*ast_inboxcount2_func)(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs) = NULL; -- cgit v1.2.3