Overview
Comment: | Make sync loop automatic |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
63d344bd1d172c6cf29ef3fad72f37d0 |
User & Date: | js on 2020-10-31 17:09:42 |
Other Links: | manifest | tags |
Context
2020-10-31
| ||
19:37 | Adjust to ObjFW changes check-in: 6b6fe6d802 user: js tags: trunk | |
17:09 | Make sync loop automatic check-in: 63d344bd1d user: js tags: trunk | |
2020-10-11
| ||
18:34 | Track joined rooms check-in: 366f90be1a user: js tags: trunk | |
Changes
Modified src/MTXClient.h from [a9c991a2fb] to [4640a34e7e].
︙ | |||
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | + + + + + + + | /** * @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); /** * @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); /** * @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)( |
︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | + + + + + + + + + + + + + | @property (readonly, nonatomic) OFURL *homeserver; /** * @brief The storage used by the client. */ @property (readonly, nonatomic) id <MTXStorage> storage; /** * @brief The timeout for sync requests. * * Defaults to 5 minutes. */ @property (nonatomic) of_time_interval_t syncTimeout; /** * @brief A block to handle exceptions that occurred during sync. */ @property (copy, nonatomic) mtx_sync_exception_handler_block_t syncExceptionHandler; /** * @brief Creates a new client with the specified access token on the specified * homeserver. * * @param userID The user ID for the client * @param deviceID The device ID for the client * @param accessToken The access token for the client |
︙ | |||
139 140 141 142 143 144 145 | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | - - - + + + + + + + + + - + - | deviceID: (OFString *)deviceID accessToken: (OFString *)accessToken homeserver: (OFURL *)homeserver storage: (id <MTXStorage>)storage OF_DESIGNATED_INITIALIZER; /** |
︙ |
Modified src/MTXClient.m from [ec0c7e8ba9] to [90a5b4b816].
︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | + + + + | if (homeserver.user != nil || homeserver.password != nil || homeserver.query != nil || homeserver.fragment != nil) @throw [OFInvalidArgumentException exception]; } @implementation MTXClient { bool _syncing; } + (instancetype)clientWithUserID: (OFString *)userID deviceID: (OFString *)deviceID accessToken: (OFString *)accessToken homeserver: (OFURL *)homeserver storage: (id <MTXStorage>)storage { return [[[self alloc] initWithUserID: userID |
︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | + | validateHomeserver(homeserver); _userID = [userID copy]; _deviceID = [deviceID copy]; _accessToken = [accessToken copy]; _homeserver = [homeserver copy]; _storage = [storage retain]; _syncTimeout = 300; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | |||
192 193 194 195 196 197 198 | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | - - - + + + + + + + - + + - + + - - - - + + + + + + - + + - + - + + + + + + + | - (MTXRequest *)requestWithPath: (OFString *)path { return [MTXRequest requestWithPath: path accessToken: _accessToken homeserver: _homeserver]; } |
︙ |
Modified tests/tests.m from [9eabf30e59] to [bf6cef9450].
︙ | |||
59 60 61 62 63 64 65 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | - - - - - - - + - - - - - - - - | of_log(@"Error logging in: %@", exception); [OFApplication terminateWithStatus: 1]; } _client = [client retain]; of_log(@"Logged in client: %@", _client); |
︙ | |||
106 107 108 109 110 111 112 | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | - - - - - - - - - - - - - - - + + - + + + | of_log(@"Failed to join room %@: %@", room, exception); [OFApplication terminateWithStatus: 1]; } _roomID = [roomID copy]; of_log(@"Joined room %@", _roomID); |
︙ |