mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 08:40:16 +00:00
introduce a temporary variable for tmp->chan to shorten expressions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48575 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
107
apps/app_dial.c
107
apps/app_dial.c
@@ -1268,6 +1268,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
rest = args.peers;
|
rest = args.peers;
|
||||||
while ((cur = strsep(&rest, "&")) ) {
|
while ((cur = strsep(&rest, "&")) ) {
|
||||||
struct dial_localuser *tmp;
|
struct dial_localuser *tmp;
|
||||||
|
struct ast_channel *tc; /* channel for this destination */
|
||||||
/* Get a technology/[device:]number pair */
|
/* Get a technology/[device:]number pair */
|
||||||
char *number = cur;
|
char *number = cur;
|
||||||
char *tech = strsep(&number, "/");
|
char *tech = strsep(&number, "/");
|
||||||
@@ -1288,56 +1289,60 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
}
|
}
|
||||||
ast_copy_string(numsubst, number, sizeof(numsubst));
|
ast_copy_string(numsubst, number, sizeof(numsubst));
|
||||||
/* Request the peer */
|
/* Request the peer */
|
||||||
tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause);
|
tc = ast_request(tech, chan->nativeformats, numsubst, &cause);
|
||||||
if (!tmp->chan) {
|
if (!tc) {
|
||||||
/* If we can't, just go on to the next call */
|
/* If we can't, just go on to the next call */
|
||||||
ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
|
ast_log(LOG_WARNING, "Unable to create channel of type '%s' (cause %d - %s)\n",
|
||||||
|
tech, cause, ast_cause2str(cause));
|
||||||
handle_cause(cause, &num);
|
handle_cause(cause, &num);
|
||||||
if (!rest) /* we are on the last destination */
|
if (!rest) /* we are on the last destination */
|
||||||
chan->hangupcause = cause;
|
chan->hangupcause = cause;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pbx_builtin_setvar_helper(tmp->chan, "DIALEDPEERNUMBER", numsubst);
|
pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
|
||||||
if (!ast_strlen_zero(tmp->chan->call_forward)) {
|
if (!ast_strlen_zero(tc->call_forward)) {
|
||||||
char tmpchan[256];
|
char tmpchan[256];
|
||||||
char *stuff;
|
char *stuff;
|
||||||
char *tech;
|
char *tech;
|
||||||
ast_copy_string(tmpchan, tmp->chan->call_forward, sizeof(tmpchan));
|
ast_copy_string(tmpchan, tc->call_forward, sizeof(tmpchan));
|
||||||
if ((stuff = strchr(tmpchan, '/'))) {
|
if ((stuff = strchr(tmpchan, '/'))) {
|
||||||
*stuff++ = '\0';
|
*stuff++ = '\0';
|
||||||
tech = tmpchan;
|
tech = tmpchan;
|
||||||
} else {
|
} else {
|
||||||
snprintf(tmpchan, sizeof(tmpchan), "%s@%s", tmp->chan->call_forward, tmp->chan->context);
|
snprintf(tmpchan, sizeof(tmpchan), "%s@%s", tc->call_forward, tc->context);
|
||||||
stuff = tmpchan;
|
stuff = tmpchan;
|
||||||
tech = "Local";
|
tech = "Local";
|
||||||
}
|
}
|
||||||
tmp->forwards++;
|
tmp->forwards++;
|
||||||
if (tmp->forwards < AST_MAX_FORWARDS) {
|
if (tmp->forwards < AST_MAX_FORWARDS) {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n",
|
||||||
ast_hangup(tmp->chan);
|
chan->name, tech, stuff, tc->name);
|
||||||
/* If we have been told to ignore forwards, just set this channel to null and continue processing extensions normally */
|
ast_hangup(tc);
|
||||||
|
/* If we have been told to ignore forwards, just set this channel to null
|
||||||
|
* and continue processing extensions normally */
|
||||||
if (ast_test_flag(&opts, OPT_IGNORE_FORWARDING)) {
|
if (ast_test_flag(&opts, OPT_IGNORE_FORWARDING)) {
|
||||||
tmp->chan = NULL;
|
tc = NULL;
|
||||||
cause = AST_CAUSE_BUSY;
|
cause = AST_CAUSE_BUSY;
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Forwarding %s to '%s/%s' prevented.\n", chan->name, tech, stuff);
|
ast_verbose(VERBOSE_PREFIX_3 "Forwarding %s to '%s/%s' prevented.\n",
|
||||||
|
chan->name, tech, stuff);
|
||||||
} else {
|
} else {
|
||||||
tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
|
tc = ast_request(tech, chan->nativeformats, stuff, &cause);
|
||||||
}
|
}
|
||||||
if (!tmp->chan)
|
if (!tc)
|
||||||
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
|
||||||
else
|
else
|
||||||
ast_channel_inherit_variables(chan, tmp->chan);
|
ast_channel_inherit_variables(chan, tc);
|
||||||
} else {
|
} else {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", tmp->chan->name);
|
ast_verbose(VERBOSE_PREFIX_3 "Too many forwards from %s\n", tc->name);
|
||||||
ast_hangup(tmp->chan);
|
ast_hangup(tc);
|
||||||
tmp->chan = NULL;
|
tc = NULL;
|
||||||
cause = AST_CAUSE_CONGESTION;
|
cause = AST_CAUSE_CONGESTION;
|
||||||
}
|
}
|
||||||
if (!tmp->chan) {
|
if (!tc) {
|
||||||
handle_cause(cause, &num);
|
handle_cause(cause, &num);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
continue;
|
continue;
|
||||||
@@ -1345,51 +1350,46 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setup outgoing SDP to match incoming one */
|
/* Setup outgoing SDP to match incoming one */
|
||||||
ast_rtp_make_compatible(tmp->chan, chan, !outgoing && !rest);
|
ast_rtp_make_compatible(tc, chan, !outgoing && !rest);
|
||||||
|
|
||||||
/* Inherit specially named variables from parent channel */
|
/* Inherit specially named variables from parent channel */
|
||||||
ast_channel_inherit_variables(chan, tmp->chan);
|
ast_channel_inherit_variables(chan, tc);
|
||||||
|
|
||||||
tmp->chan->appl = "AppDial";
|
tc->appl = "AppDial";
|
||||||
tmp->chan->data = "(Outgoing Line)";
|
tc->data = "(Outgoing Line)";
|
||||||
tmp->chan->whentohangup = 0;
|
tc->whentohangup = 0;
|
||||||
|
|
||||||
S_REPLACE(tmp->chan->cid.cid_num, ast_strdup(chan->cid.cid_num));
|
S_REPLACE(tc->cid.cid_num, ast_strdup(chan->cid.cid_num));
|
||||||
S_REPLACE(tmp->chan->cid.cid_name, ast_strdup(chan->cid.cid_name));
|
S_REPLACE(tc->cid.cid_name, ast_strdup(chan->cid.cid_name));
|
||||||
S_REPLACE(tmp->chan->cid.cid_ani, ast_strdup(chan->cid.cid_ani));
|
S_REPLACE(tc->cid.cid_ani, ast_strdup(chan->cid.cid_ani));
|
||||||
S_REPLACE(tmp->chan->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
|
S_REPLACE(tc->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
|
||||||
|
|
||||||
/* Copy language from incoming to outgoing */
|
/* Copy language from incoming to outgoing */
|
||||||
ast_string_field_set(tmp->chan, language, chan->language);
|
ast_string_field_set(tc, language, chan->language);
|
||||||
ast_string_field_set(tmp->chan, accountcode, chan->accountcode);
|
ast_string_field_set(tc, accountcode, chan->accountcode);
|
||||||
tmp->chan->cdrflags = chan->cdrflags;
|
tc->cdrflags = chan->cdrflags;
|
||||||
if (ast_strlen_zero(tmp->chan->musicclass))
|
if (ast_strlen_zero(tc->musicclass))
|
||||||
ast_string_field_set(tmp->chan, musicclass, chan->musicclass);
|
ast_string_field_set(tc, musicclass, chan->musicclass);
|
||||||
/* Pass callingpres setting */
|
/* Pass callingpres, type of number, tns, ADSI CPE, transfer capability */
|
||||||
tmp->chan->cid.cid_pres = chan->cid.cid_pres;
|
tc->cid.cid_pres = chan->cid.cid_pres;
|
||||||
/* Pass type of number */
|
tc->cid.cid_ton = chan->cid.cid_ton;
|
||||||
tmp->chan->cid.cid_ton = chan->cid.cid_ton;
|
tc->cid.cid_tns = chan->cid.cid_tns;
|
||||||
/* Pass type of tns */
|
tc->adsicpe = chan->adsicpe;
|
||||||
tmp->chan->cid.cid_tns = chan->cid.cid_tns;
|
tc->transfercapability = chan->transfercapability;
|
||||||
/* Presense of ADSI CPE on outgoing channel follows ours */
|
|
||||||
tmp->chan->adsicpe = chan->adsicpe;
|
|
||||||
/* Pass the transfer capability */
|
|
||||||
tmp->chan->transfercapability = chan->transfercapability;
|
|
||||||
|
|
||||||
/* If we have an outbound group, set this peer channel to it */
|
/* If we have an outbound group, set this peer channel to it */
|
||||||
if (outbound_group)
|
if (outbound_group)
|
||||||
ast_app_group_set_channel(tmp->chan, outbound_group);
|
ast_app_group_set_channel(tc, outbound_group);
|
||||||
|
|
||||||
/* Inherit context and extension */
|
/* Inherit context and extension */
|
||||||
ast_copy_string(tmp->chan->dialcontext, chan->context, sizeof(tmp->chan->dialcontext));
|
ast_copy_string(tc->dialcontext, chan->context, sizeof(tc->dialcontext));
|
||||||
ast_copy_string(tmp->chan->exten, chan->exten, sizeof(tmp->chan->exten));
|
ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
|
||||||
|
|
||||||
/* Place the call, but don't wait on the answer */
|
res = ast_call(tc, numsubst, 0); /* Place the call, but don't wait on the answer */
|
||||||
res = ast_call(tmp->chan, numsubst, 0);
|
|
||||||
|
|
||||||
/* Save the info in cdr's that we called them */
|
/* Save the info in cdr's that we called them */
|
||||||
if (chan->cdr)
|
if (chan->cdr)
|
||||||
ast_cdr_setdestchan(chan->cdr, tmp->chan->name);
|
ast_cdr_setdestchan(chan->cdr, tc->name);
|
||||||
|
|
||||||
/* check the results of ast_call */
|
/* check the results of ast_call */
|
||||||
if (res) {
|
if (res) {
|
||||||
@@ -1398,21 +1398,22 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
|
|||||||
ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
|
ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res);
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst);
|
ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst);
|
||||||
ast_hangup(tmp->chan);
|
ast_hangup(tc);
|
||||||
tmp->chan = NULL;
|
tc = NULL;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
senddialevent(chan, tmp->chan);
|
senddialevent(chan, tc);
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst);
|
ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst);
|
||||||
if (!ast_test_flag(peerflags, OPT_ORIGINAL_CLID))
|
if (!ast_test_flag(peerflags, OPT_ORIGINAL_CLID))
|
||||||
ast_set_callerid(tmp->chan, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);
|
ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);
|
||||||
}
|
}
|
||||||
/* Put them in the list of outgoing thingies... We're ready now.
|
/* Put them in the list of outgoing thingies... We're ready now.
|
||||||
XXX If we're forcibly removed, these outgoing calls won't get
|
XXX If we're forcibly removed, these outgoing calls won't get
|
||||||
hung up XXX */
|
hung up XXX */
|
||||||
ast_set_flag(tmp, DIAL_STILLGOING);
|
ast_set_flag(tmp, DIAL_STILLGOING);
|
||||||
|
tmp->chan = tc;
|
||||||
tmp->next = outgoing;
|
tmp->next = outgoing;
|
||||||
outgoing = tmp;
|
outgoing = tmp;
|
||||||
/* If this line is up, don't try anybody else */
|
/* If this line is up, don't try anybody else */
|
||||||
|
|||||||
Reference in New Issue
Block a user