src/account.c

changeset 11303
448b8bae1ca7
parent 11298
46959efe9342
child 11320
1b2fd0a486aa
equal deleted inserted replaced
11302:25694fe861b9 11303:448b8bae1ca7
1208 void 1208 void
1209 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon) 1209 gaim_account_set_buddy_icon(GaimAccount *account, const char *icon)
1210 { 1210 {
1211 g_return_if_fail(account != NULL); 1211 g_return_if_fail(account != NULL);
1212 1212
1213 /* Delete an existing icon from the cache. */
1214 if (account->buddy_icon != NULL && (icon == NULL || strcmp(account->buddy_icon, icon)))
1215 {
1216 const char *dirname = gaim_buddy_icons_get_cache_dir();
1217 struct stat st;
1218
1219 if (g_stat(account->buddy_icon, &st) == 0)
1220 {
1221 /* The file exists. This is a full path. */
1222
1223 /* XXX: This is a hack so we only delete the file if it's
1224 * in the cache dir. Otherwise, people who upgrade (who
1225 * may have buddy icon filenames set outside of the cache
1226 * dir) could lose files. */
1227 if (!strncmp(dirname, account->buddy_icon, strlen(dirname)))
1228 g_unlink(account->buddy_icon);
1229 }
1230 else
1231 {
1232 char *filename = g_build_filename(dirname, account->buddy_icon, NULL);
1233 g_unlink(filename);
1234 g_free(filename);
1235 }
1236 }
1237
1213 g_free(account->buddy_icon); 1238 g_free(account->buddy_icon);
1214 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon)); 1239 account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon));
1215 if (gaim_account_is_connected(account)) 1240 if (gaim_account_is_connected(account))
1216 serv_set_buddyicon(gaim_account_get_connection(account), icon); 1241 serv_set_buddyicon(gaim_account_get_connection(account), icon);
1217 1242
1938 } 1963 }
1939 1964
1940 /* Remove this account's pounces */ 1965 /* Remove this account's pounces */
1941 gaim_pounce_destroy_all_by_account(account); 1966 gaim_pounce_destroy_all_by_account(account);
1942 1967
1968 /* This will cause the deletion of an old buddy icon. */
1969 gaim_account_set_buddy_icon(account, NULL);
1970
1943 gaim_account_destroy(account); 1971 gaim_account_destroy(account);
1944 } 1972 }
1945 1973
1946 void 1974 void
1947 gaim_accounts_reorder(GaimAccount *account, size_t new_index) 1975 gaim_accounts_reorder(GaimAccount *account, size_t new_index)

mercurial