[asterisk-commits] russell: branch russell/chan_refcount r91442 - in /team/russell/chan_refcount...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 6 10:23:04 CST 2007


Author: russell
Date: Thu Dec  6 10:23:03 2007
New Revision: 91442

URL: http://svn.digium.com/view/asterisk?view=rev&rev=91442
Log:
resolve, reset

Added:
    team/russell/chan_refcount/doc/manager_1_1.txt
      - copied unchanged from r91438, trunk/doc/manager_1_1.txt
Modified:
    team/russell/chan_refcount/   (props changed)
    team/russell/chan_refcount/UPGRADE.txt
    team/russell/chan_refcount/apps/app_dial.c
    team/russell/chan_refcount/apps/app_meetme.c
    team/russell/chan_refcount/main/cdr.c
    team/russell/chan_refcount/main/channel.c
    team/russell/chan_refcount/main/manager.c

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/russell/chan_refcount/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Dec  6 10:23:03 2007
@@ -1,1 +1,1 @@
-/trunk:1-91403
+/trunk:1-91439

Modified: team/russell/chan_refcount/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/UPGRADE.txt?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/UPGRADE.txt (original)
+++ team/russell/chan_refcount/UPGRADE.txt Thu Dec  6 10:23:03 2007
@@ -139,9 +139,8 @@
 
 Manager:
 
-* The CallerID fields across Manager events have now been made more
-  consistent. CallerID Number will be sent as CallerIDNum and CallerID
-  Name will be sent as CallerIDName wherever used.
+* Manager has been upgraded to version 1.1 with a lot of changes. 
+  Please check doc/manager_1_1.txt for information
 
 * The IAXpeers command output has been changed to more closely resemble the
   output of the SIPpeers command.

Modified: team/russell/chan_refcount/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_dial.c?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/apps/app_dial.c (original)
+++ team/russell/chan_refcount/apps/app_dial.c Thu Dec  6 10:23:03 2007
@@ -426,19 +426,20 @@
 	return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
 }
 
-static void senddialevent(struct ast_channel *src, struct ast_channel *dst)
+static void senddialevent(struct ast_channel *src, struct ast_channel *dst, const char *dialstring)
 {
 	manager_event(EVENT_FLAG_CALL, "Dial", 
 			   "SubEvent: Begin\r\n"
-			   "Source: %s\r\n"
+			   "Channel: %s\r\n"
 			   "Destination: %s\r\n"
 			   "CallerIDNum: %s\r\n"
 			   "CallerIDName: %s\r\n"
-			   "SrcUniqueID: %s\r\n"
-			   "DestUniqueID: %s\r\n",
+			   "UniqueID: %s\r\n"
+			   "DestUniqueID: %s\r\n"
+			   "Dialstring: %s\r\n",
 			   src->name, dst->name, S_OR(src->cid.cid_num, "<unknown>"),
 			   S_OR(src->cid.cid_name, "<unknown>"), src->uniqueid,
-			   dst->uniqueid);
+			   dst->uniqueid, dialstring ? dialstring : "");
 }
 
 static void senddialendevent(const struct ast_channel *src, const char *dialstatus)
@@ -446,8 +447,9 @@
 	manager_event(EVENT_FLAG_CALL, "Dial",
 			   		"SubEvent: End\r\n"
 					"Channel: %s\r\n"
+			   		"UniqueID: %s\r\n"
 					"DialStatus: %s\r\n",
-					src->name, dialstatus);
+					src->name, src->uniqueid, dialstatus);
 }	
 
 /*!
@@ -528,7 +530,7 @@
 			c = o->chan = NULL;
 			num->nochan++;
 		} else {
-			senddialevent(in, c);
+			senddialevent(in, c, stuff);
 			/* After calling, set callerid to extension */
 			if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
 				char cidname[AST_MAX_EXTENSION] = "";
