src/blist.c

changeset 5346
4be84db22956
parent 5313
77dfd6912785
child 5368
f6b3a132ea00
equal deleted inserted replaced
5345:665b4fdd094a 5346:4be84db22956
263 } 263 }
264 264
265 void gaim_blist_rename_group(struct group *group, const char *name) 265 void gaim_blist_rename_group(struct group *group, const char *name)
266 { 266 {
267 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops; 267 struct gaim_blist_ui_ops *ops = gaimbuddylist->ui_ops;
268 g_free(group->name); 268 struct group *dest_group;
269 group->name = g_strdup(name); 269 GaimBlistNode *prev, *child, *next;
270 if (ops) 270 GSList *accts;
271 ops->update(gaimbuddylist, (GaimBlistNode*)group); 271
272 if(!name || !strlen(name) || !strcmp(name, group->name)) {
273 /* nothing to do here */
274 return;
275 } else if((dest_group = gaim_find_group(name))) {
276 /* here we're merging two groups */
277 prev = gaim_blist_get_last_child((GaimBlistNode*)dest_group);
278 child = ((GaimBlistNode*)group)->child;
279
280 while(child)
281 {
282 next = child->next;
283 if(GAIM_BLIST_NODE_IS_BUDDY(child)) {
284 gaim_blist_add_buddy((struct buddy *)child, dest_group, prev);
285 prev = child;
286 } else if(GAIM_BLIST_NODE_IS_CHAT(child)) {
287 gaim_blist_add_chat((struct chat *)child, dest_group, prev);
288 prev = child;
289 } else {
290 gaim_debug(GAIM_DEBUG_ERROR, "blist",
291 "Unknown child type in group %s\n", group->name);
292 }
293 child = next;
294 }
295 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) {
296 struct gaim_account *account = accts->data;
297 serv_rename_group(account->gc, group, name);
298 }
299 gaim_blist_remove_group(group);
300 } else {
301 /* a simple rename */
302 for (accts = gaim_group_get_accounts(group); accts; accts = g_slist_remove(accts, accts->data)) {
303 struct gaim_account *account = accts->data;
304 serv_rename_group(account->gc, group, name);
305 }
306 g_free(group->name);
307 group->name = g_strdup(name);
308 if (ops)
309 ops->update(gaimbuddylist, (GaimBlistNode*)group);
310 }
272 } 311 }
273 312
274 struct chat *gaim_chat_new(struct gaim_account *account, const char *alias, GHashTable *components) 313 struct chat *gaim_chat_new(struct gaim_account *account, const char *alias, GHashTable *components)
275 { 314 {
276 struct chat *chat; 315 struct chat *chat;

mercurial