aboutsummaryrefslogtreecommitdiffstats
path: root/matrix-api.c
Commit message (Collapse)AuthorAgeFilesLines
* api: Add whoamiDr. David Alan Gilbert2019-12-281-0/+25
| | | | | | Add the 'whoami' api call, as a means to validate an access token Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* api/login: synapse got r0 loginDr. David Alan Gilbert2019-12-281-5/+9
| | | | | | | | | Synapse got r0/login in Jan 2016 (pull 459), so lets use it instead of the ancient api/v1/login. Fixes: https://github.com/matrix-org/purple-matrix/issues/100 Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Merge pull request #70 from penguin42/crypt-push4Richard van der Hoff2018-08-031-0/+46
|\ | | | | E2E support
| * Use r0 rather than unstableRichard van der Hoff2018-08-031-1/+1
| |
| * use r0 rather than unstableRichard van der Hoff2018-08-031-1/+1
| |
| * e2e: Route key count from syncDr. David Alan Gilbert2018-02-251-1/+1
| | | | | | | | | | | | | | Route the count of remaining one time keys out of the sync result. We need the newer (v2?) API for this. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
| * e2e: Add matrix_api_upload_keysDr. David Alan Gilbert2018-02-251-0/+46
| | | | | | | | | | | | | | Add api call for uploading device and one time keys. It expects the json blobs to be presigned. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* | api: Handle chunked messagesDr. David Alan Gilbert2018-03-251-11/+25
|/ | | | | | | | | | | | The http_parser handles chunked transfer encoding, but it calls the body handler for each chunk and it's our job to stitch it all back together. Use of on_message_complete suggested by ScottAbbey on github Fixes #72 Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Merge pull request #62 from radiocane/mediaDave Gilbert2018-02-241-5/+16
|\ | | | | Handle media messages (m.video, m.audio, m.file)
| * Improve media handlingWhite_Rabbit2018-02-221-5/+16
| | | | | | | | | | | | | | | | Handle m.video, m.file, m.audio and m.image in _handle_incoming_media. Remove _handle incoming_image. On incoming media, always print a chat message with the download link and mimetype/size. If a thumbnail_url is available and the thumbnail size is small, download and show that. Otherwise, only for m_image, ask for a server generated thumbnail.
* | matrix-api: Fix join by alias or room-idDamien Zammit2017-12-091-2/+2
|/
* bump up max reply sizeDr. David Alan Gilbert2017-09-021-1/+1
| | | | | | | | | | Initial sync's are getting huge, we really need to fix that, but in the mean time bump the max size up. I've seen matrix HQ giving out a 5MB reply in the initial sync. see issue #28. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Responding to PR commentsEion Robb2017-05-281-2/+9
| | | | | * Comment about using state table for ephermal events * Move JSON handling into matrix-api
* Merge branch 'master' into typing-notifications3Eion Robb2017-05-281-7/+9
|\
| * Fix image uploadDr. David Alan Gilbert2017-05-271-1/+1
| | | | | | | | | | | | | | I made the same mistake in image upload I had in download - an extra / at the start triggered a 500. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
| * Fix image downloadDr. David Alan Gilbert2017-04-171-3/+1
| | | | | | | | | | | | | | | | I had an extra / after the hostname, and it doesn't need the access key. (Interestingly my server would take the extra / but matrix.org wouldn't) Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
| * Re-use the device-id provided by the serverEion Robb2017-03-121-3/+7
| | | | | | | | so we don't show up once for each login
* | Send/receive typing notificationsEion Robb2017-03-121-0/+44
|/ | | | using the "Group Typing Notifications" plugin
* Merge pull request #24 from zamaudio/enable-inviteRichard van der Hoff2017-01-051-0/+41
|\ | | | | Enable room invites when matrix handle is known
| * Enable room invites when matrix handle is knownDamien Zammit2017-01-051-0/+41
| | | | | | | | Signed-off-by: Damien Zammit <damien@zamaudio.com>
* | Add matrix_api_download_thumbDr. David Alan Gilbert2016-12-271-0/+42
|/ | | | | | | | | | Allow downloading of a thumbnail for a file. Note: Synapse really doesn't like it if you don't specify the height (I get a 500); so the caller has to give some guess of dimensions, but the server gives something reasonable. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Add matrix_api_download_fileDr. David Alan Gilbert2016-11-131-0/+37
| | | | | | Download a file given a URI. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Pass body/len/content_type to completion callbackDr. David Alan Gilbert2016-11-131-3/+12
| | | | | | | | When a response can't be parsed as JSON pass the body and length to the callback. Also add the content_type. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Fix bogus matrix_api_upload_file urlDr. David Alan Gilbert2016-11-031-1/+1
| | | | | | | I added an extra /join in the upload url - synapse seems to ignore it but we'd better remove it! Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Allow building on libpurple 2.10.xDr. David Alan Gilbert2016-10-161-0/+20
| | | | | | | | | | | In 2f143058d I used the purple_util_fetch_url_request_data_len_with_account which turns out to be new in libpurple 2.11 and ubuntu is still stuck on 2.10. This is a build hack that allows building on 2.10 but doesn't allow sending images. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* api: Upload a fileDr. David Alan Gilbert2016-09-031-0/+37
| | | | | | Upload a file to a Matrix server. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* api: Allow extra_headers to be passedDr. David Alan Gilbert2016-09-031-5/+10
| | | | | | | We need to be able to pass a content-type header for file uploading. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* api: Allow binary data to be sentDr. David Alan Gilbert2016-09-031-17/+53
| | | | | | | | | | | | | | | Allow binary data to be sent after the headers. This data may include a NUL byte and so everything gets more complicated. The data is sent raw on the wire. It's used for uploading files. We rename matrix_api_start to matrix_api_start_full with the extra parameters and provide a matrix_api_start for the callers who don't need the extra binary data. Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
* Fix some indentation; move json_object_unref back to where it wasRichard van der Hoff2016-01-031-6/+6
|
* Allow building for winpidginEion Robb2016-01-041-14/+9
|
* Use Client API r0 rather than a mix of v1 and v2_alpha.Richard van der Hoff2016-01-021-5/+7
|
* Implement joining roomsRichard van der Hoff2015-10-301-0/+29
| | | | Double-clicking on a room in the buddy list now joins a room if necessary.
* Leave rooms when pidgin tells us to.Richard van der Hoff2015-10-301-1/+28
| | | | If a user unticks 'persistent', then closes a tab, we should leave the room.
* Fix segfault when JSON parsing failsRichard van der Hoff2015-10-301-1/+1
| | | | | We weren't correctly initialising a GError *, which meant that we then tried to display the error message from an invalid location.
* Improve error-handling in API requestsRichard van der Hoff2015-10-291-82/+121
| | | | | | | | | Try to deal better with errors which occur during API requests, in terms of reporting them to the user/logs, and in terms of not writing to freed structures. Also do some sanity-checking of the supplied homeserver URL: make sure it is https:// or http://, and make sure we get the right number of '/'s.
* Set HTTP request headers correctly for requests via proxyRichard van der Hoff2015-10-291-14/+23
| | | | | When making a request via a proxy, we are supposed to put the absolute URL in the request-line.
* Build our own GET requestsRichard van der Hoff2015-10-281-15/+68
| | | | | Libpurple assumes that path+querystring is < 256 characters, so we're going to have to build our own GET requests as well as POSTs.
* Request a full_state sync the first time we connect to an account.Richard van der Hoff2015-10-271-3/+6
| | | | | | This requires the new full_state support from https://github.com/matrix-org/synapse/pull/332. It's much cleaner than trying to request the state the first time we hear about a room.
* Update the room state on first messageRichard van der Hoff2015-10-221-0/+24
| | | | | Now that we persist the next_batch identifier, we no longer get all of the state for a room, so we need to explicitly fetch it on initial sync.
* Abort active sync when the account disconnectsRichard van der Hoff2015-10-221-2/+5
| | | | | Apart from seeming like the expected behaviour, this should stop us ending up with segfaults when the sync completes after the connection has gone away.
* Refactor the connection codeRichard van der Hoff2015-10-221-0/+2
| | | | | | | Move all matrix-login and bits of matrix-sync into matrix-connection, where it seems to make more sense. Also move MatrixConnectionData into matrix-connection.h
* Rename MatrixAccount to MatrixConnectionDataRichard van der Hoff2015-10-221-39/+26
| | | | | This structure comes and goes with each connection, so rename it to better reflect its lifecycle.
* Implement a 'cancel' method for the matrix-api interfaceRichard van der Hoff2015-10-221-19/+27
| | | | | | We're going to need to do proper cancelling of API requests, which means passing around enough state to make that possible, so return the MatrixApiRequestData * from matrix_api_*.
* Stash the next_batch token in the account settingsRichard van der Hoff2015-10-221-4/+8
| | | | | Persist the next_batch, so that we don't get old scrollback each time we open the application.
* Update README and file commentsRichard van der Hoff2015-10-211-1/+1
|
* Initial implementation of sending messagesRichard van der Hoff2015-10-211-8/+67
| | | | | | Implement an event queue, and send messages through it. We still need to sort out local echo.
* Implement loginRichard van der Hoff2015-10-201-16/+136
| | | | | Username, password, and homeserver are now configurable options, and we use the login api rather than making the user get their own access token.
* Use libhttp_parser for parsing the API responseRichard van der Hoff2015-10-201-94/+201
| | | | Use an external http parser, instead of inventing that wheel ourselves.
* Refactor API callbacksRichard van der Hoff2015-10-201-6/+61
| | | | | Factor out the handling of errors from API calls, to make it easier to add new ones.
* Implement polling for incoming messagesRichard van der Hoff2015-10-191-8/+15
| | | | We now receive new messages in existing chats.