Mercurial > pidgin
annotate src/value.h @ 11849:dc51cdcb648e
[gaim-migrate @ 14140]
sf patch #1339135, from Sadrul Habib Chowdhury
Hi. Bleeter found this bug:
(1) open up some conversation window
(2) open the smiley dialog
(3) close the conversation window. the smiley dialog
remains open
(4) select some smiley
(5) Gaim crashes
This patch fixes this crash. It shouldn't cause any
probs with regards to gtk-version-checking. The other
code handling the smiley-dialog doesn't do the
version-checking, so this shouldn't be necessary either.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 27 Oct 2005 12:00:17 +0000 |
parents | 185ca25b5c7e |
children | 717cbb3115bc |
rev | line source |
---|---|
6562 | 1 /** |
2 * @file value.h Value wrapper 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. | |
6562 | 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_VALUE_H_ | |
26 #define _GAIM_VALUE_H_ | |
27 | |
6565
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
28 #include <glib.h> |
cb00e9647033
[gaim-migrate @ 7087]
Christian Hammond <chipx86@chipx86.com>
parents:
6563
diff
changeset
|
29 |
6562 | 30 /** |
31 * Specific value types. | |
32 */ | |
33 typedef enum | |
34 { | |
35 GAIM_TYPE_UNKNOWN = 0, /**< Unknown type. */ | |
36 GAIM_TYPE_SUBTYPE, /**< Subtype. */ | |
37 GAIM_TYPE_CHAR, /**< Character. */ | |
38 GAIM_TYPE_UCHAR, /**< Unsigned character. */ | |
39 GAIM_TYPE_BOOLEAN, /**< Boolean. */ | |
40 GAIM_TYPE_SHORT, /**< Short integer. */ | |
41 GAIM_TYPE_USHORT, /**< Unsigned short integer. */ | |
42 GAIM_TYPE_INT, /**< Integer. */ | |
43 GAIM_TYPE_UINT, /**< Unsigned integer. */ | |
44 GAIM_TYPE_LONG, /**< Long integer. */ | |
45 GAIM_TYPE_ULONG, /**< Unsigned long integer. */ | |
46 GAIM_TYPE_INT64, /**< 64-bit integer. */ | |
47 GAIM_TYPE_UINT64, /**< 64-bit unsigned integer. */ | |
48 GAIM_TYPE_STRING, /**< String. */ | |
49 GAIM_TYPE_OBJECT, /**< Object pointer. */ | |
50 GAIM_TYPE_POINTER, /**< Generic pointer. */ | |
51 GAIM_TYPE_ENUM, /**< Enum. */ | |
52 GAIM_TYPE_BOXED /**< Boxed pointer with specific type. */ | |
53 | |
54 } GaimType; | |
55 | |
56 /** | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
57 * Gaim-specific subtype values. |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
58 */ |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
59 typedef enum |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
60 { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
61 GAIM_SUBTYPE_UNKNOWN = 0, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
62 GAIM_SUBTYPE_ACCOUNT, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
63 GAIM_SUBTYPE_BLIST, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
64 GAIM_SUBTYPE_BLIST_BUDDY, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
65 GAIM_SUBTYPE_BLIST_GROUP, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
66 GAIM_SUBTYPE_BLIST_CHAT, |
10934 | 67 GAIM_SUBTYPE_BUDDY_ICON, |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
68 GAIM_SUBTYPE_CONNECTION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
69 GAIM_SUBTYPE_CONVERSATION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
70 GAIM_SUBTYPE_CONV_WINDOW, |
8817 | 71 GAIM_SUBTYPE_PLUGIN, |
10684
72a5babfa8b4
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10477
diff
changeset
|
72 GAIM_SUBTYPE_BLIST_NODE, |
72a5babfa8b4
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10477
diff
changeset
|
73 GAIM_SUBTYPE_CIPHER |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
74 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
75 } GaimSubType; |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
76 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
77 /** |
6562 | 78 * A wrapper for a type, subtype, and specific type of value. |
79 */ | |
80 typedef struct | |
81 { | |
82 GaimType type; | |
83 unsigned short flags; | |
84 | |
85 union | |
86 { | |
87 char char_data; | |
88 unsigned char uchar_data; | |
89 gboolean boolean_data; | |
90 short short_data; | |
91 unsigned short ushort_data; | |
92 int int_data; | |
93 unsigned int uint_data; | |
94 long long_data; | |
95 unsigned long ulong_data; | |
96 gint64 int64_data; | |
97 guint64 uint64_data; | |
98 char *string_data; | |
99 void *object_data; | |
100 void *pointer_data; | |
101 int enum_data; | |
102 void *boxed_data; | |
103 | |
104 } data; | |
105 | |
106 union | |
107 { | |
108 unsigned int subtype; | |
109 char *specific_type; | |
110 | |
111 } u; | |
112 | |
113 } GaimValue; | |
114 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
115 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
116 extern "C" { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
117 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
118 |
6562 | 119 /** |
120 * Creates a new GaimValue. | |
121 * | |
122 * This function takes a type and, depending on that type, a sub-type | |
123 * or specific type. | |
124 * | |
10477 | 125 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 126 * string representing the specific type. |
127 * | |
128 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
129 * integer or enum representing the sub-type. | |
130 * | |
131 * If the subtype or specific type is not set when required, random | |
132 * errors may occur. You have been warned. | |
133 * | |
134 * @param type The type. | |
135 * | |
136 * @return The new value. | |
137 */ | |
138 GaimValue *gaim_value_new(GaimType type, ...); | |
139 | |
140 /** | |
10477 | 141 * Creates a new outgoing GaimValue. If a value is an "outgoing" value |
142 * it means the value can be modified by plugins and scripts. | |
6562 | 143 * |
144 * This function takes a type and, depending on that type, a sub-type | |
145 * or specific type. | |
146 * | |
10477 | 147 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 148 * string representing the specific type. |
149 * | |
150 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
151 * integer or enum representing the sub-type. | |
152 * | |
153 * If the sub-type or specific type is not set when required, random | |
154 * errors may occur. You have been warned. | |
155 * | |
156 * @param type The type. | |
157 * | |
158 * @return The new value. | |
159 */ | |
160 GaimValue *gaim_value_new_outgoing(GaimType type, ...); | |
161 | |
162 /** | |
163 * Destroys a GaimValue. | |
164 * | |
165 * @param value The value to destroy. | |
166 */ | |
167 void gaim_value_destroy(GaimValue *value); | |
168 | |
169 /** | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
170 * Duplicated a GaimValue. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 * @param value The value to duplicate. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
173 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
174 * @return The duplicate value. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
175 */ |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 GaimValue *gaim_value_dup(const GaimValue *value); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 /** |
6562 | 179 * Returns a value's type. |
180 * | |
10071 | 181 * @param value The value whose type you want. |
182 * | |
6562 | 183 * @return The value's type. |
184 */ | |
185 GaimType gaim_value_get_type(const GaimValue *value); | |
186 | |
187 /** | |
188 * Returns a value's subtype. | |
189 * | |
190 * If the value's type is not GAIM_TYPE_SUBTYPE, this will return 0. | |
191 * Subtypes should never have a subtype of 0. | |
192 * | |
10071 | 193 * @param value The value whose subtype you want. |
194 * | |
6562 | 195 * @return The value's subtype, or 0 if @a type is not GAIM_TYPE_SUBTYPE. |
196 */ | |
197 unsigned int gaim_value_get_subtype(const GaimValue *value); | |
198 | |
199 /** | |
200 * Returns a value's specific type. | |
201 * | |
202 * If the value's type is not GAIM_TYPE_BOXED, this will return @c NULL. | |
203 * | |
10071 | 204 * @param value The value whose specific type you want. |
205 * | |
6562 | 206 * @return The value's specific type, or @a NULL if not GAIM_TYPE_BOXED. |
207 */ | |
208 const char *gaim_value_get_specific_type(const GaimValue *value); | |
209 | |
210 /** | |
211 * Returns whether or not the value is an outgoing value. | |
212 * | |
213 * @param value The value. | |
214 * | |
215 * @return TRUE if the value is outgoing, or FALSE otherwise. | |
216 */ | |
217 gboolean gaim_value_is_outgoing(const GaimValue *value); | |
218 | |
219 /** | |
220 * Sets the value's character data. | |
221 * | |
222 * @param value The value. | |
223 * @param data The character data. | |
224 */ | |
225 void gaim_value_set_char(GaimValue *value, char data); | |
226 | |
227 /** | |
228 * Sets the value's unsigned character data. | |
229 * | |
230 * @param value The value. | |
231 * @param data The unsigned character data. | |
232 */ | |
233 void gaim_value_set_uchar(GaimValue *value, unsigned char data); | |
234 | |
235 /** | |
236 * Sets the value's boolean data. | |
237 * | |
238 * @param value The value. | |
239 * @param data The boolean data. | |
240 */ | |
241 void gaim_value_set_boolean(GaimValue *value, gboolean data); | |
242 | |
243 /** | |
244 * Sets the value's short integer data. | |
245 * | |
246 * @param value The value. | |
247 * @param data The short integer data. | |
248 */ | |
249 void gaim_value_set_short(GaimValue *value, short data); | |
250 | |
251 /** | |
252 * Sets the value's unsigned short integer data. | |
253 * | |
254 * @param value The value. | |
255 * @param data The unsigned short integer data. | |
256 */ | |
257 void gaim_value_set_ushort(GaimValue *value, unsigned short data); | |
258 | |
259 /** | |
260 * Sets the value's integer data. | |
261 * | |
262 * @param value The value. | |
263 * @param data The integer data. | |
264 */ | |
265 void gaim_value_set_int(GaimValue *value, int data); | |
266 | |
267 /** | |
268 * Sets the value's unsigned integer data. | |
269 * | |
270 * @param value The value. | |
271 * @param data The unsigned integer data. | |
272 */ | |
273 void gaim_value_set_uint(GaimValue *value, unsigned int data); | |
274 | |
275 /** | |
276 * Sets the value's long integer data. | |
277 * | |
278 * @param value The value. | |
279 * @param data The long integer data. | |
280 */ | |
281 void gaim_value_set_long(GaimValue *value, long data); | |
282 | |
283 /** | |
284 * Sets the value's unsigned long integer data. | |
285 * | |
286 * @param value The value. | |
287 * @param data The unsigned long integer data. | |
288 */ | |
289 void gaim_value_set_ulong(GaimValue *value, unsigned long data); | |
290 | |
291 /** | |
292 * Sets the value's 64-bit integer data. | |
293 * | |
294 * @param value The value. | |
295 * @param data The 64-bit integer data. | |
296 */ | |
297 void gaim_value_set_int64(GaimValue *value, gint64 data); | |
298 | |
299 /** | |
300 * Sets the value's unsigned 64-bit integer data. | |
301 * | |
302 * @param value The value. | |
303 * @param data The unsigned 64-bit integer data. | |
304 */ | |
305 void gaim_value_set_uint64(GaimValue *value, guint64 data); | |
306 | |
307 /** | |
308 * Sets the value's string data. | |
309 * | |
310 * @param value The value. | |
311 * @param data The string data. | |
312 */ | |
313 void gaim_value_set_string(GaimValue *value, const char *data); | |
314 | |
315 /** | |
316 * Sets the value's object data. | |
317 * | |
318 * @param value The value. | |
319 * @param data The object data. | |
320 */ | |
321 void gaim_value_set_object(GaimValue *value, void *data); | |
322 | |
323 /** | |
324 * Sets the value's pointer data. | |
325 * | |
326 * @param value The value. | |
327 * @param data The pointer data. | |
328 */ | |
329 void gaim_value_set_pointer(GaimValue *value, void *data); | |
330 | |
331 /** | |
332 * Sets the value's enum data. | |
333 * | |
334 * @param value The value. | |
335 * @param data The enum data. | |
336 */ | |
337 void gaim_value_set_enum(GaimValue *value, int data); | |
338 | |
339 /** | |
340 * Sets the value's boxed data. | |
341 * | |
342 * @param value The value. | |
343 * @param data The boxed data. | |
344 */ | |
345 void gaim_value_set_boxed(GaimValue *value, void *data); | |
346 | |
347 /** | |
348 * Returns the value's character data. | |
349 * | |
350 * @param value The value. | |
351 * | |
352 * @return The character data. | |
353 */ | |
354 char gaim_value_get_char(const GaimValue *value); | |
355 | |
356 /** | |
357 * Returns the value's unsigned character data. | |
358 * | |
359 * @param value The value. | |
360 * | |
361 * @return The unsigned character data. | |
362 */ | |
363 unsigned char gaim_value_get_uchar(const GaimValue *value); | |
364 | |
365 /** | |
366 * Returns the value's boolean data. | |
367 * | |
368 * @param value The value. | |
369 * | |
370 * @return The boolean data. | |
371 */ | |
372 gboolean gaim_value_get_boolean(const GaimValue *value); | |
373 | |
374 /** | |
375 * Returns the value's short integer data. | |
376 * | |
377 * @param value The value. | |
378 * | |
379 * @return The short integer data. | |
380 */ | |
381 short gaim_value_get_short(const GaimValue *value); | |
382 | |
383 /** | |
384 * Returns the value's unsigned short integer data. | |
385 * | |
386 * @param value The value. | |
387 * | |
388 * @return The unsigned short integer data. | |
389 */ | |
390 unsigned short gaim_value_get_ushort(const GaimValue *value); | |
391 | |
392 /** | |
393 * Returns the value's integer data. | |
394 * | |
395 * @param value The value. | |
396 * | |
397 * @return The integer data. | |
398 */ | |
399 int gaim_value_get_int(const GaimValue *value); | |
400 | |
401 /** | |
402 * Returns the value's unsigned integer data. | |
403 * | |
404 * @param value The value. | |
405 * | |
406 * @return The unsigned integer data. | |
407 */ | |
408 unsigned int gaim_value_get_uint(const GaimValue *value); | |
409 | |
410 /** | |
411 * Returns the value's long integer data. | |
412 * | |
413 * @param value The value. | |
414 * | |
415 * @return The long integer data. | |
416 */ | |
417 long gaim_value_get_long(const GaimValue *value); | |
418 | |
419 /** | |
420 * Returns the value's unsigned long integer data. | |
421 * | |
422 * @param value The value. | |
423 * | |
424 * @return The unsigned long integer data. | |
425 */ | |
426 unsigned long gaim_value_get_ulong(const GaimValue *value); | |
427 | |
428 /** | |
429 * Returns the value's 64-bit integer data. | |
430 * | |
431 * @param value The value. | |
432 * | |
433 * @return The 64-bit integer data. | |
434 */ | |
435 gint64 gaim_value_get_int64(const GaimValue *value); | |
436 | |
437 /** | |
438 * Returns the value's unsigned 64-bit integer data. | |
439 * | |
440 * @param value The value. | |
441 * | |
442 * @return The unsigned 64-bit integer data. | |
443 */ | |
444 guint64 gaim_value_get_uint64(const GaimValue *value); | |
445 | |
446 /** | |
447 * Returns the value's string data. | |
448 * | |
449 * @param value The value. | |
450 * | |
451 * @return The string data. | |
452 */ | |
453 const char *gaim_value_get_string(const GaimValue *value); | |
454 | |
455 /** | |
456 * Returns the value's object data. | |
457 * | |
458 * @param value The value. | |
459 * | |
460 * @return The object data. | |
461 */ | |
462 void *gaim_value_get_object(const GaimValue *value); | |
463 | |
464 /** | |
465 * Returns the value's pointer data. | |
466 * | |
467 * @param value The value. | |
468 * | |
469 * @return The pointer data. | |
470 */ | |
471 void *gaim_value_get_pointer(const GaimValue *value); | |
472 | |
473 /** | |
474 * Returns the value's enum data. | |
475 * | |
476 * @param value The value. | |
477 * | |
478 * @return The enum data. | |
479 */ | |
480 int gaim_value_get_enum(const GaimValue *value); | |
481 | |
482 /** | |
483 * Returns the value's boxed data. | |
484 * | |
485 * @param value The value. | |
486 * | |
487 * @return The boxed data. | |
488 */ | |
489 void *gaim_value_get_boxed(const GaimValue *value); | |
490 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
491 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
492 } |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
493 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
494 |
6562 | 495 #endif /* _GAIM_VALUE_H_ */ |