[svn-commits] phsultan: trunk r83804 - /trunk/res/res_jabber.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Sep 25 11:34:49 CDT 2007


Author: phsultan
Date: Tue Sep 25 11:34:49 2007
New Revision: 83804

URL: http://svn.digium.com/view/asterisk?view=rev&rev=83804
Log:
Added a CLI command that shows our buddy list, as suggested by Daniel McKeehan, thanks!

Modified:
    trunk/res/res_jabber.c

Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?view=diff&rev=83804&r1=83803&r2=83804
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue Sep 25 11:34:49 2007
@@ -90,8 +90,9 @@
 static char *aji_do_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);
-static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static int aji_create_client(char *label, struct ast_variable *var, int debug);
 static int aji_create_buddy(char *label, struct aji_client *client);
 static int aji_reload(int reload);
@@ -118,6 +119,7 @@
 	NEW_CLI(aji_no_debug, "Disable Jabber debug"),
 	NEW_CLI(aji_do_reload, "Reload Jabber configuration"),
 	NEW_CLI(aji_show_clients, "Show state of clients and components"),
+	NEW_CLI(aji_show_buddies, "Show buddy lists of our clients"),
 	NEW_CLI(aji_test, "Shows roster, but is generally used for mog's debugging."),
 };
 
@@ -2126,6 +2128,52 @@
 }
 
 /*!
+ * \brief Show buddy lists
+ * \return CLI_SUCCESS.
+ */
+static char *aji_show_buddies(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	struct aji_resource *resource;
+	struct aji_client *client;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "jabber show buddies";
+		e->usage =
+			"Usage: jabber show buddies\n"
+			"       Shows buddy lists of our clients\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	ast_cli(a->fd, "Jabber buddy lists\n");
+	ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
+		ast_cli(a->fd,"Client: %s\n", iterator->user);
+		client = iterator;
+		ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, {
+			ASTOBJ_RDLOCK(iterator);
+			ast_cli(a->fd,"\tBuddy:\t%s\n", iterator->name);
+			if (!iterator->resources)
+				ast_cli(a->fd,"\t\tResource: None\n");	
+			for (resource = iterator->resources; resource; resource = resource->next) {
+				ast_cli(a->fd,"\t\tResource: %s\n", resource->resource);
+				if(resource->cap) {
+					ast_cli(a->fd,"\t\t\tnode: %s\n", resource->cap->parent->node);
+					ast_cli(a->fd,"\t\t\tversion: %s\n", resource->cap->version);
+					ast_cli(a->fd,"\t\t\tJingle capable: %s\n", resource->cap->jingle ? "yes" : "no");
+				}
+				ast_cli(a->fd,"\t\tStatus: %d\n", resource->status);
+				ast_cli(a->fd,"\t\tPriority: %d\n", resource->priority);
+			}
+			ASTOBJ_UNLOCK(iterator);
+		});
+		iterator = client;
+	});
+	return CLI_SUCCESS;
+}
+
+/*!
  * \brief Send test message for debugging.
  * \return CLI_SUCCESS,CLI_FAILURE.
  */




More information about the svn-commits mailing list