diff --git a/docs/reference/matrix-glib-sdk/matrix-glib-sdk-sections.txt b/docs/reference/matrix-glib-sdk/matrix-glib-sdk-sections.txt index b840a06..e0f09f3 100644 --- a/docs/reference/matrix-glib-sdk/matrix-glib-sdk-sections.txt +++ b/docs/reference/matrix-glib-sdk/matrix-glib-sdk-sections.txt @@ -50,6 +50,7 @@ matrix_api_forget_room matrix_api_invite_user_3rdparty matrix_api_invite_user matrix_api_join_room +matrix_api_get_joined_rooms matrix_api_kick_user matrix_api_leave_room matrix_api_unban_user diff --git a/src/matrix-api.c b/src/matrix-api.c index 543ea00..fd8e1e0 100644 --- a/src/matrix-api.c +++ b/src/matrix-api.c @@ -78,6 +78,7 @@ * @invite_user_3rdparty: the virtual function pointer to matrix_api_invite_user_3rdparty() * @invite_user: the virtual function pointer to matrix_api_invite_user() * @join_room: the virtual function pointer to matrix_api_join_room() + * @get_joined_rooms: the virtual function pointer to matrix_api_get_joined_rooms() * @kick_user: the virtual function pointer to matrix_api_kick_user() * @leave_room: the virtual function pointer to matrix_api_leave_room() * @unban_user: the virtual function pointer to matrix_api_unban_user() @@ -657,6 +658,26 @@ matrix_api_delete_room_alias(MatrixAPI *matrix_api, MATRIX_API_GET_IFACE(matrix_api)->delete_room_alias(matrix_api, callback, user_data, room_alias, error); } +/** + * matrix_api_get_joined_rooms: + * @api: a #MatrixAPI + * @callback: the function to call when the request is finished + * @user_data: user data to be passed to @callback + * @error: (nullable): a #GError, or %NULL to ignore errors + * + * Get the rooms the current user is joined to. + */ +void +matrix_api_get_joined_rooms(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + GError **error) +{ + g_return_if_fail(api != NULL); + + MATRIX_API_GET_IFACE(api)->get_joined_rooms(api, callback, user_data, error); +} + /** * matrix_api_get_room_id: * @api: a #MatrixAPI diff --git a/src/matrix-api.h b/src/matrix-api.h index dc474f3..9c73b54 100644 --- a/src/matrix-api.h +++ b/src/matrix-api.h @@ -172,6 +172,10 @@ struct _MatrixAPIInterface { gpointer user_data, const gchar *room_alias, GError **error); + void (*get_joined_rooms)(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + GError **error); void (*get_room_id)(MatrixAPI *api, MatrixAPICallback callback, gpointer user_data, @@ -601,6 +605,10 @@ void matrix_api_delete_room_alias(MatrixAPI *api, MatrixAPICallback callback, gpointer user_data, GError **error); +void matrix_api_get_joined_rooms(MatrixAPI *api, + MatrixAPICallback callback, + gpointer user_data, + GError **error); void matrix_api_get_room_id(MatrixAPI *api, const gchar *room_alias, MatrixAPICallback callback, diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 6c50dd5..a24709c 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -2212,6 +2212,15 @@ whoami(MatrixAPI *api, MatrixAPICallback cb, void *cb_target, GError **error) NULL, NULL, NULL, NULL, FALSE, error); } +static void +get_joined_rooms(MatrixAPI *api, MatrixAPICallback cb, void *cb_target, GError **error) +{ + _matrix_http_api_send(MATRIX_HTTP_API(api), + cb, cb_target, + CALL_TYPE_API, "GET", "joined_rooms", + NULL, NULL, NULL, NULL, FALSE, error); +} + static void matrix_http_api_abort_pending (MatrixAPI *matrix_api) { @@ -2583,6 +2592,7 @@ matrix_http_api_matrix_api_interface_init(MatrixAPIInterface * iface) iface->set_token = matrix_http_api_set_token; iface->get_homeserver = matrix_http_api_get_homeserver; iface->whoami = whoami; + iface->get_joined_rooms = get_joined_rooms; } static void