@@ -1469,7 +1471,7 @@
 			ast_free(tmp);
 			continue;
 		} else {
-			senddialevent(chan, tc);
+			senddialevent(chan, tc, numsubst);
 			ast_verb(3, "Called %s\n", numsubst);
 			if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID))
 				ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);

Modified: team/russell/chan_refcount/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/apps/app_meetme.c?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/apps/app_meetme.c (original)
+++ team/russell/chan_refcount/apps/app_meetme.c Thu Dec  6 10:23:03 2007
@@ -1893,7 +1893,7 @@
 				"Meetme: %s\r\n"
 				"Usernum: %d\r\n"
 				"CallerIDnum: %s\r\n"
-			      	"CallerIDname: %s\r\n"
+			      	"CallerIDname: %s\r\n",
 			      	chan->name, chan->uniqueid, conf->confno, 
 				user->user_no,
 				S_OR(user->chan->cid.cid_num, "<unknown>"),

Modified: team/russell/chan_refcount/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/cdr.c?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/main/cdr.c (original)
+++ team/russell/chan_refcount/main/cdr.c Thu Dec  6 10:23:03 2007
@@ -41,6 +41,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/cdr.h"
 #include "asterisk/callerid.h"
+#include "asterisk/manager.h"
 #include "asterisk/causes.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/utils.h"
@@ -892,6 +893,9 @@
 int ast_cdr_setaccount(struct ast_channel *chan, const char *account)
 {
 	struct ast_cdr *cdr = chan->cdr;
+	char buf[BUFSIZ/2] = "";
+	if (!ast_strlen_zero(chan->accountcode))
+		ast_copy_string(buf, chan->accountcode, sizeof(buf));
 
 	ast_string_field_set(chan, accountcode, account);
 	for ( ; cdr ; cdr = cdr->next) {
@@ -899,6 +903,9 @@
 			ast_copy_string(cdr->accountcode, chan->accountcode, sizeof(cdr->accountcode));
 		}
 	}
+
+	/* Signal change of account code to manager */
+	manager_event(EVENT_FLAG_CALL, "NewAccountCode", "Channel: %s\r\nUniqueid: %s\r\nAccountCode: %s\r\nOldAccountCode: %s\r\n", chan->name, chan->uniqueid, chan->accountcode, buf);
 	return 0;
 }
 
@@ -1408,6 +1415,7 @@
 
 	ast_mutex_unlock(&cdr_batch_lock);
 	ast_config_destroy(config);
+	manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: CDR\r\nMessage: CDR subsystem reload requested\r\n");
 
 	return res;
 }

Modified: team/russell/chan_refcount/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/channel.c?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/main/channel.c (original)
+++ team/russell/chan_refcount/main/channel.c Thu Dec  6 10:23:03 2007
@@ -833,13 +833,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);
 	}
 
@@ -3404,7 +3409,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);
 }
 
@@ -3535,8 +3540,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;
@@ -3622,7 +3627,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;
@@ -3753,15 +3758,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)
@@ -3783,13 +3788,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;
@@ -3998,6 +4004,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)
@@ -4051,15 +4078,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;
@@ -4076,6 +4094,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, };
@@ -4212,15 +4231,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;

Modified: team/russell/chan_refcount/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_refcount/main/manager.c?view=diff&rev=91442&r1=91441&r2=91442
==============================================================================
--- team/russell/chan_refcount/main/manager.c (original)
+++ team/russell/chan_refcount/main/manager.c Thu Dec  6 10:23:03 2007
@@ -68,6 +68,7 @@
 #include "asterisk/version.h"
 #include "asterisk/threadstorage.h"
 #include "asterisk/linkedlists.h"
+#include "asterisk/version.h"
 #include "asterisk/term.h"
 #include "asterisk/astobj2.h"
 
