From 58d08cef143811d990218551a922451609978610 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 18 Feb 2009 16:41:12 +0100 Subject: Rethink a bit the logic for an incoming transfer. Now, a client should have to do the following, in order to receive a file transfer: - let the EmpathyFTFactory claim the EmpathyDispatchOperation - the factory will emit "new-incoming-transfer" when the handler is filled with the relevant properties - now you can choose a destination file, and then you should call _set_destination on EmpathyFTFactory passing the handler. - the factory will emit "new-ft-handler" as you're now ready to start the actual transfer. --- libempathy-gtk/empathy-ui-utils.c | 46 ++++++++++++++++++++++++++++++++++++++- libempathy-gtk/empathy-ui-utils.h | 3 ++- 2 files changed, 47 insertions(+), 2 deletions(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index c61ad0dac..c33abb63d 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -1418,13 +1418,14 @@ file_manager_send_file_response_cb (GtkDialog *widget, factory = empathy_ft_factory_dup_singleton (); - empathy_ft_factory_new_transfer (factory, contact, file); + empathy_ft_factory_new_transfer_outgoing (factory, contact, file); manager = gtk_recent_manager_get_default (); gtk_recent_manager_add_item (manager, uri); g_free (uri); g_object_unref (factory); + g_object_unref (file); } gtk_widget_destroy (GTK_WIDGET (widget)); @@ -1466,6 +1467,49 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact) gtk_widget_show (widget); } +static void +file_manager_receive_file_response_cb (GtkDialog *dialog, + GtkResponseType response, + EmpathyFTHandler *handler) +{ + EmpathyFTFactory *factory; + GFile *file; + + if (response == GTK_RESPONSE_OK) { + factory = empathy_ft_factory_dup_singleton (); + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)); + + empathy_ft_factory_set_destination_for_incoming_handler + (factory, handler, file); + + g_object_unref (factory); + g_object_unref (file); + } + + gtk_widget_destroy (GTK_WIDGET (dialog)); +} + +void +empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler) +{ + GtkWidget *widget; + + widget = gtk_file_chooser_dialog_new (_("Select a destination"), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, + GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (widget), + empathy_ft_handler_get_filename (handler)); + g_signal_connect (widget, "response", + G_CALLBACK (file_manager_receive_file_response_cb), handler); + + gtk_widget_show (widget); +} + typedef struct { EmpathySound sound_id; const char * event_ca_id; diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 0b5b17f28..4d58fedcf 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -39,8 +39,8 @@ #include #include - #include +#include #include "empathy-chat-view.h" @@ -124,6 +124,7 @@ GtkWidget * empathy_link_button_new (const gchar *url, const gchar *title); void empathy_send_file_with_file_chooser (EmpathyContact *contact); +void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler); /* Sounds */ void empathy_sound_play (GtkWidget *widget, -- cgit v1.2.3