adium 2206:09eb872535ff: AIContactLists shouldn't move their con...

commits at adium.im commits at adium.im
Sat May 16 22:11:57 UTC 2009


details:	http://hg.adium.im/adium/rev/09eb872535ff
revision:	2206:09eb872535ff
author:		Zachary West <zacw at adium.im>
date:		Sat May 16 18:11:48 2009 -0400

AIContactLists shouldn't move their contents around directly. Move this logic to the contact controller.

Fixes the "all groups are gone" notification not being posted during a drag. Fixes #12011.

diffstat:

 Frameworks/Adium Framework/Source/AIContactControllerProtocol.h |   1 +
 Frameworks/Adium Framework/Source/AIContactList.h               |   3 -
 Frameworks/Adium Framework/Source/AIContactList.m               |  22 -------
 Source/AIContactController.m                                    |  23 +++++++
 Source/AIListController.m                                       |   6 +-
 Source/AISCLViewPlugin.m                                        |  28 ++-------
 6 files changed, 35 insertions(+), 48 deletions(-)

diffs (146 lines):

diff -r cbf4b0122c52 -r 09eb872535ff Frameworks/Adium Framework/Source/AIContactControllerProtocol.h
--- a/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h	Sat May 16 16:43:37 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h	Sat May 16 18:11:48 2009 -0400
@@ -115,6 +115,7 @@
 - (void)explodeMetaContact:(AIMetaContact *)metaContact; //Unpack contained contacts and then remove the meta
 - (void)removeListGroup:(AIListGroup *)listGroup;
 - (void)requestAddContactWithUID:(NSString *)contactUID service:(AIService *)inService account:(AIAccount *)inAccount;
+- (void)moveGroup:(AIListGroup *)group fromContactList:(AIContactList *)oldContactList toContactList:(AIContactList *)contactList;
 - (void)moveContact:(AIListObject *)listContact fromGroups:(NSSet *)oldGroups intoGroups:(NSSet *)groups;
 - (void)_moveContactLocally:(AIListContact *)listContact fromGroups:(NSSet *)oldGroups toGroups:(NSSet *)groups;
 @property (readonly, nonatomic) BOOL useContactListGroups;
diff -r cbf4b0122c52 -r 09eb872535ff Frameworks/Adium Framework/Source/AIContactList.h
--- a/Frameworks/Adium Framework/Source/AIContactList.h	Sat May 16 16:43:37 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIContactList.h	Sat May 16 18:11:48 2009 -0400
@@ -21,7 +21,4 @@
 	
 }
 
-- (void)moveAllGroupsTo:(AIContactList *)toContactList;
-- (BOOL)moveGroup:(AIListGroup *)group to:(AIContactList *)toList;
-
 @end
diff -r cbf4b0122c52 -r 09eb872535ff Frameworks/Adium Framework/Source/AIContactList.m
--- a/Frameworks/Adium Framework/Source/AIContactList.m	Sat May 16 16:43:37 2009 -0400
+++ b/Frameworks/Adium Framework/Source/AIContactList.m	Sat May 16 18:11:48 2009 -0400
@@ -57,26 +57,4 @@
 	[super sort];
 }
 
-- (void)moveAllGroupsTo:(AIContactList *)toContactList 
-{
-	for (AIListObject *object in self) {
-		if ([object isKindOfClass:[AIListGroup class]]) {
-			[self moveGroup:(AIListGroup *)object to:toContactList];
-		}
-	}
-}
-
-- (BOOL)moveGroup:(AIListGroup *)group to:(AIContactList *)toList
-{
-	// Check if group is not already there
-	if(![self containsObject:group] || [toList containsObject:group])
-		return NO;
-	
-	//XXX is this right? we may need contact controller involvement here
-	[self removeObject:group];
-	[toList addObject:group];
-	
-	return YES;
-}
-
 @end
diff -r cbf4b0122c52 -r 09eb872535ff Source/AIContactController.m
--- a/Source/AIContactController.m	Sat May 16 16:43:37 2009 -0400
+++ b/Source/AIContactController.m	Sat May 16 18:11:48 2009 -0400
@@ -1484,6 +1484,29 @@
 }
 
 #pragma mark Detached Contact Lists
