FS-3937 --resolve

This commit is contained in:
Anthony Minessale 2012-02-22 15:26:38 -06:00
parent 21a469e4d2
commit 8e47f3c660
3 changed files with 29 additions and 0 deletions

View File

@ -1117,6 +1117,7 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
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_core_session_t *session, sip_t const *sip, const char *prefix);
char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, 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);

View File

@ -1975,6 +1975,30 @@ void sofia_glue_set_extra_headers(switch_core_session_t *session, sip_t const *s
switch_channel_api_on(channel, "api_on_sip_extra_headers");
}
char *sofia_glue_get_extra_headers_from_event(switch_event_t *event, const char *prefix)
{
char *extra_headers = NULL;
switch_stream_handle_t stream = { 0 };
switch_event_header_t *hp;
SWITCH_STANDARD_STREAM(stream);
for (hp = event->headers; hp; hp = hp->next) {
if (!zstr(hp->name) && !zstr(hp->value) && !strncasecmp(hp->name, prefix, strlen(prefix))) {
char *name = strdup(hp->name);
const char *hname = name + strlen(prefix);
stream.write_function(&stream, "%s: %s\r\n", hname, (char *)hp->value);
free(name);
}
}
if (!zstr((char *) stream.data)) {
extra_headers = stream.data;
} else {
switch_safe_free(stream.data);
}
return extra_headers;
}
switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
{

View File

@ -116,6 +116,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
char header[256] = "";
char *route_uri = NULL;
const char *network_ip = NULL, *network_port = NULL, *from_proto;
char *extra_headers = NULL;
proto = switch_event_get_header(message_event, "proto");
from_proto = switch_event_get_header(message_event, "from_proto");
@ -129,6 +130,8 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
network_ip = switch_event_get_header(message_event, "to_sip_ip");
network_port = switch_event_get_header(message_event, "to_sip_port");
extra_headers = sofia_glue_get_extra_headers_from_event(message_event, SOFIA_SIP_HEADER_PREFIX);
if (!to) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n");
goto end;
@ -322,6 +325,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
SIPTAG_CONTENT_TYPE_STR(ct),
SIPTAG_PAYLOAD_STR(body),
SIPTAG_HEADER_STR(header),
TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_END());
sofia_glue_free_destination(dst);