changeset 6858:885c6528843b

[gaim-migrate @ 7403] Moving MSN buddies between groups should no longer reset their server-side friendly name. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 16 Sep 2003 03:56:54 +0000
parents 59f6d0b1bdbe
children 17514a2f976a
files src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/msn/user.c
diffstat 3 files changed, 35 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/msn.c	Tue Sep 16 03:18:44 2003 +0000
+++ b/src/protocols/msn/msn.c	Tue Sep 16 03:56:54 2003 +0000
@@ -406,6 +406,9 @@
 	GList *m = NULL;
 
 	b = gaim_find_buddy(gc->account, who);
+
+	g_return_val_if_fail(b != NULL, NULL);
+
 	user = b->proto_data;
 
 	if (user != NULL) {
@@ -1040,6 +1043,7 @@
 	MsnSession *session = gc->proto_data;
 	MsnGroup *old_group, *new_group;
 	MsnUser *user;
+	const char *friendly;
 	char outparams[MSN_BUF_LEN];
 
 	old_group = msn_groups_find_with_name(session->groups, old_group_name);
@@ -1047,6 +1051,9 @@
 
 	user = msn_users_find_with_passport(session->users, who);
 
+	if ((friendly = msn_user_get_name(user)) == NULL)
+		friendly = msn_user_get_passport(user);
+
 	if (old_group != NULL)
 		msn_user_remove_group_id(user, msn_group_get_id(old_group));
 
@@ -1072,7 +1079,7 @@
 	}
 	else {
 		g_snprintf(outparams, sizeof(outparams), "FL %s %s %d",
-				   who, who, msn_group_get_id(new_group));
+				   who, friendly, msn_group_get_id(new_group));
 
 		if (!msn_servconn_send_command(session->notification_conn,
 									   "ADD", outparams)) {
--- a/src/protocols/msn/notification.c	Tue Sep 16 03:18:44 2003 +0000
+++ b/src/protocols/msn/notification.c	Tue Sep 16 03:56:54 2003 +0000
@@ -103,12 +103,18 @@
 
 		if (b == NULL)
 		{
-			b = gaim_buddy_new(account,
-							   msn_user_get_passport(user), NULL);
+			const char *passport, *friendly;
+
+			passport = msn_user_get_passport(user);
+
+			b = gaim_buddy_new(account, passport, NULL);
 
 			b->proto_data = user;
 
 			gaim_blist_add_buddy(b, NULL, g, NULL);
+
+			if ((friendly = msn_user_get_name(user)) != NULL)
+				serv_got_alias(gc, passport, friendly);
 		}
 		else
 			b->proto_data = user;
@@ -1052,12 +1058,14 @@
 	passport = params[2];
 	friend   = msn_url_decode(params[3]);
 
+	user = msn_users_find_with_passport(session->users, passport);
+
 	serv_got_alias(gc, (char *)passport, (char *)friend);
 
+	msn_user_set_name(user, friend);
+
 	if (session->protocol_ver >= 9 && param_count == 6)
 	{
-		user = msn_users_find_with_passport(session->users, passport);
-
 		msnobj = msn_object_new_from_string(msn_url_decode(params[5]));
 		msn_user_set_object(user, msnobj);
 	}
@@ -1471,12 +1479,14 @@
 	passport = params[1];
 	friend   = msn_url_decode(params[2]);
 
+	user = msn_users_find_with_passport(session->users, passport);
+
 	serv_got_alias(gc, (char *)passport, (char *)friend);
 
+	msn_user_set_name(user, friend);
+
 	if (session->protocol_ver >= 9 && param_count == 5)
 	{
-		user = msn_users_find_with_passport(session->users, passport);
-
 		msnobj = msn_object_new_from_string(msn_url_decode(params[4]));
 		msn_user_set_object(user, msnobj);
 	}
@@ -1597,6 +1607,7 @@
 	if (session->moving_buddy) {
 		MsnGroup *group, *old_group;
 		GaimConnection *gc = session->account->gc;
+		const char *friendly;
 		char outparams[MSN_BUF_LEN];
 
 		group = msn_groups_find_with_name(session->groups,
@@ -1621,8 +1632,11 @@
 		g_free(session->dest_group_name);
 		session->dest_group_name = NULL;
 
+		if ((friendly = msn_user_get_name(session->moving_user)) == NULL)
+			friendly = passport;
+
 		g_snprintf(outparams, sizeof(outparams), "FL %s %s %d",
-				   passport, passport, msn_group_get_id(group));
+				   passport, friendly, msn_group_get_id(group));
 
 		if (!msn_servconn_send_command(session->notification_conn,
 									   "ADD", outparams)) {
--- a/src/protocols/msn/user.c	Tue Sep 16 03:18:44 2003 +0000
+++ b/src/protocols/msn/user.c	Tue Sep 16 03:56:54 2003 +0000
@@ -39,8 +39,14 @@
 		msn_users_add(session->users, user);
 	}
 
+	/*
+	 * XXX This seems to reset the friendly name from what it should be
+	 *     to the passport when moving users. So, screw it :)
+	 */
+#if 0
 	if (name != NULL)
 		msn_user_set_name(user, name);
+#endif
 
 	msn_user_ref(user);