@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2022 Jonathan Schleifer + * Copyright (c) 2008-2024 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -59,17 +59,16 @@ * * This class is a class cluster and returns a suitable OFTLSStream subclass, * if available. * * Subclasses need to override @ref lowlevelReadIntoBuffer:length:, - * @ref lowlevelWriteBuffer:length: and - * @ref asyncPerformClientHandshakeWithHost:runLoopMode:. The method - * @ref hasDataInReadBuffer should be overridden to return `true` if the TLS - * stream has cached unprocessed data internally, while returning - * `self.underlyingStream.hasDataInReadBuffer` if it does not have any - * unprocessed data. In order to get access to the underlying stream, - * @ref underlyingStream can be used. + * @ref lowlevelWriteBuffer:length:, + * @ref lowlevelHasDataInReadBuffer and + * @ref asyncPerformClientHandshakeWithHost:runLoopMode:. + * + * In order to get access to the underlying stream, @ref underlyingStream can + * be used. */ @interface OFTLSStream: OFStream { OFStream @@ -107,31 +106,34 @@ * @param stream The stream to use as underlying stream. Must not be closed * before the TLS stream is closed. * @return A new, autoreleased TLS stream */ + (instancetype)streamWithStream: (OFStream *)stream; + OFReadyForWritingObserving> *)stream; /** * @brief Initializes the TLS stream with the specified stream as its * underlying stream. * + * @note The delegate of the specified stream will be changed to the TLS + * stream. You must not change this before the TLS session is completed. + * * @param stream The stream to use as underlying stream. Must not be closed * before the TLS stream is closed. * @return An initialized TLS stream */ - (instancetype)initWithStream: (OFStream *)stream + OFReadyForWritingObserving> *)stream OF_DESIGNATED_INITIALIZER; /** * @brief Asynchronously performs the TLS client handshake for the specified * host and calls the delegate afterwards. * * @param host The host to perform the handshake with * @throw OFTLSHandshakeFailedException The TLS handshake failed - * @throw OFAlreadyConnectedException The handshake was already performed + * @throw OFAlreadyOpenException The handshake was already performed */ - (void)asyncPerformClientHandshakeWithHost: (OFString *)host; /** * @brief Asynchronously performs the TLS client handshake for the specified @@ -138,21 +140,21 @@ * host and calls the delegate afterwards. * * @param host The host to perform the handshake with * @param runLoopMode The run loop mode in which to perform the async handshake * @throw OFTLSHandshakeFailedException The TLS handshake failed - * @throw OFAlreadyConnectedException The handshake was already performed + * @throw OFAlreadyOpenException The handshake was already performed */ - (void)asyncPerformClientHandshakeWithHost: (OFString *)host runLoopMode: (OFRunLoopMode)runLoopMode; /** * @brief Performs the TLS client handshake for the specified host. * * @param host The host to perform the handshake with * @throw OFTLSHandshakeFailedException The TLS handshake failed - * @throw OFAlreadyConnectedException The handshake was already performed + * @throw OFAlreadyOpenException The handshake was already performed */ - (void)performClientHandshakeWithHost: (OFString *)host; @end #ifdef __cplusplus