Changeset 3134

Show
Ignore:
Timestamp:
02/11/06 17:15:55 (2 years ago)
Author:
timothy
Message:
  • Cleanup.
  • Added the finalize method to classes that will need it when GC is supported.
Files:

Legend:

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

    r3132 r3134  
    146146} 
    147147 
     148- (void) finalize { 
     149        [[NSNotificationCenter defaultCenter] removeObserver:self]; 
     150        [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; 
     151        [self cancelPendingReconnectAttempts]; 
     152        [super finalize]; 
     153} 
     154 
    148155- (void) dealloc { 
    149156        [[NSNotificationCenter defaultCenter] removeObserver:self]; 
     
    161168        [_proxyUsername release]; 
    162169        [_proxyPassword release]; 
    163          
     170 
    164171        _npassword = nil; 
    165172        _roomsCache = nil; 
  • branches/cocoa-networking/Chat Core/MVChatPluginManager.m

    r3072 r3134  
    3333        } 
    3434        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]; 
    3542} 
    3643 
  • branches/cocoa-networking/Chat Core/MVChatRoom.m

    r3128 r3134  
    6666 
    6767- (void) dealloc { 
    68         [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    69  
    7068        [_name release]; 
    7169        [_uniqueIdentifier release]; 
     
    288286         
    289287        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]; 
    292289        [info release]; 
    293290} 
     
    601598        [old release]; 
    602599 
    603         NSNotification *note = [NSNotification notificationWithName:MVChatRoomTopicChangedNotification object:self userInfo:nil]; 
    604         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
     600        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatRoomTopicChangedNotification object:self userInfo:nil]; 
    605601} 
    606602 
  • branches/cocoa-networking/Chat Core/MVChatUser.m

    r3128 r3134  
    114114 
    115115- (void) dealloc { 
    116         [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    117  
    118116        [_uniqueIdentifier release]; 
    119117        [_nickname release]; 
     
    426424 
    427425        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]; 
    430427        [info release]; 
    431428} 
     
    520517- (void) _setIdleTime:(NSTimeInterval) time { 
    521518        _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]; 
    525520} 
    526521 
     
    528523        if( _status == status ) return; 
    529524        _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]; 
    533526} 
    534527 
  • branches/cocoa-networking/Chat Core/MVIRCChatConnection.m

    r3132 r3134  
    271271} 
    272272 
     273- (void) finalize { 
     274        [self disconnect]; 
     275        [_chatConnection setDelegate:nil]; 
     276        _connectionThread = nil; 
     277        [super finalize]; 
     278} 
     279 
    273280- (void) dealloc { 
    274281        [self disconnect]; 
     
    323330 
    324331- (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; 
    333333 
    334334        id old = _lastConnectAttempt; 
     
    351351        [self cancelPendingReconnectAttempts]; 
    352352 
    353         if( [self status] == MVChatConnectionConnectedStatus ) { 
     353        if( _status == MVChatConnectionConnectedStatus ) { 
    354354                if( [[reason string] length] ) { 
    355355                        NSData *msg = [[self class] _flattenedIRCDataForMessage:reason withEncoding:[self encoding] andChatFormat:[self outgoingChatFormat]]; 
     
    516516 
    517517        while( ( room = [enumerator nextObject] ) ) { 
    518                 if( [room length] && [room rangeOfString:@" "].location == NSNotFound ) { // join non-password room in bulk 
     518                if( [room length] && [room rangeOfString:@" "].location == NSNotFound ) { // join non-password rooms in bulk 
    519519                        [roomList addObject:[self properNameForChatRoomNamed:room]]; 
    520520                } 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 
    523527                        [self sendRawMessageWithFormat:@"JOIN %@", [self properNameForChatRoomNamed:room]]; 
    524                         [roomList removeAllObjects]; // clear list since we joined them 
    525528                } 
    526529        } 
     
    668671} 
    669672 
     673#pragma mark - 
     674 
    670675- (void) _didDisconnect { 
    671676        [_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 
    675684        [super _didDisconnect]; 
    676685} 
     686 
     687#pragma mark - 
    677688 
    678689- (BOOL) socketWillConnect:(AsyncSocket *) sock { 
     
    873884} 
    874885 
     886#pragma mark - 
     887 
    875888- (void) _writeDataToServer:(NSData *) data { 
    876889        [_chatConnection writeData:data withTimeout:-1. tag:0]; 
     
    882895        [_chatConnection readDataToData:delimeter withTimeout:-1. tag:0]; 
    883896} 
     897 
     898#pragma mark - 
    884899 
    885900+ (NSData *) _flattenedIRCDataForMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { 
     
    902917        return [message chatFormatWithOptions:options]; 
    903918} 
    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 } 
    946919 
    947920- (void) _sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding toTarget:(NSString *) target asAction:(BOOL) action { 
     
    958931} 
    959932 
    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]; 
    969975        } 
    970976} 
     
    974980        _currentNickname = [nickname copyWithZone:nil]; 
    975981        [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        } 
    976996} 
    977997@end 
  • branches/cocoa-networking/Chat Core/MVIRCChatUser.m

    r3128 r3134  
    2222 
    2323        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]; 
    2434} 
    2535 
  • branches/cocoa-networking/Chat Core/MVIRCFileTransfer.m

    r3131 r3134  
    144144} 
    145145 
     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 
    146158- (void) release { 
    147159        if( ( [self retainCount] - 1 ) == 1 ) 
     
    151163 
    152164- (void) dealloc { 
     165        [_connection disconnect]; 
     166        [_connection setDelegate:nil]; 
     167 
    153168        id old = _fileHandle; 
    154169        _fileHandle = nil; 
     
    354369 
    355370@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 
    356384- (void) release { 
    357385        if( ( [self retainCount] - 1 ) == 1 ) 
     
    361389 
    362390- (void) dealloc { 
     391        [_connection disconnect]; 
     392        [_connection setDelegate:nil]; 
     393 
    363394        id old = _fileHandle; 
    364395        _fileHandle = nil; 
  • branches/cocoa-networking/Chat Core/MVSILCChatConnection.m

    r3132 r3134  
    4747        } 
    4848 
    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]; 
    5752} 
    5853 
     
    6762                va_end( list ); 
    6863 
    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]]; 
    7165        } 
    7266} 
     
    10195        if( ! msgData ) msgData = [NSData dataWithBytes:message length:message_len]; 
    10296 
    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]]; 
    10598} 
    10699 
     
    133126        if( ! msgData ) msgData = [NSData dataWithBytes:message length:message_len]; 
    134127 
    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]]; 
    137129} 
    138130 
     
    148140                        if( message ) { 
    149141                                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]]; 
    152143                        } 
    153144                }       break; 
     
    156147                        if( message ) { 
    157148                                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]]; 
    160150                        } 
    161151                }       break; 
     
    175165                                if( ! [room isJoined] || ! [room hasUser:member] ) continue; 
    176166                                [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]; 
    179168                        } 
    180169 
     
    206195                                break; 
    207196 
    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]]; 
    210198                }       break; 
    211199                case SILC_NOTIFY_TYPE_SERVER_SIGNOFF: { 
     
    232220                                        if( ! [room isJoined] || ! [room hasUser:member] ) continue; 
    233221                                        [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]; 
    236223                                } 
    237224 
     
    271258                                [member _setServerOperator:YES]; 
    272259 
    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]]; 
    275261                }       break; 
    276262                case SILC_NOTIFY_TYPE_LEAVE: { 
     
    285271                        [room _removeMemberUser:member]; 
    286272 
    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]]; 
    289274                }       break; 
    290275                case SILC_NOTIFY_TYPE_TOPIC_SET: { 
     
    333318                                [room _removeMode:m forMemberUser:member]; 
    334319 
    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]]; 
    337321                        } else if( ! ( oldModes & MVChatRoomMemberFounderMode ) && ( mode & SILC_CHANNEL_UMODE_CHANFO ) ) { 
    338322                                enabled = YES; 
     
    341325                                [room _setMode:m forMemberUser:member]; 
    342326 
    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]]; 
    345328                        } 
    346329 
     
    351334                                [room _removeMode:m forMemberUser:member]; 
    352335 
    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]]; 
    355337                        } else if( ! ( oldModes & MVChatRoomMemberOperatorMode ) && ( mode & SILC_CHANNEL_UMODE_CHANOP ) ) { 
    356338                                enabled = YES; 
     
    359341                                [room _setMode:m forMemberUser:member]; 
    360342 
    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]]; 
    363344                        } 
    364345 
     
    369350                                [room _removeMode:m forMemberUser:member]; 
    370351 
    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]]; 
    373353                        } else if( ! ( oldModes & MVChatRoomMemberQuietedMode ) && ( mode & SILC_CHANNEL_UMODE_QUIET ) ) { 
    374354                                enabled = YES; 
     
    377357                                [room _setMode:m forMemberUser:member]; 
    378358 
    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]]; 
    381360                        } 
    382361                }       break; 
     
    392371 
    393372                        NSData *msgData = ( kick_message ? [[NSData allocWithZone:nil] initWithBytes:kick_message length:strlen( kick_message )] : nil ); 
    394                         NSNotification *note = nil; 
    395373 
    396374                        MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
     
    400378 
    401379                        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]]; 
    403381                        } 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]]; 
    405383                        } 
    406384 
    407                         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
    408385                        [msgData release]; 
    409386                }       break; 
     
    458435                                if( ! [room isJoined] || ! [room hasUser:member] ) continue; 
    459436                                [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]; 
    462438                        } 
    463439 
     
    482458 
    483459                        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]]; 
    486461                }       break; 
    487462        } 
     
    555530                        [chanArray release]; 
    556531                } 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]; 
    560534        }       break; 
    561535        case SILC_COMMAND_WHOWAS: 
     
    580554                } 
    581555 
    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]]; 
    584557        }       break; 
    585558        case SILC_COMMAND_LIST: { 
     
    675648                MVChatRoom *room = [self joinedChatRoomWithName:[NSString stringWithUTF8String:channel -> channel_name]]; 
    676649                [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]; 
    679651        }       break; 
    680652        case SILC_COMMAND_USERS: 
     
    831803        [dict setObject:[NSNumber numberWithUnsignedInt:SILC_PTR_TO_32(conn)] forKey:@"silcConn"]; 
    832804 
    833         NSNotification *note = [NSNotification notificationWithName:MVChatConnectionNeedPublicKeyVerificationNotification object:self userInfo:dict]; 
    834         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
     805        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionNeedPublicKeyVerificationNotification object:self userInfo:dict]; 
    835806} 
    836807 
     
    864835        MVChatUser *user = [self _chatUserWithClientEntry:client_entry]; 
    865836        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]; */ 
    868838} 
    869839 
     
    937907} 
    938908 
    939 - (void) dealloc { 
     909- (void) finalize { 
     910        [[NSNotificationCenter defaultCenter] removeObserver:self]; 
     911 
    940912        [self disconnect]; 
    941913 
     
    951923        // we only stop if we have an scheduler - silc client is actually running 
    952924        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 ); 
    954948        _silcClient = NULL; 
    955949 
     
    13371331                SilcUnlock( [self _silcClient] ); 
    13381332 
    1339                 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 
    1340                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
     1333                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 
    13411334        } else { 
    13421335                [self sendRawMessage:@"UMODE -g"]; 
     
    13461339                SilcUnlock( [self _silcClient] ); 
    13471340 
    1348                 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 
    1349                 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
     1341                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionSelfAwayStatusChangedNotification object:self userInfo:nil]; 
    13501342        } 
    13511343} 
     
    14511443        if( requestPassword ) { 
    14521444                _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]; 
    14571446                return NO; 
    14581447        } 
    14591448 
    1460         NSNotification *note = [NSNotification notificationWithName:MVSILCChatConnectionLoadedCertificate object:self userInfo:nil]; 
    1461         [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 
     1449        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVSILCChatConnectionLoadedCertificate object:self userInfo:nil]; 
    14621450 
    14631451        return YES; 
     
    15161504 
    15171505- (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]]; 
    15201507} 
    15211508 
    15221509- (void) _sendCommandFailedNotify:(NSString *) message { 
    15231510        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]]; 
    15261512} 
    15271513 
  • branches/cocoa-networking/Chat Core/MVSILCChatRoom.m

    r3072 r3134  
    77        if( ( self = [self init] ) ) { 
    88                _connection = connection; // prevent circular retain 
    9                  
    109                [self updateWithChannelEntry:channelEntry]; 
    1110        } 
     
    2019 
    2120        SilcLock( [connection _silcClient] ); 
    22          
     21 
    2322        [_name release]; 
    2423        _name = [[NSString allocWithZone:nil] initWithUTF8String:channelEntry -> channel_name]; 
     
    2827        unsigned len = silc_id_get_len( channelEntry -> id, SILC_ID_CHANNEL ); 
    2928        _uniqueIdentifier = [[NSData allocWithZone:nil] initWithBytes:identifier length:len]; 
    30          
     29 
    3130        _channelEntry = channelEntry; 
    32          
     31 
    3332        SilcUnlock( [connection _silcClient] ); 
    3433} 
  • branches/cocoa-networking/Chat Core/MVSILCChatUser.m

    r3072 r3134  
    2424                _type = MVChatRemoteUserType; 
    2525                _connection = connection; // prevent circular retain 
    26  
    2726                [self updateWithClientEntry:clientEntry]; 
    2827        } 
     
    6968        [self _setUniqueIdentifier:[NSData dataWithBytes:identifier length:len]]; 
    7069 
    71         self -> _clientEntry = clientEntry; 
     70        _clientEntry = clientEntry; 
    7271 
    7372        SilcUnlock( [[self connection] _silcClient] ); 
  • branches/cocoa-networking/Chat Core/MVSILCFileTransfer.m

    r3099 r3134  
    1717                        [transfer _setStatus:MVFileTransferNormalStatus]; 
    1818 
    19                         NSNotification *note = [NSNotification notificationWithName:MVFileTransferStartedNotification object:transfer]; 
    20               &nbs