diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-10-02 20:31:02 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-10-02 20:31:02 +0000 |
commit | be62f83d5494ceda6f8f158d338bbe4618ae8426 (patch) | |
tree | 7b8ae5be36f30e9750f9fbfbac02e234db9a484e | |
parent | 8195eeac456e8874e3b061a1fb7ecb011797682b (diff) |
Originate: Make setting caller id on outgoing call use either name or number.
Previous code was requiring both name and number to be available.
Also restored a comment block on why caller id is also set on an outgoing
call leg in addition to connected line from earlier versions of Asterisk.
........
Merged revisions 400303 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400304 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/pbx.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/main/pbx.c b/main/pbx.c index 6b71c54b9..a5ac9100b 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -10059,24 +10059,35 @@ static int pbx_outgoing_attempt(const char *type, struct ast_format_cap *cap, co } ast_set_flag(ast_channel_flags(dialed), AST_FLAG_ORIGINATED); - if (!ast_strlen_zero(cid_num) && !ast_strlen_zero(cid_name)) { + if (!ast_strlen_zero(cid_num) || !ast_strlen_zero(cid_name)) { struct ast_party_connected_line connected; - ast_party_connected_line_set_init(&connected, ast_channel_connected(dialed)); - + /* + * It seems strange to set the CallerID on an outgoing call leg + * to whom we are calling, but this function's callers are doing + * various Originate methods. This call leg goes to the local + * user. Once the called party answers, the dialplan needs to + * be able to access the CallerID from the CALLERID function as + * if the called party had placed this call. + */ ast_set_callerid(dialed, cid_num, cid_name, cid_num); - connected.id.number.valid = 1; - connected.id.number.str = (char *) cid_num; - connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; - connected.id.name.valid = 1; - connected.id.name.str = (char *) cid_name; - connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; + ast_party_connected_line_set_init(&connected, ast_channel_connected(dialed)); + if (!ast_strlen_zero(cid_num)) { + connected.id.number.valid = 1; + connected.id.number.str = (char *) cid_num; + connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; + } + if (!ast_strlen_zero(cid_name)) { + connected.id.name.valid = 1; + connected.id.name.str = (char *) cid_name; + connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; + } ast_channel_set_connected_line(dialed, &connected, NULL); } if (early_media) { - ast_dial_set_state_callback(outgoing->dial, &pbx_outgoing_state_callback); + ast_dial_set_state_callback(outgoing->dial, pbx_outgoing_state_callback); } if (channel) { |