adium 3502:69a112797966: If a contact was previously associated ...

commits at adium.im commits at adium.im
Wed Nov 10 03:25:17 UTC 2010


details:	http://hg.adium.im/adium/rev/69a112797966
revision:	3502:69a112797966
author:		Evan Schoenberg
date:		Sun Sep 19 16:04:07 2010 -0500

If a contact was previously associated with an address book entry but now is not - e.g. the contact was within a metacontact that has an AB card, then is moved out of that metacontact and now should not have that same data - be sure to clear it. Also, added a debug log when grouping contacts via the address book to help investigate #13872. Refs #13872
(transplanted from ff2202a84a35c5d4dd91620e53f6524c0b04a24e)

diffs (137 lines):

diff -r dbc99b3b5ba1 -r 69a112797966 Frameworks/Adium Framework/Source/AIAddressBookController.m
--- a/Frameworks/Adium Framework/Source/AIAddressBookController.m	Tue Nov 09 18:58:54 2010 -0600
+++ b/Frameworks/Adium Framework/Source/AIAddressBookController.m	Sun Sep 19 16:04:07 2010 -0500
@@ -279,54 +279,32 @@
     if (inModifiedKeys == nil) { //Only perform this when updating for all list objects or when a contact is created
         ABPerson *person = [listContact addressBookPerson];
 
-		if (person) {
-			if (enableImport) {
-				//Load the name if appropriate
-				AIMutableOwnerArray *displayNameArray, *phoneticNameArray;
-				NSString			*displayName, *phoneticName = nil;
-				
-				displayNameArray = [listContact displayArrayForKey:@"Display Name"];
-				
-				displayName = [self nameForPerson:person phonetic:&phoneticName];
+		if (person && enableImport) {
+			//Load the name if appropriate
+			AIMutableOwnerArray *displayNameArray, *phoneticNameArray;
+			NSString			*displayName, *phoneticName = nil;
+			
+			displayNameArray = [listContact displayArrayForKey:@"Display Name"];
+			
+			displayName = [self nameForPerson:person phonetic:&phoneticName];
+			
+			//Apply the values 
+			NSString *oldValue = [displayNameArray objectWithOwner:self];
+			if (!oldValue || ![oldValue isEqualToString:displayName]) {
+				[displayNameArray setObject:displayName withOwner:self];
+				modifiedAttributes = [NSSet setWithObject:@"Display Name"];
+			}
+			
+			if (phoneticName) {
+				phoneticNameArray = [listContact displayArrayForKey:@"Phonetic Name"];
 				
 				//Apply the values 
-				NSString *oldValue = [displayNameArray objectWithOwner:self];
-				if (!oldValue || ![oldValue isEqualToString:displayName]) {
-					[displayNameArray setObject:displayName withOwner:self];
-					modifiedAttributes = [NSSet setWithObject:@"Display Name"];
+				oldValue = [phoneticNameArray objectWithOwner:self];
+				if (!oldValue || ![oldValue isEqualToString:phoneticName]) {
+					[phoneticNameArray setObject:phoneticName withOwner:self];
+					modifiedAttributes = [NSSet setWithObjects:@"Display Name", @"Phonetic Name", nil];
 				}
-				
-				if (phoneticName) {
-					phoneticNameArray = [listContact displayArrayForKey:@"Phonetic Name"];
-
-					//Apply the values 
-					oldValue = [phoneticNameArray objectWithOwner:self];
-					if (!oldValue || ![oldValue isEqualToString:phoneticName]) {
-						[phoneticNameArray setObject:phoneticName withOwner:self];
-						modifiedAttributes = [NSSet setWithObjects:@"Display Name", @"Phonetic Name", nil];
-					}
-				} else {
-					phoneticNameArray = [listContact displayArrayForKey:@"Phonetic Name"
-																 create:NO];
-					//Clear any stored value
-					if ([phoneticNameArray objectWithOwner:self]) {
-						[displayNameArray setObject:nil withOwner:self];
-						modifiedAttributes = [NSSet setWithObjects:@"Display Name", @"Phonetic Name", nil];
-					}					
-				}
-
 			} else {
-				AIMutableOwnerArray *displayNameArray, *phoneticNameArray;
-				
-				displayNameArray = [listContact displayArrayForKey:@"Display Name"
-															create:NO];
-
-				//Clear any stored value
-				if ([displayNameArray objectWithOwner:self]) {
-					[displayNameArray setObject:nil withOwner:self];
-					modifiedAttributes = [NSSet setWithObject:@"Display Name"];
-				}
-				
 				phoneticNameArray = [listContact displayArrayForKey:@"Phonetic Name"
 															 create:NO];
 				//Clear any stored value
@@ -334,21 +312,46 @@
 					[displayNameArray setObject:nil withOwner:self];
 					modifiedAttributes = [NSSet setWithObjects:@"Display Name", @"Phonetic Name", nil];
 				}					
-				
 			}
-
-			//If we changed anything, request an update of the alias / long display name
-			if (modifiedAttributes) {
-				[[NSNotificationCenter defaultCenter] postNotificationName:Contact_ApplyDisplayName
-														  object:listContact
-														userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:silent]
-																							 forKey:@"Notify"]];
+			
+		} else {
+			AIMutableOwnerArray *displayNameArray, *phoneticNameArray;
+			
+			displayNameArray = [listContact displayArrayForKey:@"Display Name"
+														create:NO];
+			
+			//Clear any stored value
+			if ([displayNameArray objectWithOwner:self]) {
+				[displayNameArray setObject:nil withOwner:self];
+				modifiedAttributes = [NSSet setWithObject:@"Display Name"];
 			}
-
-			//Add this contact to the ABPerson's metacontact if it's not already there.
+			
+			phoneticNameArray = [listContact displayArrayForKey:@"Phonetic Name"
+														 create:NO];
+			//Clear any stored value
+			if ([phoneticNameArray objectWithOwner:self]) {
+				[phoneticNameArray setObject:nil withOwner:self];
+				modifiedAttributes = [NSSet setWithObjects:@"Display Name", @"Phonetic Name", nil];
+			}					
+			
+		}
+		
+		//If we changed anything, request an update of the alias / long display name
+		if (modifiedAttributes) {
+			[[NSNotificationCenter defaultCenter] postNotificationName:Contact_ApplyDisplayName
+																object:listContact
+															  userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:silent]
+																								   forKey:@"Notify"]];
+		}
+		
+		//Add this contact to the ABPerson's metacontact if it's not already there.
+		if (person) {
 			AIMetaContact *personMetaContact;
 			if ((personMetaContact = [personUniqueIdToMetaContactDict objectForKey:[person uniqueId]]) &&
+				(personMetaContact != listContact) &&
 				![personMetaContact containsObject:listContact]) {
+				AILog(@"AIAddressBookController: personMetaContact = %@; listContact = %@; performing metacontact grouping",
+					  personMetaContact, listContact);
 				[adium.contactController groupContacts:[NSArray arrayWithObjects:personMetaContact, listContact, nil]];
 			}
 		}




More information about the commits mailing list