aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy/empathy-tp-file.c10
-rw-r--r--src/empathy-event-manager.c51
-rw-r--r--src/empathy-ft-manager.c10
-rw-r--r--src/empathy-ft-manager.h1
-rw-r--r--src/empathy-main-window.c4
5 files changed, 58 insertions, 18 deletions
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index 7fa4548c9..a2a999b81 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -812,5 +812,15 @@ empathy_tp_file_is_incoming (EmpathyTpFile *tp_file)
void
empathy_tp_file_cancel (EmpathyTpFile *tp_file)
{
+ g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
+
close_channel_internal (tp_file, TRUE);
}
+
+void
+empathy_tp_file_close (EmpathyTpFile *tp_file)
+{
+ g_return_if_fail (EMPATHY_IS_TP_FILE (tp_file));
+
+ close_channel_internal (tp_file, FALSE);
+}
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index bd31b193e..c8749bc46 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -752,6 +752,32 @@ event_manager_muc_invite_got_contact_cb (EmpathyTpContactFactory *factory,
}
static void
+event_manager_ft_got_contact_cb (EmpathyTpContactFactory *factory,
+ EmpathyContact *contact,
+ const GError *error,
+ gpointer user_data,
+ GObject *object)
+{
+ EventManagerApproval *approval = (EventManagerApproval *) user_data;
+ char *header;
+
+ approval->contact = contact;
+
+ header = g_strdup_printf (_("Incoming file transfer from %s"),
+ empathy_contact_get_name (approval->contact));
+
+ event_manager_add (approval->manager, approval->contact,
+ EMPATHY_IMAGE_DOCUMENT_SEND, header, NULL, approval,
+ event_channel_process_func, NULL);
+
+ /* FIXME better sound for incoming file transfers ?*/
+ empathy_sound_play (empathy_main_window_get (),
+ EMPATHY_SOUND_CONVERSATION_NEW);
+
+ g_free (header);
+}
+
+static void
event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
EmpathyDispatchOperation *operation, EmpathyEventManager *manager)
{
@@ -839,23 +865,18 @@ event_manager_approve_channel_cb (EmpathyDispatcher *dispatcher,
}
else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER))
{
- EmpathyTpFile *file;
- gchar *header;
-
- file = EMPATHY_TP_FILE (empathy_dispatch_operation_get_channel_wrapper (operation));
- approval->contact = g_object_ref (empathy_tp_file_get_contact (file));
-
- header = g_strdup_printf (_("Incoming file transfer from %s"),
- empathy_contact_get_name (approval->contact));
-
- event_manager_add (manager, approval->contact, EMPATHY_IMAGE_DOCUMENT_SEND,
- header, NULL, approval, event_channel_process_func, NULL);
+ TpChannel *channel;
+ TpConnection *connection;
+ TpHandle handle;
+ EmpathyTpContactFactory *factory;
- /* FIXME better sound for incoming file transfers ?*/
- empathy_sound_play (empathy_main_window_get (),
- EMPATHY_SOUND_CONVERSATION_NEW);
+ channel = empathy_dispatch_operation_get_channel (operation);
+ handle = tp_channel_get_handle (channel, NULL);
- g_free (header);
+ connection = tp_channel_borrow_connection (channel);
+ factory = empathy_tp_contact_factory_dup_singleton (connection);
+ empathy_tp_contact_factory_get_from_handle (factory, handle,
+ event_manager_ft_got_contact_cb, approval, NULL, G_OBJECT (manager));
}
else if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE) ||
!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE))
diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c
index 91c1ef0d8..40a1d7b6c 100644
--- a/src/empathy-ft-manager.c
+++ b/src/empathy-ft-manager.c
@@ -1084,3 +1084,13 @@ empathy_ft_manager_display_error (EmpathyFTManager *manager,
ft_manager_add_handler_to_list (manager, handler, error);
gtk_window_present (GTK_WINDOW (priv->window));
}
+
+void
+empathy_ft_manager_show (EmpathyFTManager *manager)
+{
+ EmpathyFTManagerPriv *priv = GET_PRIV (manager);
+
+ g_return_if_fail (EMPATHY_IS_FT_MANAGER (manager));
+
+ gtk_window_present (GTK_WINDOW (priv->window));
+}
diff --git a/src/empathy-ft-manager.h b/src/empathy-ft-manager.h
index 7a2fbcdc0..7200f3f08 100644
--- a/src/empathy-ft-manager.h
+++ b/src/empathy-ft-manager.h
@@ -66,6 +66,7 @@ void empathy_ft_manager_add_handler (EmpathyFTManager *ft_manager,
EmpathyFTHandler *handler);
void empathy_ft_manager_display_error (EmpathyFTManager *ft_manager,
EmpathyFTHandler *handler, const GError *error);
+void empathy_ft_manager_show (EmpathyFTManager *manager);
G_END_DECLS
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index e53807236..43e9224bb 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -696,12 +696,10 @@ main_window_view_show_ft_manager (GtkAction *action,
EmpathyMainWindow *window)
{
EmpathyFTManager *manager;
- GtkWidget *dialog;
manager = empathy_ft_manager_dup_singleton ();
- dialog = empathy_ft_manager_get_dialog (manager);
+ empathy_ft_manager_show (manager);
- gtk_window_present (GTK_WINDOW (dialog));
g_object_unref (manager);
}