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