[svn-commits] tilghman: trunk r131606 - in /trunk: CHANGES UPGRADE.txt main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jul 17 09:00:28 CDT 2008


Author: tilghman
Date: Thu Jul 17 09:00:27 2008
New Revision: 131606

URL: http://svn.digium.com/view/asterisk?view=rev&rev=131606
Log:
Change several 'core' commands to be 'dialplan' commands (with appropriate
deprecation, of course)
(closes issue #13016)
 Reported by: caio1982
 Patches: 
       dialplan_globals6.diff uploaded by caio1982 (license 22)

Modified:
    trunk/CHANGES
    trunk/UPGRADE.txt
    trunk/main/pbx.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=131606&r1=131605&r2=131606
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Jul 17 09:00:27 2008
@@ -146,6 +146,11 @@
      A new API call was added so trunk will now have to be compiled against
      a versions of libpri and libss7 that have them or it will not know that
      these libraries exist.
+  * The commands "core show globals", "core set global" and "core set chanvar" has
+     been deprecated in favor of the more semanticly correct "dialplan show globals",
+     "dialplan set chanvar" and "dialplan set global".
+  * New CLI command "dialplan show chanvar" to list all variables associated
+    with a given channel.
 
 DNS manager changes
 -------------------

Modified: trunk/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/trunk/UPGRADE.txt?view=diff&rev=131606&r1=131605&r2=131606
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Thu Jul 17 09:00:27 2008
@@ -62,6 +62,11 @@
 
 * The concise versions of various CLI commands are now deprecated. We recommend
   using the manager interface (AMI) for application integration with Asterisk.
+
+* The following core commands dealing with dialplan has been deprecated: 'core
+  show globals', 'core set global' and 'core set chanvar'. Use the equivalent
+  'dialplan show globals', 'dialplan set global' and 'dialplan set chanvar'
+  instead.
 
 * The silencethreshold used for various applications is now settable via a
   centralized config option in dsp.conf.

Modified: trunk/main/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/main/pbx.c?view=diff&rev=131606&r1=131605&r2=131606
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Thu Jul 17 09:00:27 2008
@@ -5376,7 +5376,6 @@
 " Context: <context>		Context (Optional)\n"
 "\n";
 
-
 /*! \brief CLI support for listing global variables in a parseable way */
 static char *handle_show_globals(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
@@ -5385,9 +5384,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core show globals";
+		e->command = "dialplan show globals";
 		e->usage = 
-			"Usage: core show globals\n"
+			"Usage: dialplan show globals\n"
 			"       List current global dialplan variables and their values\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -5400,18 +5399,60 @@
 		ast_cli(a->fd, "   %s=%s\n", ast_var_name(newvariable), ast_var_value(newvariable));
 	}
 	ast_rwlock_unlock(&globalslock);
-	ast_cli(a->fd, "\n    -- %d variables\n", i);
+	ast_cli(a->fd, "\n    -- %d variable(s)\n", i);
 
 	return CLI_SUCCESS;
 }
 
-static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
+static char *handle_show_globals_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+
+	char *res = handle_show_globals(e, cmd, a);
+	if (cmd == CLI_INIT)
+		e->command = "core show globals";
+	return res;
+}
+
+/*! \brief CLI support for listing chanvar's variables in a parseable way */
+static char *handle_show_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	struct ast_channel *chan = NULL;
+	struct ast_str *vars = ast_str_alloca(BUFSIZ * 4); /* XXX large because we might have lots of channel vars */
+
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core set global";
+		e->command = "dialplan show chanvar";
 		e->usage = 
