Mercurial > pidgin
comparison src/protocols/jabber/buddy.c @ 10941:cef48e318125
[gaim-migrate @ 12731]
sick of having my tree be so far out of sync...here's all my jabber stuff
most notable is the "iChat" buddy icon support
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 26 May 2005 04:13:06 +0000 |
parents | b256ce6b85b8 |
children | 719779387f96 |
comparison
equal
deleted
inserted
replaced
10940:999555fbbbd9 | 10941:cef48e318125 |
---|---|
382 GError *error = NULL; | 382 GError *error = NULL; |
383 unsigned char *avatar_data; | 383 unsigned char *avatar_data; |
384 gsize avatar_len; | 384 gsize avatar_len; |
385 | 385 |
386 if(avatar_file && g_file_get_contents(avatar_file, (gchar **)&avatar_data, &avatar_len, &error)) { | 386 if(avatar_file && g_file_get_contents(avatar_file, (gchar **)&avatar_data, &avatar_len, &error)) { |
387 xmlnode *photo; | 387 xmlnode *photo, *binval; |
388 unsigned char *enc; | 388 unsigned char *enc; |
389 int i; | 389 int i; |
390 unsigned char hashval[20]; | 390 unsigned char hashval[20]; |
391 char *p, hash[41]; | 391 char *p, hash[41]; |
392 | 392 |
393 photo = xmlnode_new_child(vc_node, "PHOTO"); | 393 photo = xmlnode_new_child(vc_node, "PHOTO"); |
394 binval = xmlnode_new_child(photo, "BINVAL"); | |
394 enc = gaim_base64_encode(avatar_data, avatar_len); | 395 enc = gaim_base64_encode(avatar_data, avatar_len); |
395 | 396 |
396 gaim_cipher_digest_region("sha1", (guint8 *)avatar_data, | 397 gaim_cipher_digest_region("sha1", (guint8 *)avatar_data, |
397 avatar_len, sizeof(hashval), | 398 avatar_len, sizeof(hashval), |
398 hashval, NULL); | 399 hashval, NULL); |
400 p = hash; | 401 p = hash; |
401 for(i=0; i<20; i++, p+=2) | 402 for(i=0; i<20; i++, p+=2) |
402 snprintf(p, 3, "%02x", hashval[i]); | 403 snprintf(p, 3, "%02x", hashval[i]); |
403 js->avatar_hash = g_strdup(hash); | 404 js->avatar_hash = g_strdup(hash); |
404 | 405 |
405 xmlnode_insert_data(photo, enc, -1); | 406 xmlnode_insert_data(binval, enc, -1); |
406 g_free(enc); | 407 g_free(enc); |
407 g_free(avatar_data); | 408 g_free(avatar_data); |
408 } else if (error != NULL) { | 409 } else if (error != NULL) { |
409 g_error_free(error); | 410 g_error_free(error); |
410 } | 411 } |
802 } else if(text && !strcmp(child->name, "DESC")) { | 803 } else if(text && !strcmp(child->name, "DESC")) { |
803 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 804 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", |
804 _("Description"), text); | 805 _("Description"), text); |
805 } else if(!strcmp(child->name, "PHOTO") || | 806 } else if(!strcmp(child->name, "PHOTO") || |
806 !strcmp(child->name, "LOGO")) { | 807 !strcmp(child->name, "LOGO")) { |
807 int size, i; | 808 char *bintext = NULL; |
808 unsigned char hashval[20]; | 809 xmlnode *binval; |
809 char *data, *p, hash[41]; | 810 if((binval = xmlnode_get_child(child, "BINVAL")) && |
810 gboolean photo = (strcmp(child->name, "PHOTO") == 0); | 811 (bintext = xmlnode_get_data(binval))) { |
811 | 812 int size, i; |
812 gaim_base64_decode(text, &data, &size); | 813 unsigned char hashval[20]; |
813 | 814 char *data, *p, hash[41]; |
814 imgids = g_slist_prepend(imgids, GINT_TO_POINTER(gaim_imgstore_add(data, size, "logo.png"))); | 815 gboolean photo = (strcmp(child->name, "PHOTO") == 0); |
815 g_string_append_printf(info_text, | 816 |
816 "<b>%s:</b> <img id='%d'><br/>", | 817 gaim_base64_decode(text, &data, &size); |
817 photo ? _("Photo") : _("Logo"), | 818 |
818 GPOINTER_TO_INT(imgids->data)); | 819 imgids = g_slist_prepend(imgids, GINT_TO_POINTER(gaim_imgstore_add(data, size, "logo.png"))); |
819 | 820 g_string_append_printf(info_text, |
820 gaim_buddy_icons_set_for_user(js->gc->account, bare_jid, | 821 "<b>%s:</b> <img id='%d'><br/>", |
821 data, size); | 822 photo ? _("Photo") : _("Logo"), |
822 | 823 GPOINTER_TO_INT(imgids->data)); |
823 gaim_cipher_digest_region("sha1", (guint8 *)data, size, | 824 |
824 sizeof(hashval), hashval, NULL); | 825 gaim_buddy_icons_set_for_user(js->gc->account, bare_jid, |
825 p = hash; | 826 data, size); |
826 for(i=0; i<20; i++, p+=2) | 827 |
827 snprintf(p, 3, "%02x", hashval[i]); | 828 gaim_cipher_digest_region("sha1", (guint8 *)data, size, |
828 gaim_blist_node_set_string((GaimBlistNode*)b, "avatar_hash", hash); | 829 sizeof(hashval), hashval, NULL); |
829 | 830 p = hash; |
830 g_free(data); | 831 for(i=0; i<20; i++, p+=2) |
832 snprintf(p, 3, "%02x", hashval[i]); | |
833 gaim_blist_node_set_string((GaimBlistNode*)b, "avatar_hash", hash); | |
834 | |
835 g_free(data); | |
836 g_free(bintext); | |
837 } | |
831 } | 838 } |
832 g_free(text); | 839 g_free(text); |
833 } | 840 } |
834 } | 841 } |
835 | 842 |