empathy r1768 - in trunk: . libempathy



Author: xclaesse
Date: Fri Nov 21 16:15:47 2008
New Revision: 1768
URL: http://svn.gnome.org/viewvc/empathy?rev=1768&view=rev

Log:
Merged empathy_send_file and empathy_send_file_from_stream, and dropped the dependency on gnome-vfs in favour of GIO. (Jonny Lamb)

Signed-off-by: Jonny Lamb <jonny lamb collabora co uk>

Modified:
   trunk/configure.ac
   trunk/libempathy/empathy-utils.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri Nov 21 16:15:47 2008
@@ -86,7 +86,6 @@
    libmissioncontrol >= $MISSION_CONTROL_REQUIRED
    gio-2.0 >= $GLIB_REQUIRED
    gio-unix-2.0 >= $GLIB_REQUIRED
-   gnome-vfs-2.0
 ])
 
 PKG_CHECK_MODULES(EMPATHY,

Modified: trunk/libempathy/empathy-utils.c
==============================================================================
--- trunk/libempathy/empathy-utils.c	(original)
+++ trunk/libempathy/empathy-utils.c	Fri Nov 21 16:15:47 2008
@@ -30,9 +30,9 @@
 #include <sys/types.h>
 #include <regex.h>
 
+#include <gio/gio.h>
 #include <glib/gi18n.h>
 
-#include <libgnomevfs/gnome-vfs.h>
 #include <libxml/uri.h>
 #include <telepathy-glib/connection.h>
 #include <telepathy-glib/channel.h>
@@ -778,11 +778,12 @@
 }
 
 EmpathyFile *
-empathy_send_file_from_stream (EmpathyContact *contact,
-			       GInputStream   *in_stream,
-			       const gchar    *filename,
-			       guint64         size)
+empathy_send_file (EmpathyContact *contact,
+		   GFile          *gfile)
 {
+	GFileInfo      *info;
+	guint64         size;
+	GInputStream   *in_stream = NULL;
 	MissionControl *mc;
 	McAccount      *account;
 	TpConnection   *connection;
@@ -792,20 +793,28 @@
 	EmpathyFile    *file;
 	GError         *error = NULL;
 	GValue          value = { 0 };
+	gchar          *filename;
 
 	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-	g_return_val_if_fail (G_IS_INPUT_STREAM (in_stream), NULL);
-	g_return_val_if_fail (filename != NULL, NULL);
-
-	DEBUG ("Sending %s from a stream to %s (size %llu)",
-	       filename, empathy_contact_get_name (contact), size);
+	g_return_val_if_fail (G_IS_FILE (gfile), NULL);
 
+	info = g_file_query_info (gfile,
+				  G_FILE_ATTRIBUTE_STANDARD_SIZE ","
+				  G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+				  0, NULL, NULL);
+	size = info ? g_file_info_get_size (info) : EMPATHY_FILE_UNKNOWN_SIZE;
+	filename = g_file_get_basename (gfile);
+	in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, NULL));
 	mc = empathy_mission_control_new ();
 	account = empathy_contact_get_account (contact);
 	connection = mission_control_get_tpconnection (mc, account, NULL);
 	tp_connection_run_until_ready (connection, FALSE, NULL, NULL);
 	handle = empathy_contact_get_handle (contact);
 
+	DEBUG ("Sending %s from a stream to %s (size %llu, content-type %s)",
+	       filename, empathy_contact_get_name (contact), size,
+	       g_file_info_get_content_type (info));
+
 	if (!tp_cli_connection_run_request_channel (connection, -1,
 						    EMP_IFACE_CHANNEL_TYPE_FILE,
 						    TP_HANDLE_TYPE_CONTACT,
@@ -844,7 +853,7 @@
 		&value, NULL, NULL);
 	g_value_reset (&value);
 
-	g_value_set_string (&value, gnome_vfs_get_mime_type_for_name (filename));
+	g_value_set_string (&value, g_file_info_get_content_type (info));
 	tp_cli_dbus_properties_run_set (TP_PROXY (channel),
 		-1, EMP_IFACE_CHANNEL_TYPE_FILE, "ContentType",
 		&value, NULL, NULL);
@@ -872,37 +881,6 @@
 	return file;
 }
 
-EmpathyFile *
-empathy_send_file (EmpathyContact *contact,
-		   GFile          *gfile)
-{
-	GFileInfo        *info;
-	guint64           size;
-	gchar            *filename;
-	GInputStream     *in_stream = NULL;
-	EmpathyFile      *file;
-
-	g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-	g_return_val_if_fail (G_IS_FILE (gfile), NULL);
-
-	filename = g_file_get_basename (gfile);
-	info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, NULL, NULL);
-	size = info ? g_file_info_get_size (info) : EMPATHY_FILE_UNKNOWN_SIZE;
-
-	DEBUG ("Sending %s to %s",
-	       filename, empathy_contact_get_name (contact));
-
-	in_stream = G_INPUT_STREAM (g_file_read (gfile, NULL, NULL));
-	file = empathy_send_file_from_stream (contact, in_stream, filename, size);
-
-	g_object_unref (in_stream);
-	g_free (filename);
-	if (info)
-		g_object_unref (info);
-
-	return file;
-}
-
 void
 empathy_init (void)
 {



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