[asterisk-commits] file: branch file/res_xmpp r369180 - in /team/file/res_xmpp: configs/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 21 08:11:59 CDT 2012


Author: file
Date: Thu Jun 21 08:11:55 2012
New Revision: 369180

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=369180
Log:
Incorporate all current review feedback.

Modified:
    team/file/res_xmpp/configs/cli_aliases.conf.sample
    team/file/res_xmpp/res/res_xmpp.c

Modified: team/file/res_xmpp/configs/cli_aliases.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/file/res_xmpp/configs/cli_aliases.conf.sample?view=diff&rev=369180&r1=369179&r2=369180
==============================================================================
--- team/file/res_xmpp/configs/cli_aliases.conf.sample (original)
+++ team/file/res_xmpp/configs/cli_aliases.conf.sample Thu Jun 21 08:11:55 2012
@@ -186,3 +186,16 @@
 
 [asterisk14](asterisk14_tpl)
 ; add any additional custom commands you want below here.
+
+[asterisk11_tpl](!)
+jabber list nodes=xmpp list nodes
+jabber purge nodes=xmpp purge nodes
+jabber delete node=xmpp delete node
+jabber create collection=xmpp create collection
+jabber create leaf=xmpp create leaf
+jabber set debug=xmpp set debug
+jabber show connections=xmpp show connections
+jabber show buddies=xmpp show buddies
+
+[asterisk11](asterisk11_tpl)
+; add any additional custom commands you want below here.

Modified: team/file/res_xmpp/res/res_xmpp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/res_xmpp/res/res_xmpp.c?view=diff&rev=369180&r1=369179&r2=369180
==============================================================================
--- team/file/res_xmpp/res/res_xmpp.c (original)
+++ team/file/res_xmpp/res/res_xmpp.c Thu Jun 21 08:11:55 2012
@@ -1859,7 +1859,7 @@
 	while (diff < timeout) {
 		struct timespec ts = { 0, };
 		struct timeval wait;
-		int res;
+		int res = 0;
 
 		wait = ast_tvadd(start, ast_tv(timeout, 0));
 		ts.tv_sec = wait.tv_sec;
@@ -1867,7 +1867,9 @@
 
 		/* wait up to timeout seconds for an incoming message */
 		ast_mutex_lock(&messagelock);
-		res = ast_cond_timedwait(&message_received_condition, &messagelock, &ts);
+		if (AST_LIST_EMPTY(&clientcfg->client->messages)) {
+			res = ast_cond_timedwait(&message_received_condition, &messagelock, &ts);
+		}
 		ast_mutex_unlock(&messagelock);
 		if (res == ETIMEDOUT) {
 			ast_debug(3, "No message received from %s in %d seconds\n", args.jid, timeout);
@@ -3513,8 +3515,12 @@
 		/* Disconnect the existing session since our role is changing, or we are starting up */
 		ast_xmpp_client_disconnect(cfg->client);
 
-		cfg->client->parser = iks_stream_new(ast_test_flag(&cfg->flags, XMPP_COMPONENT) ? "jabber:component:accept" : "jabber:client", cfg->client,
-						     xmpp_action_hook);
+		if (!cfg->client->parser = iks_stream_new(ast_test_flag(&cfg->flags, XMPP_COMPONENT) ? "jabber:component:accept" : "jabber:client", cfg->client,
+							  xmpp_action_hook)) {
+			ast_log(LOG_ERROR, "Iksemel stream could not be created for client '%s' - client not active\n", cfg->name);
+			return -1;
+		}
+
 		iks_set_log_hook(cfg->client->parser, xmpp_log_hook);
 
 		/* Create a JID based on the given user, if no resource is given use the default */
@@ -3525,6 +3531,11 @@
 			cfg->client->jid = iks_id_new(cfg->client->stack, resource);
 		} else {
 			cfg->client->jid = iks_id_new(cfg->client->stack, cfg->user);
+		}
+
+		if (!cfg->client->jid) {
+			ast_log(LOG_ERROR, "Jabber identity could not be created for client '%s' - client not active\n", cfg->name);
+			return -1;
 		}
 
 		ast_pthread_create_background(&cfg->client->thread, NULL, xmpp_client_thread, cfg->client);
@@ -3685,11 +3696,11 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber list nodes";
+		e->command = "xmpp list nodes";
 		e->usage =
-			"Usage: jabber list nodes <connection> [collection]\n"
+			"Usage: xmpp list nodes <connection> [collection]\n"
 			"       Lists the user's nodes on the respective connection\n"
-			"       ([connection] as configured in jabber.conf.)\n";
+			"       ([connection] as configured in xmpp.conf.)\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -3771,11 +3782,11 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber purge nodes";
-			e->usage =
-					"Usage: jabber purge nodes <connection> <node>\n"
-					"       Purges nodes on PubSub server\n"
-				"       as configured in jabber.conf.\n";
+		e->command = "xmpp purge nodes";
+		e->usage =
+			"Usage: xmpp purge nodes <connection> <node>\n"
+			"       Purges nodes on PubSub server\n"
+			"       as configured in xmpp.conf.\n";
 			return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -3816,12 +3827,12 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber delete node";
-			e->usage =
-					"Usage: jabber delete node <connection> <node>\n"
-					"       Deletes a node on PubSub server\n"
-				"       as configured in jabber.conf.\n";
-			return NULL;
+		e->command = "xmpp delete node";
+		e->usage =
+			"Usage: xmpp delete node <connection> <node>\n"
+			"       Deletes a node on PubSub server\n"
+			"       as configured in xmpp.conf.\n";
+		return NULL;
 	case CLI_GENERATE:
 		return NULL;
 	}
