| 44 |
44 |
| 45 extern char *yahoo_crypt(const char *, const char *); |
45 extern char *yahoo_crypt(const char *, const char *); |
| 46 |
46 |
| 47 /* #define YAHOO_DEBUG */ |
47 /* #define YAHOO_DEBUG */ |
| 48 |
48 |
| 49 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *); |
49 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); |
| 50 static void yahoo_send_buddy_icon_request(GaimConnection *gc, const char *who); |
50 static void yahoo_send_buddy_icon_request(GaimConnection *gc, const char *who); |
| 51 |
51 |
| 52 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
52 struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id) |
| 53 { |
53 { |
| 54 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); |
54 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1); |
| 591 b = gaim_buddy_new(account, norm_bud, NULL); |
585 b = gaim_buddy_new(account, norm_bud, NULL); |
| 592 gaim_blist_add_buddy(b, NULL, g, NULL); |
586 gaim_blist_add_buddy(b, NULL, g, NULL); |
| 593 export = TRUE; |
587 export = TRUE; |
| 594 } |
588 } |
| 595 |
589 |
| 596 yahoo_do_group_check(account, ht, norm_bud, grp, &export); |
590 yahoo_do_group_check(account, ht, norm_bud, grp); |
| 597 g_free(norm_bud); |
591 g_free(norm_bud); |
| 598 } |
592 } |
| 599 g_strfreev(buddies); |
593 g_strfreev(buddies); |
| 600 g_strfreev(split); |
594 g_strfreev(split); |
| 601 g_free(grp); |
595 g_free(grp); |
| 602 } |
596 } |
| 603 g_strfreev(lines); |
597 g_strfreev(lines); |
| 604 |
598 |
| 605 g_string_free(yd->tmp_serv_blist, TRUE); |
599 g_string_free(yd->tmp_serv_blist, TRUE); |
| 606 yd->tmp_serv_blist = NULL; |
600 yd->tmp_serv_blist = NULL; |
| 607 g_hash_table_foreach(ht, yahoo_do_group_cleanup, &export); |
601 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
| 608 g_hash_table_destroy(ht); |
602 g_hash_table_destroy(ht); |
| 609 } |
603 } |
| 610 |
604 |
| 611 |
605 |
| 612 if (yd->tmp_serv_ilist) { |
606 if (yd->tmp_serv_ilist) { |
| 1618 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
1610 yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
| 1619 } |
1611 } |
| 1620 } |
1612 } |
| 1621 } |
1613 } |
| 1622 |
1614 |
| 1623 static void ignore_buddy(GaimBuddy *b) { |
1615 static void ignore_buddy(GaimBuddy *buddy) { |
| 1624 GaimGroup *g; |
1616 GaimGroup *group; |
| 1625 GaimConversation *c; |
1617 GaimConversation *conv; |
| 1626 GaimAccount *account; |
1618 GaimAccount *account; |
| 1627 gchar *name; |
1619 gchar *name; |
| 1628 |
1620 |
| 1629 if (!b) |
1621 if (!buddy) |
| 1630 return; |
1622 return; |
| 1631 |
1623 |
| 1632 g = gaim_find_buddys_group(b); |
1624 group = gaim_find_buddys_group(buddy); |
| 1633 name = g_strdup(b->name); |
1625 name = g_strdup(buddy->name); |
| 1634 account = b->account; |
1626 account = buddy->account; |
| 1635 |
1627 |
| 1636 gaim_debug(GAIM_DEBUG_INFO, "blist", |
1628 gaim_debug(GAIM_DEBUG_INFO, "blist", |
| 1637 "Removing '%s' from buddy list.\n", b->name); |
1629 "Removing '%s' from buddy list.\n", buddy->name); |
| 1638 serv_remove_buddy(account->gc, name, g->name); |
1630 serv_remove_buddy(account->gc, buddy, group); |
| 1639 gaim_blist_remove_buddy(b); |
1631 gaim_blist_remove_buddy(buddy); |
| 1640 |
1632 |
| 1641 serv_add_deny(account->gc, name); |
1633 serv_add_deny(account->gc, name); |
| 1642 gaim_blist_save(); |
1634 |
| 1643 |
1635 conv = gaim_find_conversation_with_account(name, account); |
| 1644 c = gaim_find_conversation_with_account(name, account); |
1636 |
| 1645 |
1637 if (conv != NULL) |
| 1646 if (c != NULL) |
1638 gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); |
| 1647 gaim_conversation_update(c, GAIM_CONV_UPDATE_REMOVE); |
|
| 1648 |
1639 |
| 1649 g_free(name); |
1640 g_free(name); |
| 1650 } |
1641 } |
| 1651 |
1642 |
| 1652 static void keep_buddy(GaimBuddy *b) { |
1643 static void keep_buddy(GaimBuddy *b) { |
| 2956 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); |
2947 yahoo_packet_hash(pkt, 109, gaim_connection_get_display_name(gc)); |
| 2957 yahoo_send_packet(yd, pkt); |
2948 yahoo_send_packet(yd, pkt); |
| 2958 yahoo_packet_free(pkt); |
2949 yahoo_packet_free(pkt); |
| 2959 } |
2950 } |
| 2960 |
2951 |
| 2961 static void yahoo_add_buddy(GaimConnection *gc, const char *who, GaimGroup *foo) |
2952 /* XXX - What's the deal with GaimGroup *foo? */ |
| |
2953 static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) |
| 2962 { |
2954 { |
| 2963 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
2955 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 2964 struct yahoo_packet *pkt; |
2956 struct yahoo_packet *pkt; |
| 2965 GaimGroup *g; |
2957 GaimGroup *g; |
| 2966 char *group = NULL; |
2958 char *group = NULL; |
| 2970 return; |
2962 return; |
| 2971 |
2963 |
| 2972 if (foo) |
2964 if (foo) |
| 2973 group = foo->name; |
2965 group = foo->name; |
| 2974 if (!group) { |
2966 if (!group) { |
| 2975 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who)); |
2967 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); |
| 2976 if (g) |
2968 if (g) |
| 2977 group = g->name; |
2969 group = g->name; |
| 2978 else |
2970 else |
| 2979 group = "Buddies"; |
2971 group = "Buddies"; |
| 2980 } |
2972 } |
| 2981 |
2973 |
| 2982 group2 = yahoo_string_encode(gc, group, NULL); |
2974 group2 = yahoo_string_encode(gc, group, NULL); |
| 2983 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
2975 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 2984 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
2976 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 2985 yahoo_packet_hash(pkt, 7, who); |
2977 yahoo_packet_hash(pkt, 7, buddy->name); |
| 2986 yahoo_packet_hash(pkt, 65, group2); |
2978 yahoo_packet_hash(pkt, 65, group2); |
| 2987 yahoo_packet_hash(pkt, 14, ""); |
2979 yahoo_packet_hash(pkt, 14, ""); |
| 2988 yahoo_send_packet(yd, pkt); |
2980 yahoo_send_packet(yd, pkt); |
| 2989 yahoo_packet_free(pkt); |
2981 yahoo_packet_free(pkt); |
| 2990 g_free(group2); |
2982 g_free(group2); |
| 2991 } |
2983 } |
| 2992 |
2984 |
| 2993 static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group) |
2985 static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2994 { |
2986 { |
| 2995 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
2987 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 2996 YahooFriend *f; |
2988 YahooFriend *f; |
| 2997 struct yahoo_packet *pkt; |
2989 struct yahoo_packet *pkt; |
| 2998 GSList *buddies, *l; |
2990 GSList *buddies, *l; |
| 2999 GaimGroup *g; |
2991 GaimGroup *g; |
| 3000 gboolean remove = TRUE; |
2992 gboolean remove = TRUE; |
| 3001 char *cg; |
2993 char *cg; |
| 3002 |
2994 |
| 3003 if (!(f = yahoo_friend_find(gc, who))) |
2995 if (!(f = yahoo_friend_find(gc, buddy->name))) |
| 3004 return; |
2996 return; |
| 3005 |
2997 |
| 3006 buddies = gaim_find_buddies(gaim_connection_get_account(gc), who); |
2998 buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); |
| 3007 for (l = buddies; l; l = l->next) { |
2999 for (l = buddies; l; l = l->next) { |
| 3008 g = gaim_find_buddys_group(l->data); |
3000 g = gaim_find_buddys_group(l->data); |
| 3009 if (gaim_utf8_strcasecmp(group, g->name)) { |
3001 if (gaim_utf8_strcasecmp(group->name, g->name)) { |
| 3010 remove = FALSE; |
3002 remove = FALSE; |
| 3011 break; |
3003 break; |
| 3012 } |
3004 } |
| 3013 } |
3005 } |
| 3014 |
3006 |
| 3015 g_slist_free(buddies); |
3007 g_slist_free(buddies); |
| 3016 |
3008 |
| 3017 if (remove) |
3009 if (remove) |
| 3018 g_hash_table_remove(yd->friends, who); |
3010 g_hash_table_remove(yd->friends, buddy->name); |
| 3019 |
3011 |
| 3020 cg = yahoo_string_encode(gc, group, NULL); |
3012 cg = yahoo_string_encode(gc, group->name, NULL); |
| 3021 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
3013 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 3022 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
3014 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc)); |
| 3023 yahoo_packet_hash(pkt, 7, who); |
3015 yahoo_packet_hash(pkt, 7, buddy->name); |
| 3024 yahoo_packet_hash(pkt, 65, cg); |
3016 yahoo_packet_hash(pkt, 65, cg); |
| 3025 yahoo_send_packet(yd, pkt); |
3017 yahoo_send_packet(yd, pkt); |
| 3026 yahoo_packet_free(pkt); |
3018 yahoo_packet_free(pkt); |
| 3027 g_free(cg); |
3019 g_free(cg); |
| 3028 } |
3020 } |
| 3139 yahoo_packet_free(pkt); |
3131 yahoo_packet_free(pkt); |
| 3140 g_free(gpn); |
3132 g_free(gpn); |
| 3141 g_free(gpo); |
3133 g_free(gpo); |
| 3142 } |
3134 } |
| 3143 |
3135 |
| 3144 static void yahoo_rename_group(GaimConnection *gc, const char *old_group, |
3136 static void yahoo_rename_group(GaimConnection *gc, const char *old_name, |
| 3145 const char *new_group, GList *whocares) |
3137 GaimGroup *group, GList *moved_buddies) |
| 3146 { |
3138 { |
| 3147 struct yahoo_data *yd = gc->proto_data; |
3139 struct yahoo_data *yd = gc->proto_data; |
| 3148 struct yahoo_packet *pkt; |
3140 struct yahoo_packet *pkt; |
| 3149 char *gpn, *gpo; |
3141 char *gpn, *gpo; |
| 3150 |
3142 |
| 3151 gpn = yahoo_string_encode(gc, new_group, NULL); |
3143 gpn = yahoo_string_encode(gc, group->name, NULL); |
| 3152 gpo = yahoo_string_encode(gc, old_group, NULL); |
3144 gpo = yahoo_string_encode(gc, old_name, NULL); |
| 3153 if (!strcmp(gpn, gpo)) { |
3145 if (!strcmp(gpn, gpo)) { |
| 3154 g_free(gpn); |
3146 g_free(gpn); |
| 3155 g_free(gpo); |
3147 g_free(gpo); |
| 3156 return; |
3148 return; |
| 3157 } |
3149 } |