[Freeswitch-svn] [commit] r2981 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Thu Oct 5 11:07:45 EDT 2006


Author: anthm
Date: Thu Oct  5 11:07:45 2006
New Revision: 2981

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c

Log:
sofia again

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Thu Oct  5 11:07:45 2006
@@ -2413,6 +2413,7 @@
 			char *displayname;
 			char *username, *to_username;
 			char *url_user = (char *) from->a_url->url_user;
+			char *to_user, *to_host;
 
 			if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
@@ -2424,6 +2425,25 @@
 				tech_pvt->key = switch_core_session_strdup(session, key);
 			}
 
+			to_user = (char *) to->a_url->url_user;
+			to_host = (char *) to->a_url->url_host;
+			
+			if (switch_strlen_zero(to_user)) { /* if sofia doesnt parse the To: right, we'll have to do it */
+				if ((to_user = sip_header_as_string(tech_pvt->home, (sip_header_t *) to))) {
+					char *p;
+					if (*to_user == '<') {
+						to_user++;
+					}
+					if ((p = strchr((to_user += 4), '@'))) {
+						*p++ = '\0';
+						to_host = p;
+						if ((p = strchr(to_host, '>'))) {
+							*p = '\0';
+						}
+					}
+				}
+			}
+
 			if (switch_strlen_zero(url_user)) {
 				url_user = "service";
 			}
@@ -2446,7 +2466,7 @@
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 				return;
 			}
-			if (!(to_username = switch_core_db_mprintf("%s@%s", (char *) to->a_url->url_user, (char *) to->a_url->url_host))) {
+			if (!(to_username = switch_core_db_mprintf("%s@%s", (char *) to_user, (char *) to_host))) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 				switch_core_db_free(username);
 				return;
@@ -2470,7 +2490,7 @@
 																	  (profile->context && !strcasecmp(profile->context, "_domain_")) ? 
 																	  (char *) from->a_url->url_host : profile->context,
 																	  (profile->pflags & PFLAG_FULL_ID) ? 
-																	  to_username : (char *) to->a_url->url_user
+																	  to_username : (char *) to_user
 																	  )) != 0) {
 				switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 				switch_core_db_free(username);



More information about the Freeswitch-svn mailing list