Changeset 3136

Show
Ignore:
Timestamp:
02/12/06 17:40:15 (2 years ago)
Author:
timothy
Message:

Send a USER message that is compliant with RFC 2812. This addresses any privacy concerns about sending the host name.

Files:

Legend:

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

    r3134 r3136  
    6969 
    7070/* 
    71 static void MVChatGotUserMode( CHANNEL_REC *channel, NICK_REC *nick, char *by, char *mode, char *type ) { 
    72         MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:channel -> server]; 
    73         if( ! self ) return; 
    74  
    75         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> name]]; 
    76         MVChatUser *member = [self chatUserWithUniqueIdentifier:[self stringWithEncodedBytes:nick -> nick]]; 
    77         MVChatUser *byMember = ( by ? [self chatUserWithUniqueIdentifier:[self stringWithEncodedBytes:by]] : nil ); 
    78  
    79         unsigned int m = MVChatRoomMemberNoModes; 
    80         if( *mode == '@' ) m = MVChatRoomMemberOperatorMode; 
    81         else if( *mode == '%' ) m = MVChatRoomMemberHalfOperatorMode; 
    82         else if( *mode == '+' ) m = MVChatRoomMemberVoicedMode; 
    83  
    84         if( m == MVChatRoomMemberNoModes ) return; 
    85  
    86         if( *type == '+' ) [room _setMode:m forMemberUser:member]; 
    87         else [room _removeMode:m forMemberUser:member]; 
    88  
    89         NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:( *type == '+' ? YES : NO )], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", byMember, @"by", nil]]; 
    90         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
    91 } 
    92  
    93 static void MVChatGotRoomMode( CHANNEL_REC *channel, const char *setby ) { 
    94         MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:channel -> server]; 
    95         if( ! self ) return; 
    96  
    97         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> name]]; 
    98         MVChatUser *byMember = ( setby ? [self chatUserWithUniqueIdentifier:[self stringWithEncodedBytes:setby]] : nil ); 
    99  
    100         unsigned int oldModes = [room modes]; 
    101  
    102         [room _clearModes]; 
    103  
    104         if( strchr( channel -> mode, 'p' ) ) 
    105                 [room _setMode:MVChatRoomPrivateMode withAttribute:nil]; 
    106  
    107         if( strchr( channel -> mode, 's' ) ) 
    108                 [room _setMode:MVChatRoomSecretMode withAttribute:nil]; 
    109  
    110         if( strchr( channel -> mode, 'i' ) ) 
    111                 [room _setMode:MVChatRoomInviteOnlyMode withAttribute:nil]; 
    112  
    113         if( strchr( channel -> mode, 'm' ) ) 
    114                 [room _setMode:MVChatRoomNormalUsersSilencedMode withAttribute:nil]; 
    115  
    116         if( strchr( channel -> mode, 'n' ) ) 
    117                 [room _setMode:MVChatRoomNoOutsideMessagesMode withAttribute:nil]; 
    118  
    119         if( strchr( channel -> mode, 't' ) ) 
    120                 [room _setMode:MVChatRoomOperatorsOnlySetTopicMode withAttribute:nil]; 
    121  
    122         if( strchr( channel -> mode, 'k' ) ) 
    123                 [room _setMode:MVChatRoomPassphraseToJoinMode withAttribute:[self stringWithEncodedBytes:channel -> key]]; 
    124  
    125         if( strchr( channel -> mode, 'l' ) ) 
    126                 [room _setMode:MVChatRoomLimitNumberOfMembersMode withAttribute:[NSNumber numberWithInt:channel -> limit]]; 
    127  
    128         unsigned int changedModes = ( oldModes ^ [room modes] ); 
    129  
    130         NSNotification *note = [NSNotification notificationWithName:MVChatRoomModesChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:changedModes], @"changedModes", byMember, @"by", nil]]; 
    131         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
    132 } 
    133  
    134 #pragma mark - 
    135  
    13671static void MVChatBanListFinished( IRC_SERVER_REC *server, const char *data ) { 
    13772        MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:(SERVER_REC *)server]; 
     
    214149        g_free( params ); 
    215150} 
    216  
    217 #pragma mark - 
    218  
    219 static void MVChatErrorNoSuchUser( IRC_SERVER_REC *server, const char *data ) { 
    220         MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:(SERVER_REC *)server]; 
    221         if( ! self ) return; 
    222  
    223         g_return_if_fail( data != NULL ); 
    224  
    225         char *nick = NULL; 
    226         char *params = event_get_params( data, 2, NULL, &nick ); 
    227  
    228         [self _processErrorCode:ERR_NOSUCHNICK withContext:nick]; 
    229  
    230         g_free( params ); 
    231 
    232  
    233 static void MVChatErrorUnknownCommand( IRC_SERVER_REC *server, const char *data ) { 
    234         MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:(SERVER_REC *)server]; 
    235         if( ! self ) return; 
    236  
    237         g_return_if_fail( data != NULL ); 
    238  
    239         char *command = NULL; 
    240         char *params = event_get_params( data, 2, NULL, &command ); 
    241  
    242         [self _processErrorCode:ERR_UNKNOWNCOMMAND withContext:command]; 
    243  
    244         g_free( params ); 
    245 
    246  
    247 #pragma mark - */ 
     151*/ 
    248152 
    249153@implementation MVIRCChatConnection 
     
    741645        if( [[self password] length] ) [self sendRawMessageWithFormat:@"PASS %@", [self password]]; 
    742646        [self sendRawMessageWithFormat:@"NICK %@", [self nickname]]; 
    743         [self sendRawMessageWithFormat:@"USER %@ %@ %@ :%@", [self username], [[NSHost currentHost] name], [self server], [self realName]]; 
     647        [self sendRawMessageWithFormat:@"USER %@ 0 * :%@", [self username], [self realName]]; 
    744648 
    745649        id old = _localUser; 
     
    15091413                        } 
    15101414 
     1415#undef enabledHighBit 
     1416#undef banMode 
     1417#undef banExcludeMode 
     1418#undef inviteExcludeMode 
     1419 
    15111420                        unsigned int changedModes = ( oldModes ^ [room modes] ); 
    15121421                        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomModesChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:changedModes], @"changedModes", sender, @"by", nil]];