[empathy] add empathy_individual_manager_lookup_by_contact()
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] add empathy_individual_manager_lookup_by_contact()
- Date: Wed, 15 Feb 2012 09:52:19 +0000 (UTC)
commit 894ce49de11658ae2b66907bf609f0e6810acb3e
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Fri Feb 10 14:40:28 2012 +0100
add empathy_individual_manager_lookup_by_contact()
https://bugzilla.gnome.org/show_bug.cgi?id=669676
libempathy/empathy-individual-manager.c | 52 +++++++++++++++++++++++++++++++
libempathy/empathy-individual-manager.h | 4 ++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-individual-manager.c b/libempathy/empathy-individual-manager.c
index a1ca269..68b094e 100644
--- a/libempathy/empathy-individual-manager.c
+++ b/libempathy/empathy-individual-manager.c
@@ -763,3 +763,55 @@ empathy_individual_manager_get_contacts_loaded (EmpathyIndividualManager *self)
return priv->contacts_loaded;
}
+
+static gboolean
+individual_has_contact (FolksIndividual *individual,
+ TpContact *contact)
+{
+ GeeSet *personas;
+ GeeIterator *iter;
+ gboolean found = FALSE;
+
+ personas = folks_individual_get_personas (individual);
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+
+ while (!found && gee_iterator_next (iter))
+ {
+ TpfPersona *persona = gee_iterator_get (iter);
+
+ if (TPF_IS_PERSONA (persona))
+ {
+ TpContact *c = tpf_persona_get_contact (persona);
+
+ if (c == contact)
+ found = TRUE;
+ }
+
+ g_clear_object (&persona);
+ }
+
+ g_clear_object (&iter);
+
+ return found;
+}
+
+/* Try finding a FolksIndividual containing @contact as one of his persona */
+FolksIndividual *
+empathy_individual_manager_lookup_by_contact (EmpathyIndividualManager *self,
+ TpContact *contact)
+{
+ EmpathyIndividualManagerPriv *priv = GET_PRIV (self);
+ GHashTableIter iter;
+ gpointer value;
+
+ g_hash_table_iter_init (&iter, priv->individuals);
+ while (g_hash_table_iter_next (&iter, NULL, &value))
+ {
+ FolksIndividual *individual = value;
+
+ if (individual_has_contact (individual, contact))
+ return individual;
+ }
+
+ return NULL;
+}
diff --git a/libempathy/empathy-individual-manager.h b/libempathy/empathy-individual-manager.h
index ec76038..08a1faa 100644
--- a/libempathy/empathy-individual-manager.h
+++ b/libempathy/empathy-individual-manager.h
@@ -93,5 +93,9 @@ void empathy_individual_manager_set_blocked (EmpathyIndividualManager *self,
gboolean empathy_individual_manager_get_contacts_loaded (
EmpathyIndividualManager *self);
+FolksIndividual * empathy_individual_manager_lookup_by_contact (
+ EmpathyIndividualManager *self,
+ TpContact *contact);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]