aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-ft-handler.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2009-05-18 22:59:19 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-06-01 23:53:21 +0800
commit9e3494b16c494577ea54fb809f7dadba1ba482b4 (patch)
treed5e37992759612488be80c52eb9305961746adf3 /libempathy/empathy-ft-handler.c
parentf131fb616483531a97334890c56376fc0e2f4cf2 (diff)
downloadgsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar.gz
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar.bz2
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar.lz
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar.xz
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.tar.zst
gsoc2013-empathy-9e3494b16c494577ea54fb809f7dadba1ba482b4.zip
Use the new function in EmpathyFTHandler
Diffstat (limited to 'libempathy/empathy-ft-handler.c')
-rw-r--r--libempathy/empathy-ft-handler.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index beb57b1ed..bd789ff29 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -117,6 +117,8 @@ typedef struct {
GCancellable *cancellable;
gboolean use_hash;
+ EmpathyDispatcher *dispatcher;
+
/* request for the new transfer */
GHashTable *request;
@@ -236,6 +238,12 @@ do_dispose (GObject *object)
g_hash_table_unref (priv->request);
priv->request = NULL;
}
+
+ if (priv->dispatcher != NULL)
+ {
+ g_object_unref (priv->dispatcher);
+ priv->dispatcher = NULL;
+ }
G_OBJECT_CLASS (empathy_ft_handler_parent_class)->dispose (object);
}
@@ -442,6 +450,7 @@ empathy_ft_handler_init (EmpathyFTHandler *self)
self->priv = priv;
priv->cancellable = g_cancellable_new ();
+ priv->dispatcher = empathy_dispatcher_dup_singleton ();
}
/* private functions */
@@ -659,46 +668,16 @@ ft_handler_create_channel_cb (EmpathyDispatchOperation *operation,
static void
ft_handler_push_to_dispatcher (EmpathyFTHandler *handler)
{
- EmpathyDispatcher *dispatcher;
TpConnection *connection;
EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
DEBUG ("Pushing request to the dispatcher");
- dispatcher = empathy_dispatcher_dup_singleton ();
connection = empathy_contact_get_connection (priv->contact);
/* I want to own a reference to the request, and destroy it later */
- empathy_dispatcher_create_channel (dispatcher, connection,
+ empathy_dispatcher_create_channel (priv->dispatcher, connection,
g_hash_table_ref (priv->request), ft_handler_create_channel_cb, handler);
-
- g_object_unref (dispatcher);
-}
-
-static gboolean
-ft_handler_check_if_allowed (EmpathyFTHandler *handler)
-{
- EmpathyDispatcher *dispatcher;
- EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
- TpConnection *connection;
- GStrv allowed;
- gboolean res = TRUE;
-
- dispatcher = empathy_dispatcher_dup_singleton ();
- connection = empathy_contact_get_connection (priv->contact);
-
- allowed = empathy_dispatcher_find_channel_class (dispatcher, connection,
- TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT);
-
- if (!tp_strv_contains ((const gchar * const *) allowed,
- TP_IFACE_CHANNEL ".TargetHandle"))
- res = FALSE;
-
- DEBUG ("check if FT allowed: %s", res ? "True" : "False");
-
- g_object_unref (dispatcher);
-
- return res;
}
static void
@@ -954,13 +933,21 @@ ft_handler_read_async_cb (GObject *source,
}
static void
-ft_handler_complete_request (EmpathyFTHandler *handler)
-{
+find_channel_class_cb (GStrv channel_class,
+ gpointer user_data)
+{
+ EmpathyFTHandler *handler = user_data;
EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
+ gboolean allowed = TRUE;
GError *myerr = NULL;
- /* check if FT is allowed before firing up the I/O machinery */
- if (!ft_handler_check_if_allowed (handler))
+ if (!tp_strv_contains ((const gchar * const *) channel_class,
+ TP_IFACE_CHANNEL ".TargetHandle"))
+ allowed = FALSE;
+
+ DEBUG ("check if FT allowed: %s", allowed ? "True" : "False");
+
+ if (!allowed)
{
g_set_error_literal (&myerr, EMPATHY_FT_ERROR_QUARK,
EMPATHY_FT_ERROR_NOT_SUPPORTED,
@@ -985,6 +972,20 @@ ft_handler_complete_request (EmpathyFTHandler *handler)
}
static void
+ft_handler_complete_request (EmpathyFTHandler *handler)
+{
+ EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
+ TpConnection *connection;
+
+ /* check if FT is allowed before firing up the I/O machinery */
+ connection = empathy_contact_get_connection (priv->contact);
+
+ empathy_dispatcher_find_channel_class_async (priv->dispatcher, connection,
+ TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER, TP_HANDLE_TYPE_CONTACT,
+ find_channel_class_cb, handler);
+}
+
+static void
callbacks_data_free (gpointer user_data)
{
CallbacksData *data = user_data;