aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2008-11-22 00:15:47 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-11-22 00:15:47 +0800
commitee2f8cf1ead02aff7c0da47175868b4caa4d246b (patch)
tree725e8c050c7c4527dcb35660b9f011673f2b8a28
parent7611cc90a1147911f61e88827057232308fd2b86 (diff)
downloadgsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar.gz
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar.bz2
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar.lz
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar.xz
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.tar.zst
gsoc2013-empathy-ee2f8cf1ead02aff7c0da47175868b4caa4d246b.zip
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> svn path=/trunk/; revision=1768
-rw-r--r--configure.ac1
-rw-r--r--libempathy/empathy-utils.c62
2 files changed, 20 insertions, 43 deletions
diff --git a/configure.ac b/configure.ac
index f29596117..aa5234dab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,6 @@ PKG_CHECK_MODULES(LIBEMPATHY,
libmissioncontrol >= $MISSION_CONTROL_REQUIRED
gio-2.0 >= $GLIB_REQUIRED
gio-unix-2.0 >= $GLIB_REQUIRED
- gnome-vfs-2.0
])
PKG_CHECK_MODULES(EMPATHY,
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c
index c4f0d716e..e1c7244fd 100644
--- a/libempathy/empathy-utils.c
+++ b/libempathy/empathy-utils.c
@@ -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 @@ empathy_connection_request_channel (TpConnection *connection,
}
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 @@ empathy_send_file_from_stream (EmpathyContact *contact,
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 @@ empathy_send_file_from_stream (EmpathyContact *contact,
&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 @@ empathy_send_file_from_stream (EmpathyContact *contact,
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)
{