aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_jabber.c
diff options
context:
space:
mode:
authorphsultan <phsultan@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-25 16:34:49 +0000
committerphsultan <phsultan@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-25 16:34:49 +0000
commitc8cc686423426d0322869a94d596a102bfc5fa52 (patch)
tree3bf9452db116875fe65adbf3de749d300dd1192c /res/res_jabber.c
parenteda57ca8ae1d04ccc1488253230653556170f498 (diff)
Added a CLI command that shows our buddy list, as suggested by Daniel McKeehan, thanks!
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@83804 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_jabber.c')
-rw-r--r--res/res_jabber.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/res/res_jabber.c b/res/res_jabber.c
index b673cb17d..ec4d297f4 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -90,8 +90,9 @@ static void aji_set_presence(struct aji_client *client, char *to, char *from, in
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_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 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 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 @@ static struct ast_cli_entry aji_cli[] = {
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 @@ static char *aji_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_a
}
/*!
+ * \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.
*/