From: <sa...@us...> - 2006-08-09 18:00:42
|
Revision: 16682 Author: sadrul Date: 2006-08-09 11:00:38 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16682&view=rev Log Message: ----------- Removing buddies/groups now works. Modified Paths: -------------- trunk/console/gntblist.c trunk/console/gntrequest.c Modified: trunk/console/gntblist.c =================================================================== --- trunk/console/gntblist.c 2006-08-09 17:22:55 UTC (rev 16681) +++ trunk/console/gntblist.c 2006-08-09 18:00:38 UTC (rev 16682) @@ -590,24 +590,73 @@ g_free(prompt); } -/* XXX: This still doesn't do anything, because request doesn't have a ui yet */ +/* Xeroxed from gtkdialogs.c:gaim_gtkdialogs_remove_group_cb*/ static void -gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *null) +remove_group(GaimGroup *group) { - void (*callback)(gpointer); + 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)) - callback = (void(*)(gpointer))gaim_blist_remove_buddy; + { + 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)) - callback = (void(*)(gpointer))gaim_blist_remove_chat; + { + gaim_blist_remove_chat((GaimChat*)node); + } else if (GAIM_BLIST_NODE_IS_GROUP(node)) - callback = (void(*)(gpointer))gaim_blist_remove_group; + { + 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) +{ /* 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); } Modified: trunk/console/gntrequest.c =================================================================== --- trunk/console/gntrequest.c 2006-08-09 17:22:55 UTC (rev 16681) +++ trunk/console/gntrequest.c 2006-08-09 18:00:38 UTC (rev 16682) @@ -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) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |