| 234 |
234 |
| 235 if (filename == NULL) |
235 if (filename == NULL) |
| 236 { |
236 { |
| 237 file = purple_buddy_icon_data_calculate_filename(icon_data, icon_len); |
237 file = purple_buddy_icon_data_calculate_filename(icon_data, icon_len); |
| 238 if (file == NULL) |
238 if (file == NULL) |
| |
239 { |
| |
240 g_free(icon_data); |
| 239 return NULL; |
241 return NULL; |
| |
242 } |
| 240 } |
243 } |
| 241 else |
244 else |
| 242 file = g_strdup(filename); |
245 file = g_strdup(filename); |
| 243 |
246 |
| 244 if ((img = g_hash_table_lookup(icon_data_cache, file))) |
247 if ((img = g_hash_table_lookup(icon_data_cache, file))) |
| 245 { |
248 { |
| 246 g_free(file); |
249 g_free(file); |
| |
250 g_free(icon_data); |
| 247 return purple_imgstore_ref(img); |
251 return purple_imgstore_ref(img); |
| 248 } |
252 } |
| 249 |
253 |
| 250 img = purple_imgstore_add(icon_data, icon_len, file); |
254 img = purple_imgstore_add(icon_data, icon_len, file); |
| 251 |
255 |
| 436 g_return_if_fail(icon != NULL); |
440 g_return_if_fail(icon != NULL); |
| 437 |
441 |
| 438 old_img = icon->img; |
442 old_img = icon->img; |
| 439 icon->img = NULL; |
443 icon->img = NULL; |
| 440 |
444 |
| 441 if (data != NULL && len > 0) |
445 if (data != NULL) |
| 442 icon->img = purple_buddy_icon_data_new(data, len, NULL); |
446 if (len > 0) |
| |
447 icon->img = purple_buddy_icon_data_new(data, len, NULL); |
| |
448 else |
| |
449 g_free(data); |
| 443 |
450 |
| 444 icon->checksum = g_strdup(checksum); |
451 icon->checksum = g_strdup(checksum); |
| 445 |
452 |
| 446 purple_buddy_icon_update(icon); |
453 purple_buddy_icon_update(icon); |
| 447 |
454 |
| 608 icon = purple_buddy_icon_create(account, username); |
615 icon = purple_buddy_icon_create(account, username); |
| 609 icon->ref_count = 0; |
616 icon->ref_count = 0; |
| 610 icon->img = NULL; |
617 icon->img = NULL; |
| 611 checksum = g_strdup(purple_blist_node_get_string((PurpleBlistNode*)b, "icon_checksum")); |
618 checksum = g_strdup(purple_blist_node_get_string((PurpleBlistNode*)b, "icon_checksum")); |
| 612 purple_buddy_icon_set_data(icon, data, len, checksum); |
619 purple_buddy_icon_set_data(icon, data, len, checksum); |
| 613 g_free(data); |
|
| 614 } |
620 } |
| 615 g_free(path); |
621 g_free(path); |
| 616 } |
622 } |
| 617 |
623 |
| 618 purple_buddy_icons_set_caching(caching); |
624 purple_buddy_icons_set_caching(caching); |
| 656 |
662 |
| 657 if (read_icon_file(path, &data, &len)) |
663 if (read_icon_file(path, &data, &len)) |
| 658 { |
664 { |
| 659 g_free(path); |
665 g_free(path); |
| 660 img = purple_buddy_icon_data_new(data, len, account_icon_file); |
666 img = purple_buddy_icon_data_new(data, len, account_icon_file); |
| 661 g_free(data); |
|
| 662 g_hash_table_insert(pointer_icon_cache, account, img); |
667 g_hash_table_insert(pointer_icon_cache, account, img); |
| 663 return img; |
668 return img; |
| 664 } |
669 } |
| 665 g_free(path); |
670 g_free(path); |
| 666 |
671 |
| 678 old_img = g_hash_table_lookup(pointer_icon_cache, account); |
683 old_img = g_hash_table_lookup(pointer_icon_cache, account); |
| 679 |
684 |
| 680 if (icon_data != NULL && icon_len > 0) |
685 if (icon_data != NULL && icon_len > 0) |
| 681 { |
686 { |
| 682 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
687 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
| 683 g_free(icon_data); |
|
| 684 } |
688 } |
| 685 |
689 |
| 686 old_icon = g_strdup(purple_account_get_string(account, "buddy_icon", NULL)); |
690 old_icon = g_strdup(purple_account_get_string(account, "buddy_icon", NULL)); |
| 687 if (img && purple_buddy_icons_is_caching()) |
691 if (img && purple_buddy_icons_is_caching()) |
| 688 { |
692 { |
| 755 |
759 |
| 756 if (read_icon_file(path, &data, &len)) |
760 if (read_icon_file(path, &data, &len)) |
| 757 { |
761 { |
| 758 g_free(path); |
762 g_free(path); |
| 759 img = purple_buddy_icon_data_new(data, len, custom_icon_file); |
763 img = purple_buddy_icon_data_new(data, len, custom_icon_file); |
| 760 g_free(data); |
|
| 761 g_hash_table_insert(pointer_icon_cache, contact, img); |
764 g_hash_table_insert(pointer_icon_cache, contact, img); |
| 762 return img; |
765 return img; |
| 763 } |
766 } |
| 764 g_free(path); |
767 g_free(path); |
| 765 |
768 |
| 778 old_img = g_hash_table_lookup(pointer_icon_cache, contact); |
781 old_img = g_hash_table_lookup(pointer_icon_cache, contact); |
| 779 |
782 |
| 780 if (icon_data != NULL && icon_len > 0) |
783 if (icon_data != NULL && icon_len > 0) |
| 781 { |
784 { |
| 782 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
785 img = purple_buddy_icon_data_new(icon_data, icon_len, NULL); |
| 783 g_free(icon_data); |
|
| 784 } |
786 } |
| 785 |
787 |
| 786 old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)contact, |
788 old_icon = g_strdup(purple_blist_node_get_string((PurpleBlistNode *)contact, |
| 787 "custom_buddy_icon")); |
789 "custom_buddy_icon")); |
| 788 if (img && purple_buddy_icons_is_caching()) |
790 if (img && purple_buddy_icons_is_caching()) |