aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-08-05 19:13:31 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-10-18 16:56:40 +0800
commit588247c8bba25fd9ed087e1f8f06997c5c7534f2 (patch)
tree509fc189e576f84392566af0b69cca18ac6c5271
parent5af3f211b66a1278c44ad6815224e00dd26b795a (diff)
downloadgsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar.gz
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar.bz2
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar.lz
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar.xz
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.tar.zst
gsoc2013-empathy-588247c8bba25fd9ed087e1f8f06997c5c7534f2.zip
factor out empathy_individual_can_audio_video_call()
Also allow caller to get a ref on the EmpathyContact supporting audio/video. https://bugzilla.gnome.org/show_bug.cgi?id=661981
-rw-r--r--libempathy-gtk/empathy-individual-store.c57
-rw-r--r--libempathy/empathy-utils.c58
-rw-r--r--libempathy/empathy-utils.h5
3 files changed, 67 insertions, 53 deletions
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index a499bf1cc..e7b859f98 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -105,55 +105,6 @@ static void individual_store_contact_update (EmpathyIndividualStore *self,
G_DEFINE_TYPE (EmpathyIndividualStore, empathy_individual_store,
GTK_TYPE_TREE_STORE);
-/* Calculate whether the Individual can do audio or video calls.
- * FIXME: We can remove this once libfolks has grown capabilities support
- * again: bgo#626179. */
-static void
-individual_can_audio_video_call (FolksIndividual *individual,
- gboolean *can_audio_call,
- gboolean *can_video_call)
-{
- GeeSet *personas;
- GeeIterator *iter;
- gboolean can_audio = FALSE, can_video = FALSE;
-
- personas = folks_individual_get_personas (individual);
- iter = gee_iterable_iterator (GEE_ITERABLE (personas));
- while (gee_iterator_next (iter))
- {
- FolksPersona *persona = gee_iterator_get (iter);
- TpContact *tp_contact;
-
- if (!empathy_folks_persona_is_interesting (persona))
- goto while_finish;
-
- tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
- if (tp_contact != NULL)
- {
- EmpathyContact *contact;
-
- contact = empathy_contact_dup_from_tp_contact (tp_contact);
- empathy_contact_set_persona (contact, persona);
-
- can_audio = can_audio || empathy_contact_get_capabilities (contact) &
- EMPATHY_CAPABILITIES_AUDIO;
- can_video = can_video || empathy_contact_get_capabilities (contact) &
- EMPATHY_CAPABILITIES_VIDEO;
-
- g_object_unref (contact);
- }
-while_finish:
- g_clear_object (&persona);
-
- if (can_audio && can_video)
- break;
- }
- g_clear_object (&iter);
-
- *can_audio_call = can_audio;
- *can_video_call = can_video;
-}
-
static const gchar * const *
individual_get_client_types (FolksIndividual *individual)
{
@@ -207,8 +158,8 @@ add_individual_to_store (GtkTreeStore *self,
const gchar * const *types;
GQueue *queue;
- individual_can_audio_video_call (individual, &can_audio_call,
- &can_video_call);
+ empathy_individual_can_audio_video_call (individual, &can_audio_call,
+ &can_video_call, NULL);
types = individual_get_client_types (individual);
@@ -770,8 +721,8 @@ individual_store_contact_update (EmpathyIndividualStore *self,
gboolean can_audio_call, can_video_call;
const gchar * const *types;
- individual_can_audio_video_call (individual, &can_audio_call,
- &can_video_call);
+ empathy_individual_can_audio_video_call (individual, &can_audio_call,
+ &can_video_call, NULL);
types = individual_get_client_types (individual);
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index 9eec82e74..c4c2780ac 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -1090,3 +1090,61 @@ out:
g_clear_object (&persona_store);
return retval;
}
+
+/* Calculate whether the Individual can do audio or video calls.
+ * FIXME: We can remove this once libfolks has grown capabilities support
+ * again: bgo#626179. */
+void
+empathy_individual_can_audio_video_call (FolksIndividual *individual,
+ gboolean *can_audio_call,
+ gboolean *can_video_call,
+ EmpathyContact **out_contact)
+{
+ GeeSet *personas;
+ GeeIterator *iter;
+ gboolean can_audio = FALSE, can_video = FALSE;
+
+ personas = folks_individual_get_personas (individual);
+ iter = gee_iterable_iterator (GEE_ITERABLE (personas));
+ while (gee_iterator_next (iter))
+ {
+ FolksPersona *persona = gee_iterator_get (iter);
+ TpContact *tp_contact;
+
+ if (!empathy_folks_persona_is_interesting (persona))
+ goto while_finish;
+
+ tp_contact = tpf_persona_get_contact (TPF_PERSONA (persona));
+ if (tp_contact != NULL)
+ {
+ EmpathyContact *contact;
+
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
+ empathy_contact_set_persona (contact, persona);
+
+ can_audio = can_audio || empathy_contact_get_capabilities (contact) &
+ EMPATHY_CAPABILITIES_AUDIO;
+ can_video = can_video || empathy_contact_get_capabilities (contact) &
+ EMPATHY_CAPABILITIES_VIDEO;
+
+ if (out_contact != NULL)
+ *out_contact = g_object_ref (contact);
+
+ g_object_unref (contact);
+ }
+
+while_finish:
+ g_clear_object (&persona);
+
+ if (can_audio && can_video)
+ break;
+ }
+
+ g_clear_object (&iter);
+
+ if (can_audio_call != NULL)
+ *can_audio_call = can_audio;
+
+ if (can_video_call != NULL)
+ *can_video_call = can_video;
+}
diff --git a/libempathy/empathy-utils.h b/libempathy/empathy-utils.h
index ed603a80f..4983c89a6 100644
--- a/libempathy/empathy-utils.h
+++ b/libempathy/empathy-utils.h
@@ -113,6 +113,11 @@ gboolean empathy_account_has_uri_scheme_tel (TpAccount *account);
TpContact * empathy_get_tp_contact_for_individual (FolksIndividual *individual,
TpConnection *conn);
+void empathy_individual_can_audio_video_call (FolksIndividual *individual,
+ gboolean *can_audio_call,
+ gboolean *can_video_call,
+ EmpathyContact **out_contact);
+
/* Copied from wocky/wocky-utils.h */
#define empathy_implement_finish_void(source, tag) \