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
This commit is contained in:
Tilghman Lesher 2008-04-02 19:34:52 +00:00
parent 2580dfc6fb
commit cbf80c1a3c
1 changed files with 12 additions and 8 deletions

View File

@ -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");
}