| |
1 /** |
| |
2 * @file buddyicon.h Buddy Icon API |
| |
3 * @ingroup core |
| |
4 * |
| |
5 * gaim |
| |
6 * |
| |
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. |
| |
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 #ifndef _GAIM_BUDDYICON_H_ |
| |
26 #define _GAIM_BUDDYICON_H_ |
| |
27 |
| |
28 typedef struct _GaimBuddyIcon GaimBuddyIcon; |
| |
29 |
| |
30 #include "account.h" |
| |
31 #include "blist.h" |
| |
32 #include "prpl.h" |
| |
33 |
| |
34 struct _GaimBuddyIcon |
| |
35 { |
| |
36 GaimAccount *account; /**< The account the user is on. */ |
| |
37 char *username; /**< The username the icon belongs to. */ |
| |
38 |
| |
39 void *data; /**< The buddy icon data. */ |
| |
40 size_t len; /**< The length of the buddy icon data. */ |
| |
41 |
| |
42 int ref_count; /**< The buddy icon reference count. */ |
| |
43 }; |
| |
44 |
| |
45 #ifdef __cplusplus |
| |
46 extern "C" { |
| |
47 #endif |
| |
48 |
| |
49 /**************************************************************************/ |
| |
50 /** @name Buddy Icon API */ |
| |
51 /**************************************************************************/ |
| |
52 /*@{*/ |
| |
53 |
| |
54 /** |
| |
55 * Creates a new buddy icon structure. |
| |
56 * |
| |
57 * @param account The account the user is on. |
| |
58 * @param username The username the icon belongs to. |
| |
59 * @param icon_data The buddy icon data. |
| |
60 * @param icon_len The buddy icon length. |
| |
61 * |
| |
62 * @return The buddy icon structure. |
| |
63 */ |
| |
64 GaimBuddyIcon *gaim_buddy_icon_new(GaimAccount *account, const char *username, |
| |
65 void *icon_data, size_t icon_len); |
| |
66 |
| |
67 /** |
| |
68 * Destroys a buddy icon structure. |
| |
69 * |
| |
70 * If the buddy icon's reference count is greater than 1, this will |
| |
71 * just decrease the reference count and return. |
| |
72 * |
| |
73 * @param icon The buddy icon structure to destroy. |
| |
74 */ |
| |
75 void gaim_buddy_icon_destroy(GaimBuddyIcon *icon); |
| |
76 |
| |
77 /** |
| |
78 * Increments the reference count on a buddy icon. |
| |
79 * |
| |
80 * @param icon The buddy icon. |
| |
81 * |
| |
82 * @return @a icon. |
| |
83 */ |
| |
84 GaimBuddyIcon *gaim_buddy_icon_ref(GaimBuddyIcon *icon); |
| |
85 |
| |
86 /** |
| |
87 * Decrements the reference count on a buddy icon. |
| |
88 * |
| |
89 * If the reference count reaches 0, the icon will be destroyed. |
| |
90 * |
| |
91 * @param icon The buddy icon. |
| |
92 * |
| |
93 * @return @a icon, or @c NULL if the reference count reached 0. |
| |
94 */ |
| |
95 GaimBuddyIcon *gaim_buddy_icon_unref(GaimBuddyIcon *icon); |
| |
96 |
| |
97 /** |
| |
98 * Updates every instance of this icon. |
| |
99 * |
| |
100 * @param icon The buddy icon. |
| |
101 */ |
| |
102 void gaim_buddy_icon_update(GaimBuddyIcon *icon); |
| |
103 |
| |
104 /** |
| |
105 * Caches a buddy icon associated with a specific buddy to disk. |
| |
106 * |
| |
107 * @param icon The buddy icon. |
| |
108 * @param buddy The buddy that this icon belongs to. |
| |
109 */ |
| |
110 void gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy); |
| |
111 |
| |
112 /** |
| |
113 * Removes cached buddy icon for a specific buddy. |
| |
114 * |
| |
115 * @param buddy The buddy for which to remove the cached icon. |
| |
116 */ |
| |
117 void gaim_buddy_icon_uncache(GaimBuddy *buddy); |
| |
118 |
| |
119 /** |
| |
120 * Sets the buddy icon's account. |
| |
121 * |
| |
122 * @param icon The buddy icon. |
| |
123 * @param account The account. |
| |
124 */ |
| |
125 void gaim_buddy_icon_set_account(GaimBuddyIcon *icon, GaimAccount *account); |
| |
126 |
| |
127 /** |
| |
128 * Sets the buddy icon's username. |
| |
129 * |
| |
130 * @param icon The buddy icon. |
| |
131 * @param username The username. |
| |
132 */ |
| |
133 void gaim_buddy_icon_set_username(GaimBuddyIcon *icon, const char *username); |
| |
134 |
| |
135 /** |
| |
136 * Sets the buddy icon's icon data. |
| |
137 * |
| |
138 * @param icon The buddy icon. |
| |
139 * @param data The buddy icon data. |
| |
140 * @param len The length of the icon data. |
| |
141 */ |
| |
142 void gaim_buddy_icon_set_data(GaimBuddyIcon *icon, void *data, size_t len); |
| |
143 |
| |
144 /** |
| |
145 * Returns the buddy icon's account. |
| |
146 * |
| |
147 * @param icon The buddy icon. |
| |
148 * |
| |
149 * @return The account. |
| |
150 */ |
| |
151 GaimAccount *gaim_buddy_icon_get_account(const GaimBuddyIcon *icon); |
| |
152 |
| |
153 /** |
| |
154 * Returns the buddy icon's username. |
| |
155 * |
| |
156 * @param icon The buddy icon. |
| |
157 * |
| |
158 * @return The username. |
| |
159 */ |
| |
160 const char *gaim_buddy_icon_get_username(const GaimBuddyIcon *icon); |
| |
161 |
| |
162 /** |
| |
163 * Returns the buddy icon's data. |
| |
164 * |
| |
165 * @param icon The buddy icon. |
| |
166 * @param len The returned icon length. |
| |
167 * |
| |
168 * @return The icon data. |
| |
169 */ |
| |
170 const guchar *gaim_buddy_icon_get_data(const GaimBuddyIcon *icon, size_t *len); |
| |
171 |
| |
172 /** |
| |
173 * Returns an extension corresponding to the buddy icon's file type. |
| |
174 * |
| |
175 * @param icon The buddy icon. |
| |
176 * |
| |
177 * @return The icon's extension. |
| |
178 */ |
| |
179 const char *gaim_buddy_icon_get_type(const GaimBuddyIcon *icon); |
| |
180 |
| |
181 /*@}*/ |
| |
182 |
| |
183 /**************************************************************************/ |
| |
184 /** @name Buddy Icon Subsystem API */ |
| |
185 /**************************************************************************/ |
| |
186 /*@{*/ |
| |
187 |
| |
188 /** |
| |
189 * Sets a buddy icon for a user. |
| |
190 * |
| |
191 * @param account The account the user is on. |
| |
192 * @param username The username of the user. |
| |
193 * @param icon_data The icon data. |
| |
194 * @param icon_len The length of the icon data. |
| |
195 */ |
| |
196 void gaim_buddy_icons_set_for_user(GaimAccount *account, const char *username, |
| |
197 void *icon_data, size_t icon_len); |
| |
198 |
| |
199 /** |
| |
200 * Returns the buddy icon information for a user. |
| |
201 * |
| |
202 * @param account The account the user is on. |
| |
203 * @param username The username of the user. |
| |
204 * |
| |
205 * @return The icon data if found, or @c NULL if not found. |
| |
206 */ |
| |
207 GaimBuddyIcon *gaim_buddy_icons_find(GaimAccount *account, |
| |
208 const char *username); |
| |
209 |
| |
210 /** |
| |
211 * Sets whether or not buddy icon caching is enabled. |
| |
212 * |
| |
213 * @param caching TRUE of buddy icon caching should be enabled, or |
| |
214 * FALSE otherwise. |
| |
215 */ |
| |
216 void gaim_buddy_icons_set_caching(gboolean caching); |
| |
217 |
| |
218 /** |
| |
219 * Returns whether or not buddy icon caching should be enabled. |
| |
220 * |
| |
221 * The default is TRUE, unless otherwise specified by |
| |
222 * gaim_buddy_icons_set_caching(). |
| |
223 * |
| |
224 * @return TRUE if buddy icon caching is enabled, or FALSE otherwise. |
| |
225 */ |
| |
226 gboolean gaim_buddy_icons_is_caching(void); |
| |
227 |
| |
228 /** |
| |
229 * Sets the directory used to store buddy icon cache files. |
| |
230 * |
| |
231 * @param cache_dir The directory to store buddy icon cache files to. |
| |
232 */ |
| |
233 void gaim_buddy_icons_set_cache_dir(const char *cache_dir); |
| |
234 |
| |
235 /** |
| |
236 * Returns the directory used to store buddy icon cache files. |
| |
237 * |
| |
238 * The default directory is GAIMDIR/icons, unless otherwise specified |
| |
239 * by gaim_buddy_icons_set_cache_dir(). |
| |
240 * |
| |
241 * @return The directory to store buddy icon cache files to. |
| |
242 */ |
| |
243 const char *gaim_buddy_icons_get_cache_dir(void); |
| |
244 |
| |
245 /** |
| |
246 * Takes a buddy icon and returns a full path. |
| |
247 * |
| |
248 * If @a icon is a full path to an existing file, a copy of |
| |
249 * @a icon is returned. Otherwise, a newly allocated string |
| |
250 * consiting of gaim_buddy_icons_get_cache_dir() + @a icon is |
| |
251 * returned. |
| |
252 * |
| |
253 * @return The full path for an icon. |
| |
254 */ |
| |
255 char *gaim_buddy_icons_get_full_path(const char *icon); |
| |
256 |
| |
257 /** |
| |
258 * Returns the buddy icon subsystem handle. |
| |
259 * |
| |
260 * @return The subsystem handle. |
| |
261 */ |
| |
262 void *gaim_buddy_icons_get_handle(void); |
| |
263 |
| |
264 /** |
| |
265 * Initializes the buddy icon subsystem. |
| |
266 */ |
| |
267 void gaim_buddy_icons_init(void); |
| |
268 |
| |
269 /** |
| |
270 * Uninitializes the buddy icon subsystem. |
| |
271 */ |
| |
272 void gaim_buddy_icons_uninit(void); |
| |
273 |
| |
274 /*@}*/ |
| |
275 |
| |
276 /**************************************************************************/ |
| |
277 /** @name Buddy Icon Helper API */ |
| |
278 /**************************************************************************/ |
| |
279 /*@{*/ |
| |
280 |
| |
281 /** |
| |
282 * Gets display size for a buddy icon |
| |
283 */ |
| |
284 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height); |
| |
285 |
| |
286 /*@}*/ |
| |
287 |
| |
288 #ifdef __cplusplus |
| |
289 } |
| |
290 #endif |
| |
291 |
| |
292 #endif /* _GAIM_BUDDYICON_H_ */ |