]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
try to auto guess presence_id where possible
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Feb 2012 21:22:28 +0000 (15:22 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Feb 2012 21:22:28 +0000 (15:22 -0600)
src/mod/applications/mod_dptools/mod_dptools.c
src/mod/endpoints/mod_sofia/sofia_glue.c

index a76ac7d0ee942dd693d679346991fcca5e9e09d2..e067b091f043b17bc394179e026260da8449ed06 100755 (executable)
@@ -3313,6 +3313,9 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
        if (var_event) {
                switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", user);
                switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain);
+               if (!strstr(dest, "presence_id=")) {
+                       switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "presence_id", "%s@%s", user, domain);
+               }
        }
 
        if (!dest) {
index ab68e108be3b9378ce295d55c7db87d2465b2b1d..1e23e40ee356235a0db523cf2a8c0ef077f4fe36 100644 (file)
@@ -2291,6 +2291,25 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                switch_channel_set_variable(channel, "sip_to_host", sofia_glue_get_host(to_str, switch_core_session_get_pool(session)));
                switch_channel_set_variable(channel, "sip_from_host", sofia_glue_get_host(from_str, switch_core_session_get_pool(session)));
 
+               if (!switch_channel_get_variable(channel, "presence_id")) {
+                       char *from = switch_core_session_strdup(session, from_str);
+                       
+                       if (!strncasecmp(from, "sip:", 4)) {
+                               from += 4;
+                       }
+
+                       if (!strncasecmp(from, "sips:", 4)) {
+                               from += 5;
+                       }
+
+                       if ((p = strchr(from, ':')) || (p = strchr(from, ';'))) {
+                               *p++ = '\0';
+                       }
+                       
+                       switch_channel_set_variable(channel, "presence_id", from);
+                       
+               }
+               
                if (!(tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
                                                                                NUTAG_URL(url_str),
                                                                                TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),