--- asterisk/channels/chan_agent.c.gjb 2004-06-22 14:48:59.000000000 -0400 +++ asterisk/channels/chan_agent.c 2004-06-28 11:36:31.000000000 -0400 @@ -1,3 +1,4 @@ + /* * Asterisk -- A telephony toolkit for Linux. * @@ -78,6 +79,7 @@ " 'n' - don't generate the warnings when there is no callerid or the agentid is not known. It's handy if you want to have one context for agent and non-agent calls.\n"; static char moh[80] = "default"; +static char preackannounce[80]; /* Pre Acknowledgement Announcement to play */ #define AST_MAX_AGENT 80 /* Agent ID or Password max length */ #define AST_MAX_BUF 256 @@ -88,6 +90,7 @@ static int autologoff; static int wrapuptime; static int ackcall; +static int preack; static int usecnt =0; AST_MUTEX_DEFINE_STATIC(usecnt_lock); @@ -112,6 +115,7 @@ int abouttograb; /* About to grab */ int autologoff; /* Auto timeout time */ int ackcall; /* ackcall */ + int preack; /* If we have a preackannounce file */ time_t loginstart; /* When agent first logged in (0 when logged off) */ time_t start; /* When call started */ struct timeval lastdisc; /* When last disconnected */ @@ -232,6 +236,7 @@ strncpy(p->name, name ? name : "", sizeof(p->name) - 1); strncpy(p->moh, moh, sizeof(p->moh) - 1); p->ackcall = ackcall; + p->preack = preack; p->autologoff = autologoff; p->wrapuptime = wrapuptime; if (pending) @@ -302,7 +307,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast) { - struct agent_pvt *p = ast->pvt->pvt; + int res = -1; + struct agent_pvt *p = ast->pvt->pvt; struct ast_frame *f = NULL; static struct ast_frame null_frame = { AST_FRAME_NULL, }; static struct ast_frame answer_frame = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER }; @@ -329,14 +335,33 @@ } } if (f && (f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_ANSWER)) { + /* TC */ if (p->ackcall) { - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name); + if (p->preack == 1) + { + res = ast_safe_sleep(p->chan, 1000); /* Let the agent get the phone to his ear */ + res = 0; + ast_stopstream(p->chan); + res = ast_streamfile(p->chan, preackannounce, p->chan->language); + if (!res) + res = ast_waitstream(p->chan, ""); + else + { + + ast_verbose(VERBOSE_PREFIX_3 "ast_streamfile failed on %s\n", p->chan->name); + res = 0; + } + ast_stopstream(p->chan); + } + + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name); /* Don't pass answer along */ ast_frfree(f); f = &null_frame; } + else { p->acknowledged = 1; f = &answer_frame; @@ -765,6 +790,7 @@ autologoff = 0; wrapuptime = 0; ackcall = 1; + preack = 0; cfg = ast_load(config); if (!cfg) { ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n"); @@ -800,13 +826,16 @@ if (!strcasecmp(v->value, "always")) ackcall = 2; else if (ast_true(v->value)) - ackcall = 1; + ackcall = 1; else ackcall = 0; } else if (!strcasecmp(v->name, "wrapuptime")) { wrapuptime = atoi(v->value); if (wrapuptime < 0) wrapuptime = 0; + } else if (!strcasecmp(v->name, "preackannounce")) { + strncpy(preackannounce, v->value, sizeof(preackannounce) - 1); + preack = 1; } else if (!strcasecmp(v->name, "musiconhold")) { strncpy(moh, v->value, sizeof(moh) - 1); } else if (!strcasecmp(v->name, "updatecdr")) {