aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy/empathy-dispatch-operation.c11
-rw-r--r--libempathy/empathy-tp-file.c25
-rw-r--r--libempathy/empathy-tp-file.h2
3 files changed, 24 insertions, 14 deletions
diff --git a/libempathy/empathy-dispatch-operation.c b/libempathy/empathy-dispatch-operation.c
index cfe111181..2a98b912a 100644
--- a/libempathy/empathy-dispatch-operation.c
+++ b/libempathy/empathy-dispatch-operation.c
@@ -461,15 +461,8 @@ empathy_dispatch_operation_channel_ready_cb (TpChannel *channel,
}
else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER)
{
- EmpathyTpFile *file = empathy_tp_file_new (channel);
- priv->channel_wrapper = G_OBJECT (file);
-
- if (!empathy_tp_file_is_ready (file))
- {
- priv->ready_handler = g_signal_connect (file, "notify::ready",
- G_CALLBACK (empathy_dispatcher_operation_tp_file_ready_cb), self);
- return;
- }
+ EmpathyTpFile *file = empathy_tp_file_new (channel, priv->incoming);
+ priv->channel_wrapper = G_OBJECT (file);
}
ready:
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index e1db280b8..0b12d0223 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -106,6 +106,7 @@ typedef struct {
enum {
PROP_0,
PROP_CHANNEL,
+ PROP_INCOMING,
PROP_STATE
};
@@ -379,6 +380,9 @@ ft_operation_provide_or_accept_file_cb (TpChannel *proxy,
DEBUG ("Got unix socket path: %s", priv->unix_socket_path->data);
+ /* if the channel is already open, start the transfer now, otherwise,
+ * wait for the state change signal.
+ */
if (priv->state == EMP_FILE_TRANSFER_STATE_OPEN)
tp_file_start_transfer (tp_file);
}
@@ -516,6 +520,9 @@ do_get_property (GObject *object,
case PROP_CHANNEL:
g_value_set_object (value, priv->channel);
break;
+ case PROP_INCOMING:
+ g_value_set_boolean (value, priv->incoming);
+ break;
case PROP_STATE:
g_value_set_uint (value, priv->state);
break;
@@ -537,6 +544,9 @@ do_set_property (GObject *object,
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;
case PROP_STATE:
priv->state = g_value_get_uint (value);
break;
@@ -604,6 +614,15 @@ empathy_tp_file_class_init (EmpathyTpFileClass *klass)
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_INCOMING,
+ g_param_spec_boolean ("incoming",
+ "direction of transfer",
+ "The direction of the file being transferred",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (object_class,
PROP_STATE,
g_param_spec_uint ("state",
"state of the transfer",
@@ -630,14 +649,14 @@ empathy_tp_file_class_init (EmpathyTpFileClass *klass)
* Return value: a new #EmpathyTpFile
*/
EmpathyTpFile *
-empathy_tp_file_new (TpChannel *channel)
+empathy_tp_file_new (TpChannel *channel, gboolean incoming)
{
EmpathyTpFile *tp_file;
g_return_val_if_fail (TP_IS_CHANNEL (channel), NULL);
tp_file = g_object_new (EMPATHY_TYPE_TP_FILE,
- "channel", channel,
+ "channel", channel, "incoming", incoming,
NULL);
return tp_file;
@@ -664,7 +683,6 @@ empathy_tp_file_accept (EmpathyTpFile *tp_file,
priv->progress_user_data = progress_user_data;
priv->op_callback = op_callback;
priv->op_user_data = op_user_data;
- priv->incoming = TRUE;
priv->offset = offset;
g_file_replace_async (gfile, NULL, FALSE, G_FILE_CREATE_NONE,
@@ -691,7 +709,6 @@ empathy_tp_file_offer (EmpathyTpFile *tp_file,
priv->progress_user_data = progress_user_data;
priv->op_callback = op_callback;
priv->op_user_data = op_user_data;
- priv->incoming = FALSE;
g_file_read_async (gfile, G_PRIORITY_DEFAULT, cancellable,
file_read_async_cb, tp_file);
diff --git a/libempathy/empathy-tp-file.h b/libempathy/empathy-tp-file.h
index 3e9563776..db928e86f 100644
--- a/libempathy/empathy-tp-file.h
+++ b/libempathy/empathy-tp-file.h
@@ -71,7 +71,7 @@ GType empathy_tp_file_get_type (void) G_GNUC_CONST;
/* public methods */
-EmpathyTpFile * empathy_tp_file_new (TpChannel *channel);
+EmpathyTpFile * empathy_tp_file_new (TpChannel *channel, gboolean incoming);
void empathy_tp_file_accept (EmpathyTpFile *tp_file,
guint64 offset,