diff options
author | Will Thompson <resiak@soc.pidgin.im> | 2007-08-01 23:27:13 +0000 |
---|---|---|
committer | Will Thompson <resiak@soc.pidgin.im> | 2007-08-01 23:27:13 +0000 |
commit | 195b483fddb8f61dabb7fb5ee8fa81f7413c53e7 (patch) | |
tree | 7cede86dba93f26608f9173b69b188c0bee5b823 | |
parent | a60d01475870d1fd716d350016b66a20848f0c3f (diff) |
Construct image hash directly, rather than with purple_util_get_image_filename to allow building with libpurple 2.0
-rw-r--r-- | src/connection-avatars.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/connection-avatars.c b/src/connection-avatars.c index 7e0ec40..e0e317b 100644 --- a/src/connection-avatars.c +++ b/src/connection-avatars.c @@ -1,5 +1,7 @@ #include <telepathy-glib/svc-connection.h> +#include <cipher.h> + #include "connection-avatars.h" #include "connection.h" @@ -87,7 +89,30 @@ get_token (const GArray *avatar) if (avatar) { - token = purple_util_get_image_filename (avatar->data, avatar->len); + /* Taken mostly verbatim from purple_util_get_image_filename; this copy + * does not append a file extension to the hash, and also works with + * libpurple 2.0 + */ + PurpleCipherContext *context; + gchar digest[41]; + + context = purple_cipher_context_new_by_name("sha1", NULL); + if (context == NULL) + { + g_error ("Could not find libpurple's sha1 cipher"); + } + + /* Hash the image data */ + purple_cipher_context_append(context, (const guchar *) avatar->data, + avatar->len); + if (!purple_cipher_context_digest_to_str(context, sizeof(digest), + digest, NULL)) + { + g_error ("Failed to get SHA-1 digest"); + } + purple_cipher_context_destroy(context); + + token = g_strdup (digest); } else { |