Mercurial > pidgin
annotate src/status.h @ 10396:3cf69ffdc25e
[gaim-migrate @ 11626]
Compare case-insensitively. It couldn't hurt and it might help.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sat, 18 Dec 2004 16:17:21 +0000 |
| parents | 64bc206c7473 |
| children | bed2c96bc1fb |
| rev | line source |
|---|---|
| 9944 | 1 /** |
| 2 * @file status.h Status API | |
| 3 * @ingroup core | |
| 4 * | |
| 6065 | 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. | |
| 9944 | 10 * |
| 6065 | 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 */ | |
| 9944 | 25 #ifndef _GAIM_STATUS_H_ |
| 26 #define _GAIM_STATUS_H_ | |
| 6065 | 27 |
| 10337 | 28 typedef struct _GaimStatusType GaimStatusType; |
| 29 typedef struct _GaimStatusAttr GaimStatusAttr; | |
| 30 typedef struct _GaimPresence GaimPresence; | |
| 31 typedef struct _GaimStatus GaimStatus; | |
| 32 typedef struct _GaimStatusSavedSub GaimStatusSavedSub; | |
| 33 typedef struct _GaimStatusSaved GaimStatusSaved; | |
| 9944 | 34 |
| 35 /** | |
| 36 * A context for a presence. | |
| 37 * | |
| 38 * The context indicates what the presence applies to. | |
| 39 */ | |
| 40 typedef enum | |
| 41 { | |
| 42 GAIM_PRESENCE_CONTEXT_UNSET = 0, | |
| 43 GAIM_PRESENCE_CONTEXT_ACCOUNT, | |
| 44 GAIM_PRESENCE_CONTEXT_CONV, | |
| 45 GAIM_PRESENCE_CONTEXT_BUDDY | |
| 46 | |
| 47 } GaimPresenceContext; | |
| 48 | |
| 49 /** | |
| 50 * A primitive defining the basic structure of a status type. | |
| 51 */ | |
| 52 typedef enum | |
| 53 { | |
|
10151
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
54 GAIM_STATUS_UNSET = 0, |
|
d83e6f2125b1
[gaim-migrate @ 11228]
Christian Hammond <chipx86@chipx86.com>
parents:
10087
diff
changeset
|
55 GAIM_STATUS_OFFLINE, |
| 9944 | 56 GAIM_STATUS_ONLINE, |
| 57 GAIM_STATUS_AVAILABLE, | |
| 58 GAIM_STATUS_UNAVAILABLE, | |
| 59 GAIM_STATUS_HIDDEN, | |
| 60 GAIM_STATUS_AWAY, | |
| 10348 | 61 GAIM_STATUS_EXTENDED_AWAY, |
| 62 GAIM_STATUS_NUM_PRIMITIVES | |
| 9944 | 63 |
| 64 } GaimStatusPrimitive; | |
| 65 | |
| 66 #include "account.h" | |
| 67 #include "blist.h" | |
| 68 #include "conversation.h" | |
| 69 #include "value.h" | |
| 70 | |
| 71 /**************************************************************************/ | |
| 72 /** @name GaimStatusType API */ | |
| 73 /**************************************************************************/ | |
| 74 /*@{*/ | |
| 75 | |
| 76 /** | |
| 77 * Creates a new status type. | |
| 78 * | |
| 79 * @param primitive The primitive status type. | |
| 80 * @param id The ID of the status type. | |
| 81 * @param name The name presented to the user. | |
| 82 * @param saveable TRUE if the information set for this status by the | |
| 83 * user can be saved for future sessions. | |
| 84 * @param user_settable TRUE if this is a status the user can manually set. | |
| 85 * @param independent TRUE if this is an independent (non-exclusive) | |
| 86 * status type. | |
| 87 * | |
| 88 * @return A new status type. | |
| 89 */ | |
| 90 GaimStatusType *gaim_status_type_new_full(GaimStatusPrimitive primitive, | |
| 91 const char *id, const char *name, | |
| 92 gboolean saveable, | |
| 93 gboolean user_settable, | |
| 94 gboolean independent); | |
| 95 | |
| 96 /** | |
| 97 * Creates a new status type with some default values. | |
| 98 * | |
| 99 * @param primitive The primitive status type. | |
| 100 * @param id The ID of the status type. | |
| 101 * @param name The name presented to the user. | |
| 102 * @param user_settable TRUE if this is a status the user can manually set. | |
| 103 * | |
| 104 * @return A new status type. | |
| 105 */ | |
| 106 GaimStatusType *gaim_status_type_new(GaimStatusPrimitive primitive, | |
| 107 const char *id, const char *name, | |
| 108 gboolean user_settable); | |
| 109 | |
| 110 /** | |
| 111 * Creates a new status type with attributes. | |
| 112 * | |
| 113 * @param primitive The primitive status type. | |
| 114 * @param id The ID of the status type. | |
| 115 * @param name The name presented to the user. | |
| 116 * @param saveable TRUE if the information set for this status by the | |
| 117 * user can be saved for future sessions. | |
| 118 * @param user_settable TRUE if this is a status the user can manually set. | |
| 119 * @param independent TRUE if this is an independent (non-exclusive) | |
| 120 * status type. | |
| 121 * @param attr_id The ID of the first attribute. | |
| 122 * @param attr_name The name of the first attribute. | |
| 123 * @param attr_value The value type of the first attribute attribute. | |
| 124 * @param ... Additional attribute information. | |
| 125 * | |
| 126 * @return A new status type. | |
| 127 */ | |
| 128 GaimStatusType *gaim_status_type_new_with_attrs(GaimStatusPrimitive primitive, | |
| 129 const char *id, | |
| 130 const char *name, | |
| 131 gboolean saveable, | |
| 132 gboolean user_settable, | |
| 133 gboolean independent, | |
| 134 const char *attr_id, | |
| 135 const char *attr_name, | |
| 136 GaimValue *attr_value, ...); | |
| 137 | |
| 138 /** | |
| 139 * Destroys a status type. | |
| 140 * | |
| 141 * @param status_type The status type to destroy. | |
| 142 */ | |
| 143 void gaim_status_type_destroy(GaimStatusType *status_type); | |
| 144 | |
| 145 /** | |
| 146 * Sets a status type's primary attribute. | |
| 147 * | |
| 148 * The value for the primary attribute is used as the description for | |
| 149 * the particular status type. An example is an away message. The message | |
| 150 * would be the primary attribute. | |
| 151 * | |
| 152 * @param status_type The status type. | |
| 153 * @param attr_id The ID of the primary attribute. | |
| 154 */ | |
| 155 void gaim_status_type_set_primary_attr(GaimStatusType *status_type, | |
| 156 const char *attr_id); | |
| 157 | |
| 158 /** | |
| 159 * Adds an attribute to a status type. | |
| 160 * | |
| 161 * @param status_type The status type to add the attribute to. | |
| 162 * @param id The ID of the attribute. | |
| 163 * @param name The name presented to the user. | |
| 164 * @param value The value type of this attribute. | |
| 165 */ | |
| 166 void gaim_status_type_add_attr(GaimStatusType *status_type, const char *id, | |
| 167 const char *name, GaimValue *value); | |
| 168 | |
| 169 /** | |
| 170 * Adds multiple attributes to a status type. | |
| 171 * | |
| 172 * @param status_type The status type to add the attribute to. | |
| 173 * @param id The ID of the first attribute. | |
| 174 * @param name The description of the first attribute. | |
| 175 * @param value The value type of the first attribute attribute. | |
| 176 * @param ... Additional attribute information. | |
| 177 */ | |
| 178 void gaim_status_type_add_attrs(GaimStatusType *status_type, const char *id, | |
| 179 const char *name, GaimValue *value, ...); | |
| 180 | |
| 181 /** | |
| 182 * Adds multiple attributes to a status type using a va_list. | |
| 183 * | |
| 184 * @param status_type The status type to add the attribute to. | |
| 185 * @param args The va_list of attributes. | |
| 186 */ | |
| 187 void gaim_status_type_add_attrs_vargs(GaimStatusType *status_type, | |
| 188 va_list args); | |
| 189 | |
| 190 /** | |
| 191 * Returns the primitive type of a status type. | |
| 192 * | |
| 193 * @param status_type The status type. | |
| 194 * | |
| 195 * @return The primitive type of the status type. | |
| 196 */ | |
| 197 GaimStatusPrimitive gaim_status_type_get_primitive( | |
| 198 const GaimStatusType *status_type); | |
| 199 | |
| 200 /** | |
| 201 * Returns the ID of a status type. | |
| 202 * | |
| 203 * @param status_type The status type. | |
| 204 * | |
| 205 * @return The ID of the status type. | |
| 206 */ | |
| 207 const char *gaim_status_type_get_id(const GaimStatusType *status_type); | |
| 208 | |
| 209 /** | |
| 210 * Returns the name of a status type. | |
| 211 * | |
| 212 * @param status_type The status type. | |
| 213 * | |
| 214 * @return The name of the status type. | |
| 215 */ | |
| 216 const char *gaim_status_type_get_name(const GaimStatusType *status_type); | |
| 217 | |
| 218 /** | |
| 219 * Returns whether or not the status type is saveable. | |
| 220 * | |
| 221 * @param status_type The status type. | |
| 222 * | |
| 223 * @return TRUE if user-defined statuses based off this type are saveable. | |
| 224 * FALSE otherwise. | |
| 225 */ | |
| 226 gboolean gaim_status_type_is_saveable(const GaimStatusType *status_type); | |
| 227 | |
| 228 /** | |
| 229 * Returns whether or not the status type can be set or modified by the | |
| 230 * user. | |
| 231 * | |
| 232 * @param status_type The status type. | |
| 233 * | |
| 234 * @return TRUE if the status type can be set or modified by the user. | |
| 235 * FALSE if it's a protocol-set setting. | |
| 236 */ | |
| 237 gboolean gaim_status_type_is_user_settable(const GaimStatusType *status_type); | |
| 238 | |
| 239 /** | |
| 240 * Returns whether or not the status type is independent. | |
| 241 * | |
| 242 * Independent status types are non-exclusive. If other status types on | |
| 243 * the same hierarchy level are set, this one will not be affected. | |
| 244 * | |
| 245 * @param status_type The status type. | |
| 246 * | |
| 247 * @return TRUE if the status type is independent, or FALSE otherwise. | |
| 248 */ | |
| 249 gboolean gaim_status_type_is_independent(const GaimStatusType *status_type); | |
| 250 | |
| 251 /** | |
| 10071 | 252 * Returns whether the status type is exclusive. |
| 10067 | 253 * |
| 254 * @param status_type The status type. | |
| 255 * | |
| 256 * @return TRUE if the status type is exclusive, FALSE otherwise. | |
| 257 */ | |
| 258 gboolean gaim_status_type_is_exclusive(const GaimStatusType *status_type); | |
| 259 | |
| 260 /** | |
| 9944 | 261 * Returns whether or not a status type is available. |
| 262 * | |
| 263 * Available status types are online and possibly hidden, but not away. | |
| 264 * | |
| 265 * @param status_type The status type. | |
| 266 * | |
| 267 * @return TRUE if the status is available, or FALSE otherwise. | |
| 268 */ | |
| 269 gboolean gaim_status_type_is_available(const GaimStatusType *status_type); | |
| 270 | |
| 271 /** | |
| 272 * Returns a status type's primary attribute ID. | |
| 273 * | |
| 274 * @param type The status type. | |
| 275 * | |
| 276 * @return The primary attribute's ID. | |
| 277 */ | |
| 278 const char *gaim_status_type_get_primary_attr(const GaimStatusType *type); | |
| 279 | |
| 280 /** | |
| 281 * Returns the attribute with the specified ID. | |
| 282 * | |
| 283 * @param status_type The status type containing the attribute. | |
| 284 * @param id The ID of the desired attribute. | |
| 285 * | |
| 286 * @return The attribute, if found. NULL otherwise. | |
| 287 */ | |
| 288 GaimStatusAttr *gaim_status_type_get_attr(const GaimStatusType *status_type, | |
| 289 const char *id); | |
| 290 | |
| 291 /** | |
| 292 * Returns a list of all attributes in a status type. | |
| 293 * | |
| 294 * @param status_type The status type. | |
| 295 * | |
| 296 * @return The list of attributes. | |
| 297 */ | |
| 298 const GList *gaim_status_type_get_attrs(const GaimStatusType *status_type); | |
| 299 | |
| 10348 | 300 /** |
| 301 * Find the GaimStatusType with the given id. | |
| 302 * | |
| 303 * @param status_types A list of status types. Often account->status_types. | |
| 304 * @param id The unique ID of the status type you wish to find. | |
| 305 * | |
| 306 * @return The status type with the given ID, or NULL if one could | |
| 307 * not be found. | |
| 308 */ | |
| 309 const GaimStatusType *gaim_status_type_find_with_id(GList *status_types, | |
| 310 const char *id); | |
| 311 | |
| 9944 | 312 /*@}*/ |
| 313 | |
| 314 /**************************************************************************/ | |
| 315 /** @name GaimStatusAttr API */ | |
| 316 /**************************************************************************/ | |
| 317 /*@{*/ | |
| 318 | |
| 319 /** | |
| 320 * Creates a new status attribute. | |
| 321 * | |
| 322 * @param id The ID of the attribute. | |
| 323 * @param name The name presented to the user. | |
| 324 * @param value_type The type of data contained in the attribute. | |
| 325 * | |
| 326 * @return A new status attribute. | |
| 327 */ | |
| 328 GaimStatusAttr *gaim_status_attr_new(const char *id, const char *name, | |
| 329 GaimValue *value_type); | |
| 330 | |
| 331 /** | |
| 332 * Destroys a status attribute. | |
| 333 * | |
| 334 * @param attr The status attribute to destroy. | |
| 335 */ | |
| 336 void gaim_status_attr_destroy(GaimStatusAttr *attr); | |
| 337 | |
| 338 /** | |
| 339 * Returns the ID of a status attribute. | |
| 340 * | |
| 341 * @param attr The status attribute. | |
| 342 * | |
| 343 * @return The status attribute's ID. | |
| 344 */ | |
| 345 const char *gaim_status_attr_get_id(const GaimStatusAttr *attr); | |
| 346 | |
| 347 /** | |
| 348 * Returns the name of a status attribute. | |
| 349 * | |
| 350 * @param attr The status attribute. | |
| 351 * | |
| 352 * @return The status attribute's name. | |
| 353 */ | |
| 354 const char *gaim_status_attr_get_name(const GaimStatusAttr *attr); | |
| 355 | |
| 356 /** | |
| 357 * Returns the value type of a status attribute. | |
| 358 * | |
| 359 * @param attr The status attribute. | |
| 360 * | |
| 361 * @return The status attribute's value type. | |
| 362 */ | |
| 363 GaimValue *gaim_status_attr_get_value_type(const GaimStatusAttr *attr); | |
| 364 | |
| 365 /*@}*/ | |
| 366 | |
| 367 /**************************************************************************/ | |
| 368 /** @name GaimStatus API */ | |
| 369 /**************************************************************************/ | |
| 370 /*@{*/ | |
| 371 | |
| 372 /** | |
| 373 * Creates a new status. | |
| 374 * | |
| 375 * @param status_type The type of status. | |
| 376 * @param presence The parent presence. | |
| 377 * | |
| 378 * @return The new status. | |
| 379 */ | |
| 380 GaimStatus *gaim_status_new(GaimStatusType *status_type, | |
| 381 GaimPresence *presence); | |
| 382 | |
| 383 /** | |
| 384 * Destroys a status. | |
| 385 * | |
| 386 * @param status The status to destroy. | |
| 387 */ | |
| 388 void gaim_status_destroy(GaimStatus *status); | |
| 389 | |
| 390 /** | |
| 391 * Sets whether or not a status is active. | |
| 392 * | |
| 393 * This should only be called by the account, conversation, and buddy APIs. | |
| 394 * | |
| 10204 | 395 * @param status The status. |
| 9944 | 396 * @param active The active state. |
| 397 */ | |
| 398 void gaim_status_set_active(GaimStatus *status, gboolean active); | |
| 399 | |
| 400 /** | |
| 10204 | 401 * Sets whether or not a status is active. |
| 402 * | |
| 403 * This should only be called by the account, conversation, and buddy APIs. | |
| 404 * | |
| 405 * @param status The status. | |
| 406 * @param active The active state. | |
| 407 * @param args A list of attributes to set on the status. This list is | |
| 408 * composed of key/value pairs, where each key is a valid | |
| 409 * attribute name for this GaimStatusType. The list should | |
| 410 * be NULL terminated. | |
| 411 */ | |
| 412 void gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, | |
| 413 va_list args); | |
| 414 | |
| 415 /** | |
| 9944 | 416 * Sets the boolean value of an attribute in a status with the specified ID. |
| 417 * | |
| 418 * @param status The status. | |
| 419 * @param id The attribute ID. | |
| 420 * @param value The boolean value. | |
| 421 */ | |
| 422 void gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | |
| 423 gboolean value); | |
| 424 | |
| 425 /** | |
| 426 * Sets the integer value of an attribute in a status with the specified ID. | |
| 427 * | |
| 428 * @param status The status. | |
| 429 * @param id The attribute ID. | |
| 430 * @param value The integer value. | |
| 431 */ | |
| 432 void gaim_status_set_attr_int(GaimStatus *status, const char *id, | |
| 433 int value); | |
| 434 | |
| 435 /** | |
| 436 * Sets the string value of an attribute in a status with the specified ID. | |
| 437 * | |
| 438 * @param status The status. | |
| 439 * @param id The attribute ID. | |
| 440 * @param value The string value. | |
| 441 */ | |
| 442 void gaim_status_set_attr_string(GaimStatus *status, const char *id, | |
| 443 const char *value); | |
| 444 | |
| 445 /** | |
| 446 * Returns the status's type. | |
| 447 * | |
| 448 * @param status The status. | |
| 449 * | |
| 450 * @return The status's type. | |
| 451 */ | |
| 452 GaimStatusType *gaim_status_get_type(const GaimStatus *status); | |
| 453 | |
| 454 /** | |
| 455 * Returns the status's presence. | |
| 456 * | |
| 457 * @param status The status. | |
| 458 * | |
| 459 * @return The status's presence. | |
| 460 */ | |
| 461 GaimPresence *gaim_status_get_presence(const GaimStatus *status); | |
| 462 | |
| 463 /** | |
| 464 * Returns the status's type ID. | |
| 465 * | |
| 466 * This is a convenience method for | |
| 467 * gaim_status_type_get_id(gaim_status_get_type(status)). | |
| 468 * | |
| 469 * @param status The status. | |
| 470 * | |
| 471 * @return The status's ID. | |
| 472 */ | |
| 473 const char *gaim_status_get_id(const GaimStatus *status); | |
| 474 | |
| 475 /** | |
| 476 * Returns the status's name. | |
| 477 * | |
| 478 * This is a convenience method for | |
| 479 * gaim_status_type_get_name(gaim_status_get_type(status)). | |
| 480 * | |
| 481 * @param status The status. | |
| 482 * | |
| 483 * @return The status's name. | |
| 484 */ | |
| 485 const char *gaim_status_get_name(const GaimStatus *status); | |
| 486 | |
| 487 /** | |
| 488 * Returns whether or not a status is independent. | |
| 489 * | |
| 490 * This is a convenience method for | |
| 491 * gaim_status_type_is_independent(gaim_status_get_type(status)). | |
| 492 * | |
| 493 * @param status The status. | |
| 494 * | |
| 495 * @return TRUE if the status is independent, or FALSE otherwise. | |
| 496 */ | |
| 497 gboolean gaim_status_is_independent(const GaimStatus *status); | |
| 498 | |
| 499 /** | |
| 10067 | 500 * Returns whether or not a status is exclusive. |
| 501 * | |
| 502 * This is a convenience method for | |
| 503 * gaim_status_type_is_exclusive(gaim_status_get_type(status)). | |
| 504 * | |
| 505 * @param status The status. | |
| 506 * | |
| 507 * @return TRUE if the status is exclusive, FALSE otherwise. | |
| 508 */ | |
| 509 gboolean gaim_status_is_exclusive(const GaimStatus *status); | |
| 510 | |
| 511 /** | |
| 9944 | 512 * Returns whether or not a status is available. |
| 513 * | |
| 514 * Available statuses are online and possibly hidden, but not away or idle. | |
| 515 * | |
| 516 * This is a convenience method for | |
| 517 * gaim_status_type_is_available(gaim_status_get_type(status)). | |
| 518 * | |
| 519 * @param status The status. | |
| 520 * | |
| 521 * @return TRUE if the status is available, or FALSE otherwise. | |
| 522 */ | |
| 523 gboolean gaim_status_is_available(const GaimStatus *status); | |
| 524 | |
| 525 /** | |
| 526 * Returns the active state of a status. | |
| 527 * | |
| 528 * @param status The status. | |
| 529 * | |
| 530 * @return The active state of the status. | |
| 531 */ | |
| 532 gboolean gaim_status_is_active(const GaimStatus *status); | |
| 533 | |
| 534 /** | |
|
10040
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
535 * Returns whether or not a status is considered 'online' |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
536 * |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
537 * @param status The status. |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
538 * |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
539 * @return TRUE if the status is considered online, FALSE otherwise |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
540 */ |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
541 gboolean gaim_status_is_online(const GaimStatus *status); |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
542 |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
543 /** |
| 9944 | 544 * Returns the value of an attribute in a status with the specified ID. |
| 545 * | |
| 546 * @param status The status. | |
| 547 * @param id The attribute ID. | |
| 548 * | |
| 549 * @return The value of the attribute. | |
| 550 */ | |
| 551 GaimValue *gaim_status_get_attr_value(const GaimStatus *status, | |
| 552 const char *id); | |
| 553 | |
| 554 /** | |
| 555 * Returns the boolean value of an attribute in a status with the specified ID. | |
| 556 * | |
| 557 * @param status The status. | |
| 558 * @param id The attribute ID. | |
| 559 * | |
| 560 * @return The boolean value of the attribute. | |
| 561 */ | |
| 562 gboolean gaim_status_get_attr_boolean(const GaimStatus *status, | |
| 563 const char *id); | |
| 564 | |
| 565 /** | |
| 566 * Returns the integer value of an attribute in a status with the specified ID. | |
| 567 * | |
| 568 * @param status The status. | |
| 569 * @param id The attribute ID. | |
| 570 * | |
| 571 * @return The integer value of the attribute. | |
| 572 */ | |
| 573 int gaim_status_get_attr_int(const GaimStatus *status, const char *id); | |
| 574 | |
| 575 /** | |
| 576 * Returns the string value of an attribute in a status with the specified ID. | |
| 577 * | |
| 578 * @param status The status. | |
| 579 * @param id The attribute ID. | |
| 580 * | |
| 581 * @return The string value of the attribute. | |
| 582 */ | |
| 583 const char *gaim_status_get_attr_string(const GaimStatus *status, | |
| 584 const char *id); | |
| 585 | |
| 586 /** | |
| 587 * Compares two statuses for availability. | |
| 588 * | |
| 589 * @param status1 The first status. | |
| 590 * @param status2 The second status. | |
| 591 * | |
| 592 * @return -1 if @a status1 is more available than @a status2. | |
| 593 * 0 if @a status1 is equal to @a status2. | |
| 594 * 1 if @a status2 is more available than @a status1. | |
| 595 */ | |
| 596 gint gaim_status_compare(const GaimStatus *status1, const GaimStatus *status2); | |
| 597 | |
| 598 /*@}*/ | |
| 599 | |
| 600 /**************************************************************************/ | |
| 601 /** @name GaimPresence API */ | |
| 602 /**************************************************************************/ | |
| 603 /*@{*/ | |
| 604 | |
| 605 /** | |
| 606 * Creates a new presence. | |
| 607 * | |
| 608 * @param context The presence context. | |
| 609 * | |
| 610 * @return A new presence. | |
| 611 */ | |
| 612 GaimPresence *gaim_presence_new(GaimPresenceContext context); | |
| 613 | |
| 614 /** | |
| 615 * Creates a presence for an account. | |
| 616 * | |
| 617 * @param account The account. | |
| 618 * | |
| 619 * @return The new presence. | |
| 620 */ | |
| 621 GaimPresence *gaim_presence_new_for_account(GaimAccount *account); | |
| 622 | |
| 623 /** | |
| 624 * Creates a presence for a conversation. | |
| 625 * | |
| 626 * @param conv The conversation. | |
| 627 * | |
| 628 * @return The new presence. | |
| 629 */ | |
| 630 GaimPresence *gaim_presence_new_for_conv(GaimConversation *conv); | |
| 631 | |
| 632 /** | |
| 633 * Creates a presence for a buddy. | |
| 634 * | |
| 635 * @param buddy The buddy. | |
| 636 * | |
| 637 * @return The new presence. | |
| 638 */ | |
| 639 GaimPresence *gaim_presence_new_for_buddy(GaimBuddy *buddy); | |
| 640 | |
| 641 /** | |
| 642 * Destroys a presence. | |
| 643 * | |
| 644 * All statuses added to this list will be destroyed along with | |
| 645 * the presence. | |
| 646 * | |
| 647 * If this presence belongs to a buddy, you must call | |
| 648 * gaim_presence_remove_buddy() first. | |
| 649 * | |
| 650 * @param presence The presence to destroy. | |
| 651 */ | |
| 652 void gaim_presence_destroy(GaimPresence *presence); | |
| 653 | |
| 654 /** | |
| 655 * Removes a buddy from a presence. | |
| 656 * | |
| 657 * This must be done before destroying a buddy in a presence. | |
| 658 * | |
| 659 * @param presence The presence. | |
| 660 * @param buddy The buddy. | |
| 661 */ | |
| 662 void gaim_presence_remove_buddy(GaimPresence *presence, GaimBuddy *buddy); | |
| 663 | |
| 664 /** | |
| 665 * Adds a status to a presence. | |
| 666 * | |
| 667 * @param presence The presence. | |
| 668 * @param status The status to add. | |
| 669 */ | |
| 670 void gaim_presence_add_status(GaimPresence *presence, GaimStatus *status); | |
| 671 | |
| 672 /** | |
| 673 * Adds a list of statuses to the presence. | |
| 674 * | |
| 675 * @param presence The presence. | |
| 676 * @param source_list The source list of statuses to add. | |
| 677 */ | |
| 678 void gaim_presence_add_list(GaimPresence *presence, const GList *source_list); | |
| 679 | |
| 680 /** | |
| 681 * Sets the active state of a status in a presence. | |
| 682 * | |
| 683 * Only independent statuses can be set unactive. Normal statuses can only | |
| 684 * be set active, so if you wish to disable a status, set another | |
| 685 * non-independent status to active, or use gaim_presence_switch_status(). | |
| 686 * | |
| 687 * @param presence The presence. | |
| 688 * @param status_id The ID of the status. | |
| 689 * @param active The active state. | |
| 690 */ | |
| 691 void gaim_presence_set_status_active(GaimPresence *presence, | |
| 692 const char *status_id, gboolean active); | |
| 693 | |
| 694 /** | |
| 695 * Switches the active status in a presence. | |
| 696 * | |
| 697 * This is similar to gaim_presence_set_status_active(), except it won't | |
| 698 * activate independent statuses. | |
| 699 * | |
| 700 * @param presence The presence. | |
| 701 * @param status_id The status ID to switch to. | |
| 702 */ | |
| 703 void gaim_presence_switch_status(GaimPresence *presence, | |
| 704 const char *status_id); | |
| 705 | |
| 706 /** | |
| 707 * Sets the idle state and time on a presence. | |
| 708 * | |
| 709 * @param presence The presence. | |
| 710 * @param idle The idle state. | |
| 711 * @param idle_time The idle time, if @a idle is TRUE. | |
| 712 */ | |
| 713 void gaim_presence_set_idle(GaimPresence *presence, gboolean idle, | |
| 714 time_t idle_time); | |
| 715 | |
| 716 /** | |
| 10006 | 717 * Sets the login time on a presence. |
| 718 * | |
| 10071 | 719 * @param presence The presence. |
| 720 * @param login_time The login time. | |
| 10006 | 721 */ |
| 722 void gaim_presence_set_login_time(GaimPresence *presence, time_t login_time); | |
| 723 | |
| 724 /** | |
| 9944 | 725 * Sets the warning level on a presence. |
| 726 * | |
| 727 * @param presence The presence. | |
| 9978 | 728 * @param level The warning level. An integer between 0 and 100 |
| 729 * (inclusive) representing the percentage warned. | |
| 9944 | 730 */ |
| 731 void gaim_presence_set_warning_level(GaimPresence *presence, | |
| 732 unsigned int level); | |
| 733 | |
| 734 /** | |
| 735 * Returns the presence's context. | |
| 736 * | |
| 737 * @param presence The presence. | |
| 738 * | |
| 739 * @return The presence's context. | |
| 740 */ | |
| 741 GaimPresenceContext gaim_presence_get_context(const GaimPresence *presence); | |
| 742 | |
| 743 /** | |
| 744 * Returns a presence's account. | |
| 745 * | |
| 746 * @param presence The presence. | |
| 747 * | |
| 748 * @return The presence's account. | |
| 749 */ | |
| 750 GaimAccount *gaim_presence_get_account(const GaimPresence *presence); | |
| 751 | |
| 752 /** | |
| 753 * Returns a presence's conversation. | |
| 754 * | |
| 755 * @param presence The presence. | |
| 756 * | |
| 757 * @return The presence's conversation. | |
| 758 */ | |
| 759 GaimConversation *gaim_presence_get_conversation(const GaimPresence *presence); | |
| 760 | |
| 761 /** | |
| 762 * Returns a presence's chat user. | |
| 763 * | |
| 764 * @param presence The presence. | |
| 765 * | |
| 766 * @return The chat's user. | |
| 767 */ | |
| 768 const char *gaim_presence_get_chat_user(const GaimPresence *presence); | |
| 769 | |
| 770 /** | |
| 771 * Returns a presence's list of buddies. | |
| 772 * | |
| 773 * @param presence The presence. | |
| 774 * | |
| 775 * @return The presence's list of buddies. | |
| 776 */ | |
| 777 const GList *gaim_presence_get_buddies(const GaimPresence *presence); | |
| 778 | |
| 779 /** | |
| 780 * Returns all the statuses in a presence. | |
| 781 * | |
| 782 * @param presence The presence. | |
| 783 * | |
| 784 * @return The statuses. | |
| 785 */ | |
| 786 const GList *gaim_presence_get_statuses(const GaimPresence *presence); | |
| 787 | |
| 788 /** | |
| 789 * Returns the status with the specified ID from a presence. | |
| 790 * | |
| 791 * @param presence The presence. | |
| 792 * @param status_id The ID of the status. | |
| 793 * | |
| 794 * @return The status if found, or NULL. | |
| 795 */ | |
| 796 GaimStatus *gaim_presence_get_status(const GaimPresence *presence, | |
| 797 const char *status_id); | |
| 798 | |
| 799 /** | |
| 800 * Returns the active exclusive status from a presence. | |
| 801 * | |
| 802 * @param presence The presence. | |
| 803 * | |
| 804 * @return The active exclusive status. | |
| 805 */ | |
| 806 GaimStatus *gaim_presence_get_active_status(const GaimPresence *presence); | |
| 807 | |
| 808 /** | |
| 809 * Returns whether or not a presence is available. | |
| 810 * | |
| 811 * Available presences are online and possibly hidden, but not away or idle. | |
| 812 * | |
| 813 * @param presence The presence. | |
| 814 * | |
| 815 * @return TRUE if the presence is available, or FALSE otherwise. | |
| 816 */ | |
| 817 gboolean gaim_presence_is_available(const GaimPresence *presence); | |
| 818 | |
| 819 /** | |
| 820 * Returns whether or not a presence is online. | |
| 821 * | |
| 822 * @param presence The presence. | |
| 823 * | |
| 824 * @return TRUE if the presence is online, or FALSE otherwise. | |
| 825 */ | |
| 826 gboolean gaim_presence_is_online(const GaimPresence *presence); | |
| 827 | |
| 828 /** | |
| 829 * Returns whether or not a status in a presence is active. | |
| 830 * | |
| 831 * A status is active if itself or any of its sub-statuses are active. | |
| 832 * | |
| 833 * @param presence The presence. | |
| 834 * @param status_id The ID of the status. | |
| 835 * | |
| 836 * @return TRUE if the status is active, or FALSE. | |
| 837 */ | |
| 838 gboolean gaim_presence_is_status_active(const GaimPresence *presence, | |
| 839 const char *status_id); | |
| 840 | |
| 841 /** | |
| 842 * Returns whether or not a status with the specified primitive type | |
| 843 * in a presence is active. | |
| 844 * | |
| 845 * A status is active if itself or any of its sub-statuses are active. | |
| 846 * | |
| 847 * @param presence The presence. | |
| 848 * @param primitive The status primitive. | |
| 849 * | |
| 850 * @return TRUE if the status is active, or FALSE. | |
| 851 */ | |
| 852 gboolean gaim_presence_is_status_primitive_active( | |
| 853 const GaimPresence *presence, GaimStatusPrimitive primitive); | |
| 854 | |
| 855 /** | |
| 856 * Returns whether or not a presence is idle. | |
| 857 * | |
| 858 * @param presence The presence. | |
| 859 * | |
| 860 * @return TRUE if the presence is idle, or FALSE otherwise. | |
| 861 */ | |
| 862 gboolean gaim_presence_is_idle(const GaimPresence *presence); | |
| 863 | |
| 864 /** | |
| 865 * Returns the presence's idle time. | |
| 866 * | |
| 867 * @param presence The presence. | |
| 868 * | |
| 869 * @return The presence's idle time. | |
| 870 */ | |
| 871 time_t gaim_presence_get_idle_time(const GaimPresence *presence); | |
| 872 | |
| 873 /** | |
| 874 * Returns the presence's warning level. | |
| 875 * | |
| 876 * @param presence The presence. | |
| 877 * | |
| 878 * @return The presence's warning level. | |
| 879 */ | |
| 880 unsigned int gaim_presence_get_warning_level(const GaimPresence *presence); | |
| 881 | |
| 882 /** | |
| 883 * Compares two presences for availability. | |
| 884 * | |
| 885 * @param presence1 The first presence. | |
| 886 * @param presence2 The second presence. | |
| 887 * | |
| 888 * @return -1 if @a presence1 is less available than @a presence2. | |
| 889 * 0 if @a presence1 is equal to @a presence2. | |
| 890 * 1 if @a presence2 is more available than @a presence1. | |
| 891 */ | |
| 892 gint gaim_presence_compare(const GaimPresence *presence1, | |
| 893 const GaimPresence *presence2); | |
| 894 | |
| 895 /*@}*/ | |
| 896 | |
| 897 /**************************************************************************/ | |
| 898 /** @name Status subsystem */ | |
| 899 /**************************************************************************/ | |
| 900 /*@{*/ | |
| 901 | |
| 902 /** | |
| 10337 | 903 * Returns all saved statuses. |
| 9944 | 904 * |
| 10337 | 905 * @return A list of saved statuses. |
| 9944 | 906 */ |
| 10337 | 907 const GList *gaim_statuses_get_saved(void); |
| 9944 | 908 |
| 909 /** | |
| 10340 | 910 * Finds a saved status with the specified title. |
| 9944 | 911 * |
| 10348 | 912 * @param title The name of the saved status. |
| 9944 | 913 * |
| 10337 | 914 * @return The saved status if found, or NULL. |
| 9944 | 915 */ |
| 10348 | 916 GaimStatusSaved *gaim_statuses_find_saved(const char *title); |
| 917 | |
| 918 /** | |
| 919 * Return the name of a given saved status. | |
| 920 * | |
| 921 * @param saved_status The saved status. | |
| 922 * | |
| 923 * @return The title. | |
| 924 */ | |
| 925 const char *gaim_statuses_saved_get_title(const GaimStatusSaved *saved_status); | |
| 10337 | 926 |
| 927 /** | |
| 928 * Return the name of a given saved status. | |
| 929 * | |
| 930 * @param saved_status The saved status. | |
| 931 * | |
| 932 * @return The name. | |
| 933 */ | |
| 10348 | 934 GaimStatusPrimitive gaim_statuses_saved_get_type(const GaimStatusSaved *saved_status); |
| 10340 | 935 |
| 936 /** | |
| 937 * Return the name of a given saved status. | |
| 938 * | |
| 939 * @param saved_status The saved status. | |
| 940 * | |
| 941 * @return The name. | |
| 942 */ | |
| 943 const char *gaim_statuses_saved_get_message(const GaimStatusSaved *saved_status); | |
| 944 | |
| 945 /** | |
| 10087 | 946 * Get the handle for the status subsystem. |
| 947 * | |
| 948 * @return the handle to the status subsystem | |
| 949 */ | |
| 950 void *gaim_statuses_get_handle(); | |
| 951 | |
| 952 /** | |
| 9944 | 953 * Initializes the status subsystem. |
| 954 */ | |
| 955 void gaim_statuses_init(void); | |
| 956 | |
| 957 /** | |
| 958 * Uninitializes the status subsystem. | |
| 959 */ | |
| 960 void gaim_statuses_uninit(void); | |
| 961 | |
| 962 /** | |
| 10348 | 963 * Syncs status information from a file. |
| 964 */ | |
| 965 void gaim_statuses_load(void); | |
| 966 | |
| 967 /** | |
| 9944 | 968 * Syncs status information to the file. |
| 969 */ | |
| 970 void gaim_statuses_sync(void); | |
| 971 | |
| 972 /*@}*/ | |
| 973 | |
| 974 #endif /* _GAIM_STATUS_H_ */ |
