Mercurial > pidgin
annotate src/buddyicon.c @ 8634:bcb09cc97b63
[gaim-migrate @ 9386]
Beginning of my code auditing, or whatever. Ima go eat
lunch and do some homework.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 11 Apr 2004 18:18:30 +0000 |
parents | 52dca2f38956 |
children | 7a8aa87164ae |
rev | line source |
---|---|
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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
28 #include "debug.h" |
b5fb1d5282e5
[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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
32 static char *cache_dir = NULL; |
b5fb1d5282e5
[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
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
80 GaimConversation *conv; |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
81 GaimAccount *account; |
6846 | 82 GHashTable *icon_cache; |
7311
1c8830db0189
[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
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
94 account = gaim_buddy_icon_get_account(icon); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
95 username = gaim_buddy_icon_get_username(icon); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
96 |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
97 conv = gaim_find_conversation_with_account(username, account); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
98 |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
99 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
100 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); |
1c8830db0189
[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
bf630f7dfdcd
[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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
177 gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy) |
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 const void *data; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
180 const char *dirname; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
181 char *random; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
182 char *filename; |
7125 | 183 const char *old_icon; |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
184 size_t len; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
185 FILE *file = NULL; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
186 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
187 g_return_if_fail(icon != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
188 g_return_if_fail(buddy != NULL); |
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 (!gaim_buddy_icons_is_caching()) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
191 return; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
192 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
193 data = gaim_buddy_icon_get_data(icon, &len); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
194 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
195 random = g_strdup_printf("%x", g_random_int()); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
196 dirname = gaim_buddy_icons_get_cache_dir(); |
b5fb1d5282e5
[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
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 g_free(random); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
201 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
202 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
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 gaim_debug_info("buddy icons", "Creating icon cache directory.\n"); |
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 if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
207 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
208 gaim_debug_error("buddy icons", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
209 "Unable to create directory %s: %s\n", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
210 dirname, strerror(errno)); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
211 } |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
214 if ((file = fopen(filename, "wb")) != NULL) |
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 fwrite(data, 1, len, file); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
217 fclose(file); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
218 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
219 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
220 if (old_icon != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
221 unlink(old_icon); |
b5fb1d5282e5
[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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
224 gaim_blist_save(); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
225 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
226 g_free(filename); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
227 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
228 |
b5fb1d5282e5
[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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
325 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
326 gaim_buddy_icons_set_caching(gboolean caching) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
327 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
328 icon_caching = caching; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
329 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
330 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
331 gboolean |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
332 gaim_buddy_icons_is_caching(void) |
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 return icon_caching; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
335 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
336 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
337 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
338 gaim_buddy_icons_set_cache_dir(const char *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 g_return_if_fail(cache_dir != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
341 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
342 if (cache_dir != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
343 g_free(cache_dir); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
344 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
345 cache_dir = g_strdup(dir); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
346 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
347 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
348 const char * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
349 gaim_buddy_icons_get_cache_dir(void) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
350 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
351 return cache_dir; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
352 } |
b5fb1d5282e5
[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
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
368 |
b5fb1d5282e5
[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 } |