[svn-commits] phsultan: trunk r81411 - in /trunk: ./ channels/chan_gtalk.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Aug 31 12:43:50 CDT 2007


Author: phsultan
Date: Fri Aug 31 12:43:50 2007
New Revision: 81411

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81411
Log:
Merged revisions 81410 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r81410 | phsultan | 2007-08-31 19:38:26 +0200 (Fri, 31 Aug 2007) | 3 lines

Make the 'gtalk show channels' CLI command available.

Closes issue 10548, reported by keepitcool.
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_gtalk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=81411&r1=81410&r2=81411
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Fri Aug 31 12:43:50 2007
@@ -1568,13 +1568,54 @@
 /*! \brief CLI command "gtalk show channels" */
 static int gtalk_show_channels(int fd, int argc, char **argv)
 {
+#define FORMAT  "%-30.30s  %-30.30s  %-15.15s  %-5.5s %-5.5s \n"
+	struct gtalk_pvt *p;
+	struct ast_channel *chan;
+	int numchans = 0;
+	char them[100];
+	char *jid = NULL;
+	char *resource = NULL;
+
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
+
 	ast_mutex_lock(&gtalklock);
-//	if (!gtalk_list->p)
-		ast_cli(fd, "No gtalk channels in use\n");
+	ast_cli(fd, FORMAT, "Channel", "Jabber ID", "Resource", "Read", "Write");
+	ASTOBJ_CONTAINER_TRAVERSE(&gtalk_list, 1, {
+		ASTOBJ_WRLOCK(iterator);
+		p = iterator->p;
+		while(p) {
+			chan = p->owner;
+			ast_copy_string(them, p->them, sizeof(them));
+			jid = them;
+			resource = strchr(them, '/');
+			if (!resource)
+				resource = "None";
+			else {
+				*resource = '\0';
+				resource ++;
+			}
+			if (chan)
+				ast_cli(fd, FORMAT, 
+					chan->name,
+					jid,
+					resource,
+					ast_getformatname(chan->readformat),
+					ast_getformatname(chan->writeformat)					
+					);
+			else 
+				ast_log(LOG_WARNING, "No available channel\n");
+			numchans ++;
+			p = p->next;
+		}
+		ASTOBJ_UNLOCK(iterator);
+	});
+
 	ast_mutex_unlock(&gtalklock);
+
+	ast_cli(fd, "%d active gtalk channel%s\n", numchans, (numchans != 1) ? "s" : "");
 	return RESULT_SUCCESS;
+#undef FORMAT
 }
 
 /*! \brief CLI command "gtalk show channels" */




More information about the svn-commits mailing list