@@ -1114,7 +1115,7 @@
 
 static int action_ping(struct mansession *s, const struct message *m)
 {
-	astman_send_response(s, m, "Pong", NULL);
+	astman_send_response(s, m, "Success", "Ping: Pong\r\n");
 	return 0;
 }
 
@@ -1483,9 +1484,9 @@
 
 	res = set_eventmask(s, mask);
 	if (res > 0)
-		astman_send_response(s, m, "Events On", NULL);
+		astman_send_response(s, m, "Success", "Events: On\r\n");
 	else if (res == 0)
-		astman_send_response(s, m, "Events Off", NULL);
+		astman_send_response(s, m, "Success", "Events: Off\r\n");
 
 	return 0;
 }
@@ -1656,6 +1657,7 @@
 	char bridge[256];
 	struct timeval now = ast_tvnow();
 	long elapsed_seconds = 0;
+	int channels = 0;
 	int all = ast_strlen_zero(name); /* set if we want all channels */
 	const char *id = astman_get_header(m,"ActionID");
 	char idText[256] = "";
@@ -1679,10 +1681,12 @@
 
 	/* if we look by name, we break after the first iteration */
 	while (c) {
+		channels++;
+
 		ast_channel_lock(c);
 
 		if (c->_bridge)
-			snprintf(bridge, sizeof(bridge), "Link: %s\r\n", c->_bridge->name);
+			snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", c->_bridge->name, c->_bridge->uniqueid);
 		else
 			bridge[0] = '\0';
 
@@ -1696,8 +1700,9 @@
 			"Channel: %s\r\n"
 			"CallerIDNum: %s\r\n"
 			"CallerIDName: %s\r\n"
-			"Account: %s\r\n"
-			"State: %s\r\n"
+			"Accountcode: %s\r\n"
+			"ChannelState: %d\r\n"
+			"ChannelStateDesc: %s\r\n"
 			"Context: %s\r\n"
 			"Extension: %s\r\n"
 			"Priority: %d\r\n"
@@ -1707,9 +1712,10 @@
 			"%s"
 			"\r\n",
 			c->name,
-			S_OR(c->cid.cid_num, "<unknown>"),
-			S_OR(c->cid.cid_name, "<unknown>"),
+			S_OR(c->cid.cid_num, ""),
+			S_OR(c->cid.cid_name, ""),
 			c->accountcode,
+			c->_state,
 			ast_state2str(c->_state), c->context,
 			c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText);
 		} else {
@@ -1747,7 +1753,8 @@
 	astman_append(s,
 	"Event: StatusComplete\r\n"
 	"%s"
-	"\r\n",idText);
+	"Items: %d\r\n"
+	"\r\n",idText, channels);
 
 	return 0;
 }
@@ -2520,8 +2527,10 @@
 	AST_RWLIST_UNLOCK(&actions);
 
 	if (!tmp) {
+		char buf[BUFSIZ];
+		snprintf(buf, sizeof(buf), "Invalid/unknown command: %s. Use Action: ListCommands to show available commands.", action);
 		ast_mutex_lock(&s->__lock);
-		astman_send_error(s, m, "Invalid/unknown command. Use Action: ListCommands to show available commands.");
+		astman_send_error(s, m, buf);
 		ast_mutex_unlock(&s->__lock);
 	}
 	if (ret)
@@ -3660,6 +3669,8 @@
 	if (newhttptimeout > 0)
 		httptimeout = newhttptimeout;
 
+	manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: Manager\r\nStatus: %s\r\nMessage: Manager reload Requested\r\n", manager_enabled ? "Enabled" : "Disabled");
+
 	server_start(&ami_desc);
 	if (ssl_setup(amis_desc.tls_cfg))
 		server_start(&amis_desc);
@@ -3673,6 +3684,5 @@
 
 int reload_manager(void)
 {
-	manager_event(EVENT_FLAG_SYSTEM, "Reload", "Message: Reload Requested\r\n");
 	return __init_manager(1);
 }




More information about the asterisk-commits mailing list