Rename MatrixAPIFilter to MatrixFilter

This commit is contained in:
Gergely Polonkai 2016-01-25 15:58:14 +01:00
parent 7ab4e556bd
commit 8f5877a2f0
6 changed files with 115 additions and 119 deletions

View File

@ -88,22 +88,22 @@ matrix_api_room_filter_get_json_node
matrix_api_room_filter_get_json_data matrix_api_room_filter_get_json_data
<SUBSECTION> <SUBSECTION>
MatrixAPIFilter MatrixFilter
matrix_api_filter_new matrix_filter_new
matrix_api_filter_ref matrix_filter_ref
matrix_api_filter_unref matrix_filter_unref
matrix_api_filter_set_event_fields matrix_filter_set_event_fields
matrix_api_filter_add_event_field matrix_filter_add_event_field
matrix_api_filter_delete_event_field matrix_filter_delete_event_field
matrix_api_filter_get_event_fields matrix_filter_get_event_fields
matrix_api_filter_set_event_format matrix_filter_set_event_format
matrix_api_filter_get_event_format matrix_filter_get_event_format
matrix_api_filter_set_presence_filter matrix_filter_set_presence_filter
matrix_api_filter_get_presence_filter matrix_filter_get_presence_filter
matrix_api_filter_set_room_filter matrix_filter_set_room_filter
matrix_api_filter_get_room_filter matrix_filter_get_room_filter
matrix_api_filter_get_json_node matrix_filter_get_json_node
matrix_api_filter_get_json_data matrix_filter_get_json_data
<SUBSECTION> <SUBSECTION>
MatrixAPI3PidCredential MatrixAPI3PidCredential
@ -185,8 +185,8 @@ MATRIX_TYPE_FILTER_RULES
matrix_filter_rules_get_type matrix_filter_rules_get_type
MATRIX_TYPE_API_ROOM_FILTER MATRIX_TYPE_API_ROOM_FILTER
matrix_api_room_filter_get_type matrix_api_room_filter_get_type
MATRIX_TYPE_API_FILTER MATRIX_TYPE_FILTER
matrix_api_filter_get_type matrix_filter_get_type
MATRIX_TYPE_API_3PID_CREDENTIAL MATRIX_TYPE_API_3PID_CREDENTIAL
matrix_api_3pid_credential_get_type matrix_api_3pid_credential_get_type
MATRIX_TYPE_API_PUSHER MATRIX_TYPE_API_PUSHER

View File

