@@ -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