mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Add CALLERPRES dialplan function and deprecate SetCallerPres application
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@53141 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -68,9 +68,14 @@ static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
struct ast_module_user *u;
|
struct ast_module_user *u;
|
||||||
int pres = -1;
|
int pres = -1;
|
||||||
|
static int deprecated = 0;
|
||||||
|
|
||||||
u = ast_module_user_add(chan);
|
u = ast_module_user_add(chan);
|
||||||
|
|
||||||
|
if (!deprecated) {
|
||||||
|
deprecated = 1;
|
||||||
|
ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
|
||||||
|
}
|
||||||
pres = ast_parse_caller_presentation(data);
|
pres = ast_parse_caller_presentation(data);
|
||||||
|
|
||||||
if (pres < 0) {
|
if (pres < 0) {
|
||||||
|
@@ -39,6 +39,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/options.h"
|
#include "asterisk/options.h"
|
||||||
#include "asterisk/callerid.h"
|
#include "asterisk/callerid.h"
|
||||||
|
|
||||||
|
static int callerpres_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int callerpres_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
|
||||||
|
{
|
||||||
|
int pres = ast_parse_caller_presentation(value);
|
||||||
|
if (pres < 0)
|
||||||
|
ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show function CALLERPRES')\n", value);
|
||||||
|
else
|
||||||
|
chan->cid.cid_pres = pres;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
|
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
|
||||||
char *buf, size_t len)
|
char *buf, size_t len)
|
||||||
{
|
{
|
||||||
@@ -173,14 +189,38 @@ static struct ast_custom_function callerid_function = {
|
|||||||
.write = callerid_write,
|
.write = callerid_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static struct ast_custom_function callerpres_function = {
|
||||||
|
.name = "CALLERPRES",
|
||||||
|
.synopsis = "Gets or sets Caller*ID presentation on the channel.",
|
||||||
|
.syntax = "CALLERPRES()",
|
||||||
|
.desc =
|
||||||
|
"Gets or sets Caller*ID presentation on the channel. The following values\n"
|
||||||
|
"are valid:\n"
|
||||||
|
" allowed_not_screened : Presentation Allowed, Not Screened\n"
|
||||||
|
" allowed_passed_screen : Presentation Allowed, Passed Screen\n"
|
||||||
|
" allowed_failed_screen : Presentation Allowed, Failed Screen\n"
|
||||||
|
" allowed : Presentation Allowed, Network Number\n"
|
||||||
|
" prohib_not_screened : Presentation Prohibited, Not Screened\n"
|
||||||
|
" prohib_passed_screen : Presentation Prohibited, Passed Screen\n"
|
||||||
|
" prohib_failed_screen : Presentation Prohibited, Failed Screen\n"
|
||||||
|
" prohib : Presentation Prohibited, Network Number\n"
|
||||||
|
" unavailable : Number Unavailable\n",
|
||||||
|
.read = callerpres_read,
|
||||||
|
.write = callerpres_write,
|
||||||
|
};
|
||||||
|
|
||||||
static int unload_module(void)
|
static int unload_module(void)
|
||||||
{
|
{
|
||||||
return ast_custom_function_unregister(&callerid_function);
|
int res = ast_custom_function_unregister(&callerpres_function);
|
||||||
|
res |= ast_custom_function_unregister(&callerid_function);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_module(void)
|
static int load_module(void)
|
||||||
{
|
{
|
||||||
return ast_custom_function_register(&callerid_function);
|
int res = ast_custom_function_register(&callerpres_function);
|
||||||
|
res |= ast_custom_function_register(&callerid_function);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Caller ID related dialplan function");
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Caller ID related dialplan functions");
|
||||||
|
Reference in New Issue
Block a user