Index: src/OFINIFile.h ================================================================== --- src/OFINIFile.h +++ src/OFINIFile.h @@ -42,10 +42,12 @@ */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *sections; /** * @brief All sections in the INI file. + * + * @deprecated Use @ref sections instead. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFINISection *) *categories OF_DEPRECATED(ObjFW, 1, 2, "Use -[sections] instead"); /** @@ -117,10 +119,12 @@ */ - (OFINISection *)sectionForName: (OFString *)name; /** * @brief Returns an @ref OFINISection for the section with the specified name. + * + * @deprecated Use @ref sectionForName: instead. * * @param name The name of the section for which an @ref OFINISection should be * returned * * @return An @ref OFINISection for the section with the specified name Index: src/OFIRIHandler.h ================================================================== --- src/OFIRIHandler.h +++ src/OFIRIHandler.h @@ -318,11 +318,11 @@ * implemented for the specified item */ - (OFData *)extendedAttributeDataForName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, - "Use -[getExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); + "Use -[getExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Gets the extended attribute data and type for the specified name * of the item at the specified IRI. * @@ -369,11 +369,11 @@ */ - (void)setExtendedAttributeData: (OFData *)data forName: (OFString *)name ofItemAtIRI: (OFIRI *)IRI OF_DEPRECATED(ObjFW, 1, 1, - "Use -[setExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); + "Use -[setExtendedAttributeData:andType:forName:ofItemAtIRI:] instead"); /** * @brief Sets the extended attribute data and type for the specified name of * the item at the specified IRI. * Index: src/OFLocale.h ================================================================== --- src/OFLocale.h +++ src/OFLocale.h @@ -148,12 +148,14 @@ * * @param IRI The IRI to the directory to scan for localizations */ + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI; -- (instancetype)init OF_DEPRECATED(ObjFW, 1, 1, "Manually creating an OFLocale " - "is no longer necessary. Use +[OFLocale currentLocale] instead."); +- (instancetype)init + OF_DEPRECATED(ObjFW, 1, 1, + "Manually creating an OFLocale is no longer necessary. " + "Use +[OFLocale currentLocale] instead."); /** * @brief Adds a directory to scan for localizations. * * @param IRI The IRI to the directory to scan for localizations Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -847,12 +847,12 @@ } # ifdef OF_HAVE_BLOCKS if (_handler != NULL) { if ([object isKindOfClass: [OFStreamSocket class]]) - return ((OFStreamSocketAsyncAcceptBlock)_handler)( - acceptedSocket, exception); + return ((OFStreamSocketAcceptedHandler) + _handler)(object, acceptedSocket, exception); else if ([object isKindOfClass: [OFSequencedPacketSocket class]]) return ((OFSequencedPacketSocketAcceptedHandler) _handler)(object, acceptedSocket, exception); else Index: src/OFStreamSocket.h ================================================================== --- src/OFStreamSocket.h +++ src/OFStreamSocket.h @@ -27,19 +27,35 @@ @class OFStreamSocket; #ifdef OF_HAVE_BLOCKS /** * @brief A block which is called when the socket accepted a connection. + * + * @deprecated Use OFStreamSocketAcceptedHandler instead. * * @param acceptedSocket The socket which has been accepted * @param exception An exception which occurred while accepting the socket or * `nil` on success * @return A bool whether the same block should be used for the next incoming * connection */ typedef bool (^OFStreamSocketAsyncAcceptBlock)(OFStreamSocket *acceptedSocket, - id _Nullable exception); + id _Nullable exception) + OF_DEPRECATED(ObjFW, 1, 2, "Use OFStreamSocketAcceptedHandler instead"); + +/** + * @brief A handler which is called when the socket accepted a connection. + * + * @param socket The socket which accepted the connection + * @param acceptedSocket The socket which has been accepted + * @param exception An exception which occurred while accepting the socket or + * `nil` on success + * @return A bool whether the same handler should be used for the next incoming + * connection + */ +typedef bool (^OFStreamSocketAcceptedHandler)(OFStreamSocket *socket, + OFStreamSocket *acceptedSocket, id _Nullable exception); #endif /** * @protocol OFStreamSocketDelegate OFStreamSocket.h ObjFW/ObjFW.h * @@ -149,27 +165,54 @@ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode; #ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously accept an incoming connection. + * + * @deprecated Use @ref asyncAcceptWithHandler: instead. * * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ -- (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block; +- (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block + OF_DEPRECATED(ObjFW, 1, 2, "Use -[asyncAcceptWithHandler:] instead"); + +/** + * @brief Asynchronously accept an incoming connection. + * + * @param handler The handler to execute when a new connection has been + * accepted. Returns whether the next incoming connection should + * be accepted by the specified handler as well. + */ +- (void)asyncAcceptWithHandler: (OFStreamSocketAcceptedHandler)handler; /** * @brief Asynchronously accept an incoming connection. + * + * @deprecated Use @ref asyncAcceptWithRunLoopMode:handler: instead. * * @param runLoopMode The run loop mode in which to perform the async accept * @param block The block to execute when a new connection has been accepted. * Returns whether the next incoming connection should be accepted * by the specified block as well. */ - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode - block: (OFStreamSocketAsyncAcceptBlock)block; + block: (OFStreamSocketAsyncAcceptBlock)block + OF_DEPRECATED(ObjFW, 1, 2, + "Use -[asyncAcceptWithRunLoopMode:handler:] instead"); + +/** + * @brief Asynchronously accept an incoming connection. + * + * @param runLoopMode The run loop mode in which to perform the async accept + * @param handler The handler to execute when a new connection has been + * accepted. Returns whether the next incoming connection + * should be accepted by the specified handler as well. + */ +- (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode + handler: (OFStreamSocketAcceptedHandler)handler; #endif /** * @brief Releases the socket from the current thread. * Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -338,19 +338,43 @@ } #ifdef OF_HAVE_BLOCKS - (void)asyncAcceptWithBlock: (OFStreamSocketAsyncAcceptBlock)block { - [self asyncAcceptWithRunLoopMode: OFDefaultRunLoopMode block: block]; + OFStreamSocketAcceptedHandler handler = ^ (OFStreamSocket *socket, + OFStreamSocket *acceptedSocket, id exception) { + return block(acceptedSocket, exception); + }; + + [self asyncAcceptWithRunLoopMode: OFDefaultRunLoopMode + handler: handler]; +} + +- (void)asyncAcceptWithHandler: (OFStreamSocketAcceptedHandler)handler +{ + [self asyncAcceptWithRunLoopMode: OFDefaultRunLoopMode + handler: handler]; } - (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode block: (OFStreamSocketAsyncAcceptBlock)block { + OFStreamSocketAcceptedHandler handler = ^ (OFStreamSocket *socket, + OFStreamSocket *acceptedSocket, id exception) { + return block(acceptedSocket, exception); + }; + + [self asyncAcceptWithRunLoopMode: runLoopMode + handler: handler]; +} + +- (void)asyncAcceptWithRunLoopMode: (OFRunLoopMode)runLoopMode + handler: (OFStreamSocketAcceptedHandler)handler +{ [OFRunLoop of_addAsyncAcceptForSocket: self mode: runLoopMode - handler: block + handler: handler delegate: nil]; } #endif - (const OFSocketAddress *)remoteAddress