comparison src/buddyicon.c @ 9305:0c201a2386c7

[gaim-migrate @ 10113] gaim_buddy_icons_set_for_user() can now clear and remove the icon from everything and update the UI when the icon data is NULL and/or the icon length is 0. This *should* work. Tim will test it for me :) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 18 Jun 2004 05:09:01 +0000
parents 7a8aa87164ae
children 59bca4e8678c
comparison
equal deleted inserted replaced
9304:96c481da57ea 9305:0c201a2386c7
79 { 79 {
80 GaimConversation *conv; 80 GaimConversation *conv;
81 GaimAccount *account; 81 GaimAccount *account;
82 GHashTable *icon_cache; 82 GHashTable *icon_cache;
83 const char *username; 83 const char *username;
84 GSList *sl, *list;
84 85
85 g_return_if_fail(icon != NULL); 86 g_return_if_fail(icon != NULL);
86 87
87 if (icon->ref_count > 0) 88 if (icon->ref_count > 0)
88 { 89 {
93 94
94 account = gaim_buddy_icon_get_account(icon); 95 account = gaim_buddy_icon_get_account(icon);
95 username = gaim_buddy_icon_get_username(icon); 96 username = gaim_buddy_icon_get_username(icon);
96 97
97 conv = gaim_find_conversation_with_account(username, account); 98 conv = gaim_find_conversation_with_account(username, account);
99
100 for (list = sl = gaim_find_buddies(account, username); sl != NULL;
101 sl = sl->next)
102 {
103 GaimBuddy *buddy = (GaimBuddy *)sl->data;
104
105 gaim_buddy_set_icon(buddy, NULL);
106 }
107
108 g_slist_free(list);
98 109
99 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) 110 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM)
100 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); 111 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL);
101 112
102 icon_cache = g_hash_table_lookup(account_cache, 113 icon_cache = g_hash_table_lookup(account_cache,
155 g_return_if_fail(icon != NULL); 166 g_return_if_fail(icon != NULL);
156 167
157 account = gaim_buddy_icon_get_account(icon); 168 account = gaim_buddy_icon_get_account(icon);
158 username = gaim_buddy_icon_get_username(icon); 169 username = gaim_buddy_icon_get_username(icon);
159 170
160 for (list =sl = gaim_find_buddies(account, username); sl != NULL; 171 for (list = sl = gaim_find_buddies(account, username); sl != NULL;
161 sl = sl->next) 172 sl = sl->next)
162 { 173 {
163 GaimBuddy *buddy = (GaimBuddy *)sl->data; 174 GaimBuddy *buddy = (GaimBuddy *)sl->data;
164 175
165 gaim_buddy_set_icon(buddy, icon); 176 gaim_buddy_set_icon(buddy, icon);
166 } 177 }
300 void *icon_data, size_t icon_len) 311 void *icon_data, size_t icon_len)
301 { 312 {
302 g_return_if_fail(account != NULL); 313 g_return_if_fail(account != NULL);
303 g_return_if_fail(username != NULL); 314 g_return_if_fail(username != NULL);
304 315
305 gaim_buddy_icon_new(account, username, icon_data, icon_len); 316 if (icon_data == NULL || icon_len == 0)
317 {
318 GaimBuddyIcon *buddy_icon;
319
320 buddy_icon = gaim_buddy_icons_find(account, username);
321
322 if (buddy_icon != NULL)
323 gaim_buddy_icon_destroy(buddy_icon);
324 }
325 else
326 {
327 gaim_buddy_icon_new(account, username, icon_data, icon_len);
328 }
306 } 329 }
307 330
308 GaimBuddyIcon * 331 GaimBuddyIcon *
309 gaim_buddy_icons_find(const GaimAccount *account, const char *username) 332 gaim_buddy_icons_find(const GaimAccount *account, const char *username)
310 { 333 {