# HG changeset patch # User Sadrul Habib Chowdhury # Date 1155146438 0 # Node ID ccbd43daa1a36db6d84000a073206ab4c2da2ebf # Parent fa8f65cd912cb7a943b375b7d09630ce0b260e95 [gaim-migrate @ 16682] Removing buddies/groups now works. committer: Tailor Script diff -r fa8f65cd912c -r ccbd43daa1a3 console/gntblist.c --- a/console/gntblist.c Wed Aug 09 17:22:55 2006 +0000 +++ b/console/gntblist.c Wed Aug 09 18:00:38 2006 +0000 @@ -590,24 +590,73 @@ g_free(prompt); } +/* Xeroxed from gtkdialogs.c:gaim_gtkdialogs_remove_group_cb*/ +static void +remove_group(GaimGroup *group) +{ + GaimBlistNode *cnode, *bnode; + + cnode = ((GaimBlistNode*)group)->child; + + while (cnode) { + if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) { + bnode = cnode->child; + cnode = cnode->next; + while (bnode) { + GaimBuddy *buddy; + if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) { + buddy = (GaimBuddy*)bnode; + bnode = bnode->next; + if (gaim_account_is_connected(buddy->account)) { + gaim_account_remove_buddy(buddy->account, buddy, group); + gaim_blist_remove_buddy(buddy); + } + } else { + bnode = bnode->next; + } + } + } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) { + GaimChat *chat = (GaimChat *)cnode; + cnode = cnode->next; + if (gaim_account_is_connected(chat->account)) + gaim_blist_remove_chat(chat); + } else { + cnode = cnode->next; + } + } + + gaim_blist_remove_group(group); +} + +static void +gg_blist_remove_node(GaimBlistNode *node) +{ + if (GAIM_BLIST_NODE_IS_BUDDY(node)) + { + GaimBuddy *buddy = (GaimBuddy*)node; + GaimGroup *group = gaim_buddy_get_group(buddy); + gaim_account_remove_buddy(gaim_buddy_get_account(buddy), buddy, group); + gaim_blist_remove_buddy(buddy); + } + else if (GAIM_BLIST_NODE_IS_CHAT(node)) + { + gaim_blist_remove_chat((GaimChat*)node); + } + else if (GAIM_BLIST_NODE_IS_GROUP(node)) + { + remove_group((GaimGroup*)node); + } +} + /* XXX: This still doesn't do anything, because request doesn't have a ui yet */ static void gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) { - void (*callback)(gpointer); - - if (GAIM_BLIST_NODE_IS_BUDDY(node)) - callback = (void(*)(gpointer))gaim_blist_remove_buddy; - else if (GAIM_BLIST_NODE_IS_CHAT(node)) - callback = (void(*)(gpointer))gaim_blist_remove_chat; - else if (GAIM_BLIST_NODE_IS_GROUP(node)) - callback = (void(*)(gpointer))gaim_blist_remove_group; - /* XXX: anything to do with the returned ui-handle? */ gaim_request_action(node, _("Confirm Remove"), _("Are you sure you want to remove ..."), NULL, /* XXX: tidy up */ 1, node, 2, - _("Remove"), callback, + _("Remove"), gg_blist_remove_node, _("No"), NULL); } diff -r fa8f65cd912c -r ccbd43daa1a3 console/gntrequest.c --- a/console/gntrequest.c Wed Aug 09 17:22:55 2006 +0000 +++ b/console/gntrequest.c Wed Aug 09 18:00:38 2006 +0000 @@ -234,7 +234,8 @@ else if (type == GAIM_REQUEST_FIELD_STRING) { GntWidget *entry = field->ui_data; - gaim_request_field_string_set_value(field, gnt_entry_get_text(GNT_ENTRY(entry))); + const char *text = gnt_entry_get_text(GNT_ENTRY(entry)); + gaim_request_field_string_set_value(field, (text && *text) ? text : NULL); } else if (type == GAIM_REQUEST_FIELD_INTEGER) {