Sat, 08 May 2004 23:34:30 +0000
[gaim-migrate @ 9677]
" Fixes a few warnings on 64bit machines. Also fixes
yahoo auth on 64bit machines which would have taken me
awhile if marv didn't point me in the right direction.
I've applied to my local 32bit copy and everything
seems to be working fine." --Gary Kramlich
committer: Luke Schierer <lschiere@pidgin.im>
| 6846 | 1 | /** |
| 2 | * @file icon.c Buddy Icon API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 7 | * Gaim is the legal property of its developers, whose names are too numerous |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 6846 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | #include "internal.h" | |
| 26 | #include "buddyicon.h" | |
| 27 | #include "conversation.h" | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
28 | #include "debug.h" |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
29 | #include "util.h" |
| 6846 | 30 | |
| 31 | static GHashTable *account_cache = NULL; | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
32 | static char *cache_dir = NULL; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
33 | static gboolean icon_caching = TRUE; |
| 6846 | 34 | |
| 35 | GaimBuddyIcon * | |
| 36 | gaim_buddy_icon_new(GaimAccount *account, const char *username, | |
| 37 | void *icon_data, size_t icon_len) | |
| 38 | { | |
| 39 | GaimBuddyIcon *icon; | |
| 40 | ||
| 41 | g_return_val_if_fail(account != NULL, NULL); | |
| 42 | g_return_val_if_fail(username != NULL, NULL); | |
| 43 | g_return_val_if_fail(icon_data != NULL, NULL); | |
| 44 | g_return_val_if_fail(icon_len > 0, NULL); | |
| 45 | ||
| 46 | icon = gaim_buddy_icons_find(account, username); | |
| 47 | ||
| 48 | if (icon == NULL) | |
| 49 | { | |
| 50 | GHashTable *icon_cache; | |
| 51 | ||
| 52 | icon = g_new0(GaimBuddyIcon, 1); | |
| 53 | ||
| 54 | gaim_buddy_icon_set_account(icon, account); | |
| 55 | gaim_buddy_icon_set_username(icon, username); | |
| 56 | ||
| 57 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 58 | ||
| 59 | if (icon_cache == NULL) | |
| 60 | { | |
| 61 | icon_cache = g_hash_table_new(g_str_hash, g_str_equal); | |
| 62 | ||
| 63 | g_hash_table_insert(account_cache, account, icon_cache); | |
| 64 | } | |
| 65 | ||
| 66 | g_hash_table_insert(icon_cache, | |
| 67 | (char *)gaim_buddy_icon_get_username(icon), icon); | |
| 68 | } | |
| 69 | ||
| 70 | gaim_buddy_icon_set_data(icon, icon_data, icon_len); | |
| 71 | ||
| 72 | gaim_buddy_icon_ref(icon); | |
| 73 | ||
| 74 | return icon; | |
| 75 | } | |
| 76 | ||
| 77 | void | |
| 78 | gaim_buddy_icon_destroy(GaimBuddyIcon *icon) | |
| 79 | { | |
|
7311
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
80 | GaimConversation *conv; |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
81 | GaimAccount *account; |
| 6846 | 82 | GHashTable *icon_cache; |
|
7311
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
83 | const char *username; |
| 6846 | 84 | |
| 85 | g_return_if_fail(icon != NULL); | |
| 86 | ||
| 87 | if (icon->ref_count > 0) | |
| 88 | { | |
| 89 | gaim_buddy_icon_unref(icon); | |
| 90 | ||
| 91 | return; | |
| 92 | } | |
| 93 | ||
|
7311
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
94 | account = gaim_buddy_icon_get_account(icon); |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
95 | username = gaim_buddy_icon_get_username(icon); |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
96 | |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
97 | conv = gaim_find_conversation_with_account(username, account); |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
98 | |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
99 | if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
100 | gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); |
|
cca08cb2fa3e
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
101 | |
| 6846 | 102 | icon_cache = g_hash_table_lookup(account_cache, |
| 103 | gaim_buddy_icon_get_account(icon)); | |
| 104 | ||
| 105 | if (icon_cache != NULL) | |
| 106 | g_hash_table_remove(icon_cache, gaim_buddy_icon_get_username(icon)); | |
| 107 | ||
| 108 | if (icon->username != NULL) | |
| 109 | g_free(icon->username); | |
| 110 | ||
| 111 | if (icon->data != NULL) | |
| 112 | g_free(icon->data); | |
| 113 | ||
| 114 | g_free(icon); | |
| 115 | } | |
| 116 | ||
| 117 | GaimBuddyIcon * | |
| 118 | gaim_buddy_icon_ref(GaimBuddyIcon *icon) | |
| 119 | { | |
| 120 | g_return_val_if_fail(icon != NULL, NULL); | |
| 121 | ||
| 122 | icon->ref_count++; | |
| 123 | ||
| 124 | return icon; | |
| 125 | } | |
| 126 | ||
| 127 | GaimBuddyIcon * | |
| 128 | gaim_buddy_icon_unref(GaimBuddyIcon *icon) | |
| 129 | { | |
| 130 | g_return_val_if_fail(icon != NULL, NULL); | |
| 131 | ||
| 132 | if (icon->ref_count <= 0) | |
| 133 | return NULL; | |
| 134 | ||
| 135 | icon->ref_count--; | |
| 136 | ||
| 137 | if (icon->ref_count == 0) | |
| 138 | { | |
| 139 | gaim_buddy_icon_destroy(icon); | |
| 140 | ||
| 141 | return NULL; | |
| 142 | } | |
| 143 | ||
| 144 | return icon; | |
| 145 | } | |
| 146 | ||
| 147 | void | |
| 148 | gaim_buddy_icon_update(GaimBuddyIcon *icon) | |
| 149 | { | |
| 150 | GaimConversation *conv; | |
| 151 | GaimAccount *account; | |
| 152 | const char *username; | |
| 8550 | 153 | GSList *sl, *list; |
| 6846 | 154 | |
| 155 | g_return_if_fail(icon != NULL); | |
| 156 | ||
| 157 | account = gaim_buddy_icon_get_account(icon); | |
| 158 | username = gaim_buddy_icon_get_username(icon); | |
| 159 | ||
| 8550 | 160 | for (list =sl = gaim_find_buddies(account, username); sl != NULL; |
| 161 | sl = sl->next) | |
| 6846 | 162 | { |
| 163 | GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
| 164 | ||
| 165 | gaim_buddy_set_icon(buddy, icon); | |
| 166 | } | |
| 167 | ||
| 8550 | 168 | g_slist_free(list); |
| 169 | ||
| 6846 | 170 | conv = gaim_find_conversation_with_account(username, account); |
| 171 | ||
| 172 | if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6886
diff
changeset
|
173 | gaim_conv_im_set_icon(GAIM_CONV_IM(conv), icon); |
| 6846 | 174 | } |
| 175 | ||
| 176 | void | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
177 | gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
178 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
179 | const void *data; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
180 | const char *dirname; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
181 | char *random; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
182 | char *filename; |
| 7125 | 183 | const char *old_icon; |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
184 | size_t len; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
185 | FILE *file = NULL; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
186 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
187 | g_return_if_fail(icon != NULL); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
188 | g_return_if_fail(buddy != NULL); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
189 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
190 | if (!gaim_buddy_icons_is_caching()) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
191 | return; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
192 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
193 | data = gaim_buddy_icon_get_data(icon, &len); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
194 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
195 | random = g_strdup_printf("%x", g_random_int()); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
196 | dirname = gaim_buddy_icons_get_cache_dir(); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
197 | filename = g_build_filename(dirname, random, NULL); |
| 7721 | 198 | old_icon = gaim_blist_node_get_string((GaimBlistNode*)buddy, "buddy_icon"); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
199 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
200 | g_free(random); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
201 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
202 | if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
203 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
204 | gaim_debug_info("buddy icons", "Creating icon cache directory.\n"); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
205 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
206 | if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
207 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
208 | gaim_debug_error("buddy icons", |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
209 | "Unable to create directory %s: %s\n", |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
210 | dirname, strerror(errno)); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
211 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
212 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
213 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
214 | if ((file = fopen(filename, "wb")) != NULL) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
215 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
216 | fwrite(data, 1, len, file); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
217 | fclose(file); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
218 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
219 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
220 | if (old_icon != NULL) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
221 | unlink(old_icon); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
222 | |
| 7721 | 223 | gaim_blist_node_set_string((GaimBlistNode*)buddy, "buddy_icon", filename); |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
224 | gaim_blist_save(); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
225 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
226 | g_free(filename); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
227 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
228 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
229 | void |
| 6846 | 230 | gaim_buddy_icon_set_account(GaimBuddyIcon *icon, GaimAccount *account) |
| 231 | { | |
| 232 | g_return_if_fail(icon != NULL); | |
| 233 | g_return_if_fail(account != NULL); | |
| 234 | ||
| 235 | icon->account = account; | |
| 236 | } | |
| 237 | ||
| 238 | void | |
| 239 | gaim_buddy_icon_set_username(GaimBuddyIcon *icon, const char *username) | |
| 240 | { | |
| 241 | g_return_if_fail(icon != NULL); | |
| 242 | g_return_if_fail(username != NULL); | |
| 243 | ||
| 244 | if (icon->username != NULL) | |
| 245 | g_free(icon->username); | |
| 246 | ||
| 247 | icon->username = g_strdup(username); | |
| 248 | } | |
| 249 | ||
| 250 | void | |
| 251 | gaim_buddy_icon_set_data(GaimBuddyIcon *icon, void *data, size_t len) | |
| 252 | { | |
| 253 | g_return_if_fail(icon != NULL); | |
| 254 | ||
| 255 | if (icon->data != NULL) | |
| 256 | g_free(icon->data); | |
| 257 | ||
| 258 | if (data != NULL && len > 0) | |
| 259 | { | |
| 260 | icon->data = g_memdup(data, len); | |
| 261 | icon->len = len; | |
| 262 | } | |
| 263 | else | |
| 264 | { | |
| 265 | icon->data = NULL; | |
| 266 | icon->len = 0; | |
| 267 | } | |
| 268 | ||
| 269 | gaim_buddy_icon_update(icon); | |
| 270 | } | |
| 271 | ||
| 272 | GaimAccount * | |
| 273 | gaim_buddy_icon_get_account(const GaimBuddyIcon *icon) | |
| 274 | { | |
| 275 | g_return_val_if_fail(icon != NULL, NULL); | |
| 276 | ||
| 277 | return icon->account; | |
| 278 | } | |
| 279 | ||
| 280 | const char * | |
| 281 | gaim_buddy_icon_get_username(const GaimBuddyIcon *icon) | |
| 282 | { | |
| 283 | g_return_val_if_fail(icon != NULL, NULL); | |
| 284 | ||
| 285 | return icon->username; | |
| 286 | } | |
| 287 | ||
| 288 | const void * | |
| 289 | gaim_buddy_icon_get_data(const GaimBuddyIcon *icon, size_t *len) | |
| 290 | { | |
| 291 | g_return_val_if_fail(icon != NULL, NULL); | |
| 292 | ||
| 293 | if (len != NULL) | |
| 294 | *len = icon->len; | |
| 295 | ||
| 296 | return icon->data; | |
| 297 | } | |
| 298 | ||
| 299 | void | |
| 300 | gaim_buddy_icons_set_for_user(GaimAccount *account, const char *username, | |
| 301 | void *icon_data, size_t icon_len) | |
| 302 | { | |
| 303 | g_return_if_fail(account != NULL); | |
| 304 | g_return_if_fail(username != NULL); | |
| 305 | ||
| 306 | gaim_buddy_icon_new(account, username, icon_data, icon_len); | |
| 307 | } | |
| 308 | ||
| 309 | GaimBuddyIcon * | |
| 310 | gaim_buddy_icons_find(const GaimAccount *account, const char *username) | |
| 311 | { | |
| 312 | GHashTable *icon_cache; | |
| 313 | ||
| 314 | g_return_val_if_fail(account != NULL, NULL); | |
| 315 | g_return_val_if_fail(username != NULL, NULL); | |
| 316 | ||
| 317 | icon_cache = g_hash_table_lookup(account_cache, account); | |
| 318 | ||
| 319 | if (icon_cache == NULL) | |
| 320 | return NULL; | |
| 321 | ||
| 322 | return g_hash_table_lookup(icon_cache, username); | |
| 323 | } | |
| 324 | ||
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
325 | void |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
326 | gaim_buddy_icons_set_caching(gboolean caching) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
327 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
328 | icon_caching = caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
329 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
330 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
331 | gboolean |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
332 | gaim_buddy_icons_is_caching(void) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
333 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
334 | return icon_caching; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
335 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
336 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
337 | void |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
338 | gaim_buddy_icons_set_cache_dir(const char *dir) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
339 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
340 | g_return_if_fail(cache_dir != NULL); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
341 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
342 | if (cache_dir != NULL) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
343 | g_free(cache_dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
344 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
345 | cache_dir = g_strdup(dir); |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
346 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
347 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
348 | const char * |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
349 | gaim_buddy_icons_get_cache_dir(void) |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
350 | { |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
351 | return cache_dir; |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
352 | } |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
353 | |
| 6846 | 354 | void * |
| 355 | gaim_buddy_icons_get_handle() | |
| 356 | { | |
| 357 | static int handle; | |
| 358 | ||
| 359 | return &handle; | |
| 360 | } | |
| 361 | ||
| 362 | void | |
| 363 | gaim_buddy_icons_init() | |
| 364 | { | |
| 365 | account_cache = g_hash_table_new_full( | |
| 366 | g_direct_hash, g_direct_equal, | |
| 367 | NULL, (GFreeFunc)g_hash_table_destroy); | |
|
6886
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
368 | |
|
97734a57c0f5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
369 | cache_dir = g_build_filename(gaim_user_dir(), "icons", NULL); |
| 6846 | 370 | } |
| 371 | ||
| 372 | void | |
| 373 | gaim_buddy_icons_uninit() | |
| 374 | { | |
| 375 | g_hash_table_destroy(account_cache); | |
| 376 | } |