[asterisk-commits] oej: trunk r91409 - /trunk/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 6 09:29:06 CST 2007


Author: oej
Date: Thu Dec  6 09:29:05 2007
New Revision: 91409

URL: http://svn.digium.com/view/asterisk?view=rev&rev=91409
Log:
Changes to manager events in channel.c

- Newstate event
        - Now has "CalleridNum" for numeric caller id, like Newchannel
        - The event does not send "<unknown>" for unknown caller IDs just an empty field
- Newstate and Newchannel events
        - these have changed headers
        "State"         -> ChannelStateDesc     Text based channel state
                        -> ChannelState         Numeric channel state
        - The events does not send "<unknown>" for unknown caller IDs just an empty field

- Newstate event
        - Now has "CalleridNum" for numeric caller id, like Newchannel
        - The event does not send "<unknown>" for unknown caller IDs just an empty field

- Link and Unlink events
        - The "Link" and "Unlink" bridge events in channel.c are now renamed to "Bridge"
        - The link state is in the bridgestate: header as "Link" or "Unlink"
        - For channel.c bridges, "Bridgetype: core" is added. This opens up for
          bridge events in rtp.c and channel drivers

- The "Rename" manager event has a renamed header, to use the same
        terminology for the current channel as other events
        - Oldname       -> Channel

(Moremanager)

Modified:
    trunk/main/channel.c

Modified: trunk/main/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/main/channel.c?view=diff&rev=91409&r1=91408&r2=91409
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Thu Dec  6 09:29:05 2007
@@ -736,13 +736,18 @@
 		 */
 		manager_event(EVENT_FLAG_CALL, "Newchannel",
 			      "Channel: %s\r\n"
-			      "State: %s\r\n"
+			      "ChannelState: %d\r\n"
+			      "ChannelStateDesc: %s\r\n"
 			      "CallerIDNum: %s\r\n"
 			      "CallerIDName: %s\r\n"
+			      "AccountCode: %s\r\n"
 			      "Uniqueid: %s\r\n",
-			      tmp->name, ast_state2str(state),
-			      S_OR(cid_num, "<unknown>"),
-			      S_OR(cid_name, "<unknown>"),
+			      tmp->name, 
+				state, 
+			      ast_state2str(state),
+			      S_OR(cid_num, ""),
+			      S_OR(cid_name, ""),
+			      tmp->accountcode,
 			      tmp->uniqueid);
 	}
 
@@ -3437,7 +3442,7 @@
 
 void ast_change_name(struct ast_channel *chan, char *newname)
 {
-	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
+	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
 	ast_string_field_set(chan, name, newname);
 }
 
@@ -3570,8 +3575,8 @@
 	ast_string_field_set(clone, name, masqn);
 	
 	/* Notify any managers of the change, first the masq then the other */
-	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
-	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
+	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
+	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
 
 	/* Swap the technologies */	
 	t = original->tech;
@@ -3657,7 +3662,7 @@
 	snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig);
 	/* Mangle the name of the clone channel */
 	ast_string_field_set(clone, name, zombn);
-	manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
+	manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
 
 	/* Update the type. */
 	t_pvt = original->monitor;
@@ -3788,15 +3793,15 @@
 	}
 	if (chan->cdr)
 		ast_cdr_setcid(chan->cdr, chan);
-	manager_event(EVENT_FLAG_CALL, "Newcallerid",
+	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, "<Unknown>"),
-				S_OR(chan->cid.cid_name, "<Unknown>"),
+				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)
@@ -3818,13 +3823,14 @@
 	manager_event(EVENT_FLAG_CALL,
 		      "Newstate",
 		      "Channel: %s\r\n"
-		      "State: %s\r\n"
+		      "ChannelState: %d\r\n"
+		      "ChannelStateDesc: %s\r\n"
 		      "CallerIDNum: %s\r\n"
 		      "CallerIDName: %s\r\n"
 		      "Uniqueid: %s\r\n",
-		      chan->name, ast_state2str(chan->_state),
-		      S_OR(chan->cid.cid_num, "<unknown>"),
-		      S_OR(chan->cid.cid_name, "<unknown>"),
+		      chan->name, chan->_state, ast_state2str(chan->_state),
+		      S_OR(chan->cid.cid_num, ""),
+		      S_OR(chan->cid.cid_name, ""),
 		      chan->uniqueid);
 
 	return 0;
@@ -4033,6 +4039,27 @@
 	return c0->tech->early_bridge(c0, c1);
 }
 
+/*! \brief Send manager event for bridge link and unlink events.
+	\param type	1 for core, 2 for native
+*/
+static void manager_bridge_event(int onoff, int type, struct ast_channel *c0, struct ast_channel *c1)
+{
+	manager_event(EVENT_FLAG_CALL, "Bridge",
+			"Bridgestate: %s\r\n"
+		     "Bridgetype: %s\r\n"
+		      "Channel1: %s\r\n"
+		      "Channel2: %s\r\n"
+		      "Uniqueid1: %s\r\n"
+		      "Uniqueid2: %s\r\n"
+		      "CallerID1: %s\r\n"
+		      "CallerID2: %s\r\n",
+			onoff ? "Link" : "Unlink",
+			type == 1 ? "core" : "native",
+			c0->name, c1->name, c0->uniqueid, c1->uniqueid, 
+			S_OR(c0->cid.cid_num, ""), 
+			S_OR(c1->cid.cid_num, ""));
+}
+
 /*! \brief Bridge two channels together */
 enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1,
 					  struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc)
@@ -4086,15 +4113,6 @@
 	c0->_bridge = c1;
 	c1->_bridge = c0;
 
-	/* \todo  XXX here should check that cid_num is not NULL */
-	manager_event(EVENT_FLAG_CALL, "Link",
-		      "Channel1: %s\r\n"
-		      "Channel2: %s\r\n"
-		      "Uniqueid1: %s\r\n"
-		      "Uniqueid2: %s\r\n"
-		      "CallerID1: %s\r\n"
-		      "CallerID2: %s\r\n",
-		      c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
 
 	o0nativeformats = c0->nativeformats;
 	o1nativeformats = c1->nativeformats;
@@ -4111,6 +4129,7 @@
 		ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY);
 	if (!c1->tech->send_digit_begin)
 		ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY);
+	manager_bridge_event(1, 1, c0, c1);
 
 	for (/* ever */;;) {
 		struct timeval now = { 0, };
@@ -4247,15 +4266,7 @@
 		    !(c0->generator || c1->generator)) {
 			if (ast_channel_make_compatible(c0, c1)) {
 				ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name);
-				/* \todo  XXX here should check that cid_num is not NULL */
-                                manager_event(EVENT_FLAG_CALL, "Unlink",
-					      "Channel1: %s\r\n"
-					      "Channel2: %s\r\n"
-					      "Uniqueid1: %s\r\n"
-					      "Uniqueid2: %s\r\n"
-					      "CallerID1: %s\r\n"
-					      "CallerID2: %s\r\n",
-					      c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
+				manager_bridge_event(0, 1, c0, c1);
 				return AST_BRIDGE_FAILED;
 			}
 			o0nativeformats = c0->nativeformats;




More information about the asterisk-commits mailing list