Mercurial > pidgin
annotate src/status.h @ 12067:e859c1663a27
[gaim-migrate @ 14362]
Revert GtkSpell dynamic loading. A GtkSpell plugin is a better idea, and nosnilmot says he has one that's close to fully functional.
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Sun, 13 Nov 2005 01:44:11 +0000 |
| parents | d799f242be3f |
| children | fc464a0abccc |
| rev | line source |
|---|---|
|
11035
11e465b55fe6
[gaim-migrate @ 12922]
Gary Kramlich <grim@reaperworld.com>
parents:
10860
diff
changeset
|
1 /* |
| 6065 | 2 * gaim |
| 3 * | |
| 8046 | 4 * Gaim is the legal property of its developers, whose names are too numerous |
| 5 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 * source distribution. | |
| 9944 | 7 * |
| 6065 | 8 * This program is free software; you can redistribute it and/or modify |
| 9 * it under the terms of the GNU General Public License as published by | |
| 10 * the Free Software Foundation; either version 2 of the License, or | |
| 11 * (at your option) any later version. | |
| 12 * | |
| 13 * This program is distributed in the hope that it will be useful, | |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 * GNU General Public License for more details. | |
| 17 * | |
| 18 * You should have received a copy of the GNU General Public License | |
| 19 * along with this program; if not, write to the Free Software | |
| 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 */ | |
| 9944 | 22 #ifndef _GAIM_STATUS_H_ |
| 23 #define _GAIM_STATUS_H_ | |
| 6065 | 24 |
| 10737 | 25 /** |
|
11505
6e40226a3321
[gaim-migrate @ 13750]
Gary Kramlich <grim@reaperworld.com>
parents:
11491
diff
changeset
|
26 * @file status.h Status API |
|
6e40226a3321
[gaim-migrate @ 13750]
Gary Kramlich <grim@reaperworld.com>
parents:
11491
diff
changeset
|
27 * @ingroup core |
|
6e40226a3321
[gaim-migrate @ 13750]
Gary Kramlich <grim@reaperworld.com>
parents:
11491
diff
changeset
|
28 * |
| 10737 | 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 | |
| 11491 | 33 * an available state with an optional available message, an away |
| 10737 | 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 | |
| 11696 | 50 * your accounts are saved so that the next time you start Gaim, |
| 51 * your accounts will be set to their last known statuses. There | |
| 10737 | 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 | |
| 11696 | 61 * status per GaimPresence. If you activate one exlusive status, |
| 10754 | 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_AVAILABLE, |
| 102 GAIM_STATUS_UNAVAILABLE, | |
| 103 GAIM_STATUS_HIDDEN, | |
| 104 GAIM_STATUS_AWAY, | |
| 10348 | 105 GAIM_STATUS_EXTENDED_AWAY, |
| 106 GAIM_STATUS_NUM_PRIMITIVES | |
| 9944 | 107 |
| 108 } GaimStatusPrimitive; | |
| 109 | |
| 110 #include "account.h" | |
| 111 #include "blist.h" | |
| 112 #include "conversation.h" | |
| 113 #include "value.h" | |
| 114 | |
| 115 /**************************************************************************/ | |
| 10419 | 116 /** @name GaimStatusPrimtive API */ |
| 117 /**************************************************************************/ | |
| 118 /*@{*/ | |
| 119 | |
| 120 /** | |
| 121 * Lookup the id of a primitive status type based on the type. This | |
| 122 * ID is a unique plain-text name of the status, without spaces. | |
| 123 * | |
| 124 * @param type A primitive status type. | |
| 125 * | |
| 126 * @return The unique ID for this type. | |
| 127 */ | |
| 128 const char *gaim_primitive_get_id_from_type(GaimStatusPrimitive type); | |
| 129 | |
| 130 /** | |
| 131 * Lookup the name of a primitive status type based on the type. This | |
| 132 * name is the plain-English name of the status type. It is usually one | |
|
12037
d799f242be3f
[gaim-migrate @ 14330]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11696
diff
changeset
|
133 * or two words. |
| 10419 | 134 * |
| 135 * @param type A primitive status type. | |
| 136 * | |
| 137 * @return The name of this type, suitable for users to see. | |
| 138 */ | |
| 139 const char *gaim_primitive_get_name_from_type(GaimStatusPrimitive type); | |
| 140 | |
| 141 /** | |
| 142 * Lookup the value of a primitive status type based on the id. The | |
| 143 * ID is a unique plain-text name of the status, without spaces. | |
| 144 * | |
| 10469 | 145 * @param id The unique ID of a primitive status type. |
| 10419 | 146 * |
| 147 * @return The GaimStatusPrimitive value. | |
| 148 */ | |
| 149 GaimStatusPrimitive gaim_primitive_get_type_from_id(const char *id); | |
| 150 | |
| 151 /*@}*/ | |
| 152 | |
| 153 /**************************************************************************/ | |
| 9944 | 154 /** @name GaimStatusType API */ |
| 155 /**************************************************************************/ | |
| 156 /*@{*/ | |
| 157 | |
| 158 /** | |
| 159 * Creates a new status type. | |
| 160 * | |
| 161 * @param primitive The primitive status type. | |
| 162 * @param id The ID of the status type. | |
| 163 * @param name The name presented to the user. | |
| 164 * @param saveable TRUE if the information set for this status by the | |
| 165 * user can be saved for future sessions. | |
| 166 * @param user_settable TRUE if this is a status the user can manually set. | |
| 167 * @param independent TRUE if this is an independent (non-exclusive) | |
| 168 * status type. | |
| 169 * | |
| 170 * @return A new status type. | |
| 171 */ | |
| 172 GaimStatusType *gaim_status_type_new_full(GaimStatusPrimitive primitive, | |
| 173 const char *id, const char *name, | |
| 174 gboolean saveable, | |
| 175 gboolean user_settable, | |
| 176 gboolean independent); | |
| 177 | |
| 178 /** | |
| 179 * Creates a new status type with some default values. | |
| 180 * | |
| 181 * @param primitive The primitive status type. | |
| 182 * @param id The ID of the status type. | |
| 183 * @param name The name presented to the user. | |
| 184 * @param user_settable TRUE if this is a status the user can manually set. | |
| 185 * | |
| 186 * @return A new status type. | |
| 187 */ | |
| 188 GaimStatusType *gaim_status_type_new(GaimStatusPrimitive primitive, | |
| 189 const char *id, const char *name, | |
| 190 gboolean user_settable); | |
| 191 | |
| 192 /** | |
| 193 * Creates a new status type with attributes. | |
| 194 * | |
| 195 * @param primitive The primitive status type. | |
| 196 * @param id The ID of the status type. | |
| 197 * @param name The name presented to the user. | |
| 198 * @param saveable TRUE if the information set for this status by the | |
| 199 * user can be saved for future sessions. | |
| 200 * @param user_settable TRUE if this is a status the user can manually set. | |
| 201 * @param independent TRUE if this is an independent (non-exclusive) | |
| 202 * status type. | |
| 203 * @param attr_id The ID of the first attribute. | |
| 204 * @param attr_name The name of the first attribute. | |
| 205 * @param attr_value The value type of the first attribute attribute. | |
| 206 * @param ... Additional attribute information. | |
| 207 * | |
| 208 * @return A new status type. | |
| 209 */ | |
| 210 GaimStatusType *gaim_status_type_new_with_attrs(GaimStatusPrimitive primitive, | |
| 211 const char *id, | |
| 212 const char *name, | |
| 213 gboolean saveable, | |
| 214 gboolean user_settable, | |
| 215 gboolean independent, | |
| 216 const char *attr_id, | |
| 217 const char *attr_name, | |
| 218 GaimValue *attr_value, ...); | |
| 219 | |
| 220 /** | |
| 221 * Destroys a status type. | |
| 222 * | |
| 223 * @param status_type The status type to destroy. | |
| 224 */ | |
| 225 void gaim_status_type_destroy(GaimStatusType *status_type); | |
| 226 | |
| 227 /** | |
| 228 * Sets a status type's primary attribute. | |
| 229 * | |
| 230 * The value for the primary attribute is used as the description for | |
| 231 * the particular status type. An example is an away message. The message | |
| 232 * would be the primary attribute. | |
| 233 * | |
| 234 * @param status_type The status type. | |
| 235 * @param attr_id The ID of the primary attribute. | |
| 236 */ | |
| 237 void gaim_status_type_set_primary_attr(GaimStatusType *status_type, | |
| 238 const char *attr_id); | |
| 239 | |
| 240 /** | |
| 241 * Adds an attribute to a status type. | |
| 242 * | |
| 243 * @param status_type The status type to add the attribute to. | |
| 244 * @param id The ID of the attribute. | |
| 245 * @param name The name presented to the user. | |
| 246 * @param value The value type of this attribute. | |
| 247 */ | |
| 248 void gaim_status_type_add_attr(GaimStatusType *status_type, const char *id, | |
| 249 const char *name, GaimValue *value); | |
| 250 | |
| 251 /** | |
| 252 * Adds multiple attributes to a status type. | |
| 253 * | |
| 254 * @param status_type The status type to add the attribute to. | |
| 255 * @param id The ID of the first attribute. | |
| 256 * @param name The description of the first attribute. | |
| 257 * @param value The value type of the first attribute attribute. | |
| 258 * @param ... Additional attribute information. | |
| 259 */ | |
| 260 void gaim_status_type_add_attrs(GaimStatusType *status_type, const char *id, | |
| 261 const char *name, GaimValue *value, ...); | |
| 262 | |
| 263 /** | |
| 264 * Adds multiple attributes to a status type using a va_list. | |
| 265 * | |
| 266 * @param status_type The status type to add the attribute to. | |
| 267 * @param args The va_list of attributes. | |
| 268 */ | |
| 269 void gaim_status_type_add_attrs_vargs(GaimStatusType *status_type, | |
| 270 va_list args); | |
| 271 | |
| 272 /** | |
| 273 * Returns the primitive type of a status type. | |
| 274 * | |
| 275 * @param status_type The status type. | |
| 276 * | |
| 277 * @return The primitive type of the status type. | |
| 278 */ | |
| 279 GaimStatusPrimitive gaim_status_type_get_primitive( | |
| 280 const GaimStatusType *status_type); | |
| 281 | |
| 282 /** | |
| 283 * Returns the ID of a status type. | |
| 284 * | |
| 285 * @param status_type The status type. | |
| 286 * | |
| 287 * @return The ID of the status type. | |
| 288 */ | |
| 289 const char *gaim_status_type_get_id(const GaimStatusType *status_type); | |
| 290 | |
| 291 /** | |
| 292 * Returns the name of a status type. | |
| 293 * | |
| 294 * @param status_type The status type. | |
| 295 * | |
| 296 * @return The name of the status type. | |
| 297 */ | |
| 298 const char *gaim_status_type_get_name(const GaimStatusType *status_type); | |
| 299 | |
| 300 /** | |
| 301 * Returns whether or not the status type is saveable. | |
| 302 * | |
| 303 * @param status_type The status type. | |
| 304 * | |
| 305 * @return TRUE if user-defined statuses based off this type are saveable. | |
| 306 * FALSE otherwise. | |
| 307 */ | |
| 308 gboolean gaim_status_type_is_saveable(const GaimStatusType *status_type); | |
| 309 | |
| 310 /** | |
| 311 * Returns whether or not the status type can be set or modified by the | |
| 312 * user. | |
| 313 * | |
| 314 * @param status_type The status type. | |
| 315 * | |
| 316 * @return TRUE if the status type can be set or modified by the user. | |
| 317 * FALSE if it's a protocol-set setting. | |
| 318 */ | |
| 319 gboolean gaim_status_type_is_user_settable(const GaimStatusType *status_type); | |
| 320 | |
| 321 /** | |
| 322 * Returns whether or not the status type is independent. | |
| 323 * | |
| 324 * Independent status types are non-exclusive. If other status types on | |
| 325 * the same hierarchy level are set, this one will not be affected. | |
| 326 * | |
| 327 * @param status_type The status type. | |
| 328 * | |
| 329 * @return TRUE if the status type is independent, or FALSE otherwise. | |
| 330 */ | |
| 331 gboolean gaim_status_type_is_independent(const GaimStatusType *status_type); | |
| 332 | |
| 333 /** | |
| 10071 | 334 * Returns whether the status type is exclusive. |
| 10067 | 335 * |
| 336 * @param status_type The status type. | |
| 337 * | |
| 338 * @return TRUE if the status type is exclusive, FALSE otherwise. | |
| 339 */ | |
| 340 gboolean gaim_status_type_is_exclusive(const GaimStatusType *status_type); | |
| 341 | |
| 342 /** | |
| 9944 | 343 * Returns whether or not a status type is available. |
| 344 * | |
| 345 * Available status types are online and possibly hidden, but not away. | |
| 346 * | |
| 347 * @param status_type The status type. | |
| 348 * | |
| 349 * @return TRUE if the status is available, or FALSE otherwise. | |
| 350 */ | |
| 351 gboolean gaim_status_type_is_available(const GaimStatusType *status_type); | |
| 352 | |
| 353 /** | |
| 354 * Returns a status type's primary attribute ID. | |
| 355 * | |
| 356 * @param type The status type. | |
| 357 * | |
| 358 * @return The primary attribute's ID. | |
| 359 */ | |
| 360 const char *gaim_status_type_get_primary_attr(const GaimStatusType *type); | |
| 361 | |
| 362 /** | |
| 363 * Returns the attribute with the specified ID. | |
| 364 * | |
| 365 * @param status_type The status type containing the attribute. | |
| 366 * @param id The ID of the desired attribute. | |
| 367 * | |
| 368 * @return The attribute, if found. NULL otherwise. | |
| 369 */ | |
| 370 GaimStatusAttr *gaim_status_type_get_attr(const GaimStatusType *status_type, | |
| 371 const char *id); | |
| 372 | |
| 373 /** | |
| 374 * Returns a list of all attributes in a status type. | |
| 375 * | |
| 376 * @param status_type The status type. | |
| 377 * | |
| 378 * @return The list of attributes. | |
| 379 */ | |
| 380 const GList *gaim_status_type_get_attrs(const GaimStatusType *status_type); | |
| 381 | |
| 10348 | 382 /** |
| 383 * Find the GaimStatusType with the given id. | |
| 384 * | |
| 385 * @param status_types A list of status types. Often account->status_types. | |
| 386 * @param id The unique ID of the status type you wish to find. | |
| 387 * | |
| 388 * @return The status type with the given ID, or NULL if one could | |
| 389 * not be found. | |
| 390 */ | |
| 391 const GaimStatusType *gaim_status_type_find_with_id(GList *status_types, | |
| 392 const char *id); | |
| 393 | |
| 9944 | 394 /*@}*/ |
| 395 | |
| 396 /**************************************************************************/ | |
| 397 /** @name GaimStatusAttr API */ | |
| 398 /**************************************************************************/ | |
| 399 /*@{*/ | |
| 400 | |
| 401 /** | |
| 402 * Creates a new status attribute. | |
| 403 * | |
| 404 * @param id The ID of the attribute. | |
| 405 * @param name The name presented to the user. | |
| 406 * @param value_type The type of data contained in the attribute. | |
| 407 * | |
| 408 * @return A new status attribute. | |
| 409 */ | |
| 410 GaimStatusAttr *gaim_status_attr_new(const char *id, const char *name, | |
| 411 GaimValue *value_type); | |
| 412 | |
| 413 /** | |
| 414 * Destroys a status attribute. | |
| 415 * | |
| 416 * @param attr The status attribute to destroy. | |
| 417 */ | |
| 418 void gaim_status_attr_destroy(GaimStatusAttr *attr); | |
| 419 | |
| 420 /** | |
| 421 * Returns the ID of a status attribute. | |
| 422 * | |
| 423 * @param attr The status attribute. | |
| 424 * | |
| 425 * @return The status attribute's ID. | |
| 426 */ | |
| 427 const char *gaim_status_attr_get_id(const GaimStatusAttr *attr); | |
| 428 | |
| 429 /** | |
| 430 * Returns the name of a status attribute. | |
| 431 * | |
| 432 * @param attr The status attribute. | |
| 433 * | |
| 434 * @return The status attribute's name. | |
| 435 */ | |
| 436 const char *gaim_status_attr_get_name(const GaimStatusAttr *attr); | |
| 437 | |
| 438 /** | |
| 11249 | 439 * Returns the value of a status attribute. |
| 9944 | 440 * |
| 441 * @param attr The status attribute. | |
| 442 * | |
| 11249 | 443 * @return The status attribute's value. |
| 9944 | 444 */ |
| 11249 | 445 GaimValue *gaim_status_attr_get_value(const GaimStatusAttr *attr); |
| 9944 | 446 |
| 447 /*@}*/ | |
| 448 | |
| 449 /**************************************************************************/ | |
| 450 /** @name GaimStatus API */ | |
| 451 /**************************************************************************/ | |
| 452 /*@{*/ | |
| 453 | |
| 454 /** | |
| 455 * Creates a new status. | |
| 456 * | |
| 457 * @param status_type The type of status. | |
| 458 * @param presence The parent presence. | |
| 459 * | |
| 460 * @return The new status. | |
| 461 */ | |
| 462 GaimStatus *gaim_status_new(GaimStatusType *status_type, | |
| 463 GaimPresence *presence); | |
| 464 | |
| 465 /** | |
| 466 * Destroys a status. | |
| 467 * | |
| 468 * @param status The status to destroy. | |
| 469 */ | |
| 470 void gaim_status_destroy(GaimStatus *status); | |
| 471 | |
| 472 /** | |
| 473 * Sets whether or not a status is active. | |
| 474 * | |
| 475 * This should only be called by the account, conversation, and buddy APIs. | |
| 476 * | |
| 10204 | 477 * @param status The status. |
| 9944 | 478 * @param active The active state. |
| 479 */ | |
| 480 void gaim_status_set_active(GaimStatus *status, gboolean active); | |
| 481 | |
| 482 /** | |
| 10204 | 483 * Sets whether or not a status is active. |
| 484 * | |
| 485 * This should only be called by the account, conversation, and buddy APIs. | |
| 486 * | |
| 487 * @param status The status. | |
| 488 * @param active The active state. | |
| 489 * @param args A list of attributes to set on the status. This list is | |
| 490 * composed of key/value pairs, where each key is a valid | |
| 491 * attribute name for this GaimStatusType. The list should | |
| 492 * be NULL terminated. | |
| 493 */ | |
| 494 void gaim_status_set_active_with_attrs(GaimStatus *status, gboolean active, | |
| 495 va_list args); | |
| 496 | |
| 497 /** | |
| 11249 | 498 * Sets whether or not a status is active. |
| 499 * | |
| 500 * This should only be called by the account, conversation, and buddy APIs. | |
| 501 * | |
| 502 * @param status The status. | |
| 503 * @param active The active state. | |
| 11580 | 504 * @param attrs A list of attributes to set on the status. This list is |
| 11249 | 505 * composed of key/value pairs, where each key is a valid |
| 506 * attribute name for this GaimStatusType. | |
| 507 */ | |
| 508 void gaim_status_set_active_with_attrs_list(GaimStatus *status, gboolean active, | |
| 509 const GList *attrs); | |
| 510 | |
| 511 /** | |
| 9944 | 512 * Sets the boolean value of an attribute in a status with the specified ID. |
| 513 * | |
| 514 * @param status The status. | |
| 515 * @param id The attribute ID. | |
| 516 * @param value The boolean value. | |
| 517 */ | |
| 518 void gaim_status_set_attr_boolean(GaimStatus *status, const char *id, | |
| 519 gboolean value); | |
| 520 | |
| 521 /** | |
| 522 * Sets the integer value of an attribute in a status with the specified ID. | |
| 523 * | |
| 524 * @param status The status. | |
| 525 * @param id The attribute ID. | |
| 526 * @param value The integer value. | |
| 527 */ | |
| 528 void gaim_status_set_attr_int(GaimStatus *status, const char *id, | |
| 529 int value); | |
| 530 | |
| 531 /** | |
| 532 * Sets the string value of an attribute in a status with the specified ID. | |
| 533 * | |
| 534 * @param status The status. | |
| 535 * @param id The attribute ID. | |
| 536 * @param value The string value. | |
| 537 */ | |
| 538 void gaim_status_set_attr_string(GaimStatus *status, const char *id, | |
| 539 const char *value); | |
| 540 | |
| 541 /** | |
| 542 * Returns the status's type. | |
| 543 * | |
| 544 * @param status The status. | |
| 545 * | |
| 546 * @return The status's type. | |
| 547 */ | |
| 548 GaimStatusType *gaim_status_get_type(const GaimStatus *status); | |
| 549 | |
| 550 /** | |
| 551 * Returns the status's presence. | |
| 552 * | |
| 553 * @param status The status. | |
| 554 * | |
| 555 * @return The status's presence. | |
| 556 */ | |
| 557 GaimPresence *gaim_status_get_presence(const GaimStatus *status); | |
| 558 | |
| 559 /** | |
| 560 * Returns the status's type ID. | |
| 561 * | |
| 562 * This is a convenience method for | |
| 563 * gaim_status_type_get_id(gaim_status_get_type(status)). | |
| 564 * | |
| 565 * @param status The status. | |
| 566 * | |
| 567 * @return The status's ID. | |
| 568 */ | |
| 569 const char *gaim_status_get_id(const GaimStatus *status); | |
| 570 | |
| 571 /** | |
| 572 * Returns the status's name. | |
| 573 * | |
| 574 * This is a convenience method for | |
| 575 * gaim_status_type_get_name(gaim_status_get_type(status)). | |
| 576 * | |
| 577 * @param status The status. | |
| 578 * | |
| 579 * @return The status's name. | |
| 580 */ | |
| 581 const char *gaim_status_get_name(const GaimStatus *status); | |
| 582 | |
| 583 /** | |
| 584 * Returns whether or not a status is independent. | |
| 585 * | |
| 586 * This is a convenience method for | |
| 587 * gaim_status_type_is_independent(gaim_status_get_type(status)). | |
| 588 * | |
| 589 * @param status The status. | |
| 590 * | |
| 591 * @return TRUE if the status is independent, or FALSE otherwise. | |
| 592 */ | |
| 593 gboolean gaim_status_is_independent(const GaimStatus *status); | |
| 594 | |
| 595 /** | |
| 10067 | 596 * Returns whether or not a status is exclusive. |
| 597 * | |
| 598 * This is a convenience method for | |
| 599 * gaim_status_type_is_exclusive(gaim_status_get_type(status)). | |
| 600 * | |
| 601 * @param status The status. | |
| 602 * | |
| 603 * @return TRUE if the status is exclusive, FALSE otherwise. | |
| 604 */ | |
| 605 gboolean gaim_status_is_exclusive(const GaimStatus *status); | |
| 606 | |
| 607 /** | |
| 9944 | 608 * Returns whether or not a status is available. |
| 609 * | |
| 610 * Available statuses are online and possibly hidden, but not away or idle. | |
| 611 * | |
| 612 * This is a convenience method for | |
| 613 * gaim_status_type_is_available(gaim_status_get_type(status)). | |
| 614 * | |
| 615 * @param status The status. | |
| 616 * | |
| 617 * @return TRUE if the status is available, or FALSE otherwise. | |
| 618 */ | |
| 619 gboolean gaim_status_is_available(const GaimStatus *status); | |
| 620 | |
| 621 /** | |
| 622 * Returns the active state of a status. | |
| 623 * | |
| 624 * @param status The status. | |
| 625 * | |
| 626 * @return The active state of the status. | |
| 627 */ | |
| 628 gboolean gaim_status_is_active(const GaimStatus *status); | |
| 629 | |
| 630 /** | |
|
10040
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
631 * Returns whether or not a status is considered 'online' |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
632 * |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
633 * @param status The status. |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
634 * |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
635 * @return TRUE if the status is considered online, FALSE otherwise |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
636 */ |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
637 gboolean gaim_status_is_online(const GaimStatus *status); |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
638 |
|
81059dce3aed
[gaim-migrate @ 10999]
Luke Schierer <lschiere@pidgin.im>
parents:
10006
diff
changeset
|
639 /** |
| 9944 | 640 * Returns the value of an attribute in a status with the specified ID. |
| 641 * | |
| 642 * @param status The status. | |
| 643 * @param id The attribute ID. | |
| 644 * | |
| 645 * @return The value of the attribute. | |
| 646 */ | |
| 647 GaimValue *gaim_status_get_attr_value(const GaimStatus *status, | |
| 648 const char *id); | |
| 649 | |
| 650 /** | |
| 651 * Returns the boolean value of an attribute in a status with the specified ID. | |
| 652 * | |
| 653 * @param status The status. | |
| 654 * @param id The attribute ID. | |
| 655 * | |
| 656 * @return The boolean value of the attribute. | |
| 657 */ | |
| 658 gboolean gaim_status_get_attr_boolean(const GaimStatus *status, | |
| 659 const char *id); | |
| 660 | |
| 661 /** | |
| 662 * Returns the integer value of an attribute in a status with the specified ID. | |
| 663 * | |
| 664 * @param status The status. | |
| 665 * @param id The attribute ID. | |
| 666 * | |
| 667 * @return The integer value of the attribute. | |
| 668 */ | |
| 669 int gaim_status_get_attr_int(const GaimStatus *status, const char *id); | |
| 670 | |
| 671 /** | |
| 672 * Returns the string value of an attribute in a status with the specified ID. | |
| 673 * | |
| 674 * @param status The status. | |
| 675 * @param id The attribute ID. | |
| 676 * | |
| 677 * @return The string value of the attribute. | |
| 678 */ | |
| 679 const char *gaim_status_get_attr_string(const GaimStatus *status, | |
| 680 const char *id); | |
| 681 | |
| 682 /** | |
| 683 * Compares two statuses for availability. | |
| 684 * | |
| 685 * @param status1 The first status. | |
| 686 * @param status2 The second status. | |
| 687 * | |
| 688 * @return -1 if @a status1 is more available than @a status2. | |
| 689 * 0 if @a status1 is equal to @a status2. | |
| 690 * 1 if @a status2 is more available than @a status1. | |
| 691 */ | |
| 692 gint gaim_status_compare(const GaimStatus *status1, const GaimStatus *status2); | |
| 693 | |
| 694 /*@}*/ | |
| 695 | |
| 696 /**************************************************************************/ | |
| 697 /** @name GaimPresence API */ | |
| 698 /**************************************************************************/ | |
| 699 /*@{*/ | |
| 700 | |
| 701 /** | |
| 702 * Creates a new presence. | |
| 703 * | |
| 704 * @param context The presence context. | |
| 705 * | |
| 706 * @return A new presence. | |
| 707 */ | |
| 708 GaimPresence *gaim_presence_new(GaimPresenceContext context); | |
| 709 | |
| 710 /** | |
| 711 * Creates a presence for an account. | |
| 712 * | |
| 713 * @param account The account. | |
| 714 * | |
| 715 * @return The new presence. | |
| 716 */ | |
| 717 GaimPresence *gaim_presence_new_for_account(GaimAccount *account); | |
| 718 | |
| 719 /** | |
| 720 * Creates a presence for a conversation. | |
| 721 * | |
| 722 * @param conv The conversation. | |
| 723 * | |
| 724 * @return The new presence. | |
| 725 */ | |
| 726 GaimPresence *gaim_presence_new_for_conv(GaimConversation *conv); | |
| 727 | |
| 728 /** | |
| 729 * Creates a presence for a buddy. | |
| 730 * | |
| 731 * @param buddy The buddy. | |
| 732 * | |
| 733 * @return The new presence. | |
| 734 */ | |
| 735 GaimPresence *gaim_presence_new_for_buddy(GaimBuddy *buddy); | |
| 736 | |
| 737 /** | |
| 738 * Destroys a presence. | |
| 739 * | |
| 740 * All statuses added to this list will be destroyed along with | |
| 741 * the presence. | |
| 742 * | |
| 743 * If this presence belongs to a buddy, you must call | |
| 744 * gaim_presence_remove_buddy() first. | |
| 745 * | |
| 746 * @param presence The presence to destroy. | |
| 747 */ | |
| 748 void gaim_presence_destroy(GaimPresence *presence); | |
| 749 | |
| 750 /** | |
| 751 * Removes a buddy from a presence. | |
| 752 * | |
| 753 * This must be done before destroying a buddy in a presence. | |
| 754 * | |
| 755 * @param presence The presence. | |
| 756 * @param buddy The buddy. | |
| 757 */ | |
| 758 void gaim_presence_remove_buddy(GaimPresence *presence, GaimBuddy *buddy); | |
| 759 | |
| 760 /** | |
| 761 * Adds a status to a presence. | |
| 762 * | |
| 763 * @param presence The presence. | |
| 764 * @param status The status to add. | |
| 765 */ | |
| 766 void gaim_presence_add_status(GaimPresence *presence, GaimStatus *status); | |
| 767 | |
| 768 /** | |
| 769 * Adds a list of statuses to the presence. | |
| 770 * | |
| 771 * @param presence The presence. | |
| 772 * @param source_list The source list of statuses to add. | |
| 773 */ | |
| 774 void gaim_presence_add_list(GaimPresence *presence, const GList *source_list); | |
| 775 | |
| 776 /** | |
| 777 * Sets the active state of a status in a presence. | |
| 778 * | |
| 779 * Only independent statuses can be set unactive. Normal statuses can only | |
| 780 * be set active, so if you wish to disable a status, set another | |
| 781 * non-independent status to active, or use gaim_presence_switch_status(). | |
| 782 * | |
| 783 * @param presence The presence. | |
| 784 * @param status_id The ID of the status. | |
| 785 * @param active The active state. | |
| 786 */ | |
| 787 void gaim_presence_set_status_active(GaimPresence *presence, | |
| 788 const char *status_id, gboolean active); | |
| 789 | |
| 790 /** | |
| 791 * Switches the active status in a presence. | |
| 792 * | |
| 793 * This is similar to gaim_presence_set_status_active(), except it won't | |
| 794 * activate independent statuses. | |
| 795 * | |
| 796 * @param presence The presence. | |
| 797 * @param status_id The status ID to switch to. | |
| 798 */ | |
| 799 void gaim_presence_switch_status(GaimPresence *presence, | |
| 800 const char *status_id); | |
| 801 | |
| 802 /** | |
| 803 * Sets the idle state and time on a presence. | |
| 804 * | |
| 805 * @param presence The presence. | |
| 806 * @param idle The idle state. | |
| 10860 | 807 * @param idle_time The idle time, if @a idle is TRUE. This |
| 808 * is the time at which the user became idle, | |
| 809 * in seconds since the epoch. | |
| 9944 | 810 */ |
| 811 void gaim_presence_set_idle(GaimPresence *presence, gboolean idle, | |
| 812 time_t idle_time); | |
| 813 | |
| 814 /** | |
| 10006 | 815 * Sets the login time on a presence. |
| 816 * | |
| 10071 | 817 * @param presence The presence. |
| 818 * @param login_time The login time. | |
| 10006 | 819 */ |
| 820 void gaim_presence_set_login_time(GaimPresence *presence, time_t login_time); | |
| 821 | |
| 9944 | 822 |
| 823 /** | |
| 824 * Returns the presence's context. | |
| 825 * | |
| 826 * @param presence The presence. | |
| 827 * | |
| 828 * @return The presence's context. | |
| 829 */ | |
| 830 GaimPresenceContext gaim_presence_get_context(const GaimPresence *presence); | |
| 831 | |
| 832 /** | |
| 833 * Returns a presence's account. | |
| 834 * | |
| 835 * @param presence The presence. | |
| 836 * | |
| 837 * @return The presence's account. | |
| 838 */ | |
| 839 GaimAccount *gaim_presence_get_account(const GaimPresence *presence); | |
| 840 | |
| 841 /** | |
| 842 * Returns a presence's conversation. | |
| 843 * | |
| 844 * @param presence The presence. | |
| 845 * | |
| 846 * @return The presence's conversation. | |
| 847 */ | |
| 848 GaimConversation *gaim_presence_get_conversation(const GaimPresence *presence); | |
| 849 | |
| 850 /** | |
| 851 * Returns a presence's chat user. | |
| 852 * | |
| 853 * @param presence The presence. | |
| 854 * | |
| 855 * @return The chat's user. | |
| 856 */ | |
| 857 const char *gaim_presence_get_chat_user(const GaimPresence *presence); | |
| 858 | |
| 859 /** | |
| 860 * Returns a presence's list of buddies. | |
| 861 * | |
| 862 * @param presence The presence. | |
| 863 * | |
| 864 * @return The presence's list of buddies. | |
| 865 */ | |
| 866 const GList *gaim_presence_get_buddies(const GaimPresence *presence); | |
| 867 | |
| 868 /** | |
| 869 * Returns all the statuses in a presence. | |
| 870 * | |
| 871 * @param presence The presence. | |
| 872 * | |
| 873 * @return The statuses. | |
| 874 */ | |
| 875 const GList *gaim_presence_get_statuses(const GaimPresence *presence); | |
| 876 | |
| 877 /** | |
| 878 * Returns the status with the specified ID from a presence. | |
| 879 * | |
| 880 * @param presence The presence. | |
| 881 * @param status_id The ID of the status. | |
| 882 * | |
| 883 * @return The status if found, or NULL. | |
| 884 */ | |
| 885 GaimStatus *gaim_presence_get_status(const GaimPresence *presence, | |
| 886 const char *status_id); | |
| 887 | |
| 888 /** | |
| 889 * Returns the active exclusive status from a presence. | |
| 890 * | |
| 891 * @param presence The presence. | |
| 892 * | |
| 893 * @return The active exclusive status. | |
| 894 */ | |
| 895 GaimStatus *gaim_presence_get_active_status(const GaimPresence *presence); | |
| 896 | |
| 897 /** | |
| 898 * Returns whether or not a presence is available. | |
| 899 * | |
| 900 * Available presences are online and possibly hidden, but not away or idle. | |
| 901 * | |
| 902 * @param presence The presence. | |
| 903 * | |
| 904 * @return TRUE if the presence is available, or FALSE otherwise. | |
| 905 */ | |
| 906 gboolean gaim_presence_is_available(const GaimPresence *presence); | |
| 907 | |
| 908 /** | |
| 909 * Returns whether or not a presence is online. | |
| 910 * | |
| 911 * @param presence The presence. | |
| 912 * | |
| 913 * @return TRUE if the presence is online, or FALSE otherwise. | |
| 914 */ | |
| 915 gboolean gaim_presence_is_online(const GaimPresence *presence); | |
| 916 | |
| 917 /** | |
| 918 * Returns whether or not a status in a presence is active. | |
| 919 * | |
| 920 * A status is active if itself or any of its sub-statuses are active. | |
| 921 * | |
| 922 * @param presence The presence. | |
| 923 * @param status_id The ID of the status. | |
| 924 * | |
| 925 * @return TRUE if the status is active, or FALSE. | |
| 926 */ | |
| 927 gboolean gaim_presence_is_status_active(const GaimPresence *presence, | |
| 928 const char *status_id); | |
| 929 | |
| 930 /** | |
| 931 * Returns whether or not a status with the specified primitive type | |
| 932 * in a presence is active. | |
| 933 * | |
| 934 * A status is active if itself or any of its sub-statuses are active. | |
| 935 * | |
| 936 * @param presence The presence. | |
| 937 * @param primitive The status primitive. | |
| 938 * | |
| 939 * @return TRUE if the status is active, or FALSE. | |
| 940 */ | |
| 941 gboolean gaim_presence_is_status_primitive_active( | |
| 942 const GaimPresence *presence, GaimStatusPrimitive primitive); | |
| 943 | |
| 944 /** | |
| 945 * Returns whether or not a presence is idle. | |
| 946 * | |
| 947 * @param presence The presence. | |
| 948 * | |
| 949 * @return TRUE if the presence is idle, or FALSE otherwise. | |
| 11651 | 950 * If the presence is offline (gaim_presence_is_online() |
| 951 * returns FALSE) then FALSE is returned. | |
| 9944 | 952 */ |
| 953 gboolean gaim_presence_is_idle(const GaimPresence *presence); | |
| 954 | |
| 955 /** | |
| 956 * Returns the presence's idle time. | |
| 957 * | |
| 958 * @param presence The presence. | |
| 959 * | |
| 960 * @return The presence's idle time. | |
| 961 */ | |
| 962 time_t gaim_presence_get_idle_time(const GaimPresence *presence); | |
| 963 | |
| 964 /** | |
| 10567 | 965 * Returns the presence's login time. |
| 966 * | |
| 967 * @param presence The presence. | |
| 968 * | |
| 969 * @return The presence's login time. | |
| 970 */ | |
| 971 time_t gaim_presence_get_login_time(const GaimPresence *presence); | |
| 972 | |
| 973 /** | |
| 9944 | 974 * Compares two presences for availability. |
| 975 * | |
| 976 * @param presence1 The first presence. | |
| 977 * @param presence2 The second presence. | |
| 978 * | |
| 10860 | 979 * @return -1 if @a presence1 is more available than @a presence2. |
| 9944 | 980 * 0 if @a presence1 is equal to @a presence2. |
| 10860 | 981 * 1 if @a presence1 is less available than @a presence2. |
| 9944 | 982 */ |
| 983 gint gaim_presence_compare(const GaimPresence *presence1, | |
| 984 const GaimPresence *presence2); | |
| 985 | |
| 986 /*@}*/ | |
| 987 | |
| 988 /**************************************************************************/ | |
| 989 /** @name Status subsystem */ | |
| 990 /**************************************************************************/ | |
| 991 /*@{*/ | |
| 992 | |
| 993 /** | |
| 10087 | 994 * Get the handle for the status subsystem. |
| 995 * | |
| 996 * @return the handle to the status subsystem | |
| 997 */ | |
| 10418 | 998 void *gaim_status_get_handle(); |
| 10087 | 999 |
| 1000 /** | |
| 9944 | 1001 * Initializes the status subsystem. |
| 1002 */ | |
| 10418 | 1003 void gaim_status_init(void); |
| 9944 | 1004 |
| 1005 /** | |
| 1006 * Uninitializes the status subsystem. | |
| 1007 */ | |
| 10418 | 1008 void gaim_status_uninit(void); |
| 9944 | 1009 |
| 1010 /*@}*/ | |
| 1011 | |
| 1012 #endif /* _GAIM_STATUS_H_ */ |
