Changeset 3134
- Timestamp:
- 02/11/06 17:15:55 (2 years ago)
- Files:
-
- branches/cocoa-networking/Chat Core/MVChatConnection.m (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVChatPluginManager.m (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVChatRoom.m (modified) (3 diffs)
- branches/cocoa-networking/Chat Core/MVChatUser.m (modified) (4 diffs)
- branches/cocoa-networking/Chat Core/MVIRCChatConnection.m (modified) (10 diffs)
- branches/cocoa-networking/Chat Core/MVIRCChatUser.m (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m (modified) (4 diffs)
- branches/cocoa-networking/Chat Core/MVSILCChatConnection.m (modified) (32 diffs)
- branches/cocoa-networking/Chat Core/MVSILCChatRoom.m (modified) (3 diffs)
- branches/cocoa-networking/Chat Core/MVSILCChatUser.m (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVSILCFileTransfer.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cocoa-networking/Chat Core/MVChatConnection.m
r3132 r3134 146 146 } 147 147 148 - (void) finalize { 149 [[NSNotificationCenter defaultCenter] removeObserver:self]; 150 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; 151 [self cancelPendingReconnectAttempts]; 152 [super finalize]; 153 } 154 148 155 - (void) dealloc { 149 156 [[NSNotificationCenter defaultCenter] removeObserver:self]; … … 161 168 [_proxyUsername release]; 162 169 [_proxyPassword release]; 163 170 164 171 _npassword = nil; 165 172 _roomsCache = nil; branches/cocoa-networking/Chat Core/MVChatPluginManager.m
r3072 r3134 33 33 } 34 34 return self; 35 } 36 37 - (void) finalize { 38 extern MVChatPluginManager *sharedInstance; 39 [[NSNotificationCenter defaultCenter] removeObserver:self]; 40 if( self == sharedInstance ) sharedInstance = nil; 41 [super finalize]; 35 42 } 36 43 branches/cocoa-networking/Chat Core/MVChatRoom.m
r3128 r3134 66 66 67 67 - (void) dealloc { 68 [[NSNotificationCenter defaultCenter] removeObserver:self];69 70 68 [_name release]; 71 69 [_uniqueIdentifier release]; … … 288 286 289 287 NSDictionary *info = [[NSDictionary allocWithZone:nil] initWithObjectsAndKeys:key, @"attribute", nil]; 290 NSNotification *note = [NSNotification notificationWithName:MVChatRoomAttributeUpdatedNotification object:self userInfo:info]; 291 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 288 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomAttributeUpdatedNotification object:self userInfo:info]; 292 289 [info release]; 293 290 } … … 601 598 [old release]; 602 599 603 NSNotification *note = [NSNotification notificationWithName:MVChatRoomTopicChangedNotification object:self userInfo:nil]; 604 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 600 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomTopicChangedNotification object:self userInfo:nil]; 605 601 } 606 602 branches/cocoa-networking/Chat Core/MVChatUser.m
r3128 r3134 114 114 115 115 - (void) dealloc { 116 [[NSNotificationCenter defaultCenter] removeObserver:self];117 118 116 [_uniqueIdentifier release]; 119 117 [_nickname release]; … … 426 424 427 425 NSDictionary *info = [[NSDictionary allocWithZone:nil] initWithObjectsAndKeys:key, @"attribute", nil]; 428 NSNotification *note = [NSNotification notificationWithName:MVChatUserAttributeUpdatedNotification object:self userInfo:info]; 429 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 426 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserAttributeUpdatedNotification object:self userInfo:info]; 430 427 [info release]; 431 428 } … … 520 517 - (void) _setIdleTime:(NSTimeInterval) time { 521 518 _idleTime = time; 522 523 NSNotification *note = [NSNotification notificationWithName:MVChatUserIdleTimeUpdatedNotification object:self userInfo:nil]; 524 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 519 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserIdleTimeUpdatedNotification object:self userInfo:nil]; 525 520 } 526 521 … … 528 523 if( _status == status ) return; 529 524 _status = status; 530 531 NSNotification *note = [NSNotification notificationWithName:MVChatUserStatusChangedNotification object:self userInfo:nil]; 532 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 525 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserStatusChangedNotification object:self userInfo:nil]; 533 526 } 534 527 branches/cocoa-networking/Chat Core/MVIRCChatConnection.m
r3132 r3134 271 271 } 272 272 273 - (void) finalize { 274 [self disconnect]; 275 [_chatConnection setDelegate:nil]; 276 _connectionThread = nil; 277 [super finalize]; 278 } 279 273 280 - (void) dealloc { 274 281 [self disconnect]; … … 323 330 324 331 - (void) connect { 325 if( [self status] != MVChatConnectionDisconnectedStatus && [self status] != MVChatConnectionServerDisconnectedStatus && [self status] != MVChatConnectionSuspendedStatus ) return; 326 327 if( _lastConnectAttempt && ABS( [_lastConnectAttempt timeIntervalSinceNow] ) < 5. ) { 328 // prevents connecting too quick 329 // cancel any reconnect attempts, this lets a user cancel the attempts with a "double connect" 330 [self cancelPendingReconnectAttempts]; 331 return; 332 } 332 if( _status != MVChatConnectionDisconnectedStatus && _status != MVChatConnectionServerDisconnectedStatus && _status != MVChatConnectionSuspendedStatus ) return; 333 333 334 334 id old = _lastConnectAttempt; … … 351 351 [self cancelPendingReconnectAttempts]; 352 352 353 if( [self status]== MVChatConnectionConnectedStatus ) {353 if( _status == MVChatConnectionConnectedStatus ) { 354 354 if( [[reason string] length] ) { 355 355 NSData *msg = [[self class] _flattenedIRCDataForMessage:reason withEncoding:[self encoding] andChatFormat:[self outgoingChatFormat]]; … … 516 516 517 517 while( ( room = [enumerator nextObject] ) ) { 518 if( [room length] && [room rangeOfString:@" "].location == NSNotFound ) { // join non-password room in bulk518 if( [room length] && [room rangeOfString:@" "].location == NSNotFound ) { // join non-password rooms in bulk 519 519 [roomList addObject:[self properNameForChatRoomNamed:room]]; 520 520 } else if( [room length] && [room rangeOfString:@" "].location != NSNotFound ) { // has a password, join separately 521 // join all requested rooms before this one so we do things in order 522 if( [roomList count] ) [self sendRawMessageWithFormat:@"JOIN %@", [roomList componentsJoinedByString:@","]]; 521 if( [roomList count] ) { 522 // join all requested rooms before this one so we do things in order 523 [self sendRawMessageWithFormat:@"JOIN %@", [roomList componentsJoinedByString:@","]]; 524 [roomList removeAllObjects]; // clear list since we joined them 525 } 526 523 527 [self sendRawMessageWithFormat:@"JOIN %@", [self properNameForChatRoomNamed:room]]; 524 [roomList removeAllObjects]; // clear list since we joined them525 528 } 526 529 } … … 668 671 } 669 672 673 #pragma mark - 674 670 675 - (void) _didDisconnect { 671 676 [_knownUsers removeAllObjects]; 672 if( ABS( [_lastConnectAttempt timeIntervalSinceNow] ) > 300. ) 673 [self performSelector:@selector( connect ) withObject:nil afterDelay:5.]; 674 [self scheduleReconnectAttemptEvery:30.]; 677 678 if( _status == MVChatConnectionServerDisconnectedStatus ) { 679 if( ABS( [_lastConnectAttempt timeIntervalSinceNow] ) > 300. ) 680 [self performSelector:@selector( connect ) withObject:nil afterDelay:5.]; 681 [self scheduleReconnectAttemptEvery:30.]; 682 } 683 675 684 [super _didDisconnect]; 676 685 } 686 687 #pragma mark - 677 688 678 689 - (BOOL) socketWillConnect:(AsyncSocket *) sock { … … 873 884 } 874 885 886 #pragma mark - 887 875 888 - (void) _writeDataToServer:(NSData *) data { 876 889 [_chatConnection writeData:data withTimeout:-1. tag:0]; … … 882 895 [_chatConnection readDataToData:delimeter withTimeout:-1. tag:0]; 883 896 } 897 898 #pragma mark - 884 899 885 900 + (NSData *) _flattenedIRCDataForMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { … … 902 917 return [message chatFormatWithOptions:options]; 903 918 } 904 /*905 906 #pragma mark -907 908 - (void) _processErrorCode:(int) errorCode withContext:(char *) context {909 NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];910 NSError *error = nil;911 912 [userInfo setObject:self forKey:@"connection"];913 914 switch( errorCode ) {915 case ERR_NOSUCHNICK: {916 MVChatUser *user = [self chatUserWithUniqueIdentifier:[self stringWithEncodedBytes:context]];917 [user _setStatus:MVChatUserOfflineStatus];918 [userInfo setObject:user forKey:@"user"];919 [userInfo setObject:[NSString stringWithFormat:NSLocalizedString( @"The user \"%@\" is no longer connected (or never was connected) to the \"%@\" server.", "user not on the server" ), [user nickname], [self server]] forKey:NSLocalizedDescriptionKey];920 error = [NSError errorWithDomain:MVChatConnectionErrorDomain code:MVChatConnectionNoSuchUserError userInfo:userInfo];921 break;922 }923 case ERR_UNKNOWNCOMMAND: {924 NSString *command = [self stringWithEncodedBytes:context];925 [userInfo setObject:command forKey:@"command"];926 [userInfo setObject:[NSString stringWithFormat:NSLocalizedString( @"The command \"%@\" is not a valid command on the \"%@\" server.", "user not on the server" ), command, [self server]] forKey:NSLocalizedDescriptionKey];927 error = [NSError errorWithDomain:MVChatConnectionErrorDomain code:MVChatConnectionUnknownCommandError userInfo:userInfo];928 break;929 }930 }931 932 if( error ) [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO];933 }934 */935 936 - (void) _updateKnownUser:(MVChatUser *) user withNewNickname:(NSString *) nickname {937 @synchronized( _knownUsers ) {938 [user retain];939 [_knownUsers removeObjectForKey:[user uniqueIdentifier]];940 [user _setUniqueIdentifier:[nickname lowercaseString]];941 [user _setNickname:nickname];942 [_knownUsers setObject:user forKey:[user uniqueIdentifier]];943 [user release];944 }945 }946 919 947 920 - (void) _sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding toTarget:(NSString *) target asAction:(BOOL) action { … … 958 931 } 959 932 960 - (void) _addFileTransfer:(MVFileTransfer *) transfer { 961 @synchronized( _fileTransfers ) { 962 if( transfer ) [_fileTransfers addObject:transfer]; 963 } 964 } 965 966 - (void) _removeFileTransfer:(MVFileTransfer *) transfer { 967 @synchronized( _fileTransfers ) { 968 if( transfer ) [_fileTransfers removeObject:transfer]; 933 /* 934 935 #pragma mark - 936 937 - (void) _processErrorCode:(int) errorCode withContext:(char *) context { 938 NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; 939 NSError *error = nil; 940 941 [userInfo setObject:self forKey:@"connection"]; 942 943 switch( errorCode ) { 944 case ERR_NOSUCHNICK: { 945 MVChatUser *user = [self chatUserWithUniqueIdentifier:[self stringWithEncodedBytes:context]]; 946 [user _setStatus:MVChatUserOfflineStatus]; 947 [userInfo setObject:user forKey:@"user"]; 948 [userInfo setObject:[NSString stringWithFormat:NSLocalizedString( @"The user \"%@\" is no longer connected (or never was connected) to the \"%@\" server.", "user not on the server" ), [user nickname], [self server]] forKey:NSLocalizedDescriptionKey]; 949 error = [NSError errorWithDomain:MVChatConnectionErrorDomain code:MVChatConnectionNoSuchUserError userInfo:userInfo]; 950 break; 951 } 952 case ERR_UNKNOWNCOMMAND: { 953 NSString *command = [self stringWithEncodedBytes:context]; 954 [userInfo setObject:command forKey:@"command"]; 955 [userInfo setObject:[NSString stringWithFormat:NSLocalizedString( @"The command \"%@\" is not a valid command on the \"%@\" server.", "user not on the server" ), command, [self server]] forKey:NSLocalizedDescriptionKey]; 956 error = [NSError errorWithDomain:MVChatConnectionErrorDomain code:MVChatConnectionUnknownCommandError userInfo:userInfo]; 957 break; 958 } 959 } 960 961 if( error ) [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 962 } 963 */ 964 965 #pragma mark - 966 967 - (void) _updateKnownUser:(MVChatUser *) user withNewNickname:(NSString *) nickname { 968 @synchronized( _knownUsers ) { 969 [user retain]; 970 [_knownUsers removeObjectForKey:[user uniqueIdentifier]]; 971 [user _setUniqueIdentifier:[nickname lowercaseString]]; 972 [user _setNickname:nickname]; 973 [_knownUsers setObject:user forKey:[user uniqueIdentifier]]; 974 [user release]; 969 975 } 970 976 } … … 974 980 _currentNickname = [nickname copyWithZone:nil]; 975 981 [old release]; 982 } 983 984 #pragma mark - 985 986 - (void) _addFileTransfer:(MVFileTransfer *) transfer { 987 @synchronized( _fileTransfers ) { 988 if( transfer ) [_fileTransfers addObject:transfer]; 989 } 990 } 991 992 - (void) _removeFileTransfer:(MVFileTransfer *) transfer { 993 @synchronized( _fileTransfers ) { 994 if( transfer ) [_fileTransfers removeObject:transfer]; 995 } 976 996 } 977 997 @end branches/cocoa-networking/Chat Core/MVIRCChatUser.m
r3128 r3134 22 22 23 23 return self; 24 } 25 26 - (void) finalize { 27 [[NSNotificationCenter defaultCenter] removeObserver:self]; 28 [super finalize]; 29 } 30 31 - (void) dealloc { 32 [[NSNotificationCenter defaultCenter] removeObserver:self]; 33 [super dealloc]; 24 34 } 25 35 branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m
r3131 r3134 144 144 } 145 145 146 - (void) finalize { 147 [_connection disconnect]; 148 [_connection setDelegate:nil]; 149 150 [_fileHandle closeFile]; 151 _fileHandle = nil; 152 153 _connectionThread = nil; 154 155 [super finalize]; 156 } 157 146 158 - (void) release { 147 159 if( ( [self retainCount] - 1 ) == 1 ) … … 151 163 152 164 - (void) dealloc { 165 [_connection disconnect]; 166 [_connection setDelegate:nil]; 167 153 168 id old = _fileHandle; 154 169 _fileHandle = nil; … … 354 369 355 370 @implementation MVIRCDownloadFileTransfer 371 - (void) finalize { 372 [_connection disconnect]; 373 [_connection setDelegate:nil]; 374 375 [_fileHandle closeFile]; 376 [_fileHandle synchronizeFile]; 377 _fileHandle = nil; 378 379 _connectionThread = nil; 380 381 [super finalize]; 382 } 383 356 384 - (void) release { 357 385 if( ( [self retainCount] - 1 ) == 1 ) … … 361 389 362 390 - (void) dealloc { 391 [_connection disconnect]; 392 [_connection setDelegate:nil]; 393 363 394 id old = _fileHandle; 364 395 _fileHandle = nil; branches/cocoa-networking/Chat Core/MVSILCChatConnection.m
r3132 r3134 47 47 } 48 48 49 NSNotification *note = [NSNotification notificationWithName:MVChatRoomJoinedNotification object:room userInfo:nil]; 50 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 51 52 note = [NSNotification notificationWithName:MVChatRoomMemberUsersSyncedNotification object:room userInfo:nil]; 53 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 54 55 note = [NSNotification notificationWithName:MVChatRoomBannedUsersSyncedNotification object:room userInfo:nil]; 56 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 49 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomJoinedNotification object:room userInfo:nil]; 50 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomMemberUsersSyncedNotification object:room userInfo:nil]; 51 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomBannedUsersSyncedNotification object:room userInfo:nil]; 57 52 } 58 53 … … 67 62 va_end( list ); 68 63 69 NSNotification *rawMessageNote = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 70 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:rawMessageNote]; 64 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 71 65 } 72 66 } … … 101 95 if( ! msgData ) msgData = [NSData dataWithBytes:message length:message_len]; 102 96 103 NSNotification *note = [NSNotification notificationWithName:MVChatRoomGotMessageNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:user, @"user", msgData, @"message", [NSString locallyUniqueString], @"identifier", mimeType, @"mimeType", [NSNumber numberWithBool:action], @"action", nil]]; 104 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 97 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomGotMessageNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:user, @"user", msgData, @"message", [NSString locallyUniqueString], @"identifier", mimeType, @"mimeType", [NSNumber numberWithBool:action], @"action", nil]]; 105 98 } 106 99 … … 133 126 if( ! msgData ) msgData = [NSData dataWithBytes:message length:message_len]; 134 127 135 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionGotPrivateMessageNotification object:user userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgData, @"message", [NSString locallyUniqueString], @"identifier", mimeType, @"mimeType", [NSNumber numberWithBool:action], @"action", nil]]; 136 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 128 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotPrivateMessageNotification object:user userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgData, @"message", [NSString locallyUniqueString], @"identifier", mimeType, @"mimeType", [NSNumber numberWithBool:action], @"action", nil]]; 137 129 } 138 130 … … 148 140 if( message ) { 149 141 NSString *msgString = [NSString stringWithUTF8String:message]; 150 NSNotification *rawMessageNote = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 151 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:rawMessageNote]; 142 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 152 143 } 153 144 } break; … … 156 147 if( message ) { 157 148 NSString *msgString = [NSString stringWithUTF8String:message]; 158 NSNotification *rawMessageNote = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 159 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:rawMessageNote]; 149 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:msgString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 160 150 } 161 151 } break; … … 175 165 if( ! [room isJoined] || ! [room hasUser:member] ) continue; 176 166 [room _removeMemberUser:member]; 177 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 178 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 167 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 179 168 } 180 169 … … 206 195 break; 207 196 208 NSNotification *note = [NSNotification notificationWithName:MVChatUserNicknameChangedNotification object:user userInfo:[NSDictionary dictionaryWithObjectsAndKeys:oldNickname, @"oldNickname", nil]]; 209 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 197 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserNicknameChangedNotification object:user userInfo:[NSDictionary dictionaryWithObjectsAndKeys:oldNickname, @"oldNickname", nil]]; 210 198 } break; 211 199 case SILC_NOTIFY_TYPE_SERVER_SIGNOFF: { … … 232 220 if( ! [room isJoined] || ! [room hasUser:member] ) continue; 233 221 [room _removeMemberUser:member]; 234 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 235 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 222 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 236 223 } 237 224 … … 271 258 [member _setServerOperator:YES]; 272 259 273 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserJoinedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", nil]]; 274 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 260 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserJoinedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", nil]]; 275 261 } break; 276 262 case SILC_NOTIFY_TYPE_LEAVE: { … … 285 271 [room _removeMemberUser:member]; 286 272 287 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserPartedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", nil]]; 288 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 273 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserPartedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", nil]]; 289 274 } break; 290 275 case SILC_NOTIFY_TYPE_TOPIC_SET: { … … 333 318 [room _removeMode:m forMemberUser:member]; 334 319 335 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 336 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 320 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 337 321 } else if( ! ( oldModes & MVChatRoomMemberFounderMode ) && ( mode & SILC_CHANNEL_UMODE_CHANFO ) ) { 338 322 enabled = YES; … … 341 325 [room _setMode:m forMemberUser:member]; 342 326 343 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 344 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 327 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 345 328 } 346 329 … … 351 334 [room _removeMode:m forMemberUser:member]; 352 335 353 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 354 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 336 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 355 337 } else if( ! ( oldModes & MVChatRoomMemberOperatorMode ) && ( mode & SILC_CHANNEL_UMODE_CHANOP ) ) { 356 338 enabled = YES; … … 359 341 [room _setMode:m forMemberUser:member]; 360 342 361 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 362 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 343 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 363 344 } 364 345 … … 369 350 [room _removeMode:m forMemberUser:member]; 370 351 371 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 372 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 352 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 373 353 } else if( ! ( oldModes & MVChatRoomMemberQuietedMode ) && ( mode & SILC_CHANNEL_UMODE_QUIET ) ) { 374 354 enabled = YES; … … 377 357 [room _setMode:m forMemberUser:member]; 378 358 379 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 380 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 359 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserModeChangedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"who", [NSNumber numberWithBool:enabled], @"enabled", [NSNumber numberWithUnsignedInt:m], @"mode", changerUser, @"by", nil]]; 381 360 } 382 361 } break; … … 392 371 393 372 NSData *msgData = ( kick_message ? [[NSData allocWithZone:nil] initWithBytes:kick_message length:strlen( kick_message )] : nil ); 394 NSNotification *note = nil;395 373 396 374 MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; … … 400 378 401 379 if( kicked == conn -> local_entry ) { 402 note = [NSNotification notificationWithName:MVChatRoomKickedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:byMember, @"byUser", msgData, @"reason", nil]];380 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomKickedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:byMember, @"byUser", msgData, @"reason", nil]]; 403 381 } else { 404 note = [NSNotification notificationWithName:MVChatRoomUserKickedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", byMember, @"byUser", msgData, @"reason", nil]];382 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserKickedNotification object:room userInfo:[NSDictionary dictionaryWithObjectsAndKeys:member, @"user", byMember, @"byUser", msgData, @"reason", nil]]; 405 383 } 406 384 407 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note];408 385 [msgData release]; 409 386 } break; … … 458 435 if( ! [room isJoined] || ! [room hasUser:member] ) continue; 459 436 [room _removeMemberUser:member]; 460 NSNotification *note = [NSNotification notificationWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 461 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 437 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomUserPartedNotification object:room userInfo:info]; 462 438 } 463 439 … … 482 458 483 459 MVChatUser *user = [self _chatUserWithClientEntry:inviter]; 484 NSNotification *note = [NSNotification notificationWithName:MVChatRoomInvitedNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:user, @"user", channelName, @"room", nil]]; 485 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 460 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomInvitedNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:user, @"user", channelName, @"room", nil]]; 486 461 } break; 487 462 } … … 555 530 [chanArray release]; 556 531 } else [user setAttribute:nil forKey:MVChatUserKnownRoomsAttribute]; 557 558 NSNotification *note = [NSNotification notificationWithName:MVChatUserInformationUpdatedNotification object:user userInfo:nil]; 559 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 532 533 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatUserInformationUpdatedNotification object:user userInfo:nil]; 560 534 } break; 561 535 case SILC_COMMAND_WHOWAS: … … 580 554 } 581 555 582 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionNicknameAcceptedNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithUTF8String:nickname], @"nickname", nil]]; 583 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 556 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionNicknameAcceptedNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithUTF8String:nickname], @"nickname", nil]]; 584 557 } break; 585 558 case SILC_COMMAND_LIST: { … … 675 648 MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 676 649 [room _setDateParted:[NSDate date]]; 677 NSNotification *note = [NSNotification notificationWithName:MVChatRoomPartedNotification object:room userInfo:nil]; 678 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 650 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomPartedNotification object:room userInfo:nil]; 679 651 } break; 680 652 case SILC_COMMAND_USERS: … … 831 803 [dict setObject:[NSNumber numberWithUnsignedInt:SILC_PTR_TO_32(conn)] forKey:@"silcConn"]; 832 804 833 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionNeedPublicKeyVerificationNotification object:self userInfo:dict]; 834 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 805 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionNeedPublicKeyVerificationNotification object:self userInfo:dict]; 835 806 } 836 807 … … 864 835 MVChatUser *user = [self _chatUserWithClientEntry:client_entry]; 865 836 MVSILCDownloadFileTransfer *transfer = [[[MVSILCDownloadFileTransfer allocWithZone:nil] initWithSessionID:session_id toUser:user] 866 NSNotification *note = [NSNotification notificationWithName:MVDownloadFileTransferOfferNotification object:transfer]; 867 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; */ 837 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVDownloadFileTransferOfferNotification object:transfer]; */ 868 838 } 869 839 … … 937 907 } 938 908 939 - (void) dealloc { 909 - (void) finalize { 910 [[NSNotificationCenter defaultCenter] removeObserver:self]; 911 940 912 [self disconnect]; 941 913 … … 951 923 // we only stop if we have an scheduler - silc client is actually running 952 924 if( _silcClient -> schedule ) silc_client_stop( _silcClient ); 953 silc_client_free( _silcClient ); 925 if( _silcClient ) silc_client_free( _silcClient ); 926 _silcClient = NULL; 927 928 [super finalize]; 929 } 930 931 - (void) dealloc { 932 [[NSNotificationCenter defaultCenter] removeObserver:self]; 933 934 [self disconnect]; 935 936 // if we don't have a scheduler, we don't have a lock. but we don't need to 937 // lock anything anyway, because silc can't be connected without scheduler ... 938 if( _silcClient -> schedule ) SilcLock( _silcClient ); 939 if( _silcClient -> realname ) free( _silcClient -> realname ); 940 if( _silcClient -> username ) free( _silcClient -> username ); 941 if( _silcClient -> hostname ) free( _silcClient -> hostname ); 942 if( _silcClient -> nickname ) free( _silcClient -> nickname ); 943 if( _silcClient -> schedule ) SilcUnlock( _silcClient ); 944 945 // we only stop if we have an scheduler - silc client is actually running 946 if( _silcClient -> schedule ) silc_client_stop( _silcClient ); 947 if( _silcClient ) silc_client_free( _silcClient ); 954 948 _silcClient = NULL; 955 949 … … 1337 1331 SilcUnlock( [self _silcClient] ); 1338 1332 1339 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 1340 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 1333 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 1341 1334 } else { 1342 1335 [self sendRawMessage:@"UMODE -g"]; … … 1346 1339 SilcUnlock( [self _silcClient] ); 1347 1340 1348 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 1349 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 1341 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 1350 1342 } 1351 1343 } … … 1451 1443 if( requestPassword ) { 1452 1444 _waitForCertificatePassword = YES; 1453 1454 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionNeedCertificatePasswordNotification object:self userInfo:nil]; 1455 [[NSNotificationCenter defaultCenter] postNotification:note]; 1456 1445 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionNeedCertificatePasswordNotification object:self userInfo:nil]; 1457 1446 return NO; 1458 1447 } 1459 1448 1460 NSNotification *note = [NSNotification notificationWithName:MVSILCChatConnectionLoadedCertificate object:self userInfo:nil]; 1461 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 1449 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVSILCChatConnectionLoadedCertificate object:self userInfo:nil]; 1462 1450 1463 1451 return YES; … … 1516 1504 1517 1505 - (void) _sendCommandSucceededNotify:(NSString *) message { 1518 NSNotification *rawMessageNote = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:message, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 1519 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:rawMessageNote]; 1506 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:message, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 1520 1507 } 1521 1508 1522 1509 - (void) _sendCommandFailedNotify:(NSString *) message { 1523 1510 NSString *raw = [NSString stringWithFormat:@"Command failed: %@", message]; 1524 NSNotification *rawMessageNote = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:raw, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 1525 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:rawMessageNote]; 1511 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:raw, @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 1526 1512 } 1527 1513 branches/cocoa-networking/Chat Core/MVSILCChatRoom.m
r3072 r3134 7 7 if( ( self = [self init] ) ) { 8 8 _connection = connection; // prevent circular retain 9 10 9 [self updateWithChannelEntry:channelEntry]; 11 10 } … … 20 19 21 20 SilcLock( [connection _silcClient] ); 22 21 23 22 [_name release]; 24 23 _name = [[NSString allocWithZone:nil] initWithUTF8String:channelEntry -> channel_name]; … … 28 27 unsigned len = silc_id_get_len( channelEntry -> id, SILC_ID_CHANNEL ); 29 28 _uniqueIdentifier = [[NSData allocWithZone:nil] initWithBytes:identifier length:len]; 30 29 31 30 _channelEntry = channelEntry; 32 31 33 32 SilcUnlock( [connection _silcClient] ); 34 33 } branches/cocoa-networking/Chat Core/MVSILCChatUser.m
r3072 r3134 24 24 _type = MVChatRemoteUserType; 25 25 _connection = connection; // prevent circular retain 26 27 26 [self updateWithClientEntry:clientEntry]; 28 27 } … … 69 68 [self _setUniqueIdentifier:[NSData dataWithBytes:identifier length:len]]; 70 69 71 self ->_clientEntry = clientEntry;70 _clientEntry = clientEntry; 72 71 73 72 SilcUnlock( [[self connection] _silcClient] ); branches/cocoa-networking/Chat Core/MVSILCFileTransfer.m
r3099 r3134 17 17 [transfer _setStatus:MVFileTransferNormalStatus]; 18 18 19 NSNotification *note = [NSNotification notificationWithName:MVFileTransferStartedNotification object:transfer]; 20 &nbs
