adium-1.4 3065:b25b0a269395: Fix autocompleting names in various...
commits at adium.im
commits at adium.im
Sat Sep 25 03:10:38 UTC 2010
details: http://hg.adium.im/adium-1.4/rev/b25b0a269395
revision: 3065:b25b0a269395
author: Zachary West <zacw at adium.im>
date: Fri Sep 24 23:10:32 2010 -0400
Fix autocompleting names in various group chats. Fixes #14026.
Reverts functionality for autocompletes to pre-b18, by always autocompleting the alias. However, to correct against libpurple returning a contact list alias for a contact in the alias field, use the PurpleConvChatBuddy's name field.
The name field contains the formatted name as we're expecting it.
Patch (albeit modified to avoid trying to passive-aggressively rename alias to nick in comments ;)) by paradoxmo.
diffs (108 lines):
diff -r 70d54243d807 -r b25b0a269395 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:10:32 2010 -0400
@@ -1028,13 +1028,13 @@
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);
}
}
@@ -1057,27 +1057,24 @@
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];
+
+ // Otherwise, complete the UID (if we're completing UIDs for this chat) or the display name.
+ if (!completion)
+ completion = autoCompleteUID ? listContact.formattedUID : listContact.displayName;
- // 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;
- }
-
- // Add what we came up with to the completions list (with suffix if at beginning of line)
[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]) {
*index = 0;
}
diff -r 70d54243d807 -r b25b0a269395 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:10:32 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