[empathy: 12/35] Add contact blocking support to EmpathyIndividualManager
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 12/35] Add contact blocking support to EmpathyIndividualManager
- Date: Mon, 14 Mar 2011 02:00:11 +0000 (UTC)
commit 6da159d09091d68a102c142b10747ae58755de51
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Wed Feb 9 17:24:27 2011 +1100
Add contact blocking support to EmpathyIndividualManager
libempathy/empathy-individual-manager.c | 104 +++++++++++++++++++++++++++++++
libempathy/empathy-individual-manager.h | 18 +++++
2 files changed, 122 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index 894ae64..a2432ef 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -30,6 +30,7 @@
#include <telepathy-glib/util.h>
#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
#include <extensions/extensions.h>
@@ -483,6 +484,77 @@ empathy_individual_manager_remove (EmpathyIndividualManager *self,
aggregator_remove_individual_cb, self);
}
+/**
+ * empathy_individual_manager_supports_blocking
+ * @self: the #EmpathyIndividualManager
+ * @individual: an individual to check
+ *
+ * Indicates whether any personas of an @individual can be blocked.
+ *
+ * Returns: %TRUE if any persona supports contact blocking
+ */
+gboolean
+empathy_individual_manager_supports_blocking (EmpathyIndividualManager *self,
+ FolksIndividual *individual)
+{
+ EmpathyIndividualManagerPriv *priv;
+ GList *personas, *l;
+
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self), FALSE);
+
+ priv = GET_PRIV (self);
+
+ personas = folks_individual_get_personas (individual);
+
+ for (l = personas; l != NULL; l = l->next)
+ {
+ TpfPersona *persona = l->data;
+ TpConnection *conn;
+
+ if (!TPF_IS_PERSONA (persona))
+ continue;
+
+ conn = tp_contact_get_connection (tpf_persona_get_contact (persona));
+
+ if (empathy_individual_manager_get_flags_for_connection (self, conn) &
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
+ FolksIndividual *individual,
+ gboolean blocked)
+{
+ EmpathyIndividualManagerPriv *priv;
+ GList *personas, *l;
+
+ g_return_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self));
+
+ priv = GET_PRIV (self);
+
+ personas = folks_individual_get_personas (individual);
+
+ for (l = personas; l != NULL; l = l->next)
+ {
+ TpfPersona *persona = l->data;
+ EmpathyContact *contact;
+
+ if (!TPF_IS_PERSONA (persona))
+ continue;
+
+ contact = empathy_contact_dup_from_tp_contact (
+ tpf_persona_get_contact (persona));
+ empathy_contact_set_persona (contact, FOLKS_PERSONA (persona));
+ empathy_contact_list_set_blocked (
+ EMPATHY_CONTACT_LIST (priv->contact_manager),
+ contact, blocked);
+ }
+}
+
static void
groups_change_group_cb (GObject *source,
GAsyncResult *result,
@@ -526,6 +598,38 @@ empathy_individual_manager_remove_group (EmpathyIndividualManager *manager,
(gpointer) group);
}
+EmpathyIndividualManagerFlags
+empathy_individual_manager_get_flags_for_connection (
+ EmpathyIndividualManager *self,
+ TpConnection *connection)
+{
+ EmpathyIndividualManagerPriv *priv;
+ EmpathyContactListFlags list_flags;
+ EmpathyIndividualManagerFlags flags;
+
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (self),
+ EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS);
+
+ priv = GET_PRIV (self);
+
+ list_flags = empathy_contact_manager_get_flags_for_connection (
+ priv->contact_manager, connection);
+
+ flags = EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_ADD)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_REMOVE)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_ALIAS)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_GROUP)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP;
+ if (list_flags & EMPATHY_CONTACT_LIST_CAN_BLOCK)
+ flags |= EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK;
+
+ return flags;
+}
+
static void
link_personas_cb (FolksIndividualAggregator *aggregator,
GAsyncResult *async_result,
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index f2f5f5b..daa7ec8 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -36,6 +36,16 @@ G_BEGIN_DECLS
#define EMPATHY_IS_INDIVIDUAL_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDIVIDUAL_MANAGER))
#define EMPATHY_INDIVIDUAL_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDIVIDUAL_MANAGER, EmpathyIndividualManagerClass))
+typedef enum
+{
+ EMPATHY_INDIVIDUAL_MANAGER_NO_FLAGS = 0,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_ADD = 1 << 0,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_REMOVE = 1 << 1,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_ALIAS = 1 << 2,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_GROUP = 1 << 3,
+ EMPATHY_INDIVIDUAL_MANAGER_CAN_BLOCK = 1 << 4,
+} EmpathyIndividualManagerFlags;
+
typedef struct _EmpathyIndividualManager EmpathyIndividualManager;
typedef struct _EmpathyIndividualManagerClass EmpathyIndividualManagerClass;
@@ -81,5 +91,13 @@ void empathy_individual_manager_unlink_individual (
EmpathyIndividualManager *self,
FolksIndividual *individual);
+gboolean empathy_individual_manager_supports_blocking (
+ EmpathyIndividualManager *self,
+ FolksIndividual *individual);
+
+void empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
+ FolksIndividual *individual,
+ gboolean blocked);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]