diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-02 19:34:52 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-02 19:34:52 +0000 |
commit | 5fc7941629716375b509232d64fa0cdf6aa026ef (patch) | |
tree | 57ebd3366ad0b401cbd3c8f921ac6ed9363fd93b /channels/chan_misdn.c | |
parent | 6c28f000bfe21b61660a395eb878379e14913da9 (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@112520 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_misdn.c')
-rw-r--r-- | channels/chan_misdn.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c index b09c11e94..35b50643b 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"); } |