Adium

Changeset 24099

Show
Ignore:
Timestamp:
06/29/2008 05:04:01 PM (5 months ago)
Author:
evands
Message:

Refs #8742

  • Added -[AIContactController knownMetaContactForGroupingUIDs:forServices:], which allows prediction of what metacontact, if any, will be used by -[AIContactController groupUIDs:forServices:].
  • Replaced -[AIContactController groupUIDs:forServices:] with -[AIContactController groupUIDs:forServices:usingMetaContactHint:]. The new metaContactHint argument allows the caller to suggest a metacontact to be used if a new one would otherwise be created.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/Source/AIContactControllerProtocol.h

    r23607 r24099  
    8888- (AIListBookmark *)bookmarkForChat:(AIChat *)inChat; 
    8989 
    90 - (AIMetaContact *)groupUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray; 
     90- (AIMetaContact *)knownMetaContactForGroupingUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray; 
     91- (AIMetaContact *)groupUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray usingMetaContactHint:(AIMetaContact *)metaContactHint; 
     92- (AIMetaContact *)metaContactWithObjectID:(NSNumber *)inObjectID; 
     93 
    9194- (AIMetaContact *)groupListContacts:(NSArray *)contactsToGroupArray; 
    9295- (void)removeAllListObjectsMatching:(AIListObject *)listObject fromMetaContact:(AIMetaContact *)metaContact; 
  • trunk/Source/AIContactController.m

    r24074 r24099  
    101101 
    102102//MetaContacts 
    103 - (AIMetaContact *)metaContactWithObjectID:(NSNumber *)inObjectID; 
    104103- (BOOL)_restoreContactsToMetaContact:(AIMetaContact *)metaContact; 
    105104- (void)_restoreContactsToMetaContact:(AIMetaContact *)metaContact fromContainedContactsArray:(NSArray *)containedContactsArray; 
     
    680679                 * existed before this call to metaContactWithObjectID: 
    681680                 */ 
    682                 if (shouldRestoreContacts) { 
    683                         if (![self _restoreContactsToMetaContact:metaContact]) { 
    684                                 //If restoring the metacontact did not actually add any contacts, delete it since it is invalid 
    685                                 [self breakdownAndRemoveMetaContact:metaContact]; 
    686                                 metaContact = nil; 
    687                         } 
    688                 } 
     681                if (shouldRestoreContacts) 
     682                        [self _restoreContactsToMetaContact:metaContact]; 
    689683                 
    690684                /* As with contactWithService:account:UID, update all attributes so observers are initially informed of 
     
    696690        } 
    697691         
    698         return (metaContact)
     692        return metaContact
    699693} 
    700694 
     
    951945} 
    952946 
     947/*! 
     948 * @brief Determine the existing metacontact into which a grouping of UIDs and services would be placed 
     949 * 
     950 * @param UIDsArray NSArray of UIDs 
     951 * @param servicesArray NSArray of serviceIDs corresponding to entries in UIDsArray 
     952 *  
     953 * @result Either the existing AIMetaContact -[self groupUIDs:forServices:usingMetaContactHint:] would return if passed a nil metaContactHint, 
     954 *         or nil (if no existing metacontact would be used). 
     955 */ 
     956- (AIMetaContact *)knownMetaContactForGroupingUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray 
     957{ 
     958        AIMetaContact   *metaContact = nil; 
     959        int                             count = [UIDsArray count]; 
     960        int                             i; 
     961         
     962        //Build an array of all contacts matching this description (multiple accounts on the same service listing 
     963        //the same UID mean that we can have multiple AIListContact objects with a UID/service combination) 
     964        for (i = 0; i < count; i++) { 
     965                if ((metaContact = [contactToMetaContactLookupDict objectForKey:[AIListObject internalObjectIDForServiceID:[servicesArray objectAtIndex:i] 
     966                                                                                                                                                                                                                           UID:[UIDsArray objectAtIndex:i]]])) { 
     967                        break; 
     968                } 
     969        } 
     970         
     971        return metaContact; 
     972} 
    953973 
    954974/*! 
     
    963983 * @param UIDsArray NSArray of UIDs 
    964984 * @param servicesArray NSArray of serviceIDs corresponding to entries in UIDsArray 
     985 * @param metaContactHint If passed, an AIMetaContact to use for the grouping if an existing one isn't found. If nil, a new metacontact will be craeted in that case. 
    965986 */ 
    966 - (AIMetaContact *)groupUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray 
     987- (AIMetaContact *)groupUIDs:(NSArray *)UIDsArray forServices:(NSArray *)servicesArray usingMetaContactHint:(AIMetaContact *)metaContactHint 
    967988{ 
    968989        NSMutableSet    *internalObjectIDs = [[NSMutableSet alloc] init]; 
     
    9891010         
    9901011        if ([internalObjectIDs count] > 1) { 
    991                 //Create a new metaContact is we didn't find one. 
    992                 if (!metaContact) { 
     1012                //Create a new metaContact is we didn't find one and weren't supplied a hint 
     1013                if (!metaContact && !(metaContact = metaContactHint)) { 
    9931014                        AILogWithSignature(@"New metacontact to group %@ on %@", UIDsArray, servicesArray); 
    9941015                        metaContact = [self metaContactWithObjectID:nil];