Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,14 +1,14 @@ OBJMATRIX_SHARED_LIB = @OBJMATRIX_SHARED_LIB@ OBJMATRIX_STATIC_LIB = @OBJMATRIX_STATIC_LIB@ OBJMATRIX_FRAMEWORK = @OBJMATRIX_FRAMEWORK@ OBJMATRIX_LIB_MAJOR = 0 OBJMATRIX_LIB_MINOR = 0 -OBJMATRIX_LIB_MAJOR_MINOR = ${OBJMATRIX_LIB_MAJOR_MINOR}.${OBJMATRIX_LIB_MINOR} +OBJMATRIX_LIB_MAJOR_MINOR = ${OBJMATRIX_LIB_MAJOR}.${OBJMATRIX_LIB_MINOR} EXCEPTIONS_A = @EXCEPTIONS_A@ EXCEPTIONS_EXCEPTIONS_A = @EXCEPTIONS_EXCEPTIONS_A@ EXCEPTIONS_EXCEPTIONS_LIB_A = @EXCEPTIONS_EXCEPTIONS_LIB_A@ EXCEPTIONS_LIB_A = @EXCEPTIONS_LIB_A@ LIBOBJMATRIX_DEP = @LIBOBJMATRIX_DEP@ OBJFW_CONFIG = @OBJFW_CONFIG@ RUN_TESTS = @RUN_TESTS@ Index: src/MTXClient.h ================================================================== --- src/MTXClient.h +++ src/MTXClient.h @@ -32,44 +32,44 @@ * @brief A block called when a new login succeeded or failed. * * @param client If the login succeeded, the newly created client * @param exception If the login failed, an exception */ -typedef void (^mtx_client_login_block_t)(MTXClient *_Nullable client, +typedef void (^MTXClientLoginBlock)(MTXClient *_Nullable client, id _Nullable exception); /** * @brief A block called when the response for an operation was received. * * @param exception `nil` on success, otherwise an exception */ -typedef void (^mtx_client_response_block_t)(id _Nullable exception); +typedef void (^MTXClientResponseBlock)(id _Nullable exception); /** * @brief A block called when an exception occurred during sync. * * @param exception The exception which occurred during sync */ -typedef void (^mtx_sync_exception_handler_block_t)(id exception); +typedef void (^MTXSyncExceptionHandlerBlock)(id exception); /** * @brief A block called when the room list was fetched. * * @param rooms An array of joined rooms, or nil on error * @param exception An exception if fetching the room list failed */ -typedef void (^mtx_client_room_list_block_t)( - OFArray *_Nullable rooms, id _Nullable exception); +typedef void (^MTXClientRoomListBlock)(OFArray *_Nullable rooms, + id _Nullable exception); /** * @brief A block called when a room was joined. * * @param roomID The room ID that was joined, or nil on error. This can be used * to get the room ID if a room alias was joined. * @param exception An exception if joining the room failed */ -typedef void (^mtx_client_room_join_block_t)(OFString *_Nullable roomID, +typedef void (^MTXClientRoomJoinBlock)(OFString *_Nullable roomID, id _Nullable exception); /** * @brief A class that represents a client. */ @@ -102,17 +102,16 @@ /** * @brief The timeout for sync requests. * * Defaults to 5 minutes. */ -@property (nonatomic) of_time_interval_t syncTimeout; +@property (nonatomic) OFTimeInterval syncTimeout; /** * @brief A block to handle exceptions that occurred during sync. */ -@property (copy, nonatomic) - mtx_sync_exception_handler_block_t syncExceptionHandler; +@property (copy, nonatomic) MTXSyncExceptionHandlerBlock syncExceptionHandler; /** * @brief Creates a new client with the specified access token on the specified * homeserver. * @@ -140,11 +139,11 @@ */ + (void)logInWithUser: (OFString *)user password: (OFString *)password homeserver: (OFURL *)homeserver storage: (id )storage - block: (mtx_client_login_block_t)block; + block: (MTXClientLoginBlock)block; /** * @brief Initializes an already allocated client with the specified access * token on the specified homeserver. * @@ -180,36 +179,34 @@ * * @warning The client can no longer be used after this succeeded! * * @param block A block to call when logging out succeeded or failed */ -- (void)logOutWithBlock: (mtx_client_response_block_t)block; +- (void)logOutWithBlock: (MTXClientResponseBlock)block; /** * @brief Fetches the list of joined rooms. * * @param block A block to call with the list of joined room */ -- (void)fetchRoomListWithBlock: (mtx_client_room_list_block_t)block; +- (void)fetchRoomListWithBlock: (MTXClientRoomListBlock)block; /** * @brief Joins the specified room. * * @param room The room to join. Either a room ID or a room alias. * @param block A block to call when the room was joined */ -- (void)joinRoom: (OFString *)room - block: (mtx_client_room_join_block_t)block; +- (void)joinRoom: (OFString *)room block: (MTXClientRoomJoinBlock)block; /** * @brief Leaves the specified room. * * @param roomID The room ID to leave * @param block A block to call when the room was left */ -- (void)leaveRoom: (OFString *)roomID - block: (mtx_client_response_block_t)block; +- (void)leaveRoom: (OFString *)roomID block: (MTXClientResponseBlock)block; /** * @brief Sends the specified message to the specified room ID. * * @param message The message to send @@ -216,9 +213,9 @@ * @param roomID The room ID to which to send the message * @param block A block to call when the message was sent */ - (void)sendMessage: (OFString *)message roomID: (OFString *)roomID - block: (mtx_client_response_block_t)block; + block: (MTXClientResponseBlock)block; @end OF_ASSUME_NONNULL_END Index: src/MTXClient.m ================================================================== --- src/MTXClient.m +++ src/MTXClient.m @@ -67,31 +67,31 @@ + (void)logInWithUser: (OFString *)user password: (OFString *)password homeserver: (OFURL *)homeserver storage: (id )storage - block: (mtx_client_login_block_t)block + block: (MTXClientLoginBlock)block { void *pool = objc_autoreleasePoolPush(); validateHomeserver(homeserver); MTXRequest *request = [MTXRequest requestWithPath: @"/_matrix/client/r0/login" accessToken: nil homeserver: homeserver]; - request.method = OF_HTTP_REQUEST_METHOD_POST; + request.method = OFHTTPRequestMethodPost; request.body = @{ @"type": @"m.login.password", @"identifier": @{ @"type": @"m.id.user", @"user": user }, @"password": password }; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(nil, exception); return; } @@ -215,11 +215,11 @@ OFMutableDictionary *query = [OFMutableDictionary dictionaryWithObject: @(timeoutMs).stringValue forKey: @"timeout"]; query[@"since"] = [_storage nextBatchForDeviceID: _deviceID]; request.query = query; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { if (_syncExceptionHandler != NULL) _syncExceptionHandler(exception); return; @@ -273,17 +273,17 @@ - (void)stopSyncLoop { _syncing = false; } -- (void)logOutWithBlock: (mtx_client_response_block_t)block +- (void)logOutWithBlock: (MTXClientResponseBlock)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: @"/_matrix/client/r0/logout"]; - request.method = OF_HTTP_REQUEST_METHOD_POST; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + request.method = OFHTTPRequestMethodPost; + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(exception); return; } @@ -300,16 +300,16 @@ }]; objc_autoreleasePoolPop(pool); } -- (void)fetchRoomListWithBlock: (mtx_client_room_list_block_t)block +- (void)fetchRoomListWithBlock: (MTXClientRoomListBlock)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: @"/_matrix/client/r0/joined_rooms"]; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(nil, exception); return; } @@ -339,18 +339,17 @@ }]; objc_autoreleasePoolPop(pool); } -- (void)joinRoom: (OFString *)room - block: (mtx_client_room_join_block_t)block +- (void)joinRoom: (OFString *)room block: (MTXClientRoomJoinBlock)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: [OFString stringWithFormat: @"/_matrix/client/r0/join/%@", room]]; - request.method = OF_HTTP_REQUEST_METHOD_POST; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + request.method = OFHTTPRequestMethodPost; + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(nil, exception); return; } @@ -374,18 +373,17 @@ }]; objc_autoreleasePoolPop(pool); } -- (void)leaveRoom: (OFString *)roomID - block: (mtx_client_response_block_t)block +- (void)leaveRoom: (OFString *)roomID block: (MTXClientResponseBlock)block { void *pool = objc_autoreleasePoolPush(); MTXRequest *request = [self requestWithPath: [OFString stringWithFormat: @"/_matrix/client/r0/rooms/%@/leave", roomID]]; - request.method = OF_HTTP_REQUEST_METHOD_POST; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + request.method = OFHTTPRequestMethodPost; + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(exception); return; } @@ -405,22 +403,22 @@ objc_autoreleasePoolPop(pool); } - (void)sendMessage: (OFString *)message roomID: (OFString *)roomID - block: (mtx_client_response_block_t)block; + block: (MTXClientResponseBlock)block; { void *pool = objc_autoreleasePoolPush(); OFString *path = [OFString stringWithFormat: @"/_matrix/client/r0/rooms/%@/send/m.room.message", roomID]; MTXRequest *request = [self requestWithPath: path]; - request.method = OF_HTTP_REQUEST_METHOD_POST; + request.method = OFHTTPRequestMethodPost; request.body = @{ @"msgtype": @"m.text", @"body": message }; - [request performWithBlock: ^ (mtx_response_t response, int statusCode, + [request performWithBlock: ^ (MTXResponse response, int statusCode, id exception) { if (exception != nil) { block(exception); return; } @@ -464,12 +462,11 @@ { if (rooms == nil) return; for (OFString *roomID in rooms) - [_storage addJoinedRoom: roomID - forUser: _userID]; + [_storage addJoinedRoom: roomID forUser: _userID]; } - (void)processInvitedRooms: (OFDictionary *)rooms { if (rooms == nil) @@ -480,9 +477,8 @@ { if (rooms == nil) return; for (OFString *roomID in rooms) - [_storage removeJoinedRoom: roomID - forUser: _userID]; + [_storage removeJoinedRoom: roomID forUser: _userID]; } @end Index: src/MTXRequest.h ================================================================== --- src/MTXRequest.h +++ src/MTXRequest.h @@ -27,22 +27,22 @@ /** * @brief A response to a request. * * This is a typedef for `OFDictionary *`. */ -typedef OFDictionary *mtx_response_t; +typedef OFDictionary *MTXResponse; /** * @brief A block called with the response for an MTXRequest. * * @param response The response to the request, as a dictionary parsed from JSON * @param statusCode The HTTP status code returned for the request * @param exception The first exception that occurred during the request, * or `nil` on success */ -typedef void (^mtx_request_block_t)(mtx_response_t _Nullable response, - int statusCode, id _Nullable exception); +typedef void (^MTXRequestBlock)(MTXResponse _Nullable response, int statusCode, + id _Nullable exception); /** * @brief An internal class for performing a request on the Matrix server. */ @interface MTXRequest: OFObject @@ -61,11 +61,11 @@ /** * @brief The HTTP request method. * * Defaults to `OF_HTTP_REQUEST_METHOD_GET`. */ -@property (nonatomic) of_http_request_method_t method; +@property (nonatomic) OFHTTPRequestMethod method; /** * @brief The path of the request. */ @property (copy, nonatomic) OFString *path; @@ -110,9 +110,9 @@ * @brief Performs the request and calls the specified block once the request * succeeded or failed. * * @param block The block to call once the request succeeded or failed */ -- (void)performWithBlock: (mtx_request_block_t)block; +- (void)performWithBlock: (MTXRequestBlock)block; @end OF_ASSUME_NONNULL_END Index: src/MTXRequest.m ================================================================== --- src/MTXRequest.m +++ src/MTXRequest.m @@ -23,11 +23,11 @@ #import "MTXRequest.h" @implementation MTXRequest { OFData *_body; - mtx_request_block_t _block; + MTXRequestBlock _block; } + (instancetype)requestWithPath: (OFString *)path accessToken: (OFString *)accessToken homeserver: (OFURL *)homeserver @@ -45,11 +45,11 @@ @try { _accessToken = [accessToken copy]; _homeserver = [homeserver copy]; _path = [path copy]; - _method = OF_HTTP_REQUEST_METHOD_GET; + _method = OFHTTPRequestMethodGet; } @catch (id e) { [self release]; @throw e; } @@ -71,25 +71,23 @@ void *pool = objc_autoreleasePoolPush(); [_body release]; OFString *JSONString = [body JSONRepresentation]; - _body = [[OFData alloc] - initWithItems: JSONString.UTF8String - count: JSONString.UTF8StringLength]; + _body = [[OFData alloc] initWithItems: JSONString.UTF8String + count: JSONString.UTF8StringLength]; objc_autoreleasePoolPop(pool); } - (OFDictionary *)body { return [OFString stringWithUTF8String: _body.items - length: _body.count] - .objectByParsingJSON; + length: _body.count].objectByParsingJSON; } -- (void)performWithBlock: (mtx_request_block_t)block +- (void)performWithBlock: (MTXRequestBlock)block { void *pool = objc_autoreleasePoolPush(); if (_block != nil) /* Not the best exception to indicate it's already in-flight. */ @@ -129,11 +127,11 @@ if (response != nil && [exception isKindOfClass: [OFHTTPRequestFailedException class]]) exception = nil; /* Reset to nil first, so that another one can be performed. */ - mtx_request_block_t block = _block; + MTXRequestBlock block = _block; _block = nil; if (exception == nil) { @try { OFMutableData *responseData = [OFMutableData data]; @@ -140,15 +138,14 @@ while (!response.atEndOfStream) { char buffer[512]; size_t length = [response readIntoBuffer: buffer length: 512]; - [responseData addItems: buffer - count: length]; + [responseData addItems: buffer count: length]; } - mtx_response_t responseJSON = [OFString + MTXResponse responseJSON = [OFString stringWithUTF8String: responseData.items length: responseData.count] .objectByParsingJSON; block(responseJSON, response.statusCode, nil); Index: src/MTXSQLite3Storage.m ================================================================== --- src/MTXSQLite3Storage.m +++ src/MTXSQLite3Storage.m @@ -104,17 +104,16 @@ @" room_id TEXT,\n" @" PRIMARY KEY (user_id, room_id)\n" @");"]; } -- (void)transactionWithBlock: (mtx_storage_transaction_block_t)block +- (void)transactionWithBlock: (MTXStorageTransactionBlock)block { [_conn transactionWithBlock: block]; } -- (void)setNextBatch: (OFString *)nextBatch - forDeviceID: (OFString *)deviceID +- (void)setNextBatch: (OFString *)nextBatch forDeviceID: (OFString *)deviceID { void *pool = objc_autoreleasePoolPush(); [_nextBatchSetStatement reset]; [_nextBatchSetStatement bindWithDictionary: @{ @@ -144,12 +143,11 @@ objc_autoreleasePoolPop(pool); return [nextBatch autorelease]; } -- (void)addJoinedRoom: (OFString *)roomID - forUser: (OFString *)userID +- (void)addJoinedRoom: (OFString *)roomID forUser: (OFString *)userID { void *pool = objc_autoreleasePoolPush(); [_joinedRoomsAddStatement reset]; [_joinedRoomsAddStatement bindWithDictionary: @{ @@ -159,12 +157,11 @@ [_joinedRoomsAddStatement step]; objc_autoreleasePoolPop(pool); } -- (void)removeJoinedRoom: (OFString *)roomID - forUser: (OFString *)userID +- (void)removeJoinedRoom: (OFString *)roomID forUser: (OFString *)userID { void *pool = objc_autoreleasePoolPush(); [_joinedRoomsRemoveStatement reset]; [_joinedRoomsRemoveStatement bindWithDictionary: @{ @@ -180,13 +177,11 @@ { OFMutableArray *joinedRooms = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); [_joinedRoomsGetStatement reset]; - [_joinedRoomsGetStatement bindWithDictionary: @{ - @"$user_id": userID - }]; + [_joinedRoomsGetStatement bindWithDictionary: @{ @"$user_id": userID }]; while ([_joinedRoomsGetStatement step]) [joinedRooms addObject: _joinedRoomsGetStatement.rowDictionary[@"room_id"]]; Index: src/MTXStorage.h ================================================================== --- src/MTXStorage.h +++ src/MTXStorage.h @@ -28,29 +28,28 @@ * @brief A block which will be treated as a single transaction for the storage. * * @return Whether the transaction should be committed (`true`) or rolled back * (`false`). */ -typedef bool (^mtx_storage_transaction_block_t)(void); +typedef bool (^MTXStorageTransactionBlock)(void); /** * @brief A protocol for a storage to be used by @ref MTXClient. */ @protocol MTXStorage /** * @brief Performs all operations inside the block as a transaction. */ -- (void)transactionWithBlock: (mtx_storage_transaction_block_t)block; +- (void)transactionWithBlock: (MTXStorageTransactionBlock)block; /** * @brief Stores the next batch for the specified device. * * @param nextBatch The next batch for the device * @param deviceID The device for which to store the next batch */ -- (void)setNextBatch: (OFString *)nextBatch - forDeviceID: (OFString *)deviceID; +- (void)setNextBatch: (OFString *)nextBatch forDeviceID: (OFString *)deviceID; /** * @brief Returns the next batch for the specified device. * * @param deviceID The device ID for which to return the next batch @@ -64,22 +63,20 @@ * specified user ID. * * @param roomID The room ID to add to the list of joined rooms * @param userID The user ID for which to add the room */ -- (void)addJoinedRoom: (OFString *)roomID - forUser: (OFString *)userID; +- (void)addJoinedRoom: (OFString *)roomID forUser: (OFString *)userID; /** * @brief Removes the specified room ID to the list of joined rooms for the * specified user ID. * * @param roomID The room ID to add to the list of joined rooms * @param userID The user ID for which to add the room */ -- (void)removeJoinedRoom: (OFString *)roomID - forUser: (OFString *)userID; +- (void)removeJoinedRoom: (OFString *)roomID forUser: (OFString *)userID; /** * @brief Returns the joined room IDs for the specified user ID. * * @param userID The user ID for which to return the joined rooms Index: src/exceptions/MTXClientException.h ================================================================== --- src/exceptions/MTXClientException.h +++ src/exceptions/MTXClientException.h @@ -28,18 +28,18 @@ @class MTXClient; @interface MTXClientException: OFException @property (readonly, nonatomic) int statusCode; -@property (readonly, nonatomic) mtx_response_t response; +@property (readonly, nonatomic) MTXResponse response; @property (readonly, nonatomic) MTXClient *client; + (instancetype)exceptionWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; - (instancetype)initWithStatusCode: (int)statusCode - response: (mtx_response_t)respons + response: (MTXResponse)respons client: (MTXClient *)client OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/MTXClientException.m ================================================================== --- src/exceptions/MTXClientException.m +++ src/exceptions/MTXClientException.m @@ -24,20 +24,20 @@ #import "MTXClient.h" @implementation MTXClientException + (instancetype)exceptionWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { return [[[self alloc] initWithStatusCode: statusCode response: response client: client] autorelease]; } - (instancetype)initWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { self = [super init]; @try { Index: src/exceptions/MTXJoinRoomFailedException.h ================================================================== --- src/exceptions/MTXJoinRoomFailedException.h +++ src/exceptions/MTXJoinRoomFailedException.h @@ -28,21 +28,21 @@ @interface MTXJoinRoomFailedException: MTXClientException @property (readonly, nonatomic) OFString *room; + (instancetype)exceptionWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; + (instancetype)exceptionWithRoom: (OFString *)room statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; - (instancetype)initWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; - (instancetype)initWithRoom: (OFString *)room statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; @end OF_ASSUME_NONNULL_END Index: src/exceptions/MTXJoinRoomFailedException.m ================================================================== --- src/exceptions/MTXJoinRoomFailedException.m +++ src/exceptions/MTXJoinRoomFailedException.m @@ -25,11 +25,11 @@ #import "MTXClient.h" @implementation MTXJoinRoomFailedException + (instancetype)exceptionWithRoom: (OFString *)room statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { return [[[self alloc] initWithRoom: room statusCode: statusCode response: response @@ -36,11 +36,11 @@ client: client] autorelease]; } - (instancetype)initWithRoom: (OFString *)room statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { self = [super initWithStatusCode: statusCode response: response client: client]; Index: src/exceptions/MTXLeaveRoomFailedException.h ================================================================== --- src/exceptions/MTXLeaveRoomFailedException.h +++ src/exceptions/MTXLeaveRoomFailedException.h @@ -28,21 +28,21 @@ @interface MTXLeaveRoomFailedException: MTXClientException @property (readonly, nonatomic) OFString *roomID; + (instancetype)exceptionWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; + (instancetype)exceptionWithRoomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; - (instancetype)initWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; - (instancetype)initWithRoomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; @end OF_ASSUME_NONNULL_END Index: src/exceptions/MTXLeaveRoomFailedException.m ================================================================== --- src/exceptions/MTXLeaveRoomFailedException.m +++ src/exceptions/MTXLeaveRoomFailedException.m @@ -25,11 +25,11 @@ #import "MTXClient.h" @implementation MTXLeaveRoomFailedException + (instancetype)exceptionWithRoomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { return [[[self alloc] initWithRoomID: roomID statusCode: statusCode response: response @@ -36,11 +36,11 @@ client: client] autorelease]; } - (instancetype)initWithRoomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { self = [super initWithStatusCode: statusCode response: response client: client]; Index: src/exceptions/MTXLoginFailedException.h ================================================================== --- src/exceptions/MTXLoginFailedException.h +++ src/exceptions/MTXLoginFailedException.h @@ -28,18 +28,18 @@ @interface MTXLoginFailedException: OFException @property (readonly, nonatomic) OFString *user; @property (readonly, nonatomic) OFURL *homeserver; @property (readonly, nonatomic) int statusCode; -@property (readonly, nonatomic) mtx_response_t response; +@property (readonly, nonatomic) MTXResponse response; + (instancetype)exceptionWithUser: (OFString *)user homeserver: (OFURL *)homeserver statusCode: (int)statusCode - response: (mtx_response_t)response; + response: (MTXResponse)response; - (instancetype)initWithUser: (OFString *)user homeserver: (OFURL *)homeserver statusCode: (int)statusCode - response: (mtx_response_t)response; + response: (MTXResponse)response; @end OF_ASSUME_NONNULL_END Index: src/exceptions/MTXLoginFailedException.m ================================================================== --- src/exceptions/MTXLoginFailedException.m +++ src/exceptions/MTXLoginFailedException.m @@ -24,11 +24,11 @@ @implementation MTXLoginFailedException + (instancetype)exceptionWithUser: (OFString *)user homeserver: (OFURL *)homeserver statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response { return [[[self alloc] initWithUser: user homeserver: homeserver statusCode: statusCode response: response] autorelease]; @@ -35,11 +35,11 @@ } - (instancetype)initWithUser: (OFString *)user homeserver: (OFURL *)homeserver statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response { self = [super init]; @try { _user = [user copy]; Index: src/exceptions/MTXSendMessageFailedException.h ================================================================== --- src/exceptions/MTXSendMessageFailedException.h +++ src/exceptions/MTXSendMessageFailedException.h @@ -29,23 +29,23 @@ @interface MTXSendMessageFailedException: MTXClientException @property (readonly, nonatomic) OFString *message; @property (readonly, nonatomic) OFString *roomID; + (instancetype)exceptionWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; + (instancetype)exceptionWithMessage: (OFString *)message roomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client; - (instancetype)initWithStatusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_UNAVAILABLE; - (instancetype)initWithMessage: (OFString *)message roomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/MTXSendMessageFailedException.m ================================================================== --- src/exceptions/MTXSendMessageFailedException.m +++ src/exceptions/MTXSendMessageFailedException.m @@ -26,11 +26,11 @@ @implementation MTXSendMessageFailedException + (instancetype)exceptionWithMessage: (OFString *)message roomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { return [[[self alloc] initWithMessage: message roomID: roomID statusCode: statusCode @@ -39,11 +39,11 @@ } - (instancetype)initWithMessage: (OFString *)message roomID: (OFString *)roomID statusCode: (int)statusCode - response: (mtx_response_t)response + response: (MTXResponse)response client: (MTXClient *)client { self = [super initWithStatusCode: statusCode response: response client: client]; Index: tests/tests.m ================================================================== --- tests/tests.m +++ tests/tests.m @@ -39,13 +39,13 @@ { __auto_type environment = OFApplication.environment; if (environment[@"OBJMATRIX_USER"] == nil || environment[@"OBJMATRIX_PASS"] == nil || environment[@"OBJMATRIX_HS"] == nil) { - [of_stderr writeString: @"Please set OBJMATRIX_USER, " - @"OBJMATRIX_PASS and OBJMATRIX_HS in " - @"the environment!\n"]; + [OFStdErr writeString: @"Please set OBJMATRIX_USER, " + @"OBJMATRIX_PASS and OBJMATRIX_HS in " + @"the environment!\n"]; [OFApplication terminateWithStatus: 1]; } OFURL *homeserver = [OFURL URLWithString: environment[@"OBJMATRIX_HS"]]; id storage = @@ -54,16 +54,16 @@ password: environment[@"OBJMATRIX_PASS"] homeserver: homeserver storage: storage block: ^ (MTXClient *client, id exception) { if (exception != nil) { - of_log(@"Error logging in: %@", exception); + OFLog(@"Error logging in: %@", exception); [OFApplication terminateWithStatus: 1]; } _client = [client retain]; - of_log(@"Logged in client: %@", _client); + OFLog(@"Logged in client: %@", _client); [_client startSyncLoop]; [self fetchRoomList]; }]; } @@ -71,32 +71,31 @@ - (void)fetchRoomList { [_client fetchRoomListWithBlock: ^ (OFArray *rooms, id exception) { if (exception != nil) { - of_log(@"Failed to fetch room list: %@", exception); + OFLog(@"Failed to fetch room list: %@", exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Fetched room list: %@", rooms); + OFLog(@"Fetched room list: %@", rooms); [self joinRoom]; }]; } - (void)joinRoom { OFString *room = @"#test:nil.im"; - [_client joinRoom: room - block: ^ (OFString *roomID, id exception) { + [_client joinRoom: room block: ^ (OFString *roomID, id exception) { if (exception != nil) { - of_log(@"Failed to join room %@: %@", room, exception); + OFLog(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } _roomID = [roomID copy]; - of_log(@"Joined room %@", _roomID); + OFLog(@"Joined room %@", _roomID); [self sendMessage]; }]; } @@ -104,49 +103,46 @@ { [_client sendMessage: @"ObjMatrix test successful!" roomID: _roomID block: ^ (id exception) { if (exception != nil) { - of_log(@"Failed to send message to room %@: %@", + OFLog(@"Failed to send message to room %@: %@", _roomID, exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Message sent to %@", _roomID); + OFLog(@"Message sent to %@", _roomID); - of_log( - @"Waiting 5 seconds before leaving room and logging out"); + OFLog(@"Waiting 5 seconds before leaving room and logging out"); - [self performSelector: @selector(leaveRoom) - afterDelay: 5]; + [self performSelector: @selector(leaveRoom) afterDelay: 5]; }]; } - (void)leaveRoom { - [_client leaveRoom: _roomID - block: ^ (id exception) { + [_client leaveRoom: _roomID block: ^ (id exception) { if (exception != nil) { - of_log(@"Failed to leave room %@: %@", exception); + OFLog(@"Failed to leave room %@: %@", exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Left room %@", _roomID); + OFLog(@"Left room %@", _roomID); [self logOut]; }]; } - (void)logOut { [_client logOutWithBlock: ^ (id exception) { if (exception != nil) { - of_log(@"Failed to log out: %@\n", exception); + OFLog(@"Failed to log out: %@\n", exception); [OFApplication terminateWithStatus: 1]; } - of_log(@"Logged out client"); + OFLog(@"Logged out client"); [OFApplication terminate]; }]; } @end