pidgin: b5a5f38c: jabber: Fix getting info on your own JID...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sun Feb 14 19:31:20 EST 2010
-----------------------------------------------------------------
Revision: b5a5f38cb77e61bca90f7791428de9ec3c742771
Ancestor: 8cc16fcb41111aae817fe10168b40d82990895c5
Author: darkrain42 at pidgin.im
Date: 2010-02-14T23:56:00
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b5a5f38cb77e61bca90f7791428de9ec3c742771
Modified files:
ChangeLog libpurple/protocols/jabber/buddy.c
ChangeLog:
jabber: Fix getting info on your own JID, under some circumstances.
Prosody doesn't stamp a 'from' on responses from one's own bare JID (and
the spec does not require it), so neither of these functions can rely on
'from' being non-NULL. Of course, we shouldn't be sending an NS_LAST_ACTIVITY
to our own bare JID, but that's another issue.
-------------- next part --------------
============================================================
--- ChangeLog 6812c01711f9b82376faf40767bbab81f256ef60
+++ ChangeLog 5ed02c27c245c713e9616389860f07a50eb98e0c
@@ -49,6 +49,7 @@ version 2.6.6 (??/??/20??):
* When getting info on a domain-only (server) JID, show uptime
(when given by the result of the "last query") and don't show status as
offline.
+ * Fix getting info on your own JID.
* Wrap XHTML messages in <p>, as described in XEP-0071, for compatibility
with some clients.
* Don't do an SRV lookup for a STUN server associated with the account
============================================================
--- libpurple/protocols/jabber/buddy.c 0c8b7646ec51795cd8296b341efde6504c1e7035
+++ libpurple/protocols/jabber/buddy.c 8c542107d95d7958f3bf99937f9ec7ff66cf8e22
@@ -980,28 +980,25 @@ static void jabber_vcard_parse(JabberStr
char *text;
char *serverside_alias = NULL;
xmlnode *vcard;
- PurpleBuddy *b;
+ PurpleAccount *account;
JabberBuddyInfo *jbi = data;
PurpleNotifyUserInfo *user_info;
- if(!jbi)
- return;
+ g_return_if_fail(jbi != NULL);
jabber_buddy_info_remove_id(jbi, id);
- if(!from)
+ if (type == JABBER_IQ_ERROR) {
+ purple_debug_info("jabber", "Got error response for vCard\n");
+ jabber_buddy_info_show_if_ready(jbi);
return;
+ }
- if(!jabber_buddy_find(js, from, FALSE))
- return;
-
- /* XXX: handle the error case */
-
user_info = jbi->user_info;
- bare_jid = jabber_get_bare_jid(from);
+ account = purple_connection_get_account(js->gc);
+ bare_jid = jabber_get_bare_jid(from ? from : purple_account_get_username(account));
- b = purple_find_buddy(js->gc->account, bare_jid);
-
+ /* TODO: Is the query xmlns='vcard-temp' version of this still necessary? */
if((vcard = xmlnode_get_child(packet, "vCard")) ||
(vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
xmlnode *child;
@@ -1183,8 +1180,7 @@ static void jabber_vcard_parse(JabberStr
purple_notify_user_info_add_pair(user_info, (photo ? _("Photo") : _("Logo")), img_text);
hash = jabber_calculate_data_sha1sum(data, size);
- purple_buddy_icons_set_for_user(js->gc->account, bare_jid,
- data, size, hash);
+ purple_buddy_icons_set_for_user(account, bare_jid, data, size, hash);
g_free(hash);
g_free(img_text);
}
@@ -1196,8 +1192,10 @@ static void jabber_vcard_parse(JabberStr
}
if (serverside_alias) {
+ PurpleBuddy *b;
/* If we found a serverside alias, set it and tell the core */
- serv_got_alias(js->gc, from, serverside_alias);
+ serv_got_alias(js->gc, bare_jid, serverside_alias);
+ b = purple_find_buddy(account, bare_jid);
if (b) {
purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias);
}
@@ -1363,9 +1361,6 @@ static void jabber_last_offline_parse(Ja
jabber_buddy_info_remove_id(jbi, id);
- if(!from)
- return;
-
if (type == JABBER_IQ_RESULT) {
if((query = xmlnode_get_child(packet, "query"))) {
seconds = xmlnode_get_attrib(query, "seconds");
@@ -1587,9 +1582,18 @@ static void jabber_buddy_get_info_for_ji
jabber_iq_send(iq);
if (is_bare_jid) {
- for(resources = jb->resources; resources; resources = resources->next) {
- JabberBuddyResource *jbr = resources->data;
- dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
+ if (jb->resources) {
+ for(resources = jb->resources; resources; resources = resources->next) {
+ JabberBuddyResource *jbr = resources->data;
+ dispatch_queries_for_resource(js, jbi, is_bare_jid, jid, jbr);
+ }
+ } else {
+ /* user is offline, send a jabber:iq:last to find out last time online */
+ iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY);
+ xmlnode_set_attrib(iq->node, "to", jid);
+ jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi);
+ jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
+ jabber_iq_send(iq);
}
} else {
JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, slash + 1);
@@ -1601,15 +1605,6 @@ static void jabber_buddy_get_info_for_ji
"JabberBuddyResource!\n", jid);
}
- if (!jb->resources && is_bare_jid) {
- /* user is offline, send a jabber:iq:last to find out last time online */
- iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_LAST_ACTIVITY);
- xmlnode_set_attrib(iq->node, "to", jid);
- jabber_iq_set_callback(iq, jabber_last_offline_parse, jbi);
- jbi->ids = g_slist_prepend(jbi->ids, g_strdup(iq->id));
- jabber_iq_send(iq);
- }
-
js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi);
jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi);
}
More information about the Commits
mailing list