add sip_refer_to var
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7008 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
ef563f04c4
commit
24038ba5f9
|
@ -72,6 +72,7 @@ typedef struct private_object private_object_t;
|
||||||
#define SOFIA_SIP_HEADER_PREFIX_T "~sip_h_"
|
#define SOFIA_SIP_HEADER_PREFIX_T "~sip_h_"
|
||||||
#define SOFIA_DEFAULT_PORT "5060"
|
#define SOFIA_DEFAULT_PORT "5060"
|
||||||
#define SOFIA_DEFAULT_TLS_PORT "5061"
|
#define SOFIA_DEFAULT_TLS_PORT "5061"
|
||||||
|
#define SOFIA_REFER_TO_VARIABLE "sip_refer_to"
|
||||||
|
|
||||||
#include <sofia-sip/nua.h>
|
#include <sofia-sip/nua.h>
|
||||||
#include <sofia-sip/sip_status.h>
|
#include <sofia-sip/sip_status.h>
|
||||||
|
|
|
@ -1720,6 +1720,7 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
switch_channel_t *channel_a = NULL, *channel_b = NULL;
|
switch_channel_t *channel_a = NULL, *channel_b = NULL;
|
||||||
su_home_t *home = NULL;
|
su_home_t *home = NULL;
|
||||||
char *full_ref_by = NULL;
|
char *full_ref_by = NULL;
|
||||||
|
char *full_ref_to = NULL;
|
||||||
|
|
||||||
tech_pvt = switch_core_session_get_private(session);
|
tech_pvt = switch_core_session_get_private(session);
|
||||||
channel_a = switch_core_session_get_channel(session);
|
channel_a = switch_core_session_get_channel(session);
|
||||||
|
@ -1739,14 +1740,16 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
from = sip->sip_from;
|
from = sip->sip_from;
|
||||||
to = sip->sip_to;
|
to = sip->sip_to;
|
||||||
|
|
||||||
|
home = su_home_new(sizeof(*home));
|
||||||
|
switch_assert(home != NULL);
|
||||||
|
|
||||||
if (sip->sip_referred_by) {
|
if (sip->sip_referred_by) {
|
||||||
home = su_home_new(sizeof(*home));
|
|
||||||
switch_assert(home != NULL);
|
|
||||||
full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by);
|
full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((refer_to = sip->sip_refer_to)) {
|
if ((refer_to = sip->sip_refer_to)) {
|
||||||
|
full_ref_to = sip_header_as_string(home, (void *) sip->sip_refer_to);
|
||||||
|
|
||||||
if (profile->pflags & PFLAG_FULL_ID) {
|
if (profile->pflags & PFLAG_FULL_ID) {
|
||||||
exten = switch_mprintf("%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
|
exten = switch_mprintf("%s@%s", (char *) refer_to->r_url->url_user, (char *) refer_to->r_url->url_host);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1774,11 +1777,6 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!home) {
|
|
||||||
home = su_home_new(sizeof(*home));
|
|
||||||
switch_assert(home != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((replaces = sip_replaces_make(home, rep))
|
if ((replaces = sip_replaces_make(home, rep))
|
||||||
&& (bnh = nua_handle_by_replaces(nua, replaces))) {
|
&& (bnh = nua_handle_by_replaces(nua, replaces))) {
|
||||||
sofia_private_t *b_private = NULL;
|
sofia_private_t *b_private = NULL;
|
||||||
|
@ -1845,6 +1843,10 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
switch_channel_set_variable(t_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
switch_channel_set_variable(t_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!switch_strlen_zero(full_ref_to)) {
|
||||||
|
switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
|
||||||
|
}
|
||||||
|
|
||||||
switch_ivr_session_transfer(t_session, ext, NULL, NULL);
|
switch_ivr_session_transfer(t_session, ext, NULL, NULL);
|
||||||
nua_notify(tech_pvt->nh,
|
nua_notify(tech_pvt->nh,
|
||||||
NUTAG_NEWSUB(1),
|
NUTAG_NEWSUB(1),
|
||||||
|
@ -1898,7 +1900,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
if (!switch_strlen_zero(full_ref_by)) {
|
if (!switch_strlen_zero(full_ref_by)) {
|
||||||
switch_channel_set_variable(channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
switch_channel_set_variable(channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
||||||
}
|
}
|
||||||
|
if (!switch_strlen_zero(full_ref_to)) {
|
||||||
|
switch_channel_set_variable(channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
|
||||||
|
}
|
||||||
if (switch_ivr_originate(a_session,
|
if (switch_ivr_originate(a_session,
|
||||||
&tsession, &cause, exten, timeout, &noop_state_handler, NULL, NULL, NULL, SOF_NONE)
|
&tsession, &cause, exten, timeout, &noop_state_handler, NULL, NULL, NULL, SOF_NONE)
|
||||||
!= SWITCH_STATUS_SUCCESS) {
|
!= SWITCH_STATUS_SUCCESS) {
|
||||||
|
@ -1954,7 +1958,9 @@ void sofia_handle_sip_i_refer(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||||
if (!switch_strlen_zero(full_ref_by)) {
|
if (!switch_strlen_zero(full_ref_by)) {
|
||||||
switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
switch_channel_set_variable(b_channel, SOFIA_SIP_HEADER_PREFIX "Referred-By", full_ref_by);
|
||||||
}
|
}
|
||||||
|
if (!switch_strlen_zero(full_ref_to)) {
|
||||||
|
switch_channel_set_variable(b_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
|
||||||
|
}
|
||||||
switch_ivr_session_transfer(b_session, exten, NULL, NULL);
|
switch_ivr_session_transfer(b_session, exten, NULL, NULL);
|
||||||
switch_core_session_rwunlock(b_session);
|
switch_core_session_rwunlock(b_session);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue