Changeset 3603

Show
Ignore:
Timestamp:
03/05/07 11:00:21 (1 year ago)
Author:
timothy
Message:

Correct the orider in how we load the bookmarks. We needed to register for notifications before connecting and the connection needed to be in _bookmarks for anything to work. Also removed many redundant showConsoleOnConnectForConnection: since the console is shown in _willConnect:.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Controllers/MVConnectionsController.m

    r3597 r3603  
    432432        if( [_joinRooms count] ) [connection joinChatRoomsNamed:_joinRooms]; 
    433433 
    434         if( [self showConsoleOnConnectForConnection:connection] ) 
    435                 [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    436  
    437         [connection connectToServer:[newAddress stringValue] onPort:[newPort intValue] asUser:[newNickname stringValue]]; 
    438  
    439434        [self addConnection:connection keepBookmark:(BOOL)[newRemember state]]; 
    440435        [self setJoinRooms:_joinRooms forConnection:connection]; 
     436 
     437        [connection connectToServer:[newAddress stringValue] onPort:[newPort intValue] asUser:[newNickname stringValue]]; 
    441438 
    442439        [[self window] makeKeyAndOrderFront:nil]; 
     
    763760                                ( ! [[url port] unsignedShortValue] || [connection serverPort] == [[url port] unsignedShortValue] ) ) { 
    764761 
    765                                 if( ! [connection isConnected] && connect ) { 
    766                                         if( [self showConsoleOnConnectForConnection:connection] ) 
    767                                                 [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    768                                         [connection connect]; 
    769                                 } 
    770  
    771762                                if( target ) [connection joinChatRoomNamed:target]; 
    772763                                else [[self window] orderFront:nil]; 
     764 
     765                                if( ! [connection isConnected] && connect ) 
     766                                        [connection connect]; 
    773767 
    774768                                [connections selectRow:[_bookmarks indexOfObject:info] byExtendingSelection:NO]; 
     
    795789                        [connection setOutgoingChatFormat:[[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatFormat"]]; 
    796790 
     791                        [self addConnection:connection keepBookmark:NO]; 
     792 
    797793                        if( connect ) { 
    798                                 if( [self showConsoleOnConnectForConnection:connection] ) 
    799                                         [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    800794                                if( target ) [connection joinChatRoomNamed:target]; 
    801795                                [connection connect]; 
    802796                        } 
    803  
    804                         [self addConnection:connection keepBookmark:NO]; 
    805797 
    806798                        [[self window] orderFront:nil]; 
     
    16281620        NSArray *list = [[NSUserDefaults standardUserDefaults] arrayForKey:@"MVChatBookmarks"]; 
    16291621        NSEnumerator *enumerator = [list objectEnumerator]; 
    1630         NSMutableArray *bookmarks = [NSMutableArray array]; 
    16311622        NSMutableDictionary *info = nil; 
    16321623 
    16331624        [self _deregisterNotificationsForConnection:nil]; // deregister all connections 
     1625 
     1626        [_bookmarks release]; 
     1627        _bookmarks = [[NSMutableArray alloc] init]; 
    16341628 
    16351629        while( ( info = [enumerator nextObject] ) ) { 
     
    16881682                [connection setSecure:[[info objectForKey:@"secure"] boolValue]]; 
    16891683 
     1684                [info setObject:connection forKey:@"connection"]; 
     1685 
     1686                [_bookmarks addObject:info]; 
     1687 
     1688                [self _registerNotificationsForConnection:connection]; 
     1689 
    16901690                if( [[info objectForKey:@"automatic"] boolValue] && ! ( [[[NSApplication sharedApplication] currentEvent] modifierFlags] & NSShiftKeyMask ) ) { 
    1691                         if( [[info objectForKey:@"showConsole"] boolValue] ) 
    1692                                 [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    1693  
    16941691                        [connection setPassword:[[MVKeyChain defaultKeyChain] internetPasswordForServer:[connection server] securityDomain:[connection server] account:nil path:nil port:[connection serverPort] protocol:MVKeyChainProtocolIRC authenticationType:MVKeyChainAuthenticationTypeDefault]]; 
    1695  
    16961692                        [connection connect]; 
    16971693                } 
    1698  
    1699                 [info setObject:connection forKey:@"connection"]; 
    1700                 [self _registerNotificationsForConnection:connection]; 
    1701  
    1702                 [bookmarks addObject:info]; 
    1703         } 
    1704  
    1705         [_bookmarks autorelease]; 
    1706         _bookmarks = [bookmarks retain]; 
     1694        } 
    17071695 
    17081696        [connections noteNumberOfRowsChanged]; 
     
    18501838        MVChatConnection *connection = [[_bookmarks objectAtIndex:[connections selectedRow]] objectForKey:@"connection"]; 
    18511839        [connection setPassword:[[MVKeyChain defaultKeyChain] internetPasswordForServer:[connection server] securityDomain:[connection server] account:nil path:nil port:[connection serverPort] protocol:MVKeyChainProtocolIRC authenticationType:MVKeyChainAuthenticationTypeDefault]]; 
    1852         if( [self showConsoleOnConnectForConnection:connection] ) 
    1853                 [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    18541840        [connection connect]; 
    18551841}