mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
- mark some applications deprecated that already have replacements
- add BLACKLIST and mark LookupBlacklist deprecated - add transfercapability support to CHANNEL and mark SetTransferCapability deprecated (issue #7225, Corydon) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@30359 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -65,6 +65,32 @@ static char *descrip =
|
|||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
|
static int blacklist_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
|
||||||
|
{
|
||||||
|
char blacklist[1];
|
||||||
|
int bl = 0;
|
||||||
|
|
||||||
|
if (chan->cid.cid_num) {
|
||||||
|
if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
|
||||||
|
bl = 1;
|
||||||
|
}
|
||||||
|
if (chan->cid.cid_name) {
|
||||||
|
if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
|
||||||
|
bl = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(buf, len, "%d", bl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ast_custom_function blacklist_function = {
|
||||||
|
.name = "BLACKLIST",
|
||||||
|
.synopsis = "Check if the callerid is on the blacklist",
|
||||||
|
.desc = "Uses astdb to check if the Caller*ID is in family 'blacklist'. Returns 1 or 0.\n",
|
||||||
|
.syntax = "BLACKLIST()",
|
||||||
|
.read = blacklist_read,
|
||||||
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
lookupblacklist_exec (struct ast_channel *chan, void *data)
|
lookupblacklist_exec (struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
@@ -72,9 +98,15 @@ lookupblacklist_exec (struct ast_channel *chan, void *data)
|
|||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
int bl = 0;
|
int bl = 0;
|
||||||
int priority_jump = 0;
|
int priority_jump = 0;
|
||||||
|
static int dep_warning = 0;
|
||||||
|
|
||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
|
if (!dep_warning) {
|
||||||
|
dep_warning = 1;
|
||||||
|
ast_log(LOG_WARNING, "LookupBlacklist is deprecated. Please use ${BLACKLIST()} instead.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (!ast_strlen_zero(data)) {
|
if (!ast_strlen_zero(data)) {
|
||||||
if (strchr(data, 'j'))
|
if (strchr(data, 'j'))
|
||||||
priority_jump = 1;
|
priority_jump = 1;
|
||||||
@@ -112,6 +144,7 @@ static int unload_module(void *mod)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = ast_unregister_application(app);
|
res = ast_unregister_application(app);
|
||||||
|
res |= ast_custom_function_unregister(&blacklist_function);
|
||||||
|
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
|
|
||||||
@@ -120,7 +153,9 @@ static int unload_module(void *mod)
|
|||||||
|
|
||||||
static int load_module(void *mod)
|
static int load_module(void *mod)
|
||||||
{
|
{
|
||||||
return ast_register_application (app, lookupblacklist_exec, synopsis,descrip);
|
int res = ast_custom_function_register(&blacklist_function);
|
||||||
|
res |= ast_register_application (app, lookupblacklist_exec, synopsis,descrip);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *description(void)
|
static const char *description(void)
|
||||||
|
@@ -66,8 +66,13 @@ lookupcidname_exec (struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
char dbname[64];
|
char dbname[64];
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
|
static int dep_warning = 0;
|
||||||
|
|
||||||
LOCAL_USER_ADD (u);
|
LOCAL_USER_ADD (u);
|
||||||
|
if (!dep_warning) {
|
||||||
|
dep_warning = 1;
|
||||||
|
ast_log(LOG_WARNING, "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})} instead.\n");
|
||||||
|
}
|
||||||
if (chan->cid.cid_num) {
|
if (chan->cid.cid_num) {
|
||||||
if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
|
if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
|
||||||
ast_set_callerid (chan, NULL, dbname, NULL);
|
ast_set_callerid (chan, NULL, dbname, NULL);
|
||||||
|
@@ -109,6 +109,7 @@ static int setcdruserfield_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
static int dep_warning = 0;
|
||||||
|
|
||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
@@ -116,6 +117,11 @@ static int setcdruserfield_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_cdr_setuserfield(chan, (char*)data);
|
ast_cdr_setuserfield(chan, (char*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dep_warning) {
|
||||||
|
dep_warning = 1;
|
||||||
|
ast_log(LOG_WARNING, "SetCDRUserField is deprecated. Please use CDR(userfield) instead.\n");
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -125,6 +131,7 @@ static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
static int dep_warning = 0;
|
||||||
|
|
||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
@@ -132,6 +139,11 @@ static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_cdr_appenduserfield(chan, (char*)data);
|
ast_cdr_appenduserfield(chan, (char*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dep_warning) {
|
||||||
|
dep_warning = 1;
|
||||||
|
ast_log(LOG_WARNING, "AppendCDRUserField is deprecated. Please use CDR(userfield) instead.\n");
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@@ -76,9 +76,15 @@ static int settransfercapability_exec(struct ast_channel *chan, void *data)
|
|||||||
int x;
|
int x;
|
||||||
char *opts;
|
char *opts;
|
||||||
int transfercapability = -1;
|
int transfercapability = -1;
|
||||||
|
static int dep_warning = 0;
|
||||||
|
|
||||||
LOCAL_USER_ADD(u);
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
|
if (!dep_warning) {
|
||||||
|
dep_warning = 1;
|
||||||
|
ast_log(LOG_WARNING, "SetTransferCapability is deprecated. Please use CHANNEL(transfercapability) instead.\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
tmp = ast_strdupa(data);
|
tmp = ast_strdupa(data);
|
||||||
else
|
else
|
||||||
|
@@ -51,6 +51,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
ast_channel_unlock(chan); \
|
ast_channel_unlock(chan); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
char *transfercapability_table[0x20] = {
|
||||||
|
"SPEECH", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
|
||||||
|
"DIGITAL", "RESTRICTED_DIGITAL", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
|
||||||
|
"3K1AUDIO", "DIGITAL_W_TONES", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK",
|
||||||
|
"VIDEO", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", "UNK", };
|
||||||
|
|
||||||
static int func_channel_read(struct ast_channel *chan, char *function,
|
static int func_channel_read(struct ast_channel *chan, char *function,
|
||||||
char *data, char *buf, size_t len)
|
char *data, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
@@ -78,6 +84,8 @@ static int func_channel_read(struct ast_channel *chan, char *function,
|
|||||||
locked_copy_string(chan, buf, ast_state2str(chan->_state), len);
|
locked_copy_string(chan, buf, ast_state2str(chan->_state), len);
|
||||||
else if (!strcasecmp(data, "channeltype"))
|
else if (!strcasecmp(data, "channeltype"))
|
||||||
locked_copy_string(chan, buf, chan->tech->type, len);
|
locked_copy_string(chan, buf, chan->tech->type, len);
|
||||||
|
else if (!strcasecmp(data, "transfercapability"))
|
||||||
|
locked_copy_string(chan, buf, transfercapability_table[chan->transfercapability & 0x1f], len);
|
||||||
else if (!strcasecmp(data, "callgroup")) {
|
else if (!strcasecmp(data, "callgroup")) {
|
||||||
char groupbuf[256];
|
char groupbuf[256];
|
||||||
locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
|
locked_copy_string(chan, buf, ast_print_group(groupbuf, sizeof(groupbuf), chan->callgroup), len);
|
||||||
@@ -107,7 +115,15 @@ static int func_channel_write(struct ast_channel *chan, char *function,
|
|||||||
ast_channel_setoption(chan, AST_OPTION_TXGAIN, &gainset, sizeof(gainset), 0);
|
ast_channel_setoption(chan, AST_OPTION_TXGAIN, &gainset, sizeof(gainset), 0);
|
||||||
} else if (!strcasecmp(data, "rxgain")) {
|
} else if (!strcasecmp(data, "rxgain")) {
|
||||||
sscanf(value, "%hhd", &gainset);
|
sscanf(value, "%hhd", &gainset);
|
||||||
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &gainset, sizeof(gainset), 0);
|
ast_channel_setoption(chan, AST_OPTION_RXGAIN, &gainset, sizeof(gainset), 0);
|
||||||
|
} else if (!strcasecmp(data, "transfercapability")) {
|
||||||
|
unsigned short i;
|
||||||
|
for (i = 0; i < 0x20; i++) {
|
||||||
|
if (!strcasecmp(transfercapability_table[i], value) && strcmp(value, "UNK")) {
|
||||||
|
chan->transfercapability = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (!chan->tech->func_channel_write
|
} else if (!chan->tech->func_channel_write
|
||||||
|| chan->tech->func_channel_write(chan, function, data, value)) {
|
|| chan->tech->func_channel_write(chan, function, data, value)) {
|
||||||
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",
|
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",
|
||||||
|
Reference in New Issue
Block a user