[Freeswitch-branches] [commit] r3325 - freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference

Freeswitch SVN knhor at freeswitch.org
Sat Nov 11 23:54:13 EST 2006


Author: knhor
Date: Sat Nov 11 23:54:12 2006
New Revision: 3325

Modified:
   freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
better invalid caller control config entry handling. do not populate default handlers if there are config entries in the profile.

Modified: freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/branches/knhor/trunk/src/mod/applications/mod_conference/mod_conference.c	Sat Nov 11 23:54:12 2006
@@ -3447,7 +3447,6 @@
 	conference->interval = interval;
 
 	if(switch_ivr_digit_stream_parser_new(conference->pool,&conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
-		int i;
 		struct _ccds {
 			char *key;
 			char *digits;
@@ -3467,29 +3466,38 @@
 			{"hangup",		"#",	CALLER_CONTROL_HANGUP},
 		};
 		int ccds_qty = sizeof(ccds)/sizeof(ccds[0]);
+		int i;
 
-		// set the default control handler strings
-		for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<ccds_qty; i++) {
-			status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,ccds[i].digits,ccds[i].action);
+		// count the number of caller control definitons in the profile
+		for (i=0,xml_kvp = switch_xml_child(profile, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
+			i++;
 		}
+		// map in the default control handler strings only if the profile has no caller control definitions
+		if (i == 0) {
+			for(i=0,status=SWITCH_STATUS_SUCCESS; status == SWITCH_STATUS_SUCCESS && i<ccds_qty; i++) {
+				status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,ccds[i].digits,ccds[i].action);
+			}
+		}
 
 		// parse the profile tree for caller control digit strings
 		for (xml_kvp = switch_xml_child(profile, "control"); xml_kvp; xml_kvp = xml_kvp->next) {
-			char *key = (char *) switch_xml_attr_soft(xml_kvp, "action");
-			char *val = (char *) switch_xml_attr_soft(xml_kvp, "digits");
+			char *key = (char *) switch_xml_attr(xml_kvp, "action");
+			char *val = (char *) switch_xml_attr(xml_kvp, "digits");
 
-			if(key != NULL && val != NULL) {
+			if(key != NULL && val != NULL && *key && *val) {
 				// scan through all of the valid actions, and if found,
 				// set the new caller control action digit string, then
 				// stop scanning the table, and go to the next xml kvp.
 				for(i=0,status=SWITCH_STATUS_NOOP; i<ccds_qty && status == SWITCH_STATUS_NOOP; i++) {
 					if(strcasecmp(ccds[i].key,key) == 0) {
-						status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,ccds[i].key,ccds[i].action);
+						status = switch_ivr_digit_stream_parser_set_event(conference->dtmf_parser,val,ccds[i].action);
 					}
 				}
 				if(status == SWITCH_STATUS_NOOP) {
-					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%'.\n",key);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control action name '%s'.\n",key);
 				}
+			} else {
+				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid caller control config entry pair action='%s' digits='%s'\n",key,val);
 			}
 		}
 	} else {



More information about the Freeswitch-branches mailing list