Revision
15186
Author
anthm
Date
2009-10-21 13:48:28 -0500 (Wed, 21 Oct 2009)

Log Message

FSCORE-471 and any other update related bugs

Modified Paths

Diff

Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c (15185 => 15186)


--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -3490,8 +3490,9 @@
 	if ((overlap = sr0->sr_offer_recv && !sr0->sr_answer_sent))
 	  break;
 
-    if (nh->nh_soa && overlap)
-      return nua_server_retry_after(sr, 500, "Overlapping Offer/Answer", 1, 9);
+    if (nh->nh_soa && overlap) {
+		return nua_server_retry_after(sr, 500, "Overlapping Offer/Answer", 1, 9);
+	}
 
     if (nh->nh_soa &&
 	soa_set_remote_sdp(nh->nh_soa, NULL, sr->sr_sdp, sr->sr_sdp_len) < 0) {

Modified: freeswitch/trunk/src/include/switch_channel.h (15185 => 15186)


--- freeswitch/trunk/src/include/switch_channel.h	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/include/switch_channel.h	2009-10-21 18:48:28 UTC (rev 15186)
@@ -252,6 +252,8 @@
 SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname);
 SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event);
 
+SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel);
+
 /*!
  * \brief Start iterating over the entries in the channel variable list.
  * \param channel the channel to iterate the variables for

Modified: freeswitch/trunk/src/include/switch_core.h (15185 => 15186)


--- freeswitch/trunk/src/include/switch_core.h	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/include/switch_core.h	2009-10-21 18:48:28 UTC (rev 15186)
@@ -96,6 +96,7 @@
 	const char *_func;
 	int _line;
 	const char *string_array_arg[MESSAGE_STRING_ARG_MAX];
+	time_t delivery_time;
 };
 
 /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (15185 => 15186)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -181,17 +181,19 @@
 	const char *callee_name = NULL, *callee_number = NULL;
 	char *pai = NULL;
 
-	if ((callee_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name"))) {
-		if (!(callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number"))) {
+	if (!(callee_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name"))) {
+		callee_name = switch_channel_get_variable(tech_pvt->channel, "callee_id_name");
+	}
+
+	if (!(callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number"))) {
+		if (!(callee_number = switch_channel_get_variable(tech_pvt->channel, "callee_id_number"))) {
 			callee_number = tech_pvt->caller_profile->destination_number;
 		}
+	}
 
-		if (!strchr(callee_number, '@')) {
-			char *tmp = switch_core_session_sprintf(session, "sip:%s@cluecon.com", callee_number);
-			callee_number = tmp;
-		}
-
-		pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>", callee_name, callee_number);
+	if (callee_name && callee_number) {
+		pai = switch_core_session_sprintf(tech_pvt->session, "P-Asserted-Identity: \"%s\" <%s>\nX-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", 
+										  callee_name, callee_number, callee_name, callee_number);
 	}
 	return pai;
 }
@@ -483,7 +485,7 @@
 							SOATAG_REUSE_REJECTED(1),
 							SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), 
 							TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-							SIPTAG_HEADER_STR("X-Actually-Support: "SOFIA_ACTUALLY_SUPPORT),
+							SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
 							TAG_END());
 
 				switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
@@ -572,7 +574,7 @@
 					SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 					SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1), 
 					TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-					SIPTAG_HEADER_STR("X-Actually-Support: "SOFIA_ACTUALLY_SUPPORT),
+					SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
 					TAG_END());
 		switch_safe_free(extra_headers);
 		sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
@@ -1289,21 +1291,25 @@
 					number = tech_pvt->caller_profile->destination_number;
 				}
 
-				if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
-					switch_channel_set_variable(channel, "sip_callee_id_name", name);
-					switch_channel_set_variable(channel, "sip_callee_id_number", number);
-				} else {
+				if (switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
 					if (switch_strlen_zero(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) ||
 						switch_strlen_zero(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) {
-					
-						if (ua && switch_stristr("snom", ua)) {
+						
+						if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
+							snprintf(message, sizeof(message), "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", name, number);
+
+							nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/update_display"),
+									 TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)),
+									 TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
+									 TAG_END());
+						} else if (ua && switch_stristr("snom", ua)) {
 							snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number);
 							nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
 									 TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
 									 SIPTAG_PAYLOAD_STR(message), TAG_END());
-						} else if ((ua && (switch_stristr("polycom", ua) ||
-										   switch_stristr("UPDATE", tech_pvt->x_actually_support_remote)))) {
+						} else if ((ua && (switch_stristr("polycom", ua)))) {
 							snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number);
+							sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
 							nua_update(tech_pvt->nh,
 									   TAG_IF(!switch_strlen_zero_buf(message), SIPTAG_HEADER_STR(message)),
 									   TAG_IF(!switch_strlen_zero(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
@@ -1519,7 +1525,7 @@
 						SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
 						SIPTAG_HEADER_STR(generate_pai_str(session)), 
 						TAG_IF(!switch_strlen_zero(extra_header), SIPTAG_HEADER_STR(extra_header)),
-						SIPTAG_HEADER_STR("X-Actually-Support: "SOFIA_ACTUALLY_SUPPORT),
+						SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
 						TAG_END());
 			switch_safe_free(extra_header);
 			switch_channel_mark_ring_ready(channel);
@@ -1605,7 +1611,7 @@
 								SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
 								SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"), 
 								TAG_IF(!switch_strlen_zero(extra_header), SIPTAG_HEADER_STR(extra_header)),
-								SIPTAG_HEADER_STR("X-Actually-Support: "SOFIA_ACTUALLY_SUPPORT),
+								SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
 								TAG_END());
 					switch_safe_free(extra_header);
 				}

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (15185 => 15186)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h	2009-10-21 18:48:28 UTC (rev 15186)
@@ -96,7 +96,7 @@
 #define SOFIA_SECURE_MEDIA_CONFIRMED_VARIABLE "sip_secure_media_confirmed"
 #define SOFIA_HAS_CRYPTO_VARIABLE "sip_has_crypto"
 #define SOFIA_CRYPTO_MANDATORY_VARIABLE "sip_crypto_mandatory"
-#define SOFIA_ACTUALLY_SUPPORT "UPDATE"
+#define FREESWITCH_SUPPORT "update_display"
 
 #include <sofia-sip/nua.h>
 #include <sofia-sip/sip_status.h>
@@ -247,7 +247,7 @@
 	TFLAG_HOLD_LOCK,
 	TFLAG_3PCC_HAS_ACK,
 	TFLAG_PASS_RFC2833,
-
+	TFLAG_UPDATING_DISPLAY,
 	/* No new flags below this line */
 	TFLAG_MAX
 } TFLAGS;
