Adium

Changeset 22571

Show
Ignore:
Timestamp:
02/08/2008 02:10:10 PM (10 months ago)
Author:
evands
Message:

Merged [22570]: Fixes and optimizations for AIContactMenu which fix a number of problems seen primarily in the account/contact selection view in chat windows; fixed initial contact selection there, as well. Fixes #9013. I am fairly sure this fixes #8638. Probably fixes some other odd, intermittent issues with multiple-possible-source-account-or-destination-contact messaging, too, as the UI wasn't matching reality in all cases -and- could randomly change.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/adium-1.2/Frameworks/Adium Framework/Source/AIContactMenu.h

    r22292 r22571  
    1717        BOOL                                    delegateRespondsToDidSelectContact; 
    1818        BOOL                                    delegateRespondsToShouldIncludeContact;  
     19        BOOL                                    delegateRespondsToValidateContact; 
    1920        BOOL                                    shouldUseDisplayName; 
    2021        BOOL                                    shouldDisplayGroupHeaders; 
     
    3334- (void)contactMenu:(AIContactMenu *)inContactMenu didRebuildMenuItems:(NSArray *)menuItems; 
    3435- (void)contactMenu:(AIContactMenu *)inContactMenu didSelectContact:(AIListContact *)inContact; //Optional 
     36- (AIListContact *)contactMenu:(AIContactMenu *)inContactMenu validateContact:(AIListContact *)inContact; //Optional 
    3537- (BOOL)contactMenu:(AIContactMenu *)inContactMenu shouldIncludeContact:(AIListContact *)inContact; //Optional 
    3638- (BOOL)contactMenuShouldUseUserIcon:(AIContactMenu *)inContactMenu; //Optional 
  • branches/adium-1.2/Frameworks/Adium Framework/Source/AIContactMenu.m

    r22292 r22571  
    1818- (id)initWithDelegate:(id)inDelegate forContactsInObject:(AIListObject *)inContainingObject; 
    1919- (NSArray *)contactMenusForListObjects:(NSArray *)listObjects; 
    20 - (NSArray *)listObjectsForContainedObjects:(NSArray *)listObjects; 
     20- (NSArray *)listObjectsForMenuFromArrayOfListObjects:(NSArray *)listObjects; 
    2121- (void)_updateMenuItem:(NSMenuItem *)menuItem; 
    2222@end 
     
    5050                // Register for contact list order notifications (so we can update our sorting) 
    5151                [[adium notificationCenter] addObserver:self 
    52                                                                    selector:@selector(rebuildMenu
    53                                                                            name:Contact_OrderChanged 
    54                                                                         object:nil]; 
     52                                                                          selector:@selector(contactOrderChanged:
     53                                                                                  name:Contact_OrderChanged 
     54                                                                                object:nil]; 
    5555 
    5656                [self rebuildMenu]; 
     
    8282} 
    8383 
     84- (void)contactOrderChanged:(NSNotification *)notification 
     85{ 
     86        AIListObject *changedObject = [notification object]; 
     87        if (changedObject == containingObject) { 
     88                [self rebuildMenu]; 
     89        } 
     90} 
    8491 
    8592//Delegate ------------------------------------------------------------------------------------------------------------- 
     
    96103        delegateRespondsToDidSelectContact = [delegate respondsToSelector:@selector(contactMenu:didSelectContact:)]; 
    97104        delegateRespondsToShouldIncludeContact = [delegate respondsToSelector:@selector(contactMenu:shouldIncludeContact:)]; 
    98          
     105        delegateRespondsToValidateContact = [delegate respondsToSelector:@selector(contactMenu:validateContact:)]; 
     106 
    99107        shouldUseUserIcon = ([delegate respondsToSelector:@selector(contactMenuShouldUseUserIcon:)] && 
    100108                                                                 [delegate contactMenuShouldUseUserIcon:self]); 
     
    160168                 */ 
    161169                if (!shouldDisplayGroupHeaders) { 
    162                         listObjects = [self listObjectsForContainedObjects:listObjects]; 
     170                        listObjects = [self listObjectsForMenuFromArrayOfListObjects:listObjects]; 
    163171                } 
    164172 
     
    167175        } else { 
    168176                // We can assume these are already sorted 
    169                 listObjects = ([containingObject conformsToProtocol:@protocol(AIContainingObject)] ? 
    170                                           [(AIListObject<AIContainingObject> *)containingObject listContacts] : 
    171                                            [NSArray arrayWithObject:containingObject])
     177                listObjects = [self listObjectsForMenuFromArrayOfListObjects:([containingObject conformsToProtocol:@protocol(AIContainingObject)] ? 
     178                                                                                                                                         [(AIListObject<AIContainingObject> *)containingObject listContacts] : 
     179                                                                                                                                         [NSArray arrayWithObject:containingObject])]
    172180        } 
    173181         
     
    179187* @brief Creates an array of list objects which should be presented in the menu, expanding any containing objects 
    180188 */ 
    181 - (NSArray *)listObjectsForContainedObjects:(NSArray *)listObjects 
     189- (NSArray *)listObjectsForMenuFromArrayOfListObjects:(NSArray *)listObjects 
    182190{ 
    183191        NSMutableArray  *listObjectArray = [NSMutableArray array]; 
     
    187195        while ((listObject = [enumerator nextObject])) { 
    188196                if ([listObject isKindOfClass:[AIListContact class]]) { 
    189                         // Include if the delegate doesn't specify, or if the delegate approves the contact. 
     197                        /* Include if the delegate doesn't specify, or if the delegate approves the contact. 
     198                         * Note that this includes a metacontact itself, not its contained objects. 
     199                         */ 
    190200                        if (!delegateRespondsToShouldIncludeContact || [delegate contactMenu:self shouldIncludeContact:(AIListContact *)listObject]) { 
     201                                if (delegateRespondsToValidateContact) 
     202                                        listObject = [delegate contactMenu:self validateContact:(AIListContact *)listObject]; 
     203         
    191204                                [listObjectArray addObject:listObject]; 
    192205                        } 
    193                 // Only recurse through groups; meta contacts can stay as meta contacts. 
    194                 } else if ([listObject isKindOfClass:[AIListGroup class]] && [listObject conformsToProtocol:@protocol(AIContainingObject)]) { 
    195                         [listObjectArray addObjectsFromArray:[self listObjectsForContainedObjects:[(AIListObject<AIContainingObject> *)listObject listContacts]]]; 
     206 
     207                } else if ([listObject isKindOfClass:[AIListGroup class]]) { 
     208                        [listObjectArray addObjectsFromArray:[self listObjectsForMenuFromArrayOfListObjects:[(AIListGroup *)listObject listContacts]]]; 
    196209                } 
    197210        } 
     
    211224        while ((listObject = [enumerator nextObject])) { 
    212225                // Display groups inline 
    213                 if ([listObject isKindOfClass:[AIListGroup class]] && [listObject conformsToProtocol:@protocol(AIContainingObject)]) { 
    214                         NSArray                 *containedListObjects = [self listObjectsForContainedObjects:[(AIListObject<AIContainingObject> *)listObject listContacts]]; 
     226                if ([listObject isKindOfClass:[AIListGroup class]]) { 
     227                        NSArray                 *containedListObjects = [self listObjectsForMenuFromArrayOfListObjects:[(AIListObject<AIContainingObject> *)listObject listContacts]]; 
    215228                         
    216229                        // If there's any contained list objects, add ourself as a group and add the contained objects. 
     
    277290{ 
    278291        if ([inObject isKindOfClass:[AIListContact class]]) { 
     292                //Note that this will return nil if we don't ahve a menu item for inObject 
    279293                NSMenuItem      *menuItem = [self menuItemForContact:(AIListContact *)inObject]; 
    280294                 
     
    285299                   [inModifiedKeys containsObject:@"IdleSince"] || 
    286300                   [inModifiedKeys containsObject:@"StatusType"]) { 
    287                          
     301 
    288302                        //Update the changed menu item (or rebuild the entire menu if this item should be removed or added) 
    289303                        if (delegateRespondsToShouldIncludeContact) { 
  • branches/adium-1.2/Plugins/Dual Window Interface/AIAccountSelectionView.m

    r21803 r22571  
    3737@interface AIAccountSelectionView (PRIVATE) 
    3838- (id)_init; 
    39 - (void)chatMetaContactChanged
     39- (void)configureForCurrentChat
    4040- (void)chatDestinationChanged:(NSNotification *)notification; 
    4141- (void)chatSourceChanged:(NSNotification *)notification; 
     
    157157                         
    158158                        //Update source and destination menus 
    159                         [self chatMetaContactChanged]; 
     159                        [self configureForCurrentChat]; 
    160160                }                        
    161161        } 
     
    163163 
    164164/*! 
    165  * @brief Update our menus when the meta contact or the meta contact's content changes 
    166  */ 
    167 - (void)chatMetaContactChanged 
    168 
     165 * @brief Build and configure all menus for the current chat 
     166 */ 
     167- (void)configureForCurrentChat 
     168
     169        AILogWithSignature(@""); 
     170 
    169171        //Rebuild 'To' contact menu 
    170         if([self choicesAvailableForContact])
     172        if ([self choicesAvailableForContact])
    171173                [self _createContactMenu]; 
    172         }else
     174        } else
    173175                [self _destroyContactMenu]; 
    174176        } 
     
    183185- (void)chatDestinationChanged:(NSNotification *)notification 
    184186{ 
     187        AILogWithSignature(@"popUp_contacts selecting %@ (%@)", [chat listObject], [notification object]); 
     188 
    185189        //Update selection in contact menu 
    186190        [popUp_contacts selectItemWithRepresentedObjectUsingCompare:[chat listObject]]; 
     
    343347 */ 
    344348- (void)contactMenu:(AIContactMenu *)inContactMenu didRebuildMenuItems:(NSArray *)menuItems { 
     349        AILogWithSignature(@""); 
    345350        [popUp_contacts setMenu:[inContactMenu menu]]; 
     351        [self chatDestinationChanged:nil]; 
    346352} 
    347353- (void)contactMenu:(AIContactMenu *)inContactMenu didSelectContact:(AIListContact *)inContact { 
    348354        [[adium chatController] switchChat:chat toListContact:inContact usingContactAccount:YES]; 
    349355} 
    350  
     356- (AIListContact *)contactMenu:(AIContactMenu *)inContactMenu validateContact:(AIListContact *)inContact { 
     357        AIListContact *preferredContact = [[adium contactController] preferredContactForContentType:CONTENT_MESSAGE_TYPE 
     358                                                                                                                                                                 forListContact:inContact]; 
     359        return preferredContact; 
     360
    351361/*! 
    352362 * @brief Create the contact menu and add it to our view