adium 4020:c9f8919114a4: Use the #define for a constant where ap...

commits at adium.im commits at adium.im
Sat Jun 25 21:31:19 UTC 2011


details:	http://hg.adium.im/adium/rev/c9f8919114a4
revision:	4020:c9f8919114a4
branch:		(none)
author:		Evan Schoenberg
date:		Sat Jun 25 16:31:14 2011 -0500

Use the #define for a constant where applicable. Speicifcally, KEY_FORMATTED_DISPLAY_NAME should be used for that key; the #define value needed to be changed for some reason, it should be changed there and an appropriate upgrade path made for existing preferences. Fixes saving of formatted display names (which were broken in [3380]).

Also moved OBJECT_STATUS_CACHE to a single universal #define, PREF_GROUP_OBJECT_STATUS_CACHE, as having multiple #defines for the same value is messy.

diffs (240 lines):

diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIAbstractAccount.m
--- a/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIAbstractAccount.m	Sat Jun 25 16:31:14 2011 -0500
@@ -124,7 +124,7 @@
 		[adium.preferenceController registerPreferenceObserver:self forGroup:GROUP_ACCOUNT_STATUS];
 
 		//Update our display name and formattedUID immediately
-		[self updateStatusForKey:@"formattedUID"];
+		[self updateStatusForKey:KEY_FORMATTED_UID];
 		
 		//Init the account
 		[self initFUSDisconnecting];
@@ -540,10 +540,10 @@
 			[self autoRefreshingOutgoingContentForStatusKey:key selector:@selector(gotFilteredDisplayName:) context:nil];
 		}
 
