Changeset 3085

Show
Ignore:
Timestamp:
12/26/05 20:39:32 (3 years ago)
Author:
timothy
Message:

Handle CTCP action.

Files:

Legend:

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

    r3084 r3085  
    15241524        const char *end = line + [data length] - 2; // minus the first and last \001 char 
    15251525        BOOL done = NO; 
     1526        BOOL restAsData = NO; 
    15261527 
    15271528        while( line != end && ! done ) { 
     
    15291530                const char *currentParameter = NULL; 
    15301531                id param = nil; 
    1531                 if( *line == ':' ) { 
    1532                         currentParameter = ++line
     1532                if( *line == ':' || restAsData ) { 
     1533                        currentParameter = ( ! restAsData ? ++line : line )
    15331534                        param = [[NSMutableData allocWithZone:nil] initWithBytes:currentParameter length:(end - currentParameter)]; 
    15341535                        done = YES; 
     
    15411542                } 
    15421543 
    1543                 if( param ) [parameters addObject:param]; 
    1544                 [param release]; 
     1544                if( param ) { 
     1545                        [parameters addObject:param]; 
     1546                        if( [parameters count] == 1 && [param isKindOfClass:[NSString class]] ) 
     1547                                restAsData = ( [param caseInsensitiveCompare:@"ACTION"] == NSOrderedSame ); 
     1548                        [param release]; 
     1549                } 
    15451550 
    15461551                while( *line == ' ' && line != end && ! done ) line++; 
    15471552        } 
    15481553 
     1554        if( [parameters count] == 2 && [[parameters objectAtIndex:0] caseInsensitiveCompare:@"ACTION"] == NSOrderedSame ) { 
     1555                // special case ACTION and send it out like a message with the action flag 
     1556                if( room ) [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomGotMessageNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:sender, @"user", [parameters objectAtIndex:1], @"message", [NSString locallyUniqueString], @"identifier", [NSNumber numberWithBool:YES], @"action", nil]]; 
     1557                else [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotPrivateMessageNotification object:sender userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[parameters objectAtIndex:1], @"message", [NSString locallyUniqueString], @"identifier", [NSNumber numberWithBool:YES], @"action", nil]]; 
     1558                [parameters release]; 
     1559                return; 
     1560        } 
     1561 
    15491562        NSLog(@"ctcp %@ %d %@", sender, request, [parameters description] ); 
     1563        [parameters release]; 
    15501564} 
    15511565