diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2008-11-22 00:16:10 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-11-22 00:16:10 +0800 |
commit | 82f32e4f34fbaebb5cf44e494aafb9a8f601c495 (patch) | |
tree | ab6b308cf86abfc999073f9f82f698859c87fa83 /libempathy | |
parent | 2aa329dcb7773bef4ee2b593147b48a83b7658f8 (diff) | |
download | gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar.gz gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar.bz2 gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar.lz gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar.xz gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.tar.zst gsoc2013-empathy-82f32e4f34fbaebb5cf44e494aafb9a8f601c495.zip |
Added ability to get an md5sum of the file being sent using GChecksum. (Jonny Lamb)
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
svn path=/trunk/; revision=1774
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-utils.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/libempathy/empathy-utils.c b/libempathy/empathy-utils.c index c0cba4d73..b62c834fa 100644 --- a/libempathy/empathy-utils.c +++ b/libempathy/empathy-utils.c @@ -795,6 +795,11 @@ empathy_send_file (EmpathyContact *contact, GValue value = { 0 }; gchar *filename; + /* for getting ContentMD5 */ + gsize checksum_length; + gchar *checksum_data; + gchar *checksum_hex; + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL); g_return_val_if_fail (G_IS_FILE (gfile), NULL); @@ -847,7 +852,24 @@ empathy_send_file (EmpathyContact *contact, &value, NULL, NULL); g_value_reset (&value); - g_value_set_string (&value, "foobar"); + + if (g_file_get_contents (g_file_get_path (gfile), + &checksum_data, &checksum_length, &error)) { + + checksum_hex = g_compute_checksum_for_data (G_CHECKSUM_MD5, + (guchar *) checksum_data, + (gssize) checksum_length); + g_free (checksum_data); + DEBUG ("Got a checksum: %s", checksum_hex); + } else { + DEBUG ("Couldn't get file contents for checksum: %s", + error ? error->message : "No error given"); + g_clear_error (&error); + checksum_hex = ""; + } + + g_value_set_string (&value, checksum_hex); + g_free (checksum_hex); tp_cli_dbus_properties_run_set (TP_PROXY (channel), -1, EMP_IFACE_CHANNEL_TYPE_FILE, "ContentMD5", &value, NULL, NULL); |