summaryrefslogtreecommitdiff
path: root/telepathy-glib/handle-set.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2010-09-22 15:10:56 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2010-09-22 15:10:56 +0100
commit3c5604730daf0c5798c54ed5d5297a0c34ef35a6 (patch)
tree23b06ab6bcb3f39882ad612b951ec2a8c9af581a /telepathy-glib/handle-set.c
parent016f1f1cc160efc3297dc33d89dda6fa9f70cf5e (diff)
downloadtelepathy-glib-3c5604730daf0c5798c54ed5d5297a0c34ef35a6.tar.gz
TpHandleSet: add convenience constructors from TpIntset and TpHandle
Diffstat (limited to 'telepathy-glib/handle-set.c')
-rw-r--r--telepathy-glib/handle-set.c50
1 files changed, 47 insertions, 3 deletions
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;
}