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