Mercurial > pidgin
changeset 16485:6c3b44ac71f3
Update SILC for imgstore changes.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 27 Apr 2007 03:27:37 +0000 |
parents | 3c01acbf3478 |
children | fc76627be6de |
files | libpurple/protocols/silc/buddy.c libpurple/protocols/silc/silc.c libpurple/protocols/silc/silcpurple.h |
diffstat | 3 files changed, 15 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/silc/buddy.c Fri Apr 27 02:34:42 2007 +0000 +++ b/libpurple/protocols/silc/buddy.c Fri Apr 27 03:27:37 2007 +0000 @@ -987,8 +987,10 @@ const unsigned char *data; SilcUInt32 data_len; data = silc_mime_get_data(m, &data_len); - if (data) - purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup(data, data_len), data_len); + if (data) { + /* TODO: Check if SILC gives us something to use as the checksum instead */ + purple_buddy_icons_set_for_user(purple_buddy_get_account(r->b), purple_buddy_get_name(r->b), g_memdup(data, data_len), data_len, NULL); + } } silc_mime_free(m); } @@ -1681,48 +1683,31 @@ } #ifdef SILC_ATTRIBUTE_USER_ICON -void silcpurple_buddy_set_icon(PurpleConnection *gc, const char *iconfile) +void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img) { SilcPurple sg = gc->proto_data; SilcClient client = sg->client; SilcClientConnection conn = sg->conn; SilcMime mime; - PurpleBuddyIcon ic; char type[32]; unsigned char *icon; const char *t; - struct stat st; - FILE *fp; SilcAttributeObjMime obj; /* Remove */ - if (!iconfile) { + if (!img) { silc_client_attribute_del(client, conn, SILC_ATTRIBUTE_USER_ICON, NULL); return; } /* Add */ - if (g_stat(iconfile, &st) < 0) - return; - fp = g_fopen(iconfile, "rb"); - if (!fp) - return; - ic.data = g_malloc(st.st_size); - if (!ic.data) + mime = silc_mime_alloc(); + if (!mime) return; - ic.len = fread(ic.data, 1, st.st_size, fp); - fclose(fp); - mime = silc_mime_alloc(); - if (!mime) { - g_free(ic.data); - return; - } - - t = purple_buddy_icon_get_type((const PurpleBuddyIcon *)&ic); + t = purple_util_get_image_extension(purple_imgstore_get_data(img), purple_imgstore_get_size(img)); if (!t || !strcmp(t, "icon")) { - g_free(ic.data); silc_mime_free(mime); return; } @@ -1730,7 +1715,7 @@ t = "jpeg"; g_snprintf(type, sizeof(type), "image/%s", t); silc_mime_add_field(mime, "Content-Type", type); - silc_mime_add_data(mime, ic.data, ic.len); + silc_mime_add_data(mime, purple_imgstore_get_data(img), purple_imgstore_get_size(img)); obj.mime = icon = silc_mime_encode(mime, &obj.mime_len); if (obj.mime) @@ -1738,7 +1723,6 @@ SILC_ATTRIBUTE_USER_ICON, &obj, sizeof(obj)); silc_free(icon); - g_free(ic.data); silc_mime_free(mime); } #endif
--- a/libpurple/protocols/silc/silc.c Fri Apr 27 02:34:42 2007 +0000 +++ b/libpurple/protocols/silc/silc.c Fri Apr 27 03:27:37 2007 +0000 @@ -194,7 +194,7 @@ SilcUInt32 mask; const char *tmp; #ifdef SILC_ATTRIBUTE_USER_ICON - char *icon; + PurpleStoredImage *img; #endif #ifdef HAVE_SYS_UTSNAME_H struct utsname u; @@ -233,9 +233,9 @@ #ifdef SILC_ATTRIBUTE_USER_ICON /* Set our buddy icon */ - icon = purple_buddy_icons_get_full_path(purple_account_get_buddy_icon(account)); - silcpurple_buddy_set_icon(gc, icon); - g_free(icon); + img = purple_buddy_icons_find_account_icon(account); + silcpurple_buddy_set_icon(gc, img); + purple_imgstore_unref(img); #endif }
--- a/libpurple/protocols/silc/silcpurple.h Fri Apr 27 02:34:42 2007 +0000 +++ b/libpurple/protocols/silc/silcpurple.h Fri Apr 27 03:27:37 2007 +0000 @@ -145,7 +145,7 @@ char **contactstr, char **langstr, char **devicestr, char **tzstr, char **geostr); #ifdef SILC_ATTRIBUTE_USER_ICON -void silcpurple_buddy_set_icon(PurpleConnection *gc, const char *iconfile); +void silcpurple_buddy_set_icon(PurpleConnection *gc, PurpleStoredImage *img); #endif #ifdef HAVE_SILCMIME_H char *silcpurple_file2mime(const char *filename);