[asterisk-commits] oej: branch oej/tilghman-chanvar-backport r222097 - in /team/oej/tilghman-cha...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 2 14:10:34 CDT 2009


Author: oej
Date: Fri Oct  2 14:10:30 2009
New Revision: 222097

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=222097
Log:
Committing without testing, since Asterisk 1.4 doesn't compile on snow leopard... Tss. tss. 

Modified:
    team/oej/tilghman-chanvar-backport/apps/app_dial.c
    team/oej/tilghman-chanvar-backport/apps/app_meetme.c
    team/oej/tilghman-chanvar-backport/apps/app_queue.c
    team/oej/tilghman-chanvar-backport/apps/app_voicemail.c
    team/oej/tilghman-chanvar-backport/channels/chan_iax2.c
    team/oej/tilghman-chanvar-backport/channels/chan_sip.c
    team/oej/tilghman-chanvar-backport/configs/manager.conf.sample
    team/oej/tilghman-chanvar-backport/include/asterisk/manager.h
    team/oej/tilghman-chanvar-backport/main/channel.c
    team/oej/tilghman-chanvar-backport/main/manager.c
    team/oej/tilghman-chanvar-backport/utils/Makefile

Modified: team/oej/tilghman-chanvar-backport/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/apps/app_dial.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/apps/app_dial.c (original)
+++ team/oej/tilghman-chanvar-backport/apps/app_dial.c Fri Oct  2 14:10:30 2009
@@ -400,7 +400,7 @@
 static void senddialevent(struct ast_channel *src, struct ast_channel *dst)
 {
 	/* XXX do we need also CallerIDnum ? */
-	manager_event(EVENT_FLAG_CALL, "Dial", 
+	ast_channel_manager_event(src, dst, EVENT_FLAG_CALL, "Dial", 
 			   "Source: %s\r\n"
 			   "Destination: %s\r\n"
 			   "CallerID: %s\r\n"

Modified: team/oej/tilghman-chanvar-backport/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/apps/app_meetme.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/apps/app_meetme.c (original)
+++ team/oej/tilghman-chanvar-backport/apps/app_meetme.c Fri Oct  2 14:10:30 2009
@@ -1818,7 +1818,7 @@
 	ast_log(LOG_DEBUG, "Placed channel %s in %s conf %d\n", chan->name, dahdi_chan_name, conf->zapconf);
 
 	if (!sent_event) {
-		manager_event(EVENT_FLAG_CALL, "MeetmeJoin", 
+		ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeJoin", 
 			      "Channel: %s\r\n"
 			      "Uniqueid: %s\r\n"
 			      "Meetme: %s\r\n"
@@ -1993,7 +1993,7 @@
 					break;
 				}
 
-				manager_event(EVENT_FLAG_CALL, "MeetmeMute", 
+				ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeMute", 
 						"Channel: %s\r\n"
 						"Uniqueid: %s\r\n"
 						"Meetme: %s\r\n"
@@ -2011,7 +2011,7 @@
 					break;
 				}
 
-				manager_event(EVENT_FLAG_CALL, "MeetmeMute", 
+				ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeMute", 
 						"Channel: %s\r\n"
 						"Uniqueid: %s\r\n"
 						"Meetme: %s\r\n"
@@ -2074,7 +2074,7 @@
 						if (!user->talking && totalsilence < MEETME_DELAYDETECTTALK) {
 							user->talking = 1;
 							if (confflags & CONFFLAG_MONITORTALKER)
-								manager_event(EVENT_FLAG_CALL, "MeetmeTalking",
+								ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeTalking",
 								      "Channel: %s\r\n"
 								      "Uniqueid: %s\r\n"
 								      "Meetme: %s\r\n"
@@ -2085,7 +2085,7 @@
 						if (user->talking && totalsilence > MEETME_DELAYDETECTENDTALK) {
 							user->talking = 0;
 							if (confflags & CONFFLAG_MONITORTALKER)
-								manager_event(EVENT_FLAG_CALL, "MeetmeTalking",
+								ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeTalking",
 								      "Channel: %s\r\n"
 								      "Uniqueid: %s\r\n"
 								      "Meetme: %s\r\n"
@@ -2441,7 +2441,7 @@
 		sec = (now - user->jointime) % 60;
 
 		if (sent_event) {
-			manager_event(EVENT_FLAG_CALL, "MeetmeLeave",
+			ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MeetmeLeave",
 				      "Channel: %s\r\n"
 				      "Uniqueid: %s\r\n"
 				      "Meetme: %s\r\n"

Modified: team/oej/tilghman-chanvar-backport/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/apps/app_queue.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/apps/app_queue.c (original)
+++ team/oej/tilghman-chanvar-backport/apps/app_queue.c Fri Oct  2 14:10:30 2009
@@ -1487,7 +1487,7 @@
 		ast_copy_string(qe->context, q->context, sizeof(qe->context));
 		q->count++;
 		res = 0;
-		manager_event(EVENT_FLAG_CALL, "Join",
+		ast_channel_manager_event(qe->chan, NULL, EVENT_FLAG_CALL, "Join",
 			"Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n",
 			qe->chan->name,
 			S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */
@@ -1694,7 +1694,7 @@
 			q->count--;
 
 			/* Take us out of the queue */
-			manager_event(EVENT_FLAG_CALL, "Leave",
+			ast_channel_manager_event(qe->chan, NULL, EVENT_FLAG_CALL, "Leave",
 				"Channel: %s\r\nQueue: %s\r\nCount: %d\r\nUniqueid: %s\r\n",
 				qe->chan->name, q->name,  q->count, qe->chan->uniqueid);
 			if (option_debug)

Modified: team/oej/tilghman-chanvar-backport/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/apps/app_voicemail.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/apps/app_voicemail.c (original)
+++ team/oej/tilghman-chanvar-backport/apps/app_voicemail.c Fri Oct  2 14:10:30 2009
@@ -5147,7 +5147,7 @@
 	if (ast_app_has_voicemail(ext_context, NULL)) {
 		ast_app_inboxcount(ext_context, &newmsgs, &oldmsgs);
 	}
-	manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs);
 	run_externnotify(vmu->context, vmu->mailbox);
 	return 0;
 }
@@ -7877,7 +7877,7 @@
 		close_mailbox(&vms, vmu);
 	if (valid) {
 		snprintf(ext_context, sizeof(ext_context), "%s@%s", vms.username, vmu->context);
-		manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
+		ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s\r\nWaiting: %d\r\n", ext_context, has_voicemail(ext_context, NULL));
 		run_externnotify(vmu->context, vmu->mailbox);
 	}
 #ifdef IMAP_STORAGE

Modified: team/oej/tilghman-chanvar-backport/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/channels/chan_iax2.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/channels/chan_iax2.c (original)
+++ team/oej/tilghman-chanvar-backport/channels/chan_iax2.c Fri Oct  2 14:10:30 2009
@@ -8808,7 +8808,7 @@
 				if (ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED)) {
 				        /* Generate Manager Hold event, if necessary*/
 					if (iaxs[fr->callno]->owner) {
-						manager_event(EVENT_FLAG_CALL, "Hold",
+						ast_channel_manager_event(iaxs[fr->callno]->owner, NULL,EVENT_FLAG_CALL, "Hold",
 							"Channel: %s\r\n"
 							"Uniqueid: %s\r\n",
 							iaxs[fr->callno]->owner->name, 
@@ -8834,7 +8834,7 @@
 				if (ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED)) {
 				        /* Generate Manager Unhold event, if necessary*/
 					if (iaxs[fr->callno]->owner && ast_test_flag(iaxs[fr->callno], IAX_QUELCH)) {
-						manager_event(EVENT_FLAG_CALL, "Unhold",
+						ast_channel_manager_event(iaxs[fr->callno]->owner, NULL,EVENT_FLAG_CALL, "Unhold",
 							"Channel: %s\r\n"
 							"Uniqueid: %s\r\n",
 							iaxs[fr->callno]->owner->name, 

Modified: team/oej/tilghman-chanvar-backport/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/channels/chan_sip.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/channels/chan_sip.c (original)
+++ team/oej/tilghman-chanvar-backport/channels/chan_sip.c Fri Oct  2 14:10:30 2009
@@ -5209,7 +5209,7 @@
 	if (global_notifyhold && (!holdstate || !ast_test_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD)))
 		sip_peer_hold(dialog, holdstate);
 	if (global_callevents)
-		manager_event(EVENT_FLAG_CALL, holdstate ? "Hold" : "Unhold",
+		ast_channel_manager_event(dialog->owner, NULL, EVENT_FLAG_CALL, holdstate ? "Hold" : "Unhold",
 			      "Channel: %s\r\n"
 			      "Uniqueid: %s\r\n",
 			      dialog->owner->name, 

Modified: team/oej/tilghman-chanvar-backport/configs/manager.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/configs/manager.conf.sample?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/configs/manager.conf.sample (original)
+++ team/oej/tilghman-chanvar-backport/configs/manager.conf.sample Fri Oct  2 14:10:30 2009
@@ -40,6 +40,11 @@
 ;
 ;timestampevents = yes
 
+; Display certain channel variables every time a channel-oriented
+; event is emitted:
+;
+;channelvars = var1,var2,var3
+
 ;[mark]
 ;secret = mysecret
 ;deny=0.0.0.0/0.0.0.0

Modified: team/oej/tilghman-chanvar-backport/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/include/asterisk/manager.h?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/include/asterisk/manager.h (original)
+++ team/oej/tilghman-chanvar-backport/include/asterisk/manager.h Fri Oct  2 14:10:30 2009
@@ -126,7 +126,25 @@
 	\param event	Event name
 	\param contents	Contents of event
 */
-int __attribute__((format(printf, 3,4))) manager_event(int category, const char *event, const char *contents, ...);
+
+#define manager_event(category, event, contents, ...) __ast_channel_manager_event(category, event, 0, NULL, contents, ## __VA_ARGS__)
+#define ast_channel_manager_event(chan1, chan2, category, event, contents, ...)  \
+	do { \
+		struct ast_channel *_chans[] = { chan1, chan2 }; \
+		__ast_channel_manager_event(category, event, 2, _chans, contents , ## __VA_ARGS__); \
+	} while (0)
+
+/*! External routines may send asterisk manager events this way
+ * \param chan1 First channel related to this event (or NULL if none are relevant)
+ * \param chan2 Second channel related to this event (or NULL if none are relevant)
+ * \param category Event category, matches manager authorization
+ * \param event Event name
+ * \param contents Format string describing event
+ * \since 1.4-edv
+*/
+int __ast_channel_manager_event(int category, const char *event, int chancount,
+		struct ast_channel **chans, const char *contents, ...);
+		//struct ast_channel **chans, const char *contents, ...) __attribute__((format(printf, 6, 7)));
 
 /*! Get header from mananger transaction */
 const char *astman_get_header(const struct message *m, char *var);

Modified: team/oej/tilghman-chanvar-backport/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/main/channel.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/main/channel.c (original)
+++ team/oej/tilghman-chanvar-backport/main/channel.c Fri Oct  2 14:10:30 2009
@@ -881,7 +881,7 @@
 	 * a lot of data into this func to do it here!
 	 */
 	if (!ast_strlen_zero(name_fmt)) {
-		manager_event(EVENT_FLAG_CALL, "Newchannel",
+		ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Newchannel",
 		      "Channel: %s\r\n"
 		      "State: %s\r\n"
 		      "CallerIDNum: %s\r\n"
@@ -1570,7 +1570,7 @@
 	}
 			
 	ast_channel_unlock(chan);
-	manager_event(EVENT_FLAG_CALL, "Hangup",
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
 			"Cause: %d\r\n"
@@ -3687,7 +3687,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);
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid);
 	ast_string_field_set(chan, name, newname);
 }
 
@@ -3765,7 +3765,7 @@
  */
 static void report_new_callerid(const struct ast_channel *chan)
 {
-	manager_event(EVENT_FLAG_CALL, "Newcallerid",
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Newcallerid",
 				"Channel: %s\r\n"
 				"CallerID: %s\r\n"
 				"CallerIDName: %s\r\n"
@@ -3842,8 +3842,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);
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid);
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid);
 
 	/* Swap the technologies */	
 	t = original->tech;
@@ -3932,7 +3932,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);
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
 
 	/* Update the type. */
 	t_pvt = original->monitor;
@@ -4037,7 +4037,7 @@
 		if (option_debug)
 			ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
 		ast_channel_unlock(clone);
-		manager_event(EVENT_FLAG_CALL, "Hangup",
+		ast_channel_manager_event(clone, NULL, EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
 			"Cause: %d\r\n"
@@ -4105,7 +4105,7 @@
 	chan->_state = state;
 	ast_device_state_changed_literal(name);
 	/* setstate used to conditionally report Newchannel; this is no more */
-	manager_event(EVENT_FLAG_CALL,
+	ast_channel_manager_event(chan, NULL, EVENT_FLAG_CALL,
 		      "Newstate",
 		      "Channel: %s\r\n"
 		      "State: %s\r\n"
@@ -4415,7 +4415,7 @@
 	c1->_bridge = c0;
 
 	/* \todo  XXX here should check that cid_num is not NULL */
-	manager_event(EVENT_FLAG_CALL, "Link",
+	ast_channel_manager_event(c0, c1, EVENT_FLAG_CALL, "Link",
 		      "Channel1: %s\r\n"
 		      "Channel2: %s\r\n"
 		      "Uniqueid1: %s\r\n"
@@ -4538,7 +4538,7 @@
 			ast_set_flag(c1, AST_FLAG_NBRIDGE);
 			if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, to)) == AST_BRIDGE_COMPLETE) {
 				/* \todo  XXX here should check that cid_num is not NULL */
-				manager_event(EVENT_FLAG_CALL, "Unlink",
+				ast_channel_manager_event(c0, c1, EVENT_FLAG_CALL, "Unlink",
 					      "Channel1: %s\r\n"
 					      "Channel2: %s\r\n"
 					      "Uniqueid1: %s\r\n"
@@ -4586,7 +4586,7 @@
 			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",
+                                ast_channel_manager_event(c0, c1, EVENT_FLAG_CALL, "Unlink",
 					      "Channel1: %s\r\n"
 					      "Channel2: %s\r\n"
 					      "Uniqueid1: %s\r\n"
@@ -4622,7 +4622,7 @@
 	c1->_bridge = NULL;
 
 	/* \todo  XXX here should check that cid_num is not NULL */
-	manager_event(EVENT_FLAG_CALL, "Unlink",
+	ast_channel_manager_event(c0, c1, EVENT_FLAG_CALL, "Unlink",
 		      "Channel1: %s\r\n"
 		      "Channel2: %s\r\n"
 		      "Uniqueid1: %s\r\n"

Modified: team/oej/tilghman-chanvar-backport/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/main/manager.c?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/main/manager.c (original)
+++ team/oej/tilghman-chanvar-backport/main/manager.c Fri Oct  2 14:10:30 2009
@@ -97,6 +97,17 @@
 	char eventdata[1];
 };
 
+struct manager_channel_variable {
+	AST_LIST_ENTRY(manager_channel_variable) entry;
+	unsigned int isfunc:1;
+	char name[0]; /* allocate off the end the real size. */
+};
+
+/* Forward declaration */
+static void free_channelvars(void);
+
+static AST_RWLIST_HEAD_STATIC(channelvars, manager_channel_variable);
+
 static int enabled;
 static int portno = DEFAULT_MANAGER_PORT;
 static int asock = -1;
@@ -116,6 +127,9 @@
 
 AST_THREADSTORAGE(astman_append_buf, astman_append_buf_init);
 #define ASTMAN_APPEND_BUF_INITSIZE   256
+
+	
+AST_THREADSTORAGE(manager_event_funcbuf);
 
 static struct permalias {
 	int num;
@@ -248,6 +262,27 @@
 static struct manager_action *first_action;
 AST_RWLOCK_DEFINE_STATIC(actionlock);
 
+static void append_channel_vars(struct ast_str **pbuf, struct ast_channel *chan)
+{
+	struct manager_channel_variable *var;
+	AST_RWLIST_RDLOCK(&channelvars);
+	AST_LIST_TRAVERSE(&channelvars, var, entry) {
+		const char *val = "";
+		if (var->isfunc) {
+			struct ast_str *res = ast_str_thread_get(&manager_event_funcbuf, 16);
+			int ret;
+			if (res && (ret = ast_func_read2(chan, var->name, &res, 0)) == 0) {
+				val = ast_str_buffer(res);
+			}
+		} else {
+			val = pbx_builtin_getvar_helper(chan, var->name);
+		}
+		ast_str_append(pbuf, 0, "ChanVariable(%s): %s=%s\r\n", chan->name, var->name, val ? val : "");
+	}
+	AST_RWLIST_UNLOCK(&channelvars);
+}
+
+
 /*! \brief Convert authority code to string with serveral options */
 static char *authority_to_str(int authority, char *res, int reslen)
 {
@@ -1867,7 +1902,7 @@
 	if (!chan)
 		snprintf(requested_channel, AST_CHANNEL_NAME, "%s/%s", in->tech, in->data);	
 	/* Tell the manager what happened with the channel */
-	manager_event(EVENT_FLAG_CALL, "OriginateResponse",
+	ast_channel_manager_event(chan ? chan : NULL, NULL, EVENT_FLAG_CALL, "OriginateResponse",
 		"%s%s"
 		"Response: %s\r\n"
 		"Channel: %s\r\n"
@@ -2555,13 +2590,14 @@
 }
 
 /*! \brief  manager_event: Send AMI event to client */
-int manager_event(int category, const char *event, const char *fmt, ...)
+int __ast_channel_manager_event(int category, const char *event, int chancount, struct ast_channel **chans, const char *fmt, ...)
 {
 	struct mansession_session *s;
 	char auth[80];
 	va_list ap;
 	struct timeval now;
 	struct ast_dynamic_str *buf;
+	int i;
 
 	/* Abort if there aren't any manager sessions */
 	if (!num_sessions)
@@ -2584,6 +2620,10 @@
 	va_start(ap, fmt);
 	ast_dynamic_str_thread_append_va(&buf, 0, &manager_event_buf, fmt, ap);
 	va_end(ap);
+
+	for (i = 0; i < chancount; i++) {
+		append_channel_vars(&buf, chans[i]);
+	}
 	
 	ast_dynamic_str_thread_append(&buf, 0, &manager_event_buf, "\r\n");	
 	
@@ -3006,6 +3046,18 @@
 	.callback = mxml_http_callback,
 };
 
+
+/* clear out every entry in the channelvar list */
+static void free_channelvars(void)
+{
+	struct manager_channel_variable *var;
+	AST_RWLIST_WRLOCK(&channelvars);
+	while ((var = AST_RWLIST_REMOVE_HEAD(&channelvars, entry))) {
+		ast_free(var);
+	}
+	AST_RWLIST_UNLOCK(&channelvars);
+}
+
 static int registered = 0;
 static int webregged = 0;
 
@@ -3084,6 +3136,22 @@
 
 	if ((val = ast_variable_retrieve(cfg, "general", "httptimeout")))
 		newhttptimeout = atoi(val);
+	if ((val = ast_variable_retrieve(cfg, "general", "channelvars"))) {
+		struct manager_channel_variable *mcv;
+			char *remaining = ast_strdupa(val), *next;
+			AST_RWLIST_WRLOCK(&channelvars);
+			while ((next = strsep(&remaining, ",|"))) {
+				if (!(mcv = ast_calloc(1, sizeof(*mcv) + strlen(next) + 1))) {
+					break;
+				}
+				strcpy(mcv->name, next); /* SAFE */
+				if (strchr(next, '(')) {
+					mcv->isfunc = 1;
+				}
+				AST_RWLIST_INSERT_TAIL(&channelvars, mcv, entry);
+			}
+			AST_RWLIST_UNLOCK(&channelvars);
+	}
 
 	memset(&ba, 0, sizeof(ba));
 	ba.sin_family = AF_INET;

Modified: team/oej/tilghman-chanvar-backport/utils/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/oej/tilghman-chanvar-backport/utils/Makefile?view=diff&rev=222097&r1=222096&r2=222097
==============================================================================
--- team/oej/tilghman-chanvar-backport/utils/Makefile (original)
+++ team/oej/tilghman-chanvar-backport/utils/Makefile Fri Oct  2 14:10:30 2009
@@ -26,7 +26,7 @@
 #     changes are made to ast_expr2.y or ast_expr2.fl (or the corresponding .c files),
 #     as a regression test. Others (mere mortals?) need not bother, but they are
 #     more than welcome to play! The regression test itself is in expr2.testinput.
-ALL_UTILS:=astman smsq stereorize streamplayer aelparse muted
+ALL_UTILS:=#astman smsq stereorize streamplayer aelparse muted
 UTILS:=$(ALL_UTILS)
 
 include $(ASTTOPDIR)/Makefile.rules




More information about the asterisk-commits mailing list