Changeset 3588
- Timestamp:
- 02/25/07 18:03:42 (2 years ago)
- Files:
-
- trunk/Chat Core/MVICBChatConnection.m (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/MVICBChatConnection.m
r3585 r3588 46 46 #import "ICBPacket.h" 47 47 #import "InterThreadMessaging.h" 48 #import "MVUtilities.h" 48 49 #import "NSStringAdditions.h" 49 50 #import "NSNotificationAdditions.h" … … 64 65 withPassphrase:(NSString *) passphrase 65 66 alreadyJoined:(BOOL) joined; 67 - (void) _updateKnownUser:(MVChatUser *) user 68 withNewNickname:(NSString *) newNickname; 66 69 @end 67 70 … … 141 144 142 145 if( ! [newNickname isEqualToString:_nickname] ) { 143 id old = _nickname;144 _nickname = [newNickname copyWithZone:nil];145 [old release];146 147 146 if( [self isConnected] ) 148 147 [self performSelector:@selector( ctsCommandName: ) 149 withObject:_nickname inThread:_connectionThread]; 148 withObject:newNickname inThread:_connectionThread]; 149 else 150 MVSafeCopyAssign( &_nickname, newNickname ); 150 151 } 151 152 } … … 238 239 - (void) sendRawMessage:(id) raw immediately:(BOOL) now { 239 240 NSParameterAssert( raw ); 240 NSParameterAssert( [raw isKindOfClass:[NSData class]] || 241 [raw isKindOfClass:[NSString class]] ); 241 242 // XXX Colloquy assumes in multiple places that sendRawMessage can 243 // take a plain string and send it to the server as a valid message. 244 // This is not the case for ICB, nor it is a proper abstraction 245 // because different protocols need not share the same protocol syntax. 246 // We simply discard such messages at the moment until the code in 247 // the upper layers is "corrected". 248 if( [raw isKindOfClass:[NSString class]] ) { 249 NSLog(@"MVICBChatConnection: sendRawMessage ignored message %@", 250 raw); 251 return; 252 } 253 254 NSParameterAssert( [raw isKindOfClass:[NSData class]] ); 242 255 243 256 if( now ) { … … 547 560 [oldroom release]; 548 561 } 562 } 563 } 564 565 #pragma mark Users handling 566 567 - (void) _updateKnownUser:(MVChatUser *) user 568 withNewNickname:(NSString *) newNickname { 569 @synchronized( _knownUsers ) { 570 [user retain]; 571 [_knownUsers removeObjectForKey:[user uniqueIdentifier]]; 572 [user _setUniqueIdentifier:[newNickname lowercaseString]]; 573 [user _setNickname:newNickname]; 574 [_knownUsers setObject:user forKey:[user uniqueIdentifier]]; 575 [user release]; 549 576 } 550 577 } … … 1004 1031 } 1005 1032 1033 - (void) stcStatusPacketName:(NSArray *) fields { 1034 NSString *msg = [fields objectAtIndex:1]; 1035 1036 NSRange r; 1037 1038 r = [msg rangeOfString:@" changed nickname to "]; 1039 if( r.location != NSNotFound ) { 1040 NSString *oldnick = [msg substringToIndex:r.location]; 1041 NSString *newnick = [msg substringFromIndex:r.location + r.length]; 1042 1043 MVChatUser *who = [self chatUserWithUniqueIdentifier:oldnick]; 1044 if( [who isLocalUser] ) { 1045 MVSafeCopyAssign( &_nickname, newnick ); 1046 [who _setUniqueIdentifier:[newnick lowercaseString]]; 1047 1048 [[NSNotificationCenter defaultCenter] 1049 postNotificationOnMainThreadWithName:MVChatConnectionNicknameAcceptedNotification 1050 object:self userInfo:nil]; 1051 } else { 1052 [self _updateKnownUser:who withNewNickname:newnick]; 1053 1054 [[NSNotificationCenter defaultCenter] 1055 postNotificationOnMainThreadWithName:MVChatUserNicknameChangedNotification 1056 object:who 1057 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:oldnick, @"oldNickname", nil]]; 1058 } 1059 } 1060 } 1061 1006 1062 - (void) stcStatusPacketNoPass:(NSArray *) fields { 1007 1063 }
