Mercurial > pidgin.yaz
comparison src/prpl.c @ 2191:657dbe515608
[gaim-migrate @ 2201]
genericize buddy icon stuff
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 29 Aug 2001 23:41:43 +0000 |
parents | dca8e00d7de0 |
children | 5014b802eb41 |
comparison
equal
deleted
inserted
replaced
2190:24d947eff811 | 2191:657dbe515608 |
---|---|
547 } | 547 } |
548 gtk_label_set_text(GTK_LABEL(gc->email_label), buf); | 548 gtk_label_set_text(GTK_LABEL(gc->email_label), buf); |
549 } else if (gc->email_win) | 549 } else if (gc->email_win) |
550 gtk_widget_destroy(gc->email_win); | 550 gtk_widget_destroy(gc->email_win); |
551 } | 551 } |
552 | |
553 struct icon_data { | |
554 struct gaim_connection *gc; | |
555 char *who; | |
556 void *data; | |
557 int len; | |
558 }; | |
559 | |
560 static GList *icons = NULL; | |
561 | |
562 static gint find_icon_data(gconstpointer a, gconstpointer b) | |
563 { | |
564 const struct icon_data *x = a; | |
565 const struct icon_data *y = b; | |
566 | |
567 return ((x->gc != y->gc) || g_strcasecmp(x->who, y->who)); | |
568 } | |
569 | |
570 void set_icon_data(struct gaim_connection *gc, char *who, void *data, int len) | |
571 { | |
572 struct icon_data tmp = { gc, who, NULL, 0 }; | |
573 GList *l = g_list_find_custom(icons, &tmp, find_icon_data); | |
574 struct icon_data *id = l ? l->data : NULL; | |
575 | |
576 if (id) { | |
577 g_free(id->data); | |
578 if (!data) { | |
579 icons = g_list_remove(icons, id); | |
580 g_free(id->who); | |
581 g_free(id); | |
582 return; | |
583 } | |
584 } else if (data) { | |
585 id = g_new0(struct icon_data, 1); | |
586 icons = g_list_append(icons, id); | |
587 id->gc = gc; | |
588 id->who = g_strdup(who); | |
589 } else { | |
590 return; | |
591 } | |
592 | |
593 id->data = g_memdup(data, len); | |
594 id->len = len; | |
595 | |
596 got_new_icon(gc, who); | |
597 } | |
598 | |
599 void remove_icon_data(struct gaim_connection *gc) | |
600 { | |
601 GList *list = icons; | |
602 struct icon_data *id; | |
603 | |
604 while (list) { | |
605 id = list->data; | |
606 if (id->gc == gc) { | |
607 g_free(id->data); | |
608 g_free(id->who); | |
609 list = icons = g_list_remove(icons, id); | |
610 g_free(id); | |
611 } else | |
612 list = list->next; | |
613 } | |
614 } | |
615 | |
616 void *get_icon_data(struct gaim_connection *gc, char *who, int *len) | |
617 { | |
618 struct icon_data tmp = { gc, who, NULL, 0 }; | |
619 GList *l = g_list_find_custom(icons, &tmp, find_icon_data); | |
620 struct icon_data *id = l ? l->data : NULL; | |
621 | |
622 if (id) { | |
623 *len = id->len; | |
624 return id->data; | |
625 } | |
626 | |
627 *len = 0; | |
628 return NULL; | |
629 } |