aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy/empathy-ft-handler.c19
-rw-r--r--libempathy/empathy-ft-handler.h4
-rw-r--r--src/empathy-ft-manager.c27
3 files changed, 21 insertions, 29 deletions
diff --git a/libempathy/empathy-ft-handler.c b/libempathy/empathy-ft-handler.c
index 89fc13399..93232b187 100644
--- a/libempathy/empathy-ft-handler.c
+++ b/libempathy/empathy-ft-handler.c
@@ -912,15 +912,14 @@ empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file,
}
void
-empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
- GCancellable *cancellable)
+empathy_ft_handler_start_transfer (EmpathyFTHandler *handler)
{
EmpathyFTHandlerPriv *priv;
g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
priv = GET_PRIV (handler);
- priv->cancellable = g_object_ref (cancellable);
+ priv->cancellable = g_cancellable_new ();
if (priv->tpfile == NULL)
{
@@ -941,6 +940,20 @@ empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
}
void
+empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler)
+{
+ EmpathyFTHandlerPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_FT_HANDLER (handler));
+
+ priv = GET_PRIV (handler);
+
+ g_return_if_fail (priv->tpfile != NULL);
+
+ empathy_tp_file_cancel (priv->tpfile);
+}
+
+void
empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler,
GFile *destination)
{
diff --git a/libempathy/empathy-ft-handler.h b/libempathy/empathy-ft-handler.h
index 221f4e5b5..085abab52 100644
--- a/libempathy/empathy-ft-handler.h
+++ b/libempathy/empathy-ft-handler.h
@@ -69,8 +69,8 @@ void empathy_ft_handler_new_incoming (EmpathyTpFile *tp_file,
void empathy_ft_handler_incoming_set_destination (EmpathyFTHandler *handler,
GFile *destination);
-void empathy_ft_handler_start_transfer (EmpathyFTHandler *handler,
- GCancellable *cancellable);
+void empathy_ft_handler_start_transfer (EmpathyFTHandler *handler);
+void empathy_ft_handler_cancel_transfer (EmpathyFTHandler *handler);
/* properties of the transfer */
const char * empathy_ft_handler_get_filename (EmpathyFTHandler *handler);
diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c
index 671a3a4a2..6048cac70 100644
--- a/src/empathy-ft-manager.c
+++ b/src/empathy-ft-manager.c
@@ -76,7 +76,6 @@ enum
typedef struct {
GtkTreeModel *model;
GHashTable *ft_handler_to_row_ref;
- GHashTable *cancellable_refs;
/* Widgets */
GtkWidget *window;
@@ -238,7 +237,6 @@ ft_manager_remove_file_from_model (EmpathyFTManager *manager,
GtkTreePath *path = NULL;
GtkTreeIter iter;
gboolean update_selection;
- GCancellable *cancellable;
EmpathyFTManagerPriv *priv = GET_PRIV (manager);
row_ref = ft_manager_get_row_from_handler (manager, handler);
@@ -272,12 +270,6 @@ ft_manager_remove_file_from_model (EmpathyFTManager *manager,
if (update_selection)
gtk_tree_selection_select_iter (selection, &iter);
-
- cancellable = g_hash_table_lookup (priv->cancellable_refs, handler);
-
- if (cancellable != NULL) {
- g_cancellable_cancel (cancellable);
- }
}
static gboolean
@@ -409,7 +401,6 @@ ft_handler_transfer_done_cb (EmpathyFTHandler *handler,
char *first_line, *second_line, *message;
gboolean incoming;
GtkTreeRowReference *row_ref;
- EmpathyFTManagerPriv *priv = GET_PRIV (manager);
DEBUG ("Transfer done");
@@ -437,9 +428,6 @@ ft_handler_transfer_done_cb (EmpathyFTHandler *handler,
message = g_strdup_printf ("%s\n%s", first_line, second_line);
ft_manager_update_handler_message (manager, row_ref, message);
- /* remove the cancellable object */
- g_hash_table_remove (priv->cancellable_refs, handler);
-
/* update buttons */
ft_manager_update_buttons (manager);
@@ -578,16 +566,11 @@ static void
ft_manager_start_transfer (EmpathyFTManager *manager,
EmpathyFTHandler *handler)
{
- GCancellable *cancellable;
EmpathyFTManagerPriv *priv;
gboolean is_incoming;
priv = GET_PRIV (manager);
- cancellable = g_cancellable_new ();
- g_hash_table_insert (priv->cancellable_refs, g_object_ref (handler),
- cancellable);
-
is_incoming = empathy_ft_handler_is_incoming (handler);
DEBUG ("Start transfer, is incoming %d", is_incoming);
@@ -604,7 +587,7 @@ ft_manager_start_transfer (EmpathyFTManager *manager,
G_CALLBACK (ft_handler_hashing_started_cb), manager);
}
- empathy_ft_handler_start_transfer (handler, cancellable);
+ empathy_ft_handler_start_transfer (handler);
}
static void
@@ -706,7 +689,6 @@ ft_manager_stop (EmpathyFTManager *manager)
GtkTreeIter iter;
GtkTreeModel *model;
EmpathyFTHandler *handler;
- GCancellable *cancellable;
EmpathyFTManagerPriv *priv;
priv = GET_PRIV (manager);
@@ -723,10 +705,9 @@ ft_manager_stop (EmpathyFTManager *manager)
empathy_contact_get_name (empathy_ft_handler_get_contact (handler)),
empathy_ft_handler_get_filename (handler));
- cancellable = g_hash_table_lookup (priv->cancellable_refs, handler);
- g_assert (cancellable != NULL);
+ empathy_ft_handler_cancel_transfer (handler);
- g_cancellable_cancel (cancellable);
+ g_object_unref (handler);
}
static gboolean
@@ -953,8 +934,6 @@ empathy_ft_manager_init (EmpathyFTManager *manager)
priv->ft_handler_to_row_ref = g_hash_table_new_full (g_direct_hash,
g_direct_equal, (GDestroyNotify) g_object_unref,
(GDestroyNotify) gtk_tree_row_reference_free);
- priv->cancellable_refs = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- (GDestroyNotify) g_object_unref, (GDestroyNotify) g_object_unref);
ft_manager_build_ui (manager);
}