Adium

Changeset 23973

Show
Ignore:
Timestamp:
06/14/2008 01:41:12 PM (6 months ago)
Author:
zacw
Message:

Save and restore the active chats in containers. Fixes #10045.

Files:

Legend:

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

    r23883 r23973  
    473473 *      Key                     Value 
    474474 *      @"ID"           NSString of the containerID 
    475  *  @"Frame"  NSString of the window's [NSWindow frame] 
     475 *     @"Frame"       NSString of the window's [NSWindow frame] 
    476476 *      @"Content"      NSArray of the AIChat objects within that container 
     477 *      @"ActiveChat"   AIChat that is currently active 
    477478 *      @"Name"         NSString of the container's name 
    478479 */ 
  • trunk/Plugins/Dual Window Interface/AIDualWindowInterfacePlugin.m

    r23556 r23973  
    170170 *  
    171171 * The returned array has zero or more NSDictionary objects with the following information for each container 
    172  *      Key                     Value 
    173  *      @"ID"           NSString of the containerID 
    174  *  @"Frame"    NSString of the window's [NSWindow frame] 
    175  *      @"Content"      NSArray of the AIChat objects within that container 
    176  *      @"Name"         NSString of the container's name 
     172 *      Key                             Value 
     173 *      @"ID"                   NSString of the containerID 
     174 *      @"Frame"                NSString of the window's [NSWindow frame] 
     175 *      @"Content"              NSArray of the AIChat objects within that container 
     176 *      @"ActiveChat"   AIChat that is currently active 
     177 *      @"Name"                 NSString of the container's name 
    177178 */ 
    178179- (NSArray *)openContainersAndChats 
     
    187188                                                                                   NSStringFromRect([[container window] frame]), @"Frame", 
    188189                                                                                   [container containedChats], @"Content", 
     190                                                                                   [container activeChat], @"ActiveChat", 
    189191                                                                                   [container name], @"Name", 
    190192                                                                                   nil]]; 
  • trunk/Source/AIInterfaceController.m

    r23883 r23973  
    408408        if (!savedData) 
    409409                return; 
    410  
     410         
    411411        NSEnumerator            *enumerator = [[NSKeyedUnarchiver unarchiveObjectWithData:savedData] objectEnumerator]; 
    412412        NSDictionary            *dict; 
     
    421421                NSEnumerator                    *chatEnumerator = [[dict objectForKey:@"Content"] objectEnumerator]; 
    422422                NSDictionary                    *chatDict; 
     423                AIChat                                  *containerActiveChat = nil; 
    423424                 
    424425                while ((chatDict = [chatEnumerator nextObject])) { 
     
    426427                        AIService               *service = [[adium accountController] firstServiceWithServiceID:[chatDict objectForKey:@"serviceID"]]; 
    427428                        AIAccount               *account = [[adium accountController] accountWithInternalObjectID:[chatDict objectForKey:@"AccountID"]]; 
    428                                  
     429                                        
    429430                        if ([[chatDict objectForKey:@"IsGroupChat"] boolValue]) { 
    430431                                chat = [[adium chatController] chatWithName:[chatDict objectForKey:@"Name"] 
     
    434435                        } else { 
    435436                                AIListContact           *contact = [[adium contactController] contactWithService:service 
    436                                                                                                                                                                 account:account 
    437                                                                                                                                                                         UID:[chatDict objectForKey:@"UID"]]; 
     437                                                                                                                                                                       account:account 
     438                                                                                                                                                                               UID:[chatDict objectForKey:@"UID"]]; 
    438439                                 
    439440                                chat = [[adium chatController] chatWithContact:contact]; 
     
    444445                           forProperty:@"Restored Chat" 
    445446                                        notify:NotifyNow]; 
     447                         
     448                        if ([[chatDict objectForKey:@"ActiveChat"] boolValue]) { 
     449                                containerActiveChat = chat; 
     450                        } 
    446451                                         
    447452                        // Open the chat into the container we've created above. 
    448453                        [self openChat:chat inContainerWithID:[dict objectForKey:@"ID"] atIndex:-1]; 
    449454                } 
     455                 
     456                if (containerActiveChat) 
     457                        [self setActiveChat:containerActiveChat]; 
    450458        } 
    451459} 
     
    470478                return; 
    471479        } 
    472          
     480 
    473481        // Save active containers. 
    474482        NSMutableArray          *savedContainers = [NSMutableArray array]; 
     
    485493 
    486494                        [newContainerDict setObject:[[chat account] internalObjectID] forKey:@"AccountID"]; 
    487  
     495                         
    488496                        // Save chat-specific information. 
    489497                        if ([chat isGroupChat]) { 
     
    491499                                [newContainerDict addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys: 
    492500                                                                                                                        [NSNumber numberWithBool:YES], @"IsGroupChat", 
     501                                                                                                                        [NSNumber numberWithBool:([dict objectForKey:@"ActiveChat"] == chat)], @"ActiveChat", 
    493502                                                                                                                        [chat name], @"Name", 
    494503                                                                                                                        [chat chatCreationDictionary], @"ChatCreationInfo",nil]]; 
    495504                        } else { 
    496505                                [newContainerDict addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys: 
     506                                                                                                                        [NSNumber numberWithBool:([dict objectForKey:@"ActiveChat"] == chat)], @"ActiveChat", 
    497507                                                                                                                        [[chat listObject] UID], @"UID", 
    498508                                                                                                                        [[chat listObject] serviceID], @"serviceID", 
    499509                                                                                                                        [[chat account] internalObjectID], @"AccountID",nil]]; 
    500510                        } 
    501                          
     511                                        
    502512                        [containerContents addObject:newContainerDict]; 
    503513                } 
    504514                 
    505515                // Replace the "Content" key in -openContainersAndChats with our version of the content. 
     516                // Remove the ActiveChat reference 
    506517                // We use the same keys otherwise that -openContainersAndChats provides (Name, ID, Frame) 
    507518                NSMutableDictionary *saveDict = [[dict mutableCopy] autorelease]; 
     519 
     520                [saveDict removeObjectForKey:@"ActiveChat"]; 
    508521                 
    509522                [saveDict setObject:containerContents