Rename MatrixAPIFilterRules to MatrixFilterRules

This commit is contained in:
Gergely Polonkai 2016-01-25 13:03:26 +01:00
parent e163e73f2c
commit 7ab4e556bd
3 changed files with 268 additions and 282 deletions

View File

@ -38,38 +38,38 @@ MatrixReceiptType
MatrixAccountKind
<SUBSECTION>
MatrixAPIFilterRules
matrix_api_filter_rules_new
matrix_api_filter_rules_ref
matrix_api_filter_rules_unref
matrix_api_filter_rules_set_limit
matrix_api_filter_rules_get_limit
matrix_api_filter_rules_set_rooms
matrix_api_filter_rules_add_room
matrix_api_filter_rules_delete_room
matrix_api_filter_rules_get_rooms
matrix_api_filter_rules_set_excluded_rooms
matrix_api_filter_rules_add_excluded_room
matrix_api_filter_rules_delete_excluded_room
matrix_api_filter_rules_get_excluded_rooms
matrix_api_filter_rules_set_senders
matrix_api_filter_rules_add_sender
matrix_api_filter_rules_delete_sender
matrix_api_filter_rules_get_senders
matrix_api_filter_rules_set_excluded_senders
matrix_api_filter_rules_add_excluded_sender
matrix_api_filter_rules_delete_excluded_sender
matrix_api_filter_rules_get_excluded_senders
matrix_api_filter_rules_set_types
matrix_api_filter_rules_add_type
matrix_api_filter_rules_delete_type
matrix_api_filter_rules_get_types
matrix_api_filter_rules_set_excluded_types
matrix_api_filter_rules_add_excluded_type
matrix_api_filter_rules_delete_excluded_type
matrix_api_filter_rules_get_excluded_types
matrix_api_filter_rules_get_json_node
matrix_api_filter_rules_get_json_data
MatrixFilterRules
matrix_filter_rules_new
matrix_filter_rules_ref
matrix_filter_rules_unref
matrix_filter_rules_set_limit
matrix_filter_rules_get_limit
matrix_filter_rules_set_rooms
matrix_filter_rules_add_room
matrix_filter_rules_delete_room
matrix_filter_rules_get_rooms
matrix_filter_rules_set_excluded_rooms
matrix_filter_rules_add_excluded_room
matrix_filter_rules_delete_excluded_room
matrix_filter_rules_get_excluded_rooms
matrix_filter_rules_set_senders
matrix_filter_rules_add_sender
matrix_filter_rules_delete_sender
matrix_filter_rules_get_senders
matrix_filter_rules_set_excluded_senders
matrix_filter_rules_add_excluded_sender
matrix_filter_rules_delete_excluded_sender
matrix_filter_rules_get_excluded_senders
matrix_filter_rules_set_types
matrix_filter_rules_add_type
matrix_filter_rules_delete_type
matrix_filter_rules_get_types
matrix_filter_rules_set_excluded_types
matrix_filter_rules_add_excluded_type
matrix_filter_rules_delete_excluded_type
matrix_filter_rules_get_excluded_types
matrix_filter_rules_get_json_node
matrix_filter_rules_get_json_data
<SUBSECTION>
MatrixAPIRoomFilter
@ -181,8 +181,8 @@ MATRIX_TYPE_RECEIPT_TYPE
matrix_receipt_type_get_type
MATRIX_TYPE_ACCOUNT_KIND
matrix_account_kind_get_type
MATRIX_TYPE_API_FILTER_RULES
matrix_api_filter_rules_get_type
MATRIX_TYPE_FILTER_RULES
matrix_filter_rules_get_type
MATRIX_TYPE_API_ROOM_FILTER
matrix_api_room_filter_get_type
MATRIX_TYPE_API_FILTER

View File

