Add API method for /joined_rooms

This commit is contained in:
Gergely Polonkai 2018-02-28 11:12:34 +01:00
parent 1be76ea025
commit db912dd701
4 changed files with 40 additions and 0 deletions

View File

@ -48,6 +48,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

View File

@ -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()
@ -661,6 +662,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: (scope async): 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

View File

@ -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,

View File

@ -2206,6 +2206,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)
{
@ -2577,6 +2586,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