From 4ceca1890d10787be6c86446599b95f63d60b014 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 21 Oct 2011 20:38:41 -0500 Subject: [PATCH] fix return addrs in chat msgs --- src/mod/endpoints/mod_sofia/sofia_presence.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 23c0661a0e..2b6c6ed5fc 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -112,9 +112,10 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) const char *from_full; char header[256] = ""; char *route_uri = NULL; - const char *network_ip = NULL, *network_port = NULL; - + const char *network_ip = NULL, *network_port = NULL, *from_proto; + proto = switch_event_get_header(message_event, "proto"); + from_proto = switch_event_get_header(message_event, "from_proto"); from = switch_event_get_header(message_event, "from"); to = switch_event_get_header(message_event, "to"); //subject = switch_event_get_header(message_event, "subject"); @@ -204,6 +205,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) } else { char *fp, *p = NULL; + fp = strdup(from); switch_assert(fp); @@ -220,9 +222,14 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event) } if (switch_stristr("global", proto)) { - ffrom = switch_mprintf("\"%s\" ", fp, fp, p); + if (!from_proto || !strcasecmp(from_proto, SOFIA_CHAT_PROTO)) { + ffrom = switch_mprintf("\"%s\" ", fp, fp, p); + } else { + ffrom = switch_mprintf("\"%s\" ", fp, from_proto, fp, p); + } + } else { - ffrom = switch_mprintf("\"%s\" ", fp, proto, fp, p); + ffrom = switch_mprintf("\"%s\" ", fp, from_proto ? from_proto : proto, fp, p); } from = ffrom; @@ -3441,6 +3448,9 @@ void sofia_presence_handle_sip_i_message(int status, if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO); + + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", proto); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", from_addr); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", from_user); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", from_host);