[asterisk-commits] russell: branch russell/chan_console r81491 - /team/russell/chan_console/chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 4 23:10:00 CDT 2007


Author: russell
Date: Tue Sep  4 23:10:00 2007
New Revision: 81491

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81491
Log:
pull in a "console set autoanswer" CLI command

Modified:
    team/russell/chan_console/channels/chan_console.c

Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=81491&r1=81490&r2=81491
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Tue Sep  4 23:10:00 2007
@@ -36,11 +36,10 @@
  * implemented here are:
  *
  * Multiple device support
+ *  - with "active" CLI command
  * Set Auto-answer from the dialplan
  *
  * transfer CLI command
- * autoanswer CLI command (maybe general settings CLI command, instead?)
- * active CLI command
  *
  *
  * TODO
@@ -632,6 +631,49 @@
 	return *ext;
 }
 
+static char *cli_console_autoanswer(struct ast_cli_entry *e, int cmd, 
+	struct ast_cli_args *a)
+{
+	struct console_pvt *pvt = &console_pvt;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "console set autoanswer [on|off]";
+		e->usage =
+			"Usage: console set autoanswer [on|off]\n"
+			"       Enables or disables autoanswer feature.  If used without\n"
+			"       argument, displays the current on/off status of autoanswer.\n"
+			"       The default value of autoanswer is in 'oss.conf'.\n";
+		return NULL;
+
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc == e->args - 1) {
+		ast_cli(a->fd, "Auto answer is %s.\n", pvt->autoanswer ? "on" : "off");
+		return CLI_SUCCESS;
+	}
+
+	if (a->argc != e->args)
+		return CLI_SHOWUSAGE;
+
+	if (!pvt) {
+		ast_log(LOG_WARNING, "Cannot find device %s (should not happen!)\n",
+			pvt->name);
+		return CLI_FAILURE;
+	}
+
+	if (!strcasecmp(a->argv[e->args-1], "on"))
+		pvt->autoanswer = 1;
+	else if (!strcasecmp(a->argv[e->args - 1], "off"))
+		pvt->autoanswer = 0;
+	else
+		return CLI_SHOWUSAGE;
+
+	return CLI_SUCCESS;
+}
+
 static char *cli_console_flash(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_FLASH };
@@ -902,6 +944,7 @@
 	NEW_CLI(cli_console_answer, "Answer an incoming console call"),
 	NEW_CLI(cli_console_sendtext, "Send text to a connected party"),
 	NEW_CLI(cli_console_flash, "Send a flash to the connected party"),
+	NEW_CLI(cli_console_autoanswer, "Turn autoanswer on or off"),
 	NEW_CLI(cli_list_devices, "List available devices"),
 };
 




More information about the asterisk-commits mailing list