Move the "Change status to" menu to be beside the checkbox controlling it.
[pidgin-git.git] / libpurple / status.h
blob743dd4dbb3309243b905953853da91a29bd7a72a
1 /*
2 * purple
4 * Purple 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.
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_STATUS_H_
23 #define _PURPLE_STATUS_H_
25 /**
26 * @file status.h Status API
27 * @ingroup core
29 * A brief explanation of the status API:
31 * PurpleStatusType'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). PurpleStatusTypes 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.
40 * A PurpleStatus can be thought of as an "instance" of a PurpleStatusType.
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 * PurpleBuddy node for this person in your buddy list. Purple wants
45 * to mark this buddy as "away," so it creates a new PurpleStatus.
46 * The PurpleStatus has its PurpleStatusType set to the "away" state
47 * for the oscar PRPL. The PurpleStatus also contains the buddy's
48 * away message. PurpleStatuses are sometimes saved, depending on
49 * the context. The current PurpleStatuses associated with each of
50 * your accounts are saved so that the next time you start Purple,
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 PurpleStatus has a "saveable" boolean.
54 * If "saveable" is set to FALSE then the status is NEVER saved.
55 * All PurpleStatuses should be inside a PurplePresence.
58 * A PurpleStatus is either "independent" or "exclusive."
59 * Independent statuses can be active or inactive and they don't
60 * affect anything else. However, you can only have one exclusive
61 * status per PurplePresence. If you activate one exclusive status,
62 * then the previous exclusive status is automatically deactivated.
64 * A PurplePresence is like a collection of PurpleStatuses (plus some
65 * other random info). For any buddy, or for any one of your accounts,
66 * or for any person with which you're chatting, you may know various
67 * amounts of information. This information is all contained in
68 * one PurplePresence. If one of your buddies is away and idle,
69 * then the presence contains the PurpleStatus for their awayness,
70 * and it contains their current idle time. PurplePresences are
71 * never saved to disk. The information they contain is only relevant
72 * for the current PurpleSession.
75 /**
76 * PurpleStatusType's are created by each PRPL. They outline the
77 * available statuses of the protocol. AIM, for example, supports
78 * an available state with an optional available message, an away
79 * state with a mandatory message, and an invisible state (which is
80 * technically "independent" of the other two, but we'll get into
81 * that later). PurpleStatusTypes are very permanent. They are
82 * hardcoded in each PRPL and will not change often. And because
83 * they are hardcoded, they do not need to be saved to any XML file.
85 typedef struct _PurpleStatusType PurpleStatusType;
86 typedef struct _PurpleStatusAttr PurpleStatusAttr;
87 typedef struct _PurplePresence PurplePresence;
88 typedef struct _PurpleStatus PurpleStatus;
90 /**
91 * A context for a presence.
93 * The context indicates to what the presence applies.
95 typedef enum
97 PURPLE_PRESENCE_CONTEXT_UNSET = 0,
98 PURPLE_PRESENCE_CONTEXT_ACCOUNT,
99 PURPLE_PRESENCE_CONTEXT_CONV,
100 PURPLE_PRESENCE_CONTEXT_BUDDY
102 } PurplePresenceContext;
105 * A primitive defining the basic structure of a status type.
108 * If you add a value to this enum, make sure you update
109 * the status_primitive_map array in status.c and the special-cases for idle
110 * and offline-messagable just below it.
112 typedef enum
114 PURPLE_STATUS_UNSET = 0,
115 PURPLE_STATUS_OFFLINE,
116 PURPLE_STATUS_AVAILABLE,
117 PURPLE_STATUS_UNAVAILABLE,
118 PURPLE_STATUS_INVISIBLE,
119 PURPLE_STATUS_AWAY,
120 PURPLE_STATUS_EXTENDED_AWAY,
121 PURPLE_STATUS_MOBILE,
122 PURPLE_STATUS_TUNE,
123 PURPLE_STATUS_NUM_PRIMITIVES
124 } PurpleStatusPrimitive;
126 #include "account.h"
127 #include "blist.h"
128 #include "conversation.h"
129 #include "value.h"
131 #define PURPLE_TUNE_ARTIST "tune_artist"
132 #define PURPLE_TUNE_TITLE "tune_title"
133 #define PURPLE_TUNE_ALBUM "tune_album"
134 #define PURPLE_TUNE_GENRE "tune_genre"
135 #define PURPLE_TUNE_COMMENT "tune_comment"
136 #define PURPLE_TUNE_TRACK "tune_track"
137 #define PURPLE_TUNE_TIME "tune_time"
138 #define PURPLE_TUNE_YEAR "tune_year"
139 #define PURPLE_TUNE_URL "tune_url"
140 #define PURPLE_TUNE_FULL "tune_full"
142 #ifdef __cplusplus
143 extern "C" {
144 #endif
146 /**************************************************************************/
147 /** @name PurpleStatusPrimitive API */
148 /**************************************************************************/
149 /*@{*/
152 * Lookup the id of a primitive status type based on the type. This
153 * ID is a unique plain-text name of the status, without spaces.
155 * @param type A primitive status type.
157 * @return The unique ID for this type.
159 const char *purple_primitive_get_id_from_type(PurpleStatusPrimitive type);
162 * Lookup the name of a primitive status type based on the type. This
163 * name is the plain-English name of the status type. It is usually one
164 * or two words.
166 * @param type A primitive status type.
168 * @return The name of this type, suitable for users to see.
170 const char *purple_primitive_get_name_from_type(PurpleStatusPrimitive type);
173 * Lookup the value of a primitive status type based on the id. The
174 * ID is a unique plain-text name of the status, without spaces.
176 * @param id The unique ID of a primitive status type.
178 * @return The PurpleStatusPrimitive value.
180 PurpleStatusPrimitive purple_primitive_get_type_from_id(const char *id);
182 /*@}*/
184 /**************************************************************************/
185 /** @name PurpleStatusType API */
186 /**************************************************************************/
187 /*@{*/
190 * Creates a new status type.
192 * @param primitive The primitive status type.
193 * @param id The ID of the status type, or @c NULL to use the id of
194 * the primitive status type.
195 * @param name The name presented to the user, or @c NULL to use the
196 * name of the primitive status type.
197 * @param saveable TRUE if the information set for this status by the
198 * user can be saved for future sessions.
199 * @param user_settable TRUE if this is a status the user can manually set.
200 * @param independent TRUE if this is an independent (non-exclusive)
201 * status type.
203 * @return A new status type.
205 PurpleStatusType *purple_status_type_new_full(PurpleStatusPrimitive primitive,
206 const char *id, const char *name,
207 gboolean saveable,
208 gboolean user_settable,
209 gboolean independent);
212 * Creates a new status type with some default values (
213 * saveable and not independent).
215 * @param primitive The primitive status type.
216 * @param id The ID of the status type, or @c NULL to use the id of
217 * the primitive status type.
218 * @param name The name presented to the user, or @c NULL to use the
219 * name of the primitive status type.
220 * @param user_settable TRUE if this is a status the user can manually set.
222 * @return A new status type.
224 PurpleStatusType *purple_status_type_new(PurpleStatusPrimitive primitive,
225 const char *id, const char *name,
226 gboolean user_settable);
229 * Creates a new status type with attributes.
231 * @param primitive The primitive status type.
232 * @param id The ID of the status type, or @c NULL to use the id of
233 * the primitive status type.
234 * @param name The name presented to the user, or @c NULL to use the
235 * name of the primitive status type.
236 * @param saveable TRUE if the information set for this status by the
237 * user can be saved for future sessions.
238 * @param user_settable TRUE if this is a status the user can manually set.
239 * @param independent TRUE if this is an independent (non-exclusive)
240 * status type.
241 * @param attr_id The ID of the first attribute.
242 * @param attr_name The name of the first attribute.
243 * @param attr_value The value type of the first attribute attribute.
244 * @param ... Additional attribute information.
246 * @return A new status type.
248 PurpleStatusType *purple_status_type_new_with_attrs(PurpleStatusPrimitive primitive,
249 const char *id,
250 const char *name,
251 gboolean saveable,
252 gboolean user_settable,
253 gboolean independent,
254 const char *attr_id,
255 const char *attr_name,
256 PurpleValue *attr_value, ...) G_GNUC_NULL_TERMINATED;
259 * Destroys a status type.
261 * @param status_type The status type to destroy.
263 void purple_status_type_destroy(PurpleStatusType *status_type);
265 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
267 * Sets a status type's primary attribute.
269 * The value for the primary attribute is used as the description for
270 * the particular status type. An example is an away message. The message
271 * would be the primary attribute.
273 * @param status_type The status type.
274 * @param attr_id The ID of the primary attribute.
276 * @deprecated This function isn't used and should be removed in 3.0.0.
278 void purple_status_type_set_primary_attr(PurpleStatusType *status_type,
279 const char *attr_id);
280 #endif
282 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
284 * Adds an attribute to a status type.
286 * @param status_type The status type to add the attribute to.
287 * @param id The ID of the attribute.
288 * @param name The name presented to the user.
289 * @param value The value type of this attribute.
291 * @deprecated This function isn't needed and should be removed in 3.0.0.
292 * Status type attributes should be set when the status type
293 * is created, in the call to purple_status_type_new_with_attrs.
295 void purple_status_type_add_attr(PurpleStatusType *status_type, const char *id,
296 const char *name, PurpleValue *value);
297 #endif
299 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
301 * Adds multiple attributes to a status type.
303 * @param status_type The status type to add the attribute to.
304 * @param id The ID of the first attribute.
305 * @param name The description of the first attribute.
306 * @param value The value type of the first attribute attribute.
307 * @param ... Additional attribute information.
309 * @deprecated This function isn't needed and should be removed in 3.0.0.
310 * Status type attributes should be set when the status type
311 * is created, in the call to purple_status_type_new_with_attrs.
313 void purple_status_type_add_attrs(PurpleStatusType *status_type, const char *id,
314 const char *name, PurpleValue *value, ...) G_GNUC_NULL_TERMINATED;
315 #endif
317 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
319 * Adds multiple attributes to a status type using a va_list.
321 * @param status_type The status type to add the attribute to.
322 * @param args The va_list of attributes.
324 * @deprecated This function isn't needed and should be removed in 3.0.0.
325 * Status type attributes should be set when the status type
326 * is created, in the call to purple_status_type_new_with_attrs.
328 void purple_status_type_add_attrs_vargs(PurpleStatusType *status_type,
329 va_list args);
330 #endif
333 * Returns the primitive type of a status type.
335 * @param status_type The status type.
337 * @return The primitive type of the status type.
339 PurpleStatusPrimitive purple_status_type_get_primitive(
340 const PurpleStatusType *status_type);
343 * Returns the ID of a status type.
345 * @param status_type The status type.
347 * @return The ID of the status type.
349 const char *purple_status_type_get_id(const PurpleStatusType *status_type);
352 * Returns the name of a status type.
354 * @param status_type The status type.
356 * @return The name of the status type.
358 const char *purple_status_type_get_name(const PurpleStatusType *status_type);
361 * Returns whether or not the status type is saveable.
363 * @param status_type The status type.
365 * @return TRUE if user-defined statuses based off this type are saveable.
366 * FALSE otherwise.
368 gboolean purple_status_type_is_saveable(const PurpleStatusType *status_type);
371 * Returns whether or not the status type can be set or modified by the
372 * user.
374 * @param status_type The status type.
376 * @return TRUE if the status type can be set or modified by the user.
377 * FALSE if it's a protocol-set setting.
379 gboolean purple_status_type_is_user_settable(const PurpleStatusType *status_type);
382 * Returns whether or not the status type is independent.
384 * Independent status types are non-exclusive. If other status types on
385 * the same hierarchy level are set, this one will not be affected.
387 * @param status_type The status type.
389 * @return TRUE if the status type is independent, or FALSE otherwise.
391 gboolean purple_status_type_is_independent(const PurpleStatusType *status_type);
394 * Returns whether the status type is exclusive.
396 * @param status_type The status type.
398 * @return TRUE if the status type is exclusive, FALSE otherwise.
400 gboolean purple_status_type_is_exclusive(const PurpleStatusType *status_type);
403 * Returns whether or not a status type is available.
405 * Available status types are online and possibly invisible, but not away.
407 * @param status_type The status type.
409 * @return TRUE if the status is available, or FALSE otherwise.
411 gboolean purple_status_type_is_available(const PurpleStatusType *status_type);
413 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
415 * Returns a status type's primary attribute ID.
417 * @param type The status type.
419 * @return The primary attribute's ID.
421 * @deprecated This function isn't used and should be removed in 3.0.0.
423 const char *purple_status_type_get_primary_attr(const PurpleStatusType *type);
424 #endif
427 * Returns the attribute with the specified ID.
429 * @param status_type The status type containing the attribute.
430 * @param id The ID of the desired attribute.
432 * @return The attribute, if found. NULL otherwise.
434 PurpleStatusAttr *purple_status_type_get_attr(const PurpleStatusType *status_type,
435 const char *id);
438 * Returns a list of all attributes in a status type.
440 * @param status_type The status type.
442 * @constreturn The list of attributes.
444 GList *purple_status_type_get_attrs(const PurpleStatusType *status_type);
447 * Find the PurpleStatusType with the given id.
449 * @param status_types A list of status types. Often account->status_types.
450 * @param id The unique ID of the status type you wish to find.
452 * @return The status type with the given ID, or NULL if one could
453 * not be found.
455 const PurpleStatusType *purple_status_type_find_with_id(GList *status_types,
456 const char *id);
458 /*@}*/
460 /**************************************************************************/
461 /** @name PurpleStatusAttr API */
462 /**************************************************************************/
463 /*@{*/
466 * Creates a new status attribute.
468 * @param id The ID of the attribute.
469 * @param name The name presented to the user.
470 * @param value_type The type of data contained in the attribute.
472 * @return A new status attribute.
474 PurpleStatusAttr *purple_status_attr_new(const char *id, const char *name,
475 PurpleValue *value_type);
478 * Destroys a status attribute.
480 * @param attr The status attribute to destroy.
482 void purple_status_attr_destroy(PurpleStatusAttr *attr);
485 * Returns the ID of a status attribute.
487 * @param attr The status attribute.
489 * @return The status attribute's ID.
491 const char *purple_status_attr_get_id(const PurpleStatusAttr *attr);
494 * Returns the name of a status attribute.
496 * @param attr The status attribute.
498 * @return The status attribute's name.
500 const char *purple_status_attr_get_name(const PurpleStatusAttr *attr);
503 * Returns the value of a status attribute.
505 * @param attr The status attribute.
507 * @return The status attribute's value.
509 PurpleValue *purple_status_attr_get_value(const PurpleStatusAttr *attr);
511 /*@}*/
513 /**************************************************************************/
514 /** @name PurpleStatus API */
515 /**************************************************************************/
516 /*@{*/
519 * Creates a new status.
521 * @param status_type The type of status.
522 * @param presence The parent presence.
524 * @return The new status.
526 PurpleStatus *purple_status_new(PurpleStatusType *status_type,
527 PurplePresence *presence);
530 * Destroys a status.
532 * @param status The status to destroy.
534 void purple_status_destroy(PurpleStatus *status);
537 * Sets whether or not a status is active.
539 * This should only be called by the account, conversation, and buddy APIs.
541 * @param status The status.
542 * @param active The active state.
544 void purple_status_set_active(PurpleStatus *status, gboolean active);
547 * Sets whether or not a status is active.
549 * This should only be called by the account, conversation, and buddy APIs.
551 * @param status The status.
552 * @param active The active state.
553 * @param args A list of attributes to set on the status. This list is
554 * composed of key/value pairs, where each key is a valid
555 * attribute name for this PurpleStatusType. The list should
556 * be NULL terminated.
558 void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active,
559 va_list args);
562 * Sets whether or not a status is active.
564 * This should only be called by the account, conversation, and buddy APIs.
566 * @param status The status.
567 * @param active The active state.
568 * @param attrs A list of attributes to set on the status. This list is
569 * composed of key/value pairs, where each key is a valid
570 * attribute name for this PurpleStatusType. The list is
571 * not modified or freed by this function.
573 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
574 GList *attrs);
576 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
578 * Sets the boolean value of an attribute in a status with the specified ID.
580 * @param status The status.
581 * @param id The attribute ID.
582 * @param value The boolean value.
584 * @deprecated This function is only used by status.c and should be made
585 * static in 3.0.0.
587 void purple_status_set_attr_boolean(PurpleStatus *status, const char *id,
588 gboolean value);
589 #endif
591 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
593 * Sets the integer value of an attribute in a status with the specified ID.
595 * @param status The status.
596 * @param id The attribute ID.
597 * @param value The integer value.
599 * @deprecated This function is only used by status.c and should be made
600 * static in 3.0.0.
602 void purple_status_set_attr_int(PurpleStatus *status, const char *id,
603 int value);
604 #endif
606 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
608 * Sets the string value of an attribute in a status with the specified ID.
610 * @param status The status.
611 * @param id The attribute ID.
612 * @param value The string value.
614 * @deprecated This function is only used by status.c and should be made
615 * static in 3.0.0.
617 void purple_status_set_attr_string(PurpleStatus *status, const char *id,
618 const char *value);
619 #endif
622 * Returns the status's type.
624 * @param status The status.
626 * @return The status's type.
628 PurpleStatusType *purple_status_get_type(const PurpleStatus *status);
631 * Returns the status's presence.
633 * @param status The status.
635 * @return The status's presence.
637 PurplePresence *purple_status_get_presence(const PurpleStatus *status);
640 * Returns the status's type ID.
642 * This is a convenience method for
643 * purple_status_type_get_id(purple_status_get_type(status)).
645 * @param status The status.
647 * @return The status's ID.
649 const char *purple_status_get_id(const PurpleStatus *status);
652 * Returns the status's name.
654 * This is a convenience method for
655 * purple_status_type_get_name(purple_status_get_type(status)).
657 * @param status The status.
659 * @return The status's name.
661 const char *purple_status_get_name(const PurpleStatus *status);
664 * Returns whether or not a status is independent.
666 * This is a convenience method for
667 * purple_status_type_is_independent(purple_status_get_type(status)).
669 * @param status The status.
671 * @return TRUE if the status is independent, or FALSE otherwise.
673 gboolean purple_status_is_independent(const PurpleStatus *status);
676 * Returns whether or not a status is exclusive.
678 * This is a convenience method for
679 * purple_status_type_is_exclusive(purple_status_get_type(status)).
681 * @param status The status.
683 * @return TRUE if the status is exclusive, FALSE otherwise.
685 gboolean purple_status_is_exclusive(const PurpleStatus *status);
688 * Returns whether or not a status is available.
690 * Available statuses are online and possibly invisible, but not away or idle.
692 * This is a convenience method for
693 * purple_status_type_is_available(purple_status_get_type(status)).
695 * @param status The status.
697 * @return TRUE if the status is available, or FALSE otherwise.
699 gboolean purple_status_is_available(const PurpleStatus *status);
702 * Returns the active state of a status.
704 * @param status The status.
706 * @return The active state of the status.
708 gboolean purple_status_is_active(const PurpleStatus *status);
711 * Returns whether or not a status is considered 'online'
713 * @param status The status.
715 * @return TRUE if the status is considered online, FALSE otherwise
717 gboolean purple_status_is_online(const PurpleStatus *status);
720 * Returns the value of an attribute in a status with the specified ID.
722 * @param status The status.
723 * @param id The attribute ID.
725 * @return The value of the attribute.
727 PurpleValue *purple_status_get_attr_value(const PurpleStatus *status,
728 const char *id);
731 * Returns the boolean value of an attribute in a status with the specified ID.
733 * @param status The status.
734 * @param id The attribute ID.
736 * @return The boolean value of the attribute.
738 gboolean purple_status_get_attr_boolean(const PurpleStatus *status,
739 const char *id);
742 * Returns the integer value of an attribute in a status with the specified ID.
744 * @param status The status.
745 * @param id The attribute ID.
747 * @return The integer value of the attribute.
749 int purple_status_get_attr_int(const PurpleStatus *status, const char *id);
752 * Returns the string value of an attribute in a status with the specified ID.
754 * @param status The status.
755 * @param id The attribute ID.
757 * @return The string value of the attribute.
759 const char *purple_status_get_attr_string(const PurpleStatus *status,
760 const char *id);
763 * Compares two statuses for availability.
765 * @param status1 The first status.
766 * @param status2 The second status.
768 * @return -1 if @a status1 is more available than @a status2.
769 * 0 if @a status1 is equal to @a status2.
770 * 1 if @a status2 is more available than @a status1.
772 gint purple_status_compare(const PurpleStatus *status1, const PurpleStatus *status2);
774 /*@}*/
776 /**************************************************************************/
777 /** @name PurplePresence API */
778 /**************************************************************************/
779 /*@{*/
782 * Creates a new presence.
784 * @param context The presence context.
786 * @return A new presence.
788 PurplePresence *purple_presence_new(PurplePresenceContext context);
791 * Creates a presence for an account.
793 * @param account The account.
795 * @return The new presence.
797 PurplePresence *purple_presence_new_for_account(PurpleAccount *account);
800 * Creates a presence for a conversation.
802 * @param conv The conversation.
804 * @return The new presence.
806 PurplePresence *purple_presence_new_for_conv(PurpleConversation *conv);
809 * Creates a presence for a buddy.
811 * @param buddy The buddy.
813 * @return The new presence.
815 PurplePresence *purple_presence_new_for_buddy(PurpleBuddy *buddy);
818 * Destroys a presence.
820 * All statuses added to this list will be destroyed along with
821 * the presence.
823 * @param presence The presence to destroy.
825 void purple_presence_destroy(PurplePresence *presence);
827 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
829 * Adds a status to a presence.
831 * @param presence The presence.
832 * @param status The status to add.
834 * @deprecated This function is only used by purple_presence_add_list,
835 * and both should be removed in 3.0.0.
837 void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status);
838 #endif
840 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
842 * Adds a list of statuses to the presence.
844 * @param presence The presence.
845 * @param source_list The source list of statuses to add, which is not
846 * modified or freed by this function.
848 * @deprecated This function isn't used and should be removed in 3.0.0.
850 void purple_presence_add_list(PurplePresence *presence, GList *source_list);
851 #endif
854 * Sets the active state of a status in a presence.
856 * Only independent statuses can be set unactive. Normal statuses can only
857 * be set active, so if you wish to disable a status, set another
858 * non-independent status to active, or use purple_presence_switch_status().
860 * @param presence The presence.
861 * @param status_id The ID of the status.
862 * @param active The active state.
864 void purple_presence_set_status_active(PurplePresence *presence,
865 const char *status_id, gboolean active);
868 * Switches the active status in a presence.
870 * This is similar to purple_presence_set_status_active(), except it won't
871 * activate independent statuses.
873 * @param presence The presence.
874 * @param status_id The status ID to switch to.
876 void purple_presence_switch_status(PurplePresence *presence,
877 const char *status_id);
880 * Sets the idle state and time on a presence.
882 * @param presence The presence.
883 * @param idle The idle state.
884 * @param idle_time The idle time, if @a idle is TRUE. This
885 * is the time at which the user became idle,
886 * in seconds since the epoch. If this value is
887 * unknown then 0 should be used.
889 void purple_presence_set_idle(PurplePresence *presence, gboolean idle,
890 time_t idle_time);
893 * Sets the login time on a presence.
895 * @param presence The presence.
896 * @param login_time The login time.
898 void purple_presence_set_login_time(PurplePresence *presence, time_t login_time);
902 * Returns the presence's context.
904 * @param presence The presence.
906 * @return The presence's context.
908 PurplePresenceContext purple_presence_get_context(const PurplePresence *presence);
911 * Returns a presence's account.
913 * @param presence The presence.
915 * @return The presence's account.
917 PurpleAccount *purple_presence_get_account(const PurplePresence *presence);
920 * Returns a presence's conversation.
922 * @param presence The presence.
924 * @return The presence's conversation.
926 PurpleConversation *purple_presence_get_conversation(const PurplePresence *presence);
929 * Returns a presence's chat user.
931 * @param presence The presence.
933 * @return The chat's user.
935 const char *purple_presence_get_chat_user(const PurplePresence *presence);
938 * Returns the presence's buddy.
940 * @param presence The presence.
942 * @return The presence's buddy.
944 PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence);
947 * Returns all the statuses in a presence.
949 * @param presence The presence.
951 * @constreturn The statuses.
953 GList *purple_presence_get_statuses(const PurplePresence *presence);
956 * Returns the status with the specified ID from a presence.
958 * @param presence The presence.
959 * @param status_id The ID of the status.
961 * @return The status if found, or NULL.
963 PurpleStatus *purple_presence_get_status(const PurplePresence *presence,
964 const char *status_id);
967 * Returns the active exclusive status from a presence.
969 * @param presence The presence.
971 * @return The active exclusive status.
973 PurpleStatus *purple_presence_get_active_status(const PurplePresence *presence);
976 * Returns whether or not a presence is available.
978 * Available presences are online and possibly invisible, but not away or idle.
980 * @param presence The presence.
982 * @return TRUE if the presence is available, or FALSE otherwise.
984 gboolean purple_presence_is_available(const PurplePresence *presence);
987 * Returns whether or not a presence is online.
989 * @param presence The presence.
991 * @return TRUE if the presence is online, or FALSE otherwise.
993 gboolean purple_presence_is_online(const PurplePresence *presence);
996 * Returns whether or not a status in a presence is active.
998 * A status is active if itself or any of its sub-statuses are active.
1000 * @param presence The presence.
1001 * @param status_id The ID of the status.
1003 * @return TRUE if the status is active, or FALSE.
1005 gboolean purple_presence_is_status_active(const PurplePresence *presence,
1006 const char *status_id);
1009 * Returns whether or not a status with the specified primitive type
1010 * in a presence is active.
1012 * A status is active if itself or any of its sub-statuses are active.
1014 * @param presence The presence.
1015 * @param primitive The status primitive.
1017 * @return TRUE if the status is active, or FALSE.
1019 gboolean purple_presence_is_status_primitive_active(
1020 const PurplePresence *presence, PurpleStatusPrimitive primitive);
1023 * Returns whether or not a presence is idle.
1025 * @param presence The presence.
1027 * @return TRUE if the presence is idle, or FALSE otherwise.
1028 * If the presence is offline (purple_presence_is_online()
1029 * returns FALSE) then FALSE is returned.
1031 gboolean purple_presence_is_idle(const PurplePresence *presence);
1034 * Returns the presence's idle time.
1036 * @param presence The presence.
1038 * @return The presence's idle time.
1040 time_t purple_presence_get_idle_time(const PurplePresence *presence);
1043 * Returns the presence's login time.
1045 * @param presence The presence.
1047 * @return The presence's login time.
1049 time_t purple_presence_get_login_time(const PurplePresence *presence);
1052 * Compares two presences for availability.
1054 * @param presence1 The first presence.
1055 * @param presence2 The second presence.
1057 * @return -1 if @a presence1 is more available than @a presence2.
1058 * 0 if @a presence1 is equal to @a presence2.
1059 * 1 if @a presence1 is less available than @a presence2.
1061 gint purple_presence_compare(const PurplePresence *presence1,
1062 const PurplePresence *presence2);
1064 /*@}*/
1066 /**************************************************************************/
1067 /** @name Status subsystem */
1068 /**************************************************************************/
1069 /*@{*/
1072 * Get the handle for the status subsystem.
1074 * @return the handle to the status subsystem
1076 void *purple_status_get_handle(void);
1079 * Initializes the status subsystem.
1081 void purple_status_init(void);
1084 * Uninitializes the status subsystem.
1086 void purple_status_uninit(void);
1088 /*@}*/
1090 #ifdef __cplusplus
1092 #endif
1094 #endif /* _PURPLE_STATUS_H_ */