changeset 20549:ec75e26e72b3

Update the alias and emit the signal only when the alias has actually changed.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 19 Sep 2007 09:52:54 +0000
parents 301c89809b9a
children 28493a27849b
files libpurple/blist.c
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/blist.c	Wed Sep 19 08:55:52 2007 +0000
+++ b/libpurple/blist.c	Wed Sep 19 09:52:54 2007 +0000
@@ -843,6 +843,13 @@
 		ops->update(purplebuddylist, (PurpleBlistNode *)buddy);
 }
 
+static gboolean
+purple_strings_are_different(const char *one, const char *two)
+{
+	return !((one && two && g_utf8_collate(one, two) == 0) ||
+			((one == NULL || *one == '\0') && (two == NULL || *two == '\0')));
+}
+
 void purple_blist_alias_contact(PurpleContact *contact, const char *alias)
 {
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
@@ -852,6 +859,9 @@
 
 	g_return_if_fail(contact != NULL);
 
+	if (!purple_strings_are_different(contact->alias, alias))
+		return;
+
 	old_alias = contact->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -886,6 +896,9 @@
 
 	g_return_if_fail(chat != NULL);
 
+	if (!purple_strings_are_different(chat->alias, alias))
+		return;
+
 	old_alias = chat->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -911,6 +924,9 @@
 
 	g_return_if_fail(buddy != NULL);
 
+	if (!purple_strings_are_different(buddy->alias, alias))
+		return;
+
 	old_alias = buddy->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))
@@ -941,6 +957,9 @@
 
 	g_return_if_fail(buddy != NULL);
 
+	if (!purple_strings_are_different(buddy->server_alias, alias))
+		return;
+
 	old_alias = buddy->server_alias;
 
 	if ((alias != NULL) && (*alias != '\0') && g_utf8_validate(alias, -1, NULL))
@@ -1428,6 +1447,9 @@
 
 	g_return_if_fail(contact != NULL);
 
+	if (!purple_strings_are_different(contact->alias, alias))
+		return;
+
 	old_alias = contact->alias;
 
 	if ((alias != NULL) && (*alias != '\0'))