[Telepathy-commits] [telepathy-glib/master] MembersChangedDetailed: include new members' IDs in details
Will Thompson
will.thompson at collabora.co.uk
Fri Jan 2 17:44:15 PST 2009
---
telepathy-glib/group-mixin.c | 79 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/telepathy-glib/group-mixin.c b/telepathy-glib/group-mixin.c
index 24cdd50..e804098 100644
--- a/telepathy-glib/group-mixin.c
+++ b/telepathy-glib/group-mixin.c
@@ -1283,6 +1283,78 @@ local_pending_remove (TpGroupMixin *mixin,
static void
+add_members_in_array (GHashTable *member_ids,
+ TpHandleRepoIface *repo,
+ const GArray *handles)
+{
+ guint i;
+
+ for (i = 0; i < handles->len; i++)
+ {
+ TpHandle handle = g_array_index (handles, TpHandle, i);
+ const gchar *id = tp_handle_inspect (repo, handle);
+
+ g_hash_table_insert (member_ids, GUINT_TO_POINTER (handle), (gchar *) id);
+ }
+}
+
+
+static gboolean
+maybe_add_member_ids (TpGroupMixin *mixin,
+ const GArray *add,
+ const GArray *local_pending,
+ const GArray *remote_pending,
+ TpHandle actor,
+ GHashTable *details)
+{
+ GValue *v;
+ GHashTable *member_ids;
+
+ /* If the library user had its own ideas about which members' IDs to include
+ * in the change details, we'll leave that intact.
+ */
+ if (tp_asv_lookup (details, "member-ids") != NULL)
+ return FALSE;
+
+ /* The library user didn't include the new members' IDs in details; let's add
+ * the IDs of the handles being added to the group (but not removed, as per
+ * the spec) and of the actor.
+ */
+ member_ids = g_hash_table_new (NULL, NULL);
+
+ add_members_in_array (member_ids, mixin->handle_repo, add);
+ add_members_in_array (member_ids, mixin->handle_repo, local_pending);
+ add_members_in_array (member_ids, mixin->handle_repo, remote_pending);
+
+ if (actor != 0)
+ {
+ const gchar *id = tp_handle_inspect (mixin->handle_repo, actor);
+
+ g_hash_table_insert (member_ids, GUINT_TO_POINTER (actor), (gchar *) id);
+ }
+
+ /* FIXME: TP_HASH_TYPE_HANDLE_IDENTIFIER_MAP */
+ v = tp_g_value_slice_new (tp_type_dbus_hash_us ());
+ g_value_take_boxed (v, member_ids);
+ g_hash_table_insert (details, "member-ids", v);
+
+ return TRUE;
+}
+
+
+static void
+remove_member_ids (GHashTable *details)
+{
+ GValue *member_ids_v = g_hash_table_lookup (details, "member-ids");
+
+ g_assert (member_ids_v != NULL);
+ g_hash_table_steal (details, "member-ids");
+
+ tp_g_value_slice_free (member_ids_v);
+}
+
+
+static void
emit_members_changed_signals (GObject *channel,
const gchar *message,
const GArray *add,
@@ -1295,6 +1367,7 @@ emit_members_changed_signals (GObject *channel,
{
TpGroupMixin *mixin = TP_GROUP_MIXIN (channel);
GHashTable *details_ = (GHashTable *) details; /* Cast the pain away! */
+ gboolean added_member_ids;
if (DEBUGGING)
{
@@ -1325,6 +1398,9 @@ emit_members_changed_signals (GObject *channel,
g_free (remote_str);
}
+ added_member_ids = maybe_add_member_ids (mixin, add, local_pending,
+ remote_pending, actor, details_);
+
tp_svc_channel_interface_group_emit_members_changed (channel, message,
add, del, local_pending, remote_pending, actor, reason);
tp_svc_channel_interface_group_emit_members_changed_detailed (channel,
@@ -1344,6 +1420,9 @@ emit_members_changed_signals (GObject *channel,
external, add, del, local_pending, remote_pending, details_);
}
}
+
+ if (added_member_ids)
+ remove_member_ids (details_);
}
--
1.5.6.5
More information about the Telepathy-commits
mailing list