aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2010-09-02 23:02:01 +0800
committerPhilip Withnall <philip.withnall@collabora.co.uk>2010-09-03 17:18:44 +0800
commit415b48c96ad03fa4949268d0ce9645f02005a818 (patch)
treecaf6317b2cf8a48711ed2ba0065c4c189a8bff96
parent5de0be112e18b3c1ad4d122a6a293bd4cb6807af (diff)
downloadgsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar.gz
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar.bz2
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar.lz
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar.xz
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.tar.zst
gsoc2013-empathy-415b48c96ad03fa4949268d0ce9645f02005a818.zip
Add a heuristic to prefer audio- and video-capable Personas when calling
When choosing which Persona out of an Individual to start an audio or video call to, given a choice between two Personas of equal presence, choose the one which is capable of both audio and video calls over the one which is capable of only one of the two. This is because clients which can do both types of call are generally more featureful than those which can only do one type. Helps: bgo#628338
-rw-r--r--libempathy/empathy-contact.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 0bba88396..ec5d83ab6 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1750,14 +1750,40 @@ presence_sort_func (EmpathyContact *a, EmpathyContact *b)
folks_presence_get_presence_type (presence_b));
}
+/* Sort by presence as with presence_sort_func(), but if the two contacts have
+ * the same presence, prefer the one which can do both audio *and* video calls,
+ * over the one which can only do one of the two. */
+static int
+voip_sort_func (EmpathyContact *a, EmpathyContact *b)
+{
+ gboolean has_audio_video_a, has_audio_video_b;
+ gint presence_sort = presence_sort_func (a, b);
+
+ if (presence_sort != 0)
+ return presence_sort;
+
+ has_audio_video_a = empathy_contact_can_voip_audio (a) &&
+ empathy_contact_can_voip_video (a);
+ has_audio_video_b = empathy_contact_can_voip_audio (b) &&
+ empathy_contact_can_voip_video (b);
+
+ if (has_audio_video_a && !has_audio_video_b)
+ return -1;
+ else if (!has_audio_video_a && has_audio_video_b)
+ return 1;
+ else
+ return 0;
+}
+
static GCompareFunc
get_sort_func_for_action (EmpathyActionType action_type)
{
switch (action_type)
{
- case EMPATHY_ACTION_CHAT:
case EMPATHY_ACTION_AUDIO_CALL:
case EMPATHY_ACTION_VIDEO_CALL:
+ return (GCompareFunc) voip_sort_func;
+ case EMPATHY_ACTION_CHAT:
case EMPATHY_ACTION_VIEW_LOGS:
case EMPATHY_ACTION_SEND_FILE:
case EMPATHY_ACTION_SHARE_MY_DESKTOP: