diff options
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index bd85c0522..10c32bcb7 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -51,6 +51,7 @@ #include <libempathy/empathy-utils.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-idle.h> +#include <libempathy/empathy-tp-file.h> void empathy_gtk_init (void) @@ -1422,6 +1423,31 @@ empathy_toggle_button_set_state_quietly (GtkWidget *widget, /* Sending files with the file chooser */ 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); + g_object_unref (tp_file); +} + +static void file_manager_send_file_response_cb (GtkDialog *widget, gint response_id, EmpathyContact *contact) @@ -1437,18 +1463,42 @@ file_manager_send_file_response_cb (GtkDialog *widget, 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; + } DEBUG ("\t%s", uri); - empathy_dispatcher_send_file (contact, gfile); + filename = g_file_get_basename (gfile); + g_file_info_get_modification_time (info, &mtime); + + 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); + + g_free (filename); + g_object_unref (info); manager = gtk_recent_manager_get_default (); gtk_recent_manager_add_item (manager, uri); - g_object_unref (gfile); g_free (uri); } g_slist_free (list); |