Changeset 3115

Show
Ignore:
Timestamp:
02/04/06 00:40:58 (2 years ago)
Author:
timothy
Message:
  • Implements the invites.
  • Marks users as away when joining a room.
  • Sends NickServ? an identify message when connecting.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.m

    r3111 r3115  
    10991099} 
    11001100/* 
    1101 #pragma mark - 
    1102  
    1103 - (void) _didConnect { 
    1104         id old = _localUser; 
    1105         _localUser = [[MVIRCChatUser allocWithZone:nil] initLocalUserWithConnection:self]; 
    1106         [old release]; 
    1107  
    1108         // Identify if we have a user password 
    1109         if( [[self nicknamePassword] length] ) 
    1110                 [self sendRawMessageWithFormat:@"PRIVMSG NickServ :IDENTIFY %@", [self nicknamePassword]]; 
    1111  
    1112         [super _didConnect]; 
    1113 } 
    11141101 
    11151102#pragma mark - 
     
    12581245- (void) _handle001WithParameters:(NSArray *) parameters fromSender:(MVChatUser *) sender { 
    12591246        [self performSelectorOnMainThread:@selector( _didConnect ) withObject:nil waitUntilDone:NO];     
     1247        // Identify if we have a user password 
     1248        if( [[self nicknamePassword] length] ) 
     1249                [self sendRawMessageWithFormat:@"NickServ IDENTIFY %@", [self nicknamePassword]]; 
    12601250        if( [parameters count] >= 1 ) { 
    12611251                NSString *nickname = [parameters objectAtIndex:0]; 
     
    16311621} 
    16321622 
     1623- (void) _handleInviteWithParameters:(NSArray *) parameters fromSender:(MVChatUser *) sender { 
     1624        if( [parameters count] == 2 ) { 
     1625                id roomName = [parameters objectAtIndex:1]; 
     1626                if( [roomName isKindOfClass:[NSData class]] ) 
     1627                        roomName = [[[NSString allocWithZone:nil] initWithData:roomName encoding:[self encoding]] autorelease]; 
     1628                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomInvitedNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:sender, @"user", roomName, @"room", nil]]; 
     1629        } 
     1630} 
     1631 
    16331632- (void) _handleNickWithParameters:(NSArray *) parameters fromSender:(MVChatUser *) sender { 
    16341633        if( [parameters count] == 1 ) { 
     
    17471746 
    17481747- (void) _handle352WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_WHOREPLY 
    1749         if( [parameters count] >= 6 ) { 
     1748        if( [parameters count] >= 7 ) { 
    17501749                MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:1]]; 
    17511750                MVChatUser *member = [self chatUserWithUniqueIdentifier:[parameters objectAtIndex:5]]; 
    17521751                [member _setUsername:[parameters objectAtIndex:2]]; 
    17531752                [member _setAddress:[parameters objectAtIndex:3]]; 
     1753 
     1754                unichar status = ( [[parameters objectAtIndex:6] length] ? [[parameters objectAtIndex:6] characterAtIndex:0] : 0 ); 
     1755                if( status == 'H' ) { 
     1756                        [member _setStatus:MVChatUserAvailableStatus]; 
     1757                } else if( status == 'G' ) { 
     1758                        [member _setStatus:MVChatUserAwayStatus]; 
     1759                } 
    17541760        } 
    17551761}