[asterisk-commits] tilghman: trunk r112520 - /trunk/channels/chan_misdn.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 2 14:34:52 CDT 2008


Author: tilghman
Date: Wed Apr  2 14:34:52 2008
New Revision: 112520

URL: http://svn.digium.com/view/asterisk?view=rev&rev=112520
Log:
Make MISDN generate channel rename events when the name changes.
(closes issue #11142)
 Reported by: julianjm
 Patches: 
       chan_misdn_tmpchan_trunk_v1.diff uploaded by julianjm (license 99)

Modified:
    trunk/channels/chan_misdn.c

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?view=diff&rev=112520&r1=112519&r2=112520
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Wed Apr  2 14:34:52 2008
@@ -3424,6 +3424,7 @@
 {
 	int chan_offset = 0;
 	int tmp_port = misdn_cfg_get_next_port(0);
+	char newname[255];
 	for (; tmp_port > 0; tmp_port = misdn_cfg_get_next_port(tmp_port)) {
 		if (tmp_port == port)
 			break;
@@ -3432,10 +3433,12 @@
 	if (c < 0)
 		c = 0;
 
-	ast_string_field_build(tmp, name, "%s/%d-u%d",
-				 misdn_type, chan_offset+c, glob_channel++);
-
-	chan_misdn_log(3 , port, " --> updating channel name to [%s]\n", tmp->name);
+	snprintf(newname, sizeof(newname), "%s/%d-", misdn_type, chan_offset + c);
+	if (strncmp(tmp->name, newname, strlen(newname))) {
+		snprintf(newname, sizeof(newname), "%s/%d-u%d", misdn_type, chan_offset + c, glob_channel++);
+		ast_change_name(tmp, newname);
+		chan_misdn_log(3, port, " --> updating channel name to [%s]\n", tmp->name);
+	}
 }
 
 static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char *exten, char *callerid, int format, int port, int c)
@@ -3449,15 +3452,16 @@
 	for (; tmp_port > 0; tmp_port = misdn_cfg_get_next_port(tmp_port)) {
 		if (tmp_port == port)
 			break;
-		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;	
+		chan_offset += misdn_lib_port_is_pri(tmp_port) ? 30 : 2;
 	}
 	if (c < 0)
 		c = 0;
 
-	if (callerid) 
+	if (callerid) {
 		ast_callerid_parse(callerid, &cid_name, &cid_num);
-
-	tmp = ast_channel_alloc(1, state, cid_num, cid_name, "", exten, "", 0, "%s/%d-u%d", misdn_type, chan_offset + c, glob_channel++);
+	}
+
+	tmp = ast_channel_alloc(1, state, cid_num, cid_name, "", exten, "", 0, "%s/%s%d-u%d", misdn_type, c ? "" : "tmp", chan_offset + c, glob_channel++);
 
 	if (tmp) {
 		chan_misdn_log(2, 0, " --> * NEW CHANNEL dad:%s oad:%s\n", exten, callerid);
@@ -3502,7 +3506,7 @@
 		else
 			tmp->rings = 0;
 		
-	        ast_jb_configure(tmp, misdn_get_global_jbconf());
+		ast_jb_configure(tmp, misdn_get_global_jbconf());
 	} else {
 		chan_misdn_log(-1, 0, "Unable to allocate channel structure\n");
 	}




More information about the asterisk-commits mailing list