mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-21 09:10:36 +00:00
fix dial a channel on chanspy
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5309 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -81,6 +81,7 @@ struct chanspy_translation_helper {
|
|||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
static struct ast_channel *local_get_channel_by_name(char *name);
|
static struct ast_channel *local_get_channel_by_name(char *name);
|
||||||
|
static struct ast_channel *local_get_channel_begin_name(char *name);
|
||||||
static struct ast_channel *local_channel_walk(struct ast_channel *chan);
|
static struct ast_channel *local_channel_walk(struct ast_channel *chan);
|
||||||
static void spy_release(struct ast_channel *chan, void *data);
|
static void spy_release(struct ast_channel *chan, void *data);
|
||||||
static void *spy_alloc(struct ast_channel *chan, void *params);
|
static void *spy_alloc(struct ast_channel *chan, void *params);
|
||||||
@@ -116,6 +117,24 @@ static struct ast_channel *local_channel_walk(struct ast_channel *chan)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ast_channel *local_get_channel_begin_name(char *name)
|
||||||
|
{
|
||||||
|
struct ast_channel *chan, *ret = NULL;
|
||||||
|
ast_mutex_lock(&modlock);
|
||||||
|
chan = local_channel_walk(NULL);
|
||||||
|
while (chan) {
|
||||||
|
if (!strncmp(chan->name, name, strlen(name))) {
|
||||||
|
ret = chan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chan = local_channel_walk(chan);
|
||||||
|
}
|
||||||
|
ast_mutex_unlock(&modlock);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void spy_release(struct ast_channel *chan, void *data)
|
static void spy_release(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
struct chanspy_translation_helper *csth = data;
|
struct chanspy_translation_helper *csth = data;
|
||||||
@@ -420,7 +439,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
|
|||||||
char *argv[5];
|
char *argv[5];
|
||||||
char *mygroup = NULL;
|
char *mygroup = NULL;
|
||||||
int bronly = 0;
|
int bronly = 0;
|
||||||
|
int chosen = 0;
|
||||||
|
|
||||||
if (!(args = ast_strdupa((char *)data))) {
|
if (!(args = ast_strdupa((char *)data))) {
|
||||||
ast_log(LOG_ERROR, "Out of memory!\n");
|
ast_log(LOG_ERROR, "Out of memory!\n");
|
||||||
@@ -493,9 +512,10 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
|
|||||||
char *group = NULL;
|
char *group = NULL;
|
||||||
int igrp = 1;
|
int igrp = 1;
|
||||||
|
|
||||||
if (peer == prev) {
|
if (peer == prev && !chosen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
chosen = 0;
|
||||||
group = pbx_builtin_getvar_helper(peer, "SPYGROUP");
|
group = pbx_builtin_getvar_helper(peer, "SPYGROUP");
|
||||||
if (mygroup) {
|
if (mygroup) {
|
||||||
if (!group || strcmp(mygroup, group)) {
|
if (!group || strcmp(mygroup, group)) {
|
||||||
@@ -540,17 +560,17 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
|
|||||||
ALL_DONE(u, -1);
|
ALL_DONE(u, -1);
|
||||||
} else if (res > 1 && spec) {
|
} else if (res > 1 && spec) {
|
||||||
snprintf(name, AST_NAME_STRLEN, "%s/%d", spec, res);
|
snprintf(name, AST_NAME_STRLEN, "%s/%d", spec, res);
|
||||||
if (!silent)
|
if ((peer = local_get_channel_begin_name(name))) {
|
||||||
ast_say_digits(chan, res, "", chan->language);
|
chosen = 1;
|
||||||
peer=local_get_channel_by_name(name);
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((peer = local_channel_walk(peer)) == NULL) {
|
||||||
if ((peer = local_channel_walk(peer)) == NULL)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
waitms = count ? 100 : 5000;
|
waitms = count ? 100 : 5000;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user