[asterisk-commits] marquis: branch marquis/pubsub-distributed-events r215302 - /team/marquis/pub...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 1 18:46:28 CDT 2009


Author: marquis
Date: Tue Sep  1 18:46:24 2009
New Revision: 215302

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215302
Log:
While posting my initial diff for reviewboard, I noticed some extra whitespace as well as some formatting changes in lines that I didn't otherwise change.  This gets rid of both of those issues.

Modified:
    team/marquis/pubsub-distributed-events/res/res_jabber.c

Modified: team/marquis/pubsub-distributed-events/res/res_jabber.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/marquis/pubsub-distributed-events/res/res_jabber.c?view=diff&rev=215302&r1=215301&r2=215302
==============================================================================
--- team/marquis/pubsub-distributed-events/res/res_jabber.c (original)
+++ team/marquis/pubsub-distributed-events/res/res_jabber.c Tue Sep  1 18:46:24 2009
@@ -514,7 +514,7 @@
 	);
 
 	if (deprecation_warning++ % 10 == 0)
-	ast_log(LOG_WARNING,"JabberStatus is deprecated Please use the JABBER_STATUS dialplan function in the future.\n");
+		ast_log(LOG_WARNING, "JabberStatus is deprecated.  Please use the JABBER_STATUS dialplan function in the future.\n");
 
 	if (!data) {
 		ast_log(LOG_ERROR, "Usage: JabberStatus(<sender>,<jid>[/<resource>],<varname>\n");
@@ -543,8 +543,7 @@
 	if (!r && buddy->resources) 
 		r = buddy->resources;
 	if (!r)
-		ast_log(LOG_NOTICE, "Resource '%s' of buddy '%s' was not found\n", jid.resource,
-jid.screenname);
+		ast_log(LOG_NOTICE, "Resource '%s' of buddy '%s' was not found\n", jid.resource, jid.screenname);
 	else
 		stat = r->status;
 	snprintf(status, sizeof(status), "%d", stat);
@@ -552,8 +551,7 @@
 	return 0;
 }
 
