Mercurial > ~mikael > mcabber > hg
diff mcabber/src/commands.c @ 620:97dd14e22b2a
Rewrite buddy_setgroup()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 16 Dec 2005 23:48:42 +0100 |
parents | d3a8b43bf9e7 |
children | 2b7ef605ddc6 |
line wrap: on
line diff
--- a/mcabber/src/commands.c Fri Dec 16 18:07:14 2005 +0100 +++ b/mcabber/src/commands.c Fri Dec 16 23:48:42 2005 +0100 @@ -1006,7 +1006,7 @@ static void do_move(char *arg) { gpointer bud; - const char *jid, *name; + const char *jid, *name, *oldgroupname; guint type; char *newgroupname, *p; @@ -1017,6 +1017,8 @@ name = buddy_getname(bud); type = buddy_gettype(bud); + oldgroupname = buddy_getgroupname(bud); + if (type & ROSTER_TYPE_GROUP) { scr_LogPrint(LPRINT_NORMAL, "You can't move groups!"); return; @@ -1029,12 +1031,11 @@ strip_arg_special_chars(newgroupname); - // Call to buddy_setgroup() should be at the end, as current implementation - // clones the buddy and deletes the old one (and thus, jid and name are - // freed) - jb_updatebuddy(jid, name, *newgroupname ? newgroupname : NULL); - scr_RosterUp(); - buddy_setgroup(bud, newgroupname); + if (strcmp(oldgroupname, newgroupname)) { + jb_updatebuddy(jid, name, *newgroupname ? newgroupname : NULL); + scr_RosterUp(); + buddy_setgroup(bud, newgroupname); + } g_free(newgroupname); update_roster = TRUE;