diff options
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 103 |
1 files changed, 14 insertions, 89 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 23b382d30..c61ad0dac 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -50,9 +50,7 @@ #include <libempathy/empathy-utils.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-idle.h> -#include <libempathy/empathy-tp-file.h> #include <libempathy/empathy-ft-factory.h> -#include <libempathy/empathy-ft-handler.h> #define SCHEMES "(https?|s?ftps?|nntp|news|javascript|about|ghelp|apt|telnet|"\ "file|webcal|mailto)" @@ -1404,102 +1402,29 @@ empathy_toggle_button_set_state_quietly (GtkWidget *widget, g_signal_handlers_unblock_by_func (widget, callback, user_data); } -/* Sending files with the file chooser */ -#if 0 -static void -file_manager_send_file_request_cb (EmpathyDispatchOperation *operation, - const GError *error, gpointer user_data) -{ - GFile *file = (GFile *) user_data; - EmpathyTpFile *tp_file; - - if (error != NULL) { - DEBUG ("Couldn't request channel: %s", error->message); - g_object_unref (file); - return; - } - - DEBUG ("Starting to send file"); - - tp_file = EMPATHY_TP_FILE ( - empathy_dispatch_operation_get_channel_wrapper (operation)); - - empathy_tp_file_offer (tp_file, file, NULL); - - g_object_unref (file); -} -#endif - -static void -new_ft_handler_cb (EmpathyFTFactory *factory, - EmpathyFTHandler *handler, - gboolean direction, - gpointer user_data) -{ - empathy_ft_handler_start_transfer (handler, g_cancellable_new ()); -} - static void file_manager_send_file_response_cb (GtkDialog *widget, gint response_id, EmpathyContact *contact) { EmpathyFTFactory *factory; + GFile *file; + gchar *uri; + GtkRecentManager *manager; if (response_id == GTK_RESPONSE_OK) { - GSList *list; - GSList *l; - - list = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (widget)); - - DEBUG ("File chooser selected files:"); - - for (l = list; l; l = l->next) { - gchar *uri; - GFile *gfile; - GFileInfo *info; - GtkRecentManager *manager; - gchar *filename; - GTimeVal mtime; - GError *error = NULL; - - uri = l->data; - gfile = g_file_new_for_uri (uri); - info = g_file_query_info (gfile, - G_FILE_ATTRIBUTE_STANDARD_SIZE "," - G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," - G_FILE_ATTRIBUTE_TIME_MODIFIED, - 0, NULL, &error); - - if (error) { - DEBUG ("Can't get info about the file: %s", error->message); - g_clear_error (&error); - g_object_unref (gfile); - continue; - } + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (widget)); + uri = g_file_get_uri (file); - DEBUG ("\t%s", uri); - filename = g_file_get_basename (gfile); - g_file_info_get_modification_time (info, &mtime); -#if 0 - empathy_dispatcher_send_file_to_contact (contact, - filename, g_file_info_get_size (info), mtime.tv_sec, - g_file_info_get_content_type (info), - file_manager_send_file_request_cb, gfile); -#endif - factory = empathy_ft_factory_dup_singleton (); - g_signal_connect (factory, "new-ft-handler", - G_CALLBACK (new_ft_handler_cb), NULL); - empathy_ft_factory_new_transfer (factory, contact, gfile); - g_free (filename); - g_object_unref (info); - - manager = gtk_recent_manager_get_default (); - gtk_recent_manager_add_item (manager, uri); - - g_free (uri); - } - g_slist_free (list); + factory = empathy_ft_factory_dup_singleton (); + + empathy_ft_factory_new_transfer (factory, contact, file); + + manager = gtk_recent_manager_get_default (); + gtk_recent_manager_add_item (manager, uri); + + g_free (uri); + g_object_unref (factory); } gtk_widget_destroy (GTK_WIDGET (widget)); |