aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-17 20:10:32 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-09-27 21:20:19 +0800
commita2851c345723360e779b9adc4fe17684136f40b7 (patch)
tree05fba549c3c52b00bf44ea1c6bec51a65e89f1b4 /libempathy
parent362d847a53dfa9c344781065c3b1af5952a405e3 (diff)
downloadgsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar.gz
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar.bz2
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar.lz
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar.xz
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.tar.zst
gsoc2013-empathy-a2851c345723360e779b9adc4fe17684136f40b7.zip
Prioritize default individual for chats using capabilities (#629912)
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index ab3fba538..642f087df 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1770,6 +1770,40 @@ voip_cmp_func (EmpathyContact *a,
return 0;
}
+static gint
+ft_cmp_func (EmpathyContact *a,
+ EmpathyContact *b)
+{
+ gboolean can_send_files_a, can_send_files_b;
+
+ can_send_files_a = empathy_contact_can_send_files (a);
+ can_send_files_b = empathy_contact_can_send_files (b);
+
+ if (can_send_files_a == can_send_files_b)
+ return 0;
+ else if (can_send_files_a)
+ return -1;
+ else
+ return 1;
+}
+
+static gint
+rfb_stream_tube_cmp_func (EmpathyContact *a,
+ EmpathyContact *b)
+{
+ gboolean rfb_a, rfb_b;
+
+ rfb_a = empathy_contact_can_use_rfb_stream_tube (a);
+ rfb_b = empathy_contact_can_use_rfb_stream_tube (b);
+
+ if (rfb_a == rfb_b)
+ return 0;
+ else if (rfb_a)
+ return -1;
+ else
+ return 1;
+}
+
/* Sort by presence as with presence_cmp_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. */
@@ -1784,6 +1818,33 @@ voip_sort_func (EmpathyContact *a, EmpathyContact *b)
return voip_cmp_func (a, b);
}
+/* Sort by presence as with presence_cmp_func() and then break ties using the
+ * most "capable" individual. So users will be able to pick more actions on
+ * the contact in the "Contact" menu of the chat window. */
+static gint
+chat_sort_func (EmpathyContact *a,
+ EmpathyContact *b)
+{
+ gint result;
+
+ result = presence_cmp_func (a, b);
+ if (result != 0)
+ return result;
+
+ /* Prefer individual supporting file transfer */
+ result = ft_cmp_func (a, b);
+ if (result != 0)
+ return result;
+
+ /* Check audio/video capabilities */
+ result = voip_cmp_func (a, b);
+ if (result != 0)
+ return result;
+
+ /* Check 'Share my destop' feature */
+ return rfb_stream_tube_cmp_func (a, b);
+}
+
static GCompareFunc
get_sort_func_for_action (EmpathyActionType action_type)
{
@@ -1793,6 +1854,7 @@ get_sort_func_for_action (EmpathyActionType action_type)
case EMPATHY_ACTION_VIDEO_CALL:
return (GCompareFunc) voip_sort_func;
case EMPATHY_ACTION_CHAT:
+ return (GCompareFunc) chat_sort_func;
case EMPATHY_ACTION_VIEW_LOGS:
case EMPATHY_ACTION_SEND_FILE:
case EMPATHY_ACTION_SHARE_MY_DESKTOP: