diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-09-22 15:10:56 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-09-22 15:10:56 +0100 |
commit | 3c5604730daf0c5798c54ed5d5297a0c34ef35a6 (patch) | |
tree | 23b06ab6bcb3f39882ad612b951ec2a8c9af581a | |
parent | 016f1f1cc160efc3297dc33d89dda6fa9f70cf5e (diff) | |
download | telepathy-glib-3c5604730daf0c5798c54ed5d5297a0c34ef35a6.tar.gz |
TpHandleSet: add convenience constructors from TpIntset and TpHandle
-rw-r--r-- | docs/reference/telepathy-glib-sections.txt | 2 | ||||
-rw-r--r-- | telepathy-glib/handle-repo.h | 5 | ||||
-rw-r--r-- | telepathy-glib/handle-set.c | 50 |
3 files changed, 54 insertions, 3 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt index e4086d935..a09f024a8 100644 --- a/docs/reference/telepathy-glib-sections.txt +++ b/docs/reference/telepathy-glib-sections.txt @@ -242,7 +242,9 @@ TpHandleSet TP_TYPE_HANDLE_SET TpHandleSetMemberFunc tp_handle_set_new +tp_handle_set_new_containing tp_handle_set_new_from_array +tp_handle_set_new_from_intset tp_handle_set_copy tp_handle_set_clear tp_handle_set_destroy diff --git a/telepathy-glib/handle-repo.h b/telepathy-glib/handle-repo.h index 4fe996764..376cd50eb 100644 --- a/telepathy-glib/handle-repo.h +++ b/telepathy-glib/handle-repo.h @@ -115,6 +115,11 @@ TpHandleSet * tp_handle_set_new (TpHandleRepoIface *repo) G_GNUC_WARN_UNUSED_RESULT; TpHandleSet *tp_handle_set_copy (const TpHandleSet *other) G_GNUC_WARN_UNUSED_RESULT; +TpHandleSet *tp_handle_set_new_from_intset (TpHandleRepoIface *repo, + const TpIntset *intset); +TpHandleSet *tp_handle_set_new_containing (TpHandleRepoIface *repo, + TpHandle handle); + void tp_handle_set_clear (TpHandleSet *set); void tp_handle_set_destroy (TpHandleSet *set); diff --git a/telepathy-glib/handle-set.c b/telepathy-glib/handle-set.c index ce6c6d076..86554df18 100644 --- a/telepathy-glib/handle-set.c +++ b/telepathy-glib/handle-set.c @@ -336,13 +336,57 @@ ref_one (guint handle, gpointer data) TpHandleSet * tp_handle_set_copy (const TpHandleSet *other) { + g_return_val_if_fail (other != NULL, NULL); + + return tp_handle_set_new_from_intset (other->repo, other->intset); +} + +/** + * tp_handle_set_new_containing: + * @repo: #TpHandleRepoIface that holds the handles to be reffed by this set + * @handle: a valid handle + * + * Creates a new #TpHandleSet from a specified handle repository and single + * handle. + * + * Returns: A new #TpHandleSet + * + * Since: 0.13.UNRELEASED + */ +TpHandleSet * +tp_handle_set_new_containing (TpHandleRepoIface *repo, + TpHandle handle) +{ + TpHandleSet *set = tp_handle_set_new (repo); + + tp_handle_set_add (set, handle); + return set; +} + +/** + * tp_handle_set_new_from_intset: + * @repo: #TpHandleRepoIface that holds the handles to be reffed by this set + * @intset: a set of handles, which must all be valid + * + * Creates a new #TpHandleSet from a specified handle repository and + * set of handles. + * + * Returns: A new #TpHandleSet + * + * Since: 0.13.UNRELEASED + */ +TpHandleSet * +tp_handle_set_new_from_intset (TpHandleRepoIface *repo, + const TpIntset *intset) +{ TpHandleSet *set; - g_return_val_if_fail (other != NULL, NULL); + g_return_val_if_fail (repo != NULL, NULL); + g_return_val_if_fail (intset != NULL, NULL); set = g_slice_new0 (TpHandleSet); - set->repo = other->repo; - set->intset = tp_intset_copy (other->intset); + set->repo = repo; + set->intset = tp_intset_copy (intset); tp_intset_foreach (set->intset, ref_one, set); return set; } |