@@ -136,11 +136,11 @@ _port = port; _SOCKS5Host = [SOCKS5Host copy]; _SOCKS5Port = SOCKS5Port; _delegate = [delegate retain]; - [_socket setDelegate: self]; + _socket.delegate = self; } @catch (id e) { [self release]; @throw e; } @@ -174,14 +174,14 @@ #endif - (void)dealloc { #ifdef OF_HAVE_BLOCKS - if (_block != NULL) + if (_block == NULL) #endif - if ([_socket delegate] == self) - [_socket setDelegate: _delegate]; + if (_socket.delegate == self) + _socket.delegate = _delegate; [_socket release]; [_host release]; [_SOCKS5Host release]; [_delegate release]; @@ -196,18 +196,18 @@ } - (void)didConnect { if (_exception == nil) - [_socket setBlocking: true]; + _socket.blocking = true; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_socket, _exception); else { #endif - [_socket setDelegate: _delegate]; + _socket.delegate = _delegate; if ([_delegate respondsToSelector: @selector(socket:didConnectToHost:port:exception:)]) [_delegate socket: _socket didConnectToHost: _host @@ -216,20 +216,20 @@ #ifdef OF_HAVE_BLOCKS } #endif } -- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))sock +- (void)of_socketDidConnect: (OFTCPSocket *)sock exception: (id)exception { if (exception != nil) { - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [exception retain]; [self didConnect]; } else { [self tryNextAddressWithRunLoopMode: - [[OFRunLoop currentRunLoop] currentMode]]; + [OFRunLoop currentRunLoop].currentMode]; } return; } @@ -250,11 +250,11 @@ else of_socket_address_set_port(&address, _port); if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; @@ -275,13 +275,13 @@ * * So for now, connecting is blocking on Wii and 3DS. * * FIXME: Use a different thread as a work around. */ - [_socket setBlocking: true]; + _socket.blocking = true; #else - [_socket setBlocking: false]; + _socket.blocking = false; #endif if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) @@ -292,11 +292,11 @@ return; } else { #endif [_socket of_closeSocket]; - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; @@ -310,11 +310,11 @@ } #endif } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) - [_socket setBlocking: false]; + _socket.blocking = false; #endif [self didConnect]; } @@ -330,20 +330,20 @@ } _socketAddresses = [socketAddresses copy]; [self tryNextAddressWithRunLoopMode: - [[OFRunLoop currentRunLoop] currentMode]]; + [OFRunLoop currentRunLoop].currentMode]; } - (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode { OFString *host; uint16_t port; if (_SOCKS5Host != nil) { - if ([_host UTF8StringLength] > 255) + if (_host.UTF8StringLength > 255) @throw [OFOutOfRangeException exception]; host = _SOCKS5Host; port = _SOCKS5Port; } else { @@ -377,14 +377,14 @@ OFData *data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; _SOCKS5State = SOCKS5_STATE_SEND_AUTHENTICATION; [_socket asyncWriteData: data - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; } -- (bool)stream: (OF_KINDOF(OFStream *))sock +- (bool)stream: (OFStream *)sock didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { of_run_loop_mode_t runLoopMode; @@ -397,11 +397,11 @@ _exception = [exception retain]; [self didConnect]; return false; } - runLoopMode = [[OFRunLoop currentRunLoop] currentMode]; + runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case SOCKS5_STATE_READ_VERSION: SOCKSVersion = buffer; @@ -419,19 +419,19 @@ _request = [[OFMutableData alloc] init]; [_request addItems: "\x05\x01\x00\x03" count: 4]; - hostLength = (uint8_t)[_host UTF8StringLength]; + hostLength = (uint8_t)_host.UTF8StringLength; [_request addItem: &hostLength]; - [_request addItems: [_host UTF8String] + [_request addItems: _host.UTF8String count: hostLength]; port[0] = _port >> 8; port[1] = _port & 0xFF; [_request addItems: port - count: 2]; + count: 2]; _SOCKS5State = SOCKS5_STATE_SEND_REQUEST; [_socket asyncWriteData: _request runLoopMode: runLoopMode]; return false; @@ -533,11 +533,11 @@ assert(0); return false; } } -- (OFData *)stream: (OF_KINDOF(OFStream *))sock +- (OFData *)stream: (OFStream *)sock didWriteData: (OFData *)data bytesWritten: (size_t)bytesWritten exception: (id)exception { of_run_loop_mode_t runLoopMode; @@ -546,11 +546,11 @@ _exception = [exception retain]; [self didConnect]; return nil; } - runLoopMode = [[OFRunLoop currentRunLoop] currentMode]; + runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case SOCKS5_STATE_SEND_AUTHENTICATION: _SOCKS5State = SOCKS5_STATE_READ_VERSION; [_socket asyncReadIntoBuffer: _buffer @@ -579,11 +579,11 @@ [_exception release]; [super dealloc]; } -- (void)socket: (OF_KINDOF(OFTCPSocket *))sock +- (void)socket: (OFTCPSocket *)sock didConnectToHost: (OFString *)host port: (uint16_t)port exception: (id)exception { _done = true; @@ -706,11 +706,11 @@ id delegate = [_delegate retain]; OFTCPSocket_ConnectDelegate *connectDelegate = [[[OFTCPSocket_ConnectDelegate alloc] init] autorelease]; OFRunLoop *runLoop = [OFRunLoop currentRunLoop]; - [self setDelegate: connectDelegate]; + self.delegate = connectDelegate; [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode]; while (!connectDelegate->_done) @@ -722,11 +722,11 @@ beforeDate: [OFDate date]]; if (connectDelegate->_exception != nil) @throw connectDelegate->_exception; - [self setDelegate: delegate]; + self.delegate = delegate; objc_autoreleasePoolPop(pool); } - (void)asyncConnectToHost: (OFString *)host