changeset 5264:e4dadc60ea5a

[gaim-migrate @ 5636] 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(). committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 01 May 2003 05:54:54 +0000
parents b476a30ef4e3
children 0e2cc6379618
files src/protocols/jabber/jabber.c
diffstat 1 files changed, 17 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/jabber/jabber.c	Wed Apr 30 19:54:19 2003 +0000
+++ b/src/protocols/jabber/jabber.c	Thu May 01 05:54:54 2003 +0000
@@ -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);
+				struct group *g = gaim_find_group(groupname);
+				if(!g) {
+					g = gaim_group_new(groupname);
+					gaim_blist_add_group(g, NULL);
+				}
+
+				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();
-				if(present > 0) {
-					serv_got_update(GJ_GC(gjc), buddyname, 1, 0, signon, idle,
-							uc);
-				}
-			} 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();
-			}
 		}
 	}  else if (BUD_USUB_TO_PEND(sub, ask) || BUD_USUBD_TO(sub, ask) || !strcasecmp(sub, "remove")) {
 		jabber_remove_gaim_buddy(GJ_GC(gjc), buddyname);