Mercurial > pidgin
annotate src/buddyicon.h @ 13119:fcde3faa1f57
[gaim-migrate @ 15481]
This adds support for displaying log timestamps in their original timezone. If your OS's definition of struct tm sucks, then the log timestamps will show up in your local timezone, but converted, so the time is accurate. Yay! Anyway, this all works, as I've renamed lots of my log files locally, but currently, there's no code to save new logs in this name format. That's held up on a portability issue and backwards compatibility issue.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 04 Feb 2006 20:55:52 +0000 |
parents | fc464a0abccc |
children | 6fc412e59214 |
rev | line source |
---|---|
6846 | 1 /** |
6869 | 2 * @file buddyicon.h Buddy Icon API |
6846 | 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 */ | |
9713 | 25 #ifndef _GAIM_BUDDYICON_H_ |
26 #define _GAIM_BUDDYICON_H_ | |
6846 | 27 |
28 typedef struct _GaimBuddyIcon GaimBuddyIcon; | |
29 | |
30 #include "account.h" | |
9718 | 31 #include "blist.h" |
10483 | 32 #include "prpl.h" |
6846 | 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 /**************************************************************************/ | |
46 /** @name Buddy Icon API */ | |
47 /**************************************************************************/ | |
48 /*@{*/ | |
49 | |
50 /** | |
51 * Creates a new buddy icon structure. | |
52 * | |
53 * @param account The account the user is on. | |
54 * @param username The username the icon belongs to. | |
55 * @param icon_data The buddy icon data. | |
56 * @param icon_len The buddy icon length. | |
57 * | |
58 * @return The buddy icon structure. | |
59 */ | |
60 GaimBuddyIcon *gaim_buddy_icon_new(GaimAccount *account, const char *username, | |
61 void *icon_data, size_t icon_len); | |
62 | |
63 /** | |
64 * Destroys a buddy icon structure. | |
65 * | |
66 * If the buddy icon's reference count is greater than 1, this will | |
67 * just decrease the reference count and return. | |
68 * | |
69 * @param icon The buddy icon structure to destroy. | |
70 */ | |
71 void gaim_buddy_icon_destroy(GaimBuddyIcon *icon); | |
72 | |
73 /** | |
74 * Increments the reference count on a buddy icon. | |
75 * | |
76 * @param icon The buddy icon. | |
77 * | |
78 * @return @a icon. | |
79 */ | |
80 GaimBuddyIcon *gaim_buddy_icon_ref(GaimBuddyIcon *icon); | |
81 | |
82 /** | |
83 * Decrements the reference count on a buddy icon. | |
84 * | |
85 * If the reference count reaches 0, the icon will be destroyed. | |
86 * | |
87 * @param icon The buddy icon. | |
88 * | |
89 * @return @a icon, or @c NULL if the reference count reached 0. | |
90 */ | |
91 GaimBuddyIcon *gaim_buddy_icon_unref(GaimBuddyIcon *icon); | |
92 | |
93 /** | |
94 * Updates every instance of this icon. | |
95 * | |
96 * @param icon The buddy icon. | |
97 */ | |
98 void gaim_buddy_icon_update(GaimBuddyIcon *icon); | |
99 | |
100 /** | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
101 * Caches a buddy icon associated with a specific buddy to disk. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
102 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
103 * @param icon The buddy icon. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
104 * @param buddy The buddy that this icon belongs to. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
105 */ |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
106 void gaim_buddy_icon_cache(GaimBuddyIcon *icon, GaimBuddy *buddy); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
107 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
108 /** |
11040
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
109 * Removes cached buddy icon for a specific buddy. |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
110 * |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
111 * @param buddy The buddy for which to remove the cached icon. |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
112 */ |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
113 void gaim_buddy_icon_uncache(GaimBuddy *buddy); |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
114 |
3428ad6f5049
[gaim-migrate @ 12940]
Richard Laager <rlaager@wiktel.com>
parents:
10953
diff
changeset
|
115 /** |
6846 | 116 * Sets the buddy icon's account. |
117 * | |
118 * @param icon The buddy icon. | |
119 * @param account The account. | |
120 */ | |
121 void gaim_buddy_icon_set_account(GaimBuddyIcon *icon, GaimAccount *account); | |
122 | |
123 /** | |
124 * Sets the buddy icon's username. | |
125 * | |
126 * @param icon The buddy icon. | |
127 * @param username The username. | |
128 */ | |
129 void gaim_buddy_icon_set_username(GaimBuddyIcon *icon, const char *username); | |
130 | |
131 /** | |
132 * Sets the buddy icon's icon data. | |
133 * | |
134 * @param icon The buddy icon. | |
135 * @param data The buddy icon data. | |
136 * @param len The length of the icon data. | |
137 */ | |
138 void gaim_buddy_icon_set_data(GaimBuddyIcon *icon, void *data, size_t len); | |
139 | |
140 /** | |
141 * Returns the buddy icon's account. | |
142 * | |
143 * @param icon The buddy icon. | |
144 * | |
145 * @return The account. | |
146 */ | |
147 GaimAccount *gaim_buddy_icon_get_account(const GaimBuddyIcon *icon); | |
148 | |
149 /** | |
150 * Returns the buddy icon's username. | |
151 * | |
152 * @param icon The buddy icon. | |
153 * | |
154 * @return The username. | |
155 */ | |
156 const char *gaim_buddy_icon_get_username(const GaimBuddyIcon *icon); | |
157 | |
158 /** | |
159 * Returns the buddy icon's data. | |
160 * | |
161 * @param icon The buddy icon. | |
162 * @param len The returned icon length. | |
163 * | |
164 * @return The icon data. | |
165 */ | |
11137 | 166 const guchar *gaim_buddy_icon_get_data(const GaimBuddyIcon *icon, size_t *len); |
6846 | 167 |
10953 | 168 /** |
169 * Returns an extension corresponding to the buddy icon's file type. | |
170 * | |
171 * @param icon The buddy icon. | |
172 * | |
173 * @return The icon's extension. | |
174 */ | |
175 const char *gaim_buddy_icon_get_type(const GaimBuddyIcon *icon); | |
176 | |
6846 | 177 /*@}*/ |
178 | |
179 /**************************************************************************/ | |
180 /** @name Buddy Icon Subsystem API */ | |
181 /**************************************************************************/ | |
182 /*@{*/ | |
183 | |
184 /** | |
185 * Sets a buddy icon for a user. | |
186 * | |
187 * @param account The account the user is on. | |
188 * @param username The username of the user. | |
189 * @param icon_data The icon data. | |
190 * @param icon_len The length of the icon data. | |
191 */ | |
192 void gaim_buddy_icons_set_for_user(GaimAccount *account, const char *username, | |
193 void *icon_data, size_t icon_len); | |
194 | |
195 /** | |
196 * Returns the buddy icon information for a user. | |
197 * | |
198 * @param account The account the user is on. | |
199 * @param username The username of the user. | |
200 * | |
201 * @return The icon data if found, or @c NULL if not found. | |
202 */ | |
9396 | 203 GaimBuddyIcon *gaim_buddy_icons_find(GaimAccount *account, |
6846 | 204 const char *username); |
205 | |
206 /** | |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
207 * Sets whether or not buddy icon caching is enabled. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
208 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
209 * @param caching TRUE of buddy icon caching should be enabled, or |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
210 * FALSE otherwise. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
211 */ |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
212 void gaim_buddy_icons_set_caching(gboolean caching); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
213 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
214 /** |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
215 * Returns whether or not buddy icon caching should be enabled. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
216 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
217 * The default is TRUE, unless otherwise specified by |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
218 * gaim_buddy_icons_set_caching(). |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
219 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
220 * @return TRUE if buddy icon caching is enabled, or FALSE otherwise. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
221 */ |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
222 gboolean gaim_buddy_icons_is_caching(void); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
223 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
224 /** |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
225 * Sets the directory used to store buddy icon cache files. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
226 * |
7114
c47633e9e2a4
[gaim-migrate @ 7681]
Christian Hammond <chipx86@chipx86.com>
parents:
6886
diff
changeset
|
227 * @param cache_dir The directory to store buddy icon cache files to. |
6886
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
228 */ |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
229 void gaim_buddy_icons_set_cache_dir(const char *cache_dir); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
230 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
231 /** |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
232 * Returns the directory used to store buddy icon cache files. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
233 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
234 * The default directory is GAIMDIR/icons, unless otherwise specified |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
235 * by gaim_buddy_icons_set_cache_dir(). |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
236 * |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
237 * @return The directory to store buddy icon cache files to. |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
238 */ |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
239 const char *gaim_buddy_icons_get_cache_dir(void); |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
240 |
b5fb1d5282e5
[gaim-migrate @ 7432]
Christian Hammond <chipx86@chipx86.com>
parents:
6869
diff
changeset
|
241 /** |
11303
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
242 * Takes a buddy icon and returns a full path. |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
243 * |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
244 * If @a icon is a full path to an existing file, a copy of |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
245 * @a icon is returned. Otherwise, a newly allocated string |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
246 * consiting of gaim_buddy_icons_get_cache_dir() + @a icon is |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
247 * returned. |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
248 * |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
249 * @return The full path for an icon. |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
250 */ |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
251 char *gaim_buddy_icons_get_full_path(const char *icon); |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
252 |
10066662176a
[gaim-migrate @ 13503]
Richard Laager <rlaager@wiktel.com>
parents:
11137
diff
changeset
|
253 /** |
6846 | 254 * Returns the buddy icon subsystem handle. |
255 * | |
256 * @return The subsystem handle. | |
257 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
258 void *gaim_buddy_icons_get_handle(void); |
6846 | 259 |
260 /** | |
261 * Initializes the buddy icon subsystem. | |
262 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
263 void gaim_buddy_icons_init(void); |
6846 | 264 |
265 /** | |
266 * Uninitializes the buddy icon subsystem. | |
267 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
11303
diff
changeset
|
268 void gaim_buddy_icons_uninit(void); |
6846 | 269 |
270 /*@}*/ | |
271 | |
10483 | 272 /**************************************************************************/ |
273 /** @name Buddy Icon Helper API */ | |
274 /**************************************************************************/ | |
275 /*@{*/ | |
276 | |
277 /** | |
278 * Gets display size for a buddy icon | |
279 */ | |
280 void gaim_buddy_icon_get_scale_size(GaimBuddyIconSpec *spec, int *width, int *height); | |
281 | |
282 /*@}*/ | |
283 | |
9713 | 284 #endif /* _GAIM_BUDDYICON_H_ */ |