aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-05-15 20:50:17 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-06-01 23:53:17 +0800
commitca4022f7e479bf282db649c15860f41b1d281020 (patch)
tree8ac2e8d40f8f7e224eba6e6132cee99321f330e4
parent3d5e817ba6f8094d40471fb5c41c4edf3c2e573b (diff)
downloadgsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar.gz
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar.bz2
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar.lz
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar.xz
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.tar.zst
gsoc2013-empathy-ca4022f7e479bf282db649c15860f41b1d281020.zip
Wait for channel close before closing the socket
So that we can better handle cancellations of the transfer.
-rw-r--r--libempathy/empathy-tp-file.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 1ca6858ef..61cb22e66 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -136,10 +136,10 @@ tp_file_get_state_cb (TpProxy *proxy,
static void
tp_file_invalidated_cb (TpProxy *proxy,
- guint domain,
- gint code,
- gchar *message,
- EmpathyTpFile *tp_file)
+ guint domain,
+ gint code,
+ gchar *message,
+ EmpathyTpFile *tp_file)
{
EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
@@ -523,22 +523,32 @@ file_replace_async_cb (GObject *source,
}
static void
+channel_closed_cb (TpChannel *proxy,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ EmpathyTpFile *tp_file = EMPATHY_TP_FILE (weak_object);
+ EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
+ gboolean *cancel = user_data;
+
+ DEBUG ("Channel is closed");
+
+ if (priv->cancellable != NULL &&
+ !g_cancellable_is_cancelled (priv->cancellable) && *cancel)
+ g_cancellable_cancel (priv->cancellable);
+}
+
+static void
close_channel_internal (EmpathyTpFile *tp_file,
gboolean cancel)
{
- EmpathyTpFilePriv *priv;
-
- g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
-
- priv = GET_PRIV (tp_file);
+ EmpathyTpFilePriv *priv = GET_PRIV (tp_file);
DEBUG ("Closing channel..");
- tp_cli_channel_call_close (priv->channel, -1,
- NULL, NULL, NULL, NULL);
- if (priv->cancellable != NULL &&
- !g_cancellable_is_cancelled (priv->cancellable) && cancel)
- g_cancellable_cancel (priv->cancellable);
+ tp_cli_channel_call_close (priv->channel, -1,
+ channel_closed_cb, &cancel, NULL, G_OBJECT (tp_file));
}
/* GObject methods */