@@ -581,8 +581,8 @@
 	char *extrtpip;
 	char *stun_ip;
 	char *route_uri;
-	char *x_actually_support_remote;
-	char *x_actually_support_local;
+	char *x_freeswitch_support_remote;
+	char *x_freeswitch_support_local;
 	char *last_sent_callee_id_name;
 	char *last_sent_callee_id_number;
 	switch_port_t stun_port;

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (15185 => 15186)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -393,7 +393,7 @@
 	}
 
 	if (switch_strlen_zero(name)) {
-		name = "unknown";
+		name = number;
 	}
 	
 	if (switch_strlen_zero(number)) {
@@ -402,7 +402,11 @@
 
 	if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
 		switch_core_session_message_t *msg;
-		
+		//switch_channel_t *channel_b = switch_core_session_get_channel(session_b);
+
+		//switch_channel_set_profile_var(channel_b, "callee_id_name", name);
+		//switch_channel_set_profile_var(channel_b, "callee_id_number", number);
+
 		msg = switch_core_session_alloc(session_b, sizeof(*msg));
 		MESSAGE_STAMP_FFL(msg);
 		msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
@@ -418,33 +422,47 @@
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	sip_p_asserted_identity_t *passerted = NULL;
-	char *name = "unknown";
+	char *name = NULL;
 	const char *number = "unknown", *tmp;
 	switch_caller_profile_t *caller_profile;
 	char *dup = NULL;
 	switch_event_t *event;
+	const char *val;
+	int fs = 0;
 
 	if (sip->sip_to) {
 		number = sip->sip_to->a_url->url_user;
 	}
-	
-	if ((passerted = sip_p_asserted_identity(sip))) {
-		if (passerted->paid_url && passerted->paid_url->url_user) {
-			number = passerted->paid_url->url_user;
-		}
-		if (!switch_strlen_zero(passerted->paid_display)) {
-			dup = strdup(passerted->paid_display);
-			if (*dup == '"') {
-				name = dup + 1;
-			} else {
-				name = dup;
+
+	if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Display-Number"))) {
+		number = val;
+		fs++;
+	}
+
+	if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Display-Name"))) {
+		name = (char *)val;
+		fs++;
+	}
+
+	if (!fs) {
+		if ((passerted = sip_p_asserted_identity(sip))) {
+			if (passerted->paid_url && passerted->paid_url->url_user) {
+				number = passerted->paid_url->url_user;
 			}
-			if (end_of(name) == '"') {
-				end_of(name) = '\0';
+			if (!switch_strlen_zero(passerted->paid_display)) {
+				dup = strdup(passerted->paid_display);
+				if (*dup == '"') {
+					name = dup + 1;
+				} else {
+					name = dup;
+				}
+				if (end_of(name) == '"') {
+					end_of(name) = '\0';
+				}
 			}
 		}
 	}
-	
+
 	if ((tmp = switch_channel_get_variable(channel, "sip_callee_id_name"))) {
 		name = (char *)tmp;
 	}
@@ -453,6 +471,8 @@
 		number = tmp;
 	}
 
+	if (!name) name = (char *) number;
+
 	if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
 		const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
 		switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV");
@@ -663,6 +683,9 @@
 		if (session) sofia_handle_sip_i_update(nua, profile, nh, session, sip, tags);
 		break;
 	case nua_r_update:
+		if (session && tech_pvt && locked) {
+			sofia_clear_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
+		}
 		break;
 	case nua_r_refer:
 		break;
@@ -1033,7 +1056,7 @@
 				   NUTAG_ENABLEMESSENGER(1),
 				   TAG_IF((profile->mflags & MFLAG_REGISTER), NUTAG_ALLOW("REGISTER")),
 				   TAG_IF((profile->mflags & MFLAG_REFER), NUTAG_ALLOW("REFER")),
-				   TAG_IF((profile->mflags & MFLAG_UPDATE), NUTAG_ALLOW("UPDATE")),
+				   //TAG_IF((profile->mflags & MFLAG_UPDATE), NUTAG_ALLOW("UPDATE")),
 				   TAG_IF(!sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_ALLOW("PRACK")),
 				   NUTAG_ALLOW("INFO"),
 				   NUTAG_ALLOW("NOTIFY"),
@@ -1069,7 +1092,7 @@
 					   NUTAG_AUTOALERT(0),
 					   TAG_IF((profile->mflags & MFLAG_REGISTER), NUTAG_ALLOW("REGISTER")),
 					   TAG_IF((profile->mflags & MFLAG_REFER), NUTAG_ALLOW("REFER")),
-					   TAG_IF((profile->mflags & MFLAG_UPDATE), NUTAG_ALLOW("UPDATE")),
+					   //TAG_IF((profile->mflags & MFLAG_UPDATE), NUTAG_ALLOW("UPDATE")),
 					   NUTAG_ALLOW("INFO"),
 					   TAG_IF(profile->pres_type, NUTAG_ALLOW("PUBLISH")),
 					   TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)),
