Mercurial > pidgin.yaz
changeset 7116:6c8706109f92
[gaim-migrate @ 7683]
fix a big ugly memleak on jabber account signoff, fix the img display in vcards until the gtk code can be talked into understanding proper XHTML, and a few misc other things I felt like getting out of my tree.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 02 Oct 2003 01:58:26 +0000 |
parents | 7bee4be16385 |
children | 943085b0ff8b |
files | src/protocols/jabber/buddy.c src/protocols/jabber/buddy.h src/protocols/jabber/iq.c src/protocols/jabber/jabber.c |
diffstat | 4 files changed, 46 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/jabber/buddy.c Thu Oct 02 01:57:26 2003 +0000 +++ b/src/protocols/jabber/buddy.c Thu Oct 02 01:58:26 2003 +0000 @@ -34,6 +34,18 @@ #include "xmlnode.h" +void jabber_buddy_free(JabberBuddy *jb) +{ + g_return_if_fail(jb != NULL); + + if(jb->error_msg) + g_free(jb->error_msg); + while(jb->resources) + jabber_buddy_resource_free(jb->resources->data); + + g_free(jb); +} + JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name, gboolean create) { @@ -97,6 +109,7 @@ if(!jbr) { jbr = g_new0(JabberBuddyResource, 1); + jbr->jb = jb; jbr->name = g_strdup(resource); jbr->capabilities = JABBER_CAP_XHTML; jb->resources = g_list_append(jb->resources, jbr); @@ -108,6 +121,18 @@ jbr->status = g_strdup(status); } +void jabber_buddy_resource_free(JabberBuddyResource *jbr) +{ + g_return_if_fail(jbr != NULL); + + jbr->jb->resources = g_list_remove(jbr->jb->resources, jbr); + + g_free(jbr->name); + if(jbr->status) + g_free(jbr->status); + g_free(jbr); +} + void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource) { JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, resource); @@ -115,12 +140,7 @@ if(!jbr) return; - jb->resources = g_list_remove(jb->resources, jbr); - - g_free(jbr->name); - if(jbr->status) - g_free(jbr->status); - g_free(jbr); + jabber_buddy_resource_free(jbr); } const char *jabber_buddy_get_status_msg(JabberBuddy *jb) @@ -524,6 +544,8 @@ if(!from) return; + /* XXX: make this handle handle errors */ + resource_name = jabber_get_resource(from); jb = jabber_buddy_find(js, from, TRUE); @@ -725,7 +747,7 @@ imgid = gaim_imgstore_add(data, size, "logo.png"); g_string_append_printf(info_text, - "<b>%s:</b> <img id='%d' /><br/>", + "<b>%s:</b> <img id='%d'><br/>", strcmp(child->name, "PHOTO") == 0 ? _("Photo") : _("Logo"), imgid);
--- a/src/protocols/jabber/buddy.h Thu Oct 02 01:57:26 2003 +0000 +++ b/src/protocols/jabber/buddy.h Thu Oct 02 01:58:26 2003 +0000 @@ -24,17 +24,6 @@ #include "jabber.h" -typedef struct _JabberBuddyResource { - char *name; - int priority; - int state; - char *status; - enum { - JABBER_CAP_XHTML = 1 << 1, - JABBER_CAP_COMPOSING = 1 << 2 - } capabilities; -} JabberBuddyResource; - typedef struct _JabberBuddy { GList *resources; char *error_msg; @@ -52,12 +41,26 @@ } subscription; } JabberBuddy; +typedef struct _JabberBuddyResource { + JabberBuddy *jb; + char *name; + int priority; + int state; + char *status; + enum { + JABBER_CAP_XHTML = 1 << 1, + JABBER_CAP_COMPOSING = 1 << 2 + } capabilities; +} JabberBuddyResource; + +void jabber_buddy_free(JabberBuddy *jb); JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name, gboolean create); JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb, const char *resource); void jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, int priority, int state, const char *status); +void jabber_buddy_resource_free(JabberBuddyResource *jbr); void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource); const char *jabber_buddy_get_status_msg(JabberBuddy *jb); void jabber_buddy_get_info(GaimConnection *gc, const char *who);
--- a/src/protocols/jabber/iq.c Thu Oct 02 01:57:26 2003 +0000 +++ b/src/protocols/jabber/iq.c Thu Oct 02 01:58:26 2003 +0000 @@ -229,6 +229,8 @@ jabber_iq_handle_version(js, packet); } else if(!strcmp(xmlns, "jabber:iq:register")) { jabber_register_parse(js, packet); + } else if(!strcmp(xmlns, "jabber:iq:oob")) { + /* XXX: need to re-implement file receive for the old-skool way */ } else { gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown query: %s\n", xmlns); }
--- a/src/protocols/jabber/jabber.c Thu Oct 02 01:57:26 2003 +0000 +++ b/src/protocols/jabber/jabber.c Thu Oct 02 01:58:26 2003 +0000 @@ -352,7 +352,7 @@ js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, NULL); + g_free, (GDestroyNotify)jabber_buddy_free); js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); js->user = jabber_id_new(gaim_account_get_username(account));