Mercurial > pidgin.yaz
comparison src/protocols/jabber/roster.c @ 9285:7a8aa87164ae
[gaim-migrate @ 10088]
Ok I'm done. This started out as shx's patch to make add/remove
buddy/buddies take GaimBuddy and GaimGroup's in various places.
I think his diff was like 2000 lines and mine is like 5000. I
tried to clean up blist.c a bit and make it more uniform. There
are some more g_return_if_fail() checks. Removed some code that
was deprecated--it's probably been long enough. Removed some
#include <multi.h>'s. Make blist.xml saving happen on a timer,
like prefs.xml and accounts.xml.
Sorry if this doesn't merge cleanly with whatever you're doing.
People should really test this a lot.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 15 Jun 2004 02:37:27 +0000 |
parents | 5d039bc19350 |
children | fb08a0973b3e |
comparison
equal
deleted
inserted
replaced
9284:fe0291162312 | 9285:7a8aa87164ae |
---|---|
193 groups = g_slist_append(groups, group_name); | 193 groups = g_slist_append(groups, group_name); |
194 } | 194 } |
195 add_gaim_buddies_in_groups(js, jid, name, groups); | 195 add_gaim_buddies_in_groups(js, jid, name, groups); |
196 } | 196 } |
197 } | 197 } |
198 | |
199 gaim_blist_save(); | |
200 } | 198 } |
201 | 199 |
202 static void jabber_roster_update(JabberStream *js, const char *name, | 200 static void jabber_roster_update(JabberStream *js, const char *name, |
203 GSList *grps) | 201 GSList *grps) |
204 { | 202 { |
244 g_slist_free(groups); | 242 g_slist_free(groups); |
245 | 243 |
246 jabber_iq_send(iq); | 244 jabber_iq_send(iq); |
247 } | 245 } |
248 | 246 |
249 void jabber_roster_add_buddy(GaimConnection *gc, const char *name, | 247 void jabber_roster_add_buddy(GaimConnection *gc, GaimBuddy *buddy, |
250 GaimGroup *grp) | 248 GaimGroup *group) |
251 { | 249 { |
252 JabberStream *js = gc->proto_data; | 250 JabberStream *js = gc->proto_data; |
253 char *who; | 251 char *who; |
254 GSList *groups = NULL; | 252 GSList *groups = NULL; |
255 JabberBuddy *jb; | 253 JabberBuddy *jb; |
257 char *my_bare_jid; | 255 char *my_bare_jid; |
258 | 256 |
259 if(!js->roster_parsed) | 257 if(!js->roster_parsed) |
260 return; | 258 return; |
261 | 259 |
262 if(!(who = jabber_get_bare_jid(name))) | 260 if(!(who = jabber_get_bare_jid(buddy->name))) |
263 return; | 261 return; |
264 | 262 |
265 jb = jabber_buddy_find(js, name, FALSE); | 263 jb = jabber_buddy_find(js, buddy->name, FALSE); |
266 | 264 |
267 if(!jb || !(jb->subscription & JABBER_SUB_TO)) { | 265 if(!jb || !(jb->subscription & JABBER_SUB_TO)) { |
268 groups = g_slist_append(groups, grp->name); | 266 groups = g_slist_append(groups, group->name); |
269 } | 267 } |
270 | 268 |
271 jabber_roster_update(js, who, groups); | 269 jabber_roster_update(js, who, groups); |
272 | 270 |
273 my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); | 271 my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); |
316 } | 314 } |
317 jabber_roster_update(gc->proto_data, name, groups); | 315 jabber_roster_update(gc->proto_data, name, groups); |
318 g_slist_free(groups); | 316 g_slist_free(groups); |
319 } | 317 } |
320 | 318 |
321 void jabber_roster_group_rename(GaimConnection *gc, const char *old_group, | 319 void jabber_roster_group_rename(GaimConnection *gc, const char *old_name, |
322 const char *new_group, GList *members) | 320 GaimGroup *group, GList *moved_buddies) |
323 { | 321 { |
324 GList *l; | 322 GList *l; |
325 if(old_group && new_group && strcmp(old_group, new_group)) { | 323 for(l = moved_buddies; l; l = l->next) { |
326 for(l = members; l; l = l->next) { | 324 GaimBuddy *buddy = l->data; |
327 jabber_roster_group_change(gc, l->data, old_group, new_group); | 325 jabber_roster_group_change(gc, buddy->name, old_name, group->name); |
328 } | 326 } |
329 } | 327 } |
330 } | 328 |
331 | 329 void jabber_roster_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, |
332 void jabber_roster_remove_buddy(GaimConnection *gc, const char *name, const char *group) { | 330 GaimGroup *group) { |
333 GSList *buddies = gaim_find_buddies(gc->account, name); | 331 GSList *buddies = gaim_find_buddies(gc->account, buddy->name); |
334 GSList *groups = NULL; | 332 GSList *groups = NULL; |
335 GaimGroup *g = gaim_find_group(group); | 333 |
336 GaimBuddy *b = gaim_find_buddy_in_group(gc->account, name, g); | 334 buddies = g_slist_remove(buddies, buddy); |
337 | |
338 buddies = g_slist_remove(buddies, b); | |
339 if(g_slist_length(buddies)) { | 335 if(g_slist_length(buddies)) { |
336 GaimBuddy *tmpbuddy; | |
337 GaimGroup *tmpgroup; | |
338 | |
340 while(buddies) { | 339 while(buddies) { |
341 b = buddies->data; | 340 tmpbuddy = buddies->data; |
342 g = gaim_find_buddys_group(b); | 341 tmpgroup = gaim_find_buddys_group(tmpbuddy); |
343 groups = g_slist_append(groups, g->name); | 342 groups = g_slist_append(groups, tmpgroup->name); |
344 buddies = g_slist_remove(buddies, b); | 343 buddies = g_slist_remove(buddies, tmpbuddy); |
345 } | 344 } |
346 jabber_roster_update(gc->proto_data, name, groups); | 345 |
346 jabber_roster_update(gc->proto_data, buddy->name, groups); | |
347 } else { | 347 } else { |
348 JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET, | 348 JabberIq *iq = jabber_iq_new_query(gc->proto_data, JABBER_IQ_SET, |
349 "jabber:iq:roster"); | 349 "jabber:iq:roster"); |
350 xmlnode *query = xmlnode_get_child(iq->node, "query"); | 350 xmlnode *query = xmlnode_get_child(iq->node, "query"); |
351 xmlnode *item = xmlnode_new_child(query, "item"); | 351 xmlnode *item = xmlnode_new_child(query, "item"); |
352 | 352 |
353 xmlnode_set_attrib(item, "jid", name); | 353 xmlnode_set_attrib(item, "jid", buddy->name); |
354 xmlnode_set_attrib(item, "subscription", "remove"); | 354 xmlnode_set_attrib(item, "subscription", "remove"); |
355 | 355 |
356 jabber_iq_send(iq); | 356 jabber_iq_send(iq); |
357 } | 357 } |
358 | 358 |