@@ -3116,12 +3139,12 @@
 		switch_channel_clear_flag(channel, CF_REQ_MEDIA);
 
 		if ((status == 180 || status == 183 || status == 200)) { 
-			const char *x_actually_support;
+			const char *x_freeswitch_support;
 
 			switch_channel_set_flag(channel, CF_MEDIA_ACK);
 
-			if ((x_actually_support = sofia_glue_get_unknown_header(sip, "X-Actually-Support"))) {
-				tech_pvt->x_actually_support_remote = switch_core_session_strdup(session, x_actually_support);
+			if ((x_freeswitch_support = sofia_glue_get_unknown_header(sip, "X-FS-Support"))) {
+				tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, x_freeswitch_support);
 			}
 
 			if (sip->sip_user_agent && sip->sip_user_agent->g_string) {
@@ -4603,6 +4626,8 @@
 			} else if (!strncasecmp(sip->sip_content_type->c_type, "application", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "dtmf")) {
 				int tmp = atoi(sip->sip_payload->pl_data);
 				dtmf.digit = switch_rfc2833_to_char(tmp);
+			} else if (!strncasecmp(sip->sip_content_type->c_type, "message", 11) && !strcasecmp(sip->sip_content_type->c_subtype, "update_display")) {
+				sofia_update_callee_id(session, profile, sip, SWITCH_TRUE);
 			} else {
 				goto end;
 			}
@@ -5558,8 +5583,8 @@
 				}
 			} else if (!strncasecmp(un->un_name, "History-Info", 12)) {
 				switch_channel_set_variable(channel, "sip_history_info", un->un_value);
-			} else if (!strcasecmp(un->un_name, "X-Actually-Support")) {
-				tech_pvt->x_actually_support_remote = switch_core_session_strdup(session, un->un_value);
+			} else if (!strcasecmp(un->un_name, "X-FS-Support")) {
+				tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, un->un_value);
 			} else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {
 				if (!switch_strlen_zero(un->un_value)) {
 					char new_name[512] = "";

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (15185 => 15186)


--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -496,7 +496,7 @@
 		tech_pvt->flags[x] = profile->flags[x];
 	}
 
-	tech_pvt->x_actually_support_local = SOFIA_ACTUALLY_SUPPORT;
+	tech_pvt->x_freeswitch_support_local = FREESWITCH_SUPPORT;
 
 	tech_pvt->profile = profile;
 	profile->inuse++;
@@ -1773,7 +1773,7 @@
 			   TAG_IF(!switch_strlen_zero(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)),
 			   TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
 			   TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-			   SIPTAG_HEADER_STR("X-Actually-Support: "SOFIA_ACTUALLY_SUPPORT),
+			   SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT),
 			   TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
 			   TAG_IF(!switch_strlen_zero(route_uri), NUTAG_PROXY(route_uri)),
 			   TAG_IF(!switch_strlen_zero(route), SIPTAG_ROUTE_STR(route)),

