Changeset 3638
- Timestamp:
- 04/17/07 01:39:07 (1 year ago)
- Files:
-
- trunk/Chat Core.xcodeproj/project.pbxproj (modified) (4 diffs)
- trunk/Chat Core/MVChatConnection.h (modified) (1 diff)
- trunk/Chat Core/MVChatConnection.m (modified) (3 diffs)
- trunk/Chat Core/MVChatRoom.h (modified) (2 diffs)
- trunk/Chat Core/MVChatRoom.m (modified) (1 diff)
- trunk/Chat Core/MVChatUser.m (modified) (1 diff)
- trunk/Chat Core/MVChatUserPrivate.h (modified) (1 diff)
- trunk/Chat Core/MVICBChatConnection.m (modified) (1 diff)
- trunk/Chat Core/MVXMPPChatConnection.h (modified) (3 diffs)
- trunk/Chat Core/MVXMPPChatConnection.m (modified) (14 diffs)
- trunk/Chat Core/MVXMPPChatRoom.h (added)
- trunk/Chat Core/MVXMPPChatRoom.m (added)
- trunk/Chat Core/MVXMPPChatUser.h (modified) (1 diff)
- trunk/Chat Core/MVXMPPChatUser.m (modified) (5 diffs)
- trunk/Frameworks/frameworks.tar.gz (modified) (previous)
- trunk/Models/JVSQLChatTranscript.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core.xcodeproj/project.pbxproj
r3637 r3638 75 75 32C46E1B0B3AB37E00B96B27 /* MVICBChatUser.m in Sources */ = {isa = PBXBuildFile; fileRef = 32C46E190B3AB37E00B96B27 /* MVICBChatUser.m */; }; 76 76 431261C3072EE37A00720AD1 /* MVSILCFileTransfer.m in Sources */ = {isa = PBXBuildFile; fileRef = 431261C1072EE37A00720AD1 /* MVSILCFileTransfer.m */; }; 77 DD4741310BD35A2E00D93AB9 /* MVXMPPChatRoom.m in Sources */ = {isa = PBXBuildFile; fileRef = DD47412F0BD35A2E00D93AB9 /* MVXMPPChatRoom.m */; }; 77 78 DDF64CE60BD29E41009E8FF6 /* MVXMPPChatConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = DDF64CE40BD29E41009E8FF6 /* MVXMPPChatConnection.m */; }; 78 79 DDF64D530BD2A4F6009E8FF6 /* Acid.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDF64D520BD2A4F6009E8FF6 /* Acid.framework */; }; … … 164 165 431261C0072EE37A00720AD1 /* MVSILCFileTransfer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MVSILCFileTransfer.h; path = "Chat Core/MVSILCFileTransfer.h"; sourceTree = "<group>"; }; 165 166 431261C1072EE37A00720AD1 /* MVSILCFileTransfer.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MVSILCFileTransfer.m; path = "Chat Core/MVSILCFileTransfer.m"; sourceTree = "<group>"; }; 167 DD47412E0BD35A2E00D93AB9 /* MVXMPPChatRoom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVXMPPChatRoom.h; path = "Chat Core/MVXMPPChatRoom.h"; sourceTree = "<group>"; }; 168 DD47412F0BD35A2E00D93AB9 /* MVXMPPChatRoom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MVXMPPChatRoom.m; path = "Chat Core/MVXMPPChatRoom.m"; sourceTree = "<group>"; }; 166 169 DDF64CE30BD29E41009E8FF6 /* MVXMPPChatConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVXMPPChatConnection.h; path = "Chat Core/MVXMPPChatConnection.h"; sourceTree = "<group>"; }; 167 170 DDF64CE40BD29E41009E8FF6 /* MVXMPPChatConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MVXMPPChatConnection.m; path = "Chat Core/MVXMPPChatConnection.m"; sourceTree = "<group>"; }; … … 310 313 DDF64CE40BD29E41009E8FF6 /* MVXMPPChatConnection.m */, 311 314 DDF64CE30BD29E41009E8FF6 /* MVXMPPChatConnection.h */, 315 DD47412F0BD35A2E00D93AB9 /* MVXMPPChatRoom.m */, 316 DD47412E0BD35A2E00D93AB9 /* MVXMPPChatRoom.h */, 312 317 DDF64E180BD2CABE009E8FF6 /* MVXMPPChatUser.m */, 313 318 DDF64E170BD2CABE009E8FF6 /* MVXMPPChatUser.h */, … … 570 575 DDF64CE60BD29E41009E8FF6 /* MVXMPPChatConnection.m in Sources */, 571 576 DDF64E1A0BD2CABE009E8FF6 /* MVXMPPChatUser.m in Sources */, 577 DD4741310BD35A2E00D93AB9 /* MVXMPPChatRoom.m in Sources */, 572 578 ); 573 579 runOnlyForDeploymentPostprocessing = 0; trunk/Chat Core/MVChatConnection.h
r3637 r3638 373 373 #pragma mark - 374 374 375 - (MVChatRoom *) joinedChatRoomWithUniqueIdentifier:(id) identifier; 375 376 - (MVChatRoom *) joinedChatRoomWithName:(NSString *) room; 376 377 trunk/Chat Core/MVChatConnection.m
r3637 r3638 633 633 } 634 634 635 - (MVChatRoom *) joinedChatRoomWithUniqueIdentifier:(id) identifier { 636 @synchronized( _joinedRooms ) { 637 return [_joinedRooms objectForKey:identifier]; 638 } return nil; 639 } 640 635 641 - (MVChatRoom *) joinedChatRoomWithName:(NSString *) name { 636 642 @synchronized( _joinedRooms ) { 637 return [_joinedRooms objectForKey:[name lowercaseString]]; 638 } return nil; 643 NSEnumerator *enumerator = [_joinedRooms objectEnumerator]; 644 MVChatRoom *room = nil; 645 646 while( ( room = [enumerator nextObject] ) ) 647 if( [[room name] isEqualToString:name] ) 648 return room; 649 } 650 651 return nil; 639 652 } 640 653 … … 899 912 - (void) _addJoinedRoom:(MVChatRoom *) room { 900 913 @synchronized( _joinedRooms ) { 901 [_joinedRooms setObject:room forKey:[ [room name] lowercaseString]];914 [_joinedRooms setObject:room forKey:[room uniqueIdentifier]]; 902 915 } 903 916 } … … 905 918 - (void) _removeJoinedRoom:(MVChatRoom *) room { 906 919 @synchronized( _joinedRooms ) { 907 [_joinedRooms removeObjectForKey:[ [room name] lowercaseString]];920 [_joinedRooms removeObjectForKey:[room uniqueIdentifier]]; 908 921 } 909 922 } trunk/Chat Core/MVChatRoom.h
r3597 r3638 99 99 @property(readonly, ivar) unsigned long modes; 100 100 101 @property(readonly) MVChatUser *localMemberUser; 101 102 @property(readonly) NSSet *memberUsers; 102 103 @property(readonly) NSSet *bannedUsers; … … 128 129 - (unsigned long) modes; 129 130 131 - (MVChatUser *) localMemberUser; 130 132 - (NSSet *) memberUsers; 131 133 - (NSSet *) bannedUsers; trunk/Chat Core/MVChatRoom.m
r3597 r3638 375 375 #pragma mark - 376 376 377 - (MVChatUser *) localMemberUser { 378 return [[self connection] localUser]; 379 } 380 377 381 - (NSSet *) memberUsers { 378 382 @synchronized( _memberUsers ) { trunk/Chat Core/MVChatUser.m
r3626 r3638 454 454 455 455 @implementation MVChatUser (MVChatUserPrivate) 456 - (void) _setType:(MVChatUserType) type { 457 _type = type; 458 } 459 456 460 - (void) _setUniqueIdentifier:(id) identifier { 457 461 MVSafeAdoptAssign( &_uniqueIdentifier, ( [identifier conformsToProtocol:@protocol( NSCopying )] ? [identifier copyWithZone:nil] : [identifier retain] ) ); trunk/Chat Core/MVChatUserPrivate.h
r3498 r3638 2 2 3 3 @interface MVChatUser (MVChatUserPrivate) 4 - (void) _setType:(MVChatUserType) type; 4 5 - (void) _setUniqueIdentifier:(id) identifier; 5 6 - (void) _setNickname:(NSString *) name; trunk/Chat Core/MVICBChatConnection.m
r3599 r3638 307 307 NSParameterAssert( [identifier isKindOfClass:[NSString class]] ); 308 308 309 MVChatRoom *room; 310 @synchronized( _joinedRooms ) { 311 room = [self joinedChatRoomWithName:identifier]; 312 if( !room ) { 313 room = [[MVICBChatRoom alloc] initWithName:identifier 314 andConnection:self]; 315 [self _addJoinedRoom:room]; 316 } 317 } 309 MVChatRoom *room = [self joinedChatRoomWithUniqueIdentifier:identifier]; 310 if( !room ) { 311 room = [[MVICBChatRoom alloc] initWithName:identifier 312 andConnection:self]; 313 [self _addJoinedRoom:room]; 314 } 315 318 316 return room; 319 317 } trunk/Chat Core/MVXMPPChatConnection.h
r3637 r3638 4 4 @class JabberSession; 5 5 @class JabberID; 6 @class XMLElement; 6 7 7 8 @interface MVXMPPChatConnection : MVChatConnection { … … 12 13 NSString *_server; 13 14 NSString *_username; 15 NSString *_nickname; 14 16 NSString *_password; 15 17 NSMutableDictionary *_knownUsers; … … 21 23 - (JabberSession *) _chatSession; 22 24 - (JabberID *) _localUserID; 25 - (XMLElement *) _capabilitiesElement; 26 - (XMLElement *) _multiUserChatExtensionElement; 23 27 @end trunk/Chat Core/MVXMPPChatConnection.m
r3637 r3638 3 3 #import "MVXMPPChatConnection.h" 4 4 #import "MVXMPPChatUser.h" 5 #import "MVXMPPChatRoom.h" 5 6 #import "MVUtilities.h" 6 7 #import "MVChatPluginManager.h" 7 8 #import "NSMethodSignatureAdditions.h" 9 #import "NSStringAdditions.h" 8 10 9 11 @implementation MVXMPPChatConnection … … 19 21 _server = @"jabber.org"; 20 22 _username = [NSUserName() retain]; 23 _nickname = [_username retain]; 21 24 _session = [[JabberSession alloc] init]; 22 25 … … 29 32 [_session addObserver:self selector:@selector( outgoingPacket: ) name:JSESSION_RAWDATA_OUT]; 30 33 [_session addObserver:self selector:@selector( incomingPacket: ) name:JSESSION_RAWDATA_IN]; 31 [_session addObserver:self selector:@selector( incomingPrivateMessage: ) xpath:@"/message[@type='chat']"]; 34 [_session addObserver:self selector:@selector( incomingMessage: ) xpath:@"/message"]; 35 [_session addObserver:self selector:@selector( incomingPresence: ) xpath:@"/presence"]; 32 36 } 33 37 … … 47 51 [_server release]; 48 52 [_username release]; 53 [_nickname release]; 49 54 [_password release]; 50 55 [_knownUsers release]; … … 54 59 _server = nil; 55 60 _username = nil; 61 _nickname = nil; 56 62 _password = nil; 57 63 _knownUsers = nil; … … 106 112 107 113 - (void) setNickname:(NSString *) newNickname { 108 [self setUsername:newNickname]; 114 NSParameterAssert( newNickname != nil ); 115 NSParameterAssert( [newNickname length] > 0 ); 116 MVSafeCopyAssign( &_nickname, newNickname ); 109 117 } 110 118 111 119 - (NSString *) nickname { 112 return [self username];120 return _nickname; 113 121 } 114 122 115 123 - (NSString *) preferredNickname { 116 return [self username];124 return [self nickname]; 117 125 } 118 126 … … 120 128 121 129 - (void) setNicknamePassword:(NSString *) newPassword { 122 [self setPassword:newPassword];130 // not supported 123 131 } 124 132 125 133 - (NSString *) nicknamePassword { 126 return [self password];134 return nil; 127 135 } 128 136 … … 186 194 NSParameterAssert( [identifier isKindOfClass:[NSString class]] || [identifier isKindOfClass:[JabberID class]] ); 187 195 188 if( [identifier isKindOfClass:[ JabberIDclass]] )189 identifier = [ identifier completeID];190 if( [identifier isEqual ToString:[[self localUser] uniqueIdentifier]] )196 if( [identifier isKindOfClass:[NSString class]] ) 197 identifier = [[[JabberID allocWithZone:nil] initWithString:identifier] autorelease]; 198 if( [identifier isEqual:[[self localUser] uniqueIdentifier]] ) 191 199 return [self localUser]; 192 200 … … 196 204 MVChatUser *user = nil; 197 205 @synchronized( _knownUsers ) { 198 user = [_knownUsers objectForKey: identifier];206 user = [_knownUsers objectForKey:[identifier completeID]]; 199 207 if( user ) return user; 200 208 201 JabberID *jabberID = [[JabberID alloc] initWithString:identifier]; 202 user = [[MVXMPPChatUser allocWithZone:nil] initWithJabberID:jabberID andConnection:self]; 203 if( user ) [_knownUsers setObject:user forKey:identifier]; 204 [jabberID release]; 209 user = [[MVXMPPChatUser allocWithZone:nil] initWithJabberID:identifier andConnection:self]; 210 if( user ) [_knownUsers setObject:user forKey:[identifier completeID]]; 205 211 } 206 212 207 213 return [user autorelease]; 214 } 215 216 #pragma mark - 217 218 - (void) joinChatRoomNamed:(NSString *) room withPassphrase:(NSString *) passphrase { 219 NSParameterAssert( room != nil ); 220 NSParameterAssert( [room length] > 0 ); 221 222 /* Example: 223 <presence from='hag66@shakespeare.lit/pda' to='darkcave@macbeth.shakespeare.lit/thirdwitch'> 224 <x xmlns='http://jabber.org/protocol/muc' /> 225 </presence> 226 */ 227 228 JabberID *roomId = [[JabberID allocWithZone:nil] initWithString:room]; 229 MVXMPPChatRoom *joiningRoom = (MVXMPPChatRoom *)[[self joinedChatRoomWithUniqueIdentifier:roomId] retain]; 230 if( joiningRoom && [joiningRoom isJoined] ) { 231 // already joined 232 [joiningRoom release]; 233 [roomId release]; 234 return; 235 } 236 237 JabberPresence *presence = [[JabberPresence allocWithZone:nil] initWithQName:JABBER_PRESENCE_QN]; 238 [presence putAttribute:@"from" withValue:[_localID escapedCompleteID]]; 239 240 NSString *localUserStringId = [[NSString allocWithZone:nil] initWithFormat:@"%@/%@", room, [self nickname]]; 241 [presence putAttribute:@"to" withValue:localUserStringId]; 242 243 [presence addElement:[self _capabilitiesElement]]; 244 XMLElement *x = [presence addElement:[self _multiUserChatExtensionElement]]; 245 246 if ([passphrase length]) 247 [[x addElementWithName:@"password"] addCData:passphrase]; 248 249 [_session sendElement:presence]; 250 [presence release]; 251 252 JabberID *localUserJabberId = [[JabberID allocWithZone:nil] initWithString:localUserStringId]; 253 MVXMPPChatUser *localUser = (MVXMPPChatUser *)[self chatUserWithUniqueIdentifier:localUserJabberId]; 254 [localUser _setRoomMember:YES]; 255 [localUser _setType:MVChatLocalUserType]; 256 257 if( ! joiningRoom ) 258 joiningRoom = [[MVXMPPChatRoom allocWithZone:nil] initWithJabberID:roomId andConnection:self]; 259 [joiningRoom _setLocalMemberUser:localUser]; 260 [joiningRoom _setDateJoined:nil]; 261 [joiningRoom _setDateParted:nil]; 262 [joiningRoom _clearMemberUsers]; 263 [joiningRoom _clearBannedUsers]; 264 265 [self _addJoinedRoom:joiningRoom]; 266 267 // joiningRoom will be released in incomingPresence 268 269 [localUserStringId release]; 270 [localUserJabberId release]; 271 [roomId release]; 208 272 } 209 273 … … 235 299 236 300 - (void) outgoingPacket:(NSNotification *) notification { 237 NSString *string = [@"send: " stringByAppendingString:[[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding]]; 238 NSLog(@"%@", string); 301 NSString *string = [[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding]; 302 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:string, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 303 [string release]; 239 304 } 240 305 241 306 - (void) incomingPacket:(NSNotification *) notification { 242 NSString *string = [@"recv: " stringByAppendingString:[[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding]]; 243 NSLog(@"%@", string); 244 } 245 246 - (void) incomingPrivateMessage:(NSNotification *) notification { 307 NSString *string = [[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding]; 308 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:string, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 309 [string release]; 310 } 311 312 - (void) incomingMessage:(NSNotification *) notification { 247 313 JabberMessage *message = [notification object]; 248 314 … … 252 318 case JMEVENT_NONE: { 253 319 MVChatRoom *room = nil; 254 MVChatUser *sender = [self chatUserWithUniqueIdentifier:[message from]]; 320 MVChatUser *sender = nil; 321 322 if( [[message type] isEqualToString:@"groupchat"] ) { 323 room = [self joinedChatRoomWithUniqueIdentifier:[[message from] userhostJID]]; 324 if( ! room ) return; 325 sender = [self chatUserWithUniqueIdentifier:[message from]]; 326 if( [sender isLocalUser] ) return; 327 } else { 328 sender = [self chatUserWithUniqueIdentifier:[message from]]; 329 } 330 255 331 NSMutableData *msgData = [[[message body] dataUsingEncoding:NSUTF8StringEncoding] mutableCopyWithZone:nil]; 256 332 257 333 NSMutableDictionary *msgAttributes = [[NSMutableDictionary allocWithZone:nil] init]; 258 [msgAttributes setObject:sender forKey:@" sender"];334 [msgAttributes setObject:sender forKey:@"user"]; 259 335 [msgAttributes setObject:msgData forKey:@"message"]; 260 336 … … 270 346 if( ! [msgData length] ) return; 271 347 272 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotPrivateMessageNotification object:sender userInfo:msgAttributes]; 348 if( room ) { 349 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomGotMessageNotification object:room userInfo:msgAttributes]; 350 } else { 351 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotPrivateMessageNotification object:sender userInfo:msgAttributes]; 352 } 273 353 274 354 [msgData release]; 275 355 [msgAttributes release]; 276 277 356 break; 278 357 } … … 284 363 } 285 364 } 365 366 - (void) incomingPresence:(NSNotification *) notification { 367 JabberPresence *presence = [notification object]; 368 JabberID *roomID = [[presence from] userhostJID]; 369 MVChatRoom *room = [self joinedChatRoomWithUniqueIdentifier:roomID]; 370 371 if( ! room ) return; 372 373 if ([[presence getAttribute:@"type"] isCaseInsensitiveEqualToString:@"error"]) { 374 [self _removeJoinedRoom:room]; 375 [room release]; 376 // handle error... 377 return; 378 } 379 380 MVXMPPChatUser *user = nil; 381 if( [[[room localMemberUser] uniqueIdentifier] isEqual:[presence from]] ) 382 user = (MVXMPPChatUser *)[room localMemberUser]; 383 else user = (MVXMPPChatUser *)[self chatUserWithUniqueIdentifier:[presence from]]; 384 385 if ([[presence getAttribute:@"type"] isCaseInsensitiveEqualToString:@"unavailable"]) { 386 [room _removeMemberUser:user]; 387 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomUserPartedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:user, @"user", nil]]; 388 return; 389 } 390 391 [room retain]; // retain incase the following release is the last reference 392 393 if( ! [room isJoined] ) { 394 [room _setDateJoined:[NSDate date]]; 395 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomJoinedNotification object:room]; 396 [room release]; // balance the alloc or retain in joinChatRoomNamed: 397 } 398 399 if( ! [room hasUser:user] ) { 400 [user _setRoomMember:YES]; 401 [room _addMemberUser:user]; 402 [self _markUserAsOnline:user]; 403 404 NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSArray arrayWithObject:user] forKey:@"added"]; 405 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomMemberUsersSyncedNotification object:room userInfo:userInfo]; 406 } 407 408 [room release]; 409 } 286 410 @end 287 288 411 289 412 #pragma mark - … … 297 420 return _localID; 298 421 } 422 423 - (XMLElement *) _capabilitiesElement { 424 XMLElement *caps = [[XMLElement allocWithZone:nil] initWithQName:JABBER_CLIENTCAP_QN]; 425 [caps putAttribute:@"node" withValue:@"http://colloquy.info/caps"]; 426 [caps putAttribute:@"ver" withValue:@"2.1"]; 427 return [caps autorelease]; 428 } 429 430 - (XMLElement *) _multiUserChatExtensionElement { 431 XMLQName *xQName = [XMLQName construct:@"x" withURI:@"http://jabber.org/protocol/muc"]; 432 return [[[XMLElement allocWithZone:nil] initWithQName:xQName] autorelease]; 433 } 299 434 @end trunk/Chat Core/MVXMPPChatUser.h
r3637 r3638 7 7 @interface MVXMPPChatUser : MVChatUser { 8 8 @private 9 JabberID *_identifier;9 BOOL _roomMember; 10 10 } 11 11 - (id) initLocalUserWithConnection:(MVXMPPChatConnection *) connection; 12 12 - (id) initWithJabberID:(JabberID *) identifier andConnection:(MVXMPPChatConnection *) connection; 13 13 @end 14 15 @interface MVXMPPChatUser (MVXMPPChatUserPrivate) 16 - (void) _setRoomMember:(BOOL) member; 17 - (BOOL) _isRoomMember; 18 @end trunk/Chat Core/MVXMPPChatUser.m
r3637 r3638 16 16 _type = MVChatRemoteUserType; 17 17 _connection = userConnection; // prevent circular retain 18 MVSafeRetainAssign( &_identifier, identifier ); 19 MVSafeCopyAssign( &_uniqueIdentifier, [identifier completeID] ); 18 MVSafeRetainAssign( &_uniqueIdentifier, identifier ); 20 19 } 21 20 … … 31 30 32 31 - (NSString *) displayName { 33 if( _type == MVChatWildcardUserType ) 34 return [NSString stringWithFormat:@"%@@%@", ( [self username] ? [self username] : @"*" ), ( [self address] ? [self address] : @"*" )]; 35 return [self nickname]; 32 return [self username]; 36 33 } 37 34 38 35 - (NSString *) nickname { 39 if( _type == MVChatLocalUserType ) 40 return [[self connection] username]; 41 return [_identifier username]; 36 return [self username]; 42 37 } 43 38 … … 47 42 48 43 - (NSString *) username { 44 if( _roomMember ) 45 return [_uniqueIdentifier resource]; 49 46 if( _type == MVChatLocalUserType ) 50 47 return [[self connection] username]; 51 return [_ identifier username];48 return [_uniqueIdentifier username]; 52 49 } 53 50 54 51 - (NSString *) address { 55 return [_ identifier hostname];52 return [_uniqueIdentifier hostname]; 56 53 } 57 54 58 55 - (NSString *) serverAddress { 59 return [_ identifier hostname];56 return [_uniqueIdentifier hostname]; 60 57 } 61 58 … … 75 72 NSParameterAssert( message != nil ); 76 73 77 JabberMessage *jabberMsg = [[JabberMessage alloc] initWithRecipient:_ identifier andBody:[message string]];74 JabberMessage *jabberMsg = [[JabberMessage alloc] initWithRecipient:_uniqueIdentifier andBody:[message string]]; 78 75 [jabberMsg setType:@"chat"]; 79 76 [jabberMsg addComposingRequest]; … … 82 79 } 83 80 @end 81 82 #pragma mark - 83 84 @implementation MVXMPPChatUser (MVXMPPChatUserPrivate) 85 - (void) _setRoomMember:(BOOL) member { 86 _roomMember = member; 87 } 88 89 - (BOOL) _isRoomMember { 90 return _roomMember; 91 } 92 @end trunk/Models/JVSQLChatTranscript.m
r3616 r3638 656 656 senderNickname = [member nickname]; 657 657 senderIdentifier = [[member user] uniqueIdentifier]; 658 if( [senderIdentifier isKindOfClass:[NSData class]] )659 senderIdentifier = [senderIdentifier base64Encoding];660 658 senderHostmask = [member hostmask]; 661 659 if( [member serverOperator] ) senderClass = @"server operator"; … … 673 671 senderNickname = [chatUser nickname]; 674 672 senderIdentifier = [chatUser uniqueIdentifier]; 675 if( [senderIdentifier isKindOfClass:[NSData class]] )676 senderIdentifier = [senderIdentifier base64Encoding];677 673 if( [[chatUser username] length] && [[chatUser address] length] ) 678 674 senderHostmask = [NSString stringWithFormat:@"%@@%@", [chatUser username], [chatUser address]]; 679 675 senderLocalUser = [chatUser isLocalUser]; 680 676 } 677 678 if( [senderIdentifier isKindOfClass:[NSData class]] ) 679 senderIdentifier = [senderIdentifier base64Encoding]; 680 else if( ! [senderIdentifier isKindOfClass:[NSString class]] ) 681 senderIdentifier = [senderIdentifier description]; 681 682 682 683 char userQuery[512] = "";
