mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 12:42:02 +00:00
add send_info dp app and uuid_send_info FSAPI and execute_on_sip_extra_headers and api_on_sip_extra_headers handler variables
This commit is contained in:
@@ -1906,7 +1906,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
case SWITCH_MESSAGE_INDICATE_PHONE_EVENT:
|
||||
{
|
||||
const char *event = "talk";
|
||||
switch_channel_set_flag(channel, CF_REQ_MEDIA);
|
||||
|
||||
if (!zstr(msg->string_arg) && strcasecmp(msg->string_arg, event)) {
|
||||
if (!strcasecmp(msg->string_arg, "hold")) {
|
||||
@@ -1924,6 +1923,27 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
|
||||
}
|
||||
|
||||
}
|
||||
case SWITCH_MESSAGE_INDICATE_INFO:
|
||||
{
|
||||
char *headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_INFO_HEADER_PREFIX);
|
||||
char *ct = "freeswitch/data";
|
||||
const char *pl = NULL;
|
||||
|
||||
if (!zstr(msg->string_array_arg[0]) && !zstr(msg->string_array_arg[1])) {
|
||||
ct = switch_core_session_sprintf(session, "%s/%s", msg->string_array_arg[0], msg->string_array_arg[1]);
|
||||
}
|
||||
|
||||
if (!zstr(msg->string_array_arg[2])) {
|
||||
pl = msg->string_array_arg[2];
|
||||
}
|
||||
|
||||
nua_info(tech_pvt->nh,
|
||||
SIPTAG_CONTENT_TYPE_STR(ct),
|
||||
TAG_IF(!zstr(headers), SIPTAG_HEADER_STR(headers)),
|
||||
TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
|
||||
TAG_IF(pl, SIPTAG_PAYLOAD_STR(pl)),
|
||||
TAG_END());
|
||||
}
|
||||
break;
|
||||
case SWITCH_MESSAGE_INDICATE_SIMPLIFY:
|
||||
{
|
||||
|
||||
@@ -95,6 +95,8 @@ typedef struct private_object private_object_t;
|
||||
#define SOFIA_MULTIPART_PREFIX "sip_mp_"
|
||||
#define SOFIA_MULTIPART_PREFIX_T "~sip_mp_"
|
||||
#define SOFIA_SIP_HEADER_PREFIX "sip_h_"
|
||||
#define SOFIA_SIP_INFO_HEADER_PREFIX "sip_info_h_"
|
||||
#define SOFIA_SIP_INFO_HEADER_PREFIX_T "~sip_info_h_"
|
||||
#define SOFIA_SIP_RESPONSE_HEADER_PREFIX "sip_rh_"
|
||||
#define SOFIA_SIP_RESPONSE_HEADER_PREFIX_T "~sip_rh_"
|
||||
#define SOFIA_SIP_BYE_HEADER_PREFIX "sip_bye_h_"
|
||||
@@ -1108,7 +1110,7 @@ void sofia_glue_free_destination(sofia_destination_t *dst);
|
||||
switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype,
|
||||
const char *body, const char *o_contact, const char *network_ip);
|
||||
char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix);
|
||||
void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix);
|
||||
void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *sip, const char *prefix);
|
||||
void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t *bleg);
|
||||
void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *profile, sip_t const *sip, switch_bool_t send);
|
||||
void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number);
|
||||
|
||||
@@ -617,7 +617,7 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status,
|
||||
switch_channel_set_variable(channel, "sip_term_cause", st);
|
||||
|
||||
extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
|
||||
if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
|
||||
switch_core_session_t *nsession = NULL;
|
||||
@@ -4714,9 +4714,9 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
|
||||
const char *vval;
|
||||
|
||||
if (status > 199) {
|
||||
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
|
||||
} else {
|
||||
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
|
||||
}
|
||||
|
||||
|
||||
@@ -6122,7 +6122,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
|
||||
if (phrase) {
|
||||
switch_channel_set_variable_partner(channel, "sip_hangup_phrase", phrase);
|
||||
}
|
||||
sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
|
||||
}
|
||||
switch_snprintf(st, sizeof(st), "%d", cause);
|
||||
switch_channel_set_variable(channel, "sip_term_cause", st);
|
||||
@@ -6957,9 +6957,38 @@ void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t
|
||||
if (session) {
|
||||
/* Get the channel */
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *vval;
|
||||
|
||||
/* Barf if we didn't get our private */
|
||||
assert(switch_core_session_get_private(session));
|
||||
|
||||
sofia_glue_set_extra_headers(session, sip, SOFIA_SIP_INFO_HEADER_PREFIX);
|
||||
|
||||
if (!(vval = switch_channel_get_variable(channel, "sip_copy_custom_headers")) || switch_true(vval)) {
|
||||
switch_core_session_t *nsession = NULL;
|
||||
|
||||
switch_core_session_get_partner(session, &nsession);
|
||||
|
||||
if (nsession) {
|
||||
switch_core_session_message_t *msg;
|
||||
|
||||
switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_INFO_HEADER_PREFIX_T);
|
||||
msg = switch_core_session_alloc(nsession, sizeof(*msg));
|
||||
MESSAGE_STAMP_FFL(msg);
|
||||
msg->message_id = SWITCH_MESSAGE_INDICATE_INFO;
|
||||
|
||||
if (sip && sip->sip_content_type && sip->sip_content_type->c_type && sip->sip_content_type->c_subtype &&
|
||||
sip->sip_payload && sip->sip_payload->pl_data) {
|
||||
msg->string_array_arg[0] = switch_core_session_strdup(nsession, sip->sip_content_type->c_type);
|
||||
msg->string_array_arg[1] = switch_core_session_strdup(nsession, sip->sip_content_type->c_subtype);
|
||||
msg->string_array_arg[0] = switch_core_session_strdup(nsession, sip->sip_payload->pl_data);
|
||||
}
|
||||
msg->from = __FILE__;
|
||||
switch_core_session_queue_message(nsession, msg);
|
||||
|
||||
switch_core_session_rwunlock(nsession);
|
||||
}
|
||||
}
|
||||
|
||||
if (sip && sip->sip_content_type && sip->sip_content_type->c_subtype && sip->sip_content_type->c_type &&
|
||||
!strncasecmp(sip->sip_content_type->c_type, "message", 7) &&
|
||||
|
||||
@@ -1908,11 +1908,14 @@ char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix
|
||||
return extra_headers;
|
||||
}
|
||||
|
||||
void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix)
|
||||
void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *sip, const char *prefix)
|
||||
{
|
||||
sip_unknown_t *un;
|
||||
char name[512] = "";
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *pstr;
|
||||
|
||||
|
||||
if (!sip || !channel) {
|
||||
return;
|
||||
}
|
||||
@@ -1925,6 +1928,13 @@ void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pstr = switch_core_session_sprintf(session, "execute_on_%sprefix", prefix);
|
||||
switch_channel_execute_on(channel, pstr);
|
||||
switch_channel_api_on(channel, pstr);
|
||||
|
||||
switch_channel_execute_on(channel, "execute_on_sip_extra_headers");
|
||||
switch_channel_api_on(channel, "api_on_sip_extra_headers");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user