[Freeswitch-svn] [commit] r3058 - in freeswitch/trunk/src: . include mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Mon Oct 16 00:39:00 EDT 2006


Author: anthm
Date: Mon Oct 16 00:39:00 2006
New Revision: 3058

Modified:
   freeswitch/trunk/src/include/switch_caller.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/trunk/src/switch_caller.c
   freeswitch/trunk/src/switch_core.c

Log:
rpid for sofia

Modified: freeswitch/trunk/src/include/switch_caller.h
==============================================================================
--- freeswitch/trunk/src/include/switch_caller.h	(original)
+++ freeswitch/trunk/src/include/switch_caller.h	Mon Oct 16 00:39:00 2006
@@ -86,6 +86,8 @@
 	char *uuid;
 	/*! context */
 	char *context;
+	/*! flags */
+	switch_caller_profile_flag_t flags;
 	struct switch_caller_profile *next;
 };
 

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Mon Oct 16 00:39:00 2006
@@ -131,6 +131,11 @@
 #define SWITCH_FALSE 0
 #define SWITCH_CORE_QUEUE_LEN 100000
 
+typedef enum {
+	SWITCH_CPF_SCREEN = (1 << 0),
+	SWITCH_CPF_HIDE_NAME = (1 << 1),
+	SWITCH_CPF_HIDE_NUMBER = (1 << 2)
+} switch_caller_profile_flag_t;
 
 typedef enum {
 	SWITCH_AUDIO_COL_STR_TITLE                    = 0x01,

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	Mon Oct 16 00:39:00 2006
@@ -842,6 +842,7 @@
 
 static void do_invite(switch_core_session_t *session)
 {
+	char rpid[1024];
 	private_object_t *tech_pvt;
     switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
@@ -869,6 +870,23 @@
 
 		switch_set_flag_locked(tech_pvt, TFLAG_READY);
 
+		// forge a RPID for now KHR  -- Should wrap this in an if statement so it can be turned on and off
+		if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
+			char *priv = "no";
+			
+			if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME)) {
+				priv = "name";
+				if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+					priv = "yes";
+				}
+			} else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
+				priv = "yes";
+			}
+
+			snprintf(rpid, sizeof(rpid) - 1, "Remote-Party-ID: %s;party=calling;screen=yes;privacy=%s", tech_pvt->from_str, priv);
+								
+		}
+
 		if (!tech_pvt->nh) {
 			tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
 									  SIPTAG_TO_STR(tech_pvt->dest),
@@ -882,6 +900,7 @@
 		}
 
 		nua_invite(tech_pvt->nh,
+				   TAG_IF(rpid, SIPTAG_HEADER_STR(rpid)),
 				   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
 				   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
@@ -897,6 +916,7 @@
 
 static void do_xfer_invite(switch_core_session_t *session)
 {
+	char rpid[1024];
 	private_object_t *tech_pvt;
     switch_channel_t *channel = NULL;
 	switch_caller_profile_t *caller_profile;
@@ -918,7 +938,6 @@
 													 ))) {
 
 		char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
-		
 
 		tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
 								  SIPTAG_TO_STR(tech_pvt->dest),
@@ -932,6 +951,7 @@
 
 
 		nua_invite(tech_pvt->nh2,
+				   TAG_IF(rpid, SIPTAG_HEADER_STR(rpid)),
 				   SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
 				   SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
 				   SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
@@ -3115,6 +3135,7 @@
 {
 	switch_core_session_t *session = sofia_private ? sofia_private->session : NULL;
 	char key[128] = "";
+	sip_unknown_t *un;
 
 
 	if (!session) {
@@ -3212,10 +3233,62 @@
 																	  (profile->pflags & PFLAG_FULL_ID) ? 
 																	  to_username : (char *) to_user
 																	  )) != 0) {
+
+				
+				for (un=sip->sip_unknown; un; un=un->un_next) {
+					// Loop thru Known Headers Here so we can do something with them
+					// John Doe <sip:+19018577141 at 209.247.16.1>;party=calling;screen=yes;privacy=off
+					if (!strncasecmp(un->un_name, "Remote-Party-ID", 15)) {
+						int argc, x, screen = 1;
+						char *mydata, *argv[10] = { 0 };
+						if (!switch_strlen_zero(un->un_value)) { 
+							if ((mydata = strdup(un->un_value))) {
+								argc = switch_separate_string(mydata, ';', argv, (sizeof(argv) / sizeof(argv[0]))); 
+
+								// Do We really need this at this time 
+								// clid_uri = argv[0];
+
+								for (x=1; x < argc && argv[x]; x++){
+									// we dont need to do anything with party yet we should only be seeing party=calling here anyway
+									// maybe thats a dangerous assumption bit oh well yell at me later
+									// if (!strncasecmp(argv[x], "party", 5)) {
+									//	party = argv[x];
+									// } else 
+									if (!strncasecmp(argv[x], "privacy=", 8)) {
+										char *arg = argv[x] + 9;
+
+										if(!strcasecmp(arg, "no")) {
+											switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
+											switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
+										} else if (!strcasecmp(arg, "yes")) {
+											switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+										} else if (!strcasecmp(arg, "full")) {
+											switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+										} else if (!strcasecmp(arg, "name")) {
+											switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME);
+										} else if (!strcasecmp(arg, "number")) {
+											switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NUMBER);
+										}
+									} else if (!strncasecmp(argv[x], "screen=", 7) && screen > 0) {
+										char *arg = argv[x] + 8;
+										if (!strcasecmp(arg, "no")) {
+											screen = 0;
+											switch_clear_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
+										}
+									}
+								}
+								free(mydata);
+							}
+						}
+						break;
+					}
+				}
+
 				switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
 				switch_core_db_free(username);
 				switch_core_db_free(to_username);
 			}
