summaryrefslogtreecommitdiff
path: root/telepathy-glib
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2011-07-17 12:26:47 +0200
committerXavier Claessens <xclaesse@gmail.com>2011-08-04 14:25:37 +0200
commit026d5c3c6a1f678c50cb763ecc1d597329be3c58 (patch)
tree3565fc99125abe88dbd2757deb6cd77960288e61 /telepathy-glib
parentcb60818446aa2ada02be888c0bb99b42777f5594 (diff)
downloadtelepathy-glib-026d5c3c6a1f678c50cb763ecc1d597329be3c58.tar.gz
Add _tp_contacts_from_values
Diffstat (limited to 'telepathy-glib')
-rw-r--r--telepathy-glib/util-internal.h2
-rw-r--r--telepathy-glib/util.c22
2 files changed, 24 insertions, 0 deletions
diff --git a/telepathy-glib/util-internal.h b/telepathy-glib/util-internal.h
index e3f39518e..f3f892073 100644
--- a/telepathy-glib/util-internal.h
+++ b/telepathy-glib/util-internal.h
@@ -97,4 +97,6 @@ gboolean _tp_contacts_to_handles (TpConnection *connection,
TpContact * const *contacts,
GArray **handles);
+GPtrArray *_tp_contacts_from_values (GHashTable *table);
+
#endif /* __TP_UTIL_INTERNAL_H__ */
diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c
index 305cf076f..ba0ec416b 100644
--- a/telepathy-glib/util.c
+++ b/telepathy-glib/util.c
@@ -1920,3 +1920,25 @@ _tp_contacts_to_handles (TpConnection *connection,
return TRUE;
}
+
+/* table's key can be anything (usually TpHandle) but value must be a
+ * GObject (usually TpContact) */
+GPtrArray *
+_tp_contacts_from_values (GHashTable *table)
+{
+ GPtrArray *contacts;
+ GHashTableIter iter;
+ gpointer value;
+
+ contacts = _tp_g_ptr_array_new_full (g_hash_table_size (table),
+ g_object_unref);
+
+ g_hash_table_iter_init (&iter, table);
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ {
+ g_assert (G_IS_OBJECT (value));
+ g_ptr_array_add (contacts, g_object_ref (value));
+ }
+
+ return contacts;
+}