aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-ui-utils.c
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-01-10 00:12:33 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2009-01-10 00:12:33 +0800
commit88cb102f7072be2748d9847e45e550be1c1bd399 (patch)
treedb80af5377cd510560e0045350b30f705b567fc7 /libempathy-gtk/empathy-ui-utils.c
parent1f41dbb4da057920c23d902797d020119b9b57c4 (diff)
downloadgsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar.gz
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar.bz2
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar.lz
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar.xz
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.tar.zst
gsoc2013-empathy-88cb102f7072be2748d9847e45e550be1c1bd399.zip
Use new API to request file transfers
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk> svn path=/trunk/; revision=2136
Diffstat (limited to 'libempathy-gtk/empathy-ui-utils.c')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c54
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);