-static int acf_jabberstatus_read(struct ast_channel *chan, const char *name, char *data,
-char *buf, size_t buflen)
+static int acf_jabberstatus_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
 {
 	struct aji_client *client = NULL;
 	struct aji_buddy *buddy = NULL;
@@ -594,8 +592,7 @@
 	if (!r && buddy->resources) 
 		r = buddy->resources;
 	if (!r)
-		ast_log(LOG_NOTICE, "Resource %s of buddy %s was not found.\n", jid.resource,
-jid.screenname);
+		ast_log(LOG_NOTICE, "Resource %s of buddy %s was not found.\n", jid.resource, jid.screenname);
 	else
 		stat = r->status;
 	snprintf(buf, buflen, "%d", stat);
@@ -734,8 +731,7 @@
  * \return the number of read bytes on success, 0 on timeout expiration, 
  * -1 on  error
  */
-static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, int
-timeout)
+static int aji_io_recv(struct aji_client *client, char *buffer, size_t buf_len, int timeout)
 {
 	int sock;
 	fd_set fds;
@@ -934,8 +930,7 @@
 	struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
 
 	if (!ast_strlen_zero(xmpp))
-		manager_event(EVENT_FLAG_USER, "JabberEvent", "Account: %s\r\nPacket: %s\r\n",
-client->name, xmpp);
+		manager_event(EVENT_FLAG_USER, "JabberEvent", "Account: %s\r\nPacket: %s\r\n", client->name, xmpp);
 
 	if (client->debug) {
 		if (is_incoming)
@@ -962,8 +957,7 @@
  *
  * \return IKS_OK on success, IKSNET_NOTSUPP on failure.
  */
-static int aji_start_sasl(struct aji_client *client, enum ikssasltype type, char
-*username, char *pass)
+static int aji_start_sasl(struct aji_client *client, enum ikssasltype type, char *username, char *pass)
 {
 	iks *x = NULL;
 	int len;
@@ -1020,8 +1014,7 @@
 	int features = 0;
 
 	if(!node) {
-		ast_log(LOG_ERROR, "aji_act_hook was called with out a packet\n"); /* most likely
-cause type is IKS_NODE_ERROR lost connection */
+		ast_log(LOG_ERROR, "aji_act_hook was called with out a packet\n"); /* most likely cause type is IKS_NODE_ERROR lost connection */
 		ASTOBJ_UNREF(client, aji_client_destroy);
 		return IKS_HOOK;
 	}
@@ -1051,10 +1044,8 @@
 				break;
 			}
 			if (!client->usesasl) {
-				iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE,
-IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid, IKS_RULE_DONE);
-				auth = jabber_make_auth(client->jid, client->password,
-iks_find_attrib(node, "id"));
+				iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid, IKS_RULE_DONE);
+				auth = jabber_make_auth(client->jid, client->password, iks_find_attrib(node, "id"));
 				if (auth) {
 					iks_insert_attrib(auth, "id", client->mid);
 					iks_insert_attrib(auth, "to", client->jid->server);
@@ -1081,8 +1072,7 @@
 						break;
 					if (client->authorized) {
 						if (features & IKS_STREAM_BIND) {
-							iks_filter_add_rule(client->f, aji_client_connect, client,
-IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
+							iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_DONE);
 							auth = iks_make_resource_bind(client->jid);
 							if (auth) {
 								iks_insert_attrib(auth, "id", client->mid);
@@ -1095,9 +1085,7 @@
 							}
 						}
 						if (features & IKS_STREAM_SESSION) {
-							iks_filter_add_rule (client->f, aji_client_connect, client,
-IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth",
-IKS_RULE_DONE);
+							iks_filter_add_rule (client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "auth", IKS_RULE_DONE);
 							auth = iks_make_session();
 							if (auth) {
 								iks_insert_attrib(auth, "id", "auth");
@@ -1115,8 +1103,7 @@
 							break;
 						}
 
-						ret = aji_start_sasl(client, features, client->jid->user,
-client->password);
+						ret = aji_start_sasl(client, features, client->jid->user, client->password);
 						if (ret != IKS_OK) {
 							ASTOBJ_UNREF(client, aji_client_destroy);
 							return IKS_HOOK;
@@ -1157,8 +1144,7 @@
 					handshake = NULL;
 				}
 				client->state = AJI_CONNECTING;
-				if(aji_recv(client, 1) == 2) /*XXX proper result for iksemel library on
-iks_recv of <handshake/> XXX*/
+				if(aji_recv(client, 1) == 2) /*XXX proper result for iksemel library on iks_recv of <handshake/> XXX*/
 					client->state = AJI_CONNECTED;
 				else
 					ast_log(LOG_WARNING, "Jabber didn't seem to handshake, failed to authenticate.\n");
@@ -1289,8 +1275,7 @@
 			iks_insert_attrib(query, "xmlns", "jabber:iq:register");
 			iks_insert_attrib(error, "code" , "406");
 			iks_insert_attrib(error, "type", "modify");
-			iks_insert_attrib(notacceptable, "xmlns",
-"urn:ietf:params:xml:ns:xmpp-stanzas");
+			iks_insert_attrib(notacceptable, "xmlns", "urn:ietf:params:xml:ns:xmpp-stanzas");
 			iks_insert_node(iq, query);
 			iks_insert_node(iq, error);
 			iks_insert_node(error, notacceptable);
@@ -1443,8 +1428,7 @@
 			ASTOBJ_UNREF(client, aji_client_destroy);
 			return IKS_FILTER_EAT;
 		}
-		if (iks_find_with_attrib(pak->query, "feature", "var",
-"http://www.google.com/xmpp/protocol/voice/v1")) {
+		if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
 			resource->cap->jingle = 1;
 		} else
 			resource->cap->jingle = 0;
@@ -1465,8 +1449,7 @@
 			iks_insert_attrib(ident, "type", "pc");
 			iks_insert_attrib(ident, "name", "asterisk");
 			iks_insert_attrib(disco, "var", "http://jabber.org/protocol/disco#info");
-			iks_insert_attrib(google, "var",
-"http://www.google.com/xmpp/protocol/voice/v1");
+			iks_insert_attrib(google, "var", "http://www.google.com/xmpp/protocol/voice/v1");
 			iks_insert_node(iq, query);
 			iks_insert_node(query, ident);
 			iks_insert_node(query, google);
@@ -1510,15 +1493,12 @@
 			ASTOBJ_UNREF(client, aji_client_destroy);
 			return IKS_FILTER_EAT;
 		}
-		if (iks_find_with_attrib(pak->query, "feature", "var",
-"http://www.google.com/xmpp/protocol/voice/v1")) {
+		if (iks_find_with_attrib(pak->query, "feature", "var", "http://www.google.com/xmpp/protocol/voice/v1")) {
 			resource->cap->jingle = 1;
 		} else
 			resource->cap->jingle = 0;
-	} else if (pak->subtype == IKS_TYPE_GET && !(node = iks_find_attrib(pak->query,
-"node"))) {
-		iks *iq, *query, *identity, *disco, *reg, *commands, *gateway, *version, *vcard,
-*search;
+	} else if (pak->subtype == IKS_TYPE_GET && !(node = iks_find_attrib(pak->query, "node"))) {
+		iks *iq, *query, *identity, *disco, *reg, *commands, *gateway, *version, *vcard, *search;
 
 		iq = iks_new("iq");
 		query = iks_new("query");
@@ -1530,8 +1510,8 @@
 		version = iks_new("feature");
 		vcard = iks_new("feature");
 		search = iks_new("feature");
-		if (iq && query && identity && disco && reg && commands && gateway && version &&
-vcard && search && client) {
+
+		if (iq && query && identity && disco && reg && commands && gateway && version && vcard && search && client) {
 			iks_insert_attrib(iq, "from", client->user);
 			iks_insert_attrib(iq, "to", pak->from->full);
 			iks_insert_attrib(iq, "id", pak->id);
@@ -1572,9 +1552,8 @@
 		iks_delete(version);
 		iks_delete(vcard);
 		iks_delete(search);
-		
-	} else if (pak->subtype == IKS_TYPE_GET && !strcasecmp(node,
-"http://jabber.org/protocol/commands")) {
+
+	} else if (pak->subtype == IKS_TYPE_GET && !strcasecmp(node, "http://jabber.org/protocol/commands")) {
 		iks *iq, *query, *confirm;
 		iq = iks_new("iq");
 		query = iks_new("query");
@@ -1713,8 +1692,7 @@
 	}
 	ASTOBJ_WRLOCK(buddy);
 	status = (pak->show) ? pak->show : 6;
-	priority = atoi((iks_find_cdata(pak->x, "priority")) ? iks_find_cdata(pak->x,
-"priority") : "0");
+	priority = atoi((iks_find_cdata(pak->x, "priority")) ? iks_find_cdata(pak->x, "priority") : "0");
 	tmp = buddy->resources;
 	descrip = ast_strdup(iks_find_cdata(pak->x,"status"));
 
@@ -1855,8 +1833,7 @@
 				iks_insert_attrib(iq,"from", client->jid->full);
 				iks_insert_attrib(iq, "id", client->mid);
 				ast_aji_increment_mid(client->mid);
-				iks_insert_attrib(query, "xmlns",
-"http://jabber.org/protocol/disco#info");
+				iks_insert_attrib(query, "xmlns", "http://jabber.org/protocol/disco#info");
 				iks_insert_node(iq, query);
 				ast_aji_send(client, iq);
 				
@@ -1932,8 +1909,7 @@
 		iks_delete(status);
 
 		if (client->component)
-			aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"),
-client->status, client->statusmessage);
+			aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage);
 	case IKS_TYPE_SUBSCRIBED:
 		buddy = ASTOBJ_CONTAINER_FIND(&client->buddies, pak->from->partial);
 		if (!buddy && pak->from->partial) {
@@ -2081,7 +2057,6 @@
 		res = aji_reconnect(client);
 		sleep(4);
 	}
-	
 
 	do {
 		if (res == IKS_NET_RWERR || client->timeout == 0) {
@@ -2161,9 +2136,7 @@
 			ASTOBJ_UNLOCK(iterator);
 		});
 		iks_filter_remove_hook(client->f, aji_register_transport);
-		iks_filter_add_rule(client->f, aji_register_transport2, client, IKS_RULE_TYPE,
-IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_NS, IKS_NS_REGISTER,
-IKS_RULE_DONE);
+		iks_filter_add_rule(client->f, aji_register_transport2, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_NS, IKS_NS_REGISTER, IKS_RULE_DONE);
 		iks_insert_attrib(send, "to", buddy->host);
 		iks_insert_attrib(send, "id", client->mid);
 		ast_aji_increment_mid(client->mid);
@@ -2230,8 +2203,7 @@
 #endif
 
 /*!
- * \brief goes through roster and prunes users not needed in list, or adds them
-accordingly.
+ * \brief goes through roster and prunes users not needed in list, or adds them accordingly.
  * \param client the configured XMPP client we use to connect to a XMPP server
  * \return void.
  * \note The messages here should be configurable.
@@ -2254,8 +2226,7 @@
 		ASTOBJ_RDLOCK(iterator);
 		/* For an aji_buddy, both AUTOPRUNE and AUTOREGISTER will never
 		 * be called at the same time */
-		if (ast_test_flag(&iterator->flags, AJI_AUTOPRUNE)) { /* If autoprune is set on
-jabber.conf */
+		if (ast_test_flag(&iterator->flags, AJI_AUTOPRUNE)) { /* If autoprune is set on jabber.conf */
 			res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
 								 "GoodBye. Your status is no longer needed by Asterisk the Open Source PBX"
 								 " so I am no longer subscribing to your presence.\n"));
@@ -2348,8 +2319,7 @@
 			if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) {
 				ast_set_flag(&buddy->flags, AJI_AUTOPRUNE);
 				ASTOBJ_MARK(buddy);
-			} else if (!iks_strcmp(iks_find_attrib(x, "subscription"), "none") ||
-!iks_strcmp(iks_find_attrib(x, "subscription"), "from")) {
+			} else if (!iks_strcmp(iks_find_attrib(x, "subscription"), "none") || !iks_strcmp(iks_find_attrib(x, "subscription"), "from")) {
 				/* subscribe to buddy's presence only 
 				   if we really need to */
 				ast_set_flag(&buddy->flags, AJI_AUTOREGISTER);
@@ -2404,8 +2374,7 @@
 
 	if(roster) {
 		iks_insert_attrib(roster, "id", "roster");
-		aji_set_presence(client, NULL, client->jid->full, client->status,
-client->statusmessage);
+		aji_set_presence(client, NULL, client->jid->full, client->status, client->statusmessage);
 		ast_aji_send(client, roster);
 	}
 
@@ -2427,8 +2396,7 @@
 
 	if (client) {
 		if (client->state == AJI_DISCONNECTED) {
-			iks_filter_add_rule(client->f, aji_filter_roster, client, IKS_RULE_TYPE,
-IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "roster", IKS_RULE_DONE);
+			iks_filter_add_rule(client->f, aji_filter_roster, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, "roster", IKS_RULE_DONE);
 			client->state = AJI_CONNECTING;
 			client->jid = (iks_find_cdata(pak->query, "jid")) ? iks_id_new(client->stack, iks_find_cdata(pak->query, "jid")) : client->jid;
 			iks_filter_remove_hook(client->f, aji_client_connect);
@@ -2460,15 +2428,13 @@
 	client->stream_flags = 0;
 #endif
 	/* If it's a component, connect to user, otherwise, connect to server */
-	connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server),
-client->port, client->component ? client->user : client->jid->server);
+	connected = iks_connect_via(client->p, S_OR(client->serverhost, client->jid->server), client->port, client->component ? client->user : client->jid->server);
 
 	if (connected == IKS_NET_NOCONN) {
 		ast_log(LOG_ERROR, "JABBER ERROR: No Connection\n");
 		return IKS_HOOK;
 	} else 	if (connected == IKS_NET_NODNS) {
-		ast_log(LOG_ERROR, "JABBER ERROR: No DNS %s for client to  %s\n", client->name,
-S_OR(client->serverhost, client->jid->server));
+		ast_log(LOG_ERROR, "JABBER ERROR: No DNS %s for client to  %s\n", client->name, S_OR(client->serverhost, client->jid->server));
 		return IKS_HOOK;
 	}
 
@@ -2517,9 +2483,9 @@
 		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
-	
+
 	struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
-	
+
 	mailbox = ast_event_get_ie_str(ast_event, AST_EVENT_IE_MAILBOX);
 	context = ast_event_get_ie_str(ast_event, AST_EVENT_IE_CONTEXT);
 	snprintf(oldmsgs, sizeof(oldmsgs), "%d",
@@ -2545,7 +2511,7 @@
 		ast_log(LOG_DEBUG, "Returning here\n");
 		return;
 	}
-	
+
 	struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
 	device = ast_event_get_ie_str(ast_event, AST_EVENT_IE_DEVICE);
 	device_state = ast_devstate_str(ast_event_get_ie_uint(ast_event, AST_EVENT_IE_STATE));
@@ -2578,7 +2544,7 @@
 		IKS_PAK_MESSAGE, IKS_RULE_FROM, client->pubsub_node, IKS_RULE_DONE);
 	iks_filter_add_rule(client->f, aji_handle_pubsub_error, client, IKS_RULE_TYPE,
 		IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_ERROR, IKS_RULE_DONE);
-	
+
 }
 
 /*!
@@ -2671,7 +2637,7 @@
 {
 	iks *request = aji_pubsub_iq_create(client, "set");
 	iks *pubsub, *subscribe;
-	
+
 	pubsub = iks_insert(request, "pubsub");
 	iks_insert_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
 	subscribe = iks_insert(pubsub, "subscribe");
@@ -2703,7 +2669,7 @@
  * \brief Build the skeleton of a publish
  * \param client the configured XMPP client we use to connect to a XMPP server
  * \param node Name of the node that will be published to
- * \param event_type 
+ * \param event_type
  * \return iks *
  */
 static iks* aji_build_publish_skeleton(struct aji_client *client, const char *node,
@@ -2781,7 +2747,7 @@
 static iks* aji_pubsub_iq_create(struct aji_client *client, const char *type)
 {
 	iks *request = iks_new("iq");
-	
+
 	iks_insert_attrib(request, "to", client->pubsub_node);
 	iks_insert_attrib(request, "from", client->jid->full);
 	iks_insert_attrib(request, "type", type);
@@ -2902,7 +2868,7 @@
 			iks_find_attrib(item, "node"));
 		while((item = iks_next_tag(item))) {
 			ast_verbose("Node name: %s\n", iks_find_attrib(item, "node"));
-		} 
+		}
 	}
 	iks_delete(item);
 	return IKS_FILTER_EAT;
