mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-17 07:18:15 +00:00
fix indentation of some large blocks after previous changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@21481 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
342
apps/app_dial.c
342
apps/app_dial.c
@@ -434,195 +434,195 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct dial_l
|
|||||||
if (c != winner)
|
if (c != winner)
|
||||||
continue;
|
continue;
|
||||||
if (!ast_strlen_zero(c->call_forward)) {
|
if (!ast_strlen_zero(c->call_forward)) {
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
char *stuff;
|
char *stuff;
|
||||||
char *tech;
|
char *tech;
|
||||||
const char *forward_context;
|
const char *forward_context;
|
||||||
|
|
||||||
ast_copy_string(tmpchan, c->call_forward, sizeof(tmpchan));
|
ast_copy_string(tmpchan, c->call_forward, sizeof(tmpchan));
|
||||||
if ((stuff = strchr(tmpchan, '/'))) {
|
if ((stuff = strchr(tmpchan, '/'))) {
|
||||||
*stuff++ = '\0';
|
*stuff++ = '\0';
|
||||||
tech = tmpchan;
|
tech = tmpchan;
|
||||||
|
} else {
|
||||||
|
forward_context = pbx_builtin_getvar_helper(c, "FORWARD_CONTEXT");
|
||||||
|
snprintf(tmpchan, sizeof(tmpchan), "%s@%s", c->call_forward, forward_context ? forward_context : c->context);
|
||||||
|
stuff = tmpchan;
|
||||||
|
tech = "Local";
|
||||||
|
}
|
||||||
|
/* Before processing channel, go ahead and check for forwarding */
|
||||||
|
o->forwards++;
|
||||||
|
if (o->forwards < AST_MAX_FORWARDS) {
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name);
|
||||||
|
/* Setup parameters */
|
||||||
|
c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
|
||||||
|
if (!c)
|
||||||
|
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
||||||
|
} else {
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", c->name);
|
||||||
|
cause = AST_CAUSE_CONGESTION;
|
||||||
|
c = o->chan = NULL;
|
||||||
|
}
|
||||||
|
if (!c) {
|
||||||
|
ast_clear_flag(o, DIAL_STILLGOING);
|
||||||
|
HANDLE_CAUSE(cause, in);
|
||||||
|
} else {
|
||||||
|
ast_rtp_make_compatible(c, in);
|
||||||
|
if (c->cid.cid_num)
|
||||||
|
free(c->cid.cid_num);
|
||||||
|
c->cid.cid_num = NULL;
|
||||||
|
if (c->cid.cid_name)
|
||||||
|
free(c->cid.cid_name);
|
||||||
|
c->cid.cid_name = NULL;
|
||||||
|
|
||||||
|
if (ast_test_flag(o, OPT_FORCECLID)) {
|
||||||
|
c->cid.cid_num = ast_strdup(S_OR(in->macroexten, in->exten));
|
||||||
|
ast_string_field_set(c, accountcode, winner->accountcode);
|
||||||
|
c->cdrflags = winner->cdrflags;
|
||||||
} else {
|
} else {
|
||||||
forward_context = pbx_builtin_getvar_helper(c, "FORWARD_CONTEXT");
|
c->cid.cid_num = ast_strdup(in->cid.cid_num);
|
||||||
snprintf(tmpchan, sizeof(tmpchan), "%s@%s", c->call_forward, forward_context ? forward_context : c->context);
|
c->cid.cid_name = ast_strdup(in->cid.cid_name);
|
||||||
stuff = tmpchan;
|
ast_string_field_set(c, accountcode, in->accountcode);
|
||||||
tech = "Local";
|
c->cdrflags = in->cdrflags;
|
||||||
}
|
}
|
||||||
/* Before processing channel, go ahead and check for forwarding */
|
|
||||||
o->forwards++;
|
if (in->cid.cid_ani) {
|
||||||
if (o->forwards < AST_MAX_FORWARDS) {
|
if (c->cid.cid_ani)
|
||||||
if (option_verbose > 2)
|
free(c->cid.cid_ani);
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, c->name);
|
c->cid.cid_ani = ast_strdup(in->cid.cid_ani);
|
||||||
/* Setup parameters */
|
|
||||||
c = o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
|
|
||||||
if (!c)
|
|
||||||
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
|
||||||
} else {
|
|
||||||
if (option_verbose > 2)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", c->name);
|
|
||||||
cause = AST_CAUSE_CONGESTION;
|
|
||||||
c = o->chan = NULL;
|
|
||||||
}
|
}
|
||||||
if (!c) {
|
if (c->cid.cid_rdnis)
|
||||||
|
free(c->cid.cid_rdnis);
|
||||||
|
c->cid.cid_rdnis = ast_strdup(S_OR(in->macroexten, in->exten));
|
||||||
|
if (ast_call(c, tmpchan, 0)) {
|
||||||
|
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
|
||||||
ast_clear_flag(o, DIAL_STILLGOING);
|
ast_clear_flag(o, DIAL_STILLGOING);
|
||||||
HANDLE_CAUSE(cause, in);
|
ast_hangup(c);
|
||||||
|
c = o->chan = NULL;
|
||||||
|
numnochan++;
|
||||||
} else {
|
} else {
|
||||||
ast_rtp_make_compatible(c, in);
|
senddialevent(in, c);
|
||||||
if (c->cid.cid_num)
|
/* After calling, set callerid to extension */
|
||||||
free(c->cid.cid_num);
|
if (!ast_test_flag(peerflags, OPT_ORIGINAL_CLID))
|
||||||
c->cid.cid_num = NULL;
|
ast_set_callerid(c, S_OR(in->macroexten, in->exten), get_cid_name(cidname, sizeof(cidname), in), NULL);
|
||||||
if (c->cid.cid_name)
|
|
||||||
free(c->cid.cid_name);
|
|
||||||
c->cid.cid_name = NULL;
|
|
||||||
|
|
||||||
if (ast_test_flag(o, OPT_FORCECLID)) {
|
|
||||||
c->cid.cid_num = ast_strdup(S_OR(in->macroexten, in->exten));
|
|
||||||
ast_string_field_set(c, accountcode, winner->accountcode);
|
|
||||||
c->cdrflags = winner->cdrflags;
|
|
||||||
} else {
|
|
||||||
c->cid.cid_num = ast_strdup(in->cid.cid_num);
|
|
||||||
c->cid.cid_name = ast_strdup(in->cid.cid_name);
|
|
||||||
ast_string_field_set(c, accountcode, in->accountcode);
|
|
||||||
c->cdrflags = in->cdrflags;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in->cid.cid_ani) {
|
|
||||||
if (c->cid.cid_ani)
|
|
||||||
free(c->cid.cid_ani);
|
|
||||||
c->cid.cid_ani = ast_strdup(in->cid.cid_ani);
|
|
||||||
}
|
|
||||||
if (c->cid.cid_rdnis)
|
|
||||||
free(c->cid.cid_rdnis);
|
|
||||||
c->cid.cid_rdnis = ast_strdup(S_OR(in->macroexten, in->exten));
|
|
||||||
if (ast_call(c, tmpchan, 0)) {
|
|
||||||
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
|
|
||||||
ast_clear_flag(o, DIAL_STILLGOING);
|
|
||||||
ast_hangup(c);
|
|
||||||
c = o->chan = NULL;
|
|
||||||
numnochan++;
|
|
||||||
} else {
|
|
||||||
senddialevent(in, c);
|
|
||||||
/* After calling, set callerid to extension */
|
|
||||||
if (!ast_test_flag(peerflags, OPT_ORIGINAL_CLID))
|
|
||||||
ast_set_callerid(c, S_OR(in->macroexten, in->exten), get_cid_name(cidname, sizeof(cidname), in), NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* Hangup the original channel now, in case we needed it */
|
}
|
||||||
ast_hangup(winner);
|
/* Hangup the original channel now, in case we needed it */
|
||||||
continue;
|
ast_hangup(winner);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
f = ast_read(winner);
|
f = ast_read(winner);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
|
in->hangupcause = c->hangupcause;
|
||||||
|
ast_hangup(c);
|
||||||
|
c = o->chan = NULL;
|
||||||
|
ast_clear_flag(o, DIAL_STILLGOING);
|
||||||
|
HANDLE_CAUSE(in->hangupcause, in);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (f->frametype == AST_FRAME_CONTROL) {
|
||||||
|
switch(f->subclass) {
|
||||||
|
case AST_CONTROL_ANSWER:
|
||||||
|
/* This is our guy if someone answered. */
|
||||||
|
if (!peer) {
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", c->name, in->name);
|
||||||
|
peer = c;
|
||||||
|
ast_copy_flags(peerflags, o,
|
||||||
|
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
||||||
|
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
||||||
|
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
||||||
|
DIAL_NOFORWARDHTML);
|
||||||
|
}
|
||||||
|
/* If call has been answered, then the eventual hangup is likely to be normal hangup */
|
||||||
|
in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
|
||||||
|
c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
|
||||||
|
break;
|
||||||
|
case AST_CONTROL_BUSY:
|
||||||
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "%s is busy\n", c->name);
|
||||||
in->hangupcause = c->hangupcause;
|
in->hangupcause = c->hangupcause;
|
||||||
ast_hangup(c);
|
ast_hangup(c);
|
||||||
c = o->chan = NULL;
|
c = o->chan = NULL;
|
||||||
ast_clear_flag(o, DIAL_STILLGOING);
|
ast_clear_flag(o, DIAL_STILLGOING);
|
||||||
HANDLE_CAUSE(in->hangupcause, in);
|
HANDLE_CAUSE(AST_CAUSE_BUSY, in);
|
||||||
continue;
|
break;
|
||||||
}
|
case AST_CONTROL_CONGESTION:
|
||||||
if (f->frametype == AST_FRAME_CONTROL) {
|
if (option_verbose > 2)
|
||||||
switch(f->subclass) {
|
ast_verbose(VERBOSE_PREFIX_3 "%s is circuit-busy\n", c->name);
|
||||||
case AST_CONTROL_ANSWER:
|
in->hangupcause = c->hangupcause;
|
||||||
/* This is our guy if someone answered. */
|
ast_hangup(c);
|
||||||
if (!peer) {
|
c = o->chan = NULL;
|
||||||
if (option_verbose > 2)
|
ast_clear_flag(o, DIAL_STILLGOING);
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", c->name, in->name);
|
HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
|
||||||
peer = c;
|
break;
|
||||||
ast_copy_flags(peerflags, o,
|
case AST_CONTROL_RINGING:
|
||||||
OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |
|
if (option_verbose > 2)
|
||||||
OPT_CALLEE_HANGUP | OPT_CALLER_HANGUP |
|
ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", c->name);
|
||||||
OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR |
|
if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
|
||||||
DIAL_NOFORWARDHTML);
|
ast_indicate(in, AST_CONTROL_RINGING);
|
||||||
}
|
(*sentringing)++;
|
||||||
/* If call has been answered, then the eventual hangup is likely to be normal hangup */
|
}
|
||||||
in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
|
break;
|
||||||
c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
|
case AST_CONTROL_PROGRESS:
|
||||||
break;
|
if (option_verbose > 2)
|
||||||
case AST_CONTROL_BUSY:
|
ast_verbose (VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", c->name, in->name);
|
||||||
if (option_verbose > 2)
|
if (!ast_test_flag(outgoing, OPT_RINGBACK))
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "%s is busy\n", c->name);
|
ast_indicate(in, AST_CONTROL_PROGRESS);
|
||||||
in->hangupcause = c->hangupcause;
|
break;
|
||||||
ast_hangup(c);
|
case AST_CONTROL_VIDUPDATE:
|
||||||
c = o->chan = NULL;
|
if (option_verbose > 2)
|
||||||
ast_clear_flag(o, DIAL_STILLGOING);
|
ast_verbose (VERBOSE_PREFIX_3 "%s requested a video update, passing it to %s\n", c->name, in->name);
|
||||||
HANDLE_CAUSE(AST_CAUSE_BUSY, in);
|
ast_indicate(in, AST_CONTROL_VIDUPDATE);
|
||||||
break;
|
break;
|
||||||
case AST_CONTROL_CONGESTION:
|
case AST_CONTROL_PROCEEDING:
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "%s is circuit-busy\n", c->name);
|
ast_verbose (VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", c->name, in->name);
|
||||||
in->hangupcause = c->hangupcause;
|
if (!ast_test_flag(outgoing, OPT_RINGBACK))
|
||||||
ast_hangup(c);
|
ast_indicate(in, AST_CONTROL_PROCEEDING);
|
||||||
c = o->chan = NULL;
|
break;
|
||||||
ast_clear_flag(o, DIAL_STILLGOING);
|
case AST_CONTROL_HOLD:
|
||||||
HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
|
if (option_verbose > 2)
|
||||||
break;
|
ast_verbose(VERBOSE_PREFIX_3 "Call on %s placed on hold\n", c->name);
|
||||||
case AST_CONTROL_RINGING:
|
ast_indicate(in, AST_CONTROL_HOLD);
|
||||||
if (option_verbose > 2)
|
break;
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", c->name);
|
case AST_CONTROL_UNHOLD:
|
||||||
if (!(*sentringing) && !ast_test_flag(outgoing, OPT_MUSICBACK)) {
|
if (option_verbose > 2)
|
||||||
ast_indicate(in, AST_CONTROL_RINGING);
|
ast_verbose(VERBOSE_PREFIX_3 "Call on %s left from hold\n", c->name);
|
||||||
(*sentringing)++;
|
ast_indicate(in, AST_CONTROL_UNHOLD);
|
||||||
}
|
break;
|
||||||
break;
|
case AST_CONTROL_OFFHOOK:
|
||||||
case AST_CONTROL_PROGRESS:
|
case AST_CONTROL_FLASH:
|
||||||
if (option_verbose > 2)
|
/* Ignore going off hook and flash */
|
||||||
ast_verbose (VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", c->name, in->name);
|
break;
|
||||||
if (!ast_test_flag(outgoing, OPT_RINGBACK))
|
case -1:
|
||||||
ast_indicate(in, AST_CONTROL_PROGRESS);
|
if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_MUSICBACK)) {
|
||||||
break;
|
if (option_verbose > 2)
|
||||||
case AST_CONTROL_VIDUPDATE:
|
ast_verbose(VERBOSE_PREFIX_3 "%s stopped sounds\n", c->name);
|
||||||
if (option_verbose > 2)
|
ast_indicate(in, -1);
|
||||||
ast_verbose (VERBOSE_PREFIX_3 "%s requested a video update, passing it to %s\n", c->name, in->name);
|
(*sentringing) = 0;
|
||||||
ast_indicate(in, AST_CONTROL_VIDUPDATE);
|
}
|
||||||
break;
|
break;
|
||||||
case AST_CONTROL_PROCEEDING:
|
default:
|
||||||
if (option_verbose > 2)
|
if (option_debug)
|
||||||
ast_verbose (VERBOSE_PREFIX_3 "%s is proceeding passing it to %s\n", c->name, in->name);
|
ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
|
||||||
if (!ast_test_flag(outgoing, OPT_RINGBACK))
|
}
|
||||||
ast_indicate(in, AST_CONTROL_PROCEEDING);
|
|
||||||
break;
|
|
||||||
case AST_CONTROL_HOLD:
|
|
||||||
if (option_verbose > 2)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Call on %s placed on hold\n", c->name);
|
|
||||||
ast_indicate(in, AST_CONTROL_HOLD);
|
|
||||||
break;
|
|
||||||
case AST_CONTROL_UNHOLD:
|
|
||||||
if (option_verbose > 2)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Call on %s left from hold\n", c->name);
|
|
||||||
ast_indicate(in, AST_CONTROL_UNHOLD);
|
|
||||||
break;
|
|
||||||
case AST_CONTROL_OFFHOOK:
|
|
||||||
case AST_CONTROL_FLASH:
|
|
||||||
/* Ignore going off hook and flash */
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
if (!ast_test_flag(outgoing, OPT_RINGBACK | OPT_MUSICBACK)) {
|
|
||||||
if (option_verbose > 2)
|
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "%s stopped sounds\n", c->name);
|
|
||||||
ast_indicate(in, -1);
|
|
||||||
(*sentringing) = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (option_debug)
|
|
||||||
ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
|
|
||||||
}
|
|
||||||
} else if (single && (f->frametype == AST_FRAME_VOICE) &&
|
} else if (single && (f->frametype == AST_FRAME_VOICE) &&
|
||||||
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
||||||
if (ast_write(in, f))
|
if (ast_write(in, f))
|
||||||
ast_log(LOG_WARNING, "Unable to forward voice frame\n");
|
ast_log(LOG_WARNING, "Unable to forward voice frame\n");
|
||||||
} else if (single && (f->frametype == AST_FRAME_IMAGE) &&
|
} else if (single && (f->frametype == AST_FRAME_IMAGE) &&
|
||||||
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
||||||
if (ast_write(in, f))
|
if (ast_write(in, f))
|
||||||
ast_log(LOG_WARNING, "Unable to forward image\n");
|
ast_log(LOG_WARNING, "Unable to forward image\n");
|
||||||
} else if (single && (f->frametype == AST_FRAME_TEXT) &&
|
} else if (single && (f->frametype == AST_FRAME_TEXT) &&
|
||||||
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
!(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) {
|
||||||
if (ast_write(in, f))
|
if (ast_write(in, f))
|
||||||
ast_log(LOG_WARNING, "Unable to send text\n");
|
ast_log(LOG_WARNING, "Unable to send text\n");
|
||||||
} else if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag(outgoing, DIAL_NOFORWARDHTML)) {
|
} else if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag(outgoing, DIAL_NOFORWARDHTML)) {
|
||||||
if(ast_channel_sendhtml(in, f->subclass, f->data, f->datalen) == -1)
|
if(ast_channel_sendhtml(in, f->subclass, f->data, f->datalen) == -1)
|
||||||
ast_log(LOG_WARNING, "Unable to send URL\n");
|
ast_log(LOG_WARNING, "Unable to send URL\n");
|
||||||
}
|
}
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
} /* end for */
|
} /* end for */
|
||||||
|
|||||||
Reference in New Issue
Block a user