Mercurial > pidgin
annotate src/value.h @ 10868:4a56b48dbaa6
[gaim-migrate @ 12555]
Don't try to send if charset conversion isn't successful. This is entirely untested.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 25 Apr 2005 03:41:16 +0000 |
parents | 72a5babfa8b4 |
children | 185ca25b5c7e |
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, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
67 GAIM_SUBTYPE_CONNECTION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
68 GAIM_SUBTYPE_CONVERSATION, |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
69 GAIM_SUBTYPE_CONV_WINDOW, |
8817 | 70 GAIM_SUBTYPE_PLUGIN, |
10684
72a5babfa8b4
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10477
diff
changeset
|
71 GAIM_SUBTYPE_BLIST_NODE, |
72a5babfa8b4
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10477
diff
changeset
|
72 GAIM_SUBTYPE_CIPHER |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
73 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
74 } GaimSubType; |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
75 |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
76 /** |
6562 | 77 * A wrapper for a type, subtype, and specific type of value. |
78 */ | |
79 typedef struct | |
80 { | |
81 GaimType type; | |
82 unsigned short flags; | |
83 | |
84 union | |
85 { | |
86 char char_data; | |
87 unsigned char uchar_data; | |
88 gboolean boolean_data; | |
89 short short_data; | |
90 unsigned short ushort_data; | |
91 int int_data; | |
92 unsigned int uint_data; | |
93 long long_data; | |
94 unsigned long ulong_data; | |
95 gint64 int64_data; | |
96 guint64 uint64_data; | |
97 char *string_data; | |
98 void *object_data; | |
99 void *pointer_data; | |
100 int enum_data; | |
101 void *boxed_data; | |
102 | |
103 } data; | |
104 | |
105 union | |
106 { | |
107 unsigned int subtype; | |
108 char *specific_type; | |
109 | |
110 } u; | |
111 | |
112 } GaimValue; | |
113 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
114 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
115 extern "C" { |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
116 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
117 |
6562 | 118 /** |
119 * Creates a new GaimValue. | |
120 * | |
121 * This function takes a type and, depending on that type, a sub-type | |
122 * or specific type. | |
123 * | |
10477 | 124 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 125 * string representing the specific type. |
126 * | |
127 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
128 * integer or enum representing the sub-type. | |
129 * | |
130 * If the subtype or specific type is not set when required, random | |
131 * errors may occur. You have been warned. | |
132 * | |
133 * @param type The type. | |
134 * | |
135 * @return The new value. | |
136 */ | |
137 GaimValue *gaim_value_new(GaimType type, ...); | |
138 | |
139 /** | |
10477 | 140 * Creates a new outgoing GaimValue. If a value is an "outgoing" value |
141 * it means the value can be modified by plugins and scripts. | |
6562 | 142 * |
143 * This function takes a type and, depending on that type, a sub-type | |
144 * or specific type. | |
145 * | |
10477 | 146 * If @a type is GAIM_TYPE_BOXED, the next parameter must be a |
6562 | 147 * string representing the specific type. |
148 * | |
149 * If @a type is GAIM_TYPE_SUBTYPE, the next parameter must be a | |
150 * integer or enum representing the sub-type. | |
151 * | |
152 * If the sub-type or specific type is not set when required, random | |
153 * errors may occur. You have been warned. | |
154 * | |
155 * @param type The type. | |
156 * | |
157 * @return The new value. | |
158 */ | |
159 GaimValue *gaim_value_new_outgoing(GaimType type, ...); | |
160 | |
161 /** | |
162 * Destroys a GaimValue. | |
163 * | |
164 * @param value The value to destroy. | |
165 */ | |
166 void gaim_value_destroy(GaimValue *value); | |
167 | |
168 /** | |
8809
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
169 * Duplicated a GaimValue. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
170 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 * @param value The value to duplicate. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 * |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
173 * @return The duplicate value. |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
174 */ |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
175 GaimValue *gaim_value_dup(const GaimValue *value); |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 |
fde4101fa183
[gaim-migrate @ 9571]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 /** |
6562 | 178 * Returns a value's type. |
179 * | |
10071 | 180 * @param value The value whose type you want. |
181 * | |
6562 | 182 * @return The value's type. |
183 */ | |
184 GaimType gaim_value_get_type(const GaimValue *value); | |
185 | |
186 /** | |
187 * Returns a value's subtype. | |
188 * | |
189 * If the value's type is not GAIM_TYPE_SUBTYPE, this will return 0. | |
190 * Subtypes should never have a subtype of 0. | |
191 * | |
10071 | 192 * @param value The value whose subtype you want. |
193 * | |
6562 | 194 * @return The value's subtype, or 0 if @a type is not GAIM_TYPE_SUBTYPE. |
195 */ | |
196 unsigned int gaim_value_get_subtype(const GaimValue *value); | |
197 | |
198 /** | |
199 * Returns a value's specific type. | |
200 * | |
201 * If the value's type is not GAIM_TYPE_BOXED, this will return @c NULL. | |
202 * | |
10071 | 203 * @param value The value whose specific type you want. |
204 * | |
6562 | 205 * @return The value's specific type, or @a NULL if not GAIM_TYPE_BOXED. |
206 */ | |
207 const char *gaim_value_get_specific_type(const GaimValue *value); | |
208 | |
209 /** | |
210 * Returns whether or not the value is an outgoing value. | |
211 * | |
212 * @param value The value. | |
213 * | |
214 * @return TRUE if the value is outgoing, or FALSE otherwise. | |
215 */ | |
216 gboolean gaim_value_is_outgoing(const GaimValue *value); | |
217 | |
218 /** | |
219 * Sets the value's character data. | |
220 * | |
221 * @param value The value. | |
222 * @param data The character data. | |
223 */ | |
224 void gaim_value_set_char(GaimValue *value, char data); | |
225 | |
226 /** | |
227 * Sets the value's unsigned character data. | |
228 * | |
229 * @param value The value. | |
230 * @param data The unsigned character data. | |
231 */ | |
232 void gaim_value_set_uchar(GaimValue *value, unsigned char data); | |
233 | |
234 /** | |
235 * Sets the value's boolean data. | |
236 * | |
237 * @param value The value. | |
238 * @param data The boolean data. | |
239 */ | |
240 void gaim_value_set_boolean(GaimValue *value, gboolean data); | |
241 | |
242 /** | |
243 * Sets the value's short integer data. | |
244 * | |
245 * @param value The value. | |
246 * @param data The short integer data. | |
247 */ | |
248 void gaim_value_set_short(GaimValue *value, short data); | |
249 | |
250 /** | |
251 * Sets the value's unsigned short integer data. | |
252 * | |
253 * @param value The value. | |
254 * @param data The unsigned short integer data. | |
255 */ | |
256 void gaim_value_set_ushort(GaimValue *value, unsigned short data); | |
257 | |
258 /** | |
259 * Sets the value's integer data. | |
260 * | |
261 * @param value The value. | |
262 * @param data The integer data. | |
263 */ | |
264 void gaim_value_set_int(GaimValue *value, int data); | |
265 | |
266 /** | |
267 * Sets the value's unsigned integer data. | |
268 * | |
269 * @param value The value. | |
270 * @param data The unsigned integer data. | |
271 */ | |
272 void gaim_value_set_uint(GaimValue *value, unsigned int data); | |
273 | |
274 /** | |
275 * Sets the value's long integer data. | |
276 * | |
277 * @param value The value. | |
278 * @param data The long integer data. | |
279 */ | |
280 void gaim_value_set_long(GaimValue *value, long data); | |
281 | |
282 /** | |
283 * Sets the value's unsigned long integer data. | |
284 * | |
285 * @param value The value. | |
286 * @param data The unsigned long integer data. | |
287 */ | |
288 void gaim_value_set_ulong(GaimValue *value, unsigned long data); | |
289 | |
290 /** | |
291 * Sets the value's 64-bit integer data. | |
292 * | |
293 * @param value The value. | |
294 * @param data The 64-bit integer data. | |
295 */ | |
296 void gaim_value_set_int64(GaimValue *value, gint64 data); | |
297 | |
298 /** | |
299 * Sets the value's unsigned 64-bit integer data. | |
300 * | |
301 * @param value The value. | |
302 * @param data The unsigned 64-bit integer data. | |
303 */ | |
304 void gaim_value_set_uint64(GaimValue *value, guint64 data); | |
305 | |
306 /** | |
307 * Sets the value's string data. | |
308 * | |
309 * @param value The value. | |
310 * @param data The string data. | |
311 */ | |
312 void gaim_value_set_string(GaimValue *value, const char *data); | |
313 | |
314 /** | |
315 * Sets the value's object data. | |
316 * | |
317 * @param value The value. | |
318 * @param data The object data. | |
319 */ | |
320 void gaim_value_set_object(GaimValue *value, void *data); | |
321 | |
322 /** | |
323 * Sets the value's pointer data. | |
324 * | |
325 * @param value The value. | |
326 * @param data The pointer data. | |
327 */ | |
328 void gaim_value_set_pointer(GaimValue *value, void *data); | |
329 | |
330 /** | |
331 * Sets the value's enum data. | |
332 * | |
333 * @param value The value. | |
334 * @param data The enum data. | |
335 */ | |
336 void gaim_value_set_enum(GaimValue *value, int data); | |
337 | |
338 /** | |
339 * Sets the value's boxed data. | |
340 * | |
341 * @param value The value. | |
342 * @param data The boxed data. | |
343 */ | |
344 void gaim_value_set_boxed(GaimValue *value, void *data); | |
345 | |
346 /** | |
347 * Returns the value's character data. | |
348 * | |
349 * @param value The value. | |
350 * | |
351 * @return The character data. | |
352 */ | |
353 char gaim_value_get_char(const GaimValue *value); | |
354 | |
355 /** | |
356 * Returns the value's unsigned character data. | |
357 * | |
358 * @param value The value. | |
359 * | |
360 * @return The unsigned character data. | |
361 */ | |
362 unsigned char gaim_value_get_uchar(const GaimValue *value); | |
363 | |
364 /** | |
365 * Returns the value's boolean data. | |
366 * | |
367 * @param value The value. | |
368 * | |
369 * @return The boolean data. | |
370 */ | |
371 gboolean gaim_value_get_boolean(const GaimValue *value); | |
372 | |
373 /** | |
374 * Returns the value's short integer data. | |
375 * | |
376 * @param value The value. | |
377 * | |
378 * @return The short integer data. | |
379 */ | |
380 short gaim_value_get_short(const GaimValue *value); | |
381 | |
382 /** | |
383 * Returns the value's unsigned short integer data. | |
384 * | |
385 * @param value The value. | |
386 * | |
387 * @return The unsigned short integer data. | |
388 */ | |
389 unsigned short gaim_value_get_ushort(const GaimValue *value); | |
390 | |
391 /** | |
392 * Returns the value's integer data. | |
393 * | |
394 * @param value The value. | |
395 * | |
396 * @return The integer data. | |
397 */ | |
398 int gaim_value_get_int(const GaimValue *value); | |
399 | |
400 /** | |
401 * Returns the value's unsigned integer data. | |
402 * | |
403 * @param value The value. | |
404 * | |
405 * @return The unsigned integer data. | |
406 */ | |
407 unsigned int gaim_value_get_uint(const GaimValue *value); | |
408 | |
409 /** | |
410 * Returns the value's long integer data. | |
411 * | |
412 * @param value The value. | |
413 * | |
414 * @return The long integer data. | |
415 */ | |
416 long gaim_value_get_long(const GaimValue *value); | |
417 | |
418 /** | |
419 * Returns the value's unsigned long integer data. | |
420 * | |
421 * @param value The value. | |
422 * | |
423 * @return The unsigned long integer data. | |
424 */ | |
425 unsigned long gaim_value_get_ulong(const GaimValue *value); | |
426 | |
427 /** | |
428 * Returns the value's 64-bit integer data. | |
429 * | |
430 * @param value The value. | |
431 * | |
432 * @return The 64-bit integer data. | |
433 */ | |
434 gint64 gaim_value_get_int64(const GaimValue *value); | |
435 | |
436 /** | |
437 * Returns the value's unsigned 64-bit integer data. | |
438 * | |
439 * @param value The value. | |
440 * | |
441 * @return The unsigned 64-bit integer data. | |
442 */ | |
443 guint64 gaim_value_get_uint64(const GaimValue *value); | |
444 | |
445 /** | |
446 * Returns the value's string data. | |
447 * | |
448 * @param value The value. | |
449 * | |
450 * @return The string data. | |
451 */ | |
452 const char *gaim_value_get_string(const GaimValue *value); | |
453 | |
454 /** | |
455 * Returns the value's object data. | |
456 * | |
457 * @param value The value. | |
458 * | |
459 * @return The object data. | |
460 */ | |
461 void *gaim_value_get_object(const GaimValue *value); | |
462 | |
463 /** | |
464 * Returns the value's pointer data. | |
465 * | |
466 * @param value The value. | |
467 * | |
468 * @return The pointer data. | |
469 */ | |
470 void *gaim_value_get_pointer(const GaimValue *value); | |
471 | |
472 /** | |
473 * Returns the value's enum data. | |
474 * | |
475 * @param value The value. | |
476 * | |
477 * @return The enum data. | |
478 */ | |
479 int gaim_value_get_enum(const GaimValue *value); | |
480 | |
481 /** | |
482 * Returns the value's boxed data. | |
483 * | |
484 * @param value The value. | |
485 * | |
486 * @return The boxed data. | |
487 */ | |
488 void *gaim_value_get_boxed(const GaimValue *value); | |
489 | |
6563
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
490 #ifdef __cplusplus |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
491 } |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
492 #endif |
122cb375be2d
[gaim-migrate @ 7085]
Christian Hammond <chipx86@chipx86.com>
parents:
6562
diff
changeset
|
493 |
6562 | 494 #endif /* _GAIM_VALUE_H_ */ |