comparison libgaim/status.h @ 14192:60b1bc8dbf37

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