+- (void)moveGroup:(AIListGroup *)group fromContactList:(AIContactList *)oldContactList toContactList:(AIContactList *)newContactList
+{
+	if (![oldContactList containsObject:group] || [newContactList containsObject:group]) {
+		return;
+	}
+	
+	[oldContactList removeObject:group];
+	[newContactList addObject:group];
+
+	[[NSNotificationCenter defaultCenter] postNotificationName:Contact_ListChanged
+														object:newContactList
+													  userInfo:nil];
+	
+	if (!oldContactList.containedObjects.count) {
+		[[NSNotificationCenter defaultCenter] postNotificationName:DetachedContactListIsEmpty
+															object:oldContactList
+														  userInfo:nil];
+	} else {
+		[[NSNotificationCenter defaultCenter] postNotificationName:Contact_ListChanged
+															object:oldContactList
+														  userInfo:nil];
+	}
+}
 
 /*!
  * @returns Empty contact list
diff -r cbf4b0122c52 -r 09eb872535ff Source/AIListController.m
--- a/Source/AIListController.m	Sat May 16 16:43:37 2009 -0400
+++ b/Source/AIListController.m	Sat May 16 18:11:48 2009 -0400
@@ -720,8 +720,10 @@
 						} else if ([listObject isKindOfClass:[AIListGroup class]]) {							
 							// Group being moved to a new detached window.
 							NSAssert([group isKindOfClass:[AIContactList class]], @"Target group not an AIContactList");
-							
-							[[(AIListGroup *)listObject contactList] moveGroup:(AIListGroup *)listObject to:(AIContactList *)group];
+
+							[adium.contactController moveGroup:(AIListGroup *)listObject
+											   fromContactList:((AIListGroup *)listObject).contactList 
+												 toContactList:(AIContactList *)group];
 						}
 					}
 					
diff -r cbf4b0122c52 -r 09eb872535ff Source/AISCLViewPlugin.m
--- a/Source/AISCLViewPlugin.m	Sat May 16 16:43:37 2009 -0400
+++ b/Source/AISCLViewPlugin.m	Sat May 16 18:11:48 2009 -0400
@@ -299,8 +299,12 @@
 		defaultController = nil;
 	} else {
 		//Return the groups in this detached contact list to the main contact list
-		[(AIContactList *)[windowController contactList] moveAllGroupsTo:adium.contactController.contactList];
-
+		for (AIListGroup *group in windowController.contactList) {
+			[adium.contactController moveGroup:group 
+							   fromContactList:windowController.contactList
+								 toContactList:adium.contactController.contactList];
+		}
+		
 		[adium.contactController removeDetachedContactList:(AIContactList *)[windowController contactList]];
 		
 		[[NSNotificationCenter defaultCenter] postNotificationName:@"Contact_ListChanged"
@@ -419,25 +423,7 @@
  */
 - (void)moveListGroup:(AIListGroup *)listGroup toContactList:(AIContactList *)destinationList
 {
-	AIContactList *sourceList = listGroup.contactList;
-
-	[sourceList moveGroup:listGroup to:destinationList];
-	
-	// Update contact list
-	[[NSNotificationCenter defaultCenter] postNotificationName:@"Contact_ListChanged"
-											  object:destinationList
-											userInfo:nil];
-	
-	// Post a notification that we've removed or changed the source group/window
-	if ([sourceList countOfContainedObjects] == 0) { 
-		[[NSNotificationCenter defaultCenter] postNotificationName:DetachedContactListIsEmpty
-												  object:sourceList
-												userInfo:nil];
-	} else {
-		[[NSNotificationCenter defaultCenter] postNotificationName:@"Contact_ListChanged"
-												  object:sourceList
-												userInfo:nil]; 
-	}
+	[adium.contactController moveGroup:listGroup fromContactList:listGroup.contactList toContactList:destinationList];
 }
 
 /*!




More information about the commits mailing list