Changeset 3594

Show
Ignore:
Timestamp:
03/03/07 17:16:55 (1 year ago)
Author:
jmmv
Message:

Make auto-join in ICB work by handling joins when not connected and updating
the initial channel accordingly.

To make this work properly, move all initialization code from _didConnect
to _willConnect in the connections controller so that it is run before the
connection is made. The chat protocols enqueue the commands and rerun them
in the right order once connected (doing any necessary processing, as is
the case of ICB). Per timothy@'s suggestion.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Chat Core/MVICBChatConnection.h

    r3582 r3594  
    7878- (unsigned short) serverPort; 
    7979- (void) sendRawMessage:(id) raw immediately:(BOOL) now; 
     80- (void) joinChatRoomsNamed:(NSArray *) rooms; 
    8081- (void) joinChatRoomNamed:(NSString *) room withPassphrase: 
    8182                           (NSString *) passphrase; 
  • trunk/Chat Core/MVICBChatConnection.m

    r3592 r3594  
    314314} 
    315315 
     316- (void) joinChatRoomsNamed:(NSArray *) rooms { 
     317        NSParameterAssert( rooms != nil ); 
     318 
     319        if( ! [rooms count] ) 
     320                return; 
     321 
     322        NSEnumerator *enumerator = [rooms objectEnumerator]; 
     323        NSString *room = nil; 
     324 
     325        while( ( room = [enumerator nextObject] ) ) { 
     326                if( [room length] ) { 
     327                        [self joinChatRoomNamed:room withPassphrase:nil]; 
     328                        break; 
     329                } 
     330        } 
     331} 
     332 
    316333- (void) joinChatRoomNamed:(NSString *) name 
    317334                        withPassphrase:(NSString *) passphrase { 
    318         [self _joinChatRoomNamed:name withPassphrase:passphrase alreadyJoined:NO]; 
     335        if( _loggedIn ) 
     336                [self _joinChatRoomNamed:name withPassphrase:passphrase alreadyJoined:NO]; 
     337        else 
     338                MVSafeCopyAssign( &_initialChannel, name ); 
    319339} 
    320340 
  • trunk/Controllers/MVConnectionsController.m

    r3593 r3594  
    18571857- (void) _willConnect:(NSNotification *) notification { 
    18581858        MVChatConnection *connection = [notification object]; 
     1859 
    18591860        if( [self showConsoleOnConnectForConnection:connection] ) 
    18601861                [[JVChatController defaultController] chatConsoleForConnection:connection ifExists:NO]; 
    1861 
    1862  
    1863 - (void) _didConnect:(NSNotification *) notification { 
    1864         MVChatConnection *connection = [notification object]; 
     1862 
    18651863        NSArray *rooms = [self joinRoomsForConnection:connection]; 
    18661864        NSString *strcommands = [self connectCommandsForConnection:connection]; 
     
    19081906        if( [rooms count] && ! ( [[[NSApplication sharedApplication] currentEvent] modifierFlags] & NSShiftKeyMask ) ) 
    19091907                [connection joinChatRoomsNamed:rooms]; 
    1910  
     1908
     1909 
     1910- (void) _didConnect:(NSNotification *) notification { 
     1911        MVChatConnection *connection = [notification object]; 
    19111912        NSMutableDictionary *context = [NSMutableDictionary dictionary]; 
    19121913        [context setObject:NSLocalizedString( @"Connected", "connected bubble title" ) forKey:@"title"];