Add API method for /joined_rooms

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

View File

@ -50,6 +50,7 @@ matrix_api_forget_room
matrix_api_invite_user_3rdparty matrix_api_invite_user_3rdparty
matrix_api_invite_user matrix_api_invite_user
matrix_api_join_room matrix_api_join_room
matrix_api_get_joined_rooms
matrix_api_kick_user matrix_api_kick_user
matrix_api_leave_room matrix_api_leave_room
matrix_api_unban_user 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_3rdparty: the virtual function pointer to matrix_api_invite_user_3rdparty()
* @invite_user: the virtual function pointer to matrix_api_invite_user() * @invite_user: the virtual function pointer to matrix_api_invite_user()
* @join_room: the virtual function pointer to matrix_api_join_room() * @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() * @kick_user: the virtual function pointer to matrix_api_kick_user()
* @leave_room: the virtual function pointer to matrix_api_leave_room() * @leave_room: the virtual function pointer to matrix_api_leave_room()
* @unban_user: the virtual function pointer to matrix_api_unban_user() * @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_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: * matrix_api_get_room_id:
* @api: a #MatrixAPI * @api: a #MatrixAPI

View File

@ -172,6 +172,10 @@ struct _MatrixAPIInterface {
gpointer user_data, gpointer user_data,
const gchar *room_alias, const gchar *room_alias,
GError **error); GError **error);
void (*get_joined_rooms)(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
GError **error);
void (*get_room_id)(MatrixAPI *api, void (*get_room_id)(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
@ -601,6 +605,10 @@ void matrix_api_delete_room_alias(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
GError **error); 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, void matrix_api_get_room_id(MatrixAPI *api,
const gchar *room_alias, const gchar *room_alias,
MatrixAPICallback callback, MatrixAPICallback callback,

View File

@ -2212,6 +2212,15 @@ whoami(MatrixAPI *api, MatrixAPICallback cb, void *cb_target, GError **error)
NULL, NULL, NULL, NULL, FALSE, 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 static void
matrix_http_api_abort_pending (MatrixAPI *matrix_api) 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->set_token = matrix_http_api_set_token;
iface->get_homeserver = matrix_http_api_get_homeserver; iface->get_homeserver = matrix_http_api_get_homeserver;
iface->whoami = whoami; iface->whoami = whoami;
iface->get_joined_rooms = get_joined_rooms;
} }
static void static void