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