summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-12-20 18:43:01 (GMT)
committerWill Thompson <will.thompson@collabora.co.uk>2010-12-20 18:43:01 (GMT)
commita59d9e3fcbe6fb8bca8962721c7c40cdda3c5154 (patch)
tree6a5f4c9117fd061c59ca8f116040495c4887a0fa
parent0da65dac9be817a4c74d89477d593b8467a0bd9f (diff)
parent42a0caaac49ebab5aff47ab1ffae00e905ef470e (diff)
downloadtelepathy-glib-a59d9e3fcbe6fb8bca8962721c7c40cdda3c5154.tar.gz
telepathy-glib-a59d9e3fcbe6fb8bca8962721c7c40cdda3c5154.tar.xz
Merge remote branch 'smcv/better-contact-list' into spec-0.21.8
-rw-r--r--docs/reference/telepathy-glib-sections.txt2
-rw-r--r--telepathy-glib/base-contact-list.c39
-rw-r--r--telepathy-glib/intset.c69
-rw-r--r--telepathy-glib/intset.h3
4 files changed, 84 insertions, 29 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 4ff15a9..aa83aeb 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -1930,7 +1930,9 @@ tp_intset_is_equal
tp_intset_copy
tp_intset_intersection
tp_intset_union
+tp_intset_union_update
tp_intset_difference
+tp_intset_difference_update
tp_intset_symmetric_difference
tp_intset_dump
TpIntsetFastIter
diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c
index 1dd274a..519c2f4 100644
--- a/telepathy-glib/base-contact-list.c
+++ b/telepathy-glib/base-contact-list.c
@@ -1939,7 +1939,9 @@ tp_base_contact_list_contacts_changed (TpBaseContactList *self,
TpHandleSet *removed)
{
GHashTable *changes;
+ GHashTable *change_ids;
GArray *removals;
+ GHashTable *removal_ids;
TpIntsetFastIter iter;
TpIntset *pub, *sub_rp, *unpub, *unsub, *store;
GObject *sub_chan, *pub_chan, *stored_chan;
@@ -1975,6 +1977,7 @@ tp_base_contact_list_contacts_changed (TpBaseContactList *self,
changes = g_hash_table_new_full (NULL, NULL, NULL,
(GDestroyNotify) g_value_array_free);
+ change_ids = g_hash_table_new (NULL, NULL);
if (changed != NULL)
tp_intset_fast_iter_init (&iter, tp_handle_set_peek (changed));
@@ -2088,21 +2091,29 @@ tp_base_contact_list_contacts_changed (TpBaseContactList *self,
G_TYPE_STRING, publish_request,
G_TYPE_INVALID));
g_free (publish_request);
+
+ g_hash_table_insert (change_ids, GUINT_TO_POINTER (contact),
+ (gchar *) tp_handle_inspect (self->priv->contact_repo, contact));
}
+ removal_ids = g_hash_table_new (NULL, NULL);
+
if (removed != NULL)
{
- TpIntset *tmp;
-
- tmp = unsub;
- unsub = tp_intset_union (tmp, tp_handle_set_peek (removed));
- tp_intset_destroy (tmp);
+ guint i;
- tmp = unpub;
- unpub = tp_intset_union (tmp, tp_handle_set_peek (removed));
- tp_intset_destroy (tmp);
+ tp_intset_union_update (unsub, tp_handle_set_peek (removed));
+ tp_intset_union_update (unpub, tp_handle_set_peek (removed));
removals = tp_handle_set_to_array (removed);
+
+ for (i = 0; i < removals->len; i++)
+ {
+ TpHandle handle = g_array_index (removals, guint, i);
+
+ g_hash_table_insert (removal_ids, GUINT_TO_POINTER (handle),
+ (gchar *) tp_handle_inspect (self->priv->contact_repo, handle));
+ }
}
else
{
@@ -2145,8 +2156,14 @@ tp_base_contact_list_contacts_changed (TpBaseContactList *self,
g_hash_table_size (changes), removals->len);
if (self->priv->svc_contact_list)
- tp_svc_connection_interface_contact_list_emit_contacts_changed (
- self->priv->conn, changes, removals);
+ {
+#if 0
+ tp_svc_connection_interface_contact_list_emit_contacts_changed_with_ids (
+ self->priv->conn, changes, change_ids, removal_ids);
+#endif
+ tp_svc_connection_interface_contact_list_emit_contacts_changed (
+ self->priv->conn, changes, removals);
+ }
}
tp_intset_destroy (pub);
@@ -2156,6 +2173,8 @@ tp_base_contact_list_contacts_changed (TpBaseContactList *self,
tp_intset_destroy (store);
g_hash_table_unref (changes);
+ g_hash_table_unref (change_ids);
+ g_hash_table_unref (removal_ids);
g_array_unref (removals);
}
diff --git a/telepathy-glib/intset.c b/telepathy-glib/intset.c
index 96dc76b..86369f6 100644
--- a/telepathy-glib/intset.c
+++ b/telepathy-glib/intset.c
@@ -624,7 +624,6 @@ tp_intset_intersection (const TpIntset *left, const TpIntset *right)
return ret;
}
-
/**
* tp_intset_union:
* @left: The left operand
@@ -640,27 +639,43 @@ tp_intset_intersection (const TpIntset *left, const TpIntset *right)
TpIntset *
tp_intset_union (const TpIntset *left, const TpIntset *right)
{
- gpointer key, value;
- GHashTableIter iter;
TpIntset *ret;
ret = tp_intset_copy (left);
+ tp_intset_union_update (ret, right);
- g_hash_table_iter_init (&iter, (GHashTable *) right->table);
+ return ret;
+}
+
+/**
+ * tp_intset_union_update:
+ * @self: the set to change
+ * @other: members to add
+ *
+ * Add each integer in @other to @self, analogous to the bitwise operation
+ * self |= other.
+ *
+ * Since: 0.13.UNRELEASED
+ */
+void
+tp_intset_union_update (TpIntset *self,
+ const TpIntset *other)
+{
+ gpointer key, value;
+ GHashTableIter iter;
+
+ g_hash_table_iter_init (&iter, (GHashTable *) other->table);
while (g_hash_table_iter_next (&iter, &key, &value))
{
gsize v = GPOINTER_TO_SIZE (value);
- intset_update_largest_ever (ret, key);
- v |= GPOINTER_TO_SIZE (g_hash_table_lookup (ret->table, key));
- g_hash_table_insert (ret->table, key, GSIZE_TO_POINTER (v));
+ intset_update_largest_ever (self, key);
+ v |= GPOINTER_TO_SIZE (g_hash_table_lookup (self->table, key));
+ g_hash_table_insert (self->table, key, GSIZE_TO_POINTER (v));
}
-
- return ret;
}
-
/**
* tp_intset_difference:
* @left: The left operand
@@ -677,33 +692,49 @@ TpIntset *
tp_intset_difference (const TpIntset *left, const TpIntset *right)
{
TpIntset *ret;
- gpointer key, value;
- GHashTableIter iter;
g_return_val_if_fail (left != NULL, NULL);
g_return_val_if_fail (right != NULL, NULL);
ret = tp_intset_copy (left);
+ tp_intset_difference_update (ret, right);
- g_hash_table_iter_init (&iter, (GHashTable *) right->table);
+ return ret;
+}
+
+/**
+ * tp_intset_difference_update:
+ * @self: the set to change
+ * @other: members to remove
+ *
+ * Remove each integer in @other from @self, analogous to the bitwise
+ * operation self &= (~other).
+ *
+ * Since: 0.13.UNRELEASED
+ */
+void
+tp_intset_difference_update (TpIntset *self,
+ const TpIntset *other)
+{
+ gpointer key, value;
+ GHashTableIter iter;
+
+ g_hash_table_iter_init (&iter, (GHashTable *) other->table);
while (g_hash_table_iter_next (&iter, &key, &value))
{
gsize v = GPOINTER_TO_SIZE (value);
- v = (GPOINTER_TO_SIZE (g_hash_table_lookup (ret->table, key))) & ~v;
+ v = (GPOINTER_TO_SIZE (g_hash_table_lookup (self->table, key))) & ~v;
/* No need to update largest_ever here - we're only deleting members. */
if (v == 0)
- g_hash_table_remove (ret->table, key);
+ g_hash_table_remove (self->table, key);
else
- g_hash_table_insert (ret->table, key, GSIZE_TO_POINTER (v));
+ g_hash_table_insert (self->table, key, GSIZE_TO_POINTER (v));
}
-
- return ret;
}
-
/**
* tp_intset_symmetric_difference:
* @left: The left operand
diff --git a/telepathy-glib/intset.h b/telepathy-glib/intset.h
index b3eb204..5b9d907 100644
--- a/telepathy-glib/intset.h
+++ b/telepathy-glib/intset.h
@@ -132,6 +132,9 @@ void tp_intset_fast_iter_init (TpIntsetFastIter *iter,
gboolean tp_intset_fast_iter_next (TpIntsetFastIter *iter,
guint *output);
+void tp_intset_union_update (TpIntset *self, const TpIntset *other);
+void tp_intset_difference_update (TpIntset *self, const TpIntset *other);
+
G_END_DECLS
#endif /*__TP_INTSET_H__*/