aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy/empathy-ft-handler.c
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy/empathy-ft-handler.c')
-rw-r--r--libempathy/empathy-ft-handler.c88
1 files changed, 52 insertions, 36 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index 99b6dc85f..facc49a3b 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -30,7 +30,6 @@
#include "empathy-ft-handler.h"
#include "empathy-tp-contact-factory.h"
-#include "empathy-marshal.h"
#include "empathy-time.h"
#include "empathy-utils.h"
@@ -85,7 +84,8 @@ enum {
PROP_FILENAME,
PROP_MODIFICATION_TIME,
PROP_TOTAL_BYTES,
- PROP_TRANSFERRED_BYTES
+ PROP_TRANSFERRED_BYTES,
+ PROP_USER_ACTION_TIME
};
enum {
@@ -138,6 +138,8 @@ typedef struct {
gchar *content_hash;
TpFileHashType content_hash_type;
+ gint64 user_action_time;
+
/* time and speed */
gdouble speed;
guint remaining_time;
@@ -189,6 +191,9 @@ do_get_property (GObject *object,
case PROP_TP_FILE:
g_value_set_object (value, priv->tpfile);
break;
+ case PROP_USER_ACTION_TIME:
+ g_value_set_int64 (value, priv->user_action_time);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -231,6 +236,9 @@ do_set_property (GObject *object,
case PROP_TP_FILE:
priv->tpfile = g_value_dup_object (value);
break;
+ case PROP_USER_ACTION_TIME:
+ priv->user_action_time = g_value_get_int64 (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -412,6 +420,13 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_TP_FILE, param_spec);
+ param_spec = g_param_spec_int64 ("user-action-time", "user action time",
+ "User action time",
+ 0, G_MAXINT64, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (object_class, PROP_USER_ACTION_TIME,
+ param_spec);
+
/* signals */
/**
@@ -424,7 +439,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[TRANSFER_STARTED] =
g_signal_new ("transfer-started", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
1, EMPATHY_TYPE_TP_FILE);
@@ -439,7 +454,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[TRANSFER_DONE] =
g_signal_new ("transfer-done", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__OBJECT,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
1, EMPATHY_TYPE_TP_FILE);
@@ -457,7 +472,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[TRANSFER_ERROR] =
g_signal_new ("transfer-error", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
1, G_TYPE_POINTER);
@@ -476,7 +491,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[TRANSFER_PROGRESS] =
g_signal_new ("transfer-progress", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- _empathy_marshal_VOID__UINT64_UINT64_UINT_DOUBLE,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
4, G_TYPE_UINT64, G_TYPE_UINT64, G_TYPE_UINT, G_TYPE_DOUBLE);
@@ -494,7 +509,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[HASHING_STARTED] =
g_signal_new ("hashing-started", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_generic,
G_TYPE_NONE, 0);
/**
@@ -509,7 +524,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[HASHING_PROGRESS] =
g_signal_new ("hashing-progress", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- _empathy_marshal_VOID__UINT64_UINT64,
+ g_cclosure_marshal_generic,
G_TYPE_NONE,
2, G_TYPE_UINT64, G_TYPE_UINT64);
@@ -523,7 +538,7 @@ empathy_ft_handler_class_init (EmpathyFTHandlerClass *klass)
signals[HASHING_DONE] =
g_signal_new ("hashing-done", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_generic,
G_TYPE_NONE, 0);
}
@@ -709,7 +724,7 @@ ft_handler_create_channel_cb (GObject *source,
EmpathyFTHandler *handler = user_data;
EmpathyFTHandlerPriv *priv = GET_PRIV (handler);
GError *error = NULL;
- TpChannel *channel = NULL;
+ TpChannel *channel;
DEBUG ("Dispatcher create channel CB");
@@ -725,18 +740,16 @@ ft_handler_create_channel_cb (GObject *source,
{
emit_error_signal (handler, error);
+ g_clear_object (&channel);
g_error_free (error);
- goto out;
+ return;
}
- priv->tpfile = empathy_tp_file_new (channel);
+ priv->tpfile = EMPATHY_TP_FILE (channel);
empathy_tp_file_offer (priv->tpfile, priv->gfile, priv->cancellable,
ft_transfer_progress_callback, handler,
ft_transfer_operation_callback, handler);
-
-out:
- tp_clear_object (&channel);
}
static void
@@ -751,7 +764,7 @@ ft_handler_push_to_dispatcher (EmpathyFTHandler *handler)
account = empathy_contact_get_account (priv->contact);
req = tp_account_channel_request_new (account, priv->request,
- TP_USER_ACTION_TIME_NOT_USER_ACTION);
+ priv->user_action_time);
tp_account_channel_request_create_and_handle_channel_async (req, NULL,
ft_handler_create_channel_cb, handler);
@@ -1253,27 +1266,12 @@ channel_get_all_properties_cb (TpProxy *proxy,
return;
}
- priv->total_bytes = g_value_get_uint64 (
- g_hash_table_lookup (properties, "Size"));
-
- priv->transferred_bytes = g_value_get_uint64 (
- g_hash_table_lookup (properties, "TransferredBytes"));
-
- priv->filename = g_value_dup_string (
- g_hash_table_lookup (properties, "Filename"));
-
priv->content_hash = g_value_dup_string (
g_hash_table_lookup (properties, "ContentHash"));
priv->content_hash_type = g_value_get_uint (
g_hash_table_lookup (properties, "ContentHashType"));
- priv->content_type = g_value_dup_string (
- g_hash_table_lookup (properties, "ContentType"));
-
- priv->description = g_value_dup_string (
- g_hash_table_lookup (properties, "Description"));
-
c_handle = tp_channel_get_handle (TP_CHANNEL (proxy), NULL);
empathy_tp_contact_factory_get_from_handle (
tp_channel_borrow_connection (TP_CHANNEL (proxy)), c_handle,
@@ -1295,6 +1293,7 @@ channel_get_all_properties_cb (TpProxy *proxy,
void
empathy_ft_handler_new_outgoing (EmpathyContact *contact,
GFile *source,
+ gint64 action_time,
EmpathyFTHandlerReadyCallback callback,
gpointer user_data)
{
@@ -1308,7 +1307,10 @@ empathy_ft_handler_new_outgoing (EmpathyContact *contact,
g_return_if_fail (G_IS_FILE (source));
handler = g_object_new (EMPATHY_TYPE_FT_HANDLER,
- "contact", contact, "gfile", source, NULL);
+ "contact", contact,
+ "gfile", source,
+ "user-action-time", action_time,
+ NULL);
priv = GET_PRIV (handler);
@@ -1345,22 +1347,36 @@ empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file,
gpointer user_data)
{
EmpathyFTHandler *handler;
- TpChannel *channel;
CallbacksData *data;
+ TpFileTransferChannel *ft_chan = (TpFileTransferChannel *) tp_file;
+ EmpathyFTHandlerPriv *priv;
g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
handler = g_object_new (EMPATHY_TYPE_FT_HANDLER,
"tp-file", tp_file, NULL);
- g_object_get (tp_file, "channel", &channel, NULL);
+ priv = GET_PRIV (handler);
data = g_slice_new0 (CallbacksData);
data->callback = callback;
data->user_data = user_data;
data->handler = g_object_ref (handler);
- tp_cli_dbus_properties_call_get_all (channel,
+ priv->total_bytes = tp_file_transfer_channel_get_size (ft_chan);
+
+ priv->transferred_bytes = tp_file_transfer_channel_get_transferred_bytes (
+ ft_chan);
+
+ priv->filename = g_strdup (tp_file_transfer_channel_get_filename (ft_chan));
+
+ priv->content_type = g_strdup (tp_file_transfer_channel_get_mime_type (
+ ft_chan));
+
+ priv->description = g_strdup (tp_file_transfer_channel_get_description (
+ ft_chan));
+
+ tp_cli_dbus_properties_call_get_all (tp_file,
-1, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER,
channel_get_all_properties_cb, data, NULL, G_OBJECT (handler));
}
@@ -1574,7 +1590,7 @@ empathy_ft_handler_is_incoming (EmpathyFTHandler *handler)
if (priv->tpfile == NULL)
return FALSE;
- return empathy_tp_file_is_incoming (priv->tpfile);
+ return !tp_channel_get_requested ((TpChannel *) priv->tpfile);
}
/**