Changeset 3717

Show
Ignore:
Timestamp:
08/29/07 01:47:02 (1 year ago)
Author:
timothy
Message:

Consolidate some redundant code and fix some subtile bugs.

Files:

Legend:

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

    r3637 r3717  
    601601 
    602602- (MVChatConnection *) connectionForServerAddress:(NSString *) address { 
    603         NSEnumerator *enumerator = [_bookmarks objectEnumerator]; 
    604         id info = nil; 
    605  
    606         address = [address stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@". \t\n"]]; 
    607  
    608         while( ( info = [enumerator nextObject] ) ) { 
    609                 MVChatConnection *connection = [info objectForKey:@"connection"]; 
    610                 NSString *server = [connection server]; 
    611                 NSRange range = [server rangeOfString:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch ) range:NSMakeRange( 0, [server length] )]; 
    612                 if( range.location != NSNotFound && ( range.location == 0 || [server characterAtIndex:( range.location - 1 )] == '.' ) ) 
    613                         return connection; 
    614         } 
    615  
     603        NSArray *result = [self connectionsForServerAddress:address]; 
     604        if( [result count] ) 
     605                return [result objectAtIndex:0]; 
    616606        return nil; 
    617607} 
     
    730720        [quitMessageString release]; 
    731721 
    732         [self _deregisterNotificationsForConnection:connection]; 
     722        [self _deregisterNotificationsForConnection:oldConnection]; 
    733723 
    734724        [[MVKeyChain defaultKeyChain] setInternetPassword:nil forServer:[oldConnection server] securityDomain:[oldConnection server] account:[oldConnection nickname] path:nil port:0 protocol:MVKeyChainProtocolIRC authenticationType:MVKeyChainAuthenticationTypeDefault]; 
     
    736726 
    737727        [oldConnection release]; 
     728 
     729        [self _registerNotificationsForConnection:connection]; 
    738730 
    739731        [_bookmarks replaceObjectAtIndex:index withObject:info];