diff options
author | Richard van der Hoff <richard@matrix.org> | 2015-10-20 10:58:25 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2015-10-20 10:58:25 +0100 |
commit | 9d691407057959418d3c23f1ec896eed5efa5fcb (patch) | |
tree | f495d6d7df9e0a46ecbe593a2439b35f6b4b41e4 /matrix-api.h | |
parent | e8c15ca56f5a2951d97aa49ac0e8aea8c93b1320 (diff) | |
download | purple-matrix-9d691407057959418d3c23f1ec896eed5efa5fcb.tar.gz |
Refactor API callbacks
Factor out the handling of errors from API calls, to make it easier to add new
ones.
Diffstat (limited to 'matrix-api.h')
-rw-r--r-- | matrix-api.h | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/matrix-api.h b/matrix-api.h index 85adea6..125568d 100644 --- a/matrix-api.h +++ b/matrix-api.h @@ -33,25 +33,34 @@ struct _JsonNode; * @param account The MatrixAccount passed into the api method * @param user_data The user data that your code passed into the api * method. - * @param http_response -1 on error, otherwise this is the HTTP response code. - * @param http_response_msg NULL on error, otherwise this is the message from - * the HTTP response line. - * @param body_start NULL on error, or if there was no body in the response; + * @param body_start NULL if there was no body in the response; * otherwise a pointer to the start of the body in the * response - * @param json_root NULL on error, or if there was no body in the response; - * otherwise the root of the JSON tree in the response - * @param error_message If something went wrong then this will contain - * a descriptive error message, and ret_text will be - * NULL and ret_len will be 0. + * @param json_root NULL if there was no body, or it could not be + * parsed as JSON; otherwise the root of the JSON + * tree in the response */ typedef void (*MatrixApiCallback)(MatrixAccount *account, gpointer user_data, - int http_response_code, - const gchar *http_response_msg, const gchar *body_start, - struct _JsonNode *json_root, - const gchar *error_message); + struct _JsonNode *json_root); + + +/** + * call the /login API + * + * @param account The MatrixAccount for which to make the request + * @param username user id to pass in request + * @param password password to pass in request + * @param callback Function to be called when the request completes + * @param user_data Opaque data to be passed to the callback + */ +PurpleUtilFetchUrlData *matrix_api_password_login(MatrixAccount *account, + const gchar *username, + const gchar *password, + MatrixApiCallback callback, + gpointer user_data); + /** @@ -62,7 +71,7 @@ typedef void (*MatrixApiCallback)(MatrixAccount *account, * @param callback Function to be called when the request completes * @param user_data Opaque data to be passed to the callback */ -PurpleUtilFetchUrlData *matrix_sync(MatrixAccount *account, +PurpleUtilFetchUrlData *matrix_api_sync(MatrixAccount *account, const gchar *since, MatrixApiCallback callback, gpointer user_data); |