diff options
-rw-r--r-- | libempathy/empathy-tp-file.c | 50 | ||||
-rw-r--r-- | libempathy/empathy-tp-file.h | 4 | ||||
-rw-r--r-- | src/empathy-ft-manager.c | 13 |
3 files changed, 26 insertions, 41 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); diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c index 5ec319b81..2092aa10d 100644 --- a/src/empathy-ft-manager.c +++ b/src/empathy-ft-manager.c @@ -177,7 +177,7 @@ ft_manager_update_buttons (EmpathyFTManager *ft_manager) { gtk_tree_model_get (model, &iter, COL_FT_OBJECT, &tp_file, -1); - if (empathy_tp_file_get_state (tp_file) + if (empathy_tp_file_get_state (tp_file, NULL) == EMP_FILE_TRANSFER_STATE_COMPLETED) { if (empathy_tp_file_is_incoming (tp_file)) @@ -188,7 +188,7 @@ ft_manager_update_buttons (EmpathyFTManager *ft_manager) abort_enabled = FALSE; } - else if (empathy_tp_file_get_state (tp_file) == + else if (empathy_tp_file_get_state (tp_file, NULL) == EMP_FILE_TRANSFER_STATE_CANCELLED) { open_enabled = FALSE; @@ -254,8 +254,7 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager, contact_name = empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)); transferred_bytes = empathy_tp_file_get_transferred_bytes (tp_file); total_size = empathy_tp_file_get_size (tp_file); - state = empathy_tp_file_get_state (tp_file); - reason = empathy_tp_file_get_state_change_reason (tp_file); + state = empathy_tp_file_get_state (tp_file, &reason); incoming = empathy_tp_file_is_incoming (tp_file); switch (state) @@ -523,7 +522,7 @@ remove_finished_transfer_foreach (gpointer key, EmpathyFTManager *self = EMPATHY_FT_MANAGER (user_data); EmpFileTransferState state; - state = empathy_tp_file_get_state (tp_file); + state = empathy_tp_file_get_state (tp_file, NULL); if (state == EMP_FILE_TRANSFER_STATE_COMPLETED || state == EMP_FILE_TRANSFER_STATE_CANCELLED) { @@ -551,7 +550,7 @@ ft_manager_state_changed_cb (EmpathyTpFile *tp_file, { gboolean remove; - switch (empathy_tp_file_get_state (tp_file)) + switch (empathy_tp_file_get_state (tp_file, NULL)) { case EMP_FILE_TRANSFER_STATE_COMPLETED: if (empathy_tp_file_is_incoming (tp_file)) @@ -944,7 +943,7 @@ empathy_ft_manager_add_tp_file (EmpathyFTManager *ft_manager, empathy_contact_get_name (empathy_tp_file_get_contact (tp_file)), empathy_tp_file_get_filename (tp_file)); - state = empathy_tp_file_get_state (tp_file); + state = empathy_tp_file_get_state (tp_file, NULL); if (state == EMP_FILE_TRANSFER_STATE_PENDING && empathy_tp_file_is_incoming (tp_file)) |