@@ -3853,11 +3864,11 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber create collection";
+		e->command = "xmpp create collection";
 		e->usage =
-			"Usage: jabber create collection <connection> <collection>\n"
+			"Usage: xmpp create collection <connection> <collection>\n"
 			"       Creates a PubSub collection node using the account\n"
-			"       as configured in jabber.conf.\n";
+			"       as configured in xmpp.conf.\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -3893,11 +3904,11 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber create leaf";
+		e->command = "xmpp create leaf";
 		e->usage =
-			"Usage: jabber create leaf <connection> <collection> <leaf>\n"
+			"Usage: xmpp create leaf <connection> <collection> <leaf>\n"
 			"       Creates a PubSub leaf node using the account\n"
-			"       as configured in jabber.conf.\n";
+			"       as configured in xmpp.conf.\n";
 		return NULL;
 	case CLI_GENERATE:
 		return NULL;
@@ -3931,9 +3942,9 @@
 {
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber set debug {on|off}";
+		e->command = "xmpp set debug {on|off}";
 		e->usage =
-			"Usage: jabber set debug {on|off}\n"
+			"Usage: xmpp set debug {on|off}\n"
 			"       Enables/disables dumping of XMPP/Jabber packets for debugging purposes.\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -3946,11 +3957,11 @@
 
 	if (!strncasecmp(a->argv[e->args - 1], "on", 2)) {
 		debug = 1;
-		ast_cli(a->fd, "Jabber Debugging Enabled.\n");
+		ast_cli(a->fd, "XMPP Debugging Enabled.\n");
 		return CLI_SUCCESS;
 	} else if (!strncasecmp(a->argv[e->args - 1], "off", 3)) {
 		debug = 0;
-		ast_cli(a->fd, "Jabber Debugging Disabled.\n");
+		ast_cli(a->fd, "XMPP Debugging Disabled.\n");
 		return CLI_SUCCESS;
 	}
 	return CLI_SHOWUSAGE; /* defaults to invalid */
@@ -3969,9 +3980,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber show connections";
+		e->command = "xmpp show connections";
 		e->usage =
-			"Usage: jabber show connections\n"
+			"Usage: xmpp show connections\n"
 			"       Shows state of client and component connections\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -4045,9 +4056,9 @@
 
 	switch (cmd) {
 	case CLI_INIT:
-		e->command = "jabber show buddies";
+		e->command = "xmpp show buddies";
 		e->usage =
-			"Usage: jabber show buddies\n"
+			"Usage: xmpp show buddies\n"
 			"       Shows buddy lists of our clients\n";
 		return NULL;
 	case CLI_GENERATE:
@@ -4058,7 +4069,7 @@
 		return NULL;
 	}
 
-	ast_cli(a->fd, "Jabber buddy lists\n");
+	ast_cli(a->fd, "XMPP buddy lists\n");
 
 	i = ao2_iterator_init(cfg->clients, 0);
 	while ((clientcfg = ao2_iterator_next(&i))) {




More information about the asterisk-commits mailing list