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
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_
26 * @file status.h Status API
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.
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 typedef struct _PurpleMood
{
92 const char *description
;
97 * A context for a presence.
99 * The context indicates to what the presence applies.
103 PURPLE_PRESENCE_CONTEXT_UNSET
= 0,
104 PURPLE_PRESENCE_CONTEXT_ACCOUNT
,
105 PURPLE_PRESENCE_CONTEXT_CONV
,
106 PURPLE_PRESENCE_CONTEXT_BUDDY
108 } PurplePresenceContext
;
111 * A primitive defining the basic structure of a status type.
114 * If you add a value to this enum, make sure you update
115 * the status_primitive_map and primitive_scores arrays in status.c.
119 PURPLE_STATUS_UNSET
= 0,
120 PURPLE_STATUS_OFFLINE
,
121 PURPLE_STATUS_AVAILABLE
,
122 PURPLE_STATUS_UNAVAILABLE
,
123 PURPLE_STATUS_INVISIBLE
,
125 PURPLE_STATUS_EXTENDED_AWAY
,
126 PURPLE_STATUS_MOBILE
,
129 PURPLE_STATUS_NUM_PRIMITIVES
130 } PurpleStatusPrimitive
;
134 #include "conversation.h"
137 #define PURPLE_TUNE_ARTIST "tune_artist"
138 #define PURPLE_TUNE_TITLE "tune_title"
139 #define PURPLE_TUNE_ALBUM "tune_album"
140 #define PURPLE_TUNE_GENRE "tune_genre"
141 #define PURPLE_TUNE_COMMENT "tune_comment"
142 #define PURPLE_TUNE_TRACK "tune_track"
143 #define PURPLE_TUNE_TIME "tune_time"
144 #define PURPLE_TUNE_YEAR "tune_year"
145 #define PURPLE_TUNE_URL "tune_url"
146 #define PURPLE_TUNE_FULL "tune_full"
148 #define PURPLE_MOOD_NAME "mood"
149 #define PURPLE_MOOD_COMMENT "moodtext"
155 /**************************************************************************/
156 /** @name PurpleStatusPrimitive API */
157 /**************************************************************************/
161 * Lookup the id of a primitive status type based on the type. This
162 * ID is a unique plain-text name of the status, without spaces.
164 * @param type A primitive status type.
166 * @return The unique ID for this type.
168 const char *purple_primitive_get_id_from_type(PurpleStatusPrimitive type
);
171 * Lookup the name of a primitive status type based on the type. This
172 * name is the plain-English name of the status type. It is usually one
175 * @param type A primitive status type.
177 * @return The name of this type, suitable for users to see.
179 const char *purple_primitive_get_name_from_type(PurpleStatusPrimitive type
);
182 * Lookup the value of a primitive status type based on the id. The
183 * ID is a unique plain-text name of the status, without spaces.
185 * @param id The unique ID of a primitive status type.
187 * @return The PurpleStatusPrimitive value.
189 PurpleStatusPrimitive
purple_primitive_get_type_from_id(const char *id
);
193 /**************************************************************************/
194 /** @name PurpleStatusType API */
195 /**************************************************************************/
199 * Creates a new status type.
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)
212 * @return A new status type.
214 PurpleStatusType
*purple_status_type_new_full(PurpleStatusPrimitive primitive
,
215 const char *id
, const char *name
,
217 gboolean user_settable
,
218 gboolean independent
);
221 * Creates a new status type with some default values (
222 * saveable and not independent).
224 * @param primitive The primitive status type.
225 * @param id The ID of the status type, or @c NULL to use the id of
226 * the primitive status type.
227 * @param name The name presented to the user, or @c NULL to use the
228 * name of the primitive status type.
229 * @param user_settable TRUE if this is a status the user can manually set.
231 * @return A new status type.
233 PurpleStatusType
*purple_status_type_new(PurpleStatusPrimitive primitive
,
234 const char *id
, const char *name
,
235 gboolean user_settable
);
238 * Creates a new status type with attributes.
240 * @param primitive The primitive status type.
241 * @param id The ID of the status type, or @c NULL to use the id of
242 * the primitive status type.
243 * @param name The name presented to the user, or @c NULL to use the
244 * name of the primitive status type.
245 * @param saveable TRUE if the information set for this status by the
246 * user can be saved for future sessions.
247 * @param user_settable TRUE if this is a status the user can manually set.
248 * @param independent TRUE if this is an independent (non-exclusive)
250 * @param attr_id The ID of the first attribute.
251 * @param attr_name The name of the first attribute.
252 * @param attr_value The value type of the first attribute attribute.
253 * @param ... Additional attribute information.
255 * @return A new status type.
257 PurpleStatusType
*purple_status_type_new_with_attrs(PurpleStatusPrimitive primitive
,
261 gboolean user_settable
,
262 gboolean independent
,
264 const char *attr_name
,
265 PurpleValue
*attr_value
, ...) G_GNUC_NULL_TERMINATED
;
268 * Destroys a status type.
270 * @param status_type The status type to destroy.
272 void purple_status_type_destroy(PurpleStatusType
*status_type
);
274 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
276 * Sets a status type's primary attribute.
278 * The value for the primary attribute is used as the description for
279 * the particular status type. An example is an away message. The message
280 * would be the primary attribute.
282 * @param status_type The status type.
283 * @param attr_id The ID of the primary attribute.
285 * @deprecated This function isn't used and should be removed in 3.0.0.
287 void purple_status_type_set_primary_attr(PurpleStatusType
*status_type
,
288 const char *attr_id
);
291 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
293 * Adds an attribute to a status type.
295 * @param status_type The status type to add the attribute to.
296 * @param id The ID of the attribute.
297 * @param name The name presented to the user.
298 * @param value The value type of this attribute.
300 * @deprecated This function isn't needed and should be removed in 3.0.0.
301 * Status type attributes should be set when the status type
302 * is created, in the call to purple_status_type_new_with_attrs.
304 void purple_status_type_add_attr(PurpleStatusType
*status_type
, const char *id
,
305 const char *name
, PurpleValue
*value
);
308 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
310 * Adds multiple attributes to a status type.
312 * @param status_type The status type to add the attribute to.
313 * @param id The ID of the first attribute.
314 * @param name The description of the first attribute.
315 * @param value The value type of the first attribute attribute.
316 * @param ... Additional attribute information.
318 * @deprecated This function isn't needed and should be removed in 3.0.0.
319 * Status type attributes should be set when the status type
320 * is created, in the call to purple_status_type_new_with_attrs.
322 void purple_status_type_add_attrs(PurpleStatusType
*status_type
, const char *id
,
323 const char *name
, PurpleValue
*value
, ...) G_GNUC_NULL_TERMINATED
;
326 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
328 * Adds multiple attributes to a status type using a va_list.
330 * @param status_type The status type to add the attribute to.
331 * @param args The va_list of attributes.
333 * @deprecated This function isn't needed and should be removed in 3.0.0.
334 * Status type attributes should be set when the status type
335 * is created, in the call to purple_status_type_new_with_attrs.
337 void purple_status_type_add_attrs_vargs(PurpleStatusType
*status_type
,
342 * Returns the primitive type of a status type.
344 * @param status_type The status type.
346 * @return The primitive type of the status type.
348 PurpleStatusPrimitive
purple_status_type_get_primitive(
349 const PurpleStatusType
*status_type
);
352 * Returns the ID of a status type.
354 * @param status_type The status type.
356 * @return The ID of the status type.
358 const char *purple_status_type_get_id(const PurpleStatusType
*status_type
);
361 * Returns the name of a status type.
363 * @param status_type The status type.
365 * @return The name of the status type.
367 const char *purple_status_type_get_name(const PurpleStatusType
*status_type
);
370 * Returns whether or not the status type is saveable.
372 * @param status_type The status type.
374 * @return TRUE if user-defined statuses based off this type are saveable.
377 gboolean
purple_status_type_is_saveable(const PurpleStatusType
*status_type
);
380 * Returns whether or not the status type can be set or modified by the
383 * @param status_type The status type.
385 * @return TRUE if the status type can be set or modified by the user.
386 * FALSE if it's a protocol-set setting.
388 gboolean
purple_status_type_is_user_settable(const PurpleStatusType
*status_type
);
391 * Returns whether or not the status type is independent.
393 * Independent status types are non-exclusive. If other status types on
394 * the same hierarchy level are set, this one will not be affected.
396 * @param status_type The status type.
398 * @return TRUE if the status type is independent, or FALSE otherwise.
400 gboolean
purple_status_type_is_independent(const PurpleStatusType
*status_type
);
403 * Returns whether the status type is exclusive.
405 * @param status_type The status type.
407 * @return TRUE if the status type is exclusive, FALSE otherwise.
409 gboolean
purple_status_type_is_exclusive(const PurpleStatusType
*status_type
);
412 * Returns whether or not a status type is available.
414 * Available status types are online and possibly invisible, but not away.
416 * @param status_type The status type.
418 * @return TRUE if the status is available, or FALSE otherwise.
420 gboolean
purple_status_type_is_available(const PurpleStatusType
*status_type
);
422 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
424 * Returns a status type's primary attribute ID.
426 * @param type The status type.
428 * @return The primary attribute's ID.
430 * @deprecated This function isn't used and should be removed in 3.0.0.
432 const char *purple_status_type_get_primary_attr(const PurpleStatusType
*type
);
436 * Returns the attribute with the specified ID.
438 * @param status_type The status type containing the attribute.
439 * @param id The ID of the desired attribute.
441 * @return The attribute, if found. NULL otherwise.
443 PurpleStatusAttr
*purple_status_type_get_attr(const PurpleStatusType
*status_type
,
447 * Returns a list of all attributes in a status type.
449 * @param status_type The status type.
451 * @constreturn The list of attributes.
453 GList
*purple_status_type_get_attrs(const PurpleStatusType
*status_type
);
456 * Find the PurpleStatusType with the given id.
458 * @param status_types A list of status types. Often account->status_types.
459 * @param id The unique ID of the status type you wish to find.
461 * @return The status type with the given ID, or NULL if one could
464 const PurpleStatusType
*purple_status_type_find_with_id(GList
*status_types
,
469 /**************************************************************************/
470 /** @name PurpleStatusAttr API */
471 /**************************************************************************/
475 * Creates a new status attribute.
477 * @param id The ID of the attribute.
478 * @param name The name presented to the user.
479 * @param value_type The type of data contained in the attribute.
481 * @return A new status attribute.
483 PurpleStatusAttr
*purple_status_attr_new(const char *id
, const char *name
,
484 PurpleValue
*value_type
);
487 * Destroys a status attribute.
489 * @param attr The status attribute to destroy.
491 void purple_status_attr_destroy(PurpleStatusAttr
*attr
);
494 * Returns the ID of a status attribute.
496 * @param attr The status attribute.
498 * @return The status attribute's ID.
500 const char *purple_status_attr_get_id(const PurpleStatusAttr
*attr
);
503 * Returns the name of a status attribute.
505 * @param attr The status attribute.
507 * @return The status attribute's name.
509 const char *purple_status_attr_get_name(const PurpleStatusAttr
*attr
);
512 * Returns the value of a status attribute.
514 * @param attr The status attribute.
516 * @return The status attribute's value.
518 PurpleValue
*purple_status_attr_get_value(const PurpleStatusAttr
*attr
);
522 /**************************************************************************/
523 /** @name PurpleStatus API */
524 /**************************************************************************/
528 * Creates a new status.
530 * @param status_type The type of status.
531 * @param presence The parent presence.
533 * @return The new status.
535 PurpleStatus
*purple_status_new(PurpleStatusType
*status_type
,
536 PurplePresence
*presence
);
541 * @param status The status to destroy.
543 void purple_status_destroy(PurpleStatus
*status
);
546 * Sets whether or not a status is active.
548 * This should only be called by the account, conversation, and buddy APIs.
550 * @param status The status.
551 * @param active The active state.
553 void purple_status_set_active(PurpleStatus
*status
, gboolean active
);
556 * Sets whether or not a status is active.
558 * This should only be called by the account, conversation, and buddy APIs.
560 * @param status The status.
561 * @param active The active state.
562 * @param args A list of attributes to set on the status. This list is
563 * composed of key/value pairs, where each key is a valid
564 * attribute name for this PurpleStatusType. The list should
565 * be NULL terminated.
567 void purple_status_set_active_with_attrs(PurpleStatus
*status
, gboolean active
,
571 * Sets whether or not a status is active.
573 * This should only be called by the account, conversation, and buddy APIs.
575 * @param status The status.
576 * @param active The active state.
577 * @param attrs A list of attributes to set on the status. This list is
578 * composed of key/value pairs, where each key is a valid
579 * attribute name for this PurpleStatusType. The list is
580 * not modified or freed by this function.
582 void purple_status_set_active_with_attrs_list(PurpleStatus
*status
, gboolean active
,
585 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
587 * Sets the boolean value of an attribute in a status with the specified ID.
589 * @param status The status.
590 * @param id The attribute ID.
591 * @param value The boolean value.
593 * @deprecated This function is only used by status.c and should be made
596 void purple_status_set_attr_boolean(PurpleStatus
*status
, const char *id
,
600 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
602 * Sets the integer value of an attribute in a status with the specified ID.
604 * @param status The status.
605 * @param id The attribute ID.
606 * @param value The integer value.
608 * @deprecated This function is only used by status.c and should be made
611 void purple_status_set_attr_int(PurpleStatus
*status
, const char *id
,
615 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
617 * Sets the string value of an attribute in a status with the specified ID.
619 * @param status The status.
620 * @param id The attribute ID.
621 * @param value The string value.
623 * @deprecated This function is only used by status.c and should be made
626 void purple_status_set_attr_string(PurpleStatus
*status
, const char *id
,
631 * Returns the status's type.
633 * @param status The status.
635 * @return The status's type.
637 PurpleStatusType
*purple_status_get_type(const PurpleStatus
*status
);
640 * Returns the status's presence.
642 * @param status The status.
644 * @return The status's presence.
646 PurplePresence
*purple_status_get_presence(const PurpleStatus
*status
);
649 * Returns the status's type ID.
651 * This is a convenience method for
652 * purple_status_type_get_id(purple_status_get_type(status)).
654 * @param status The status.
656 * @return The status's ID.
658 const char *purple_status_get_id(const PurpleStatus
*status
);
661 * Returns the status's name.
663 * This is a convenience method for
664 * purple_status_type_get_name(purple_status_get_type(status)).
666 * @param status The status.
668 * @return The status's name.
670 const char *purple_status_get_name(const PurpleStatus
*status
);
673 * Returns whether or not a status is independent.
675 * This is a convenience method for
676 * purple_status_type_is_independent(purple_status_get_type(status)).
678 * @param status The status.
680 * @return TRUE if the status is independent, or FALSE otherwise.
682 gboolean
purple_status_is_independent(const PurpleStatus
*status
);
685 * Returns whether or not a status is exclusive.
687 * This is a convenience method for
688 * purple_status_type_is_exclusive(purple_status_get_type(status)).
690 * @param status The status.
692 * @return TRUE if the status is exclusive, FALSE otherwise.
694 gboolean
purple_status_is_exclusive(const PurpleStatus
*status
);
697 * Returns whether or not a status is available.
699 * Available statuses are online and possibly invisible, but not away or idle.
701 * This is a convenience method for
702 * purple_status_type_is_available(purple_status_get_type(status)).
704 * @param status The status.
706 * @return TRUE if the status is available, or FALSE otherwise.
708 gboolean
purple_status_is_available(const PurpleStatus
*status
);
711 * Returns the active state of a status.
713 * @param status The status.
715 * @return The active state of the status.
717 gboolean
purple_status_is_active(const PurpleStatus
*status
);
720 * Returns whether or not a status is considered 'online'
722 * @param status The status.
724 * @return TRUE if the status is considered online, FALSE otherwise
726 gboolean
purple_status_is_online(const PurpleStatus
*status
);
729 * Returns the value of an attribute in a status with the specified ID.
731 * @param status The status.
732 * @param id The attribute ID.
734 * @return The value of the attribute.
736 PurpleValue
*purple_status_get_attr_value(const PurpleStatus
*status
,
740 * Returns the boolean value of an attribute in a status with the specified ID.
742 * @param status The status.
743 * @param id The attribute ID.
745 * @return The boolean value of the attribute.
747 gboolean
purple_status_get_attr_boolean(const PurpleStatus
*status
,
751 * Returns the integer value of an attribute in a status with the specified ID.
753 * @param status The status.
754 * @param id The attribute ID.
756 * @return The integer value of the attribute.
758 int purple_status_get_attr_int(const PurpleStatus
*status
, const char *id
);
761 * Returns the string value of an attribute in a status with the specified ID.
763 * @param status The status.
764 * @param id The attribute ID.
766 * @return The string value of the attribute.
768 const char *purple_status_get_attr_string(const PurpleStatus
*status
,
772 * Compares two statuses for availability.
774 * @param status1 The first status.
775 * @param status2 The second status.
777 * @return -1 if @a status1 is more available than @a status2.
778 * 0 if @a status1 is equal to @a status2.
779 * 1 if @a status2 is more available than @a status1.
781 gint
purple_status_compare(const PurpleStatus
*status1
, const PurpleStatus
*status2
);
785 /**************************************************************************/
786 /** @name PurplePresence API */
787 /**************************************************************************/
791 * Creates a new presence.
793 * @param context The presence context.
795 * @return A new presence.
797 PurplePresence
*purple_presence_new(PurplePresenceContext context
);
800 * Creates a presence for an account.
802 * @param account The account.
804 * @return The new presence.
806 PurplePresence
*purple_presence_new_for_account(PurpleAccount
*account
);
809 * Creates a presence for a conversation.
811 * @param conv The conversation.
813 * @return The new presence.
815 PurplePresence
*purple_presence_new_for_conv(PurpleConversation
*conv
);
818 * Creates a presence for a buddy.
820 * @param buddy The buddy.
822 * @return The new presence.
824 PurplePresence
*purple_presence_new_for_buddy(PurpleBuddy
*buddy
);
827 * Destroys a presence.
829 * All statuses added to this list will be destroyed along with
832 * @param presence The presence to destroy.
834 void purple_presence_destroy(PurplePresence
*presence
);
836 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
838 * Adds a status to a presence.
840 * @param presence The presence.
841 * @param status The status to add.
843 * @deprecated This function is only used by purple_presence_add_list,
844 * and both should be removed in 3.0.0.
846 void purple_presence_add_status(PurplePresence
*presence
, PurpleStatus
*status
);
849 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
851 * Adds a list of statuses to the presence.
853 * @param presence The presence.
854 * @param source_list The source list of statuses to add, which is not
855 * modified or freed by this function.
857 * @deprecated This function isn't used and should be removed in 3.0.0.
859 void purple_presence_add_list(PurplePresence
*presence
, GList
*source_list
);
863 * Sets the active state of a status in a presence.
865 * Only independent statuses can be set unactive. Normal statuses can only
866 * be set active, so if you wish to disable a status, set another
867 * non-independent status to active, or use purple_presence_switch_status().
869 * @param presence The presence.
870 * @param status_id The ID of the status.
871 * @param active The active state.
873 void purple_presence_set_status_active(PurplePresence
*presence
,
874 const char *status_id
, gboolean active
);
877 * Switches the active status in a presence.
879 * This is similar to purple_presence_set_status_active(), except it won't
880 * activate independent statuses.
882 * @param presence The presence.
883 * @param status_id The status ID to switch to.
885 void purple_presence_switch_status(PurplePresence
*presence
,
886 const char *status_id
);
889 * Sets the idle state and time on a presence.
891 * @param presence The presence.
892 * @param idle The idle state.
893 * @param idle_time The idle time, if @a idle is TRUE. This
894 * is the time at which the user became idle,
895 * in seconds since the epoch. If this value is
896 * unknown then 0 should be used.
898 void purple_presence_set_idle(PurplePresence
*presence
, gboolean idle
,
902 * Sets the login time on a presence.
904 * @param presence The presence.
905 * @param login_time The login time.
907 void purple_presence_set_login_time(PurplePresence
*presence
, time_t login_time
);
911 * Returns the presence's context.
913 * @param presence The presence.
915 * @return The presence's context.
917 PurplePresenceContext
purple_presence_get_context(const PurplePresence
*presence
);
920 * Returns a presence's account.
922 * @param presence The presence.
924 * @return The presence's account.
926 PurpleAccount
*purple_presence_get_account(const PurplePresence
*presence
);
929 * Returns a presence's conversation.
931 * @param presence The presence.
933 * @return The presence's conversation.
935 PurpleConversation
*purple_presence_get_conversation(const PurplePresence
*presence
);
938 * Returns a presence's chat user.
940 * @param presence The presence.
942 * @return The chat's user.
944 const char *purple_presence_get_chat_user(const PurplePresence
*presence
);
947 * Returns the presence's buddy.
949 * @param presence The presence.
951 * @return The presence's buddy.
953 PurpleBuddy
*purple_presence_get_buddy(const PurplePresence
*presence
);
956 * Returns all the statuses in a presence.
958 * @param presence The presence.
960 * @constreturn The statuses.
962 GList
*purple_presence_get_statuses(const PurplePresence
*presence
);
965 * Returns the status with the specified ID from a presence.
967 * @param presence The presence.
968 * @param status_id The ID of the status.
970 * @return The status if found, or NULL.
972 PurpleStatus
*purple_presence_get_status(const PurplePresence
*presence
,
973 const char *status_id
);
976 * Returns the active exclusive status from a presence.
978 * @param presence The presence.
980 * @return The active exclusive status.
982 PurpleStatus
*purple_presence_get_active_status(const PurplePresence
*presence
);
985 * Returns whether or not a presence is available.
987 * Available presences are online and possibly invisible, but not away or idle.
989 * @param presence The presence.
991 * @return TRUE if the presence is available, or FALSE otherwise.
993 gboolean
purple_presence_is_available(const PurplePresence
*presence
);
996 * Returns whether or not a presence is online.
998 * @param presence The presence.
1000 * @return TRUE if the presence is online, or FALSE otherwise.
1002 gboolean
purple_presence_is_online(const PurplePresence
*presence
);
1005 * Returns whether or not a status in a presence is active.
1007 * A status is active if itself or any of its sub-statuses are active.
1009 * @param presence The presence.
1010 * @param status_id The ID of the status.
1012 * @return TRUE if the status is active, or FALSE.
1014 gboolean
purple_presence_is_status_active(const PurplePresence
*presence
,
1015 const char *status_id
);
1018 * Returns whether or not a status with the specified primitive type
1019 * in a presence is active.
1021 * A status is active if itself or any of its sub-statuses are active.
1023 * @param presence The presence.
1024 * @param primitive The status primitive.
1026 * @return TRUE if the status is active, or FALSE.
1028 gboolean
purple_presence_is_status_primitive_active(
1029 const PurplePresence
*presence
, PurpleStatusPrimitive primitive
);
1032 * Returns whether or not a presence is idle.
1034 * @param presence The presence.
1036 * @return TRUE if the presence is idle, or FALSE otherwise.
1037 * If the presence is offline (purple_presence_is_online()
1038 * returns FALSE) then FALSE is returned.
1040 gboolean
purple_presence_is_idle(const PurplePresence
*presence
);
1043 * Returns the presence's idle time.
1045 * @param presence The presence.
1047 * @return The presence's idle time.
1049 time_t purple_presence_get_idle_time(const PurplePresence
*presence
);
1052 * Returns the presence's login time.
1054 * @param presence The presence.
1056 * @return The presence's login time.
1058 time_t purple_presence_get_login_time(const PurplePresence
*presence
);
1061 * Compares two presences for availability.
1063 * @param presence1 The first presence.
1064 * @param presence2 The second presence.
1066 * @return -1 if @a presence1 is more available than @a presence2.
1067 * 0 if @a presence1 is equal to @a presence2.
1068 * 1 if @a presence1 is less available than @a presence2.
1070 gint
purple_presence_compare(const PurplePresence
*presence1
,
1071 const PurplePresence
*presence2
);
1075 /**************************************************************************/
1076 /** @name Status subsystem */
1077 /**************************************************************************/
1081 * Get the handle for the status subsystem.
1083 * @return the handle to the status subsystem
1085 void *purple_status_get_handle(void);
1088 * Initializes the status subsystem.
1090 void purple_status_init(void);
1093 * Uninitializes the status subsystem.
1095 void purple_status_uninit(void);
1103 #endif /* _PURPLE_STATUS_H_ */