@@ -2947,7 +2913,7 @@
 			ast_cli(a->fd, "Unable to find client '%s'!\n", name);
 			return CLI_FAILURE;
 		}
-		
+
 		ast_cli(a->fd, "Listing pubsub nodes.\n");
 		aji_request_pubsub_nodes(client, collection);
 		return CLI_SUCCESS;
@@ -3002,7 +2968,7 @@
 	ast_aji_send(client, request);
 	iks_filter_add_rule(client->f, aji_delete_node_list, client, IKS_RULE_TYPE,
 		IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid,
-  		IKS_RULE_DONE);
+		IKS_RULE_DONE);
 	res = ast_aji_send(client, request);
 	iks_delete(request);
 }
@@ -3140,7 +3106,7 @@
 static iks* aji_build_node_config(iks *pubsub, const char *node_type, const char *collection_name)
 {
 	iks *configure, *x, *field_owner, *field_node_type, *field_node_config,
- 	*field_persist_items, *field_access_model, *field_pubsub_collection;
+	*field_persist_items, *field_access_model, *field_pubsub_collection;
 	configure = iks_insert(pubsub, "configure");
 	x = iks_insert(configure, "x");
 	iks_insert_attrib(x, "xmlns", "jabber:x:data");
@@ -3210,7 +3176,7 @@
 			ast_cli(a->fd, "Unable to find client '%s'!\n", name);
 			return CLI_FAILURE;
 		}
-		
+
 		ast_cli(a->fd, "Creating test PubSub node collection.\n");
 		aji_create_pubsub_collection(client, collection_name);
 		return CLI_SUCCESS;
@@ -3251,7 +3217,7 @@
 		ast_cli(a->fd, "Unable to find client '%s'!\n", name);
 		return CLI_FAILURE;
 	}
-		
+
 	ast_cli(a->fd, "Creating test PubSub node collection.\n");
 	aji_create_pubsub_leaf(client, collection_name, leaf_name);
 	return CLI_SUCCESS;
@@ -3937,7 +3903,7 @@
 				aji_init_event_distribution(iterator);
 			}
 		}
-	
+
 		ASTOBJ_UNLOCK(iterator);
 	});
 	




More information about the asterisk-commits mailing list