]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3937 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 22 Feb 2012 21:26:38 +0000 (15:26 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 22 Feb 2012 21:26:38 +0000 (15:26 -0600)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index 0a2f672df67855d37828b03333229e1ef05fa8ac..9947e3778e82a496bb8dcfbd539feec0fad95682 100644 (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);
index d8824dae33ac49f81c5786844482806c0a1bcfe6..43de002cd436326f3b0104f31476266ab58917ee 100644 (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)
 {
index ecedd8898eeda6d76005fd03854d2146abdb7cd7..e469eaca229c0a326175b42edce41c55e4aa8196 100644 (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);