Mercurial > pidgin
diff libpurple/protocols/jabber/buddy.c @ 25978:7e020fbe2cdb
propagate from branch 'im.pidgin.pidgin' (head 303af74a38e7b313d4fb0be4d4054a16cb13d819)
to branch 'im.pidgin.cpw.darkrain42.xmpp.avatars' (head 11e989f3ac36a0f958f031d55245db093923ea76)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 07 Mar 2009 01:32:29 +0000 |
parents | 2d92bbe6807b 5f9a24d1c25e |
children | 14e1f9af369f |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Sat Feb 14 18:23:13 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sat Mar 07 01:32:29 2009 +0000 @@ -169,7 +169,7 @@ g_return_if_fail(jbr != NULL); jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr); - + while(jbr->commands) { JabberAdHocCommands *cmd = jbr->commands->data; g_free(cmd->jid); @@ -178,7 +178,7 @@ g_free(cmd); jbr->commands = g_list_delete_link(jbr->commands, jbr->commands); } - + jabber_caps_free_clientinfo(jbr->caps); g_free(jbr->name); @@ -421,7 +421,7 @@ { PurpleStoredImage *img; JabberIq *iq; - JabberStream *js = gc->proto_data; + JabberStream *js = purple_connection_get_protocol_data(gc); xmlnode *vc_node; const struct tag_attr *tag_attr; @@ -472,6 +472,7 @@ enc = purple_base64_encode(avatar_data, avatar_len); js->avatar_hash = jabber_calculate_data_sha1sum(avatar_data, avatar_len); + xmlnode_insert_data(binval, enc, -1); g_free(enc); } else if (vc_node) { @@ -687,18 +688,18 @@ (jbr->client.version ? jbr->client.version : "")); purple_notify_user_info_add_pair(user_info, _("Client"), tmp); g_free(tmp); - + if(jbr->client.os) { purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os); } - } + } if(jbir) { if(jbir->idle_seconds > 0) { char *idle = purple_str_seconds_to_string(jbir->idle_seconds); purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle); g_free(idle); } - } + } if(jbr) { char *purdy = NULL; const char *status_name = jabber_buddy_state_get_name(jbr->state); @@ -716,7 +717,7 @@ } else { purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown")); } -#if 0 +#if 0 /* #if 0 this for now; I think this would be far more useful if we limited this to a particular set of features * of particular interest (-vv jumps out as one). As it is now, I don't picture people getting all excited: "Oh sweet crap! * So-and-so supports 'jabber:x:data' AND 'Collaborative Data Objects'!" @@ -727,7 +728,7 @@ GList *iter; for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) { const char *feature = iter->data; - + if(!strcmp(feature, "jabber:iq:last")) feature = _("Last Activity"); else if(!strcmp(feature, "http://jabber.org/protocol/disco#info")) @@ -836,7 +837,7 @@ if(strlen(tmp->str) > 0) purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str); - + g_string_free(tmp, TRUE); } #endif @@ -856,7 +857,7 @@ purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp); g_free(tmp); - + if(jbr->client.os) { purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os); } @@ -875,14 +876,14 @@ purdy = purple_strdup_withhtml(jbr->status); if(status_name && purdy && !strcmp(status_name, purdy)) status_name = NULL; - + tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""), ((status_name && purdy) ? ": " : ""), (purdy ? purdy : "")); purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp); g_free(tmp); g_free(purdy); - + if(multiple_resources) { tmp = g_strdup_printf("%d", jbr->priority); purple_notify_user_info_prepend_pair(user_info, _("Priority"), tmp); @@ -897,7 +898,7 @@ GList *iter; for(iter = jbr->caps->features; iter; iter = g_list_next(iter)) { const char *feature = iter->data; - + if(!strcmp(feature, "jabber:iq:last")) feature = _("Last Activity"); else if(!strcmp(feature, "http://jabber.org/protocol/disco#info")) @@ -1000,13 +1001,13 @@ feature = _("Hop Check"); else if(g_str_has_suffix(feature, "+notify")) feature = NULL; - + if(feature) g_string_append_printf(tmp, "%s\n", feature); } if(strlen(tmp->str) > 0) purple_notify_user_info_prepend_pair(user_info, _("Capabilities"), tmp->str); - + g_string_free(tmp, TRUE); } #endif @@ -1093,7 +1094,7 @@ void jabber_vcard_fetch_mine(JabberStream *js) { JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET); - + xmlnode *vcard = xmlnode_new_child(iq->node, "vCard"); xmlnode_set_namespace(vcard, "vcard-temp"); jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL); @@ -1167,13 +1168,13 @@ } g_free(text2); } - } else if(text && !strcmp(child->name, "NICKNAME")) { + } else if(text && !strcmp(child->name, "NICKNAME")) { /* Prefer the Nickcname to the Full Name as the serverside alias if it's not just part of the jid. * Ignore it if it's part of the jid. */ if (strstr(bare_jid, text) == NULL) { g_free(serverside_alias); serverside_alias = g_strdup(text); - + purple_notify_user_info_add_pair(user_info, _("Nickname"), text); } } else if(text && !strcmp(child->name, "BDAY")) { @@ -1218,7 +1219,7 @@ } g_free(text2); } - + if (address_line_added) purple_notify_user_info_add_section_break(user_info); @@ -1260,8 +1261,8 @@ escaped = g_markup_escape_text(userid, -1); mailto = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", escaped, escaped); purple_notify_user_info_add_pair(user_info, _("Email"), mailto); - - g_free(mailto); + + g_free(mailto); g_free(escaped); g_free(userid); } @@ -1328,7 +1329,7 @@ if (b) { purple_blist_node_set_string((PurpleBlistNode*)b, "servernick", serverside_alias); } - + g_free(serverside_alias); } @@ -1569,13 +1570,13 @@ void jabber_buddy_get_info(PurpleConnection *gc, const char *who) { - JabberStream *js = gc->proto_data; + JabberStream *js = purple_connection_get_protocol_data(gc); JabberID *jid = jabber_id_new(who); if (!jid) return; - if (jabber_chat_find(js, jid->node, jid->domain)) { + if (jid->node && jabber_chat_find(js, jid->node, jid->domain)) { /* For a conversation, include the resource (indicates the user). */ jabber_buddy_get_info_for_jid(js, who); } else { @@ -1629,10 +1630,10 @@ g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; - gc = purple_account_get_connection(buddy->account); - js = gc->proto_data; + gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + js = purple_connection_get_protocol_data(gc); - jabber_buddy_set_invisibility(js, buddy->name, TRUE); + jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), TRUE); } static void jabber_buddy_make_visible(PurpleBlistNode *node, gpointer data) @@ -1644,10 +1645,10 @@ g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; - gc = purple_account_get_connection(buddy->account); - js = gc->proto_data; + gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + js = purple_connection_get_protocol_data(gc); - jabber_buddy_set_invisibility(js, buddy->name, FALSE); + jabber_buddy_set_invisibility(js, purple_buddy_get_name(buddy), FALSE); } static void jabber_buddy_cancel_presence_notification(PurpleBlistNode *node, @@ -1660,11 +1661,11 @@ g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; - gc = purple_account_get_connection(buddy->account); - js = gc->proto_data; + gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + js = purple_connection_get_protocol_data(gc); /* I wonder if we should prompt the user before doing this */ - jabber_presence_subscription_set(js, buddy->name, "unsubscribed"); + jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribed"); } static void jabber_buddy_rerequest_auth(PurpleBlistNode *node, gpointer data) @@ -1676,10 +1677,10 @@ g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; - gc = purple_account_get_connection(buddy->account); - js = gc->proto_data; + gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + js = purple_connection_get_protocol_data(gc); - jabber_presence_subscription_set(js, buddy->name, "subscribe"); + jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "subscribe"); } @@ -1692,18 +1693,18 @@ g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); buddy = (PurpleBuddy *) node; - gc = purple_account_get_connection(buddy->account); - js = gc->proto_data; + gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + js = purple_connection_get_protocol_data(gc); - jabber_presence_subscription_set(js, buddy->name, "unsubscribe"); + jabber_presence_subscription_set(js, purple_buddy_get_name(buddy), "unsubscribe"); } static void jabber_buddy_login(PurpleBlistNode *node, gpointer data) { if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { /* simply create a directed presence of the current status */ PurpleBuddy *buddy = (PurpleBuddy *) node; - PurpleConnection *gc = purple_account_get_connection(buddy->account); - JabberStream *js = gc->proto_data; + PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + JabberStream *js = purple_connection_get_protocol_data(gc); PurpleAccount *account = purple_connection_get_account(gc); PurplePresence *gpresence = purple_account_get_presence(account); PurpleStatus *status = purple_presence_get_active_status(gpresence); @@ -1711,14 +1712,14 @@ JabberBuddyState state; char *msg; int priority; - + purple_status_to_jabber(status, &state, &msg, &priority); presence = jabber_presence_create_js(js, state, msg, priority); - + g_free(msg); - - xmlnode_set_attrib(presence, "to", buddy->name); - + + xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy)); + jabber_send(js, presence); xmlnode_free(presence); } @@ -1728,13 +1729,14 @@ if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { /* simply create a directed unavailable presence */ PurpleBuddy *buddy = (PurpleBuddy *) node; - JabberStream *js = purple_account_get_connection(buddy->account)->proto_data; + PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + JabberStream *js = purple_connection_get_protocol_data(gc); xmlnode *presence; - + presence = jabber_presence_create_js(js, JABBER_BUDDY_STATE_UNAVAILABLE, NULL, 0); - - xmlnode_set_attrib(presence, "to", buddy->name); - + + xmlnode_set_attrib(presence, "to", purple_buddy_get_name(buddy)); + jabber_send(js, presence); xmlnode_free(presence); } @@ -1742,9 +1744,10 @@ static GList *jabber_buddy_menu(PurpleBuddy *buddy) { - PurpleConnection *gc = purple_account_get_connection(buddy->account); - JabberStream *js = gc->proto_data; - JabberBuddy *jb = jabber_buddy_find(js, buddy->name, TRUE); + PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + JabberStream *js = purple_connection_get_protocol_data(gc); + const char *name = purple_buddy_get_name(buddy); + JabberBuddy *jb = jabber_buddy_find(js, name, TRUE); GList *jbrs; GList *m = NULL; @@ -1790,7 +1793,7 @@ NULL, NULL); m = g_list_append(m, act); } - + /* * This if-condition implements parts of XEP-0100: Gateway Interaction * @@ -1799,7 +1802,7 @@ * that gateways on the roster can be identified by having no '@' in their jid. This is a faily safe assumption, since * people don't tend to have a server or other service there. */ - if (g_utf8_strchr(buddy->name, -1, '@') == NULL) { + if (g_utf8_strchr(name, -1, '@') == NULL) { act = purple_menu_action_new(_("Log In"), PURPLE_CALLBACK(jabber_buddy_login), NULL, NULL); @@ -1809,7 +1812,7 @@ NULL, NULL); m = g_list_append(m, act); } - + /* add all ad hoc commands to the action menu */ for(jbrs = jb->resources; jbrs; jbrs = g_list_next(jbrs)) { JabberBuddyResource *jbr = jbrs->data; @@ -2267,7 +2270,7 @@ void jabber_user_search_begin(PurplePluginAction *action) { PurpleConnection *gc = (PurpleConnection *) action->context; - JabberStream *js = gc->proto_data; + JabberStream *js = purple_connection_get_protocol_data(gc); purple_request_input(gc, _("Enter a User Directory"), _("Enter a User Directory"), _("Select a user directory to search"),