Index: apps/app_dial.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_dial.c,v retrieving revision 1.63 diff -u -r1.63 app_dial.c --- apps/app_dial.c 27 Apr 2004 16:42:43 -0000 1.63 +++ apps/app_dial.c 2 May 2004 01:49:42 -0000 @@ -116,12 +116,11 @@ #define MAX 256 -static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect) +static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, int *sentringing) { struct localuser *o; int found; int numlines; - int sentringing = 0; int numbusies = 0; int orig = *to; struct ast_frame *f; @@ -129,8 +128,6 @@ struct ast_channel *watchers[MAX]; int pos; int single; - int moh=0; - int ringind=0; struct ast_channel *winner; single = (outgoing && !outgoing->next && !outgoing->musiconhold && !outgoing->ringbackonly); @@ -142,16 +139,6 @@ ast_channel_make_compatible(outgoing->chan, in); } - if (outgoing) { - moh = outgoing->musiconhold; - ringind = outgoing->ringbackonly; - if (outgoing->musiconhold) { - ast_moh_start(in, NULL); - } else if (outgoing->ringbackonly) { - ast_indicate(in, AST_CONTROL_RINGING); - sentringing++; - } - } while(*to && !peer) { o = outgoing; @@ -180,12 +167,6 @@ ast_verbose( VERBOSE_PREFIX_2 "No one is available to answer at this time\n"); } *to = 0; - /* if no one available we'd better stop MOH/ringing to */ - if (moh) { - ast_moh_stop(in); - } else if (sentringing) { - ast_indicate(in, -1); - } return NULL; } winner = ast_waitfor_n(watchers, pos, to); @@ -289,9 +270,9 @@ case AST_CONTROL_RINGING: if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "%s is ringing\n", o->chan->name); - if (!sentringing && !moh) { + if (!*sentringing && !outgoing->musiconhold) { ast_indicate(in, AST_CONTROL_RINGING); - sentringing++; + *sentringing++; } break; case AST_CONTROL_PROGRESS: @@ -303,11 +284,11 @@ /* Ignore going off hook */ break; case -1: - if (!ringind && !moh) { + if (!outgoing->ringbackonly && !outgoing->musiconhold) { if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", o->chan->name); ast_indicate(in, -1); - sentringing = 0; + *sentringing = 0; } break; default: @@ -361,11 +342,6 @@ if (!*to && (option_verbose > 2)) ast_verbose( VERBOSE_PREFIX_3 "Nobody picked up in %d ms\n", orig); } - if (moh) { - ast_moh_stop(in); - } else if (sentringing) { - ast_indicate(in, -1); - } return peer; @@ -411,7 +387,7 @@ char limitdata[256]; char *stack,*var; int play_to_caller=0,play_to_callee=0; - int playargs=0; + int playargs=0,sentringing=0,moh=0; if (!data) { ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n"); @@ -776,7 +752,17 @@ ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", timeout); } else to = -1; - peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect); + + if (outgoing->musiconhold) { + moh=1; + ast_moh_start(chan, NULL); + } else if (outgoing->ringbackonly) { + ast_indicate(chan, AST_CONTROL_RINGING); + sentringing++; + } + + peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, &sentringing); + if (!peer) { if (to) /* Musta gotten hung up */ @@ -842,18 +828,31 @@ config.warning_sound = warning_sound; config.end_sound = end_sound; config.start_sound = start_sound; + + if (moh) { + ast_moh_stop(chan); + } else if (sentringing) { + ast_indicate(chan, -1); + } + res = ast_bridge_call(chan,peer,&config); if (res != AST_PBX_NO_HANGUP_PEER) ast_hangup(peer); } out: + if (moh) { + ast_moh_stop(chan); + } else if (sentringing) { + ast_indicate(chan, -1); + } + hanguptree(outgoing, NULL); LOCAL_USER_REMOVE(u); if((go_on>0) && (!chan->_softhangup)) res=0; - + return res; }