-			"Usage: core set global <name> <value>\n"
+			"Usage: dialplan show chanvar <channel>\n"
+			"       List current channel variables and their values\n";
+		return NULL;
+	case CLI_GENERATE:
+		return ast_complete_channels(a->line, a->word, a->pos, a->n, 3);
+	}
+
+	if (a->argc != e->args + 1)
+		return CLI_SHOWUSAGE;
+
+	if (!(chan = ast_get_channel_by_name_locked(a->argv[e->args]))) {
+		ast_cli(a->fd, "Channel '%s' not found\n", a->argv[e->args]);
+		return CLI_FAILURE;
+	}
+
+	pbx_builtin_serialize_variables(chan, &vars);
+	if (vars->str) {
+		ast_cli(a->fd, "\nVariables for channel %s:\n%s\n", a->argv[e->args], vars->str);
+	}
+	ast_channel_unlock(chan);
+	return CLI_SUCCESS;
+}
+
+static char *handle_set_global(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "dialplan set global";
+		e->usage = 
+			"Usage: dialplan set global <name> <value>\n"
 			"       Set global dialplan variable <name> to <value>\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -5422,9 +5463,17 @@
 		return CLI_SHOWUSAGE;
 
 	pbx_builtin_setvar_helper(NULL, a->argv[3], a->argv[4]);
-	ast_cli(a->fd, "\n    -- Global variable %s set to %s\n", a->argv[3], a->argv[4]);
+	ast_cli(a->fd, "\n    -- Global variable '%s' set to '%s'\n", a->argv[3], a->argv[4]);
 
 	return CLI_SUCCESS;
+}
+
+static char *handle_set_global_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	char *res = handle_set_global(e, cmd, a);
+	if (cmd == CLI_INIT)
+		e->command = "core set global";
+	return res;
 }
 
 static char *handle_set_chanvar(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -5434,9 +5483,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "core set chanvar";
+		e->command = "dialplan set chanvar";
 		e->usage = 
-			"Usage: core set chanvar <channel> <varname> <value>\n"
+			"Usage: dialplan set chanvar <channel> <varname> <value>\n"
 			"       Set channel variable <varname> to <value>\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -5456,13 +5505,18 @@
 	}
 
 	pbx_builtin_setvar_helper(chan, var_name, var_value);
-
 	ast_channel_unlock(chan);
-
-	ast_cli(a->fd, "\n    -- Channel variable '%s' set to '%s' for '%s'\n", 
-		var_name, var_value, chan_name);
+	ast_cli(a->fd, "\n    -- Channel variable '%s' set to '%s' for '%s'\n",  var_name, var_value, chan_name);
 
 	return CLI_SUCCESS;
+}
+
+static char *handle_set_chanvar_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	char *res = handle_set_chanvar(e, cmd, a);
+	if (cmd == CLI_INIT)
+		e->command = "core set chanvar";
+	return res;
 }
 
 static char *handle_set_extenpatternmatchnew(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -5522,6 +5576,14 @@
 }
 
 /*
+ * Deprecated CLI commands
+ */
+
+static struct ast_cli_entry cli_show_globals_deprecated = AST_CLI_DEFINE(handle_show_globals_deprecated, "Show global dialplan variables.");
+static struct ast_cli_entry cli_set_chanvar_deprecated = AST_CLI_DEFINE(handle_set_chanvar_deprecated, "Set a channel variable.");
+static struct ast_cli_entry cli_set_global_deprecated = AST_CLI_DEFINE(handle_set_global_deprecated, "Set global dialplan variable.");
+
+/*
  * CLI entries for upper commands ...
  */
 static struct ast_cli_entry pbx_cli[] = {
@@ -5530,11 +5592,12 @@
 	AST_CLI_DEFINE(handle_show_switches, "Show alternative switches"),
 	AST_CLI_DEFINE(handle_show_hints, "Show dialplan hints"),
 	AST_CLI_DEFINE(handle_show_hint, "Show dialplan hint"),
-	AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables"),
+	AST_CLI_DEFINE(handle_show_globals, "Show global dialplan variables", .deprecate_cmd = &cli_show_globals_deprecated),
+	AST_CLI_DEFINE(handle_show_chanvar, "Show channel variables"),
 	AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"),
 	AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"),
-	AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable"),
-	AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable"),
+	AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable", .deprecate_cmd = &cli_set_global_deprecated),
+	AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable", .deprecate_cmd = &cli_set_chanvar_deprecated),
 	AST_CLI_DEFINE(handle_show_dialplan, "Show dialplan"),
 	AST_CLI_DEFINE(handle_unset_extenpatternmatchnew, "Use the Old extension pattern matching algorithm."),
 	AST_CLI_DEFINE(handle_set_extenpatternmatchnew, "Use the New extension pattern matching algorithm."),




More information about the svn-commits mailing list