aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-individual-manager.c74
-rw-r--r--libempathy/empathy-individual-manager.h9
2 files changed, 83 insertions, 0 deletions
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index fa5bd38b5..d19da2423 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>
@@ -459,6 +460,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,
@@ -528,6 +600,8 @@ empathy_individual_manager_get_flags_for_connection (
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;
}
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index 72104fc40..5d9e3e777 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -42,6 +42,7 @@ G_BEGIN_DECLS
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;
@@ -94,5 +95,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__ */