adium 2231:177b25c92580: Update the alias, if necessary, when up...

commits at adium.im commits at adium.im
Sun May 17 22:39:06 UTC 2009


details:	http://hg.adium.im/adium/rev/177b25c92580
revision:	2231:177b25c92580
author:		Zachary West <zacw at adium.im>
date:		Sun May 17 18:38:43 2009 -0400

Update the alias, if necessary, when updating a chat participant.

diffstat:

 Plugins/Purple Service/CBPurpleAccount.h         |   2 +-
 Plugins/Purple Service/CBPurpleAccount.m         |  15 ++++++++++++++-
 Plugins/Purple Service/adiumPurpleConversation.m |   3 +++
 3 files changed, 18 insertions(+), 2 deletions(-)

diffs (66 lines):

diff -r fb9497a35bb0 -r 177b25c92580 Plugins/Purple Service/CBPurpleAccount.h
--- a/Plugins/Purple Service/CBPurpleAccount.h	Sun May 17 15:04:22 2009 -0700
+++ b/Plugins/Purple Service/CBPurpleAccount.h	Sun May 17 18:38:43 2009 -0400
@@ -196,7 +196,7 @@
 - (void)renameParticipant:(NSString *)oldUID newName:(NSString *)newUID newAlias:(NSString *)newAlias flags:(AIGroupChatFlags)flags inChat:(AIChat *)chat;
 - (void)removeUser:(NSString *)contactName fromChat:(AIChat *)chat;
 - (void)updateUserListForChat:(AIChat *)chat users:(NSArray *)users newlyAdded:(BOOL)newlyAdded;
-- (void)updateUser:(NSString *)user forChat:(AIChat *)chat flags:(AIGroupChatFlags)flags attributes:(NSDictionary *)attributes;
+- (void)updateUser:(NSString *)user forChat:(AIChat *)chat flags:(AIGroupChatFlags)flags alias:(NSString *)alias attributes:(NSDictionary *)attributes;
 - (NSDictionary *)willJoinChatUsingDictionary:(NSDictionary *)chatCreationDictionary;
 - (BOOL)chatCreationDictionary:(NSDictionary *)chatCreationDict isEqualToDictionary:(NSDictionary *)baseDict;
 - (NSDictionary *)extractChatCreationDictionaryFromConversation:(PurpleConversation *)conv;
diff -r fb9497a35bb0 -r 177b25c92580 Plugins/Purple Service/CBPurpleAccount.m
--- a/Plugins/Purple Service/CBPurpleAccount.m	Sun May 17 15:04:22 2009 -0700
+++ b/Plugins/Purple Service/CBPurpleAccount.m	Sun May 17 18:38:43 2009 -0400
@@ -855,12 +855,25 @@
 - (void)updateUser:(NSString *)user
 		   forChat:(AIChat *)chat
 			 flags:(AIGroupChatFlags)flags
+			 alias:(NSString *)alias
 		attributes:(NSDictionary *)attributes
 {
+	BOOL triggerUserlistUpdate = NO;
+	
 	AIListContact *contact = [self contactWithUID:user];
 	
 	AIGroupChatFlags oldFlags = [chat flagsForContact:contact];
+	NSString *oldAlias = [chat aliasForContact:contact];
 	
+	// Trigger an update if the alias or flags (ignoring away state) changes.
+	if ((alias && !oldAlias)
+		|| (!alias && oldAlias)
+		|| ![[chat aliasForContact:contact] isEqualToString:alias]
+		|| (flags & ~AIGroupChatAway) != (oldFlags & ~AIGroupChatAway)) {
+		triggerUserlistUpdate = YES;
+	}
+
+	[chat setAlias:alias forContact:contact];
 	[chat setFlags:flags forContact:contact];
 	
 	// Away changes only come in after the initial one, so we're safe in only updating it here.
@@ -877,7 +890,7 @@
 	[contact notifyOfChangedPropertiesSilently:YES];
 	
 	// Post an update notification if we modified the flags; don't resort for away changes.
-	if ((flags & ~AIGroupChatAway) != (oldFlags & ~AIGroupChatAway)) {
+	if (triggerUserlistUpdate) {
 		[[NSNotificationCenter defaultCenter] postNotificationName:Chat_ParticipatingListObjectsChanged
 															object:chat];
 	}
diff -r fb9497a35bb0 -r 177b25c92580 Plugins/Purple Service/adiumPurpleConversation.m
--- a/Plugins/Purple Service/adiumPurpleConversation.m	Sun May 17 15:04:22 2009 -0700
+++ b/Plugins/Purple Service/adiumPurpleConversation.m	Sun May 17 18:38:43 2009 -0400
@@ -390,9 +390,12 @@
 	
 	g_list_free(attribute);
 	
+	NSString *alias = cb->alias ? [NSString stringWithUTF8String:cb->alias] : nil;
+	
 	[adiumAccount updateUser:get_real_name_for_account_conv_buddy(account, conv, (char *)user)
 					 forChat:groupChatLookupFromConv(conv)
 					   flags:cb->flags
+					   alias:alias
 				  attributes:attributes];
 }
 




More information about the commits mailing list