Mercurial > pidgin
diff src/protocols/yahoo/yahoo.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 | fe0291162312 |
children | 750d9b56a465 |
line wrap: on
line diff
--- a/src/protocols/yahoo/yahoo.c Tue Jun 15 01:17:16 2004 +0000 +++ b/src/protocols/yahoo/yahoo.c Tue Jun 15 02:37:27 2004 +0000 @@ -46,7 +46,7 @@ /* #define YAHOO_DEBUG */ -static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); +static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); static void yahoo_send_buddy_icon_request(GaimConnection *gc, const char *who); struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) @@ -417,8 +417,7 @@ } } -static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group, - gboolean *export) +static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group) { GaimBuddy *b; GaimGroup *g; @@ -455,7 +454,6 @@ } b = gaim_buddy_new(account, name, NULL); gaim_blist_add_buddy(b, NULL, g, NULL); - *export = TRUE; } if (list) { @@ -472,10 +470,6 @@ GSList *list = value, *i; GaimBuddy *b; GaimGroup *g; - gboolean *export = user_data; - - if (list) - *export = TRUE; for (i = list; i; i = i->next) { b = i->data; @@ -593,7 +587,7 @@ export = TRUE; } - yahoo_do_group_check(account, ht, norm_bud, grp, &export); + yahoo_do_group_check(account, ht, norm_bud, grp); g_free(norm_bud); } g_strfreev(buddies); @@ -604,7 +598,7 @@ g_string_free(yd->tmp_serv_blist, TRUE); yd->tmp_serv_blist = NULL; - g_hash_table_foreach(ht, yahoo_do_group_cleanup, &export); + g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); g_hash_table_destroy(ht); } @@ -626,8 +620,6 @@ gc->account->perm_deny = 4; serv_set_permit_deny(gc); } - if (export) - gaim_blist_save(); } static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) @@ -1620,31 +1612,30 @@ } } -static void ignore_buddy(GaimBuddy *b) { - GaimGroup *g; - GaimConversation *c; +static void ignore_buddy(GaimBuddy *buddy) { + GaimGroup *group; + GaimConversation *conv; GaimAccount *account; gchar *name; - if (!b) + if (!buddy) return; - g = gaim_find_buddys_group(b); - name = g_strdup(b->name); - account = b->account; + group = gaim_find_buddys_group(buddy); + name = g_strdup(buddy->name); + account = buddy->account; gaim_debug(GAIM_DEBUG_INFO, "blist", - "Removing '%s' from buddy list.\n", b->name); - serv_remove_buddy(account->gc, name, g->name); - gaim_blist_remove_buddy(b); + "Removing '%s' from buddy list.\n", buddy->name); + serv_remove_buddy(account->gc, buddy, group); + gaim_blist_remove_buddy(buddy); serv_add_deny(account->gc, name); - gaim_blist_save(); - - c = gaim_find_conversation_with_account(name, account); - - if (c != NULL) - gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); + + conv = gaim_find_conversation_with_account(name, account); + + if (conv != NULL) + gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); g_free(name); } @@ -2598,7 +2589,7 @@ buddy = (GaimBuddy *) node; gc = gaim_account_get_connection(buddy->account); - yahoo_add_buddy(gc, buddy->name, NULL); + yahoo_add_buddy(gc, buddy, NULL); } @@ -2958,7 +2949,8 @@ yahoo_packet_free(pkt); } -static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *foo) +/* XXX - What's the deal with GaimGroup *foo? */ +static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) { struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; struct yahoo_packet *pkt; @@ -2972,7 +2964,7 @@ if (foo) group = foo->name; if (!group) { - g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); + g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); if (g) group = g->name; else @@ -2982,7 +2974,7 @@ group2 = yahoo_string_encode(gc, group, NULL); pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); + yahoo_packet_hash(pkt, 7, buddy->name); yahoo_packet_hash(pkt, 65, group2); yahoo_packet_hash(pkt, 14, ""); yahoo_send_packet(yd, pkt); @@ -2990,7 +2982,7 @@ g_free(group2); } -static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group) +static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) { struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; YahooFriend *f; @@ -3000,13 +2992,13 @@ gboolean remove = TRUE; char *cg; - if (!(f = yahoo_friend_find(gc, who))) + if (!(f = yahoo_friend_find(gc, buddy->name))) return; - buddies = gaim_find_buddies(gaim_connection_get_account(gc), who); + buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); for (l = buddies; l; l = l->next) { g = gaim_find_buddys_group(l->data); - if (gaim_utf8_strcasecmp(group, g->name)) { + if (gaim_utf8_strcasecmp(group->name, g->name)) { remove = FALSE; break; } @@ -3015,12 +3007,12 @@ g_slist_free(buddies); if (remove) - g_hash_table_remove(yd->friends, who); - - cg = yahoo_string_encode(gc, group, NULL); + g_hash_table_remove(yd->friends, buddy->name); + + cg = yahoo_string_encode(gc, group->name, NULL); pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); - yahoo_packet_hash(pkt, 7, who); + yahoo_packet_hash(pkt, 7, buddy->name); yahoo_packet_hash(pkt, 65, cg); yahoo_send_packet(yd, pkt); yahoo_packet_free(pkt); @@ -3141,15 +3133,15 @@ g_free(gpo); } -static void yahoo_rename_group(GaimConnection *gc, const char *old_group, - const char *new_group, GList *whocares) +static void yahoo_rename_group(GaimConnection *gc, const char *old_name, + GaimGroup *group, GList *moved_buddies) { struct yahoo_data *yd = gc->proto_data; struct yahoo_packet *pkt; char *gpn, *gpo; - gpn = yahoo_string_encode(gc, new_group, NULL); - gpo = yahoo_string_encode(gc, old_group, NULL); + gpn = yahoo_string_encode(gc, group->name, NULL); + gpo = yahoo_string_encode(gc, old_name, NULL); if (!strcmp(gpn, gpo)) { g_free(gpn); g_free(gpo);