adium 3314:0ca2f589a8d5: Removing spurious debug logging
commits at adium.im
commits at adium.im
Sun Sep 19 21:21:45 UTC 2010
details: http://hg.adium.im/adium/rev/0ca2f589a8d5
revision: 3314:0ca2f589a8d5
author: Evan Schoenberg
date: Sun Sep 19 15:54:07 2010 -0500
Removing spurious debug logging
(transplanted from e7b6ca0c6fbc17eadab034eaced2882aa5f7b826)
Subject: adium 3315:898c5f4a8ddc: Useful debug logging
details: http://hg.adium.im/adium/rev/898c5f4a8ddc
revision: 3315:898c5f4a8ddc
author: Evan Schoenberg
date: Sun Sep 19 15:54:28 2010 -0500
Useful debug logging
(transplanted from 9aed283a5ddd0555e87bc9e64eb998d7b06aeea9)
Subject: adium 3316:bbdb662d025c: Improve debug logging
details: http://hg.adium.im/adium/rev/bbdb662d025c
revision: 3316:bbdb662d025c
author: Evan Schoenberg
date: Sun Sep 19 15:54:50 2010 -0500
Improve debug logging
(transplanted from 16aedee3a0cb5ccc364fa505a588f02b075071db)
Subject: adium 3317:4dd6ecc25f7d: Fixed multiple bugs with meta contact inter-group movement, merging of contacts, unmerging of contacts, and determination of 'uniqueness' of metacontacts (that is, whether they are presented to the user as a single contact or as the root of a combined contact) after contacts are added or removed from a metacontact.
details: http://hg.adium.im/adium/rev/4dd6ecc25f7d
revision: 3317:4dd6ecc25f7d
author: Evan Schoenberg
date: Sun Sep 19 15:58:44 2010 -0500
Fixed multiple bugs with meta contact inter-group movement, merging of contacts, unmerging of contacts, and determination of 'uniqueness' of metacontacts (that is, whether they are presented to the user as a single contact or as the root of a combined contact) after contacts are added or removed from a metacontact.
Fixes #13965. Fixes #12156.
Other contact list issues might also be fixed in the process, since as we often hide that a contact is a metacontact (via 'uniqueness') users may report problems with non-metacontacts which are actually metacontact bugs. Refs #13871. Refs #13889.
(transplanted from 0b981d5c2c762e49153bd3ee80a35ad80cd347be)
Subject: adium 3318:d26686d2ca11: Some cleanup, and reduced spamming of the IdleSince preference when we remain idle; previously, this was being written out every few seconds while were idle.
details: http://hg.adium.im/adium/rev/d26686d2ca11
revision: 3318:d26686d2ca11
author: Evan Schoenberg
date: Sun Sep 19 15:59:50 2010 -0500
Some cleanup, and reduced spamming of the IdleSince preference when we remain idle; previously, this was being written out every few seconds while were idle.
(transplanted from dc404cfe09ca64b70742b7ca0ad071fc8fc2a5ca)
Subject: adium 3319:cc5289db93c9: Whitespace fix
details: http://hg.adium.im/adium/rev/cc5289db93c9
revision: 3319:cc5289db93c9
author: Evan Schoenberg
date: Sun Sep 19 16:00:02 2010 -0500
Whitespace fix
(transplanted from 057e7349f6288b6c9ecfccd6970c472cbb0c2d91)
Subject: adium 3320:5e39c0092899: Deloggification
details: http://hg.adium.im/adium/rev/5e39c0092899
revision: 3320:5e39c0092899
author: Evan Schoenberg
date: Sun Sep 19 16:00:13 2010 -0500
Deloggification
(transplanted from 50984fdcc64dac5d25064ba2f20e056ebfd0e707)
Subject: adium 3321:53ebd43ae62b: Deloggification
details: http://hg.adium.im/adium/rev/53ebd43ae62b
revision: 3321:53ebd43ae62b
author: Evan Schoenberg
date: Sun Sep 19 16:00:22 2010 -0500
Deloggification
(transplanted from bd2cd2a48aeb334e6dcc74743364431f4d977983)
Subject: adium 3322:a9575b3b3163: Don't waste memory and CPU allocating and storing the final debug messages if debug logging isn't enabled. AILog() still isn't free since any functions and methods passed as arguments are resolved, but I think this is a reasonable compromise which still lets us instruct users to enable debug logging within release builds.
details: http://hg.adium.im/adium/rev/a9575b3b3163
revision: 3322:a9575b3b3163
author: Evan Schoenberg
date: Sun Sep 19 16:01:38 2010 -0500
Don't waste memory and CPU allocating and storing the final debug messages if debug logging isn't enabled. AILog() still isn't free since any functions and methods passed as arguments are resolved, but I think this is a reasonable compromise which still lets us instruct users to enable debug logging within release builds.
(transplanted from 19722a7790dfef62aa8f52b148e70706f1657904)
diffs (650 lines):
diff -r a534d21369d5 -r a9575b3b3163 Frameworks/Adium Framework/Source/AIListContact.m
--- a/Frameworks/Adium Framework/Source/AIListContact.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Frameworks/Adium Framework/Source/AIListContact.m Sun Sep 19 16:01:38 2010 -0500
@@ -257,8 +257,6 @@
BOOL changes = NO;
BOOL displayNameChanges = NO;
- AILogWithSignature(@"%@ received alias %@", self, alias);
-
//This is the server display name. Set it as such.
if (![alias isEqualToString:[self valueForProperty:@"Server Display Name"]]) {
//Set the server display name property as the full display name
@@ -713,6 +711,8 @@
- (void) setMetaContact:(AIMetaContact *)meta
{
metaContact = meta;
+
+ /* Ugly: Subclass accessing superclass's ivar */
[m_groups removeAllObjects];
}
diff -r a534d21369d5 -r a9575b3b3163 Frameworks/Adium Framework/Source/AIMetaContact.h
--- a/Frameworks/Adium Framework/Source/AIMetaContact.h Sun Sep 19 20:41:15 2010 +0200
+++ b/Frameworks/Adium Framework/Source/AIMetaContact.h Sun Sep 19 16:01:38 2010 -0500
@@ -26,7 +26,6 @@
NSArray *_listContactsIncludingOfflineAccounts;
BOOL containsOnlyOneUniqueContact;
- BOOL containsOnlyOneService;
NSMutableArray *_containedObjects; //Manually ordered array of contents
BOOL containedObjectsNeedsSort;
diff -r a534d21369d5 -r a9575b3b3163 Frameworks/Adium Framework/Source/AIMetaContact.m
--- a/Frameworks/Adium Framework/Source/AIMetaContact.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Frameworks/Adium Framework/Source/AIMetaContact.m Sun Sep 19 16:01:38 2010 -0500
@@ -30,6 +30,10 @@
#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
+
@interface AIListContact ()
@property (readwrite, nonatomic, assign) AIMetaContact *metaContact;
- (void)setContainingObject:(AIListGroup *)inGroup;
@@ -63,8 +67,7 @@
expanded = [[self preferenceForKey:KEY_EXPANDED group:OBJECT_STATUS_CACHE] boolValue];
- containsOnlyOneUniqueContact = NO;
- containsOnlyOneService = YES;
+ containsOnlyOneUniqueContact = YES; /* Default to YES, because addObject: will change us to NO when needed */
containedObjectsNeedsSort = NO;
saveGroupingChanges = YES;
}
@@ -276,6 +279,8 @@
[self visibleListContacts];
success = YES;
+ } else {
+ AILogWithSignature(@"%@ (meta=%p) already contained in %@", inObject, ((AIListContact *)inObject).metaContact, self);
}
return success;
@@ -286,26 +291,32 @@
*
* Should only be called by AIContactController.
*/
-- (void)removeObject:(AIListObject *)inObject
+- (BOOL)removeObject:(AIListObject *)inObject
{
NSParameterAssert([inObject isKindOfClass:[AIListContact class]]);
AIListContact *contact = (AIListContact *)inObject;
if ([self.containedObjects containsObjectIdenticalTo:inObject]) {
- BOOL noteRemoteGroupingChanged = NO;
+ BOOL needToResetToRemoteGroup = NO;
[inObject retain];
- BOOL wasPreferredContact = inObject == self.preferredContact;
+ BOOL wasPreferredContact = (inObject == self.preferredContact);
[_containedObjects removeObject:inObject];
- if (contact.countOfRemoteGroupNames > 0) {
- //Reset it to its remote group
+ if (contact.metaContact == self) {
+ /* If the contact is being reassigned to another metaContact, this may already have been done; we shouldn't
+ * mess with it if it's not still ours to order around. The other metaContact will manage it as needed.
+ */
contact.metaContact = nil;
- noteRemoteGroupingChanged = YES;
- } else {
- for (AIListGroup *group in self.groups)
- [contact addContainingGroup:group];
+
+ if (contact.countOfRemoteGroupNames > 0) {
+ //Reset it to its remote group
+ needToResetToRemoteGroup = YES;
+ } else {
+ for (AIListGroup *group in self.groups)
+ [contact addContainingGroup:group];
+ }
}
[self containedObjectsOrOrderDidChange];
@@ -326,11 +337,16 @@
/* Now that we're done reconfigured ourselves and the recently removed object,
* tell the contactController about the change in the removed object.
*/
- if (noteRemoteGroupingChanged) {
+ if (needToResetToRemoteGroup) {
[(AIListContact *)inObject restoreGrouping];
}
[inObject release];
+
+ return YES;
+ } else {
+ AILogWithSignature(@"%@: Asked to remove %@, but it's not actually contained therein", self, inObject);
+ return NO;
}
}
@@ -809,7 +825,13 @@
//FormattedUID will return nil if we have multiple different UIDs contained within us
- (NSString *)formattedUID
{
+#ifdef META_TYPE_DEBUG
+ return (containsOnlyOneUniqueContact ?
+ [self.preferredContact.formattedUID stringByAppendingString:@" (uniqueMeta)"] :
+ @"meta");
+#else
return containsOnlyOneUniqueContact ? self.preferredContact.formattedUID : nil;
+#endif
}
- (NSString *)longDisplayName
diff -r a534d21369d5 -r a9575b3b3163 Frameworks/Adium Framework/Source/ESDebugAILog.m
--- a/Frameworks/Adium Framework/Source/ESDebugAILog.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Frameworks/Adium Framework/Source/ESDebugAILog.m Sun Sep 19 16:01:38 2010 -0500
@@ -58,6 +58,8 @@
}
void AILog_impl (NSString *format, ...) {
+ if (!AIDebugLoggingEnabled) return;
+
va_list ap; /* Points to each unamed argument in turn */
NSString *debugMessage;
@@ -72,6 +74,8 @@
}
void AILogWithPrefix_impl (const char *prefix, NSString *format, ...) {
+ if (!AIDebugLoggingEnabled) return;
+
va_list ap; /* Points to each unamed argument in turn */
NSString *debugMessage, *actualMessage;
diff -r a534d21369d5 -r a9575b3b3163 Plugins/Purple Service/CBPurpleAccount.m
--- a/Plugins/Purple Service/CBPurpleAccount.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Plugins/Purple Service/CBPurpleAccount.m Sun Sep 19 16:01:38 2010 -0500
@@ -544,7 +544,6 @@
- (void)delayedUpdateContactStatus:(AIListContact *)inContact
{
//Request profile
- AILogWithSignature(@"");
[purpleAdapter getInfoFor:inContact.UID onAccount:self];
}
diff -r a534d21369d5 -r a9575b3b3163 Plugins/Purple Service/adiumPurpleSignals.m
--- a/Plugins/Purple Service/adiumPurpleSignals.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Plugins/Purple Service/adiumPurpleSignals.m Sun Sep 19 16:01:38 2010 -0500
@@ -193,11 +193,8 @@
* Failing that, we will get an alias specified remotely (either by the server or by the buddy).
*/
const char *alias = purple_buddy_get_alias_only(buddy);
-
- AILogWithSignature(@"%@ -> %s", contactLookupFromBuddy(buddy), alias);
if (alias) {
- AILogWithSignature(@"%@", listContact);
[account updateContact:listContact
toAlias:[NSString stringWithUTF8String:alias]];
}
diff -r a534d21369d5 -r a9575b3b3163 Source/AIAliasSupportPlugin.m
--- a/Source/AIAliasSupportPlugin.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIAliasSupportPlugin.m Sun Sep 19 16:01:38 2010 -0500
@@ -179,8 +179,7 @@
NSString *alias = [userInfo objectForKey:@"Alias"];
if (!alias) {
alias = [object preferenceForKey:@"Alias"
- group:PREF_GROUP_ALIASES
- ];
+ group:PREF_GROUP_ALIASES];
}
[self _applyAlias:alias
diff -r a534d21369d5 -r a9575b3b3163 Source/AIAutomaticStatus.h
--- a/Source/AIAutomaticStatus.h Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIAutomaticStatus.h Sun Sep 19 16:01:38 2010 -0500
@@ -24,7 +24,7 @@
@interface AIAutomaticStatus : AIPlugin {
NSNumber *fastUserSwitchID;
NSNumber *screenSaverID;
- NSNumber *idleID;
+ NSNumber *idleStatusID;
NSNumber *oldStatusID;
@@ -33,7 +33,7 @@
BOOL fastUserSwitchEnabled;
BOOL screenSaverEnabled;
- BOOL idleEnabled;
+ BOOL idleStatusEnabled;
BOOL reportIdleEnabled;
double idleReportInterval;
diff -r a534d21369d5 -r a9575b3b3163 Source/AIAutomaticStatus.m
--- a/Source/AIAutomaticStatus.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIAutomaticStatus.m Sun Sep 19 16:01:38 2010 -0500
@@ -150,7 +150,7 @@
// Stored status IDs
[fastUserSwitchID release];
[screenSaverID release];
- [idleID release];
+ [idleStatusID release];
[oldStatusID release];
@@ -177,9 +177,9 @@
idleReportInterval = [[prefDict objectForKey:KEY_STATUS_REPORT_IDLE_INTERVAL] doubleValue];
// Idle status change
- [idleID release];
- idleID = [[prefDict objectForKey:KEY_STATUS_AUTO_AWAY_STATUS_STATE_ID] retain];
- idleEnabled = [[prefDict objectForKey:KEY_STATUS_AUTO_AWAY] boolValue];
+ [idleStatusID release];
+ idleStatusID = [[prefDict objectForKey:KEY_STATUS_AUTO_AWAY_STATUS_STATE_ID] retain];
+ idleStatusEnabled = [[prefDict objectForKey:KEY_STATUS_AUTO_AWAY] boolValue];
idleStatusInterval = [[prefDict objectForKey:KEY_STATUS_AUTO_AWAY_INTERVAL] doubleValue];
// Fast user switch
@@ -226,17 +226,22 @@
// This is very spammy when we're already idle.
if (duration >= idleStatusInterval && !(automaticStatusBitMap & AIAwayIdle)) {
- AILogWithSignature(@"Idle (start) detected.");
+ NSDate *idleSince = [[notification userInfo] objectForKey:@"IdleSince"];
- if (idleEnabled) automaticStatusBitMap |= AIAwayIdle;
-
- // Update our idle time
- if (reportIdleEnabled) {
- [adium.preferenceController setPreference:[[notification userInfo] objectForKey:@"IdleSince"]
- forKey:@"IdleSince"
- group:GROUP_ACCOUNT_STATUS];
+ if (![[adium.preferenceController preferenceForKey:@"IdleSince" group:GROUP_ACCOUNT_STATUS] isEqualToDate:idleSince]) {
+ AILogWithSignature(@"Idle (start) detected.");
+
+ if (idleStatusEnabled) automaticStatusBitMap |= AIAwayIdle;
+
+ // Update our idle time
+ if (reportIdleEnabled) {
+ [adium.preferenceController setPreference:[[notification userInfo] objectForKey:@"IdleSince"]
+ forKey:@"IdleSince"
+ group:GROUP_ACCOUNT_STATUS];
+ }
}
}
+
} if ([notificationName isEqualToString:AIScreenLockDidStartNotification]) {
AILogWithSignature(@"Screenlock (start) detected.");
@@ -286,7 +291,7 @@
statusID = screenSaverID;
else if (automaticStatusBitMap & AIAwayIdle)
- statusID = idleID;
+ statusID = idleStatusID;
else
[self returnFromAutoAway];
diff -r a534d21369d5 -r a9575b3b3163 Source/AIContactController.m
--- a/Source/AIContactController.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIContactController.m Sun Sep 19 16:01:38 2010 -0500
@@ -69,13 +69,15 @@
#define SERVICE_ID_KEY @"ServiceID"
#define UID_KEY @"UID"
+//#define CONTACT_MOVEMENT_DEBUG
+
@interface AIListObject ()
@property (readwrite, nonatomic) CGFloat orderIndex;
@end
@interface AIMetaContact ()
-- (void)removeObject:(AIListObject *)inObject;
- (BOOL)addObject:(AIListObject *)inObject;
+- (BOOL)removeObject:(AIListObject *)inObject;
- (AIListContact *)preferredContactForContentType:(NSString *)inType;
@end
@@ -289,24 +291,24 @@
if (existingObject) {
//If an object exists in this group with the same UID and serviceID, create a MetaContact
//for the two.
- AIMetaContact *metaContact = [self groupContacts:[NSArray arrayWithObjects:listContact,existingObject,nil]];
- AILogWithSignature(@"Grouping %@ with %@ because there was a sevice/UID match within %@, yielding %@ within %@",
- listContact, existingObject, localGroup,
- metaContact, metaContact.containingObjects);
+ AIMetaContact *metaContact = [self groupContacts:[NSArray arrayWithObjects:listContact,existingObject,nil]];
+
+ AILogWithSignature(@"%@ and %@ match; grouped into %@",
+ listContact, existingObject, metaContact);
performedGrouping = YES;
} else {
AIMetaContact *metaContact = [contactToMetaContactLookupDict objectForKey:listContact.internalObjectID];
- //If no object exists in this group which matches, we should check if there is already
- //a MetaContact holding a matching ListContact, since we should include this contact in it
- //If we found a metaContact to which we should add, do it.
- AILogWithSignature(@"Adding %@ to %@ because %@ already is within a known metacontact, which is in %@",
- listContact, metaContact, listContact.internalObjectID, metaContact.containingObjects);
- if (metaContact) {
- [self addContact:listContact toMetaContact:metaContact];
- performedGrouping = YES;
- }
+ /* If no object exists in this group which matches, we should check if there is already
+ * a MetaContact holding a matching ListContact, since we should include this contact in it
+ * If we found a metaContact to which we should add, do it.
+ */
+ if (metaContact) {
+ AILogWithSignature(@"%@: Add %@", metaContact, listContact);
+ [self addContact:listContact toMetaContact:metaContact];
+ performedGrouping = YES;
+ }
}
}
@@ -332,25 +334,32 @@
*/
- (void)_moveContactLocally:(AIListContact *)listContact fromGroups:(NSSet *)oldGroups toGroups:(NSSet *)groups
{
- //Protect with a retain while we are removing and adding the contact to our arrays
- [listContact retain];
-
- [contactPropertiesObserverManager delayListObjectNotifications];
-
- AILogWithSignature(@"Removing %@ from %@ locally to add to %@", listContact, oldGroups, groups);
-
- //Remove this object from any local groups we have it in currently
- for (AIListObject<AIContainingObject> *group in oldGroups) {
- [group removeObject:listContact];
- [self _didChangeContainer:group object:listContact];
+ if (![oldGroups isEqualToSet:groups]) {
+ //Protect with a retain while we are removing and adding the contact to our arrays
+ [listContact retain];
+
+ [contactPropertiesObserverManager delayListObjectNotifications];
+
+#ifdef CONTACT_MOVEMENT_DEBUG
+ AILogWithSignature(@"%@: %@ --> %@",
+ listContact,
+ (oldGroups.count ? oldGroups : nil),
+ (groups.count ? (groups.count == 1 ? [groups anyObject] ? groups) : nil));
+#endif
+
+ //Remove this object from any local groups we have it in currently
+ for (AIListObject<AIContainingObject> *group in oldGroups) {
+ [group removeObject:listContact];
+ [self _didChangeContainer:group object:listContact];
+ }
+
+ for (AIListObject<AIContainingObject> *group in groups)
+ [self _addContactLocally:listContact toGroup:group];
+
+ [contactPropertiesObserverManager endListObjectNotificationsDelay];
+
+ [listContact release];
}
-
- for (AIListObject<AIContainingObject> *group in groups)
- [self _addContactLocally:listContact toGroup:group];
-
- [contactPropertiesObserverManager endListObjectNotificationsDelay];
-
- [listContact release];
}
//Post a list grouping changed notification for the object and containing object
@@ -587,27 +596,57 @@
}
if (inContact == metaContact) return;
-
+
+ AILogWithSignature(@"%@ will add %@", metaContact, inContact);
+
//If listObject contains other contacts, perform addContact:toMetaContact: recursively
if ([inContact conformsToProtocol:@protocol(AIContainingObject)]) {
+ AILogWithSignature(@"Adding recursively (%@)", ((AIListObject<AIContainingObject> *)inContact).containedObjects);
for (AIListContact *someObject in ((AIListObject<AIContainingObject> *)inContact).containedObjects) {
[self addContact:someObject toMetaContact:metaContact];
}
} else {
//Obtain any metaContact this listObject is currently within, so we can remove it later
- AIMetaContact *oldMetaContact = [contactToMetaContactLookupDict objectForKey:[inContact internalObjectID]];
+ AIMetaContact *oldMetaContact;
- if ([self _performAddContact:inContact toMetaContact:metaContact] && metaContact != oldMetaContact) {
- //If this listObject was not in this metaContact in any form before, store the change
- //Remove the list object from any other metaContact it is in at present
- if (oldMetaContact)
- [self removeContact:inContact fromMetaContact:oldMetaContact];
-
- [self _storeListObject:inContact inMetaContact:metaContact];
+ /* First, look for a metaContact which is -properly- associated with inContact, already.
+ * That is, a metaContact that has current ownership but which should be disassociated, in faovr of the new
+ * metaContact.
+ */
+ oldMetaContact = [contactToMetaContactLookupDict objectForKey:[inContact internalObjectID]];
+
+ if (metaContact == oldMetaContact) {
+ /* According to contactToMetaContactLookupDict, inContact is within metaContact already.
+ * However, a single UID/serviceID pair can have multiple AIListContacts (for multiple accounts).
+ * If Account A and Account B both have a contact like inContact, and we are looking at Account B's
+ * contact now, we'll have already made a reassignment. This contact does still need to be removed from
+ * its parent, however.
+ */
+ if ((inContact.parentContact != inContact) &&
+ ([inContact.parentContact isKindOfClass:[AIMetaContact class]])) {
+ oldMetaContact = (AIMetaContact *)(inContact.parentContact);
+ }
+ }
+
+ if ([self _performAddContact:inContact toMetaContact:metaContact]) {
+ if (metaContact != oldMetaContact) {
+ AILogWithSignature(@"oldMetaContact for %@ is %@", inContact.internalObjectID, oldMetaContact);
- //Do the update thing
- [contactPropertiesObserverManager _updateAllAttributesOfObject:metaContact];
+ //If this listObject was not in this metaContact in any form before, store the change
+ //Remove the list object from any other metaContact it is in at present
+ if (oldMetaContact)
+ [self removeContact:inContact fromMetaContact:oldMetaContact];
+
+ [self _storeListObject:inContact inMetaContact:metaContact];
+
+ //Do the update thing
+ [contactPropertiesObserverManager _updateAllAttributesOfObject:metaContact];
+ } else {
+ AILogWithSignature(@"The old metacontact was the same as the new metacontact");
+ }
+ } else {
+ AILogWithSignature(@"Failed to add %@ to %@", inContact, metaContact);
}
}
}
@@ -651,21 +690,35 @@
[adium.contactAlertsController mergeAndMoveContactAlertsFromListObject:listObject
intoListObject:metaContact];
+
+ AILogWithSignature(@"Updated %@'s containedContactsArray: %@", metaContact, containedContactsArray);
}
[allMetaContactsDict release];
[containedContactsArray release];
}
-//Actually adds a list contact to a meta contact. No preferences are changed.
-//Attempts to add the list object, causing group reassignment and updates our contactToMetaContactLookupDict
-//for quick lookup of the MetaContact given a AIListContact uniqueObjectID if successful.
+/*!
+ * @brief Makes the associations between an AIListContact and an AIMetaContact within memory
+ *
+ * No preferences are changed; this is an internal step during the process of moving a contact into a metacontact.
+ *
+ * Attempts to add the list object, causing group reassignment and updates our contactToMetaContactLookupDict
+ * for quick lookup of the MetaContact given a AIListContact uniqueObjectID if successful.
+ *
+ * @result YES if a change was made; NO if inContact is already contained by metaContact
+ */
- (BOOL)_performAddContact:(AIListContact *)inContact toMetaContact:(AIMetaContact *)metaContact
{
+ if (inContact.metaContact == metaContact) {
+ AILogWithSignature(@"%@'s metaContact is already %@", inContact, metaContact);
+ return NO;
+ }
+
//we only allow group->meta->contact, not group->meta->meta->contact
NSParameterAssert([metaContact canContainObject:inContact]);
-
- BOOL success;
+
+ BOOL success;
//Remove the object from its previous containing groups
if (inContact.groups.count)
@@ -686,6 +739,8 @@
- (void)removeContact:(AIListContact *)inContact fromMetaContact:(AIMetaContact *)metaContact
{
+ AILogWithSignature(@"%@: Remove %@", metaContact, inContact);
+
//we only allow group->meta->contact, not group->meta->meta->contact
NSParameterAssert(![inContact conformsToProtocol:@protocol(AIContainingObject)]);
@@ -728,13 +783,19 @@
[newContainedContactsArray release];
[newAllMetaContactsDict release];
}
-
- //The listObject can be within the metaContact without us finding a containedContactDict if we are removing multiple
- //listContacts referring to the same UID & serviceID combination - that is, on multiple accounts on the same service.
- //We therefore request removal of the object regardless of the if (containedContactDict) check above.
- [metaContact removeObject:inContact];
-
- [self _didChangeContainer:metaContact object:inContact];
+
+ /* Remove all contacts matching this service/UID from the metacontact */
+ [contactPropertiesObserverManager delayListObjectNotifications];
+
+ for (AIListContact *matchingContact in [self allContactsWithService:inContact.service UID:inContact.UID]) {
+ if ([metaContact removeObject:matchingContact]) {
+ [contactPropertiesObserverManager _updateAllAttributesOfObject:inContact];
+ [self _didChangeContainer:metaContact object:inContact];
+ }
+ }
+
+ [contactPropertiesObserverManager _updateAllAttributesOfObject:metaContact];
+ [contactPropertiesObserverManager endListObjectNotificationsDelay];
}
/*!
@@ -857,8 +918,10 @@
//Create a new metaContact is we didn't find one.
if (!metaContact) {
- AILogWithSignature(@"New metacontact to group %@", contactsToGroupArray);
metaContact = [self metaContactWithObjectID:nil];
+ AILogWithSignature(@"Created new metacontact %@ for grouping %@", metaContact, contactsToGroupArray);
+ } else {
+ AILogWithSignature(@"Existing metacontact %@ will now gain %@", metaContact, contactsToGroupArray);
}
/* Add all these contacts to our MetaContact.
@@ -875,6 +938,8 @@
}
}
+ AILogWithSignature(@"Completed groupContacts; metaContact is %@", metaContact);
+
return metaContact;
}
@@ -1480,19 +1545,18 @@
- (void)moveContact:(AIListContact *)contact fromGroups:(NSSet *)oldGroups intoGroups:(NSSet *)groups
{
- AILogWithSignature(@"Moving %@ (%@) from %@ into %@",
- contact, (contact.existsServerside ? @"Serverside" : @"Not serverside"),
- oldGroups, groups);
-
+ AILogWithSignature(@"moveContact %@ [meta=%p; contained by %@; %@] from %@ into %@",
+ contact,
+ contact.metaContact, contact.containingObjects, (contact.existsServerside ? @"exists serverside" : @"does NOT exist serverside"),
+ oldGroups,groups);
+
[contactPropertiesObserverManager delayListObjectNotifications];
if (contact.metaContact) {
AIMetaContact *meta = contact.metaContact;
//Remove from the contactToMetaContactLookupDict first so we don't try to reinsert into this metaContact
[contactToMetaContactLookupDict removeObjectForKey:contact.internalObjectID];
- for (AIListContact *matchingContact in [self allContactsWithService:contact.service UID:contact.UID]) {
- [self removeContact:matchingContact fromMetaContact:meta];
- }
+ [self removeContact:contact fromMetaContact:meta];
}
if (contact.existsServerside) {
diff -r a534d21369d5 -r a9575b3b3163 Source/AIInfoInspectorPane.m
--- a/Source/AIInfoInspectorPane.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIInfoInspectorPane.m Sun Sep 19 16:01:38 2010 -0500
@@ -520,10 +520,19 @@
if ([inObject isKindOfClass:[AIListContact class]]) {
- currentAlias = [[(AIListContact *)inObject parentContact] preferenceForKey:@"Alias"
- group:PREF_GROUP_ALIASES];
- AILogWithSignature(@"inObject is %@; parentContact is %@. Preference is %@.",
- inObject, [(AIListContact *)inObject parentContact], currentAlias);
+ AIListContact *parentContact = [(AIListContact *)inObject parentContact];
+
+ currentAlias = [parentContact preferenceForKey:@"Alias"
+ group:PREF_GROUP_ALIASES];
+
+ if (inObject == parentContact) {
+ AILogWithSignature(@"%@: current alias %@.",
+ inObject, currentAlias);
+
+ } else {
+ AILogWithSignature(@"updating alias for %@; parent %@ --> current alias %@.",
+ inObject, [(AIListContact *)inObject parentContact], currentAlias);
+ }
} else {
currentAlias = [inObject preferenceForKey:@"Alias"
group:PREF_GROUP_ALIASES];
diff -r a534d21369d5 -r a9575b3b3163 Source/AIListController.m
--- a/Source/AIListController.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIListController.m Sun Sep 19 16:01:38 2010 -0500
@@ -699,9 +699,12 @@
[[AIContactObserverManager sharedManager] delayListObjectNotifications];
+ AILogWithSignature(@"Dropping into %@ (%@)", item, item.listObject);
+
//Move the list object to its new location
if ([item.listObject isKindOfClass:[AIListGroup class]]) {
/* Can't drop into the offline group */
+
if (item.listObject != adium.contactController.offlineGroup) {
AIListGroup *group = (AIListGroup *)(item.listObject);
@@ -733,6 +736,8 @@
// Contact being moved to a new group.
// Holding option copies into the new group (like in Finder)
+
+ AILogWithSignature(@"Moving %@ from %@ to %@", listObject, sourceGroups, group);
[adium.contactController moveContact:(AIListContact *)listObject
fromGroups:sourceGroups
intoGroups:[NSSet setWithObject:group]];
diff -r a534d21369d5 -r a9575b3b3163 Source/AIListWindowController.m
--- a/Source/AIListWindowController.m Sun Sep 19 20:41:15 2010 +0200
+++ b/Source/AIListWindowController.m Sun Sep 19 16:01:38 2010 -0500
@@ -291,7 +291,6 @@
- (void)setWindowLevel:(NSInteger)level
{
- AILogWithSignature(@"Setting to %i", level);
[[self window] setLevel:level];
}
More information about the commits
mailing list