diff --git a/main/channel.c b/main/channel.c index 967b1f9e06..e1d012d7e5 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4224,6 +4224,26 @@ static void clone_variables(struct ast_channel *original, struct ast_channel *cl } } +/*! + * \pre chan is locked + */ +static void report_new_callerid(const struct ast_channel *chan) +{ + manager_event(EVENT_FLAG_CALL, "NewCallerid", + "Channel: %s\r\n" + "CallerIDNum: %s\r\n" + "CallerIDName: %s\r\n" + "Uniqueid: %s\r\n" + "CID-CallingPres: %d (%s)\r\n", + chan->name, + S_OR(chan->cid.cid_num, ""), + S_OR(chan->cid.cid_name, ""), + chan->uniqueid, + chan->cid.cid_pres, + ast_describe_caller_presentation(chan->cid.cid_pres) + ); +} + /*! \brief Masquerade a channel @@ -4427,6 +4447,7 @@ int ast_do_masquerade(struct ast_channel *original) tmpcid = original->cid; original->cid = clonechan->cid; clonechan->cid = tmpcid; + report_new_callerid(original); /* Restore original timing file descriptor */ ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd); @@ -4524,20 +4545,9 @@ void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char ast_free(chan->cid.cid_ani); chan->cid.cid_ani = ast_strdup(cid_ani); } - manager_event(EVENT_FLAG_CALL, "NewCallerid", - "Channel: %s\r\n" - "CallerIDNum: %s\r\n" - "CallerIDName: %s\r\n" - "Uniqueid: %s\r\n" - "CID-CallingPres: %d (%s)\r\n", - chan->name, - S_OR(chan->cid.cid_num, ""), - S_OR(chan->cid.cid_name, ""), - chan->uniqueid, - chan->cid.cid_pres, - ast_describe_caller_presentation(chan->cid.cid_pres) - ); - + + report_new_callerid(chan); + ast_channel_unlock(chan); }