static void ft_transfer_state_cb (TpFileTransferChannel *channel, GParamSpec *pspec, EmpathyFTHandler *handler) { EmpathyFTHandlerPriv *priv = handler->priv; TpFileTransferStateChangeReason reason; TpFileTransferState state = tp_file_transfer_channel_get_state ( channel, &reason); (void)pspec; /* suppress unused-parameter warning */ if (state == TP_FILE_TRANSFER_STATE_COMPLETED) { priv->is_completed = TRUE; g_signal_emit (handler, signals[TRANSFER_DONE], 0, channel); tp_channel_close_async (TP_CHANNEL (channel), NULL, NULL); if (empathy_ft_handler_is_incoming (handler) && priv->use_hash) { check_hash_incoming (handler); } } else if (state == TP_FILE_TRANSFER_STATE_CANCELLED) { GError *error = error_from_state_change_reason (reason); emit_error_signal (handler, error); g_clear_error (&error); } }
static void tp_file_state_changed_cb (TpChannel *proxy, guint state, guint reason, gpointer user_data, GObject *weak_object) { EmpathyTpFile *self = (EmpathyTpFile *) weak_object; GError *error = NULL; if (state == self->priv->state) return; DEBUG ("File transfer state changed:\n" "old state = %u, state = %u, reason = %u\n" "\tincoming = %s, in_stream = %s, out_stream = %s", self->priv->state, state, reason, self->priv->incoming ? "yes" : "no", self->priv->in_stream ? "present" : "not present", self->priv->out_stream ? "present" : "not present"); self->priv->state = state; self->priv->state_change_reason = reason; /* If the channel is open AND we have the socket path, we can start the * transfer. The socket path could be NULL if we are not doing the actual * data transfer but are just an observer for the channel. */ if (state == TP_FILE_TRANSFER_STATE_OPEN && self->priv->socket_address != NULL) tp_file_start_transfer (EMPATHY_TP_FILE (weak_object)); if (state == TP_FILE_TRANSFER_STATE_COMPLETED) ft_operation_close_clean (EMPATHY_TP_FILE (weak_object)); if (state == TP_FILE_TRANSFER_STATE_CANCELLED) { error = error_from_state_change_reason (self->priv->state_change_reason); ft_operation_close_with_error (EMPATHY_TP_FILE (weak_object), error); g_clear_error (&error); } }