aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-06-01 22:47:55 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-06-01 22:47:55 +0800
commit35a5ce7c4708114932b9e0274925f6a34efd2895 (patch)
treee7c3561fd20f14c5768136d10ecc5eedbc7a6eb0 /libempathy
parenta585fb5dc244a0c63f54e0bedca3b8403ffc54a6 (diff)
parentce67f6901ba26b589345a8cdea110878bf6861c6 (diff)
downloadgsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar.gz
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar.bz2
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar.lz
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar.xz
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.tar.zst
gsoc2013-empathy-35a5ce7c4708114932b9e0274925f6a34efd2895.zip
Merge commit 'ksz/can_stream_tube'
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-contact.c12
-rw-r--r--libempathy/empathy-contact.h2
-rw-r--r--libempathy/empathy-tp-contact-factory.c67
3 files changed, 55 insertions, 26 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index eac087e2e..a08c629ee 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -814,6 +814,18 @@ empathy_contact_can_send_files (EmpathyContact *contact)
return priv->capabilities & EMPATHY_CAPABILITIES_FT;
}
+gboolean
+empathy_contact_can_use_stream_tube (EmpathyContact *contact)
+{
+ EmpathyContactPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE);
+
+ priv = GET_PRIV (contact);
+
+ return priv->capabilities & EMPATHY_CAPABILITIES_STREAM_TUBE;
+}
+
static gchar *
contact_get_avatar_filename (EmpathyContact *contact,
const gchar *token)
diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h
index 0e6cfe251..ff8d426e2 100644
--- a/libempathy/empathy-contact.h
+++ b/libempathy/empathy-contact.h
@@ -63,6 +63,7 @@ typedef enum {
EMPATHY_CAPABILITIES_AUDIO = 1 << 0,
EMPATHY_CAPABILITIES_VIDEO = 1 << 1,
EMPATHY_CAPABILITIES_FT = 1 << 2,
+ EMPATHY_CAPABILITIES_STREAM_TUBE = 1 << 3,
EMPATHY_CAPABILITIES_UNKNOWN = 1 << 7
} EmpathyCapabilities;
@@ -98,6 +99,7 @@ gboolean empathy_contact_is_online (EmpathyContact *contact);
const gchar * empathy_contact_get_status (EmpathyContact *contact);
gboolean empathy_contact_can_voip (EmpathyContact *contact);
gboolean empathy_contact_can_send_files (EmpathyContact *contact);
+gboolean empathy_contact_can_use_stream_tube (EmpathyContact *contact);
guint empathy_contact_hash (gconstpointer key);
void empathy_contact_load_avatar_data (EmpathyContact *contact,
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index abef0c048..96fdfda68 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -51,6 +51,7 @@ typedef struct {
guint avatar_max_height;
guint avatar_max_size;
gboolean can_request_ft;
+ gboolean can_request_st;
} EmpathyTpContactFactoryPriv;
G_DEFINE_TYPE (EmpathyTpContactFactory, empathy_tp_contact_factory, G_TYPE_OBJECT);
@@ -618,6 +619,7 @@ get_requestable_channel_classes_cb (TpProxy *connection,
EmpathyTpContactFactoryPriv *priv = GET_PRIV (self);
GPtrArray *classes;
guint i;
+ GList *l;
if (error != NULL) {
DEBUG ("Error: %s", error->message);
@@ -629,39 +631,46 @@ get_requestable_channel_classes_cb (TpProxy *connection,
GValueArray *class_struct;
GHashTable *fixed_prop;
GValue *chan_type, *handle_type;
- GList *l;
class_struct = g_ptr_array_index (classes, i);
fixed_prop = g_value_get_boxed (g_value_array_get_nth (class_struct, 0));
- chan_type = g_hash_table_lookup (fixed_prop,
- TP_IFACE_CHANNEL ".ChannelType");
- if (chan_type == NULL ||
- tp_strdiff (g_value_get_string (chan_type),
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER)) {
- continue;
- }
-
handle_type = g_hash_table_lookup (fixed_prop,
TP_IFACE_CHANNEL ".TargetHandleType");
if (handle_type == NULL ||
- g_value_get_uint (handle_type) != TP_HANDLE_TYPE_CONTACT) {
+ g_value_get_uint (handle_type) != TP_HANDLE_TYPE_CONTACT)
continue;
- }
- /* We can request file transfer channel to contacts. */
- priv->can_request_ft = TRUE;
+ chan_type = g_hash_table_lookup (fixed_prop,
+ TP_IFACE_CHANNEL ".ChannelType");
+ if (chan_type == NULL)
+ continue;
- /* Update the capabilities of all contacts */
- for (l = priv->contacts; l != NULL; l = g_list_next (l)) {
- EmpathyContact *contact = l->data;
- EmpathyCapabilities caps;
+ if (!tp_strdiff (g_value_get_string (chan_type),
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
+ priv->can_request_ft = TRUE;
+ else if (!tp_strdiff (g_value_get_string (chan_type),
+ TP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
+ priv->can_request_st = TRUE;
+ }
- caps = empathy_contact_get_capabilities (contact);
- empathy_contact_set_capabilities (contact, caps |
- EMPATHY_CAPABILITIES_FT);
- }
- break;
+ if (!priv->can_request_ft && !priv->can_request_st)
+ return ;
+
+ /* Update the capabilities of all contacts */
+ for (l = priv->contacts; l != NULL; l = g_list_next (l)) {
+ EmpathyContact *contact = l->data;
+ EmpathyCapabilities caps;
+
+ caps = empathy_contact_get_capabilities (contact);
+
+ if (priv->can_request_ft)
+ caps |= EMPATHY_CAPABILITIES_FT;
+
+ if (priv->can_request_st)
+ caps |= EMPATHY_CAPABILITIES_STREAM_TUBE;
+
+ empathy_contact_set_capabilities (contact, caps);
}
}
@@ -706,6 +715,7 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
GHashTable *tokens;
GPtrArray *capabilities;
GError *error = NULL;
+ EmpathyCapabilities caps;
/* Keep a weak ref to that contact */
g_object_weak_ref (G_OBJECT (contact),
@@ -718,16 +728,20 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory,
g_object_ref (tp_factory),
g_object_unref);
+ caps = empathy_contact_get_capabilities (contact);
+
/* Set the FT capability */
if (priv->can_request_ft) {
- EmpathyCapabilities caps;
-
- caps = empathy_contact_get_capabilities (contact);
caps |= EMPATHY_CAPABILITIES_FT;
+ }
- empathy_contact_set_capabilities (contact, caps);
+ /* Set the Stream Tube capability */
+ if (priv->can_request_st) {
+ caps |= EMPATHY_CAPABILITIES_STREAM_TUBE;
}
+ empathy_contact_set_capabilities (contact, caps);
+
/* Set is-user property. Note that it could still be the handle is
* different from the connection's self handle, in the case the handle
* comes from a group interface. */
@@ -1391,6 +1405,7 @@ empathy_tp_contact_factory_init (EmpathyTpContactFactory *tp_factory)
tp_factory->priv = priv;
priv->can_request_ft = FALSE;
+ priv->can_request_st = FALSE;
}
static GHashTable *factories = NULL;