--- apps/app_queue.c 30 Jul 2004 20:38:45 -0000 1.82 +++ apps/app_queue.c 2 Aug 2004 23:05:35 -0000 @@ -759,6 +759,71 @@ *allowdisconnect_out = o->allowdisconnect_out; } } else if (o->chan && (o->chan == winner)) { + if (!ast_strlen_zero(o->chan->call_forward)) { + char tmpchan[256]=""; + char *stuff; + char *tech; + strncpy(tmpchan, o->chan->call_forward, sizeof(tmpchan) - 1); + if ((stuff = strchr(tmpchan, '/'))) { + *stuff = '\0'; + stuff++; + tech = tmpchan; + } else { + snprintf(tmpchan, sizeof(tmpchan), "%s@%s", o->chan->call_forward, o->chan->context); + stuff = tmpchan; + tech = "Local"; + } + /* Before processing channel, go ahead and check for forwarding */ + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name); + /* Setup parameters */ + o->chan = ast_request(tech, in->nativeformats, stuff); + if (!o->chan) { + ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s'\n", tech, stuff); + o->stillgoing = 0; + numbusies++; + } else { + o->chan->subchannel = 1; + + if (o->chan->callerid) + free(o->chan->callerid); + + o->chan->callerid = NULL; + + if (in->callerid) + o->chan->callerid = strdup(in->callerid); + if (!o->chan->callerid) + ast_log(LOG_WARNING, "Out of memory\n"); + strncpy(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode) - 1); + o->chan->cdrflags = in->cdrflags; + + if (in->ani) { + if (o->chan->ani) + free(o->chan->ani); + o->chan->ani = malloc(strlen(in->ani) + 1); + if (o->chan->ani) + strncpy(o->chan->ani, in->ani, strlen(in->ani)); + else + ast_log(LOG_WARNING, "Out of memory\n"); + } + if (o->chan->rdnis) + free(o->chan->rdnis); + if (!ast_strlen_zero(in->macroexten)) + o->chan->rdnis = strdup(in->macroexten); + else + o->chan->rdnis = strdup(in->exten); + if (ast_call(o->chan, tmpchan, 0)) { + ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan); + o->stillgoing = 0; + ast_hangup(o->chan); + o->chan = NULL; + numbusies++; + } + } + /* Hangup the original channel now, in case we needed it */ + ast_hangup(winner); + continue; + } f = ast_read(winner); if (f) { if (f->frametype == AST_FRAME_CONTROL) {