Changeset 3542

Show
Ignore:
Timestamp:
01/07/07 14:17:32 (2 years ago)
Author:
timothy
Message:

Remove the line endings from regular DCC chat messages also.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Chat Core/MVDirectChatConnection.m

    r3539 r3542  
    198198- (void) directClientConnection:(MVDirectClientConnection *) connection didReadData:(NSData *) data withTag:(long) tag { 
    199199        const char *bytes = (const char *)[data bytes]; 
    200         BOOL ctcp = ( *bytes == '\001' && [data length] > 2 ); 
     200        unsigned int len = [data length]; 
     201        const char *end = bytes + len - 2; // minus the line endings 
     202        BOOL ctcp = ( *bytes == '\001' && [data length] > 3 ); // three is the one minimum line ending and two \001 chars 
     203 
     204        if( *end != '\x0D' ) 
     205                end = bytes + len - 1; // this client only uses \x0A for the message line ending, lets work with it 
    201206 
    202207        if( ctcp ) { 
    203                 const char *line = bytes + 1; // skip the \001 char 
    204                 unsigned int len = [data length]; 
    205                 const char *end = bytes + len - 2; // minus the line endings 
     208                const char *line = bytes + 1; // skip the first \001 char 
    206209                const char *current = line; 
    207  
    208                 if( *end != '\x0D' ) 
    209                         end = bytes + len - 1; // this client only uses \x0A for the message line ending, lets work with it 
    210210 
    211211                if( *( end - 1 ) == '\001' ) 
     
    229229                [arguments release]; 
    230230        } else { 
    231                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVDirectChatConnectionGotMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:data, @"message", [NSString locallyUniqueString], @"identifier", nil]]; 
     231                NSData *msg = [[NSData allocWithZone:nil] initWithBytes:bytes length:(end - bytes)]; 
     232                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVDirectChatConnectionGotMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msg, @"message", [NSString locallyUniqueString], @"identifier", nil]]; 
     233                [msg release]; 
    232234        } 
    233235