From cbf80c1a3c6c0aa0ad6b9b7bdf4862f1cf3141d6 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Wed, 2 Apr 2008 19:34:52 +0000 Subject: [PATCH] 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) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@112520 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_misdn.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index b09c11e94f..35b50643b0 100644 --- a/channels/chan_misdn.c +++ b/channels/chan_misdn.c @@ -3424,6 +3424,7 @@ static void update_name(struct ast_channel *tmp, int port, int c) { 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 @@ static void update_name(struct ast_channel *tmp, int port, int c) 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 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char 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 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state, char 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"); }