Modified: freeswitch/trunk/src/switch_channel.c (15185 => 15186)


--- freeswitch/trunk/src/switch_channel.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/switch_channel.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -2531,6 +2531,32 @@
 	return stream.data;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel)
+{
+	int x = 0;
+
+	switch_assert(channel);
+	switch_assert(other_channel);
+
+	switch_mutex_lock(channel->profile_mutex);
+	switch_mutex_lock(other_channel->profile_mutex);
+
+	if (!switch_strlen_zero(channel->caller_profile->callee_id_name)) {
+		other_channel->caller_profile->callee_id_name = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_name);
+		x++;
+	}
+
+	if (!switch_strlen_zero(channel->caller_profile->callee_id_number)) {
+		other_channel->caller_profile->callee_id_number = switch_core_strdup(channel->caller_profile->pool, channel->caller_profile->callee_id_number);
+		x++;
+	}
+
+	switch_mutex_unlock(other_channel->profile_mutex);
+	switch_mutex_unlock(channel->profile_mutex);
+
+	return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event)
 {
 	switch_status_t status;

Modified: freeswitch/trunk/src/switch_core_session.c (15185 => 15186)


--- freeswitch/trunk/src/switch_core_session.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/switch_core_session.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -751,6 +751,11 @@
 	if (session->message_queue) {
 		if ((status = (switch_status_t) switch_queue_trypop(session->message_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
 			*message = (switch_core_session_message_t *) pop;
+			if ((*message)->delivery_time && (*message)->delivery_time > switch_epoch_time_now(NULL)) {
+				switch_core_session_queue_message(session, *message);
+				*message = NULL;
+				status = SWITCH_STATUS_FALSE;
+			}
 		}
 	}
 

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (15185 => 15186)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -375,6 +375,7 @@
 		if (!ans_a && originator) {
 
 			if (!ans_b && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
+				switch_channel_pass_callee_id(chan_b, chan_a);
 				if (switch_channel_answer(chan_a) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(chan_a));
 					goto end_of_bridge_loop;
@@ -397,6 +398,7 @@
 			switch_channel_t *un = ans_a ? chan_b : chan_a;
 			
 			if (!switch_channel_test_flag(un, CF_OUTBOUND)) {
+				switch_channel_pass_callee_id(un == chan_b ? chan_a : chan_b, un);
 				if (switch_channel_answer(un) != SWITCH_STATUS_SUCCESS) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n", switch_channel_get_name(un));
 					goto end_of_bridge_loop;
@@ -920,6 +922,7 @@
 	switch_channel_add_state_handler(peer_channel, &audio_bridge_peer_state_handlers);
 
 	if (switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
+		switch_channel_pass_callee_id(peer_channel, caller_channel);
 		switch_channel_answer(caller_channel);
 	}
 

Modified: freeswitch/trunk/src/switch_ivr_originate.c (15185 => 15186)


--- freeswitch/trunk/src/switch_ivr_originate.c	2009-10-21 17:55:31 UTC (rev 15185)
+++ freeswitch/trunk/src/switch_ivr_originate.c	2009-10-21 18:48:28 UTC (rev 15186)
@@ -385,6 +385,9 @@
 			if (!oglobals->ring_ready) {
 				oglobals->ring_ready = 1;
 				if (caller_channel && !oglobals->ignore_ring_ready) {
+					if (len == 1) {
+						switch_channel_pass_callee_id(originate_status[0].peer_channel, caller_channel);
+					}
 					switch_channel_ring_ready(caller_channel);
 					oglobals->sent_ring = 1;
 				}
@@ -2321,6 +2324,7 @@
 
 			if (caller_channel) {
 				if (switch_channel_test_flag(peer_channel, CF_ANSWERED)) {
+					switch_channel_pass_callee_id(peer_channel, caller_channel);
 					status = switch_channel_answer(caller_channel);
 				} else if (switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA)) {
 					status = switch_channel_pre_answer(caller_channel);
@@ -2561,7 +2565,7 @@
 
 	switch_safe_free(write_frame.data);
 	switch_safe_free(fail_on_single_reject_var);
-
+	
 	if (caller_channel) {
 		switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
 		switch_channel_clear_flag(caller_channel, CF_XFER_ZOMBIE);