typedef struct {
TpChannel *channel;
- gboolean ready;
GInputStream *in_stream;
GOutputStream *out_stream;
EmpathyTpFileOperationCallback op_callback;
gpointer op_user_data;
+ gboolean is_closing;
gboolean is_closed;
gboolean dispose_run;
gpointer user_data)
{
EmpathyTpFile *tp_file;
+ EmpathyTpFilePriv *priv;
GError *error = NULL;
tp_file = user_data;
+ priv = GET_PRIV (tp_file);
g_output_stream_splice_finish (G_OUTPUT_STREAM (source), res, &error);
DEBUG ("Splice stream ready cb, error %p", error);
- if (error != NULL)
+ if (error != NULL && !priv->is_closing)
{
ft_operation_close_with_error (tp_file, error);
g_clear_error (&error);
in_stream = g_file_read_finish (G_FILE (source), res, &error);
- if (error != NULL)
+ if (error != NULL && !priv->is_closing)
{
ft_operation_close_with_error (tp_file, error);
g_clear_error (&error);
DEBUG ("Closing channel, should cancel %s", cancel ?
"True" : "False");
+ priv->is_closing = TRUE;
+
tp_cli_channel_call_close (priv->channel, -1,
channel_closed_cb, GINT_TO_POINTER (cancel), NULL, G_OBJECT (tp_file));
}
case PROP_CHANNEL:
priv->channel = g_object_ref (g_value_get_object (value));
break;
- case PROP_INCOMING:
- priv->incoming = g_value_get_boolean (value);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
g_signal_connect (priv->channel, "invalidated",
G_CALLBACK (tp_file_invalidated_cb), tp_file);
+ priv->incoming = !tp_channel_get_requested (priv->channel);
+
tp_cli_channel_type_file_transfer_connect_to_file_transfer_state_changed (
priv->channel, tp_file_state_changed_cb, NULL, NULL, object, NULL);
"direction of transfer",
"The direction of the file being transferred",
FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof (EmpathyTpFilePriv));
}
* @channel: a #TpChannel
* @incoming: whether the file transfer is incoming or not
*
- * Creates a new #EmpathyTpFile wrapping @channel, with the direction
- * specified by @incoming. The returned #EmpathyTpFile should be unrefed
+ * Creates a new #EmpathyTpFile wrapping @channel.
+ * The returned #EmpathyTpFile should be unrefed
* with g_object_unref() when finished with.
*
* Return value: a new #EmpathyTpFile
*/
EmpathyTpFile *
-empathy_tp_file_new (TpChannel *channel,
- gboolean incoming)
+empathy_tp_file_new (TpChannel *channel)
{
EmpathyTpFile *tp_file;
g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
tp_file = g_object_new (EMPATHY_TYPE_TP_FILE,
- "channel", channel, "incoming", incoming,
+ "channel", channel,
NULL);
return tp_file;