comparison src/prpl.c @ 4799:7fd8a82a7c36

[gaim-migrate @ 5119] read the comment in the code and know my rage. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 16 Mar 2003 07:51:11 +0000
parents 677d3cb193a1
children 5b24e8e52e4a
comparison
equal deleted inserted replaced
4798:0c95a3731244 4799:7fd8a82a7c36
558 struct gaim_conversation *conv; 558 struct gaim_conversation *conv;
559 struct icon_data tmp; 559 struct icon_data tmp;
560 GList *l; 560 GList *l;
561 struct icon_data *id; 561 struct icon_data *id;
562 struct buddy *b; 562 struct buddy *b;
563 /* i'm going to vent here a little bit about normalize(). normalize()
564 * uses a static buffer, so when we call functions that use normalize() from
565 * functions that use normalize(), whose parameters are the result of running
566 * normalize(), bad things happen. To prevent some of this, we're going
567 * to make a copy of what we get from normalize(), so we know nothing else
568 * touches it, and buddy icons don't go to the wrong person. Some day I
569 * will kill normalize(), and dance on its grave. That will be a very happy
570 * day for everyone.
571 * --ndw
572 */
573 char *realwho = g_strdup(normalize(who));
563 tmp.gc = gc; 574 tmp.gc = gc;
564 tmp.who = normalize(who); 575 tmp.who = realwho;
565 tmp.data=NULL; 576 tmp.data=NULL;
566 tmp.len = 0; 577 tmp.len = 0;
567 l = g_list_find_custom(icons, &tmp, find_icon_data); 578 l = g_list_find_custom(icons, &tmp, find_icon_data);
568 id = l ? l->data : NULL; 579 id = l ? l->data : NULL;
569 580
570 if (id) { 581 if (id) {
571 g_free(id->data); 582 g_free(id->data);
572 if (!data) { 583 if (!data) {
573 icons = g_list_remove(icons, id); 584 icons = g_list_remove(icons, id);
574 g_free(id->who); 585 g_free(id->who);
575 g_free(id); 586 g_free(id);
587 g_free(realwho);
576 return; 588 return;
577 } 589 }
578 } else if (data) { 590 } else if (data) {
579 id = g_new0(struct icon_data, 1); 591 id = g_new0(struct icon_data, 1);
580 icons = g_list_append(icons, id); 592 icons = g_list_append(icons, id);
581 id->gc = gc; 593 id->gc = gc;
582 id->who = g_strdup(normalize(who)); 594 id->who = g_strdup(realwho);
583 } else { 595 } else {
584 return; 596 g_free(realwho);
585 } 597 return;
586 598 }
587 debug_printf("Got icon for %s (length %d)\n", who, len); 599
600 debug_printf("Got icon for %s (length %d)\n", realwho, len);
588 601
589 id->data = g_memdup(data, len); 602 id->data = g_memdup(data, len);
590 id->len = len; 603 id->len = len;
591 604
592 /* Update the buddy icon for this user. */ 605 /* Update the buddy icon for this user. */
593 conv = gaim_find_conversation(who); 606 conv = gaim_find_conversation(realwho);
594 607
595 /* XXX Buddy Icon should probalby be part of struct buddy instead of this weird global 608 /* XXX Buddy Icon should probalby be part of struct buddy instead of this weird global
596 * linked list stuff. */ 609 * linked list stuff. */
597 610
598 if ((b = gaim_find_buddy(gc->account, who)) != NULL) { 611 if ((b = gaim_find_buddy(gc->account, realwho)) != NULL) {
599 char *random = g_strdup_printf("%x", g_random_int()); 612 char *random = g_strdup_printf("%x", g_random_int());
600 char *filename = g_build_filename(gaim_user_dir(), "icons", random, 613 char *filename = g_build_filename(gaim_user_dir(), "icons", random,
601 NULL); 614 NULL);
602 char *dirname = g_build_filename(gaim_user_dir(), "icons", NULL); 615 char *dirname = g_build_filename(gaim_user_dir(), "icons", NULL);
603 char *old_icon = gaim_buddy_get_setting(b, "buddy_icon"); 616 char *old_icon = gaim_buddy_get_setting(b, "buddy_icon");
629 gaim_blist_update_buddy_icon(b); 642 gaim_blist_update_buddy_icon(b);
630 } 643 }
631 644
632 if (conv != NULL && gaim_conversation_get_gc(conv) == gc) 645 if (conv != NULL && gaim_conversation_get_gc(conv) == gc)
633 gaim_gtkconv_update_buddy_icon(conv); 646 gaim_gtkconv_update_buddy_icon(conv);
647
648 g_free(realwho);
634 } 649 }
635 650
636 void remove_icon_data(struct gaim_connection *gc) 651 void remove_icon_data(struct gaim_connection *gc)
637 { 652 {
638 GList *list = icons; 653 GList *list = icons;