aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-11-22 00:23:21 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-11-22 00:23:21 +0800
commit9556d5dee269424664b0863a372e926b1172e049 (patch)
treec61c6ee8c12aaa3a9696d2a4370c0eb9744c8805 /libempathy
parente7d0410043afbe679e5f530a09e7513002faba50 (diff)
downloadgsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar.gz
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar.bz2
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar.lz
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar.xz
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.tar.zst
gsoc2013-empathy-9556d5dee269424664b0863a372e926b1172e049.zip
When the channel is invalidated, change state to CANCELLED.
svn path=/trunk/; revision=1885
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-tp-file.c50
-rw-r--r--libempathy/empathy-tp-file.h4
2 files changed, 20 insertions, 34 deletions
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 84246c457..06540f8eb 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -327,13 +327,17 @@ empathy_tp_file_init (EmpathyTpFile *tp_file)
}
static void
-tp_file_destroy_cb (TpChannel *file_channel,
- EmpathyTpFile *tp_file)
+tp_file_invalidated_cb (TpProxy *proxy,
+ guint domain,
+ gint code,
+ gchar *message,
+ EmpathyTpFile *tp_file)
{
- DEBUG ("Channel Closed or CM crashed");
-
- g_object_unref (tp_file->priv->channel);
- tp_file->priv->channel = NULL;
+ DEBUG ("Channel invalidated: %s", message);
+ tp_file->priv->state = EMP_FILE_TRANSFER_STATE_CANCELLED;
+ tp_file->priv->state_change_reason =
+ EMP_FILE_TRANSFER_STATE_CHANGE_REASON_LOCAL_ERROR;
+ g_object_notify (G_OBJECT (tp_file), "state");
}
static void
@@ -347,7 +351,7 @@ tp_file_finalize (GObject *object)
{
DEBUG ("Closing channel..");
g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
- tp_file_destroy_cb, object);
+ tp_file_invalidated_cb, object);
tp_cli_channel_call_close (tp_file->priv->channel, -1, NULL, NULL,
NULL, NULL);
g_object_unref (tp_file->priv->channel);
@@ -384,18 +388,6 @@ tp_file_finalize (GObject *object)
G_OBJECT_CLASS (empathy_tp_file_parent_class)->finalize (object);
}
-static void
-tp_file_closed_cb (TpChannel *file_channel,
- EmpathyTpFile *tp_file,
- GObject *weak_object)
-{
- /* The channel is closed, do just like if the proxy was destroyed */
- g_signal_handlers_disconnect_by_func (tp_file->priv->channel,
- tp_file_destroy_cb,
- tp_file);
- tp_file_destroy_cb (file_channel, tp_file);
-}
-
static gint
_get_local_socket (EmpathyTpFile *tp_file)
{
@@ -539,10 +531,8 @@ tp_file_constructor (GType type,
tp_file->priv->factory = empathy_contact_factory_new ();
tp_file->priv->mc = empathy_mission_control_new ();
- tp_cli_channel_connect_to_closed (tp_file->priv->channel,
- (tp_cli_channel_signal_callback_closed) tp_file_closed_cb,
- tp_file,
- NULL, NULL, NULL);
+ g_signal_connect (tp_file->priv->channel, "invalidated",
+ G_CALLBACK (tp_file_invalidated_cb), tp_file);
emp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
TP_PROXY (tp_file->priv->channel),
@@ -875,20 +865,16 @@ empathy_tp_file_is_incoming (EmpathyTpFile *tp_file)
}
EmpFileTransferState
-empathy_tp_file_get_state (EmpathyTpFile *tp_file)
+empathy_tp_file_get_state (EmpathyTpFile *tp_file,
+ EmpFileTransferStateChangeReason *reason)
{
g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
EMP_FILE_TRANSFER_STATE_NONE);
- return tp_file->priv->state;
-}
-EmpFileTransferStateChangeReason
-empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file)
-{
- g_return_val_if_fail (EMPATHY_IS_TP_FILE (tp_file),
- EMP_FILE_TRANSFER_STATE_CHANGE_REASON_NONE);
+ if (reason != NULL)
+ *reason = tp_file->priv->state_change_reason;
- return tp_file->priv->state_change_reason;
+ return tp_file->priv->state;
}
guint64
diff --git a/libempathy/empathy-tp-file.h b/libempathy/empathy-tp-file.h
index 3243451e0..34cbb7ff2 100644
--- a/libempathy/empathy-tp-file.h
+++ b/libempathy/empathy-tp-file.h
@@ -78,8 +78,8 @@ guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
EmpathyContact *empathy_tp_file_get_contact (EmpathyTpFile *tp_file);
const gchar *empathy_tp_file_get_filename (EmpathyTpFile *tp_file);
gboolean empathy_tp_file_is_incoming (EmpathyTpFile *tp_file);
-EmpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file);
-EmpFileTransferStateChangeReason empathy_tp_file_get_state_change_reason (EmpathyTpFile *tp_file);
+EmpFileTransferState empathy_tp_file_get_state (EmpathyTpFile *tp_file,
+ EmpFileTransferStateChangeReason *reason);
guint64 empathy_tp_file_get_size (EmpathyTpFile *tp_file);
guint64 empathy_tp_file_get_transferred_bytes (EmpathyTpFile *tp_file);
gint empathy_tp_file_get_remaining_time (EmpathyTpFile *tp_file);