+
 			switch_set_flag_locked(tech_pvt, TFLAG_INBOUND);
 			tech_pvt->sofia_private.session = session;
 			nua_handle_bind(nh, &tech_pvt->sofia_private);

Modified: freeswitch/trunk/src/switch_caller.c
==============================================================================
--- freeswitch/trunk/src/switch_caller.c	(original)
+++ freeswitch/trunk/src/switch_caller.c	Mon Oct 16 00:39:00 2006
@@ -64,6 +64,7 @@
 		profile->source = switch_core_strdup(pool, source);
 		profile->context = switch_core_strdup(pool, context);
 		profile->destination_number = switch_core_strdup(pool, destination_number);
+		switch_set_flag(profile, SWITCH_CPF_SCREEN);
 	}
 
 	return profile;
@@ -88,6 +89,7 @@
 		profile->source = switch_core_session_strdup(session, tocopy->source);
 		profile->context = switch_core_session_strdup(session, tocopy->context);
 		profile->chan_name = switch_core_session_strdup(session, tocopy->chan_name);
+		profile->flags = tocopy->flags;
 	}
 
 	return profile;
@@ -195,6 +197,17 @@
 		snprintf(header_name, sizeof(header_name), "%s-Channel-Name", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->chan_name);
 	}
+
+	snprintf(header_name, sizeof(header_name), "%s-Screen-Bit", prefix);
+	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_SCREEN) ? "yes" : "no");
+
+	snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Name", prefix);
+	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NAME) ? "yes" : "no");
+
+	snprintf(header_name, sizeof(header_name), "%s-Privacy-Hide-Number", prefix);
+	switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
+
+
 
 }
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Mon Oct 16 00:39:00 2006
@@ -1335,7 +1335,7 @@
 																 caller_profile->source,
 																 caller_profile->context,
 																 caller_profile->destination_number);
-					
+					outgoing_profile->flags = caller_profile->flags;
 				}
 			}
 		}



More information about the Freeswitch-svn mailing list