-	} else if ([key isEqualToString:@"formattedUID"]) {
+	} else if ([key isEqualToString:KEY_FORMATTED_UID]) {
 		//Transfer formatted UID from the stored preference to an in-memory property
-		[self setValue:[self preferenceForKey:@"formattedUID" group:GROUP_ACCOUNT_STATUS]
-					   forProperty:@"formattedUID"
+		[self setValue:[self preferenceForKey:KEY_FORMATTED_UID group:GROUP_ACCOUNT_STATUS]
+					   forProperty:KEY_FORMATTED_UID
 					   notify:NotifyNow];
 		
 	} else if ([key isEqualToString:@"Enabled"]) {
diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIAccount.m
--- a/Frameworks/Adium Framework/Source/AIAccount.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIAccount.m	Sat Jun 25 16:31:14 2011 -0500
@@ -466,7 +466,7 @@
 	if (!supportedPropertyKeys) {
 		supportedPropertyKeys = [[NSSet alloc] initWithObjects:
 			@"isOnline",
-			@"formattedUID",
+			KEY_FORMATTED_UID,
 			KEY_ACCOUNT_DISPLAY_NAME,
 			@"Display Name",
 			@"accountStatus",
diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIContactControllerProtocol.h
--- a/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h	Sat Jun 25 16:31:14 2011 -0500
@@ -63,6 +63,8 @@
 #define	PREF_GROUP_CONTACT_LIST_DISPLAY	@"Contact List Display"
 #define PREF_GROUP_CONTACT_LIST			@"Contact List"
 
+#define	PREF_GROUP_OBJECT_STATUS_CACHE	@"Object Status Cache"
+
 typedef enum {
 	AIUserInfoLabelValuePair = 0 /* default */,
 	AIUserInfoSectionHeader,
diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIListBookmark.m
--- a/Frameworks/Adium Framework/Source/AIListBookmark.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIListBookmark.m	Sat Jun 25 16:31:14 2011 -0500
@@ -28,7 +28,6 @@
 #import <AIUtilities/AIAttributedStringAdditions.h>
 
 #define	KEY_CONTAINING_OBJECT_UID	@"ContainingObjectUID"
-#define	OBJECT_STATUS_CACHE			@"Object Status Cache"
 
 #define KEY_ACCOUNT_INTERNAL_ID		@"AccountInternalObjectID"
 
@@ -218,7 +217,7 @@
 {
 	[self setPreference:inGroup.UID
 				 forKey:KEY_CONTAINING_OBJECT_UID
-				  group:OBJECT_STATUS_CACHE];	
+				  group:PREF_GROUP_OBJECT_STATUS_CACHE];	
 }
 
 /*!
@@ -231,7 +230,7 @@
 	[super addContainingGroup:inGroup];
 	
 	NSString *groupUID = inGroup.UID;
-	NSString *savedGroupUID = [self preferenceForKey:KEY_CONTAINING_OBJECT_UID group:OBJECT_STATUS_CACHE];
+	NSString *savedGroupUID = [self preferenceForKey:KEY_CONTAINING_OBJECT_UID group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	if((!savedGroupUID || ![groupUID isEqualToString:savedGroupUID]) &&
 		(inGroup != adium.contactController.contactList)) {
@@ -239,7 +238,7 @@
 		
 		[self setPreference:groupUID
 					 forKey:KEY_CONTAINING_OBJECT_UID
-					  group:OBJECT_STATUS_CACHE];
+					  group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	}
 }
 
@@ -254,7 +253,7 @@
 {
 	NSSet *targetGroup = nil;
 	// In reality, it's extremely unlikely the saved group would be lost.
-	NSString *savedGroupUID = [self preferenceForKey:KEY_CONTAINING_OBJECT_UID group:OBJECT_STATUS_CACHE] ?: AILocalizedString(@"Bookmarks", nil);
+	NSString *savedGroupUID = [self preferenceForKey:KEY_CONTAINING_OBJECT_UID group:PREF_GROUP_OBJECT_STATUS_CACHE] ?: AILocalizedString(@"Bookmarks", nil);
 
 	if (adium.contactController.useContactListGroups) {
 		targetGroup = [NSSet setWithObject:[adium.contactController groupWithUID:savedGroupUID]];
diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIListObject.m
--- a/Frameworks/Adium Framework/Source/AIListObject.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIListObject.m	Sat Jun 25 16:31:14 2011 -0500
@@ -26,13 +26,11 @@
 #import <Adium/AIContactHidingController.h>
 #import <Adium/AIStatus.h>
 
-#define ObjectStatusCache	@"Object Status Cache"
 #define DisplayName			@"Display Name"
 #define LongDisplayName		@"Long Display Name"
 #define Key					@"Key"
 #define Group				@"Group"
 #define DisplayServiceID	@"DisplayServiceID"
-#define FormattedUID		@"formattedUID"
 #define AlwaysVisible		@"alwaysVisible"
 #define StayInChat			@"StayInChat"
 
@@ -687,7 +685,7 @@
 - (void)listObject:(AIListObject *)listObject didSetOrderIndex:(float)orderIndexForObject
 {
 	NSDictionary		*dict = [self preferenceForKey:@"OrderIndexDictionary"
-												 group:ObjectStatusCache];
+												 group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	NSMutableDictionary *newDict = (dict ? [[dict mutableCopy] autorelease] : [NSMutableDictionary dictionary]);
 	
 	// Sanity check - are we trying to assign infinity?
@@ -702,7 +700,7 @@
 		// Update the preference.
 		[self setPreference:newDict
 					 forKey:@"OrderIndexDictionary"
-					  group:ObjectStatusCache];
+					  group:PREF_GROUP_OBJECT_STATUS_CACHE];
 		
 		// Update our largest cache.
 		[self updateOrderCache];
@@ -741,7 +739,7 @@
 	
 	[self setPreference:newDict
 				 forKey:@"OrderIndexDictionary"
-				  group:ObjectStatusCache];
+				  group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	[self updateOrderCache];
 }
@@ -750,8 +748,7 @@
 - (float)orderIndexForObject:(AIListObject *)listObject
 {
 	NSDictionary *dict = [self preferenceForKey:@"OrderIndexDictionary"
-										  group:ObjectStatusCache 
-						 ];
+										  group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	NSNumber *orderIndexForObjectNumber = [dict objectForKey:listObject.internalObjectID];
 	float orderIndexForObject = (orderIndexForObjectNumber ? [orderIndexForObjectNumber floatValue] : 0);
 	
@@ -790,7 +787,7 @@
 {
 	float smallest = INFINITY, largest = 0;
 	
-	NSDictionary *orderIndex = [self preferenceForKey:@"OrderIndexDictionary" group:ObjectStatusCache];
+	NSDictionary *orderIndex = [self preferenceForKey:@"OrderIndexDictionary" group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	for (NSNumber *idx in orderIndex.allValues) {
 		smallest = MIN(smallest, idx.floatValue);
diff -r 077b30a8398c -r c9f8919114a4 Frameworks/Adium Framework/Source/AIMetaContact.m
--- a/Frameworks/Adium Framework/Source/AIMetaContact.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Frameworks/Adium Framework/Source/AIMetaContact.m	Sat Jun 25 16:31:14 2011 -0500
@@ -28,8 +28,6 @@
 #import <Adium/AIStatus.h>
 #import <Adium/AIContactHidingController.h>
 
-#define	OBJECT_STATUS_CACHE			@"Object Status Cache"
-
 /* If META_TYPE_DEBUG is defined, metaContacts and uniqueMetaContacts are given an 
  * identifying suffix to their formattedUID in the contact list */
 //#define META_TYPE_DEBUG TRUE
@@ -67,7 +65,7 @@
 		
 		_containedObjects = [[NSMutableArray alloc] init];
 		
-		expanded = [[self preferenceForKey:KEY_EXPANDED group:OBJECT_STATUS_CACHE] boolValue];
+		expanded = [[self preferenceForKey:KEY_EXPANDED group:PREF_GROUP_OBJECT_STATUS_CACHE] boolValue];
 
 		containsOnlyOneUniqueContact = YES; /* Default to YES, because addObject: will change us to NO when needed */
 		containedObjectsNeedsSort = NO;
@@ -376,7 +374,7 @@
 	/* If we've messaged this contact previously, prefer the last contact we sent to 
 	 * if that contact's status is the most-available one the metacontact can offer
 	 */
-	NSString *objID = [self preferenceForKey:KEY_PREFERRED_DESTINATION_CONTACT group:OBJECT_STATUS_CACHE];
+	NSString *objID = [self preferenceForKey:KEY_PREFERRED_DESTINATION_CONTACT group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	if (objID)
 		preferredContact = [adium.contactController existingListObjectWithUniqueID:objID];
@@ -1011,7 +1009,7 @@
 		
 		[self setPreference:[NSNumber numberWithBool:expanded]
 					 forKey:KEY_EXPANDED
-					  group:OBJECT_STATUS_CACHE];
+					  group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	}
 }
diff -r 077b30a8398c -r c9f8919114a4 Source/AIAliasSupportPlugin.m
--- a/Source/AIAliasSupportPlugin.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Source/AIAliasSupportPlugin.m	Sat Jun 25 16:31:14 2011 -0500
@@ -120,7 +120,7 @@
  */
 - (NSSet *)updateListObject:(AIListObject *)inObject keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
 {
-    if ((inModifiedKeys == nil) || ([inModifiedKeys containsObject:@"formattedUID"])) {
+    if ((inModifiedKeys == nil) || ([inModifiedKeys containsObject:KEY_FORMATTED_UID])) {
 		return [self _applyAlias:[inObject preferenceForKey:@"Alias"
 													  group:PREF_GROUP_ALIASES 
 									 ]
diff -r 077b30a8398c -r c9f8919114a4 Source/AIContactController.m
--- a/Source/AIContactController.m	Sat Jun 25 16:19:52 2011 -0500
+++ b/Source/AIContactController.m	Sat Jun 25 16:31:14 2011 -0500
@@ -53,9 +53,6 @@
 #define KEY_FLAT_METACONTACTS			@"FlatMetaContacts"		//Metacontact objectID storage
 #define KEY_BOOKMARKS					@"Bookmarks"
 
-#define	OBJECT_STATUS_CACHE				@"Object Status Cache"
-
-
 #define TOP_METACONTACT_ID				@"TopMetaContactID"
 #define KEY_IS_METACONTACT				@"isMetaContact"
 #define KEY_OBJECTID					@"objectID"
@@ -1436,12 +1433,13 @@
 		return;
 	
 	NSString	*destinationInternalObjectID = destContact.internalObjectID;
-	NSString	*currentPreferredDestination = [metaContact preferenceForKey:KEY_PREFERRED_DESTINATION_CONTACT group:OBJECT_STATUS_CACHE];
+	NSString	*currentPreferredDestination = [metaContact preferenceForKey:KEY_PREFERRED_DESTINATION_CONTACT 
+                                                                    group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	
 	if (![destinationInternalObjectID isEqualToString:currentPreferredDestination]) {
 		[metaContact setPreference:destinationInternalObjectID
 							forKey:KEY_PREFERRED_DESTINATION_CONTACT
-							 group:OBJECT_STATUS_CACHE];
+							 group:PREF_GROUP_OBJECT_STATUS_CACHE];
 	}
 }
 



More information about the commits mailing list