diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-05-20 15:40:36 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2014-05-26 14:49:04 +0200 |
commit | d86974ec31501317902712513dbf57ff04fdad39 (patch) | |
tree | 5f67b8d11dffff961868889b746df24459e48cae | |
parent | c549e7ec725a3ffb37fb682b1ff61506be18a9b5 (diff) | |
download | telepathy-glib-d86974ec31501317902712513dbf57ff04fdad39.tar.gz |
base-contact-list: pass a TpMutableContactGroupList to vfuncs
https://bugs.freedesktop.org/show_bug.cgi?id=77772
-rw-r--r-- | docs/reference/telepathy-glib/telepathy-glib-sections.txt | 9 | ||||
-rw-r--r-- | examples/cm/contactlist/contact-list.c | 27 | ||||
-rw-r--r-- | telepathy-glib/base-contact-list.c | 99 | ||||
-rw-r--r-- | telepathy-glib/base-contact-list.h | 41 | ||||
-rw-r--r-- | tests/lib/contact-list-manager.c | 10 |
5 files changed, 122 insertions, 64 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt index 2bf0a02d4..7afe4b7d9 100644 --- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt @@ -4933,6 +4933,7 @@ TP_TYPE_CONTACT_GROUP_LIST TpContactGroupList TpContactGroupListInterface TpContactGroupListBooleanFunc +TpMutableContactGroupListAsyncFinishFunc tp_contact_group_list_false_func TpContactGroupListNormalizeFunc tp_contact_group_list_normalize_group @@ -4952,20 +4953,20 @@ tp_contact_group_list_has_disjoint_groups TP_TYPE_MUTABLE_CONTACT_GROUP_LIST TpMutableContactGroupList TpMutableContactGroupListInterface -TpBaseContactListSetContactGroupsFunc +TpMutableContactGroupListSetContactGroupsFunc tp_base_contact_list_set_contact_groups_async tp_base_contact_list_set_contact_groups_finish -TpBaseContactListGroupContactsFunc +TpMutableContactGroupListGroupContactsFunc tp_base_contact_list_add_to_group_async tp_base_contact_list_add_to_group_finish tp_base_contact_list_remove_from_group_async tp_base_contact_list_remove_from_group_finish tp_base_contact_list_set_group_members_async tp_base_contact_list_set_group_members_finish -TpBaseContactListRemoveGroupFunc +TpMutableContactGroupListRemoveGroupFunc tp_base_contact_list_remove_group_async tp_base_contact_list_remove_group_finish -TpBaseContactListRenameGroupFunc +TpMutableContactGroupListRenameGroupFunc tp_base_contact_list_rename_group_async tp_base_contact_list_rename_group_finish tp_base_contact_list_get_group_storage diff --git a/examples/cm/contactlist/contact-list.c b/examples/cm/contactlist/contact-list.c index 0894ef871..c59d7233f 100644 --- a/examples/cm/contactlist/contact-list.c +++ b/examples/cm/contactlist/contact-list.c @@ -287,7 +287,8 @@ ensure_tag (ExampleContactList *self, } static void -example_contact_list_set_contact_groups_async (TpBaseContactList *contact_list, +example_contact_list_set_contact_groups_async ( + TpMutableContactGroupList *contact_list, TpHandle contact, const gchar * const *names, gsize n, @@ -311,7 +312,8 @@ example_contact_list_set_contact_groups_async (TpBaseContactList *contact_list, d = ensure_contact (self, contact, &created); if (created) - tp_base_contact_list_one_contact_changed (contact_list, contact); + tp_base_contact_list_one_contact_changed ( + TP_BASE_CONTACT_LIST (contact_list), contact); if (d->tags == NULL) d->tags = g_hash_table_new (g_str_hash, g_str_equal); @@ -601,7 +603,8 @@ send_updated_roster (ExampleContactList *self, } static void -example_contact_list_set_group_members_async (TpBaseContactList *contact_list, +example_contact_list_set_group_members_async ( + TpMutableContactGroupList *contact_list, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -658,7 +661,8 @@ example_contact_list_set_group_members_async (TpBaseContactList *contact_list, } if (!tp_handle_set_is_empty (new_contacts)) - tp_base_contact_list_contacts_changed (contact_list, new_contacts, NULL); + tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (contact_list), + new_contacts, NULL); if (!tp_handle_set_is_empty (added)) tp_contact_group_list_groups_changed (contact_group, added, &group, 1, @@ -676,7 +680,8 @@ example_contact_list_set_group_members_async (TpBaseContactList *contact_list, } static void -example_contact_list_add_to_group_async (TpBaseContactList *contact_list, +example_contact_list_add_to_group_async ( + TpMutableContactGroupList *contact_list, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -717,7 +722,8 @@ example_contact_list_add_to_group_async (TpBaseContactList *contact_list, } if (!tp_handle_set_is_empty (new_contacts)) - tp_base_contact_list_contacts_changed (contact_list, new_contacts, NULL); + tp_base_contact_list_contacts_changed (TP_BASE_CONTACT_LIST (contact_list), + new_contacts, NULL); if (!tp_handle_set_is_empty (new_to_group)) tp_contact_group_list_groups_changed (contact_group, new_to_group, &group, 1, @@ -730,7 +736,8 @@ example_contact_list_add_to_group_async (TpBaseContactList *contact_list, } static void -example_contact_list_remove_from_group_async (TpBaseContactList *contact_list, +example_contact_list_remove_from_group_async ( + TpMutableContactGroupList *contact_list, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -1577,7 +1584,8 @@ example_contact_list_dup_contact_groups (TpContactGroupList *group_list, } static void -example_contact_list_remove_group_async (TpBaseContactList *contact_list, +example_contact_list_remove_group_async ( + TpMutableContactGroupList *contact_list, const gchar *group, GAsyncReadyCallback callback, gpointer user_data) @@ -1619,7 +1627,8 @@ example_contact_list_normalize_group (TpContactGroupList *contact_list, } static void -example_contact_list_rename_group_async (TpBaseContactList *contact_list, +example_contact_list_rename_group_async ( + TpMutableContactGroupList *contact_list, const gchar *old_name, const gchar *new_name, GAsyncReadyCallback callback, diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c index 99ca4a6a8..d859a50c7 100644 --- a/telepathy-glib/base-contact-list.c +++ b/telepathy-glib/base-contact-list.c @@ -272,6 +272,19 @@ * Since: UNRELEASED */ +/** + * TpMutableContactGroupListAsyncFinishFunc: + * @self: the contact list manager implementing + * #TP_TYPE_MUTABLE_CONTACT_GROUP_LIST + * @result: the result of the asynchronous operation + * @error: used to raise an error if %FALSE is returned + * + * Signature of a virtual method to finish an async operation. + * + * Returns: %TRUE on success, or %FALSE if @error is set + * + * Since: UNRELEASED + */ #include "config.h" @@ -911,8 +924,22 @@ tp_contact_group_list_default_init (TpContactGroupListInterface *iface) /* there's no default for the other virtual methods */ } -static void tp_base_contact_list_emulate_rename_group (TpBaseContactList *, - const gchar *, const gchar *, GAsyncReadyCallback, gpointer); +static void tp_base_contact_list_emulate_rename_group ( + TpMutableContactGroupList *, const gchar *, const gchar *, + GAsyncReadyCallback, gpointer); + +static gboolean +tp_mutable_contact_group_list_simple_finish (TpMutableContactGroupList *self, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple = (GSimpleAsyncResult *) result; + + g_return_val_if_fail (g_simple_async_result_is_valid ( + result, G_OBJECT (self), NULL), FALSE); + + return !g_simple_async_result_propagate_error (simple, error); +} static void tp_mutable_contact_group_list_default_init ( @@ -920,12 +947,12 @@ tp_mutable_contact_group_list_default_init ( { iface->rename_group_async = tp_base_contact_list_emulate_rename_group; - iface->add_to_group_finish = tp_base_contact_list_simple_finish; - iface->remove_from_group_finish = tp_base_contact_list_simple_finish; - iface->set_contact_groups_finish = tp_base_contact_list_simple_finish; - iface->remove_group_finish = tp_base_contact_list_simple_finish; - iface->rename_group_finish = tp_base_contact_list_simple_finish; - iface->set_group_members_finish = tp_base_contact_list_simple_finish; + iface->add_to_group_finish = tp_mutable_contact_group_list_simple_finish; + iface->remove_from_group_finish = tp_mutable_contact_group_list_simple_finish; + iface->set_contact_groups_finish = tp_mutable_contact_group_list_simple_finish; + iface->remove_group_finish = tp_mutable_contact_group_list_simple_finish; + iface->rename_group_finish = tp_mutable_contact_group_list_simple_finish; + iface->set_group_members_finish = tp_mutable_contact_group_list_simple_finish; } static void @@ -3461,7 +3488,7 @@ tp_contact_group_list_dup_group_members (TpContactGroupList *self, } /** - * TpBaseContactListGroupContactsFunc: + * TpMutableContactGroupListGroupContactsFunc: * @self: a contact list manager * @group: a group * @contacts: a set of contact handles @@ -3510,7 +3537,8 @@ tp_base_contact_list_add_to_group_async (TpBaseContactList *self, g_return_if_fail (iface != NULL); g_return_if_fail (iface->add_to_group_async != NULL); - iface->add_to_group_async (self, group, contacts, callback, user_data); + iface->add_to_group_async (TP_MUTABLE_CONTACT_GROUP_LIST (self), group, + contacts, callback, user_data); } /** @@ -3547,11 +3575,12 @@ tp_base_contact_list_add_to_group_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->add_to_group_finish != NULL, FALSE); - return mutable_groups_iface->add_to_group_finish (self, result, error); + return mutable_groups_iface->add_to_group_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } /** - * TpBaseContactListRenameGroupFunc: + * TpMutableContactGroupListRenameGroupFunc: * @self: a contact list manager * @old_name: a group * @new_name: a new name for the group @@ -3605,8 +3634,8 @@ tp_base_contact_list_rename_group_async (TpBaseContactList *self, g_return_if_fail (iface != NULL); g_return_if_fail (iface->rename_group_async != NULL); - iface->rename_group_async (self, old_name, new_name, callback, - user_data); + iface->rename_group_async (TP_MUTABLE_CONTACT_GROUP_LIST (self), old_name, + new_name, callback, user_data); } static void @@ -3654,7 +3683,7 @@ out: } static void -tp_base_contact_list_emulate_rename_group (TpBaseContactList *self, +tp_base_contact_list_emulate_rename_group (TpMutableContactGroupList *self, const gchar *old_name, const gchar *new_name, GAsyncReadyCallback callback, @@ -3672,8 +3701,9 @@ tp_base_contact_list_emulate_rename_group (TpBaseContactList *self, old_members = tp_contact_group_list_dup_group_members ( TP_CONTACT_GROUP_LIST (self), old_name); - tp_base_contact_list_add_to_group_async (self, new_name, old_members, - emulate_rename_group_add_cb, g_object_ref (result)); + tp_base_contact_list_add_to_group_async (TP_BASE_CONTACT_LIST (self), + new_name, old_members, emulate_rename_group_add_cb, + g_object_ref (result)); g_object_unref (result); tp_handle_set_destroy (old_members); } @@ -3712,7 +3742,8 @@ tp_base_contact_list_rename_group_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->rename_group_finish != NULL, FALSE); - return mutable_groups_iface->rename_group_finish (self, result, error); + return mutable_groups_iface->rename_group_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } /** @@ -3748,7 +3779,8 @@ void tp_base_contact_list_remove_from_group_async (TpBaseContactList *self, g_return_if_fail (iface != NULL); g_return_if_fail (iface->remove_from_group_async != NULL); - iface->remove_from_group_async (self, group, contacts, callback, user_data); + iface->remove_from_group_async (TP_MUTABLE_CONTACT_GROUP_LIST (self), group, + contacts, callback, user_data); } /** @@ -3785,11 +3817,12 @@ tp_base_contact_list_remove_from_group_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->remove_from_group_finish != NULL, FALSE); - return mutable_groups_iface->remove_from_group_finish (self, result, error); + return mutable_groups_iface->remove_from_group_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } /** - * TpBaseContactListRemoveGroupFunc: + * TpMutableContactGroupListRemoveGroupFunc: * @self: a contact list manager * @group: the normalized name of a group * @callback: a callback to call on success, failure or disconnection @@ -3832,7 +3865,8 @@ tp_base_contact_list_remove_group_async (TpBaseContactList *self, g_return_if_fail (mutable_group_iface != NULL); g_return_if_fail (mutable_group_iface->remove_group_async != NULL); - mutable_group_iface->remove_group_async (self, group, callback, user_data); + mutable_group_iface->remove_group_async (TP_MUTABLE_CONTACT_GROUP_LIST (self), + group, callback, user_data); } /** @@ -3869,7 +3903,8 @@ tp_base_contact_list_remove_group_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->remove_group_finish != NULL, FALSE); - return mutable_groups_iface->remove_group_finish (self, result, error); + return mutable_groups_iface->remove_group_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } static gboolean @@ -3912,7 +3947,7 @@ tp_base_contact_list_mixin_get_contact_list_attributes ( } /** - * TpBaseContactListSetContactGroupsFunc: + * TpMutableContactGroupListSetContactGroupsFunc: * @self: a contact list manager * @contact: a contact handle * @normalized_names: (array length=n_names): the normalized names of some @@ -3964,8 +3999,9 @@ void tp_base_contact_list_set_contact_groups_async (TpBaseContactList *self, g_return_if_fail (mutable_groups_iface != NULL); g_return_if_fail (mutable_groups_iface->set_contact_groups_async != NULL); - mutable_groups_iface->set_contact_groups_async (self, contact, - normalized_names, n_names, callback, user_data); + mutable_groups_iface->set_contact_groups_async ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), contact, normalized_names, n_names, + callback, user_data); } /** @@ -4003,7 +4039,8 @@ tp_base_contact_list_set_contact_groups_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->set_contact_groups_finish != NULL, FALSE); - return mutable_groups_iface->set_contact_groups_finish (self, result, error); + return mutable_groups_iface->set_contact_groups_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } /** @@ -4044,8 +4081,9 @@ tp_base_contact_list_set_group_members_async (TpBaseContactList *self, g_return_if_fail (mutable_groups_iface != NULL); g_return_if_fail (mutable_groups_iface->set_group_members_async != NULL); - mutable_groups_iface->set_group_members_async (self, normalized_group, - contacts, callback, user_data); + mutable_groups_iface->set_group_members_async ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), normalized_group, contacts, + callback, user_data); } /** @@ -4082,7 +4120,8 @@ tp_base_contact_list_set_group_members_finish (TpBaseContactList *self, g_return_val_if_fail (mutable_groups_iface->set_group_members_finish != NULL, FALSE); - return mutable_groups_iface->set_group_members_finish (self, result, error); + return mutable_groups_iface->set_group_members_finish ( + TP_MUTABLE_CONTACT_GROUP_LIST (self), result, error); } static gboolean diff --git a/telepathy-glib/base-contact-list.h b/telepathy-glib/base-contact-list.h index a9e26f9c2..4c8748135 100644 --- a/telepathy-glib/base-contact-list.h +++ b/telepathy-glib/base-contact-list.h @@ -493,13 +493,19 @@ struct _TpContactGroupListInterface { typedef struct _TpMutableContactGroupList TpMutableContactGroupList; +typedef gboolean (*TpMutableContactGroupListAsyncFinishFunc) ( + TpMutableContactGroupList *self, + GAsyncResult *result, + GError **error); + typedef guint (*TpBaseContactListUIntFunc) ( TpBaseContactList *self); TpContactMetadataStorageType tp_base_contact_list_get_group_storage ( TpBaseContactList *self); -typedef void (*TpBaseContactListSetContactGroupsFunc) (TpBaseContactList *self, +typedef void (*TpMutableContactGroupListSetContactGroupsFunc) ( + TpMutableContactGroupList *self, TpHandle contact, const gchar * const *normalized_names, gsize n_names, @@ -518,7 +524,8 @@ gboolean tp_base_contact_list_set_contact_groups_finish ( GAsyncResult *result, GError **error); -typedef void (*TpBaseContactListGroupContactsFunc) (TpBaseContactList *self, +typedef void (*TpMutableContactGroupListGroupContactsFunc) ( + TpMutableContactGroupList *self, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -557,7 +564,8 @@ gboolean tp_base_contact_list_set_group_members_finish ( GAsyncResult *result, GError **error); -typedef void (*TpBaseContactListRemoveGroupFunc) (TpBaseContactList *self, +typedef void (*TpMutableContactGroupListRemoveGroupFunc) ( + TpMutableContactGroupList *self, const gchar *group, GAsyncReadyCallback callback, gpointer user_data); @@ -571,7 +579,8 @@ gboolean tp_base_contact_list_remove_group_finish (TpBaseContactList *self, GAsyncResult *result, GError **error); -typedef void (*TpBaseContactListRenameGroupFunc) (TpBaseContactList *self, +typedef void (*TpMutableContactGroupListRenameGroupFunc) ( + TpMutableContactGroupList *self, const gchar *old_name, const gchar *new_name, GAsyncReadyCallback callback, @@ -612,25 +621,25 @@ struct _TpMutableContactGroupListInterface { /* _async mandatory-to-implement, _finish has a default implementation * suitable for a GSimpleAsyncResult */ - TpBaseContactListSetContactGroupsFunc set_contact_groups_async; - TpBaseContactListAsyncFinishFunc set_contact_groups_finish; + TpMutableContactGroupListSetContactGroupsFunc set_contact_groups_async; + TpMutableContactGroupListAsyncFinishFunc set_contact_groups_finish; - TpBaseContactListGroupContactsFunc set_group_members_async; - TpBaseContactListAsyncFinishFunc set_group_members_finish; + TpMutableContactGroupListGroupContactsFunc set_group_members_async; + TpMutableContactGroupListAsyncFinishFunc set_group_members_finish; - TpBaseContactListGroupContactsFunc add_to_group_async; - TpBaseContactListAsyncFinishFunc add_to_group_finish; + TpMutableContactGroupListGroupContactsFunc add_to_group_async; + TpMutableContactGroupListAsyncFinishFunc add_to_group_finish; - TpBaseContactListGroupContactsFunc remove_from_group_async; - TpBaseContactListAsyncFinishFunc remove_from_group_finish; + TpMutableContactGroupListGroupContactsFunc remove_from_group_async; + TpMutableContactGroupListAsyncFinishFunc remove_from_group_finish; - TpBaseContactListRemoveGroupFunc remove_group_async; - TpBaseContactListAsyncFinishFunc remove_group_finish; + TpMutableContactGroupListRemoveGroupFunc remove_group_async; + TpMutableContactGroupListAsyncFinishFunc remove_group_finish; /* optional to implement */ - TpBaseContactListRenameGroupFunc rename_group_async; - TpBaseContactListAsyncFinishFunc rename_group_finish; + TpMutableContactGroupListRenameGroupFunc rename_group_async; + TpMutableContactGroupListAsyncFinishFunc rename_group_finish; TpBaseContactListUIntFunc get_group_storage; }; diff --git a/tests/lib/contact-list-manager.c b/tests/lib/contact-list-manager.c index d9673dbe8..88f1709bd 100644 --- a/tests/lib/contact-list-manager.c +++ b/tests/lib/contact-list-manager.c @@ -297,7 +297,7 @@ group_difference (GHashTable *left, } static void -contact_list_set_contact_groups_async (TpBaseContactList *base, +contact_list_set_contact_groups_async (TpMutableContactGroupList *base, TpHandle contact, const gchar * const *names, gsize n, @@ -363,7 +363,7 @@ contact_list_set_contact_groups_async (TpBaseContactList *base, } static void -contact_list_set_group_members_async (TpBaseContactList *base, +contact_list_set_group_members_async (TpMutableContactGroupList *base, const gchar *normalized_group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -378,7 +378,7 @@ contact_list_set_group_members_async (TpBaseContactList *base, } static void -contact_list_add_to_group_async (TpBaseContactList *base, +contact_list_add_to_group_async (TpMutableContactGroupList *base, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -393,7 +393,7 @@ contact_list_add_to_group_async (TpBaseContactList *base, } static void -contact_list_remove_from_group_async (TpBaseContactList *base, +contact_list_remove_from_group_async (TpMutableContactGroupList *base, const gchar *group, TpHandleSet *contacts, GAsyncReadyCallback callback, @@ -408,7 +408,7 @@ contact_list_remove_from_group_async (TpBaseContactList *base, } static void -contact_list_remove_group_async (TpBaseContactList *base, +contact_list_remove_group_async (TpMutableContactGroupList *base, const gchar *group, GAsyncReadyCallback callback, gpointer user_data) |