Update a couple places to use the new ast_channel_search_locked API call.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@154923 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.2
Sean Bright 17 years ago
parent 81fb7597e5
commit 6ac794074e

@ -172,42 +172,46 @@ static int pickup_by_channel(struct ast_channel *chan, char *pickup)
/* Attempt to pick up specified extension with context */ /* Attempt to pick up specified extension with context */
static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context) static int pickup_by_exten(struct ast_channel *chan, const char *exten, const char *context)
{ {
int res = -1; auto int find_by_exten(struct ast_channel *c);
struct ast_channel *target = NULL; int find_by_exten(struct ast_channel *c) {
return (!strcasecmp(c->macroexten, exten) || !strcasecmp(c->exten, exten)) &&
while ((target = ast_channel_walk_locked(target))) { !strcasecmp(c->dialcontext, context) &&
if ((!strcasecmp(target->macroexten, exten) || !strcasecmp(target->exten, exten)) && can_pickup(c);
!strcasecmp(target->dialcontext, context) &&
can_pickup(target)) {
res = pickup_do(chan, target);
ast_channel_unlock(target);
break;
} }
struct ast_channel *target = ast_channel_search_locked(find_by_exten);
if (target) {
int res = pickup_do(chan, target);
ast_channel_unlock(target); ast_channel_unlock(target);
target = NULL;
return res;
} }
return res; return -1;
} }
/* Attempt to pick up specified mark */ /* Attempt to pick up specified mark */
static int pickup_by_mark(struct ast_channel *chan, const char *mark) static int pickup_by_mark(struct ast_channel *chan, const char *mark)
{ {
int res = -1; auto int find_by_mark(struct ast_channel *);
const char *tmp = NULL; int find_by_mark(struct ast_channel *c) {
struct ast_channel *target = NULL; const char *tmp;
return (tmp = pbx_builtin_getvar_helper(c, PICKUPMARK)) &&
while ((target = ast_channel_walk_locked(target))) {
if ((tmp = pbx_builtin_getvar_helper(target, PICKUPMARK)) &&
!strcasecmp(tmp, mark) && !strcasecmp(tmp, mark) &&
can_pickup(target)) { can_pickup(c);
res = pickup_do(chan, target);
ast_channel_unlock(target);
break;
} }
struct ast_channel *target = ast_channel_search_locked(find_by_mark);
if (target) {
int res = pickup_do(chan, target);
ast_channel_unlock(target); ast_channel_unlock(target);
target = NULL;
return res;
} }
return res; return -1;
} }
/* application entry point for Pickup() */ /* application entry point for Pickup() */

@ -3997,20 +3997,18 @@ static int manager_park(struct mansession *s, const struct message *m)
*/ */
int ast_pickup_call(struct ast_channel *chan) int ast_pickup_call(struct ast_channel *chan)
{ {
struct ast_channel *cur = NULL; auto int find_channel_by_group(struct ast_channel *);
int res = -1; int find_channel_by_group(struct ast_channel *c) {
return !c->pbx &&
while ((cur = ast_channel_walk_locked(cur)) != NULL) { (c != chan) &&
if (!cur->pbx && (chan->pickupgroup & c->callgroup) &&
(cur != chan) && ((c->_state == AST_STATE_RINGING) ||
(chan->pickupgroup & cur->callgroup) && (c->_state == AST_STATE_RING));
((cur->_state == AST_STATE_RINGING) ||
(cur->_state == AST_STATE_RING))) {
break;
}
ast_channel_unlock(cur);
} }
struct ast_channel *cur = ast_channel_search_locked(find_channel_by_group);
if (cur) { if (cur) {
int res = -1;
ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name); ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
res = ast_answer(chan); res = ast_answer(chan);
if (res) if (res)
@ -4022,10 +4020,11 @@ int ast_pickup_call(struct ast_channel *chan)
if (res) if (res)
ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */ ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */
ast_channel_unlock(cur); ast_channel_unlock(cur);
return res;
} else { } else {
ast_debug(1, "No call pickup possible...\n"); ast_debug(1, "No call pickup possible...\n");
} }
return res; return -1;
} }
static char *app_bridge = "Bridge"; static char *app_bridge = "Bridge";

Loading…
Cancel
Save