]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-4053 try this
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 29 Mar 2012 16:35:57 +0000 (11:35 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 29 Mar 2012 16:36:07 +0000 (11:36 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia.c

index 1928e0f462049e790b56f9f4a68525ccf461086a..21172b5f90d1b8847d93bae8d55e87c4e98ce8b9 100644 (file)
@@ -495,12 +495,16 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session)
                val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
 
                if (!val || switch_false(val)) {
-                       if (switch_channel_test_flag(channel, CF_INTERCEPT) || cause == SWITCH_CAUSE_PICKED_OFF || cause == SWITCH_CAUSE_LOSE_RACE) {
-                               switch_snprintf(reason, sizeof(reason), "SIP;cause=200;text=\"Call completed elsewhere\"");
-                       } else if (cause > 0 && cause < 128) {
-                               switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
+                       if ((val = switch_channel_get_variable(tech_pvt->channel, "sip_reason_str"))) {
+                               switch_snprintf(reason, sizeof(reason), "%s", val);
                        } else {
-                               switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"", tech_pvt->profile->username, cause, switch_channel_cause2str(cause));
+                               if (switch_channel_test_flag(channel, CF_INTERCEPT) || cause == SWITCH_CAUSE_PICKED_OFF || cause == SWITCH_CAUSE_LOSE_RACE) {
+                                       switch_snprintf(reason, sizeof(reason), "SIP;cause=200;text=\"Call completed elsewhere\"");
+                               } else if (cause > 0 && cause < 128) {
+                                       switch_snprintf(reason, sizeof(reason), "Q.850;cause=%d;text=\"%s\"", cause, switch_channel_cause2str(cause));
+                               } else {
+                                       switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"", tech_pvt->profile->username, cause, switch_channel_cause2str(cause));
+                               }
                        }
                }
 
index a8196a2d316641dbab7afd18dd3f102c6744f3f0..b443a36fb7616a468bf5727a022d405471e36058 100644 (file)
@@ -581,6 +581,14 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
        sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
        call_info = switch_channel_get_variable(channel, "presence_call_info_full");
 
+       if (sip->sip_reason) {
+               char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
+
+               if (!zstr(reason_header)) {
+                       switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
+               }
+       }
+
        if (sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
                                                                                                                        || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")
                                                                                                                        || !strcasecmp(sip->sip_reason->re_protocol, profile->username)) && sip->sip_reason->re_cause) {
@@ -981,7 +989,6 @@ static void our_sofia_event_callback(nua_event_t event,
        case nua_r_unregister:
        case nua_r_unsubscribe:
        case nua_r_publish:
-       case nua_i_cancel:
        case nua_i_error:
        case nua_i_active:
        case nua_i_terminated:
@@ -989,6 +996,19 @@ static void our_sofia_event_callback(nua_event_t event,
        case nua_i_prack:
        case nua_r_prack:
                break;
+
+       case nua_i_cancel:
+
+               if (sip && channel && sip->sip_reason) {
+                       char *reason_header = sip_header_as_string(nh->nh_home, (void *) sip->sip_reason);
+                       
+                       if (!zstr(reason_header)) {
+                               switch_channel_set_variable_partner(channel, "sip_reason", reason_header);
+                       }
+               }
+
+               break;
+
        case nua_r_cancel:
                {
                        if (status > 299 && nh) {