@ -230,14 +230,14 @@ G_DEFINE_QUARK(matrix-error-quark, matrix_error);
*/
/**
* MatrixAPIFilterRules: (ref-func matrix_api_filter_rules_ref) (unref-func matrix_api_filter_rules_unref)
* MatrixFilterRules: (ref-func matrix_filter_rules_ref) (unref-func matrix_filter_rules_unref)
*
* An opaque structure to hold filter rules that can be used to filter
* events in the event stream. It is possible to filter by event type,
* room and sender ID.
*/
struct _MatrixAPIFilterRules {
struct _MatrixFilterRules {
guint limit;
GList *rooms;
GList *excluded_rooms;
@ -248,31 +248,31 @@ struct _MatrixAPIFilterRules {
guint refcount;
};
G_DEFINE_BOXED_TYPE(MatrixAPIFilterRules, matrix_api_filter_rules,
(GBoxedCopyFunc)matrix_api_filter_rules_ref,
(GBoxedFreeFunc)matrix_api_filter_rules_unref);
G_DEFINE_BOXED_TYPE(MatrixFilterRules, matrix_filter_rules,
(GBoxedCopyFunc)matrix_filter_rules_ref,
(GBoxedFreeFunc)matrix_filter_rules_unref);
/**
* matrix_api_filter_rules_new:
* matrix_filter_rules_new:
*
* Create a new #MatrixAPIFilterRules object with reference count of
* Create a new #MatrixFilterRules object with reference count of
* 1.
*
* Returns: (transfer full): a new #MatrixAPIFilterRules
* Returns: (transfer full): a new #MatrixFilterRules
*/
MatrixAPIFilterRules *
matrix_api_filter_rules_new(void)
MatrixFilterRules *
matrix_filter_rules_new(void)
{
MatrixAPIFilterRules *rules;
MatrixFilterRules *rules;
rules = g_new0(MatrixAPIFilterRules, 1);
rules = g_new0(MatrixFilterRules, 1);
rules->refcount = 1;
return rules;
}
static void
matrix_api_filter_rules_free(MatrixAPIFilterRules *rules)
matrix_filter_rules_free(MatrixFilterRules *rules)
{
g_list_free_full(rules->rooms, g_free);
g_list_free_full(rules->excluded_rooms, g_free);
@ -285,15 +285,15 @@ matrix_api_filter_rules_free(MatrixAPIFilterRules *rules)
}
/**
* matrix_api_filter_rules_ref:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_ref:
* @rules: a #MatrixFilterRules
*
* Increase reference count of @rules by one.
*
* Returns: (transfer none): the same #MatrixAPIFilterRules
* Returns: (transfer none): the same #MatrixFilterRules
*/
MatrixAPIFilterRules *
matrix_api_filter_rules_ref(MatrixAPIFilterRules *rules)
MatrixFilterRules *
matrix_filter_rules_ref(MatrixFilterRules *rules)
{
rules->refcount++;
@ -301,56 +301,56 @@ matrix_api_filter_rules_ref(MatrixAPIFilterRules *rules)
}
/**
* matrix_api_filter_rules_unref:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_unref:
* @rules: a #MatrixFilterRules
*
* Decrease reference count of @rules by one. If reference count
* reaches zero, @rules is freed.
*/
void
matrix_api_filter_rules_unref(MatrixAPIFilterRules *rules)
matrix_filter_rules_unref(MatrixFilterRules *rules)
{
if (--rules->refcount == 0) {
matrix_api_filter_rules_free(rules);
matrix_filter_rules_free(rules);
}
}
/**
* matrix_api_filter_rules_set_limit:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_limit:
* @rules: a #MatrixFilterRules
* @limit: (in): the maximum number of events to return.
*
* Set the maximum number of events to return by the filter. If @limit
* is <code>0</code>, no limit will be applied.
*/
void
matrix_api_filter_rules_set_limit(MatrixAPIFilterRules *rules, guint limit)
matrix_filter_rules_set_limit(MatrixFilterRules *rules, guint limit)
{
rules->limit = limit;
}
/**
* matrix_api_filter_rules_get_limit:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_limit:
* @rules: a #MatrixFilterRules
*
* Get the current limit set in @rules.
*
* Returns: the limit currently set
*/
guint
matrix_api_filter_rules_get_limit(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_limit(MatrixFilterRules *rules)
{
return rules->limit;
}
/**
* matrix_api_filter_rules_set_senders:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_senders:
* @rules: a #MatrixFilterRules
* @senders: (in) (element-type utf8) (transfer full) (allow-none):
* a list of Matrix user IDs. Events from these users will
* be included in the filtered event list.If %NULL then all
* senders are included. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Set the list of user IDs to include in the filtered events. @rules
@ -358,15 +358,15 @@ matrix_api_filter_rules_get_limit(MatrixAPIFilterRules *rules)
* directly after this call.
*/
void
matrix_api_filter_rules_set_senders(MatrixAPIFilterRules *rules, GList *senders)
matrix_filter_rules_set_senders(MatrixFilterRules *rules, GList *senders)
{
g_list_free_full(rules->senders, g_free);
rules->senders = senders;
}
/**
* matrix_api_filter_rules_add_sender:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_sender:
* @rules: a #MatrixFilterRules
* @sender: (in): a Matrix user ID to add to the included senders
* list. A <code>*</code> can be used as a wildcard to match
* any sequence of characters
@ -376,8 +376,7 @@ matrix_api_filter_rules_set_senders(MatrixAPIFilterRules *rules, GList *senders)
* nothing happens.
*/
void
matrix_api_filter_rules_add_sender(MatrixAPIFilterRules *rules,
const gchar *sender)
matrix_filter_rules_add_sender(MatrixFilterRules *rules, const gchar *sender)
{
g_return_if_fail(sender != NULL);
@ -387,16 +386,15 @@ matrix_api_filter_rules_add_sender(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_delete_sender:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_sender:
* @rules: a #MatrixFilterRules
* @sender: (in): the user ID to remove from the senders list
*
* Remove @sender from the list of user IDs to include in the filtered
* event list.
*/
void
matrix_api_filter_rules_delete_sender(MatrixAPIFilterRules *rules,
const gchar *sender)
matrix_filter_rules_delete_sender(MatrixFilterRules *rules, const gchar *sender)
{
GList *sender_element;
@ -410,8 +408,8 @@ matrix_api_filter_rules_delete_sender(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_senders:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_senders:
* @rules: a #MatrixFilterRules
*
* Get the list of user IDs that will be included in the filtered
* events.
@ -421,50 +419,50 @@ matrix_api_filter_rules_delete_sender(MatrixAPIFilterRules *rules,
* and should not be freed nor modified
*/
const GList *
matrix_api_filter_rules_get_senders(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_senders(MatrixFilterRules *rules)
{
return rules->senders;
}
/**
* matrix_api_filter_rules_set_excluded_senders:
* @rules: a #MatrixAPIFilterRules
* @senders: (in) (element-type utf8) (transfer full) (allow-none):
* a list of Matrix user IDs. Events from these users will
* be included in the filtered event list.If %NULL then all
* matrix_filter_rules_set_excluded_senders:
* @rules: a #MatrixFilterRules
* @senders: (in) (element-type utf8) (transfer full) (allow-none): a
* list of Matrix user IDs. Events from these users will be
* included in the filtered event list.If %NULL then all
* senders are included. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Set the list of Matrix user IDs to exclude from the filtered
* events. A matching sender will be excluded even if it is listed in
* the senders list (specified by
* e.g. matrix_api_filter_rules_set_senders()). @rules takes
* ownership of @senders, so it should not be freed nor modified
* directly after this call.
* e.g. matrix_filter_rules_set_senders()). @rules takes ownership of
* @senders, so it should not be freed nor modified directly after
* this call.
*/
void
matrix_api_filter_rules_set_excluded_senders(MatrixAPIFilterRules *rules,
GList *senders)
matrix_filter_rules_set_excluded_senders(MatrixFilterRules *rules,
GList *senders)
{
g_list_free_full(rules->excluded_senders, g_free);
rules->excluded_senders = senders;
}
/**
* matrix_api_filter_rules_add_excluded_sender:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_excluded_sender:
* @rules: a #MatrixFilterRules
* @sender: (in): a Matrix user ID to add to the excluded senders
* list. See matrix_api_filter_rules_add_sender() for
* wildcarding possibilities
* list. See matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Add @sender to the list of user IDs to exclude from the filtered
* event list. If @sender is already in the excluded senders list,
* nothing happens.
*/
void
matrix_api_filter_rules_add_excluded_sender(MatrixAPIFilterRules *rules,
const gchar *sender)
matrix_filter_rules_add_excluded_sender(MatrixFilterRules *rules,
const gchar *sender)
{
g_return_if_fail(sender != NULL);
@ -476,8 +474,8 @@ matrix_api_filter_rules_add_excluded_sender(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_delete_excluded_sender:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_excluded_sender:
* @rules: a #MatrixFilterRules
* @sender: (in): the Matrix user ID to remove from the excluded
* senders list
*
@ -485,8 +483,8 @@ matrix_api_filter_rules_add_excluded_sender(MatrixAPIFilterRules *rules,
* filtered event list.
*/
void
matrix_api_filter_rules_delete_excluded_sender(MatrixAPIFilterRules *rules,
const gchar *sender)
matrix_filter_rules_delete_excluded_sender(MatrixFilterRules *rules,
const gchar *sender)
{
GList *sender_element;
@ -501,8 +499,8 @@ matrix_api_filter_rules_delete_excluded_sender(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_excluded_senders:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_excluded_senders:
* @rules: a #MatrixFilterRules
*
* Get the list of user IDs that will be excluded in the filtered
* events.
@ -512,18 +510,18 @@ matrix_api_filter_rules_delete_excluded_sender(MatrixAPIFilterRules *rules,
* owned by @rules and should not be freed nor modified.
*/
const GList *
matrix_api_filter_rules_get_excluded_senders(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_excluded_senders(MatrixFilterRules *rules)
{
return rules->excluded_senders;
}
/**
* matrix_api_filter_rules_set_rooms:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_rooms:
* @rules: a #MatrixFilterRules
* @rooms: (in) (element-type utf8) (transfer full) (allow-none): a
* list of room IDs. Events from these rooms will be included
* in the filtered event list.If %NULL then all rooms are
* included. See matrix_api_filter_rules_add_sender() for
* included. See matrix_filter_rules_add_sender() for
* wildcarding possibilities
*
* Set the list of room IDs to include in the filtered events. @rules
@ -531,17 +529,17 @@ matrix_api_filter_rules_get_excluded_senders(MatrixAPIFilterRules *rules)
* directly after this call.
*/
void
matrix_api_filter_rules_set_rooms(MatrixAPIFilterRules *rules, GList *rooms)
matrix_filter_rules_set_rooms(MatrixFilterRules *rules, GList *rooms)
{
g_list_free_full(rules->rooms, g_free);
rules->rooms = rooms;
}
/**
* matrix_api_filter_rules_add_room:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_room:
* @rules: a #MatrixFilterRules
* @room: (in): a room ID to add to the included rooms list. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Add @room to the list of room IDs to include in the filtered
@ -549,8 +547,7 @@ matrix_api_filter_rules_set_rooms(MatrixAPIFilterRules *rules, GList *rooms)
* nothing happens.
*/
void
matrix_api_filter_rules_add_room(MatrixAPIFilterRules *rules,
const gchar *room)
matrix_filter_rules_add_room(MatrixFilterRules *rules, const gchar *room)
{
g_return_if_fail(room != NULL);
@ -560,16 +557,15 @@ matrix_api_filter_rules_add_room(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_delete_room:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_room:
* @rules: a #MatrixFilterRules
* @room: (in): the room ID to remove from the rooms list
*
* Remove @room from the list of room IDs to include in the filtered
* event list.
*/
void
matrix_api_filter_rules_delete_room(MatrixAPIFilterRules *rules,
const gchar *room)
matrix_filter_rules_delete_room(MatrixFilterRules *rules, const gchar *room)
{
GList *room_element;
@ -583,8 +579,8 @@ matrix_api_filter_rules_delete_room(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_rooms:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_rooms:
* @rules: a #MatrixFilterRules
*
* Get the list of room IDs that will be included in the filtered
* events.
@ -594,40 +590,38 @@ matrix_api_filter_rules_delete_room(MatrixAPIFilterRules *rules,
* and should not be freed nor modified
*/
const GList *
matrix_api_filter_rules_get_rooms(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_rooms(MatrixFilterRules *rules)
{
return rules->rooms;
}
/**
* matrix_api_filter_rules_set_excluded_rooms:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_excluded_rooms:
* @rules: a #MatrixFilterRules
* @rooms: (in) (element-type utf8) (transfer full) (allow-none): a
* list of room IDs. Events from these rooms will be included
* in the filtered event list.If %NULL, then all rooms are
* included. See matrix_api_filter_rules_add_sender() for
* included. See matrix_filter_rules_add_sender() for
* wildcarding possibilities
*
* Set the list of room IDs to exclude from the filtered events. A
* matching room will be excluded even if it is listed in the rooms
* list (specified by
* e.g. matrix_api_filter_rules_set_rooms()). @rules takes ownership
* of @rooms, so it should not be freed nor modified directly after
* this call.
* list (specified by e.g. matrix_filter_rules_set_rooms()). @rules
* takes ownership of @rooms, so it should not be freed nor modified
* directly after this call.
*/
void
matrix_api_filter_rules_set_excluded_rooms(MatrixAPIFilterRules *rules,
GList *rooms)
matrix_filter_rules_set_excluded_rooms(MatrixFilterRules *rules, GList *rooms)
{
g_list_free_full(rules->excluded_rooms, g_free);
rules->excluded_rooms = rooms;
}
/**
* matrix_api_filter_rules_add_excluded_room:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_excluded_room:
* @rules: a #MatrixFilterRules
* @room: (in): a room ID to add to the excluded rooms list. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Add @room to the list of room IDs to exclude from the filtered
@ -635,8 +629,8 @@ matrix_api_filter_rules_set_excluded_rooms(MatrixAPIFilterRules *rules,
* happens.
*/
void
matrix_api_filter_rules_add_excluded_room(MatrixAPIFilterRules *rules,
const gchar *room)
matrix_filter_rules_add_excluded_room(MatrixFilterRules *rules,
const gchar *room)
{
g_return_if_fail(room != NULL);
@ -648,16 +642,16 @@ matrix_api_filter_rules_add_excluded_room(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_delete_excluded_room:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_excluded_room:
* @rules: a #MatrixFilterRules
* @room: (in): the room ID to remove from the excluded rooms list
*
* Remove @room from the list of room IDs to exclude from the filtered
* event list.
*/
void
matrix_api_filter_rules_delete_excluded_room(MatrixAPIFilterRules *rules,
const gchar *room)
matrix_filter_rules_delete_excluded_room(MatrixFilterRules *rules,
const gchar *room)
{
GList *room_element;
@ -672,8 +666,8 @@ matrix_api_filter_rules_delete_excluded_room(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_excluded_rooms:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_excluded_rooms:
* @rules: a #MatrixFilterRules
*
* Get the list of room IDs that will be excluded in the filtered
* events.
@ -683,68 +677,68 @@ matrix_api_filter_rules_delete_excluded_room(MatrixAPIFilterRules *rules,
* owned by @rules and should not be freed nor modified.
*/
const GList *
matrix_api_filter_rules_get_excluded_rooms(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_excluded_rooms(MatrixFilterRules *rules)
{
return rules->excluded_rooms;
}
/**
* matrix_api_filter_rules_set_types:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_types:
* @rules: a #MatrixFilterRules
* @types: (in) (element-type utf8) (transfer full) (allow-none): a
* list of event types to include. If %NULL then all event
* types are included. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Set the list of event types to be included in the filtered events.
*/
void
matrix_api_filter_rules_set_types(MatrixAPIFilterRules *rules, GList *types)
matrix_filter_rules_set_types(MatrixFilterRules *rules, GList *types)
{
g_list_free_full(rules->types, g_free);
rules->types = types;
}
/**
* matrix_api_filter_rules_add_type:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_type:
* @rules: a #MatrixFilterRules
* @type: (in): an event type to add to the list of included
* events. See matrix_api_filter_rules_add_sender() for
* wildcarding possibilities
* events. See matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Add @type to the list of event types to include in the filtered
* event list. If @type is already included in the types list, nothing
* happens.
*/
void
matrix_api_filter_rules_add_type(MatrixAPIFilterRules *rules, const gchar *type)
matrix_filter_rules_add_type(MatrixFilterRules *rules, const gchar *event_type)
{
g_return_if_fail(type != NULL);
g_return_if_fail(event_type != NULL);
if (g_list_find_custom(rules->types, type, (GCompareFunc)g_strcmp0)) {
rules->types = g_list_prepend(rules->types, g_strdup(type));
if (g_list_find_custom(rules->types, event_type, (GCompareFunc)g_strcmp0)) {
rules->types = g_list_prepend(rules->types, g_strdup(event_type));
}
}
/**
* matrix_api_filter_rules_delete_type:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_type:
* @rules: a #MatrixFilterRules
* @type: (in): a type to remove from the list of included event
* types. See matrix_api_filter_rules_add_sender() for
* types. See matrix_filter_rules_add_sender() for
* wildcarding possibilities
*
* Remove @type from the list of excluded event type list.
*/
void
matrix_api_filter_rules_delete_type(MatrixAPIFilterRules *rules,
const gchar *type)
matrix_filter_rules_delete_type(MatrixFilterRules *rules,
const gchar *event_type)
{
GList *type_element;
g_return_if_fail(type != NULL);
g_return_if_fail(event_type != NULL);
while (type_element = g_list_find_custom(rules->types, type,
while (type_element = g_list_find_custom(rules->types, event_type,
(GCompareFunc)g_strcmp0)) {
rules->types = g_list_remove_link(rules->types, type_element);
g_list_free_full(type_element, g_free);
@ -752,8 +746,8 @@ matrix_api_filter_rules_delete_type(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_types:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_types:
* @rules: a #MatrixFilterRules
*
* Get the list of event types that will be included in the filtered
* events.
@ -763,59 +757,58 @@ matrix_api_filter_rules_delete_type(MatrixAPIFilterRules *rules,
* @rules and should not be freed nor modified
*/
const GList *
matrix_api_filter_rules_get_types(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_types(MatrixFilterRules *rules)
{
return rules->types;
}
/**
* matrix_api_filter_rules_set_excluded_types:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_set_excluded_types:
* @rules: a #MatrixFilterRules
* @types: (in) (element-type utf8) (transfer full) (allow-none): a
* list of event types to exclude. If %NULL then no event
* types are excluded. A matching type will be excluded even
* if it is listed in the included types. See
* matrix_api_filter_rules_add_sender() for wildcarding
* matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Set the list of event types to be excluded from the filtered
* events. A matching type will be excluded even if it is listed in
* the types list (specified by
* e.g. matrix_api_filter_rules_set_types()).
* e.g. matrix_filter_rules_set_types()).
*/
void
matrix_api_filter_rules_set_excluded_types(MatrixAPIFilterRules *rules,
GList *types)
matrix_filter_rules_set_excluded_types(MatrixFilterRules *rules, GList *types)
{
g_list_free_full(rules->excluded_types, g_free);
rules->excluded_types = types;
}
/**
* matrix_api_filter_rules_add_excluded_type:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_add_excluded_type:
* @rules: a #MatrixFilterRules
* @type: (in): an event type to add to the excluded event type
* list. See matrix_api_filter_rules_add_sender() for
* wildcarding possibilities
* list. See matrix_filter_rules_add_sender() for wildcarding
* possibilities
*
* Add @type to the list of excluded event types.
*/
void
matrix_api_filter_rules_add_excluded_type(MatrixAPIFilterRules *rules,
const gchar *type)
matrix_filter_rules_add_excluded_type(MatrixFilterRules *rules,
const gchar *event_type)
{
g_return_if_fail(type != NULL);
g_return_if_fail(event_type != NULL);
if (!g_list_find_custom(rules->excluded_types, type,
if (!g_list_find_custom(rules->excluded_types, event_type,
(GCompareFunc)g_strcmp0)) {
rules->excluded_types = g_list_prepend(rules->excluded_types,
g_strdup(type));
g_strdup(event_type));
}
}
/**
* matrix_api_filter_rules_delete_excluded_type:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_delete_excluded_type:
* @rules: a #MatrixFilterRules
* @type: (in): the event type to be removed from the excluded types
* list
*
@ -823,14 +816,14 @@ matrix_api_filter_rules_add_excluded_type(MatrixAPIFilterRules *rules,
* filtered event list.
*/
void
matrix_api_filter_rules_delete_excluded_type(MatrixAPIFilterRules *rules,
const gchar *type)
matrix_filter_rules_delete_excluded_type(MatrixFilterRules *rules,
const gchar *event_type)
{
GList *type_element;
g_return_if_fail(type != NULL);
g_return_if_fail(event_type != NULL);
while (type_element = g_list_find_custom(rules->excluded_types, type,
while (type_element = g_list_find_custom(rules->excluded_types, event_type,
(GCompareFunc)g_strcmp0)) {
rules->excluded_types = g_list_remove_link(rules->excluded_types,
type_element);
@ -839,8 +832,8 @@ matrix_api_filter_rules_delete_excluded_type(MatrixAPIFilterRules *rules,
}
/**
* matrix_api_filter_rules_get_excluded_types:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_excluded_types:
* @rules: a #MatrixFilterRules
*
* Get the list of event types that will be excluded from the filtered
* events.
@ -850,7 +843,7 @@ matrix_api_filter_rules_delete_excluded_type(MatrixAPIFilterRules *rules,
* @rules and should not be freed nor modified
*/
const GList *
matrix_api_filter_rules_get_excluded_types(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_excluded_types(MatrixFilterRules *rules)
{
return rules->excluded_types;
}
@ -862,8 +855,8 @@ json_add_string(gchar *str, JsonBuilder *builder)
}
/**
* matrix_api_filter_rules_get_json_node:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_json_node:
* @rules: a #MatrixFilterRules
*
* Gets the #JsonNode representation of this filtering ruleset.
*
@ -871,7 +864,7 @@ json_add_string(gchar *str, JsonBuilder *builder)
* data as a #JsonNode
*/
JsonNode *
matrix_api_filter_rules_get_json_node(MatrixAPIFilterRules *rules)
matrix_filter_rules_get_json_node(MatrixFilterRules *rules)
{
JsonBuilder *builder;
JsonNode *node;
@ -934,8 +927,8 @@ matrix_api_filter_rules_get_json_node(MatrixAPIFilterRules *rules)
}
/**
* matrix_api_filter_rules_get_json_data:
* @rules: a #MatrixAPIFilterRules
* matrix_filter_rules_get_json_data:
* @rules: a #MatrixFilterRules
* @datalen: (out): storage for the the length of the JSON data or
* %NULL
*
@ -946,11 +939,10 @@ matrix_api_filter_rules_get_json_node(MatrixAPIFilterRules *rules)
* rule data as a string
*/
gchar *
matrix_api_filter_rules_get_json_data(MatrixAPIFilterRules *rules,
gsize *datalen)
matrix_filter_rules_get_json_data(MatrixFilterRules *rules, gsize *datalen)
{
JsonGenerator *generator;
JsonNode *node = matrix_api_filter_rules_get_json_node(rules);
JsonNode *node = matrix_filter_rules_get_json_node(rules);
gchar *data;
generator = json_generator_new();
@ -970,9 +962,9 @@ matrix_api_filter_rules_get_json_data(MatrixAPIFilterRules *rules,
*/
struct _MatrixAPIRoomFilter {
gboolean include_leave;
MatrixAPIFilterRules *ephemeral;
MatrixAPIFilterRules *state;
MatrixAPIFilterRules *timeline;
MatrixFilterRules *ephemeral;
MatrixFilterRules *state;
MatrixFilterRules *timeline;
guint refcount;
};
@ -1002,15 +994,15 @@ static void
matrix_api_room_filter_free(MatrixAPIRoomFilter *filter)
{
if (filter->ephemeral) {
matrix_api_filter_rules_unref(filter->ephemeral);
matrix_filter_rules_unref(filter->ephemeral);
}
if (filter->state) {
matrix_api_filter_rules_unref(filter->state);
matrix_filter_rules_unref(filter->state);
}
if (filter->timeline) {
matrix_api_filter_rules_unref(filter->timeline);
matrix_filter_rules_unref(filter->timeline);
}
g_free(filter);
@ -1088,13 +1080,13 @@ matrix_api_room_filter_get_include_leave(MatrixAPIRoomFilter *filter)
*/
void
matrix_api_room_filter_set_ephemeral(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules)
MatrixFilterRules *rules)
{
if (filter->ephemeral) {
matrix_api_filter_rules_unref(filter->ephemeral);
matrix_filter_rules_unref(filter->ephemeral);
}
filter->ephemeral = matrix_api_filter_rules_ref(rules);
filter->ephemeral = matrix_filter_rules_ref(rules);
}
/**
@ -1106,7 +1098,7 @@ matrix_api_room_filter_set_ephemeral(MatrixAPIRoomFilter *filter,
*
* Returns: (transfer none): the filtering rules for ephemeral events.
*/
MatrixAPIFilterRules *
MatrixFilterRules *
matrix_api_room_filter_get_ephemeral(MatrixAPIRoomFilter *filter)
{
return filter->ephemeral;
@ -1122,13 +1114,13 @@ matrix_api_room_filter_get_ephemeral(MatrixAPIRoomFilter *filter)
*/
void
matrix_api_room_filter_set_state(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules)
MatrixFilterRules *rules)
{
if (filter->state) {
matrix_api_filter_rules_unref(filter->state);
matrix_filter_rules_unref(filter->state);
}
filter->state = matrix_api_filter_rules_ref(rules);
filter->state = matrix_filter_rules_ref(rules);
}
/**
@ -1139,7 +1131,7 @@ matrix_api_room_filter_set_state(MatrixAPIRoomFilter *filter,
*
* Returns: (transfer none): the filtering rules for state events
*/
MatrixAPIFilterRules *
MatrixFilterRules *
matrix_api_room_filter_get_state(MatrixAPIRoomFilter *filter)
{
return filter->state;
@ -1155,13 +1147,13 @@ matrix_api_room_filter_get_state(MatrixAPIRoomFilter *filter)
*/
void
matrix_api_room_filter_set_timeline(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules)
MatrixFilterRules *rules)
{
if (filter->timeline) {
matrix_api_filter_rules_unref(filter->timeline);
matrix_filter_rules_unref(filter->timeline);
}
filter->timeline = matrix_api_filter_rules_ref(rules);
filter->timeline = matrix_filter_rules_ref(rules);
}
/**
@ -1173,7 +1165,7 @@ matrix_api_room_filter_set_timeline(MatrixAPIRoomFilter *filter,
*
* Returns: (transfer none): the filtering rules for timeline events
*/
MatrixAPIFilterRules *
MatrixFilterRules *
matrix_api_room_filter_get_timeline(MatrixAPIRoomFilter *filter)
{
return filter->timeline;
@ -1203,21 +1195,21 @@ matrix_api_room_filter_get_json_node(MatrixAPIRoomFilter *filter)
if (filter->ephemeral) {
json_builder_set_member_name(builder, "ephemeral");
json_builder_add_value(builder,
matrix_api_filter_rules_get_json_node(
matrix_filter_rules_get_json_node(
filter->ephemeral));
}
if (filter->state) {
json_builder_set_member_name(builder, "state");
json_builder_add_value(builder,
matrix_api_filter_rules_get_json_node(
matrix_filter_rules_get_json_node(
filter->state));
}
if (filter->timeline) {
json_builder_set_member_name(builder, "timeline");
json_builder_add_value(builder,
matrix_api_filter_rules_get_json_node(
matrix_filter_rules_get_json_node(
filter->timeline));
}
@ -1267,7 +1259,7 @@ matrix_api_room_filter_get_json_data(MatrixAPIRoomFilter *filter,
struct _MatrixAPIFilter {
GList *event_fields;
MatrixEventFormat event_format;
MatrixAPIFilterRules *presence;
MatrixFilterRules *presence;
MatrixAPIRoomFilter *room;
guint refcount;
};
@ -1300,7 +1292,7 @@ matrix_api_filter_free(MatrixAPIFilter *filter)
g_list_free_full(filter->event_fields, g_free);
if (filter->presence) {
matrix_api_filter_rules_unref(filter->presence);
matrix_filter_rules_unref(filter->presence);
}
if (filter->room) {
@ -1466,13 +1458,13 @@ matrix_api_filter_get_event_format(MatrixAPIFilter *filter)
*/
void
matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter,
MatrixAPIFilterRules *presence_filter)
MatrixFilterRules *presence_filter)
{
if (filter->presence) {
matrix_api_filter_rules_unref(filter->presence);
matrix_filter_rules_unref(filter->presence);
}
filter->presence = matrix_api_filter_rules_ref(presence_filter);
filter->presence = matrix_filter_rules_ref(presence_filter);
}
/**
@ -1485,7 +1477,7 @@ matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter,
* is owned by @filter; if the callee wants to use it
* separately, it should create a reference for it
*/
MatrixAPIFilterRules *
MatrixFilterRules *
matrix_api_filter_get_presence_filter(MatrixAPIFilter *filter)
{
return filter->presence;
@ -1554,7 +1546,7 @@ matrix_api_filter_get_json_node(MatrixAPIFilter *filter)
TRUE));
json_builder_set_member_name(builder, "presence");
tmp = matrix_api_filter_rules_get_json_node(filter->presence);
tmp = matrix_filter_rules_get_json_node(filter->presence);
json_builder_add_value(builder, tmp);
json_node_free(tmp);

View File

@ -114,62 +114,56 @@ typedef enum {
MATRIX_ACCOUNT_KIND_GUEST
} MatrixAccountKind;
typedef struct _MatrixAPIFilterRules MatrixAPIFilterRules;
typedef struct _MatrixFilterRules MatrixFilterRules;
GType matrix_api_filter_rules_get_type(void);
#define MATRIX_TYPE_API_FILTER_RULES (matrix_api_filter_rules_get_type())
GType matrix_filter_rules_get_type(void);
#define MATRIX_TYPE_FILTER_RULES (matrix_filter_rules_get_type())
MatrixAPIFilterRules *matrix_api_filter_rules_new(void);
MatrixAPIFilterRules *matrix_api_filter_rules_ref(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_unref(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_limit(MatrixAPIFilterRules *rules,
guint limit);
guint matrix_api_filter_rules_get_limit(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_rooms(MatrixAPIFilterRules *rules,
GList *rooms);
void matrix_api_filter_rules_add_room(MatrixAPIFilterRules *rules,
const gchar *room);
void matrix_api_filter_rules_delete_room(MatrixAPIFilterRules *rules,
const gchar *room);
const GList *matrix_api_filter_rules_get_rooms(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_excluded_rooms(MatrixAPIFilterRules *rules,
GList *rooms);
void matrix_api_filter_rules_add_excluded_room(MatrixAPIFilterRules *rules,
const gchar *room);
void matrix_api_filter_rules_delete_excluded_room(MatrixAPIFilterRules *rules,
const gchar *room);
const GList *matrix_api_filter_rules_get_excluded_rooms(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_senders(MatrixAPIFilterRules *rules,
GList *senders);
void matrix_api_filter_rules_add_sender(MatrixAPIFilterRules *rules,
const gchar *sender);
void matrix_api_filter_rules_delete_sender(MatrixAPIFilterRules *rules,
const gchar *sender);
const GList *matrix_api_filter_rules_get_senders(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_excluded_senders(MatrixAPIFilterRules *rules,
GList *senders);
void matrix_api_filter_rules_add_excluded_sender(MatrixAPIFilterRules *rules,
const gchar *sender);
void matrix_api_filter_rules_delete_excluded_sender(MatrixAPIFilterRules *rules,
const gchar *sender);
const GList *matrix_api_filter_rules_get_excluded_senders(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_types(MatrixAPIFilterRules *rules,
GList *types);
void matrix_api_filter_rules_add_type(MatrixAPIFilterRules *rules,
const gchar *type);
void matrix_api_filter_rules_delete_type(MatrixAPIFilterRules *rules,
const gchar *type);
const GList *matrix_api_filter_rules_get_types(MatrixAPIFilterRules *rules);
void matrix_api_filter_rules_set_excluded_types(MatrixAPIFilterRules *rules,
GList *types);
void matrix_api_filter_rules_add_excluded_type(MatrixAPIFilterRules *rules,
const gchar *type);
void matrix_api_filter_rules_delete_excluded_type(MatrixAPIFilterRules *rules,
const gchar *type);
const GList *matrix_api_filter_rules_get_excluded_types(MatrixAPIFilterRules *rules);
JsonNode *matrix_api_filter_rules_get_json_node(MatrixAPIFilterRules *rules);
gchar *matrix_api_filter_rules_get_json_data(MatrixAPIFilterRules *rules,
gsize *datalen);
MatrixFilterRules *matrix_filter_rules_new(void);
MatrixFilterRules *matrix_filter_rules_ref(MatrixFilterRules *rules);
void matrix_filter_rules_unref(MatrixFilterRules *rules);
void matrix_filter_rules_set_limit(MatrixFilterRules *rules, guint limit);
guint matrix_filter_rules_get_limit(MatrixFilterRules *rules);
void matrix_filter_rules_set_rooms(MatrixFilterRules *rules, GList *rooms);
void matrix_filter_rules_add_room(MatrixFilterRules *rules, const gchar *room);
void matrix_filter_rules_delete_room(MatrixFilterRules *rules,
const gchar *room);
const GList *matrix_filter_rules_get_rooms(MatrixFilterRules *rules);
void matrix_filter_rules_set_excluded_rooms(MatrixFilterRules *rules,
GList *rooms);
void matrix_filter_rules_add_excluded_room(MatrixFilterRules *rules,
const gchar *room);
void matrix_filter_rules_delete_excluded_room(MatrixFilterRules *rules,
const gchar *room);
const GList *matrix_filter_rules_get_excluded_rooms(MatrixFilterRules *rules);
void matrix_filter_rules_set_senders(MatrixFilterRules *rules, GList *senders);
void matrix_filter_rules_add_sender(MatrixFilterRules *rules,
const gchar *sender);
void matrix_filter_rules_delete_sender(MatrixFilterRules *rules,
const gchar *sender);
const GList *matrix_filter_rules_get_senders(MatrixFilterRules *rules);
void matrix_filter_rules_set_excluded_senders(MatrixFilterRules *rules,
GList *senders);
void matrix_filter_rules_add_excluded_sender(MatrixFilterRules *rules,
const gchar *sender);
void matrix_filter_rules_delete_excluded_sender(MatrixFilterRules *rules,
const gchar *sender);
const GList *matrix_filter_rules_get_excluded_senders(MatrixFilterRules *rules);
void matrix_filter_rules_set_types(MatrixFilterRules *rules, GList *types);
void matrix_filter_rules_add_type(MatrixFilterRules *rules, const gchar *type);
void matrix_filter_rules_delete_type(MatrixFilterRules *rules,
const gchar *type);
const GList *matrix_filter_rules_get_types(MatrixFilterRules *rules);
void matrix_filter_rules_set_excluded_types(MatrixFilterRules *rules,
GList *types);
void matrix_filter_rules_add_excluded_type(MatrixFilterRules *rules,
const gchar *type);
void matrix_filter_rules_delete_excluded_type(MatrixFilterRules *rules,
const gchar *type);
const GList *matrix_filter_rules_get_excluded_types(MatrixFilterRules *rules);
JsonNode *matrix_filter_rules_get_json_node(MatrixFilterRules *rules);
gchar *matrix_filter_rules_get_json_data(MatrixFilterRules *rules,
gsize *datalen);
typedef struct _MatrixAPIRoomFilter MatrixAPIRoomFilter;
@ -183,14 +177,14 @@ void matrix_api_room_filter_set_include_leave(MatrixAPIRoomFilter *filter,
gboolean include_leave);
gboolean matrix_api_room_filter_get_include_leave(MatrixAPIRoomFilter *filter);
void matrix_api_room_filter_set_ephemeral(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules);
MatrixAPIFilterRules *matrix_api_room_filter_get_ephemeral(MatrixAPIRoomFilter *filter);
MatrixFilterRules *rules);
MatrixFilterRules *matrix_api_room_filter_get_ephemeral(MatrixAPIRoomFilter *filter);
void matrix_api_room_filter_set_state(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules);
MatrixAPIFilterRules *matrix_api_room_filter_get_state(MatrixAPIRoomFilter *filter);
MatrixFilterRules *rules);
MatrixFilterRules *matrix_api_room_filter_get_state(MatrixAPIRoomFilter *filter);
void matrix_api_room_filter_set_timeline(MatrixAPIRoomFilter *filter,
MatrixAPIFilterRules *rules);
MatrixAPIFilterRules *matrix_api_room_filter_get_timeline(MatrixAPIRoomFilter *filter);
MatrixFilterRules *rules);
MatrixFilterRules *matrix_api_room_filter_get_timeline(MatrixAPIRoomFilter *filter);
JsonNode *matrix_api_room_filter_get_json_node(MatrixAPIRoomFilter *filter);
gchar *matrix_api_room_filter_get_json_data(MatrixAPIRoomFilter *filter,
gsize *datalen);
@ -214,8 +208,8 @@ void matrix_api_filter_set_event_format(MatrixAPIFilter *filter,
MatrixEventFormat event_format);
MatrixEventFormat matrix_api_filter_get_event_format(MatrixAPIFilter *filter);
void matrix_api_filter_set_presence_filter(MatrixAPIFilter *filter,
MatrixAPIFilterRules *presence_filter);
MatrixAPIFilterRules *matrix_api_filter_get_presence_filter(MatrixAPIFilter *filter);
MatrixFilterRules *presence_filter);
MatrixFilterRules *matrix_api_filter_get_presence_filter(MatrixAPIFilter *filter);
void matrix_api_filter_set_room_filter(MatrixAPIFilter *filter,
MatrixAPIRoomFilter *room_filter);
MatrixAPIRoomFilter *matrix_api_filter_get_room_filter(MatrixAPIFilter *filter);