Overview
Comment: | Add support for leaving rooms |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
193ebad6ad2eb698fb1c14250d1319d2 |
User & Date: | js on 2020-10-03 17:50:07 |
Other Links: | manifest | tags |
Context
2020-10-03
| ||
18:09 | Add support for sending messages check-in: cce4e8d73a user: js tags: trunk | |
17:50 | Add support for leaving rooms check-in: 193ebad6ad user: js tags: trunk | |
17:40 | Add support for joining rooms check-in: b1d8afb546 user: js tags: trunk | |
Changes
Modified src/MTXClient.h from [dc76466324] to [0bab750caa].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | * @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, id _Nullable exception); /** * @brief A class that represents a client. */ @interface MTXClient: OFObject /** * @brief The user ID used by the client. */ | > > > > > > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | * @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, id _Nullable exception); /** * @brief A block called when a room was left. * * @param exception An exception if leaving the room failed */ typedef void (^mtx_client_room_leave_block_t)(id _Nullable exception); /** * @brief A class that represents a client. */ @interface MTXClient: OFObject /** * @brief The user ID used by the client. */ |
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 | * @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; @end OF_ASSUME_NONNULL_END | > > > > > > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | * @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; /** * @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_room_leave_block_t)block; @end OF_ASSUME_NONNULL_END |
Modified src/MTXClient.m from [69f2cc536e] to [046c876603].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | */ #import "MTXClient.h" #import "MTXRequest.h" #import "MTXFetchRoomListFailedException.h" #import "MTXJoinRoomFailedException.h" #import "MTXLoginFailedException.h" #import "MTXLogoutFailedException.h" static void validateHomeserver(OFURL *homeserver) { if (![homeserver.scheme isEqual: @"http"] && | > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | */ #import "MTXClient.h" #import "MTXRequest.h" #import "MTXFetchRoomListFailedException.h" #import "MTXJoinRoomFailedException.h" #import "MTXLeaveRoomFailedException.h" #import "MTXLoginFailedException.h" #import "MTXLogoutFailedException.h" static void validateHomeserver(OFURL *homeserver) { if (![homeserver.scheme isEqual: @"http"] && |
︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 289 290 | if (![roomID isKindOfClass: OFString.class]) { block(nil, [OFInvalidServerReplyException exception]); return; } block(roomID, nil); }]; objc_autoreleasePoolPop(pool); } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | if (![roomID isKindOfClass: OFString.class]) { block(nil, [OFInvalidServerReplyException exception]); return; } block(roomID, nil); }]; objc_autoreleasePoolPop(pool); } - (void)leaveRoom: (OFString *)roomID block: (mtx_client_room_leave_block_t)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, id exception) { if (exception != nil) { block(exception); return; } if (statusCode != 200) { block([MTXLeaveRoomFailedException exceptionWithRoomID: roomID statusCode: statusCode response: response client: self]); return; } block(nil); }]; objc_autoreleasePoolPop(pool); } @end |
Modified src/ObjMatrix.h from [43fe4f29c2] to [c891ec6342].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 | * POSSIBILITY OF SUCH DAMAGE. */ #import "MTXClient.h" #import "MTXRequest.h" #import "MTXFetchRoomListFailedException.h" #import "MTXLoginFailedException.h" #import "MTXLogoutFailedException.h" | > > | 20 21 22 23 24 25 26 27 28 29 30 | * POSSIBILITY OF SUCH DAMAGE. */ #import "MTXClient.h" #import "MTXRequest.h" #import "MTXFetchRoomListFailedException.h" #import "MTXJoinRoomFailedException.h" #import "MTXLeaveRoomFailedException.h" #import "MTXLoginFailedException.h" #import "MTXLogoutFailedException.h" |
Added src/exceptions/MTXLeaveRoomFailedException.h version [0d2a38a4ba].
Added src/exceptions/MTXLeaveRoomFailedException.m version [4b628c276b].
Modified src/exceptions/Makefile from [219a3de686] to [71eab3e5a4].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | include ../../extra.mk STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A} STATIC_LIB_NOINST = ${EXCEPTIONS_A} SRCS = MTXClientException.m \ MTXFetchRoomListFailedException.m \ MTXJoinRoomFailedException.m \ MTXLoginFailedException.m \ MTXLogoutFailedException.m INCLUDES = ${SRCS:.m=.h} include ../../buildsys.mk CPPFLAGS += -I. -I.. | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | include ../../extra.mk STATIC_PIC_LIB_NOINST = ${EXCEPTIONS_LIB_A} STATIC_LIB_NOINST = ${EXCEPTIONS_A} SRCS = MTXClientException.m \ MTXFetchRoomListFailedException.m \ MTXJoinRoomFailedException.m \ MTXLeaveRoomFailedException.m \ MTXLoginFailedException.m \ MTXLogoutFailedException.m INCLUDES = ${SRCS:.m=.h} include ../../buildsys.mk CPPFLAGS += -I. -I.. |
︙ | ︙ |
Modified tests/tests.m from [8b2bd0de5e] to [c338030dd8].
︙ | ︙ | |||
76 77 78 79 80 81 82 | [self joinRoom]; }]; } - (void)joinRoom { | > | | > > > > > > > > > > > > > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | [self joinRoom]; }]; } - (void)joinRoom { OFString *room = @"#test:nil.im"; [_client joinRoom: room block: ^ (OFString *roomID, id exception) { if (exception != nil) { of_log(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } of_log(@"Joined room %@", roomID); [self leaveRoom: roomID]; }]; } - (void)leaveRoom: (OFString *)roomID { [_client leaveRoom: roomID block: ^ (id exception) { if (exception != nil) { of_log(@"Failed to leave room %@: %@", exception); [OFApplication terminateWithStatus: 1]; } of_log(@"Left room %@", roomID); [self logOut]; }]; } - (void)logOut { [_client logOutWithBlock: ^ (id exception) { |
︙ | ︙ |