Add the new ChannelUpdate event to inform manager clients about the PVT ID and some...
authorOlle Johansson <oej@edvina.net>
Fri, 4 May 2007 13:56:25 +0000 (13:56 +0000)
committerOlle Johansson <oej@edvina.net>
Fri, 4 May 2007 13:56:25 +0000 (13:56 +0000)
is needed to follow the call through the PBX.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@63032 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
channels/chan_sip.c

index 6403bf6..fe53030 100644 (file)
@@ -895,6 +895,17 @@ static void mwi_event_cb(const struct ast_event *event, void *userdata)
         * is time to send MWI, since it is only sent with a REGACK. */
 }
 
+/*! \brief Send manager event at call setup to link between Asterisk channel name
+       and IAX2 call identifiers */
+static void iax2_ami_channelupdate(struct chan_iax2_pvt *pvt) 
+{
+       manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
+               "Channel: %s\r\nChanneltype: IAX2\r\nIAX2-callno-local: %d\r\nIAX2-callno-remote: %d\r\nIAX2-peer: %s\r\n",
+               pvt->owner ? pvt->owner->name : "",
+               pvt->callno, pvt->peercallno, pvt->peer ? pvt->peer : "");
+}
+
+
 static void insert_idle_thread(struct iax2_thread *thread)
 {
        if (thread->type == IAX_THREAD_TYPE_DYNAMIC) {
@@ -3332,6 +3343,7 @@ static int iax2_answer(struct ast_channel *c)
        unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
        if (option_debug)
                ast_log(LOG_DEBUG, "Answering IAX2 call\n");
+       iax2_ami_channelupdate(c->tech_pvt);
        return send_command_locked(callno, AST_FRAME_CONTROL, AST_CONTROL_ANSWER, 0, NULL, 0, -1);
 }
 
@@ -3422,6 +3434,7 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
        ast_mutex_unlock(&iaxsl[callno]);
        tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "IAX2/%s-%d", i->host, i->callno);
        ast_mutex_lock(&iaxsl[callno]);
+       iax2_ami_channelupdate(i);
        if (!tmp)
                return NULL;
        tmp->tech = &iax2_tech;
index 8384d00..db1b063 100644 (file)
@@ -4264,6 +4264,12 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
        if (!ast_test_flag(&i->flags[0], SIP_NO_HISTORY))
                append_history(i, "NewChan", "Channel %s - from %s", tmp->name, i->callid);
 
+       /* Inform manager user about new channel and their SIP call ID */
+       if (global_callevents)
+               manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
+                       "Channel: %s\r\nUniqueid: %s\r\nChanneltype: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\n",
+                       tmp->name, tmp->uniqueid, "SIP", i->callid, i->fullcontact);
+
        return tmp;
 }
 
@@ -12601,6 +12607,10 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
                if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
                        if (!reinvite) {
                                ast_queue_control(p->owner, AST_CONTROL_ANSWER);
+                               if (global_callevents)
+                                       manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
+                                               "Channel: %s\r\nChanneltype: %s\r\nUniqueid: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\nPeername: %s\r\n",
+                                               p->owner->name, p->owner->uniqueid, "SIP", p->callid, p->fullcontact, p->peername);
                        } else {        /* RE-invite */
                                ast_queue_frame(p->owner, &ast_null_frame);
                        }
@@ -16240,6 +16250,10 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
        p->jointcapability = oldformat;
        sip_pvt_lock(p);
        tmpc = sip_new(p, AST_STATE_DOWN, host);        /* Place the call */
+       if (global_callevents)
+               manager_event(EVENT_FLAG_SYSTEM, "ChannelUpdate",
+                       "Channel: %s\r\nChanneltype: %s\r\nSIPcallid: %s\r\nSIPfullcontact: %s\r\nPeername: %s\r\n",
+                       p->owner? p->owner->name : "", "SIP", p->callid, p->fullcontact, p->peername);
        sip_pvt_unlock(p);
        if (!tmpc)
                sip_destroy(p);