Mercurial > pidgin.yaz
changeset 8194:22b3974dc1af
[gaim-migrate @ 8916]
a bunch of tweaks to jabber roster handling, and a fix for a segfault when you delete the priority buddy in a contact
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 01 Feb 2004 01:06:10 +0000 |
parents | e0a70b763872 |
children | 7da65537d28e |
files | src/blist.c src/protocols/jabber/buddy.h src/protocols/jabber/jabber.c src/protocols/jabber/roster.c |
diffstat | 4 files changed, 66 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/blist.c Sat Jan 31 22:30:29 2004 +0000 +++ b/src/blist.c Sun Feb 01 01:06:10 2004 +0000 @@ -1090,6 +1090,10 @@ cnode->child = node->next; } + if(((GaimContact*)cnode)->priority == buddy) { + gaim_contact_compute_priority_buddy((GaimContact*)cnode); + ops->update(gaimbuddylist, cnode); + } hb.name = g_strdup(gaim_normalize(buddy->account, buddy->name)); hb.account = buddy->account;
--- a/src/protocols/jabber/buddy.h Sat Jan 31 22:30:29 2004 +0000 +++ b/src/protocols/jabber/buddy.h Sun Feb 01 01:06:10 2004 +0000 @@ -37,7 +37,8 @@ JABBER_SUB_PENDING = 1 << 1, JABBER_SUB_TO = 1 << 2, JABBER_SUB_FROM = 1 << 3, - JABBER_SUB_BOTH = (JABBER_SUB_TO | JABBER_SUB_FROM) + JABBER_SUB_BOTH = (JABBER_SUB_TO | JABBER_SUB_FROM), + JABBER_SUB_REMOVE = 1 << 4 } subscription; } JabberBuddy;
--- a/src/protocols/jabber/jabber.c Sat Jan 31 22:30:29 2004 +0000 +++ b/src/protocols/jabber/jabber.c Sun Feb 01 01:06:10 2004 +0000 @@ -917,36 +917,60 @@ { JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, FALSE); - JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); - char *ret = NULL; - - if(jbr) { - char *text = NULL; - if(jbr->status) { - char *stripped; - stripped = gaim_markup_strip_html(jbr->status); - text = g_markup_escape_text(stripped, -1); - g_free(stripped); - } + GString *ret = g_string_new(""); + char *r = NULL; - ret = g_strdup_printf("<b>%s:</b> %s%s%s", - _("Status"), - jabber_get_state_string(jbr->state), - text ? ": " : "", - text ? text : ""); - if(text) - g_free(text); - } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { - ret = g_strdup_printf("<b>%s:</b> %s", - _("Error"), jb->error_msg); - } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && - (jb->subscription & JABBER_SUB_PENDING || - !(jb->subscription & JABBER_SUB_TO))) { - ret = g_strdup_printf("<b>%s:</b> %s", - _("Status"), _("Not Authorized")); + if(jb) { + JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); + const char *sub; + if(jb->subscription & JABBER_SUB_FROM) { + if(jb->subscription & JABBER_SUB_TO) + sub = _("Both"); + else if(jb->subscription & JABBER_SUB_PENDING) + sub = _("From (To pending)"); + else + sub = _("From"); + } else { + if(jb->subscription & JABBER_SUB_TO) + sub = _("To"); + else if(jb->subscription & JABBER_SUB_PENDING) + sub = _("None (To pending)"); + else + sub = _("None"); + } + g_string_append_printf(ret, "<b>%s:</b> %s\n", _("Subscription"), sub); + + if(jbr) { + char *text = NULL; + if(jbr->status) { + char *stripped; + stripped = gaim_markup_strip_html(jbr->status); + text = g_markup_escape_text(stripped, -1); + g_free(stripped); + } + + g_string_append_printf(ret, "<b>%s:</b> %s%s%s\n", + _("Status"), + jabber_get_state_string(jbr->state), + text ? ": " : "", + text ? text : ""); + if(text) + g_free(text); + } else if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { + g_string_append_printf(ret, "<b>%s:</b> %s\n", + _("Error"), jb->error_msg); + } } - return ret; + if(ret->len > 0) { + g_string_truncate(ret, ret->len-1); + r = ret->str; + g_string_free(ret, FALSE); + } else { + g_string_free(ret, TRUE); + } + + return r; } static GList *jabber_away_states(GaimConnection *gc)
--- a/src/protocols/jabber/roster.c Sat Jan 31 22:30:29 2004 +0000 +++ b/src/protocols/jabber/roster.c Sun Feb 01 01:06:10 2004 +0000 @@ -167,6 +167,8 @@ jb->subscription = JABBER_SUB_FROM; else if(!strcmp(subscription, "both")) jb->subscription = JABBER_SUB_BOTH; + else if(!strcmp(subscription, "remove")) + jb->subscription = JABBER_SUB_REMOVE; else jb->subscription = JABBER_SUB_NONE; @@ -175,11 +177,10 @@ else jb->subscription &= ~JABBER_SUB_PENDING; - if(jb->subscription == JABBER_SUB_NONE) { + if(jb->subscription == JABBER_SUB_REMOVE) { remove_gaim_buddies(js, jid); } else { GSList *groups = NULL; - for(group = xmlnode_get_child(item, "group"); group; group = xmlnode_get_next_twin(group)) { char *group_name; @@ -188,14 +189,6 @@ groups = g_slist_append(groups, group_name); } add_gaim_buddies_in_groups(js, jid, name, groups); - - if(jb->subscription == JABBER_SUB_BOTH) { - char *my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); - if(!strcmp(jid, my_bare_jid)) { - jabber_presence_fake_to_self(js, js->gc->away_state, js->gc->away); - } - g_free(my_bare_jid); - } } } @@ -257,6 +250,7 @@ GSList *groups = NULL; JabberBuddy *jb; JabberBuddyResource *jbr; + char *my_bare_jid; if(!js->roster_parsed) return; @@ -272,11 +266,15 @@ jabber_roster_update(js, who, groups); - if(!jb || !(jb->subscription & JABBER_SUB_TO)) + my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + if(!strcmp(who, my_bare_jid)) + jabber_presence_fake_to_self(js, js->gc->away_state, js->gc->away); + else if(!jb || !(jb->subscription & JABBER_SUB_TO)) jabber_presence_subscription_set(js, who, "subscribe"); else if((jbr =jabber_buddy_find_resource(jb, NULL))) serv_got_update(gc, who, 1, 0, 0, 0, jbr->state); + g_free(my_bare_jid); g_free(who); }