[Freeswitch-svn] [commit] r7752 - in freeswitch/trunk/src: . include mod/applications/mod_dptools

Freeswitch SVN mikej at freeswitch.org
Tue Feb 26 18:29:58 EST 2008


Author: mikej
Date: Tue Feb 26 18:29:58 2008
New Revision: 7752

Modified:
   freeswitch/trunk/src/include/switch_caller.h
   freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
   freeswitch/trunk/src/switch_caller.c
   freeswitch/trunk/src/switch_channel.c
   freeswitch/trunk/src/switch_ivr.c

Log:
fix for FSCORE-97 and add set_name app to rename channel

Modified: freeswitch/trunk/src/include/switch_caller.h
==============================================================================
--- freeswitch/trunk/src/include/switch_caller.h	(original)
+++ freeswitch/trunk/src/include/switch_caller.h	Tue Feb 26 18:29:58 2008
@@ -93,6 +93,8 @@
 	char *uuid;
 	/*! context */
 	const char *context;
+	/*! profile index */
+	const char *profile_index;
 	/*! flags */
 	switch_caller_profile_flag_t flags;
 	struct switch_caller_profile *originator_caller_profile;

Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c	Tue Feb 26 18:29:58 2008
@@ -345,6 +345,14 @@
 	switch_channel_hangup(switch_core_session_get_channel(session), cause);
 }
 
+SWITCH_STANDARD_APP(set_name_function)
+{
+
+	if (!switch_strlen_zero(data)) {
+		switch_channel_set_name(switch_core_session_get_channel(session), (char *) data);
+	}
+}
+
 SWITCH_STANDARD_APP(answer_function)
 {
 	switch_channel_answer(switch_core_session_get_channel(session));
@@ -1502,6 +1510,7 @@
 	SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
+	SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "log", "Logs a channel variable", LOG_LONG_DESC, log_function, "<varname>", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA);
 	SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);

Modified: freeswitch/trunk/src/switch_caller.c
==============================================================================
--- freeswitch/trunk/src/switch_caller.c	(original)
+++ freeswitch/trunk/src/switch_caller.c	Tue Feb 26 18:29:58 2008
@@ -159,9 +159,15 @@
 	if (!strcasecmp(name, "context")) {
 		return caller_profile->context;
 	}
+
 	if (!strcasecmp(name, "chan_name")) {
 		return caller_profile->chan_name;
 	}
+
+	if (!strcasecmp(name, "profile_index")) {
+		return caller_profile->profile_index;
+	}
+
 	if (!strcasecmp(name, "caller_ton")) {
 		return switch_core_sprintf(caller_profile->pool, "%u", caller_profile->caller_ton);
 	}
@@ -245,6 +251,10 @@
 		switch_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);
 	}
+	if (!switch_strlen_zero(caller_profile->profile_index)) {
+		switch_snprintf(header_name, sizeof(header_name), "%s-Profile-Index", prefix);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%s", caller_profile->profile_index);
+	}
 	if (caller_profile->times) {
 		switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Created-Time", prefix);
 		switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);

Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c	(original)
+++ freeswitch/trunk/src/switch_channel.c	Tue Feb 26 18:29:58 2008
@@ -122,6 +122,7 @@
 	switch_call_cause_t hangup_cause;
 	int vi;
 	int event_count;
+	int profile_index;
 };
 
 SWITCH_DECLARE(const char *) switch_channel_cause2str(switch_call_cause_t cause)
@@ -190,7 +191,7 @@
 	switch_mutex_init(&(*channel)->flag_mutex, SWITCH_MUTEX_NESTED, pool);
 	switch_mutex_init(&(*channel)->profile_mutex, SWITCH_MUTEX_NESTED, pool);
 	(*channel)->hangup_cause = SWITCH_CAUSE_UNALLOCATED;
-	(*channel)->name = "N/A";
+	(*channel)->name = "";
 
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -513,13 +514,22 @@
 
 SWITCH_DECLARE(switch_status_t) switch_channel_set_name(switch_channel_t *channel, const char *name)
 {
+	const char *old = NULL;
+
 	switch_assert(channel != NULL);
+	if (!switch_strlen_zero(channel->name)) {
+		old = channel->name;
+	}
 	channel->name = NULL;
 	if (name) {
 		char *uuid = switch_core_session_get_uuid(channel->session);
 		channel->name = switch_core_session_strdup(channel->session, name);
 		switch_channel_set_variable(channel, SWITCH_CHANNEL_NAME_VARIABLE, name);
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Chan %s [%s]\n", name, uuid);
+		if (old) {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Rename Channel %s->%s [%s]\n", old, name, uuid);
+		} else {
+			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Channel %s [%s]\n", name, uuid);
+		}
 	}
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -527,7 +537,7 @@
 SWITCH_DECLARE(char *) switch_channel_get_name(switch_channel_t *channel)
 {
 	switch_assert(channel != NULL);
-	return channel->name ? channel->name : "N/A";
+	return (!switch_strlen_zero(channel->name)) ? channel->name : "N/A";
 }
 
 SWITCH_DECLARE(switch_status_t) switch_channel_set_variable(switch_channel_t *channel, const char *varname, const char *value)
@@ -1138,7 +1148,8 @@
 
 	caller_profile->next = channel->caller_profile;
 	channel->caller_profile = caller_profile;
-
+	caller_profile->profile_index = switch_core_sprintf(caller_profile->pool, "%d", ++channel->profile_index);
+	
 	switch_mutex_unlock(channel->profile_mutex);
 }
 

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Tue Feb 26 18:29:58 2008
@@ -1341,7 +1341,14 @@
 		if (!(x_callflow = switch_xml_add_child_d(cdr, "callflow", cdr_off++))) {
 			goto error;
 		}
-		switch_xml_set_attr_d(x_callflow, "dialplan", caller_profile->dialplan);
+
+		if (!switch_strlen_zero(caller_profile->dialplan)) {
+			switch_xml_set_attr_d(x_callflow, "dialplan", caller_profile->dialplan);
+		}
+
+		if (!switch_strlen_zero(caller_profile->profile_index)) {
+			switch_xml_set_attr_d(x_callflow, "profile_index", caller_profile->profile_index);
+		}
 
 		if (caller_profile->caller_extension) {
 			switch_caller_application_t *ap;



More information about the Freeswitch-svn mailing list