Update of /cvsroot/gaim/gaim/src/protocols/jabber
In directory sc8-pr-cvs1:/tmp/cvs-serv2309/src/protocols/jabber
Modified Files:
jabber.c
Log Message:
paco-paco pointed out that jabber could potentially strcmp() with a NULL
variable. This inspired me to clean up the crap code that surrounded that
strcmp().
Index: jabber.c
===================================================================
RCS file: /cvsroot/gaim/gaim/src/protocols/jabber/jabber.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- jabber.c 26 Apr 2003 20:42:30 -0000 1.135
+++ jabber.c 1 May 2003 05:54:54 -0000 1.136
@@ -1778,35 +1778,30 @@
gaim_blist_add_buddy(b, g, NULL);
gaim_blist_save();
} else {
+ gboolean save = FALSE;
struct group *c_grp = gaim_find_buddys_group(b);
/*
* If the buddy's in a new group or his/her alias is changed...
*/
if(groupname && c_grp && strcmp(c_grp->name, groupname)) {
- int present = b->present; /* save presence state */
- int uc = b->uc; /* and away state (?) */
- int idle = b->idle;
- int signon = b->signon;
-
- /*
- * FIXME: this ugly hack is no longer needed
- * seems rude, but it seems to be the only way...
- */
- gaim_blist_remove_buddy(b);
- b = gaim_buddy_new(GJ_GC(gjc)->account, buddyname, name);
- gaim_blist_add_buddy(b, gaim_find_group(groupname), NULL);
- gaim_blist_save();
- if(present > 0) {
- serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle,
- uc);
+ struct group *g = gaim_find_group(groupname);
+ if(!g) {
+ g = gaim_group_new(groupname);
+ gaim_blist_add_group(g, NULL);
}
- } else if(name != NULL && strcmp(b->alias, name)) {
- g_free(b->alias);
- b->alias = g_strdup(name);
- gaim_blist_rename_buddy(b, buddyname);
- gaim_blist_save();
+
+ gaim_blist_add_buddy(b, g, NULL);
+ save = TRUE;
}
+
+ if(name && (!b->alias || strcmp(b->alias, name))) {
+ gaim_blist_alias_buddy(b, name);
+ save = TRUE;
+ }
+
+ if(save)
+ gaim_blist_save();
}
} else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) {
jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname);
|