pidgin: 76c39e91: Move the check for whether to update the...

qulogic at pidgin.im qulogic at pidgin.im
Thu Jan 29 22:30:46 EST 2009


-----------------------------------------------------------------
Revision: 76c39e91278034c66dd1c7ffb2f0e49883bac850
Ancestor: 6a51501ec3aff341c8cd763ffc2076a9bbc07d23
Author: qulogic at pidgin.im
Date: 2009-01-30T03:14:29
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/76c39e91278034c66dd1c7ffb2f0e49883bac850

Modified files:
        libpurple/protocols/msn/notification.c
        libpurple/protocols/msn/user.c
        libpurple/protocols/msn/user.h

ChangeLog: 

Move the check for whether to update the server alias out of nln_cmd and
into msn_user_set_friendly_name instead. This is because it should be done
for nln_cmd and iln_cmd (since we have the friendly name already from the
address book).

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/notification.c	d424eaa0952166e0d7585719989a829c9cdbd970
+++ libpurple/protocols/msn/notification.c	7d48e23134e6b98c8b98c00566cbe156763e77dc
@@ -1094,8 +1094,8 @@ iln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 		return;
 	}
 
-	serv_got_alias(gc, passport, friendly);
-	msn_user_set_friendly_name(user, friendly);
+	if (msn_user_set_friendly_name(user, friendly))
+		serv_got_alias(gc, passport, friendly);
 	g_free(friendly);
 
 	msn_user_set_object(user, msnobj);
@@ -1220,7 +1220,7 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	MsnObject *msnobj;
 	unsigned long clientid;
 	int networkid;
-	const char *state, *passport, *friendly, *old_friendly;
+	const char *state, *passport, *friendly;
 
 	session = cmdproc->session;
 	account = session->account;
@@ -1234,11 +1234,9 @@ nln_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	user = msn_userlist_find_user(session->userlist, passport);
 	if (user == NULL) return;
 
-	old_friendly = msn_user_get_friendly_name(user);
-	if (!old_friendly || (old_friendly && (!friendly || strcmp(old_friendly, friendly))))
+	if (msn_user_set_friendly_name(user, friendly))
 	{
 		serv_got_alias(gc, passport, friendly);
-		msn_user_set_friendly_name(user, friendly);
 	}
 
 	if (cmd->param_count == 6)
============================================================
--- libpurple/protocols/msn/user.c	8a18ea5fc100578b8c562a0fc5757430c28ece95
+++ libpurple/protocols/msn/user.c	f1645197999aa48f09430f21f178eb62196aeeda
@@ -177,13 +177,18 @@ msn_user_set_passport(MsnUser *user, con
 	user->passport = g_strdup(passport);
 }
 
-void
+gboolean
 msn_user_set_friendly_name(MsnUser *user, const char *name)
 {
 	g_return_if_fail(user != NULL);
 
+	if (user->friendly_name && name && !strcmp(user->friendly_name, name))
+		return FALSE;
+
 	g_free(user->friendly_name);
 	user->friendly_name = g_strdup(name);
+
+	return TRUE;
 }
 
 void
============================================================
--- libpurple/protocols/msn/user.h	e09023d89c23cecb91de2523c6439358c8c9f40f
+++ libpurple/protocols/msn/user.h	3d3e068b16c3857051c17873cfdd1a0e117ff88a
@@ -178,8 +178,10 @@ void msn_user_set_passport(MsnUser *user
  *
  * @param user The user.
  * @param name The friendly name.
+ *
+ * @returns TRUE is name actually changed, FALSE otherwise.
  */
-void msn_user_set_friendly_name(MsnUser *user, const char *name);
+gboolean msn_user_set_friendly_name(MsnUser *user, const char *name);
 
 /**
  * Sets the buddy icon for a local user.


More information about the Commits mailing list