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/config.h>
#include <asterisk/app.h> #include <asterisk/app.h>
#include <asterisk/options.h> #include <asterisk/options.h>
#include <asterisk/utils.h>
#include <asterisk/cli.h> #include <asterisk/cli.h>
#include <asterisk/say.h> #include <asterisk/say.h>
#include <stdlib.h> #include <stdlib.h>
@@ -47,9 +48,9 @@ static char *app = "ZapScan";
static char *synopsis = "Scan Zap channels to monitor calls"; static char *synopsis = "Scan Zap channels to monitor calls";
static char *descrip = static char *descrip =
" ZapScan allows a call center manager to monitor Zap channels in\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"; "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; STANDARD_LOCAL_USER;
@@ -284,16 +285,23 @@ static int conf_exec(struct ast_channel *chan, void *data)
struct localuser *u; struct localuser *u;
int confflags = 0; int confflags = 0;
int confno = 0; int confno = 0;
char confstr[80] = "", *tmp; char confstr[80] = "", *tmp = NULL;
struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL; struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL;
struct ast_frame *f; struct ast_frame *f;
int input=0; char *mygroup;
char *desired_group;
int input=0,search_group=0;
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
if (chan->_state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
ast_answer(chan); 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 (;;) { for (;;) {
if (ast_waitfor(chan, 100) < 0) if (ast_waitfor(chan, 100) < 0)
break; break;
@@ -314,9 +322,18 @@ static int conf_exec(struct ast_channel *chan, void *data)
tempchan = ichan ? ichan : ast_channel_walk_locked(tempchan); tempchan = ichan ? ichan : ast_channel_walk_locked(tempchan);
if ( !tempchan && !lastchan ) if ( !tempchan && !lastchan )
break; 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) ) { 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); ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name);
strncpy(confstr, tempchan->name, sizeof(confstr) - 1); strncpy(confstr, tempchan->name, sizeof(confstr) - 1);