Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/roster.c @ 28809:05867b153f03
jabber: Remove the roster pool stuff.
The purpose of this seems to be to re-use buddies (move a buddy from one
group to another instead of delete/create). purple_blist_add_buddy ends
up calling serv_move_buddy (to move the buddy server-side), but this wasn't
actually a problem due to js->currently_parsing_roster_push being set
(which wasn't obvious at all).
Anyway, long story short, both deryni and I think this is probably more
effort than it's worth.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 26 Oct 2009 02:58:28 +0000 |
parents | 5c61429ea529 |
children | 0f7025534fc5 |
comparison
equal
deleted
inserted
replaced
28808:54755c2d6836 | 28809:05867b153f03 |
---|---|
70 | 70 |
71 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid, | 71 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid, |
72 const char *alias, GSList *groups) | 72 const char *alias, GSList *groups) |
73 { | 73 { |
74 GSList *buddies, *l; | 74 GSList *buddies, *l; |
75 GSList *pool = NULL; | 75 PurpleAccount *account = purple_connection_get_account(js->gc); |
76 | 76 |
77 buddies = purple_find_buddies(js->gc->account, jid); | 77 buddies = purple_find_buddies(js->gc->account, jid); |
78 | 78 |
79 if(!groups) { | 79 if(!groups) { |
80 if(!buddies) | 80 if(!buddies) |
115 purple_serv_got_private_alias(js->gc, jid, alias); | 115 purple_serv_got_private_alias(js->gc, jid, alias); |
116 g_free(l->data); | 116 g_free(l->data); |
117 groups = g_slist_delete_link(groups, l); | 117 groups = g_slist_delete_link(groups, l); |
118 } else { | 118 } else { |
119 /* This buddy isn't in the group on the server anymore */ | 119 /* This buddy isn't in the group on the server anymore */ |
120 pool = g_slist_prepend(pool, b); | 120 purple_debug_info("jabber", "jabber_roster_parse(): Removing %s " |
121 } | 121 "from group '%s' on the local list\n", |
122 } | 122 purple_buddy_get_name(b), |
123 | 123 purple_group_get_name(g)); |
124 if (pool) { | 124 purple_blist_remove_buddy(b); |
125 GString *tmp = g_string_new(NULL); | 125 } |
126 GSList *list = pool; | |
127 for ( ; list; list = list->next) { | |
128 tmp = g_string_append(tmp, | |
129 purple_group_get_name(purple_buddy_get_group(list->data))); | |
130 if (list->next) | |
131 tmp = g_string_append(tmp, ", "); | |
132 } | |
133 | |
134 purple_debug_info("jabber", "jabber_roster_parse(): Removing %s from " | |
135 "groups: %s\n", jid, tmp->str); | |
136 g_string_free(tmp, TRUE); | |
137 } | 126 } |
138 | 127 |
139 if (groups) { | 128 if (groups) { |
140 char *tmp = roster_groups_join(groups); | 129 char *tmp = roster_groups_join(groups); |
141 purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to " | 130 purple_debug_info("jabber", "jabber_roster_parse(): Adding %s to " |
143 g_free(tmp); | 132 g_free(tmp); |
144 } | 133 } |
145 | 134 |
146 while(groups) { | 135 while(groups) { |
147 PurpleGroup *g = purple_find_group(groups->data); | 136 PurpleGroup *g = purple_find_group(groups->data); |
148 PurpleBuddy *b = NULL; | 137 PurpleBuddy *b = purple_buddy_new(account, jid, alias); |
149 | |
150 /* If there are buddies we would otherwise delete, move them to | |
151 * the new group (instead of deleting them below) | |
152 */ | |
153 if (pool) { | |
154 b = pool->data; | |
155 pool = g_slist_delete_link(pool, pool); | |
156 } else { | |
157 b = purple_buddy_new(js->gc->account, jid, alias); | |
158 } | |
159 | 138 |
160 if(!g) { | 139 if(!g) { |
161 g = purple_group_new(groups->data); | 140 g = purple_group_new(groups->data); |
162 purple_blist_add_group(g, NULL); | 141 purple_blist_add_group(g, NULL); |
163 } | 142 } |
165 purple_blist_add_buddy(b, NULL, g, NULL); | 144 purple_blist_add_buddy(b, NULL, g, NULL); |
166 purple_blist_alias_buddy(b, alias); | 145 purple_blist_alias_buddy(b, alias); |
167 | 146 |
168 g_free(groups->data); | 147 g_free(groups->data); |
169 groups = g_slist_delete_link(groups, groups); | 148 groups = g_slist_delete_link(groups, groups); |
170 } | |
171 | |
172 /* Remove this person from all the groups they're no longer in on the | |
173 * server */ | |
174 while (pool) { | |
175 PurpleBuddy *b = pool->data; | |
176 purple_blist_remove_buddy(b); | |
177 pool = g_slist_delete_link(pool, pool); | |
178 } | 149 } |
179 | 150 |
180 g_slist_free(buddies); | 151 g_slist_free(buddies); |
181 } | 152 } |
182 | 153 |