Allow zapscan to operate on a group (bug #2927)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4509 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-12-21 01:21:12 +00:00
parent f4d1002166
commit 217bc41c7b

View File

@@ -25,6 +25,7 @@
#include <asterisk/config.h>
#include <asterisk/app.h>
#include <asterisk/options.h>
#include <asterisk/utils.h>
#include <asterisk/cli.h>
#include <asterisk/say.h>
#include <stdlib.h>
@@ -47,9 +48,9 @@ static char *app = "ZapScan";
static char *synopsis = "Scan Zap channels to monitor calls";
static char *descrip =
" ZapScan allows a call center manager to monitor Zap channels in\n"
"a convenient way. Use '#' to select the next channel and use '*' to exit\n";
" ZapScan([group]) allows a call center manager to monitor Zap channels in\n"
"a convenient way. Use '#' to select the next channel and use '*' to exit\n"
"Limit scanning to a channel GROUP by setting the option group argument.\n";
STANDARD_LOCAL_USER;
@@ -127,7 +128,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
}
ast_indicate(chan, -1);
retryzap = strcasecmp(chan->type, "Zap");
zapretry:
zapretry:
origfd = chan->fds[0];
if (retryzap) {
fd = open("/dev/zap/pseudo", O_RDWR);
@@ -273,7 +274,7 @@ zapretry:
}
}
outrun:
outrun:
return ret;
}
@@ -284,16 +285,23 @@ static int conf_exec(struct ast_channel *chan, void *data)
struct localuser *u;
int confflags = 0;
int confno = 0;
char confstr[80] = "", *tmp;
char confstr[80] = "", *tmp = NULL;
struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL;
struct ast_frame *f;
int input=0;
char *mygroup;
char *desired_group;
int input=0,search_group=0;
LOCAL_USER_ADD(u);
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
if((desired_group = ast_strdupa((char *) data)) && !ast_strlen_zero(desired_group)) {
ast_verbose(VERBOSE_PREFIX_3 "Scanning for group %s\n", desired_group);
search_group = 1;
}
for (;;) {
if (ast_waitfor(chan, 100) < 0)
break;
@@ -314,9 +322,18 @@ static int conf_exec(struct ast_channel *chan, void *data)
tempchan = ichan ? ichan : ast_channel_walk_locked(tempchan);
if ( !tempchan && !lastchan )
break;
if (tempchan && search_group) {
if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) {
ast_verbose(VERBOSE_PREFIX_3 "Found Matching Channel %s in group %s\n", tempchan->name, desired_group);
} else {
ast_mutex_unlock(&tempchan->lock);
lastchan = tempchan;
continue;
}
}
if ( tempchan && tempchan->type && (!strcmp(tempchan->type, "Zap")) && (tempchan != chan) ) {
ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name);
strncpy(confstr, tempchan->name, sizeof(confstr) - 1);