summaryrefslogtreecommitdiff
path: root/telepathy-glib
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-20 17:49:57 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-01 13:05:05 +0100
commit70df467659e59c11a54245a57dba50eb53f6a8e5 (patch)
tree0cc5c8369b137e0d3d5ad11bbe143d9602d8afdb /telepathy-glib
parent293c43f3c7d9359d7c03a150dbc348fbeaf14ca6 (diff)
Automatically prepare TP_CONTACT_FEATURE_CONTACT_BLOCKING when possible
Once TP_CONNECTION_FEATURE_CONTACT_BLOCKING has been prepared we can easily prepare TP_CONTACT_FEATURE_CONTACT_BLOCKING on all contacts as we have all the information needed. Extra contact feature for free! https://bugs.freedesktop.org/show_bug.cgi?id=41801
Diffstat (limited to 'telepathy-glib')
-rw-r--r--telepathy-glib/connection-contact-list.c24
-rw-r--r--telepathy-glib/connection-internal.h3
-rw-r--r--telepathy-glib/connection.c6
3 files changed, 33 insertions, 0 deletions
diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index 8d8dbbc2..5476d1c5 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -1587,6 +1587,18 @@ blocked_changed_item_free (BlockedChangedItem *item)
static void process_queued_blocked_changed (TpConnection *self);
+void
+_tp_connection_set_contact_blocked (TpConnection *self,
+ TpContact *contact)
+{
+ gboolean blocked;
+
+ blocked = tp_g_ptr_array_contains (self->priv->blocked_contacts,
+ contact);
+
+ _tp_contact_set_is_blocked (contact, blocked);
+}
+
static void
blocked_changed_head_ready (TpConnection *self)
{
@@ -1596,6 +1608,18 @@ blocked_changed_head_ready (TpConnection *self)
if (item->result != NULL)
{
+ /* Finish to prepare TP_CONNECTION_FEATURE_CONTACT_BLOCKING, we can
+ * prepare TP_CONTACT_FEATURE_CONTACT_BLOCKING on all contacts as we
+ * have now the list of blocked contacts. */
+ GHashTableIter iter;
+ gpointer contact;
+
+ g_hash_table_iter_init (&iter, self->priv->contacts);
+ while (g_hash_table_iter_next (&iter, NULL, &contact))
+ {
+ _tp_connection_set_contact_blocked (self, contact);
+ }
+
g_simple_async_result_complete (item->result);
}
diff --git a/telepathy-glib/connection-internal.h b/telepathy-glib/connection-internal.h
index 24031cde..e346c2b9 100644
--- a/telepathy-glib/connection-internal.h
+++ b/telepathy-glib/connection-internal.h
@@ -178,6 +178,9 @@ void _tp_connection_prepare_contact_blocking_async (TpProxy *proxy,
GAsyncReadyCallback callback,
gpointer user_data);
+void _tp_connection_set_contact_blocked (TpConnection *self,
+ TpContact *contact);
+
G_END_DECLS
#endif
diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c
index aed21ea1..97011642 100644
--- a/telepathy-glib/connection.c
+++ b/telepathy-glib/connection.c
@@ -3146,6 +3146,12 @@ _tp_connection_add_contact (TpConnection *self,
g_hash_table_insert (self->priv->contacts, GUINT_TO_POINTER (handle),
contact);
+
+ /* Set TP_CONTACT_FEATURE_CONTACT_BLOCKING if possible */
+ if (tp_proxy_is_prepared (self, TP_CONNECTION_FEATURE_CONTACT_BLOCKING))
+ {
+ _tp_connection_set_contact_blocked (self, contact);
+ }
}