summaryrefslogtreecommitdiff
path: root/res/res_jabber.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-02-08 21:26:32 +0000
committerRussell Bryant <russell@russellbryant.com>2008-02-08 21:26:32 +0000
commit1ec8cb41a8170201f45ff0efe65e96aa97e0b8d3 (patch)
tree425b3dafd75451669e2311d091127fe03d3c9693 /res/res_jabber.c
parent52595c5d30f311b4e8d1c089577b8679adde232e (diff)
Merge changes from team/mvanbaak/cli-command-audit
(closes issue #8925) About a year ago, as Leif Madsen and Jim van Meggelen were going over the CLI commands in Asterisk 1.4 for the next version of their book, they documented a lot of inconsistencies. This set of changes addresses all of these issues and has been reviewed by Leif. While this does introduce even more changes to the CLI command structure, it makes everything consistent, which is the most important thing. Thanks to all that helped with this one! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@103171 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_jabber.c')
-rw-r--r--res/res_jabber.c99
1 files changed, 63 insertions, 36 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 8e7a3d2af..4b7dcdd4a 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -87,9 +87,9 @@ static void *aji_recv_loop(void *data);
static int aji_initialize(struct aji_client *client);
static int aji_client_connect(void *data, ikspak *pak);
static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc);
-static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *aji_show_buddies(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *aji_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
@@ -114,9 +114,9 @@ static int aji_register_transport(void *data, ikspak *pak);
static int aji_register_transport2(void *data, ikspak *pak);
*/
+static struct ast_cli_entry cli_aji_do_debug_deprecated = AST_CLI_DEFINE(aji_do_debug_deprecated, "Enable/disable jabber debugging");
static struct ast_cli_entry aji_cli[] = {
- AST_CLI_DEFINE(aji_do_debug, "Enable jabber debugging"),
- AST_CLI_DEFINE(aji_no_debug, "Disable Jabber debug"),
+ AST_CLI_DEFINE(aji_do_set_debug, "Enable/Disable Jabber debug", .deprecate_cmd = &cli_aji_do_debug_deprecated),
AST_CLI_DEFINE(aji_do_reload, "Reload Jabber configuration"),
AST_CLI_DEFINE(aji_show_clients, "Show state of clients and components"),
AST_CLI_DEFINE(aji_show_buddies, "Show buddy lists of our clients"),
@@ -2330,77 +2330,104 @@ static void aji_set_presence(struct aji_client *client, char *to, char *from, in
}
/*!
- * \brief Turn on console debugging.
+ * \brief Turn on/off console debugging.
* \return CLI_SUCCESS.
*/
-static char *aji_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *aji_do_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
-
switch (cmd) {
case CLI_INIT:
- e->command = "jabber debug";
+ e->command = "jabber set debug {on|off}";
e->usage =
- "Usage: jabber debug\n"
- " Enables dumping of Jabber packets for debugging purposes.\n";
+ "Usage: jabber set debug {on|off}\n"
+ " Enables/disables dumping of Jabber packets for debugging purposes.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
- ASTOBJ_RDLOCK(iterator);
- iterator->debug = 1;
- ASTOBJ_UNLOCK(iterator);
- });
- ast_cli(a->fd, "Jabber Debugging Enabled.\n");
- return CLI_SUCCESS;
+ if (a->argc != e->args)
+ return CLI_SHOWUSAGE;
+
+ if (!strncasecmp(a->argv[e->args - 1], "on", 2)) {
+ ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+ ASTOBJ_RDLOCK(iterator);
+ iterator->debug = 1;
+ ASTOBJ_UNLOCK(iterator);
+ });
+ ast_cli(a->fd, "Jabber Debugging Enabled.\n");
+ return CLI_SUCCESS;
+ } else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) {
+ ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+ ASTOBJ_RDLOCK(iterator);
+ iterator->debug = 0;
+ ASTOBJ_UNLOCK(iterator);
+ });
+ ast_cli(a->fd, "Jabber Debugging Disabled.\n");
+ return CLI_SUCCESS;
+ }
+ return CLI_SHOWUSAGE; /* defaults to invalid */
}
/*!
- * \brief Reload jabber module.
+ * \brief Turn on/off console debugging (deprecated, use aji_do_set_debug).
* \return CLI_SUCCESS.
*/
-static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *aji_do_debug_deprecated(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
+
switch (cmd) {
case CLI_INIT:
- e->command = "jabber reload";
+ e->command = "jabber debug [off]";
e->usage =
- "Usage: jabber reload\n"
- " Reloads the Jabber module.\n";
+ "Usage: jabber debug [off]\n"
+ " Enables/disables dumping of Jabber packets for debugging purposes.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- aji_reload(1);
- ast_cli(a->fd, "Jabber Reloaded.\n");
- return CLI_SUCCESS;
+ if (a->argc == 2) {
+ ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+ ASTOBJ_RDLOCK(iterator);
+ iterator->debug = 1;
+ ASTOBJ_UNLOCK(iterator);
+ });
+ ast_cli(a->fd, "Jabber Debugging Enabled.\n");
+ return CLI_SUCCESS;
+ } else if (a->argc == 3) {
+ if (!strncasecmp(a->argv[2], "off", 3)) {
+ ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+ ASTOBJ_RDLOCK(iterator);
+ iterator->debug = 0;
+ ASTOBJ_UNLOCK(iterator);
+ });
+ ast_cli(a->fd, "Jabber Debugging Disabled.\n");
+ return CLI_SUCCESS;
+ }
+ }
+ return CLI_SHOWUSAGE; /* defaults to invalid */
}
/*!
- * \brief Turn off console debugging.
+ * \brief Reload jabber module.
* \return CLI_SUCCESS.
*/
-static char *aji_no_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *aji_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
switch (cmd) {
case CLI_INIT:
- e->command = "jabber debug off";
+ e->command = "jabber reload";
e->usage =
- "Usage: jabber debug off\n"
- " Disables dumping of Jabber packets for debugging purposes.\n";
+ "Usage: jabber reload\n"
+ " Reloads the Jabber module.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
- ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
- ASTOBJ_RDLOCK(iterator);
- iterator->debug = 0;
- ASTOBJ_UNLOCK(iterator);
- });
- ast_cli(a->fd, "Jabber Debugging Disabled.\n");
+ aji_reload(1);
+ ast_cli(a->fd, "Jabber Reloaded.\n");
return CLI_SUCCESS;
}