Mercurial > pidgin.yaz
annotate src/buddyicon.c @ 8378:2b68c423357e
[gaim-migrate @ 9105]
" For people and systems which have libzephyr installed
(e.g Debian), this will allow the zephyr plugin to
optionally be linked against it, instead of building
and linking in the libzephyr that comes with gaim.
Why?
1) A gaim binary package can be compiled against a
locally installed libzephyr.a, and use either
unkerberized or kerberized zephyr depending on which
version of the zephyr shared libraries is installed.
2) It reduces the build speed and size of the zephyr
plugin (on Debian x86, from 6.5 MB to ~ 300 kb)
Also, I added a zephyr icon (a blue Z), that's similar
to the icons used by Windows and MacOS zephyr clients
at MIT." --Arun A Tharuvai
someone will have to tell me how to fix the win32 makefiles, and i'm not
sure he patched enough to get his icon to be actually used.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 01 Mar 2004 18:08:42 +0000 |
parents | fa6395637e2c |
children | 52dca2f38956 |
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; | |
153 GSList *sl; | |
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 | |
160 for (sl = gaim_find_buddies(account, username); sl != NULL; sl = sl->next) | |
161 { | |
162 GaimBuddy *buddy = (GaimBuddy *)sl->data; | |
163 | |
164 gaim_buddy_set_icon(buddy, icon); | |
165 } | |
166 | |
167 conv = gaim_find_conversation_with_account(username, account); | |
168 | |
169 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
|
170 gaim_conv_im_set_icon(GAIM_CONV_IM(conv), icon); |
6846 | 171 } |
172 | |
173 void | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
174 gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
175 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
176 const void *data; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
177 const char *dirname; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
178 char *random; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
179 char *filename; |
7125 | 180 const char *old_icon; |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
181 size_t len; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
182 FILE *file = NULL; |
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_return_if_fail(icon != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
185 g_return_if_fail(buddy != 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 if (!gaim_buddy_icons_is_caching()) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
188 return; |
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 data = gaim_buddy_icon_get_data(icon, &len); |
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 random = g_strdup_printf("%x", g_random_int()); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
193 dirname = gaim_buddy_icons_get_cache_dir(); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
194 filename = g_build_filename(dirname, random, NULL); |
7721 | 195 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
|
196 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
197 g_free(random); |
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 if (!g_file_test(dirname, G_FILE_TEST_IS_DIR)) |
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 gaim_debug_info("buddy icons", "Creating icon cache directory.\n"); |
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 if (mkdir(dirname, S_IRUSR | S_IWUSR | S_IXUSR) < 0) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
204 { |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
205 gaim_debug_error("buddy icons", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
206 "Unable to create directory %s: %s\n", |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
207 dirname, strerror(errno)); |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
211 if ((file = fopen(filename, "wb")) != NULL) |
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 fwrite(data, 1, len, file); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
214 fclose(file); |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
217 if (old_icon != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
218 unlink(old_icon); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
219 |
7721 | 220 gaim_blist_node_set_string((GaimBlistNode*)buddy, "buddy_icon", filename); |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
221 gaim_blist_save(); |
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 g_free(filename); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
224 } |
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 void |
6846 | 227 gaim_buddy_icon_set_account(GaimBuddyIcon *icon, GaimAccount *account) |
228 { | |
229 g_return_if_fail(icon != NULL); | |
230 g_return_if_fail(account != NULL); | |
231 | |
232 icon->account = account; | |
233 } | |
234 | |
235 void | |
236 gaim_buddy_icon_set_username(GaimBuddyIcon *icon, const char *username) | |
237 { | |
238 g_return_if_fail(icon != NULL); | |
239 g_return_if_fail(username != NULL); | |
240 | |
241 if (icon->username != NULL) | |
242 g_free(icon->username); | |
243 | |
244 icon->username = g_strdup(username); | |
245 } | |
246 | |
247 void | |
248 gaim_buddy_icon_set_data(GaimBuddyIcon *icon, void *data, size_t len) | |
249 { | |
250 g_return_if_fail(icon != NULL); | |
251 | |
252 if (icon->data != NULL) | |
253 g_free(icon->data); | |
254 | |
255 if (data != NULL && len > 0) | |
256 { | |
257 icon->data = g_memdup(data, len); | |
258 icon->len = len; | |
259 } | |
260 else | |
261 { | |
262 icon->data = NULL; | |
263 icon->len = 0; | |
264 } | |
265 | |
266 gaim_buddy_icon_update(icon); | |
267 } | |
268 | |
269 GaimAccount * | |
270 gaim_buddy_icon_get_account(const GaimBuddyIcon *icon) | |
271 { | |
272 g_return_val_if_fail(icon != NULL, NULL); | |
273 | |
274 return icon->account; | |
275 } | |
276 | |
277 const char * | |
278 gaim_buddy_icon_get_username(const GaimBuddyIcon *icon) | |
279 { | |
280 g_return_val_if_fail(icon != NULL, NULL); | |
281 | |
282 return icon->username; | |
283 } | |
284 | |
285 const void * | |
286 gaim_buddy_icon_get_data(const GaimBuddyIcon *icon, size_t *len) | |
287 { | |
288 g_return_val_if_fail(icon != NULL, NULL); | |
289 | |
290 if (len != NULL) | |
291 *len = icon->len; | |
292 | |
293 return icon->data; | |
294 } | |
295 | |
296 void | |
297 gaim_buddy_icons_set_for_user(GaimAccount *account, const char *username, | |
298 void *icon_data, size_t icon_len) | |
299 { | |
300 g_return_if_fail(account != NULL); | |
301 g_return_if_fail(username != NULL); | |
302 | |
303 gaim_buddy_icon_new(account, username, icon_data, icon_len); | |
304 } | |
305 | |
306 GaimBuddyIcon * | |
307 gaim_buddy_icons_find(const GaimAccount *account, const char *username) | |
308 { | |
309 GHashTable *icon_cache; | |
310 | |
311 g_return_val_if_fail(account != NULL, NULL); | |
312 g_return_val_if_fail(username != NULL, NULL); | |
313 | |
314 icon_cache = g_hash_table_lookup(account_cache, account); | |
315 | |
316 if (icon_cache == NULL) | |
317 return NULL; | |
318 | |
319 return g_hash_table_lookup(icon_cache, username); | |
320 } | |
321 | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
322 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
323 gaim_buddy_icons_set_caching(gboolean 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 icon_caching = caching; |
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 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
328 gboolean |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
329 gaim_buddy_icons_is_caching(void) |
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 return icon_caching; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
332 } |
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 void |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
335 gaim_buddy_icons_set_cache_dir(const char *dir) |
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 g_return_if_fail(cache_dir != NULL); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
338 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
339 if (cache_dir != NULL) |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
340 g_free(cache_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 cache_dir = g_strdup(dir); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
343 } |
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 const char * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
346 gaim_buddy_icons_get_cache_dir(void) |
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 return cache_dir; |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
349 } |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
350 |
6846 | 351 void * |
352 gaim_buddy_icons_get_handle() | |
353 { | |
354 static int handle; | |
355 | |
356 return &handle; | |
357 } | |
358 | |
359 void | |
360 gaim_buddy_icons_init() | |
361 { | |
362 account_cache = g_hash_table_new_full( | |
363 g_direct_hash, g_direct_equal, | |
364 NULL, (GFreeFunc)g_hash_table_destroy); | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
365 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6846
diff
changeset
|
366 cache_dir = g_build_filename(gaim_user_dir(), "icons", NULL); |
6846 | 367 } |
368 | |
369 void | |
370 gaim_buddy_icons_uninit() | |
371 { | |
372 g_hash_table_destroy(account_cache); | |
373 } |