empathy r2136 - trunk/libempathy-gtk



Author: xclaesse
Date: Fri Jan  9 16:12:33 2009
New Revision: 2136
URL: http://svn.gnome.org/viewvc/empathy?rev=2136&view=rev

Log:
Use new API to request file transfers

Signed-off-by: Sjoerd Simons <sjoerd simons collabora co uk>

Modified:
   trunk/libempathy-gtk/empathy-ui-utils.c

Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c	(original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c	Fri Jan  9 16:12:33 2009
@@ -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 @@
 /* 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 @@
 		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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]