From 5f61ae42d2cfbdc858ab89adfd4d24311467f387 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 9 Jun 2011 12:20:53 +0100 Subject: [PATCH 1/2] Blocking: implement can_block and add to Conn.Interfaces --- src/connection.c | 11 ++++++++++- src/contact-list.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletions(-) diff --git a/src/connection.c b/src/connection.c index 949b45f..f82fbc5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -92,7 +92,8 @@ static const gchar * implemented_interfaces[] = { TP_IFACE_CONNECTION_INTERFACE_AVATARS, HAZE_IFACE_CONNECTION_INTERFACE_MAIL_NOTIFICATION, -# define HAZE_NUM_CONDITIONAL_INTERFACES 2 + TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING, +# define HAZE_NUM_CONDITIONAL_INTERFACES 3 /* Always present */ @@ -161,6 +162,14 @@ connected_cb (PurpleConnection *pc) tp_base_connection_add_interfaces (base_conn, avatar_ifaces); } + if (prpl_info->add_deny != NULL) + { + static const gchar *blocking_ifaces[] = { + TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING, + NULL }; + tp_base_connection_add_interfaces (base_conn, blocking_ifaces); + } + tp_base_contact_list_set_list_received ( (TpBaseContactList *) conn->contact_list); diff --git a/src/contact-list.c b/src/contact-list.c index e333850..fb70081 100644 --- a/src/contact-list.c +++ b/src/contact-list.c @@ -1296,6 +1296,15 @@ unblock_contacts_async(TpBaseContactList *cl, user_data, unblock_contacts_async); } +static gboolean +can_block (TpBaseContactList *cl) +{ + HazeContactList *self = HAZE_CONTACT_LIST (cl); + + return (self->priv->conn->account->gc != NULL && + HAZE_CONNECTION_GET_PRPL_INFO (self->priv->conn)->add_deny != NULL); +} + static void haze_contact_list_blockable_init( TpBlockableContactListInterface *vtable) @@ -1303,4 +1312,6 @@ haze_contact_list_blockable_init( vtable->dup_blocked_contacts = dup_blocked_contacts; vtable->block_contacts_async = block_contacts_async; vtable->unblock_contacts_async = unblock_contacts_async; + + vtable->can_block = can_block; } -- 1.7.5.3