diff --git a/src/matrix-client.c b/src/matrix-client.c index 949d07b..9b6064a 100644 --- a/src/matrix-client.c +++ b/src/matrix-client.c @@ -61,6 +61,7 @@ matrix_client_default_init(MatrixClientInterface *iface) * @client: a #MatrixClient * @username: the username to login with * @password: the password to use + * @error: a location for a #GError, or %NULL * * Authenticate with the Matrix.org server with a username and * password. @@ -68,12 +69,13 @@ matrix_client_default_init(MatrixClientInterface *iface) void matrix_client_login_with_password(MatrixClient *client, const gchar *username, - const gchar *password) + const gchar *password, + GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->login_with_password(client, username, password); + ->login_with_password(client, username, password, error); } /** @@ -82,80 +84,88 @@ matrix_client_login_with_password(MatrixClient *client, * @username: (allow-none): the username to register. If omitted, the * server will generate one * @password: the password to use with the registration + * @error: a location for a #GError, or %NULL * * Register @username with the homeserver. */ void matrix_client_register_with_password(MatrixClient *client, const gchar *username, - const gchar *password) + const gchar *password, + GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->register_with_password(client, username, password); + ->register_with_password(client, username, password, error); } /** * matrix_client_logout: * @client: a #MatrixClient + * @error: a location for a #GError, or %NULL * * Logout from the homeserver. As Matrix.org doesn’t have such an * option, this cancels all ongoing requests and clears the * authentication data (e.g. tokens). */ void -matrix_client_logout(MatrixClient *client) +matrix_client_logout(MatrixClient *client, GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->logout(client); + ->logout(client, error); } /** * matrix_client_refresh_token: * @client: a #MatrixClient + * @error: a location for a #GError, or %NULL * * Request a new authentication token from the server. */ void -matrix_client_refresh_token(MatrixClient *client) +matrix_client_refresh_token(MatrixClient *client, GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->refresh_token(client); + ->refresh_token(client, error); } /** * matrix_client_begin_polling: * @client: a #MatrixClient + * @error: a location for a #GError, or %NULL * * Begin polling the event stream. */ void -matrix_client_begin_polling(MatrixClient *client) +matrix_client_begin_polling(MatrixClient *client, GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->begin_polling(client); + ->begin_polling(client, error); } /** * matrix_client_stop_polling: * @client: a #MatrixClient * @cancel_ongoing: if %TRUE, ongoing requests will be cancelled, too + * @error: a location for a #GError, or %NULL * * Stop polling the event stream. If @cancel_ongoing is %TRUE, ongoing * requests will be cancelled, too. */ void -matrix_client_stop_polling(MatrixClient *client, gboolean cancel_ongoing) +matrix_client_stop_polling(MatrixClient *client, + gboolean cancel_ongoing, + GError **error) { g_return_if_fail(MATRIX_IS_CLIENT(client)); MATRIX_CLIENT_GET_IFACE(client) - ->stop_polling(client, cancel_ongoing); + ->stop_polling(client, cancel_ongoing, error); } diff --git a/src/matrix-client.h b/src/matrix-client.h index 54ea272..4fa2303 100644 --- a/src/matrix-client.h +++ b/src/matrix-client.h @@ -42,18 +42,19 @@ struct _MatrixClientInterface { /* Virtual table */ void (*login_with_password)(MatrixClient *client, const gchar *username, - const gchar *password); + const gchar *password, + GError **error); void (*register_with_password)(MatrixClient *client, const gchar *username, - const gchar *password); - void (*logout)(MatrixClient *client); - void (*refresh_token)(MatrixClient *client); + const gchar *password, + GError **error); + void (*logout)(MatrixClient *client, GError **error); + void (*refresh_token)(MatrixClient *client, GError **error); - void (*begin_polling)(MatrixClient *client); - void (*stop_polling)(MatrixClient *client, gboolean cancel_ongoing); - - void (*get_room)(MatrixClient *client, const gchar *room_id_or_alias); - void (*get_user)(MatrixClient *client, const gchar *user_id); + void (*begin_polling)(MatrixClient *client, GError **error); + void (*stop_polling)(MatrixClient *client, + gboolean cancel_ongoing, + GError **error); }; struct _MatrixClientClass { @@ -65,15 +66,19 @@ GType matrix_client_get_type(void) G_GNUC_CONST; void matrix_client_login_with_password(MatrixClient *client, const gchar *username, - const gchar *password); + const gchar *password, + GError **error); void matrix_client_register_with_password(MatrixClient *client, const gchar *username, - const gchar *password); -void matrix_client_logout(MatrixClient *client); -void matrix_client_refresh_token(MatrixClient *client); + const gchar *password, + GError **error); +void matrix_client_logout(MatrixClient *client, GError **error); +void matrix_client_refresh_token(MatrixClient *client, GError **error); -void matrix_client_begin_polling(MatrixClient *client); -void matrix_client_stop_polling(MatrixClient *client, gboolean cancel_ongoing); +void matrix_client_begin_polling(MatrixClient *client, GError **error); +void matrix_client_stop_polling(MatrixClient *client, + gboolean cancel_ongoing, + GError **error); G_END_DECLS