--- app_zapbarge.c 2003-02-12 08:59:14.000000000 -0500 +++ app_zapscan.c 2003-09-11 14:18:59.000000000 -0400 @@ -1,10 +1,12 @@ /* * Asterisk -- A telephony toolkit for Linux. * - * Zap Barge support + * Zap Scanner * * Copyright (C) 2003, Digium * + * Modified from app_zapbarge by David Troy + * * Mark Spencer * * This program is free software, distributed under the terms of @@ -34,17 +36,15 @@ #include #include -static char *tdesc = "Barge in on Zap channel application"; +static char *tdesc = "Scan Zap channels application"; -static char *app = "ZapBarge"; +static char *app = "ZapScan"; -static char *synopsis = "Barge in (monitor) Zap channel"; +static char *synopsis = "Scan Zap channels to monitor calls"; static char *descrip = -" ZapBarge([channel]): Barges in on a specified zap\n" -"channel or prompts if one is not specified. Returns\n" -"-1 when caller user hangs up and is independent of the\n" -"state of the channel being monitored."; +" ZapScan allows a call center manager to monitor\n" +"phone conversations in a convenient way."; STANDARD_LOCAL_USER; @@ -244,16 +245,11 @@ int retrycnt = 0; int confflags = 0; int confno = 0; - char confstr[80]; + char confstr[80], *tmp; + struct ast_channel *tempchan = NULL, *lastchan = NULL; - if (data && strlen(data)) { - if ((sscanf(data, "Zap/%d", &confno) != 1) && - (sscanf(data, "%d", &confno) != 1)) { - ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data); - return 0; - } - } LOCAL_USER_ADD(u); + if (chan->_state != AST_STATE_UP) ast_answer(chan); @@ -257,21 +253,24 @@ if (chan->_state != AST_STATE_UP) ast_answer(chan); - while(!confno && (++retrycnt < 4)) { - /* Prompt user for conference number */ - strcpy(confstr, ""); - res = ast_app_getdata(chan, "conf-getchannel",confstr, sizeof(confstr) - 1, 0); - if (res <0) goto out; - if (sscanf(confstr, "%d", &confno) != 1) - confno = 0; - } - if (confno) { - /* XXX Should prompt user for pin if pin is required XXX */ - /* Run the conference */ + for (;;) { + tempchan = ast_channel_walk(tempchan); + if ( !tempchan && !lastchan ) + break; + if ( tempchan && (!strcmp(tempchan->type, "Zap")) ) { + ast_verbose(VERBOSE_PREFIX_3 "Zap channel %s is in-use, monitoring...\n", tempchan->name); + strcpy(confstr, tempchan->name); + if (tmp = strchr(confstr,'-')) + *tmp = '\0'; + confno = atoi(strchr(confstr,'/') + 1); + ast_stopstream(chan); + ast_say_number(chan, confno, AST_DIGIT_ANY, chan->language); res = conf_run(chan, confno, confflags); + if (res<0) break; } -out: - /* Do the conference */ + lastchan = tempchan; + } + LOCAL_USER_REMOVE(u); return res; }