@ -1903,7 +1903,7 @@ matrix_api_sync(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *filter_id, const gchar *filter_id,
const MatrixAPIFilter *filter, const MatrixFilter *filter,
const gchar *since, const gchar *since,
gboolean full_state, gboolean full_state,
gboolean set_presence, gboolean set_presence,
@ -1945,7 +1945,7 @@ matrix_api_create_filter(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *user_id, const gchar *user_id,
MatrixAPIFilter *filter, MatrixFilter *filter,
GError **error) GError **error)
{ {
g_return_if_fail(MATRIX_IS_API(api)); g_return_if_fail(MATRIX_IS_API(api));

View File

@ -326,7 +326,7 @@ struct _MatrixAPIInterface {
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *filter_id, const gchar *filter_id,
const MatrixAPIFilter *filter, const MatrixFilter *filter,
const gchar *since, const gchar *since,
gboolean full_state, gboolean full_state,
gboolean set_presence, gboolean set_presence,
@ -336,7 +336,7 @@ struct _MatrixAPIInterface {
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *user_id, const gchar *user_id,
MatrixAPIFilter *filter, MatrixFilter *filter,
GError **error); GError **error);
void (*download_filter)(MatrixAPI *api, void (*download_filter)(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
@ -751,7 +751,7 @@ void matrix_api_sync(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *filter_id, const gchar *filter_id,
const MatrixAPIFilter *filter, const MatrixFilter *filter,
const gchar *since, const gchar *since,
gboolean full_state, gboolean full_state,
gboolean set_presence, gboolean set_presence,
@ -761,7 +761,7 @@ void matrix_api_create_filter(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *user_id, const gchar *user_id,
MatrixAPIFilter *filter, MatrixFilter *filter,
GError **error); GError **error);
void matrix_api_download_filter(MatrixAPI *api, void matrix_api_download_filter(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,

View File

@ -2177,7 +2177,7 @@ i_sync(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *filter_id, const gchar *filter_id,
const MatrixAPIFilter *filter, const MatrixFilter *filter,
const gchar *since, const gchar *since,
gboolean full_state, gboolean full_state,
gboolean set_presence, gboolean set_presence,
@ -2203,8 +2203,8 @@ i_sync(MatrixAPI *api,
if (filter) { if (filter) {
g_hash_table_replace(params, g_hash_table_replace(params,
"filter", "filter",
matrix_api_filter_get_json_data( matrix_filter_get_json_data(
(MatrixAPIFilter *)filter, (MatrixFilter *)filter,
NULL)); NULL));
} }
@ -2238,11 +2238,11 @@ i_create_filter(MatrixAPI *api,
MatrixAPICallback callback, MatrixAPICallback callback,
gpointer user_data, gpointer user_data,
const gchar *user_id, const gchar *user_id,
MatrixAPIFilter *filter, MatrixFilter *filter,
GError **error) GError **error)
{ {
gchar *encoded_user_id, *path; gchar *encoded_user_id, *path;
JsonNode *filter_node = matrix_api_filter_get_json_node(filter); JsonNode *filter_node = matrix_filter_get_json_node(filter);
encoded_user_id = soup_uri_encode(user_id, NULL); encoded_user_id = soup_uri_encode(user_id, NULL);
path = g_strdup_printf("user/%s/filter", encoded_user_id); path = g_strdup_printf("user/%s/filter", encoded_user_id);

View File

@ -1252,11 +1252,11 @@ matrix_api_room_filter_get_json_data(MatrixAPIRoomFilter *filter,
} }
/** /**
* MatrixAPIFilter: * MatrixFilter:
* *
* An opaque structure to hold an event filter. * An opaque structure to hold an event filter.
*/ */
struct _MatrixAPIFilter { struct _MatrixFilter {
GList *event_fields; GList *event_fields;
MatrixEventFormat event_format; MatrixEventFormat event_format;
MatrixFilterRules *presence; MatrixFilterRules *presence;
@ -1264,30 +1264,30 @@ struct _MatrixAPIFilter {
guint refcount; guint refcount;
}; };
G_DEFINE_BOXED_TYPE(MatrixAPIFilter, matrix_api_filter, G_DEFINE_BOXED_TYPE(MatrixFilter, matrix_filter,
(GBoxedCopyFunc)matrix_api_filter_ref, (GBoxedCopyFunc)matrix_filter_ref,
(GBoxedFreeFunc)matrix_api_filter_unref); (GBoxedFreeFunc)matrix_filter_unref);
/** /**
* matrix_api_filter_new: * matrix_filter_new:
* *
* Create a new #MatrixAPIFilter object with reference count of 1. * Create a new #MatrixFilter object with reference count of 1.
* *
* Returns: (transfer full): a new #MatrixAPIFilter * Returns: (transfer full): a new #MatrixFilter
*/ */
MatrixAPIFilter * MatrixFilter *
matrix_api_filter_new(void) matrix_filter_new(void)
{ {
MatrixAPIFilter *filter; MatrixFilter *filter;
filter = g_new0(MatrixAPIFilter, 1); filter = g_new0(MatrixFilter, 1);
filter->refcount = 1; filter->refcount = 1;
return filter; return filter;
} }
static void static void
matrix_api_filter_free(MatrixAPIFilter *filter) matrix_filter_free(MatrixFilter *filter)
{ {
g_list_free_full(filter->event_fields, g_free); g_list_free_full(filter->event_fields, g_free);
@ -1303,15 +1303,15 @@ matrix_api_filter_free(MatrixAPIFilter *filter)
} }
/** /**
* matrix_api_filter_ref: * matrix_filter_ref:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Increase reference count of @filter by one. * Increase reference count of @filter by one.
* *
* Returns: (transfer none): the same #MatrixAPIFilter * Returns: (transfer none): the same #MatrixFilter
*/ */
MatrixAPIFilter * MatrixFilter *
matrix_api_filter_ref(MatrixAPIFilter *filter) matrix_filter_ref(MatrixFilter *filter)
{ {
filter->refcount++; filter->refcount++;
@ -1319,23 +1319,23 @@ matrix_api_filter_ref(MatrixAPIFilter *filter)
} }
/** /**
* matrix_api_filter_unref: * matrix_filter_unref:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Decrease reference count of @filter by one. If reference count * Decrease reference count of @filter by one. If reference count
* reaches zero, @filter is freed. * reaches zero, @filter is freed.
*/ */
void void
matrix_api_filter_unref(MatrixAPIFilter *filter) matrix_filter_unref(MatrixFilter *filter)
{ {
if (--filter->refcount == 0) { if (--filter->refcount == 0) {
matrix_api_filter_free(filter); matrix_filter_free(filter);
} }
} }
/** /**
* matrix_api_filter_set_event_fields: * matrix_filter_set_event_fields:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @event_fields: (in) (element-type utf8) (transfer full) (allow-none): * @event_fields: (in) (element-type utf8) (transfer full) (allow-none):
* a list of event fields to include. If %NULL then all * a list of event fields to include. If %NULL then all
* fields are included. The entries may include * fields are included. The entries may include
@ -1349,25 +1349,23 @@ matrix_api_filter_unref(MatrixAPIFilter *filter)
* Set the event fields to include in the filtered events. * Set the event fields to include in the filtered events.
*/ */
void void
matrix_api_filter_set_event_fields(MatrixAPIFilter *filter, matrix_filter_set_event_fields(MatrixFilter *filter, GList *event_fields)
GList *event_fields)
{ {
g_list_free_full(filter->event_fields, g_free); g_list_free_full(filter->event_fields, g_free);
filter->event_fields = event_fields; filter->event_fields = event_fields;
} }
/** /**
* matrix_api_filter_add_event_field: * matrix_filter_add_event_field:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @event_field: an event field to add to the list. See * @event_field: an event field to add to the list. See
* matrix_api_filter_set_event_fields() for details * matrix_filter_set_event_fields() for details
* *
* Add an event field to the list of fields that will be present in * Add an event field to the list of fields that will be present in
* the filtered events. * the filtered events.
*/ */
void void
matrix_api_filter_add_event_field(MatrixAPIFilter *filter, matrix_filter_add_event_field(MatrixFilter *filter, const gchar *event_field)
const gchar *event_field)
{ {
g_return_if_fail(event_field != NULL); g_return_if_fail(event_field != NULL);
@ -1379,16 +1377,15 @@ matrix_api_filter_add_event_field(MatrixAPIFilter *filter,
} }
/** /**
* matrix_api_filter_delete_event_field: * matrix_filter_delete_event_field:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @event_field: an event field to remove from the list * @event_field: an event field to remove from the list
* *
* Remove @event_field from the list of fields that will be present in * Remove @event_field from the list of fields that will be present in
* the filtered events. * the filtered events.
*/ */
void void
matrix_api_filter_delete_event_field(MatrixAPIFilter *filter, matrix_filter_delete_event_field(MatrixFilter *filter, const gchar *event_field)
const gchar *event_field)
{ {
GList *event_field_element; GList *event_field_element;
@ -1404,8 +1401,8 @@ matrix_api_filter_delete_event_field(MatrixAPIFilter *filter,
} }
/** /**
* matrix_api_filter_get_event_fields: * matrix_filter_get_event_fields:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Get the list of event fields that will be present in the filtered * Get the list of event fields that will be present in the filtered
* events. * events.
@ -1415,49 +1412,49 @@ matrix_api_filter_delete_event_field(MatrixAPIFilter *filter,
* and should not be freed nor modified. * and should not be freed nor modified.
*/ */
const GList * const GList *
matrix_api_filter_get_event_fields(MatrixAPIFilter *filter) matrix_filter_get_event_fields(MatrixFilter *filter)
{ {
return filter->event_fields; return filter->event_fields;
} }
/** /**
* matrix_api_filter_set_event_format: * matrix_filter_set_event_format:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @event_format: the desired event format for filtered events * @event_format: the desired event format for filtered events
* *
* Set the desired event format for the filtered events (e.g. for * Set the desired event format for the filtered events (e.g. for
* matrix_api_sync()) * matrix_api_sync())
*/ */
void void
matrix_api_filter_set_event_format(MatrixAPIFilter *filter, matrix_filter_set_event_format(MatrixFilter *filter,
MatrixEventFormat event_format) MatrixEventFormat event_format)
{ {
filter->event_format = event_format; filter->event_format = event_format;
} }
/** /**
* matrix_api_filter_get_event_format: * matrix_filter_get_event_format:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Get the desired event format set in @filter. * Get the desired event format set in @filter.
* *
* Returns: the event format currently set * Returns: the event format currently set
*/ */
MatrixEventFormat MatrixEventFormat
matrix_api_filter_get_event_format(MatrixAPIFilter *filter) matrix_filter_get_event_format(MatrixFilter *filter)
{ {
return filter->event_format; return filter->event_format;
} }
/** /**
* matrix_api_filter_set_presence_filter: * matrix_filter_set_presence_filter:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @presence_filter: (transfer none): the desired filters to use * @presence_filter: (transfer none): the desired filters to use
* *
* Set a filtering ruleset for presence events. * Set a filtering ruleset for presence events.
*/ */
void void
matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter, matrix_filter_set_presence_filter(MatrixFilter *filter,
MatrixFilterRules *presence_filter) MatrixFilterRules *presence_filter)
{ {
if (filter->presence) { if (filter->presence) {
@ -1468,8 +1465,8 @@ matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter,
} }
/** /**
* matrix_api_filter_get_presence_filter: * matrix_filter_get_presence_filter:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Get the current filtering ruleset for presence events. * Get the current filtering ruleset for presence events.
* *
@ -1478,20 +1475,20 @@ matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter,
* separately, it should create a reference for it * separately, it should create a reference for it
*/ */
MatrixFilterRules * MatrixFilterRules *
matrix_api_filter_get_presence_filter(MatrixAPIFilter *filter) matrix_filter_get_presence_filter(MatrixFilter *filter)
{ {
return filter->presence; return filter->presence;
} }
/** /**
* matrix_api_filter_set_room_filter: * matrix_filter_set_room_filter:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @room_filter: the desired room filters to use in @filter * @room_filter: the desired room filters to use in @filter
* *
* Set a new filtering ruleset for room events in @filter. * Set a new filtering ruleset for room events in @filter.
*/ */
void void
matrix_api_filter_set_room_filter(MatrixAPIFilter *filter, matrix_filter_set_room_filter(MatrixFilter *filter,
MatrixAPIRoomFilter *room_filter) MatrixAPIRoomFilter *room_filter)
{ {
if (filter->room) { if (filter->room) {
@ -1502,8 +1499,8 @@ matrix_api_filter_set_room_filter(MatrixAPIFilter *filter,
} }
/** /**
* matrix_api_filter_get_room_filter: * matrix_filter_get_room_filter:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Get the filtering ruleset for room events in @filter. * Get the filtering ruleset for room events in @filter.
* *
@ -1511,21 +1508,21 @@ matrix_api_filter_set_room_filter(MatrixAPIFilter *filter,
* events * events
*/ */
MatrixAPIRoomFilter * MatrixAPIRoomFilter *
matrix_api_filter_get_room_filter(MatrixAPIFilter *filter) matrix_filter_get_room_filter(MatrixFilter *filter)
{ {
return filter->room; return filter->room;
} }
/** /**
* matrix_api_filter_get_json_node: * matrix_filter_get_json_node:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* *
* Get the JSON representation of @filter as a #JsonNode * Get the JSON representation of @filter as a #JsonNode
* *
* Returns: (transfer full): the JSON representation of @filter * Returns: (transfer full): the JSON representation of @filter
*/ */
JsonNode * JsonNode *
matrix_api_filter_get_json_node(MatrixAPIFilter *filter) matrix_filter_get_json_node(MatrixFilter *filter)
{ {
JsonBuilder *builder; JsonBuilder *builder;
JsonNode *root, *tmp; JsonNode *root, *tmp;
@ -1563,8 +1560,8 @@ matrix_api_filter_get_json_node(MatrixAPIFilter *filter)
} }
/** /**
* matrix_api_filter_get_json_data: * matrix_filter_get_json_data:
* @filter: a #MatrixAPIFilter * @filter: a #MatrixFilter
* @datalen: storage for the length of the JSON data, or %NULL * @datalen: storage for the length of the JSON data, or %NULL
* *
* Get the JSON representation of @filter as a string. * Get the JSON representation of @filter as a string.
@ -1572,10 +1569,10 @@ matrix_api_filter_get_json_node(MatrixAPIFilter *filter)
* Returns: (transfer full): the JSON representation of @filter * Returns: (transfer full): the JSON representation of @filter
*/ */
gchar * gchar *
matrix_api_filter_get_json_data(MatrixAPIFilter *filter, gsize *datalen) matrix_filter_get_json_data(MatrixFilter *filter, gsize *datalen)
{ {
JsonGenerator *generator; JsonGenerator *generator;
JsonNode *node = matrix_api_filter_get_json_node(filter); JsonNode *node = matrix_filter_get_json_node(filter);
gchar *data; gchar *data;
generator = json_generator_new(); generator = json_generator_new();

View File

@ -189,32 +189,31 @@ JsonNode *matrix_api_room_filter_get_json_node(MatrixAPIRoomFilter *filter);
gchar *matrix_api_room_filter_get_json_data(MatrixAPIRoomFilter *filter, gchar *matrix_api_room_filter_get_json_data(MatrixAPIRoomFilter *filter,
gsize *datalen); gsize *datalen);
typedef struct _MatrixAPIFilter MatrixAPIFilter; typedef struct _MatrixFilter MatrixFilter;
GType matrix_api_filter_get_type(void); GType matrix_filter_get_type(void);
#define MATRIX_TYPE_API_FILTER (matrix_api_filter_get_type()) #define MATRIX_TYPE_FILTER (matrix_filter_get_type())
MatrixAPIFilter *matrix_api_filter_new(void); MatrixFilter *matrix_filter_new(void);
MatrixAPIFilter *matrix_api_filter_ref(MatrixAPIFilter *filter); MatrixFilter *matrix_filter_ref(MatrixFilter *filter);
void matrix_api_filter_unref(MatrixAPIFilter *filter); void matrix_filter_unref(MatrixFilter *filter);
void matrix_api_filter_set_event_fields(MatrixAPIFilter *filter, void matrix_filter_set_event_fields(MatrixFilter *filter, GList *event_fields);
GList *event_fields); void matrix_filter_add_event_field(MatrixFilter *filter,
void matrix_api_filter_add_event_field(MatrixAPIFilter *filter,
const gchar *event_field); const gchar *event_field);
void matrix_api_filter_delete_event_field(MatrixAPIFilter *filter, void matrix_filter_delete_event_field(MatrixFilter *filter,
const gchar *event_field); const gchar *event_field);
const GList *matrix_api_filter_get_event_fields(MatrixAPIFilter *filter); const GList *matrix_filter_get_event_fields(MatrixFilter *filter);
void matrix_api_filter_set_event_format(MatrixAPIFilter *filter, void matrix_filter_set_event_format(MatrixFilter *filter,
MatrixEventFormat event_format); MatrixEventFormat event_format);
MatrixEventFormat matrix_api_filter_get_event_format(MatrixAPIFilter *filter); MatrixEventFormat matrix_filter_get_event_format(MatrixFilter *filter);
void matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter, void matrix_filter_set_presence_filter(MatrixFilter *filter,
MatrixFilterRules *presence_filter); MatrixFilterRules *presence_filter);
MatrixFilterRules *matrix_api_filter_get_presence_filter(MatrixAPIFilter *filter); MatrixFilterRules *matrix_filter_get_presence_filter(MatrixFilter *filter);
void matrix_api_filter_set_room_filter(MatrixAPIFilter *filter, void matrix_filter_set_room_filter(MatrixFilter *filter,
MatrixAPIRoomFilter *room_filter); MatrixAPIRoomFilter *room_filter);
MatrixAPIRoomFilter *matrix_api_filter_get_room_filter(MatrixAPIFilter *filter); MatrixAPIRoomFilter *matrix_filter_get_room_filter(MatrixFilter *filter);
JsonNode *matrix_api_filter_get_json_node(MatrixAPIFilter *filter); JsonNode *matrix_filter_get_json_node(MatrixFilter *filter);
gchar *matrix_api_filter_get_json_data(MatrixAPIFilter *filter, gsize *datalen); gchar *matrix_filter_get_json_data(MatrixFilter *filter, gsize *datalen);
typedef struct _MatrixAPI3PidCredential MatrixAPI3PidCredential; typedef struct _MatrixAPI3PidCredential MatrixAPI3PidCredential;