[asterisk-commits] rmudgett: trunk r400304 - in /trunk: ./ main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 2 15:31:04 CDT 2013


Author: rmudgett
Date: Wed Oct  2 15:31:02 2013
New Revision: 400304

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=400304
Log:
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

Modified:
    trunk/   (props changed)
    trunk/main/pbx.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Wed Oct  2 15:31:02 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-400181,400194,400196,400205,400217,400227,400236,400245,400254,400256,400265,400268,400270,400281,400284,400286,400291
+/branches/12:1-398558,398560-398577,398579-399305,399307-400181,400194,400196,400205,400217,400227,400236,400245,400254,400256,400265,400268,400270,400281,400284,400286,400291,400303

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=400304&r1=400303&r2=400304
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Wed Oct  2 15:31:02 2013
@@ -10059,24 +10059,35 @@
 	}
 	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;
 
+		/*
+		 * 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);
+
 		ast_party_connected_line_set_init(&connected, ast_channel_connected(dialed));
-
-		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;
-
+		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) {




More information about the asterisk-commits mailing list