Adium

Changeset 25625

Show
Ignore:
Timestamp:
11/24/2008 10:22:05 PM (2 months ago)
Author:
catfish_man
Message:

More changes in preparation for multiple group support. containingObject is now not recommended. Use the groups and metaContact/parentContact properties instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/Source/AIContactHidingController.m

    r25457 r25625  
    139139         
    140140        //we can cast to AIListContact here since groups and metas were handled up above 
    141         if (!online && (!showOfflineContacts || !(((AIListContact *)listObject).parentContact.containingObject && ((AIListContact *)listObject).parentContact.containingObject == adium.contactController.offlineGroup))) 
    142                 return NO; 
     141        AIListContact *contact = (AIListContact *)listObject; 
     142         
     143        if (!online) { 
     144                if (showOfflineContacts) { 
     145                        if (useOfflineGroup && ![contact.parentContact.groups containsObject:adium.contactController.offlineGroup]) 
     146                                return NO; 
     147                } else 
     148                        return NO; 
     149        } 
    143150         
    144151        if (!showIdleContacts && [listObject valueForProperty:@"IdleSince"]) 
  • trunk/Frameworks/Adium Framework/Source/AIContactObserverManager.m

    r25620 r25625  
    281281                if (attributes) [self listObjectAttributesChanged:listObject modifiedKeys:attributes]; 
    282282                 
    283                 //If this contact is within a meta contact, update the meta contact too 
    284                 AIListObject<AIContainingObject>        *containingObject = listObject.containingObject; 
    285                 if (containingObject && [containingObject isKindOfClass:[AIMetaContact class]]) { 
    286                         NSSet   *attributes = [inObserver updateListObject:containingObject 
    287                                                                                                                 keys:nil 
    288                                                                                                           silent:YES]; 
    289                         if (attributes) [self listObjectAttributesChanged:containingObject 
    290                                                                                                  modifiedKeys:attributes]; 
    291                 } 
     283                if ([listObject isKindOfClass:[AIListContact class]]) { 
     284                        AIListContact *contact = listObject; 
     285                         
     286                        //If this contact is within a meta contact, update the meta contact too 
     287                        if (contact.metaContact) { 
     288                                NSSet   *attributes = [inObserver updateListObject:contact.metaContact 
     289                                                                                                                        keys:nil 
     290                                                                                                                  silent:YES]; 
     291                                if (attributes) [self listObjectAttributesChanged:contact.metaContact 
     292                                                                                                         modifiedKeys:attributes]; 
     293                        } 
     294                } 
     295                 
    292296                [pool release]; 
    293297        } 
  • trunk/Frameworks/Adium Framework/Source/AIListContact.h

    r25587 r25625  
    2020#define KEY_AB_UNIQUE_ID                @"AB Unique ID" 
    2121 
    22 @class ABPerson, AIListGroup
     22@class ABPerson, AIListGroup, AIMetaContact
    2323 
    2424@interface AIListContact : AIListObject { 
    2525        AIAccount       *account; 
     26        AIMetaContact *metaContact; 
    2627        NSString                *remoteGroupName; 
    2728        NSString                *internalUniqueObjectID; 
     
    3738- (void)restoreGrouping; 
    3839 
    39 @property (readonly, nonatomic) AIListGroup *parentGroup; 
    40 @property (readonly, nonatomic) AIListContact *parentContact; 
     40@property (readonly, nonatomic) AIListContact *parentContact; //This needs renaming. It's the 'topmost' contact, either self or meta 
     41@property (readonly, nonatomic) AIMetaContact *metaContact; 
    4142 
    4243@property (readonly, nonatomic) NSString *ownDisplayName; 
  • trunk/Frameworks/Adium Framework/Source/AIListContact.m

    r25622 r25625  
    127127                [adium.contactController contactRemoteGroupingChanged:self]; 
    128128                 
    129                 if (self.parentContact != self) { 
    130                         [(AIMetaContact *)self.parentContact remoteGroupingOfContainedObject:self changedTo:remoteGroupName]; 
     129                if (self.metaContact) { 
     130                        [self.metaContact remoteGroupingOfContainedObject:self changedTo:remoteGroupName]; 
    131131                } 
    132132        } 
     
    158158- (NSString *)displayName 
    159159{ 
    160         AIListContact  *parentContact = self.parentContact; 
    161  
    162         NSString *displayName = parentContact == self ? super.displayName : parentContact.displayName; 
     160        AIMetaContact  *meta = self.metaContact; 
     161 
     162        NSString *displayName = meta ? meta.displayName : super.displayName; 
    163163 
    164164        //If a display name was found, return it; otherwise, return the formattedUID   
     
    249249- (NSString *)phoneticName 
    250250{ 
    251         AIListContact  *parentContact = self.parentContact; 
     251        AIMetaContact *meta = self.metaContact; 
    252252        NSString                *phoneticName; 
    253253 
    254         phoneticName = ((parentContact == self) ? 
    255                                    super.phoneticName : 
    256                                    parentContact.phoneticName); 
     254        phoneticName = meta ? meta.phoneticName : super.phoneticName;; 
    257255         
    258256        //If a display name was found, return it; otherwise, return the formattedUID 
    259     return phoneticName ? phoneticName : self.displayName; 
     257       return phoneticName ? phoneticName : self.displayName; 
    260258} 
    261259 
     
    570568 
    571569#pragma mark Parents 
    572 /*! 
    573  * @brief This object's parent AIListGroup 
    574  * 
    575  * @result An AIListGroup which contains this object or the object containing this object, or nil if it is not in an AIListGroup. 
    576  */ 
    577 - (AIListGroup *)parentGroup 
    578 { 
    579         AIListObject<AIContainingObject>        *parentGroup = self.parentContact.containingObject; 
    580  
    581         if (parentGroup && [parentGroup isKindOfClass:[AIListGroup class]]) { 
    582                 return (AIListGroup *)parentGroup; 
    583         } else { 
    584                 return nil; 
    585         } 
    586 } 
    587570 
    588571/*! 
     
    594577 * @result Either this contact or some more-encompassing contact which ultimately contains it. 
    595578 */ 
    596  - (AIListContact *)parentContact 
    597  { 
    598         AIListContact   *parentContact = self; 
    599  
    600         while ([parentContact.containingObject isKindOfClass:[AIListContact class]]) { 
    601                 parentContact = (AIListContact *)parentContact.containingObject; 
    602         } 
    603  
    604         return parentContact; 
    605  } 
     579- (AIListContact *)parentContact 
     580
     581        if (self.metaContact) 
     582                return self.metaContact; 
     583         
     584        return self; 
     585
    606586 
    607587- (BOOL)containsObject:(AIListObject*)object 
     
    610590} 
    611591 
     592- (NSSet *)groups { 
     593        //if we're not in a meta, we should be in at least one group 
     594        if (!self.metaContact) 
     595                return containingObjects; 
     596        return [NSSet set]; 
     597} 
     598 
     599- (void)setContainingObject:(AIListObject <AIContainingObject> *)inGroup 
     600{ 
     601        if (!inGroup || [inGroup isKindOfClass:[AIMetaContact class]]) 
     602                metaContact = (AIMetaContact *)inGroup; 
     603        [super setContainingObject:inGroup]; 
     604} 
     605 
    612606/*! 
    613607 * @brief Can this object be part of a metacontact? 
     
    616610{ 
    617611        return YES; 
     612} 
     613 
     614- (AIMetaContact *)metaContact 
     615{ 
     616        if (metaContact) 
     617                return metaContact; 
     618        return nil; 
    618619} 
    619620 
  • trunk/Frameworks/Adium Framework/Source/AIListGroup.m

    r25620 r25625  
    200200        if ([self containsObject:inObject]) {            
    201201                //Remove the object 
    202                 if (inObject.containingObject == self
    203                         [inObject setContainingObject:nil]
     202                if ([inObject.groups containsObject:self]
     203                        inObject.containingObject = nil
    204204                [_containedObjects removeObject:inObject]; 
    205205 
  • trunk/Frameworks/Adium Framework/Source/AIListObject.h

    r25621 r25625  
    116116//Grouping 
    117117@property (readonly, nonatomic) AIListObject <AIContainingObject> *containingObject; 
     118@property (readonly, nonatomic) NSSet *groups; 
    118119 
    119120//Display 
  • trunk/Frameworks/Adium Framework/Source/AIListObject.m

    r25624 r25625  
    202202//Grouping / Ownership ------------------------------------------------------------------------------------------------- 
    203203#pragma mark Grouping / Ownership 
     204 
     205- (NSSet *)groups 
     206{ 
     207        return [NSSet set]; 
     208} 
     209 
    204210/*! 
    205211 * @brief Containing object of this object 
     
    220226        NSParameterAssert(!inGroup || [inGroup canContainObject:self]); 
    221227        if (![containingObjects containsObject:inGroup]) { 
     228                 
    222229                //XXX multiple containers 
    223                 if(!inGroup) { 
     230                if (!inGroup) 
    224231                        [containingObjects removeAllObjects]; 
    225                 } else { 
     232                else { 
    226233                        AIListObject<AIContainingObject> *container = self.containingObject; 
    227234                        if(container) 
  • trunk/Frameworks/Adium Framework/Source/AIMetaContact.m

    r25587 r25625  
    138138 
    139139        [super setContainingObject:inGroup]; 
     140} 
     141 
     142- (AIListContact *)parentContact 
     143{ 
     144        return self; 
     145} 
     146 
     147- (AIMetaContact *)metaContact 
     148{ 
     149        return self; 
    140150} 
    141151 
     
    309319- (void)removeObject:(AIListObject *)inObject 
    310320{ 
     321        AIListContact *contact = (AIListContact *)inObject; 
    311322        if ([self.containedObjects containsObjectIdenticalTo:inObject]) { 
    312323                BOOL    noteRemoteGroupingChanged = NO; 
     
    318329                [_containedObjects removeObject:inObject]; 
    319330                 
    320                 if ([(AIListContact *)inObject remoteGroupName]) { 
     331                if (contact.remoteGroupName) { 
    321332                        //Reset it to its remote group 
    322                         if (inObject.containingObject == self
    323                                 [inObject setContainingObject:nil]
     333                        if (contact.metaContact
     334                                contact.containingObject = nil
    324335                        noteRemoteGroupingChanged = YES; 
    325336                } else { 
    326                         [inObject setContainingObject:self.containingObject]
     337                        contact.containingObject = self.containingObject
    327338                } 
    328339 
     
    340351 
    341352                //If we remove our list object, don't continue to show up in the contact list 
    342               if ([self.containedObjects count] == 0) { 
     353        /*    if ([self.containedObjects count] == 0) { 
    343354                        [self setContainingObject:nil]; 
    344                 } 
     355                }*/ 
    345356 
    346357                /* Now that we're done reconfigured ourselves and the recently removed object, 
  • trunk/Frameworks/Adium Framework/Source/AIUserIcons.m

    r25620 r25625  
    1717#import <Adium/AIListContact.h> 
    1818#import <Adium/AIListObject.h> 
     19#import <Adium/AIMetaContact.h> 
    1920#import <Adium/AIUserIcons.h> 
    2021#import <Adium/AIAdiumProtocol.h> 
     
    130131+ (void)notifyOfChangedIconForObject:(AIListObject *)inObject 
    131132{ 
    132         AIListObject    *containingObject = inObject.containingObject; 
    133133        NSSet                   *modifiedKeys = [NSSet setWithObject:KEY_USER_ICON]; 
    134134         
     
    137137                                                                                          modifiedKeys:modifiedKeys];            
    138138         
    139         if ([containingObject isKindOfClass:[AIListContact class]]) {          
     139        if ([inObject isKindOfClass:[AIListContact class]] && ((AIListContact *)inObject).metaContact) {               
    140140                //Notify 
    141                 [[AIContactObserverManager sharedManager] listObjectAttributesChanged:containingObject 
     141                [[AIContactObserverManager sharedManager] listObjectAttributesChanged:((AIListContact *)inObject).metaContact 
    142142                                                                                                  modifiedKeys:modifiedKeys]; 
    143143        }        
  • trunk/Plugins/Dual Window Interface/AIAccountSelectionView.m

    r25443 r25625  
    385385 * @brief Returns YES if a choice of destination contact is available 
    386386 */ 
    387 - (BOOL)choicesAvailableForContact{ 
    388         AIListContact *parentContact = chat.listObject.parentContact; 
    389         if ([parentContact conformsToProtocol:@protocol(AIContainingObject)]) { 
    390                 return [[(AIListContact <AIContainingObject> *)parentContact uniqueContainedObjects] count] > 1; 
    391         } else { 
    392                 return NO; 
    393         } 
     387- (BOOL)choicesAvailableForContact { 
     388        if (chat.listObject.metaContact) 
     389                return chat.listObject.metaContact.uniqueContainedObjects.count > 1; 
     390         
     391        return NO; 
    394392} 
    395393 
  • trunk/Plugins/Dual Window Interface/AIMessageViewController.m

    r25586 r25625  
    3939#import <Adium/AIContentMessage.h> 
    4040#import <Adium/AIListContact.h> 
     41#import <Adium/AIMetaContact.h> 
    4142#import <Adium/AIListObject.h> 
    4243#import <Adium/AIListOutlineView.h> 
     
    595596- (IBAction)sendMessageLater:(id)sender 
    596597{ 
    597         AIListContact   *listContact; 
    598  
    599598        //If the chat can _now_ send a message, send it immediately instead of waiting for "later". 
    600599        if ([chat messageSendingAbility] == AIChatCanSendMessageNow) { 
     
    604603 
    605604        //Put the alert on the metaContact containing this listContact if applicable 
    606         listContact = chat.listObject.parentContact; 
     605        AIMetaContact *listContact = chat.listObject.metaContact; 
    607606 
    608607        if (listContact) { 
  • trunk/Source/AIChatController.m

    r25621 r25625  
    304304                 
    305305                //If this object is within a meta contact, and a chat for an object in that meta contact already exists 
    306                 if (targetContact.parentContact != targetContact && chat.listObject.parentContact == targetContact.parentContact) { 
     306                if (targetContact.metaContact && chat.listObject.metaContact == targetContact.metaContact) { 
    307307 
    308308                        //Switch the chat to be on this contact (and its account) now 
  • trunk/Source/AIContactController.m

    r25559 r25625  
    279279        [[inContact retain] autorelease]; 
    280280         
    281         AIListObject<AIContainingObject>        *containingObject = inContact.containingObject; 
    282          
    283         if ([containingObject isKindOfClass:[AIMetaContact class]]) { 
     281        if (inContact.metaContact) { 
    284282                 
    285283                /* If inContact's containingObject is a metaContact, and that metaContact has no containingObject, 
    286284                 * use inContact's remote grouping as the metaContact's grouping. 
    287285                 */ 
    288                 if (!containingObject.containingObject && [remoteGroupName length]) { 
     286                if (!inContact.metaContact.containingObject && [remoteGroupName length]) { 
    289287                        //If no similar objects exist, we add this contact directly to the list 
    290288                        //Create a group for the contact even if contact list groups aren't on, 
     
    296294                                                  contactList); 
    297295                         
    298                         [localGroup addObject:containingObject]; 
    299                          
    300                         [self _didChangeContainer:localGroup object:containingObject]; 
     296                        [localGroup addObject:inContact.metaContact]; 
     297                         
     298                        [self _didChangeContainer:localGroup object:inContact.metaContact]; 
    301299                        [adium.notificationCenter postNotificationName:@"Contact_ListChanged" 
    302300                                                                                                                                object:localGroup.containingObject 
     
    319317                                                  toGroup:localGroup]; 
    320318                 
    321         } else if (containingObject) { 
     319        } else if (inContact.groups.count > 0) { 
    322320                //If !remoteGroupName, remove the contact from any local groups 
    323                 [(AIListGroup *)containingObject removeObject:inContact]; 
    324                  
    325                 [self _didChangeContainer:(AIListGroup *)containingObject object:inContact]; 
     321                for (AIListGroup *group in inContact.groups) { 
     322                        [group removeObject:inContact]; 
     323                        [self _didChangeContainer:group object:inContact]; 
     324                } 
    326325                 
    327326                //NSLog(@"contactRemoteGroupingChanged: %@: -- !remoteGroupName so removed from %@",inContact,containingObject); 
     
    339338- (void)_moveContactLocally:(AIListContact *)listContact toGroup:(AIListGroup *)localGroup 
    340339{ 
    341         AIListObject    *containingObject; 
    342340        AIListObject    *existingObject; 
    343341        BOOL                    performedGrouping = NO; 
     
    350348         
    351349        //Remove this object from any local groups we have it in currently 
    352         if ((containingObject = listContact.containingObject) && 
    353                 ([containingObject isKindOfClass:[AIListGroup class]])) { 
    354                 //Remove the object 
    355                 [(AIListGroup *)containingObject removeObject:listContact]; 
    356                 [self _didChangeContainer:(AIListGroup *)containingObject object:listContact]; 
    357         } 
    358          
    359         if ([listContact canJoinMetaContacts]) { 
     350        for (AIListGroup *group in listContact.groups) { 
     351                [group removeObject:listContact]; 
     352                [self _didChangeContainer:group object:listContact]; 
     353        } 
     354         
     355        if (listContact.canJoinMetaContacts) { 
    360356                if ((existingObject = [localGroup objectWithService:[listContact service] UID:[listContact UID]])) { 
    361357                        //If an object exists in this group with the same UID and serviceID, create a MetaContact 
     
    398394        if ([inContact isKindOfClass:[AIMetaContact class]]) { 
    399395                //For a metaContact, the closest we have to a remote group is the group it is within locally 
    400                 group = [(AIMetaContact *)inContact parentGroup]; 
     396                //XXX multiple containers 
     397                group = [[inContact groups] anyObject]; 
    401398                 
    402399        } else {