[empathy] Use more tp_capabilities_ methods



commit f83db2fac6476f8c7c2cdce15a7a92e254160eac
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Apr 10 16:18:29 2012 +0200

    Use more tp_capabilities_ methods
    
    Makes code easier and would allow us to stop using a GValueArray once we'll
    have API to check if SMS are supported.
    
    This may break StreamedMedia only CM but we are not going to support those in
    3.5 anyway.

 libempathy/empathy-contact.c |   76 ++++++++++--------------------------------
 1 files changed, 18 insertions(+), 58 deletions(-)
---
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 0c4ef75..704a64f 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1701,6 +1701,23 @@ tp_caps_to_capabilities (TpCapabilities *caps)
   guint i;
   GPtrArray *classes;
 
+  if (tp_capabilities_supports_file_transfer (caps))
+    capabilities |= EMPATHY_CAPABILITIES_FT;
+
+  if (tp_capabilities_supports_stream_tubes (caps, TP_HANDLE_TYPE_CONTACT,
+        "rfb"))
+    capabilities |= EMPATHY_CAPABILITIES_RFB_STREAM_TUBE;
+
+  if (tp_capabilities_supports_audio_video_call (caps, TP_HANDLE_TYPE_CONTACT))
+    {
+      capabilities |= EMPATHY_CAPABILITIES_AUDIO;
+      capabilities |= EMPATHY_CAPABILITIES_VIDEO;
+    }
+  else if (tp_capabilities_supports_audio_call (caps, TP_HANDLE_TYPE_CONTACT))
+    {
+      capabilities |= EMPATHY_CAPABILITIES_AUDIO;
+    }
+
   classes = tp_capabilities_get_channel_classes (caps);
 
   for (i = 0; i < classes->len; i++)
@@ -1724,69 +1741,12 @@ tp_caps_to_capabilities (TpCapabilities *caps)
       chan_type = tp_asv_get_string (fixed_prop,
           TP_PROP_CHANNEL_CHANNEL_TYPE);
 
-      if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
-        {
-          capabilities |= EMPATHY_CAPABILITIES_FT;
-        }
-      else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
-        {
-          const gchar *service;
-
-          service = tp_asv_get_string (fixed_prop,
-              TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE);
-
-          if (!tp_strdiff (service, "rfb"))
-            capabilities |= EMPATHY_CAPABILITIES_RFB_STREAM_TUBE;
-        }
-      else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA))
-        {
-          guint j;
-
-          for (j = 0; allowed_prop[j] != NULL; j++)
-            {
-              if (!tp_strdiff (allowed_prop[j],
-                    TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO))
-                capabilities |= EMPATHY_CAPABILITIES_AUDIO;
-              else if (!tp_strdiff (allowed_prop[j],
-                    TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO))
-                capabilities |= EMPATHY_CAPABILITIES_VIDEO;
-            }
-
-          if (tp_asv_get_boolean (fixed_prop,
-                    TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_AUDIO, NULL))
-            capabilities |= EMPATHY_CAPABILITIES_AUDIO;
-          if (tp_asv_get_boolean (fixed_prop,
-                    TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, NULL))
-            capabilities |= EMPATHY_CAPABILITIES_VIDEO;
-        }
-      else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
+      if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
         {
           if (tp_asv_get_boolean (fixed_prop,
                 TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL))
             capabilities |= EMPATHY_CAPABILITIES_SMS;
         }
-      else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CALL))
-        {
-          guint j;
-
-          if (tp_asv_get_boolean (fixed_prop,
-              TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, NULL))
-            capabilities |= EMPATHY_CAPABILITIES_AUDIO;
-
-          if (tp_asv_get_boolean (fixed_prop,
-              TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, NULL))
-            capabilities |= EMPATHY_CAPABILITIES_VIDEO;
-
-          for (j = 0; allowed_prop[j] != NULL; j++)
-            {
-              if (!tp_strdiff (allowed_prop[j],
-                    TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO))
-                capabilities |= EMPATHY_CAPABILITIES_AUDIO;
-              else if (!tp_strdiff (allowed_prop[j],
-                    TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO))
-                capabilities |= EMPATHY_CAPABILITIES_VIDEO;
-            }
-        }
     }
 
   return capabilities;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]