aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-10-19 20:42:41 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-10-20 15:09:00 +0800
commita360151f84ffc367ce9d749eacca3cde155649db (patch)
tree44547d38406f0e01abd1f580ba6bcaf3bf1d4f47 /libempathy
parentcb265f95cc5ca492f8808be0ab81d70e8e77d843 (diff)
downloadgsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar.gz
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar.bz2
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar.lz
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar.xz
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.tar.zst
gsoc2013-empathy-a360151f84ffc367ce9d749eacca3cde155649db.zip
empathy-ft-handler: re-implement empathy_dispatcher_find_requestable_channel_classes_async using TpCapabilities
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-ft-handler.c56
1 files changed, 50 insertions, 6 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index f18278a71..5bef8070c 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -1096,13 +1096,52 @@ out:
}
static void
-find_ft_channel_classes_cb (GList *channel_classes,
+conn_prepared_cb (GObject *conn,
+ GAsyncResult *result,
gpointer user_data)
{
CallbacksData *data = user_data;
EmpathyFTHandler *handler = data->handler;
EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
GError *myerr = NULL;
+ TpCapabilities *caps;
+ GPtrArray *classes;
+ guint i;
+ GList *channel_classes = NULL;
+
+ if (!tp_proxy_prepare_finish (conn, result, &myerr))
+ {
+ DEBUG ("Failed to prepare connection: %s", myerr->message);
+
+ data->callback (handler, myerr, data->user_data);
+ goto out;
+ }
+
+ caps = tp_connection_get_capabilities (TP_CONNECTION (conn));
+ classes = tp_capabilities_get_channel_classes (caps);
+
+ for (i = 0; i < classes->len; i++)
+ {
+ GValueArray *val;
+ GHashTable *fixed;
+ GStrv allowed;
+ const gchar *chan_type;
+
+ val = g_ptr_array_index (classes, i);
+
+ tp_value_array_unpack (val, 2, &fixed, &allowed);
+
+ chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+
+ if (tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
+ continue;
+
+ if (tp_asv_get_uint32 (fixed, TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL) !=
+ TP_HANDLE_TYPE_CONTACT)
+ continue;
+
+ channel_classes = g_list_prepend (channel_classes, val);
+ }
if (channel_classes == NULL)
{
@@ -1125,6 +1164,8 @@ find_ft_channel_classes_cb (GList *channel_classes,
data->callback (handler, NULL, data->user_data);
}
+out:
+ g_list_free (channel_classes);
callbacks_data_free (data);
}
@@ -1202,11 +1243,14 @@ out:
else
{
/* see if FT/hashing are allowed */
- empathy_dispatcher_find_requestable_channel_classes_async
- (priv->dispatcher, empathy_contact_get_connection (priv->contact),
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT,
- find_ft_channel_classes_cb, cb_data,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER ".ContentHashType", NULL);
+ TpConnection *connection;
+ GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 };
+
+ connection = empathy_contact_get_connection (priv->contact);
+ g_assert (connection != NULL);
+
+ tp_proxy_prepare_async (connection, features,
+ conn_prepared_cb, cb_data);
}
}