summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-02-29 14:58:20 (GMT)
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-03-01 13:36:30 (GMT)
commitb13c6c36f5326fcfadc1d22ea1f1fa5fa98eb548 (patch)
tree298997e4c6faf5b0269283ed69fa3c05214900a9
parent8cf081eccb2634cff8013463319a5688a68ba71f (diff)
downloadtelepathy-glib-b13c6c36f5326fcfadc1d22ea1f1fa5fa98eb548.tar.gz
telepathy-glib-b13c6c36f5326fcfadc1d22ea1f1fa5fa98eb548.tar.xz
TpCapabilities: Add API telling if call and file transfer are supported
-rw-r--r--docs/reference/telepathy-glib-sections.txt3
-rw-r--r--telepathy-glib/capabilities.c111
-rw-r--r--telepathy-glib/capabilities.h3
3 files changed, 117 insertions, 0 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 57881d9..244a2b0 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -4946,6 +4946,9 @@ tp_capabilities_get_channel_classes
tp_capabilities_is_specific_to_contact
tp_capabilities_supports_text_chatrooms
tp_capabilities_supports_text_chats
+tp_capabilities_supports_audio_call
+tp_capabilities_supports_audio_video_call
+tp_capabilities_supports_file_transfer
tp_capabilities_supports_stream_tubes
tp_capabilities_supports_dbus_tubes
tp_capabilities_supports_contact_search
diff --git a/telepathy-glib/capabilities.c b/telepathy-glib/capabilities.c
index 38d14fa..8cecd6d 100644
--- a/telepathy-glib/capabilities.c
+++ b/telepathy-glib/capabilities.c
@@ -361,6 +361,117 @@ tp_capabilities_supports_text_chatrooms (TpCapabilities *self)
}
static gboolean
+supports_call_full (TpCapabilities *self,
+ gboolean initial_audio,
+ gboolean initial_video)
+{
+ guint i;
+
+ g_return_val_if_fail (TP_IS_CAPABILITIES (self), FALSE);
+
+ for (i = 0; i < self->priv->classes->len; i++)
+ {
+ GValueArray *arr = g_ptr_array_index (self->priv->classes, i);
+ GHashTable *fixed_prop;
+ const gchar * const *allowed_prop;
+ const gchar *chan_type;
+ TpHandleType handle_type;
+ gboolean valid;
+
+ tp_value_array_unpack (arr, 2,
+ &fixed_prop,
+ &allowed_prop);
+
+ chan_type = tp_asv_get_string (fixed_prop, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_CALL))
+ continue;
+
+ handle_type = tp_asv_get_uint32 (fixed_prop,
+ TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, &valid);
+ if (!valid || handle_type != TP_HANDLE_TYPE_CONTACT)
+ continue;
+
+ if (initial_audio &&
+ !tp_asv_get_boolean (fixed_prop,
+ TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO, NULL) &&
+ !tp_strv_contains (allowed_prop,
+ TP_PROP_CHANNEL_TYPE_CALL_INITIAL_AUDIO))
+ continue;
+
+ if (initial_video &&
+ !tp_asv_get_boolean (fixed_prop,
+ TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO, NULL) &&
+ !tp_strv_contains (allowed_prop,
+ TP_PROP_CHANNEL_TYPE_CALL_INITIAL_VIDEO))
+ continue;
+
+ /* We found the right class */
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ * tp_capabilities_supports_audio_call:
+ * @self: a #TpCapabilities object
+ *
+ * Return whether private audio call can be established by providing
+ * a contact identifier.
+ *
+ * Returns: %TRUE if a channel request containing Call as ChannelType,
+ * HandleTypeContact as TargetHandleType, a True value for InitialAudio and a
+ * contact identifier can be expected to work, %FALSE otherwise.
+ *
+ * Since: 0.UNRELEASED
+ */
+gboolean
+tp_capabilities_supports_audio_call (TpCapabilities *self)
+{
+ return supports_call_full (self, TRUE, FALSE);
+}
+
+/**
+ * tp_capabilities_supports_audio_video_call:
+ * @self: a #TpCapabilities object
+ *
+ * Return whether private audio/video call can be established by providing
+ * a contact identifier.
+ *
+ * Returns: %TRUE if a channel request containing Call as ChannelType,
+ * HandleTypeContact as TargetHandleType, a True value for
+ * InitialAudio/InitialVideo and a contact identifier can be expected to work,
+ * %FALSE otherwise.
+ *
+ * Since: 0.UNRELEASED
+ */
+gboolean
+tp_capabilities_supports_audio_video_call (TpCapabilities *self)
+{
+ return supports_call_full (self, TRUE, TRUE);
+}
+
+/**
+ * tp_capabilities_supports_file_transfer:
+ * @self: a #TpCapabilities object
+ *
+ * Return whether private file transfer can be established by providing
+ * a contact identifier.
+ *
+ * Returns: %TRUE if a channel request containing FileTransfer as ChannelType,
+ * HandleTypeContact as TargetHandleType and a contact identifier can be
+ * expected to work, %FALSE otherwise.
+ *
+ * Since: 0.UNRELEASED
+ */
+gboolean
+tp_capabilities_supports_file_transfer (TpCapabilities *self)
+{
+ return supports_simple_channel (self, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
+ TP_HANDLE_TYPE_CONTACT);
+}
+
+static gboolean
tp_capabilities_supports_tubes_common (TpCapabilities *self,
const gchar *expected_channel_type,
TpHandleType expected_handle_type,
diff --git a/telepathy-glib/capabilities.h b/telepathy-glib/capabilities.h
index b8d28f8..a90e5e1 100644
--- a/telepathy-glib/capabilities.h
+++ b/telepathy-glib/capabilities.h
@@ -54,6 +54,9 @@ gboolean tp_capabilities_is_specific_to_contact (TpCapabilities *self);
gboolean tp_capabilities_supports_text_chats (TpCapabilities *self);
gboolean tp_capabilities_supports_text_chatrooms (TpCapabilities *self);
+gboolean tp_capabilities_supports_audio_call (TpCapabilities *self);
+gboolean tp_capabilities_supports_audio_video_call (TpCapabilities *self);
+gboolean tp_capabilities_supports_file_transfer (TpCapabilities *self);
gboolean tp_capabilities_supports_stream_tubes (TpCapabilities *self,
TpHandleType handle_type,