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