From 65213319d3def060c18f709717a0d13c1442ac32 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 22 Jan 2016 15:16:05 +0100 Subject: [PATCH] Implement MatrixClient.register_with_password --- src/matrix-http-client.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/matrix-http-client.c b/src/matrix-http-client.c index b6514ff..b934c77 100644 --- a/src/matrix-http-client.c +++ b/src/matrix-http-client.c @@ -93,11 +93,36 @@ i_login_with_password(MatrixClient *client, error); } +static void +cb_register_account(MatrixAPI *api, + const gchar *content_type, + JsonNode *json_content, + GByteArray *raw_content, + gpointer user_data, + GError *error) +{ + matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL)); +} + +static void +i_register_with_password(MatrixClient *client, + const gchar *username, + const gchar *password, + GError **error) +{ + matrix_api_register_account(MATRIX_API(client), + cb_register_account, NULL, + MATRIX_ACCOUNT_KIND_USER, + FALSE, + username, password, + error); +} + static void matrix_http_client_matrix_client_init(MatrixClientInterface *iface) { iface->login_with_password = i_login_with_password; - iface->register_with_password = NULL; + iface->register_with_password = i_register_with_password; iface->logout = NULL; iface->begin_polling = NULL; iface->stop_polling = NULL;