Merged revisions 124872 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
r124872 | phsultan | 2008-06-24 19:50:22 +0200 (Tue, 24 Jun 2008) | 6 lines

Subscribe to buddy's presence only if we really need to. That is, if
the corresponding roster item has a subscription value set to "none"
or "from".

Make the code more readable.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@124873 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Philippe Sultan 17 years ago
parent 4ee5ce0e55
commit a8231e854e

@ -2137,7 +2137,12 @@ static int aji_filter_roster(void *data, ikspak *pak)
ASTOBJ_UNLOCK(iterator); ASTOBJ_UNLOCK(iterator);
}); });
if (!flag) { if (flag) {
/* found buddy, don't create a new one */
x = iks_next(x);
continue;
}
buddy = ast_calloc(1, sizeof(*buddy)); buddy = ast_calloc(1, sizeof(*buddy));
if (!buddy) { if (!buddy) {
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
@ -2150,15 +2155,17 @@ static int aji_filter_roster(void *data, ikspak *pak)
if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) { if(ast_test_flag(&client->flags, AJI_AUTOPRUNE)) {
ast_set_flag(&buddy->flags, AJI_AUTOPRUNE); ast_set_flag(&buddy->flags, AJI_AUTOPRUNE);
ASTOBJ_MARK(buddy); ASTOBJ_MARK(buddy);
} else } 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); ast_set_flag(&buddy->flags, AJI_AUTOREGISTER);
}
ASTOBJ_UNLOCK(buddy); ASTOBJ_UNLOCK(buddy);
if (buddy) { if (buddy) {
ASTOBJ_CONTAINER_LINK(&client->buddies, buddy); ASTOBJ_CONTAINER_LINK(&client->buddies, buddy);
ASTOBJ_UNREF(buddy, aji_buddy_destroy); ASTOBJ_UNREF(buddy, aji_buddy_destroy);
} }
} }
}
x = iks_next(x); x = iks_next(x);
} }

Loading…
Cancel
Save