Changeset 3086

Show
Ignore:
Timestamp:
12/26/05 22:12:16 (3 years ago)
Author:
timothy
Message:
  • Code cleanup.
  • CTCP implemented.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cocoa-networking/Chat Core/MVChatConnection.h

    r3082 r3086  
    145145- (void) setEncoding:(NSStringEncoding) encoding; 
    146146- (NSStringEncoding) encoding; 
    147 - (NSString *) stringWithEncodedBytes:(const char *) bytes; 
    148 - (NSString *) stringWithEncodedBytesNoCopy:(char *) bytes freeWhenDone:(BOOL) free; 
    149 - (const char *) encodedBytesWithString:(NSString *) string; 
    150147 
    151148#pragma mark - 
     
    279276 
    280277@interface NSObject (MVChatPluginConnectionSupport) 
    281 - (BOOL) processSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments fromUser:(MVChatUser *) user; 
    282 - (BOOL) processSubcodeReply:(NSString *) command withArguments:(NSString *) arguments fromUser:(MVChatUser *) user; 
     278- (BOOL) processSubcodeRequest:(NSString *) command withArguments:(NSData *) arguments fromUser:(MVChatUser *) user; 
     279- (BOOL) processSubcodeReply:(NSString *) command withArguments:(NSData *) arguments fromUser:(MVChatUser *) user; 
    283280 
    284281- (void) connected:(MVChatConnection *) connection; 
  • branches/cocoa-networking/Chat Core/MVChatConnection.m

    r3082 r3086  
    259259- (NSStringEncoding) encoding { 
    260260        return _encoding; 
    261 } 
    262  
    263 - (NSString *) stringWithEncodedBytes:(const char *) bytes { 
    264         return [[[NSString allocWithZone:nil] initWithBytes:bytes encoding:_encoding] autorelease]; 
    265 } 
    266  
    267 - (NSString *) stringWithEncodedBytesNoCopy:(char *) bytes freeWhenDone:(BOOL) free { 
    268         return [[[NSString allocWithZone:nil] initWithBytesNoCopy:bytes encoding:_encoding freeWhenDone:free] autorelease]; 
    269 } 
    270  
    271 - (const char *) encodedBytesWithString:(NSString *) string { 
    272         return [string bytesUsingEncoding:_encoding allowLossyConversion:YES]; 
    273261} 
    274262 
  • branches/cocoa-networking/Chat Core/MVChatRoom.h

    r3072 r3086  
    9090- (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 
    9191 
    92 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments; 
    93 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments; 
     92- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments; 
     93- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments; 
    9494 
    9595- (NSData *) topic; 
  • branches/cocoa-networking/Chat Core/MVChatRoom.m

    r3081 r3086  
    213213#pragma mark - 
    214214 
    215 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments { 
     215- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments { 
    216216// subclass this method, if needed 
    217217} 
    218218 
    219 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments { 
     219- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments { 
    220220// subclass this method, if needed 
    221221} 
  • branches/cocoa-networking/Chat Core/MVChatUser.h

    r3072 r3086  
    139139- (MVUploadFileTransfer *) sendFile:(NSString *) path passively:(BOOL) passive; 
    140140 
    141 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments; 
    142 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments; 
     141- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments; 
     142- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments; 
    143143@end 
    144144 
  • branches/cocoa-networking/Chat Core/MVChatUser.m

    r3072 r3086  
    444444#pragma mark - 
    445445 
    446 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments { 
     446- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments { 
    447447// subclass this method, if needed 
    448448} 
    449449 
    450 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments { 
     450- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments { 
    451451// subclass this method, if needed 
    452452} 
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.m

    r3085 r3086  
    12491249 
    12501250end: 
     1251        [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:rawString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 
     1252 
    12511253        if( command && commandLength ) { 
    12521254                NSString *commandString = [[NSString allocWithZone:nil] initWithBytes:command length:commandLength encoding:[self encoding]]; 
     
    12801282                } 
    12811283        } 
    1282  
    1283         [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:rawString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 
    12841284 
    12851285        [rawString release]; 
     
    15201520 
    15211521- (void) _handleCTCP:(NSMutableData *) data asRequest:(BOOL) request fromSender:(MVChatUser *) sender forRoom:(MVChatRoom *) room { 
    1522         NSMutableArray *parameters = [[NSMutableArray allocWithZone:nil] initWithCapacity:15]; 
    15231522        const char *line = (const char *)[data bytes] + 1; // skip the \001 char 
    15241523        const char *end = line + [data length] - 2; // minus the first and last \001 char 
    1525         BOOL done = NO; 
    1526         BOOL restAsData = NO; 
    1527  
    1528         while( line != end && ! done ) { 
    1529                 // params: [ ':' <trailing data> | <letter> { <letter> } ] [ ' ' { ' ' } ] [ <params> ] 
    1530                 const char *currentParameter = NULL; 
    1531                 id param = nil; 
    1532                 if( *line == ':' || restAsData ) { 
    1533                         currentParameter = ( ! restAsData ? ++line : line ); 
    1534                         param = [[NSMutableData allocWithZone:nil] initWithBytes:currentParameter length:(end - currentParameter)]; 
    1535                         done = YES; 
    1536                 } else { 
    1537                         currentParameter = line; 
    1538                         while( line != end && *line != ' ' ) line++; 
    1539                         param = [[NSString allocWithZone:nil] initWithBytes:currentParameter length:(line - currentParameter) encoding:[self encoding]]; 
    1540                         if( line == end ) done = YES; 
    1541                         else line++; 
     1524        const char *current = line; 
     1525 
     1526        while( line != end && *line != ' ' ) line++; 
     1527        NSString *command = [[NSString allocWithZone:nil] initWithBytes:current length:(line - current) encoding:[self encoding]]; 
     1528        NSMutableData *arguments = nil; 
     1529        if( line != end ) arguments = [[NSMutableData allocWithZone:nil] initWithBytes:++line length:(end - line)]; 
     1530 
     1531        if( [command caseInsensitiveCompare:@"ACTION"] == NSOrderedSame && arguments ) { 
     1532                // special case ACTION and send it out like a message with the action flag 
     1533                if( room ) [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomGotMessageNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:sender, @"user", arguments, @"message", [NSString locallyUniqueString], @"identifier", [NSNumber numberWithBool:YES], @"action", nil]]; 
     1534                else [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotPrivateMessageNotification object:sender userInfo:[NSDictionary dictionaryWithObjectsAndKeys:arguments, @"message", [NSString locallyUniqueString], @"identifier", [NSNumber numberWithBool:YES], @"action", nil]]; 
     1535                [command release]; 
     1536                [arguments release]; 
     1537                return; 
     1538        } 
     1539 
     1540        [[NSNotificationCenter defaultCenter] postNotificationName:( request ? MVChatConnectionSubcodeRequestNotification : MVChatConnectionSubcodeReplyNotification ) object:sender userInfo:[NSDictionary dictionaryWithObjectsAndKeys:command, @"command", arguments, @"arguments", nil]]; 
     1541 
     1542        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( BOOL ), @encode( NSString * ), @encode( NSString * ), @encode( MVChatUser * ), nil]; 
     1543        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     1544        if( request ) [invocation setSelector:@selector( processSubcodeRequest:withArguments:fromUser: )]; 
     1545        else [invocation setSelector:@selector( processSubcodeReply:withArguments:fromUser: )]; 
     1546        [invocation setArgument:&command atIndex:2]; 
     1547        [invocation setArgument:&arguments atIndex:3]; 
     1548        [invocation setArgument:&sender atIndex:4]; 
     1549 
     1550        NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation stoppingOnFirstSuccessfulReturn:YES]; 
     1551        if( [[results lastObject] boolValue] ) { 
     1552                [command release]; 
     1553                [arguments release]; 
     1554                return; 
     1555        } 
     1556 
     1557        if( request ) { 
     1558                if( [command caseInsensitiveCompare:@"VERSION"] == NSOrderedSame ) { 
     1559                        NSDictionary *systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/ServerVersion.plist"]; 
     1560                        if( ! [systemVersion count] ) systemVersion = [[NSDictionary allocWithZone:nil] initWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"]; 
     1561                        NSDictionary *clientVersion = [[NSBundle mainBundle] infoDictionary]; 
     1562 
     1563#if __ppc__ 
     1564                        NSString *processor = @"PowerPC"; 
     1565#elif __i386__ 
     1566                        NSString *processor = @"Intel"; 
     1567#else 
     1568                        NSString *processor = @"Unknown Architecture"; 
     1569#endif 
     1570 
     1571                        NSString *reply = [[NSString allocWithZone:nil] initWithFormat:@"%@ %@ (%@) - %@ %@ (%@) - %@", [clientVersion objectForKey:@"CFBundleName"], [clientVersion objectForKey:@"CFBundleShortVersionString"], [clientVersion objectForKey:@"CFBundleVersion"], [systemVersion objectForKey:@"ProductName"], [systemVersion objectForKey:@"ProductUserVisibleVersion"], processor, [clientVersion objectForKey:@"MVChatCoreCTCPVersionReplyInfo"]]; 
     1572                        [sender sendSubcodeReply:command withArguments:reply]; 
     1573 
     1574                        [reply release]; 
     1575                        [systemVersion release]; 
     1576                } else if( [command caseInsensitiveCompare:@"TIME"] == NSOrderedSame ) { 
     1577                        [sender sendSubcodeReply:command withArguments:[[NSDate date] description]]; 
     1578                } else if( [command caseInsensitiveCompare:@"PING"] == NSOrderedSame ) { 
     1579                        // only reply with packets less than 100 bytes, anything over that is bad karma 
     1580                        if( [arguments length] < 100 ) [sender sendSubcodeReply:command withArguments:arguments]; 
     1581                } else if( [command caseInsensitiveCompare:@"CLIENTINFO"] == NSOrderedSame ) { 
     1582                        // make this extnesible later with a plugin registration method 
     1583                        [sender sendSubcodeReply:command withArguments:@"VERSION TIME PING DCC CLIENTINFO"]; 
    15421584                } 
    1543  
    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                 } 
    1550  
    1551                 while( *line == ' ' && line != end && ! done ) line++; 
    1552         } 
    1553  
    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  
    1562         NSLog(@"ctcp %@ %d %@", sender, request, [parameters description] ); 
    1563         [parameters release]; 
     1585        } 
     1586 
     1587        [command release]; 
     1588        [arguments release]; 
    15641589} 
    15651590 
  • branches/cocoa-networking/Chat Core/MVIRCChatRoom.m

    r3081 r3086  
    5959#pragma mark - 
    6060 
    61 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments { 
     61- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments { 
    6262        NSParameterAssert( command != nil ); 
    63         NSString *request = ( [arguments length] ? [NSString stringWithFormat:@"%@ %@", command, arguments] : command ); 
    64         [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@\001", [self name], request]; 
    65 
    66  
    67 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments { 
     63        if( arguments && [arguments isKindOfClass:[NSData class]] && [arguments length] ) { 
     64                NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :\001%@ ", [self name], command]; 
     65                [[self connection] sendRawMessageWithComponents:prefix, arguments, @"\001", nil]; 
     66                [prefix release]; 
     67        } else if( arguments && [arguments isKindOfClass:[NSString class]] && [arguments length] ) { 
     68                [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@ %@\001", [self name], command, arguments]; 
     69        } else [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@\001", [self name], command]; 
     70
     71 
     72- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments { 
    6873        NSParameterAssert( command != nil ); 
    69         NSString *request = ( [arguments length] ? [NSString stringWithFormat:@"%@ %@", command, arguments] : command ); 
    70         [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@\001", [self name], request]; 
     74        if( arguments && [arguments isKindOfClass:[NSData class]] && [arguments length] ) { 
     75                NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"NOTICE %@ :\001%@ ", [self name], command]; 
     76                [[self connection] sendRawMessageWithComponents:prefix, arguments, @"\001", nil]; 
     77                [prefix release]; 
     78        } else if( arguments && [arguments isKindOfClass:[NSString class]] && [arguments length] ) { 
     79                [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@ %@\001", [self name], command, arguments]; 
     80        } else [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@\001", [self name], command]; 
    7181} 
    7282 
  • branches/cocoa-networking/Chat Core/MVIRCChatUser.m

    r3080 r3086  
    4747} 
    4848 
    49 - (void) sendSubcodeRequest:(NSString *) command withArguments:(NSString *) arguments { 
     49- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments { 
    5050        NSParameterAssert( command != nil ); 
    51         NSString *request = ( [arguments length] ? [NSString stringWithFormat:@"%@ %@", command, arguments] : command ); 
    52         [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@\001", [self nickname], request]; 
     51        if( arguments && [arguments isKindOfClass:[NSData class]] && [arguments length] ) { 
     52                NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :\001%@ ", [self nickname], command]; 
     53                [[self connection] sendRawMessageWithComponents:prefix, arguments, @"\001", nil]; 
     54                [prefix release]; 
     55        } else if( arguments && [arguments isKindOfClass:[NSString class]] && [arguments length] ) { 
     56                [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@ %@\001", [self nickname], command, arguments]; 
     57        } else [[self connection] sendRawMessageWithFormat:@"PRIVMSG %@ :\001%@\001", [self nickname], command]; 
    5358} 
    5459 
    55 - (void) sendSubcodeReply:(NSString *) command withArguments:(NSString *) arguments { 
     60- (void) sendSubcodeReply:(NSString *) command withArguments:(id) arguments { 
    5661        NSParameterAssert( command != nil ); 
    57         NSString *request = ( [arguments length] ? [NSString stringWithFormat:@"%@ %@", command, arguments] : command ); 
    58         [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@\001", [self nickname], request]; 
     62        if( arguments && [arguments isKindOfClass:[NSData class]] && [arguments length] ) { 
     63                NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"NOTICE %@ :\001%@ ", [self nickname], command]; 
     64                [[self connection] sendRawMessageWithComponents:prefix, arguments, @"\001", nil]; 
     65                [prefix release]; 
     66        } else if( arguments && [arguments isKindOfClass:[NSString class]] && [arguments length] ) { 
     67                [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@ %@\001", [self nickname], command, arguments]; 
     68        } else [[self connection] sendRawMessageWithFormat:@"NOTICE %@ :\001%@\001", [self nickname], command]; 
    5969} 
    6070 
     
    8090- (void) ctcpReplyNotification:(NSNotification *) notification { 
    8191        NSString *command = [[notification userInfo] objectForKey:@"command"]; 
    82         NSString *arguments = [[notification userInfo] objectForKey:@"arguments"]; 
    83         if( ! [command caseInsensitiveCompare:@"version"] ) { 
     92        NSData *arguments = [[notification userInfo] objectForKey:@"arguments"]; 
     93        if( [command caseInsensitiveCompare:@"VERSION"] == NSOrderedSame ) { 
    8494                [self setAttribute:arguments forKey:MVChatUserClientInfoAttribute]; 
    85         } else if( ! [command caseInsensitiveCompare:@"time"] ) { 
    86                 NSDate *localThere = [NSDate dateWithNaturalLanguageString:arguments]; 
     95        } else if( [command caseInsensitiveCompare:@"TIME"] == NSOrderedSame ) { 
     96                NSString *date = [[NSString allocWithZone:nil] initWithData:arguments encoding:[[self connection] encoding]]; 
     97                NSDate *localThere = [NSDate dateWithNaturalLanguageString:date]; 
    8798                if( localThere ) { 
    8899                        NSTimeInterval diff = [localThere timeIntervalSinceDate:[NSDate date]]; 
    89100                        [self setAttribute:[NSNumber numberWithDouble:diff] forKey:MVChatUserLocalTimeDifferenceAttribute]; 
    90101                } else [self setAttribute:nil forKey:MVChatUserLocalTimeDifferenceAttribute]; 
     102                [date release]; 
    91103        } 
    92104} 
  • branches/cocoa-networking/Chat Core/MVSILCChatConnection.m

    r3072 r3086  
    7878        if( flags & SILC_MESSAGE_FLAG_ACTION ) action = YES; 
    7979 
    80         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     80        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    8181        MVChatUser *user = [self _chatUserWithClientEntry:sender]; 
    8282        NSString *mimeType = @"text/plain"; 
     
    252252                        if( joining_client == conn -> local_entry ) break; 
    253253 
    254                         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     254                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    255255                        MVChatUser *member = [self _chatUserWithClientEntry:joining_client]; 
    256256 
     
    280280                        if( ! leaving_client || ! channel ) break; 
    281281 
    282                         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     282                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    283283                        MVChatUser *member = [self _chatUserWithClientEntry:leaving_client]; 
    284284 
     
    300300                                authorUser = [self _chatUserWithClientEntry:(SilcClientEntry)setter_entry]; 
    301301 
    302                         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     302                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    303303                        NSData *msgData = ( topic ? [[NSData allocWithZone:nil] initWithBytes:topic length:strlen( topic )] : nil ); 
    304304                        [room _setTopic:msgData byAuthor:authorUser withDate:[NSDate date]]; 
     
    320320                                changerUser = [self _chatUserWithClientEntry:(SilcClientEntry)changer_entry]; 
    321321 
    322                         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     322                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    323323                        MVChatUser *member = [self _chatUserWithClientEntry:target_client]; 
    324324 
     
    394394                        NSNotification *note = nil; 
    395395 
    396                         MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     396                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    397397                        MVChatUser *member = [self _chatUserWithClientEntry:kicked]; 
    398398                        MVChatUser *byMember = [self _chatUserWithClientEntry:kicker]; 
     
    632632                /* SilcUInt32 user_limit = */ va_arg( list, SilcUInt32 ); 
    633633 
    634                 MVSILCChatRoom *room = (MVSILCChatRoom *)[self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     634                MVSILCChatRoom *room = (MVSILCChatRoom *)[self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    635635                if( ! room ) { 
    636636                        room = [[[MVSILCChatRoom allocWithZone:nil] initWithChannelEntry:channel andConnection:self] autorelease]; 
     
    673673        case SILC_COMMAND_LEAVE: { 
    674674                SilcChannelEntry channel = va_arg( list, SilcChannelEntry ); 
    675                 MVChatRoom *room = [self joinedChatRoomWithName:[self stringWithEncodedBytes:channel -> channel_name]]; 
     675                MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    676676                [room _setDateParted:[NSDate date]]; 
    677677                NSNotification *note = [NSNotification notificationWithName:MVChatRoomPartedNotification object:room userInfo:nil];