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