The winner of the $50 bounty is... ME! I wrote the code myself. Maybe I had too much coffee, but once I got into it, I couldn't stop. All told it was about 2 hours of me scratching my head and trying to remember C programming basics from 10 years ago that hasn't been touched in so long that it has cobwebs on it.
I've updated the patch to add support for custom preackannounce messages, configureable in the agents.conf file. The latest patch can be downloaded from: http://www.nacs.net/~damin/agent-preack-announce.patch To use it you will need to do the following: 1. Download the patch and stick in in /usr/src/asterisk 2. Apply the patch; [EMAIL PROTECTED] cd /usr/src/asterisk [EMAIL PROTECTED] asterisk]# patch -p1 < agent-preack-announce.patch patching file channels/chan_agent.c 3. Issue a "make install" to rebuild chan_agent.so (or just "make" and copy channels/chan_aget.so to /usr/lib/asterisk/modules) 4. Add a "preackannounce=filename" (do NOT add the .gsm extension) to your agents.config file Example: [agents] preackannounce=all-your-base agent => 102,1,Xlite Soft Phone Works for me so far. Comments appreciated. This is a hack, to be sure, but it works for my needs right now. --- asterisk/channels/chan_agent.c.gjb 2004-02-21 13:55:35.000000000 -0500 +++ asterisk/channels/chan_agent.c 2004-02-22 19:47:25.000000000 -0500 @@ -70,6 +70,7 @@ "context. \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 @@ -80,6 +81,7 @@ static int autologoff; static int wrapuptime; static int ackcall; +static int preack; static int usecnt =0; static ast_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER; @@ -101,7 +103,8 @@ int abouttograb; /* About to grab */ int autologoff; /* Auto timeout time */ int ackcall; /* ackcall */ - time_t start; /* When call started */ + int preack; /* If we have a preackannounce file */ + time_t start; /* When call started */ struct timeval lastdisc; /* When last disconnected */ int wrapuptime; /* Wrapup time in ms */ unsigned int group; /* Group memberships */ @@ -220,6 +223,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) @@ -281,7 +285,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 }; @@ -308,14 +313,32 @@ } } 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) + { + + 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; @@ -730,6 +753,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"); @@ -765,13 +789,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, "recordagentcalls")) { -- Vice President of N2Net, a New Age Consulting Service, Inc. Company http://www.n2net.net Where everything clicks into place! KP-216-121-ST _______________________________________________ Asterisk-Dev mailing list [EMAIL PROTECTED] http://lists.digium.com/mailman/listinfo/asterisk-dev To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev
