[asterisk-commits] oej: branch oej/fagi-adventures r103475 - in /team/oej/fagi-adventures: ./ in...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 12 14:47:57 CST 2008


Author: oej
Date: Tue Feb 12 14:47:56 2008
New Revision: 103475

URL: http://svn.digium.com/view/asterisk?view=rev&rev=103475
Log:
Add flags on "show channel" to show that a channel is controlled by AGI in any way.

Modified:
    team/oej/fagi-adventures/   (props changed)
    team/oej/fagi-adventures/include/asterisk/channel.h
    team/oej/fagi-adventures/main/cli.c
    team/oej/fagi-adventures/res/res_agi.c

Propchange: team/oej/fagi-adventures/
------------------------------------------------------------------------------
    automerge = Work, work, work

Modified: team/oej/fagi-adventures/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/fagi-adventures/include/asterisk/channel.h?view=diff&rev=103475&r1=103474&r2=103475
==============================================================================
--- team/oej/fagi-adventures/include/asterisk/channel.h (original)
+++ team/oej/fagi-adventures/include/asterisk/channel.h Tue Feb 12 14:47:56 2008
@@ -562,6 +562,12 @@
 	/*! This flag indicates that on a masquerade, an active stream should not
 	 *  be carried over */
 	AST_FLAG_MASQ_NOSTREAM = (1 << 16),
+	/*! If the flag is controlled by AGI (not FastAGI) */
+	AST_FLAG_AGI =           (1 << 17),
+	/*! If the flag is controlled by FastAGI  */
+	AST_FLAG_FASTAGI =       (1 << 18),
+	/*! If the flag is controlled by AsyncAGI  */
+	AST_FLAG_ASYNCAGI =      (1 << 19),
 };
 
 /*! \brief ast_bridge_config flags */

Modified: team/oej/fagi-adventures/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/fagi-adventures/main/cli.c?view=diff&rev=103475&r1=103474&r2=103475
==============================================================================
--- team/oej/fagi-adventures/main/cli.c (original)
+++ team/oej/fagi-adventures/main/cli.c Tue Feb 12 14:47:56 2008
@@ -626,6 +626,20 @@
 	}
 
 	return RESULT_SUCCESS;
+}
+
+/*! \brief Add a marker before the app if the channel is controlled by AGI/FastAGI or AsyncAGI 
+	Used for "show channels"
+*/
+static const char *agi_flag(struct ast_channel *chan)
+{
+	if (ast_test_flag(chan, AST_FLAG_AGI))
+		return "[AGI]  ";
+	if (ast_test_flag(chan, AST_FLAG_FASTAGI))
+		return "[FAGI] ";
+	if (ast_test_flag(chan, AST_FLAG_ASYNCAGI))
+		return "[AAGI] ";
+	return "";
 }
 
 static char *handle_chanlist(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -723,7 +737,7 @@
 				if (!ast_strlen_zero(c->context) && !ast_strlen_zero(c->exten)) 
 					snprintf(locbuf, sizeof(locbuf), "%s@%s:%d", c->exten, c->context, c->priority);
 				if (c->appl)
-					snprintf(appdata, sizeof(appdata), "%s(%s)", c->appl, S_OR(c->data, ""));
+					snprintf(appdata, sizeof(appdata), "%s%s(%s)", agi_flag(c), c->appl, S_OR(c->data, ""));
 				ast_cli(fd, FORMAT_STRING, c->name, locbuf, ast_state2str(c->_state), appdata);
 			}
 		}

Modified: team/oej/fagi-adventures/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/oej/fagi-adventures/res/res_agi.c?view=diff&rev=103475&r1=103474&r2=103475
==============================================================================
--- team/oej/fagi-adventures/res/res_agi.c (original)
+++ team/oej/fagi-adventures/res/res_agi.c Tue Feb 12 14:47:56 2008
@@ -204,7 +204,7 @@
 	return cmd;
 }
 
-/* channel is locked when calling this one either from the CLI or manager thread */
+/*! \brief channel is locked when calling this one either from the CLI or manager thread */
 static int add_agi_cmd(struct ast_channel *chan, const char *cmd_buff, const char *cmd_id)
 {
 	struct ast_datastore *store;
@@ -423,6 +423,8 @@
 		returnstatus = AGI_RESULT_FAILURE;
 		goto quit;
 	}
+	ast_set_flag(chan, AST_FLAG_ASYNCAGI);
+
 	agi_buffer[res] = '\0';
 	/* encode it and send it thru the manager so whoever is going to take 
 	   care of AGI commands on this channel can decide which AGI commands 
@@ -606,8 +608,10 @@
 	sigset_t signal_set, old_set;
 	struct stat st;
 
-	if (!strncasecmp(script, "agi://", 6))
+	if (!strncasecmp(script, "agi://", 6)) {
+		ast_set_flag(chan, AST_FLAG_FASTAGI);
 		return launch_netscript(script, argv, fds, efd, opid);
+	}
 	if (!strncasecmp(script, "agi:async", sizeof("agi:async")-1))
 		return launch_asyncagi(chan, argv, efd);
 	
@@ -730,6 +734,7 @@
 		close(audio[0]);
 
 	*opid = pid;
+	ast_set_flag(chan, AST_FLAG_AGI);
 	return AGI_RESULT_SUCCESS;
 }
 
@@ -2909,6 +2914,9 @@
 			close(efd);
 		ast_unreplace_sigchld();
 	} 
+	ast_clear_flag(chan, AST_FLAG_AGI);
+	ast_clear_flag(chan, AST_FLAG_FASTAGI);
+	ast_clear_flag(chan, AST_FLAG_ASYNCAGI);
 
 	switch (res) {
 	case AGI_RESULT_SUCCESS:




More information about the asterisk-commits mailing list