adium 3339:391470ac87ed: Manually merge in the adiumPurpleConver...

commits at adium.im commits at adium.im
Sat Sep 25 03:20:03 UTC 2010


details:	http://hg.adium.im/adium/rev/391470ac87ed
revision:	3339:391470ac87ed
author:		Zachary West <zacw at adium.im>
date:		Fri Sep 24 23:16:21 2010 -0400

Manually merge in the adiumPurpleConversation.m part of b25b0a269395, since it doesn't apply cleanly.

Refs #14026.
Subject: adium 3340:aea3e06a68e5: Manually merge the AIMessageViewController.m changes for b25b0a269395, since it doesn't apply cleanly.

details:	http://hg.adium.im/adium/rev/aea3e06a68e5
revision:	3340:aea3e06a68e5
author:		Zachary West <zacw at adium.im>
date:		Fri Sep 24 23:19:47 2010 -0400

Manually merge the AIMessageViewController.m changes for b25b0a269395, since it doesn't apply cleanly.

Refs #14026

diffs (119 lines):

diff -r 0ff9d5eed2cb -r aea3e06a68e5 Plugins/Dual Window Interface/AIMessageViewController.m
--- a/Plugins/Dual Window Interface/AIMessageViewController.m	Fri Sep 24 22:50:08 2010 -0400
+++ b/Plugins/Dual Window Interface/AIMessageViewController.m	Fri Sep 24 23:19:47 2010 -0400
@@ -1032,20 +1032,20 @@
 	NSMutableArray *contacts = [NSMutableArray array];
 	
 	for (AIListContact *listContact in self.chat) {
-		if ([listContact.UID rangeOfString:partialWord
-								   options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound ||
-			[listContact.formattedUID rangeOfString:partialWord
-											options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound ||
-			[listContact.displayName rangeOfString:partialWord
-										   options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound) {
-				[contacts addObject:listContact];
+		// Add to the list if it matches: (1) The display name for the chat (alias fallback to default display name), 
+		// (2) The UID, or (3) the display name
+		if ([[self.chat displayNameForContact:listContact] rangeOfString:partialWord options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound
+			|| [listContact.UID rangeOfString:partialWord options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound ||
+			|| [listContact.displayName rangeOfString:partialWord options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound) {
+			[contacts addObject:listContact];
+			AILogWithSignature(@"Added match %@ with nick %@; UID: %@; formattedUID: %@; displayName: %@", listContact, [self.chat aliasForContact:listContact], listContact.UID, listContact.formattedUID, listContact.displayName);
 		}
 	}
 	
 	return contacts;
 }
 
-- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)idx
+- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
 {
 	NSMutableArray	*completions = nil;
 	
@@ -1076,29 +1076,26 @@
 		
 		completions = [NSMutableArray array];
 		
+		// For each matching contact:
 		for (AIListContact *listContact in [self contactsMatchingBeginningString:partialWord]) {
-			// For each matching contact: if chatShouldAutoCompleteUID, then use the formattedUID
-			// else use the displayName
-			NSString *completion = autoCompleteUID ? listContact.formattedUID : listContact.displayName;
+			// Complete the chat alias.
+			NSString *completion = [self.chat aliasForContact:listContact];
 			
-			// Check the displayNameForContact (either the alias or, if it doesn't exist, the displayName).
-			// If it is the same as the completion except for case, use it (makes it complete in pretty case).
-			// We must check to see if it exists before running a string comparison on it.
-			NSString *aliasOrDisplayName = [self.chat displayNameForContact:listContact];
-			if (aliasOrDisplayName && [aliasOrDisplayName caseInsensitiveCompare:completion] == NSOrderedSame) {
-				completion = aliasOrDisplayName;
-			}
+			// Otherwise, complete the UID (if we're completing UIDs for this chat) or the display name.
+			if (!completion)
+				completion = autoCompleteUID ? listContact.formattedUID : listContact.displayName;
 			
-			// Add what we came up with to the completions list (with suffix if required)
 			[completions addObject:(suffix ? [completion stringByAppendingString:suffix] : completion)];
 		}
 		
+		// Add the name of this chat to the completions if it matches.
 		if ([self.chat.displayName rangeOfString:partialWord options:(NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch | NSAnchoredSearch)].location != NSNotFound) {
 			[completions addObject:self.chat.displayName];
 		}
-
+		
+		// Select the first completion by default.
 		if ([completions count]) {			
-			*idx = 0;
+			*index = 0;
 		}
 	}
 
diff -r 0ff9d5eed2cb -r aea3e06a68e5 Plugins/Purple Service/adiumPurpleConversation.m
--- a/Plugins/Purple Service/adiumPurpleConversation.m	Fri Sep 24 22:50:08 2010 -0400
+++ b/Plugins/Purple Service/adiumPurpleConversation.m	Fri Sep 24 23:19:47 2010 -0400
@@ -316,12 +316,11 @@
 		for (GList *l = cbuddies; l; l = l->next) {
 			PurpleConvChatBuddy *cb = (PurpleConvChatBuddy *)l->data;
 			
+			// We use cb->name for the alias field, since libpurple sets the one we're after (the chat name) formatted correctly inside.
 			NSMutableDictionary *user = [NSMutableDictionary dictionary];
 			[user setObject:get_real_name_for_account_conv_buddy(account, conv, cb->name) forKey:@"UID"];
 			[user setObject:[NSNumber numberWithInteger:cb->flags] forKey:@"Flags"];
-			if (cb->alias) {
-				[user setObject:[NSString stringWithUTF8String:cb->alias] forKey:@"Alias"];
-			}
+			[user setObject:[NSString stringWithUTF8String:cb->name] forKey:@"Alias"];
 			
 			[users addObject:user];
 		}
@@ -346,9 +345,11 @@
 		
 		PurpleAccount *account = purple_conversation_get_account(conv);
 		
+		// Ignore newAlias and set the alias to newName
+		
 		[accountLookup(purple_conversation_get_account(conv)) renameParticipant:get_real_name_for_account_conv_buddy(account, conv, (char *)oldName)
 																		newName:get_real_name_for_account_conv_buddy(account, conv, (char *)newName)
-																	   newAlias:[NSString stringWithUTF8String:newAlias]
+																	   newAlias:[NSString stringWithUTF8String:newName]
 																		  flags:cb->flags
 																		 inChat:groupChatLookupFromConv(conv)];
 	}
@@ -392,12 +393,13 @@
 	
 	g_list_free(attribute);
 	
-	NSString *alias = cb->alias ? [NSString stringWithUTF8String:cb->alias] : nil;
+	// We use cb->name for the alias field, since libpurple sets the one we're after (the chat name) formatted correctly inside.
+	NSString *name = cb->name ? [NSString stringWithUTF8String:cb->name] : nil;
 	
 	[adiumAccount updateUser:get_real_name_for_account_conv_buddy(account, conv, (char *)user)
 					 forChat:groupChatLookupFromConv(conv)
 					   flags:cb->flags
-					   alias:alias
+					   alias:name
 				  attributes:attributes];
 }
 




More information about the commits mailing list