]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
will it never end?
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 21 Nov 2007 00:56:41 +0000 (00:56 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 21 Nov 2007 00:56:41 +0000 (00:56 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6368 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c

index 2e8c884a963872c04670855442f90796565482ba..28df47893cff23a95a934e3a2ec6250ced184719 100644 (file)
@@ -1485,6 +1485,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
                }
 
                profile = gateway_ptr->profile;
+
                if (!switch_test_flag(gateway_ptr, REG_FLAG_CALLERID)) {
                        tech_pvt->gateway_from_str = switch_core_session_strdup(nsession, gateway_ptr->register_from);
                }
index 0967cc7d7371f2bc13b20c9745bd5a16852c172e..f939468d2f8bddabe812b080be48883c9209a8fb 100644 (file)
@@ -296,6 +296,7 @@ struct private_object {
        char *far_end_contact;
        char *contact_url;
        char *from_str;
+       char *rpid;
        char *gateway_from_str;
        char *rm_encoding;
        char *rm_fmtp;
index 8ecc132b95caa12876de05f21a4df2bc482a8609..99c028733dc44b56b3597069074bff443a70fdc9 100644 (file)
@@ -476,7 +476,6 @@ char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char
 
 switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 {
-       char *rpid = NULL;
        char *alert_info = NULL;
        char *max_forwards = NULL;
        const char *alertbuf;
@@ -539,30 +538,12 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
        switch_set_flag_locked(tech_pvt, TFLAG_READY);
 
-       /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
-       if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
-               const char *priv = "off";
-               const char *screen = "no";
-               if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
-                       priv = "name";
-                       if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
-                               priv = "full";
-                       }
-               } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
-                       priv = "full";
-               }
-               if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
-                       screen = "yes";
-               }
-
-               rpid = switch_core_session_sprintf(tech_pvt->session, "Remote-Party-ID: %s;screen=%s;privacy=%s", tech_pvt->from_str, screen, priv);
-       }
-
        if (!tech_pvt->nh) {
                char *d_url = NULL, *url = NULL;
                sofia_private_t *sofia_private;
                char *invite_contact = NULL, *to_str, *use_from_str, *from_str, *url_str;
                const char *transport = "udp", *t_var;
+               char *rpid_domain = "cluecon.com", *p;
 
                if (switch_strlen_zero(tech_pvt->dest)) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "URL Error! [%s]\n", tech_pvt->dest);
@@ -587,6 +568,19 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                        use_from_str = tech_pvt->from_str;
                }
                
+               rpid_domain = switch_core_session_strdup(session, use_from_str);
+               sofia_glue_get_url_from_contact(rpid_domain, 0);
+               if ((rpid_domain = strchr(rpid_domain, '@'))) {
+                       rpid_domain++;
+                       if ((p = strchr(rpid_domain, ';'))) {
+                               *p = '\0';
+                       }
+               }
+
+               if (!rpid_domain) {
+                       rpid_domain = "cluecon.com";
+               }
+
                if (switch_stristr("port=tcp", url)) {
                        transport = "tcp";
                } else {
@@ -616,6 +610,30 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                                                                  SIPTAG_CONTACT_STR(invite_contact),
                                                                  TAG_END());
 
+
+               /* TODO: We should use the new tags for making an rpid and add profile options to turn this on/off */
+               if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
+                       const char *priv = "off";
+                       const char *screen = "no";
+                       if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
+                               priv = "name";
+                               if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+                                       priv = "full";
+                               }
+                       } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+                               priv = "full";
+                       }
+                       if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
+                               screen = "yes";
+                       }
+
+                       tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "Remote-Party-ID: \"%s\"<%s@%s>;screen=%s;privacy=%s", 
+                                                                                                                tech_pvt->caller_profile->caller_id_name, 
+                                                                                                                tech_pvt->caller_profile->caller_id_number, 
+                                                                                                                rpid_domain,
+                                                                                                                screen, priv);
+               }
+
                switch_safe_free(d_url);
                
                if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
@@ -680,7 +698,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
 
        nua_invite(tech_pvt->nh,
                           NUTAG_SESSION_TIMER(session_timeout),
-                          TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)),
+                          TAG_IF(!switch_strlen_zero(tech_pvt->rpid), SIPTAG_HEADER_STR(tech_pvt->rpid)),
                           TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
                           TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
                           TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),