[asterisk-commits] trunk r10287 - in /trunk: apps/app_mixmonitor.c cli.c include/asterisk/cli.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Feb 16 10:37:07 MST 2006


Author: russell
Date: Thu Feb 16 11:37:03 2006
New Revision: 10287

URL: http://svn.digium.com/view/asterisk?rev=10287&view=rev
Log:
add StopMixMonitor application (issue #6122, with mods)
Rename and export ast_complete_channels for use by cli completion functions
that want to complete from the list of active channels

Modified:
    trunk/apps/app_mixmonitor.c
    trunk/cli.c
    trunk/include/asterisk/cli.h

Modified: trunk/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_mixmonitor.c?rev=10287&r1=10286&r2=10287&view=diff
==============================================================================
--- trunk/apps/app_mixmonitor.c (original)
+++ trunk/apps/app_mixmonitor.c Thu Feb 16 11:37:03 2006
@@ -78,6 +78,14 @@
 "Any strings matching ^{X} will be unescaped to ${X} and \n"
 "all variables will be evaluated at that time.\n"
 "The variable MIXMONITOR_FILENAME will contain the filename used to record.\n"
+"";
+
+static const char *stop_app = "StopMixMonitor";
+static const char *stop_synopsis = "Stop recording a call through MixMonitor";
+static const char *stop_desc = ""
+"  StopMixMonitor()\n\n"
+"Stops the audio recording that was started with a call to MixMonitor()\n"
+"on the current channel.\n"
 "";
 
 LOCAL_USER_DECL;
@@ -397,6 +405,25 @@
 	return 0;
 }
 
+static int stop_mixmonitor_exec(struct ast_channel *chan, void *data)
+{
+	struct localuser *u;
+
+	LOCAL_USER_ADD(u);
+
+	if (!ast_mutex_lock(&chan->lock)) {
+		ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
+		ast_mutex_unlock(&chan->lock);
+	} else {
+		ast_log(LOG_WARNING, "Could not lock %s to stop MixMonitor on it\n", 
+				chan->name);
+	}
+
+	LOCAL_USER_REMOVE(u);
+
+	return 0;
+}
+
 static int mixmonitor_cli(int fd, int argc, char **argv) 
 {
 	struct ast_channel *chan;
@@ -419,20 +446,26 @@
 	return RESULT_SUCCESS;
 }
 
+static char *complete_mixmonitor_cli(const char *line, const char *word, int pos, int state)
+{
+	return ast_complete_channels(line, word, pos, state, 2);
+}
 
 static struct ast_cli_entry cli_mixmonitor = {
 	{ "mixmonitor", NULL, NULL },
 	mixmonitor_cli, 
-	"Execute a MixMonitor command",
-	"mixmonitor <start|stop> <chan_name> [<args>]\n"
+	"Execute a MixMonitor command. The optional arguments are passed to the\n"
+	"MixMonitor application when the 'start' command is used.\n",
+	"mixmonitor <start|stop> <chan_name> [args]\n",
+	complete_mixmonitor_cli
 };
 
-
 int unload_module(void)
 {
 	int res;
 
 	res = ast_cli_unregister(&cli_mixmonitor);
+	res |= ast_unregister_application(stop_app);
 	res |= ast_unregister_application(app);
 	
 	STANDARD_HANGUP_LOCALUSERS;
@@ -446,6 +479,7 @@
 
 	res = ast_cli_register(&cli_mixmonitor);
 	res |= ast_register_application(app, mixmonitor_exec, synopsis, desc);
+	res |= ast_register_application(stop_app, stop_mixmonitor_exec, stop_synopsis, stop_desc);
 
 	return res;
 }

Modified: trunk/cli.c
URL: http://svn.digium.com/view/asterisk/trunk/cli.c?rev=10287&r1=10286&r2=10287&view=diff
==============================================================================
--- trunk/cli.c (original)
+++ trunk/cli.c Thu Feb 16 11:37:03 2006
@@ -781,7 +781,7 @@
 	return NULL;
 }
 
-static char *complete_ch_helper(const char *line, const char *word, int pos, int state, int rpos)
+char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
 {
 	struct ast_channel *c = NULL;
 	int which = 0;
@@ -809,12 +809,12 @@
 
 static char *complete_ch_3(const char *line, const char *word, int pos, int state)
 {
-	return complete_ch_helper(line, word, pos, state, 2);
+	return ast_complete_channels(line, word, pos, state, 2);
 }
 
 static char *complete_ch_4(const char *line, const char *word, int pos, int state)
 {
-	return complete_ch_helper(line, word, pos, state, 3);
+	return ast_complete_channels(line, word, pos, state, 3);
 }
 
 static char *complete_mod_2(const char *line, const char *word, int pos, int state)

Modified: trunk/include/asterisk/cli.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/cli.h?rev=10287&r1=10286&r2=10287&view=diff
==============================================================================
--- trunk/include/asterisk/cli.h (original)
+++ trunk/include/asterisk/cli.h Thu Feb 16 11:37:03 2006
@@ -132,6 +132,15 @@
  */
 char **ast_cli_completion_matches(const char *, const char *);
 
+/*!
+ * \brief Command completion for the list of active channels
+ *
+ * This can be called from a CLI command completion function that wants to
+ * complete from the list of active channels.  'rpos' is the required
+ * position in the command.  This function will return NULL immediately if
+ * 'rpos' is not the same as the current position, 'pos'.
+ */
+char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }



More information about the asterisk-commits mailing list