]> git.0d.be Git - empathy.git/commitdiff
Use more tp_capabilities_ methods
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 10 Apr 2012 14:18:29 +0000 (16:18 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 10 Apr 2012 14:18:29 +0000 (16:18 +0200)
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

index 0c4ef755f91181c685b410f3b64f43fea08607b5..704a64f979f2cea1f1b25b5e117783c7fca0bee8 100644 (file)
@@ -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;