Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/buddy.c @ 27334:ea9df9bfa921
If get_info_for_jid is passed a full JID, don't spam that JID with IQs.
Looping over all the resources while using the passed-in JID as the to
address was causing us to generate O(N) queries to a member of a MUC (where
N is the number of people in the room).
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 02 Jul 2009 22:03:21 +0000 |
parents | c408e4dc3101 |
children | f92e2fdfeda4 |
comparison
equal
deleted
inserted
replaced
27333:c408e4dc3101 | 27334:ea9df9bfa921 |
---|---|
1723 JabberIq *iq; | 1723 JabberIq *iq; |
1724 xmlnode *vcard; | 1724 xmlnode *vcard; |
1725 GList *resources; | 1725 GList *resources; |
1726 JabberBuddy *jb; | 1726 JabberBuddy *jb; |
1727 JabberBuddyInfo *jbi; | 1727 JabberBuddyInfo *jbi; |
1728 const char *slash; | |
1728 gboolean is_bare_jid; | 1729 gboolean is_bare_jid; |
1729 | 1730 |
1730 jb = jabber_buddy_find(js, jid, TRUE); | 1731 jb = jabber_buddy_find(js, jid, TRUE); |
1731 | 1732 |
1732 /* invalid JID */ | 1733 /* invalid JID */ |
1733 if(!jb) | 1734 if(!jb) |
1734 return; | 1735 return; |
1735 | 1736 |
1736 is_bare_jid = (strchr(jid, '/') == NULL); | 1737 slash = strchr(jid, '/'); |
1738 is_bare_jid = (slash == NULL); | |
1737 | 1739 |
1738 jbi = g_new0(JabberBuddyInfo, 1); | 1740 jbi = g_new0(JabberBuddyInfo, 1); |
1739 jbi->jid = g_strdup(jid); | 1741 jbi->jid = g_strdup(jid); |
1740 jbi->js = js; | 1742 jbi->js = js; |
1741 jbi->jb = jb; | 1743 jbi->jb = jb; |
1751 jabber_iq_set_callback(iq, jabber_vcard_parse, jbi); | 1753 jabber_iq_set_callback(iq, jabber_vcard_parse, jbi); |
1752 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); | 1754 jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id)); |
1753 | 1755 |
1754 jabber_iq_send(iq); | 1756 jabber_iq_send(iq); |
1755 | 1757 |
1756 for(resources = jb->resources; resources; resources = resources->next) | 1758 if (is_bare_jid) { |
1757 { | 1759 for(resources = jb->resources; resources; resources = resources->next) { |
1758 JabberBuddyResource *jbr = resources->data; | 1760 JabberBuddyResource *jbr = resources->data; |
1759 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); | 1761 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); |
1762 } | |
1763 } else { | |
1764 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, slash + 1); | |
1765 if (jbr) | |
1766 dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr); | |
1767 else | |
1768 purple_debug_warning("jabber", "jabber_buddy_get_info_for_jid() " | |
1769 "was passed JID %s, but there is no corresponding " | |
1770 "JabberBuddyResource!\n", jid); | |
1760 } | 1771 } |
1761 | 1772 |
1762 if (!jb->resources && is_bare_jid) { | 1773 if (!jb->resources && is_bare_jid) { |
1763 /* user is offline, send a jabber:iq:last to find out last time online */ | 1774 /* user is offline, send a jabber:iq:last to find out last time online */ |
1764 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last"); | 1775 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:last"); |