[asterisk-commits] phsultan: trunk r124870 - /trunk/res/res_jabber.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jun 24 12:28:40 CDT 2008
Author: phsultan
Date: Tue Jun 24 12:28:39 2008
New Revision: 124870
URL: http://svn.digium.com/view/asterisk?view=rev&rev=124870
Log:
Code simplification
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=124870&r1=124869&r2=124870
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue Jun 24 12:28:39 2008
@@ -2051,37 +2051,39 @@
iks *removequery = iks_new("query");
iks *removeitem = iks_new("item");
iks *send = iks_make_iq(IKS_TYPE_GET, "http://jabber.org/protocol/disco#items");
-
- if (client && removeiq && removequery && removeitem && send) {
- iks_insert_node(removeiq, removequery);
- iks_insert_node(removequery, removeitem);
- ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, {
- 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)) {
- 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"));
- res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
- "GoodBye you are no longer in the asterisk config file so I am removing"
- " your access to my presence.\n"));
- iks_insert_attrib(removeiq, "from", client->jid->full);
- iks_insert_attrib(removeiq, "type", "set");
- iks_insert_attrib(removequery, "xmlns", "jabber:iq:roster");
- iks_insert_attrib(removeitem, "jid", iterator->name);
- iks_insert_attrib(removeitem, "subscription", "remove");
- res = ast_aji_send(client, removeiq);
- } else if (ast_test_flag(&iterator->flags, AJI_AUTOREGISTER)) {
- res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name,
- "Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
- ast_clear_flag(&iterator->flags, AJI_AUTOREGISTER);
- }
- ASTOBJ_UNLOCK(iterator);
- });
- } else
+ if (!client || !removeiq || !removequery || !removeitem || !send) {
ast_log(LOG_ERROR, "Out of memory.\n");
-
+ goto safeout;
+ }
+
+ iks_insert_node(removeiq, removequery);
+ iks_insert_node(removequery, removeitem);
+ ASTOBJ_CONTAINER_TRAVERSE(&client->buddies, 1, {
+ 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)) {
+ 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"));
+ res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
+ "GoodBye you are no longer in the asterisk config file so I am removing"
+ " your access to my presence.\n"));
+ iks_insert_attrib(removeiq, "from", client->jid->full);
+ iks_insert_attrib(removeiq, "type", "set");
+ iks_insert_attrib(removequery, "xmlns", "jabber:iq:roster");
+ iks_insert_attrib(removeitem, "jid", iterator->name);
+ iks_insert_attrib(removeitem, "subscription", "remove");
+ res = ast_aji_send(client, removeiq);
+ } else if (ast_test_flag(&iterator->flags, AJI_AUTOREGISTER)) {
+ res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name,
+ "Greetings I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
+ ast_clear_flag(&iterator->flags, AJI_AUTOREGISTER);
+ }
+ ASTOBJ_UNLOCK(iterator);
+ });
+
+ safeout:
iks_delete(removeiq);
iks_delete(removequery);
iks_delete(removeitem);
More information about the asterisk-commits
mailing list