Mercurial > pidgin
annotate src/buddyicon.c @ 7938:160547821ea2
[gaim-migrate @ 8609]
We weren't finding the default command handler, due to a case issue. Fixed.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 27 Dec 2003 01:37:33 +0000 |
parents | 20d0c025312a |
children | fa6395637e2c |
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 { | |
7311
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
78 GaimConversation *conv; |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
79 GaimAccount *account; |
6846 | 80 GHashTable *icon_cache; |
7311
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
81 const char *username; |
6846 | 82 |
83 g_return_if_fail(icon != NULL); | |
84 | |
85 if (icon->ref_count > 0) | |
86 { | |
87 gaim_buddy_icon_unref(icon); | |
88 | |
89 return; | |
90 } | |
91 | |
7311
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
92 account = gaim_buddy_icon_get_account(icon); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
93 username = gaim_buddy_icon_get_username(icon); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
94 |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
95 conv = gaim_find_conversation_with_account(username, account); |
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 if (conv != NULL && gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
98 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), NULL); |
1c8830db0189
[gaim-migrate @ 7895]
Christian Hammond <chipx86@chipx86.com>
parents:
7125
diff
changeset
|
99 |
6846 | 100 icon_cache = g_hash_table_lookup(account_cache, |
101 gaim_buddy_icon_get_account(icon)); | |
102 | |
103 if (icon_cache != NULL) | |
104 g_hash_table_remove(icon_cache, gaim_buddy_icon_get_username(icon)); | |
105 | |
106 if (icon->username != NULL) | |
107 g_free(icon->username); | |
108 | |
109 if (icon->data != NULL) | |
110 g_free(icon->data); | |
111 | |
112 g_free(icon); | |
113 } | |
114 | |
115 GaimBuddyIcon * | |
116 gaim_buddy_icon_ref(GaimBuddyIcon *icon) | |
117 { | |
118 g_return_val_if_fail(icon != NULL, NULL); | |
119 | |
120 icon->ref_count++; | |
121 | |
122 return icon; | |
123 } | |
124 | |
125 GaimBuddyIcon * | |
126 gaim_buddy_icon_unref(GaimBuddyIcon *icon) | |
127 { | |
128 g_return_val_if_fail(icon != NULL, NULL); | |
129 | |
130 if (icon->ref_count <= 0) | |
131 return NULL; | |
132 | |
133 icon->ref_count--; | |
134 | |
135 if (icon->ref_count == 0) | |
136 { | |
137 gaim_buddy_icon_destroy(icon); | |
138 | |
139 return NULL; | |
140 } | |
141 | |
142 return icon; | |
143 } | |
144 | |
145 void | |
146 gaim_buddy_icon_update(GaimBuddyIcon *icon) | |
147 { | |
148 GaimConversation *conv; | |
149 GaimAccount *account; | |
150 const char *username; | |
151 GSList *sl; | |
152 | |
153 g_return_if_fail(icon != NULL); | |
154 | |
155 account = gaim_buddy_icon_get_account(icon); | |
156 username = gaim_buddy_icon_get_username(icon); | |
157 | |
158 for (sl = gaim_find_buddies(account, username); sl != NULL; sl = sl->next) | |
159 { | |
160 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
161 | |
162 gaim_buddy_set_icon(buddy, icon); | |
163 } | |
164 | |
165 conv = gaim_find_conversation_with_account(username, account); | |
166 | |
167 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
|
168 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), icon); |
6846 | 169 } |
170 | |
171 void | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
172 gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy) |
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 const void *data; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
175 const char *dirname; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
176 char *random; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
177 char *filename; |
7125 | 178 const char *old_icon; |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
179 size_t len; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
180 FILE *file = NULL; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
181 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
182 g_return_if_fail(icon != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
183 g_return_if_fail(buddy != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
184 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
185 if (!gaim_buddy_icons_is_caching()) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
186 return; |
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 data = gaim_buddy_icon_get_data(icon, &len); |
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 random = g_strdup_printf("%x", g_random_int()); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
191 dirname = gaim_buddy_icons_get_cache_dir(); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
192 filename = g_build_filename(dirname, random, NULL); |
7721 | 193 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
|
194 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
195 g_free(random); |
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 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
198 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
199 gaim_debug_info("buddy icons", "Creating icon cache directory.\n"); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
200 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
201 if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
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 gaim_debug_error("buddy icons", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
204 "Unable to create directory %s: %s\n", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
205 dirname, strerror(errno)); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
206 } |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
209 if ((file = fopen(filename, "wb")) != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
210 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
211 fwrite(data, 1, len, file); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
212 fclose(file); |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
215 if (old_icon != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
216 unlink(old_icon); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
217 |
7721 | 218 gaim_blist_node_set_string((GaimBlistNode*)buddy, "buddy_icon", filename); |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
219 gaim_blist_save(); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
220 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
221 g_free(filename); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
222 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
223 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
224 void |
6846 | 225 gaim_buddy_icon_set_account(GaimBuddyIcon *icon, GaimAccount *account) |
226 { | |
227 g_return_if_fail(icon != NULL); | |
228 g_return_if_fail(account != NULL); | |
229 | |
230 icon->account = account; | |
231 } | |
232 | |
233 void | |
234 gaim_buddy_icon_set_username(GaimBuddyIcon *icon, const char *username) | |
235 { | |
236 g_return_if_fail(icon != NULL); | |
237 g_return_if_fail(username != NULL); | |
238 | |
239 if (icon->username != NULL) | |
240 g_free(icon->username); | |
241 | |
242 icon->username = g_strdup(username); | |
243 } | |
244 | |
245 void | |
246 gaim_buddy_icon_set_data(GaimBuddyIcon *icon, void *data, size_t len) | |
247 { | |
248 g_return_if_fail(icon != NULL); | |
249 | |
250 if (icon->data != NULL) | |
251 g_free(icon->data); | |
252 | |
253 if (data != NULL && len > 0) | |
254 { | |
255 icon->data = g_memdup(data, len); | |
256 icon->len = len; | |
257 } | |
258 else | |
259 { | |
260 icon->data = NULL; | |
261 icon->len = 0; | |
262 } | |
263 | |
264 gaim_buddy_icon_update(icon); | |
265 } | |
266 | |
267 GaimAccount * | |
268 gaim_buddy_icon_get_account(const GaimBuddyIcon *icon) | |
269 { | |
270 g_return_val_if_fail(icon != NULL, NULL); | |
271 | |
272 return icon->account; | |
273 } | |
274 | |
275 const char * | |
276 gaim_buddy_icon_get_username(const GaimBuddyIcon *icon) | |
277 { | |
278 g_return_val_if_fail(icon != NULL, NULL); | |
279 | |
280 return icon->username; | |
281 } | |
282 | |
283 const void * | |
284 gaim_buddy_icon_get_data(const GaimBuddyIcon *icon, size_t *len) | |
285 { | |
286 g_return_val_if_fail(icon != NULL, NULL); | |
287 | |
288 if (len != NULL) | |
289 *len = icon->len; | |
290 | |
291 return icon->data; | |
292 } | |
293 | |
294 void | |
295 gaim_buddy_icons_set_for_user(GaimAccount *account, const char *username, | |
296 void *icon_data, size_t icon_len) | |
297 { | |
298 g_return_if_fail(account != NULL); | |
299 g_return_if_fail(username != NULL); | |
300 | |
301 gaim_buddy_icon_new(account, username, icon_data, icon_len); | |
302 } | |
303 | |
304 GaimBuddyIcon * | |
305 gaim_buddy_icons_find(const GaimAccount *account, const char *username) | |
306 { | |
307 GHashTable *icon_cache; | |
308 | |
309 g_return_val_if_fail(account != NULL, NULL); | |
310 g_return_val_if_fail(username != NULL, NULL); | |
311 | |
312 icon_cache = g_hash_table_lookup(account_cache, account); | |
313 | |
314 if (icon_cache == NULL) | |
315 return NULL; | |
316 | |
317 return g_hash_table_lookup(icon_cache, username); | |
318 } | |
319 | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
320 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
321 gaim_buddy_icons_set_caching(gboolean 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 icon_caching = caching; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
324 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
325 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
326 gboolean |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
327 gaim_buddy_icons_is_caching(void) |
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 return icon_caching; |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
332 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
333 gaim_buddy_icons_set_cache_dir(const char *dir) |
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 g_return_if_fail(cache_dir != NULL); |
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 if (cache_dir != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
338 g_free(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 cache_dir = g_strdup(dir); |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
343 const char * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
344 gaim_buddy_icons_get_cache_dir(void) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
345 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
346 return cache_dir; |
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 |
6846 | 349 void * |
350 gaim_buddy_icons_get_handle() | |
351 { | |
352 static int handle; | |
353 | |
354 return &handle; | |
355 } | |
356 | |
357 void | |
358 gaim_buddy_icons_init() | |
359 { | |
360 account_cache = g_hash_table_new_full( | |
361 g_direct_hash, g_direct_equal, | |
362 NULL, (GFreeFunc)g_hash_table_destroy); | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
363 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
364 cache_dir = g_build_filename(gaim_user_dir(), "icons", NULL); |
6846 | 365 } |
366 | |
367 void | |
368 gaim_buddy_icons_uninit() | |
369 { | |
370 g_hash_table_destroy(account_cache); | |
371 } |