From 3993bb112cc4bee7698ce8a55f81cbce1901e59f Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Fri, 22 Jan 2016 15:58:09 +0100 Subject: [PATCH] Add MatrixAPI.abort_pending definition --- .../matrix-glib/matrix-glib-sections.txt | 3 +++ src/matrix-api.c | 23 +++++++++++++++++++ src/matrix-api.h | 8 +++++++ src/matrix-http-api.c | 3 +++ 4 files changed, 37 insertions(+) diff --git a/docs/reference/matrix-glib/matrix-glib-sections.txt b/docs/reference/matrix-glib/matrix-glib-sections.txt index 492dfd9..d160d09 100644 --- a/docs/reference/matrix-glib/matrix-glib-sections.txt +++ b/docs/reference/matrix-glib/matrix-glib-sections.txt @@ -292,6 +292,9 @@ matrix_api_add_room_tag matrix_api_get_turn_server + +matrix_api_abort_pending + MatrixAPI MATRIX_TYPE_API_ERROR diff --git a/src/matrix-api.c b/src/matrix-api.c index 377d7d2..9120ff9 100644 --- a/src/matrix-api.c +++ b/src/matrix-api.c @@ -100,6 +100,7 @@ * @delete_room_tag: virtual function for matrix_api_delete_room_tag() * @add_room_tag: virtual function for matrix_api_add_room_tag() * @get_turn_server: virtual function for matrix_api_get_turn_server() + * @abort_pending: virtual function for matrix_api_abort_pending() * * The interface vtable for #MatrixAPI */ @@ -2681,3 +2682,25 @@ matrix_api_get_turn_server(MatrixAPI *api, MATRIX_API_GET_IFACE(api) ->get_turn_server(api, callback, user_data, error); } + +/* Non-spec methods */ + +/** + * matrix_api_abort_pending: + * @api: a #MatrixAPI implementation + * + * Abort all pending requests toward the Matrix server. Be aware that + * this may leave requests in an incosistent state. + * + * Implementations that provide only synchronous requests can choose + * not to implement this function. + */ +void +matrix_api_abort_pending(MatrixAPI *api) +{ + g_return_if_fail(MATRIX_IS_API(api)); + + if (MATRIX_API_GET_IFACE(api)->abort_pending) { + MATRIX_API_GET_IFACE(api)->abort_pending(api); + } +} diff --git a/src/matrix-api.h b/src/matrix-api.h index bda305e..0560596 100644 --- a/src/matrix-api.h +++ b/src/matrix-api.h @@ -465,6 +465,10 @@ struct _MatrixAPIInterface { gpointer user_data, GError **error); + /* Non-spec methods */ + + void (*abort_pending)(MatrixAPI *api); + /*< private >*/ /* Leave room for endpoint expansion */ void *padding[50]; @@ -885,6 +889,10 @@ void matrix_api_get_turn_server(MatrixAPI *api, gpointer user_data, GError **error); +/* Non-spec methods */ + +void matrix_api_abort_pending(MatrixAPI *api); + G_END_DECLS #endif /* __MATRIX_API_IFACE_H__ */ diff --git a/src/matrix-http-api.c b/src/matrix-http-api.c index 0ccd0f6..ca1548b 100644 --- a/src/matrix-http-api.c +++ b/src/matrix-http-api.c @@ -2832,4 +2832,7 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface) /* VoIP */ iface->get_turn_server = NULL; + + /* Non-spec methods */ + iface->abort_pending = NULL; }