Frameworks/libpurple.framework/Versions/0.6.2/Headers/status.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/status.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /*
     2  * purple
     3  *
     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.
     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., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    21  */
    22 #ifndef _PURPLE_STATUS_H_
    23 #define _PURPLE_STATUS_H_
    24 
    25 /**
    26  * @file status.h Status API
    27  * @ingroup core
    28  *
    29  * A brief explanation of the status API:
    30  *
    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.
    39  *
    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.
    56  *
    57  *
    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.
    63  *
    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.
    73  */
    74 
    75 typedef struct _PurpleStatusType      PurpleStatusType;
    76 typedef struct _PurpleStatusAttr      PurpleStatusAttr;
    77 typedef struct _PurplePresence        PurplePresence;
    78 typedef struct _PurpleStatus          PurpleStatus;
    79 
    80 /**
    81  * A context for a presence.
    82  *
    83  * The context indicates to what the presence applies.
    84  */
    85 typedef enum
    86 {
    87 	PURPLE_PRESENCE_CONTEXT_UNSET   = 0,
    88 	PURPLE_PRESENCE_CONTEXT_ACCOUNT,
    89 	PURPLE_PRESENCE_CONTEXT_CONV,
    90 	PURPLE_PRESENCE_CONTEXT_BUDDY
    91 
    92 } PurplePresenceContext;
    93 
    94 /**
    95  * A primitive defining the basic structure of a status type.
    96  */
    97 /*
    98  * If you add a value to this enum, make sure you update
    99  * the status_primitive_map array in status.c and the special-cases for idle
   100  * and offline-messagable just below it.
   101  */
   102 typedef enum
   103 {
   104 	PURPLE_STATUS_UNSET = 0,
   105 	PURPLE_STATUS_OFFLINE,
   106 	PURPLE_STATUS_AVAILABLE,
   107 	PURPLE_STATUS_UNAVAILABLE,
   108 	PURPLE_STATUS_INVISIBLE,
   109 	PURPLE_STATUS_AWAY,
   110 	PURPLE_STATUS_EXTENDED_AWAY,
   111 	PURPLE_STATUS_MOBILE,
   112 	PURPLE_STATUS_TUNE,
   113 	PURPLE_STATUS_NUM_PRIMITIVES
   114 } PurpleStatusPrimitive;
   115 
   116 #include "account.h"
   117 #include "blist.h"
   118 #include "conversation.h"
   119 #include "value.h"
   120 
   121 #define PURPLE_TUNE_ARTIST	"tune_artist"
   122 #define PURPLE_TUNE_TITLE	"tune_title"
   123 #define PURPLE_TUNE_ALBUM	"tune_album"
   124 #define PURPLE_TUNE_GENRE	"tune_genre"
   125 #define PURPLE_TUNE_COMMENT	"tune_comment"
   126 #define PURPLE_TUNE_TRACK	"tune_track"
   127 #define PURPLE_TUNE_TIME	"tune_time"
   128 #define PURPLE_TUNE_YEAR	"tune_year"
   129 #define PURPLE_TUNE_URL		"tune_url"
   130 #define PURPLE_TUNE_FULL	"tune_full"
   131 
   132 #ifdef __cplusplus
   133 extern "C" {
   134 #endif
   135 
   136 /**************************************************************************/
   137 /** @name PurpleStatusPrimitive API                                       */
   138 /**************************************************************************/
   139 /*@{*/
   140 
   141 /**
   142  * Lookup the id of a primitive status type based on the type.  This
   143  * ID is a unique plain-text name of the status, without spaces.
   144  *
   145  * @param type A primitive status type.
   146  *
   147  * @return The unique ID for this type.
   148  */
   149 const char *purple_primitive_get_id_from_type(PurpleStatusPrimitive type);
   150 
   151 /**
   152  * Lookup the name of a primitive status type based on the type.  This
   153  * name is the plain-English name of the status type.  It is usually one
   154  * or two words.
   155  *
   156  * @param type A primitive status type.
   157  *
   158  * @return The name of this type, suitable for users to see.
   159  */
   160 const char *purple_primitive_get_name_from_type(PurpleStatusPrimitive type);
   161 
   162 /**
   163  * Lookup the value of a primitive status type based on the id.  The
   164  * ID is a unique plain-text name of the status, without spaces.
   165  *
   166  * @param id The unique ID of a primitive status type.
   167  *
   168  * @return The PurpleStatusPrimitive value.
   169  */
   170 PurpleStatusPrimitive purple_primitive_get_type_from_id(const char *id);
   171 
   172 /*@}*/
   173 
   174 /**************************************************************************/
   175 /** @name PurpleStatusType API                                            */
   176 /**************************************************************************/
   177 /*@{*/
   178 
   179 /**
   180  * Creates a new status type.
   181  *
   182  * @param primitive     The primitive status type.
   183  * @param id            The ID of the status type, or @c NULL to use the id of
   184  *                      the primitive status type.
   185  * @param name          The name presented to the user, or @c NULL to use the
   186  *                      name of the primitive status type.
   187  * @param saveable      TRUE if the information set for this status by the
   188  *                      user can be saved for future sessions.
   189  * @param user_settable TRUE if this is a status the user can manually set.
   190  * @param independent   TRUE if this is an independent (non-exclusive)
   191  *                      status type.
   192  *
   193  * @return A new status type.
   194  */
   195 PurpleStatusType *purple_status_type_new_full(PurpleStatusPrimitive primitive,
   196 										  const char *id, const char *name,
   197 										  gboolean saveable,
   198 										  gboolean user_settable,
   199 										  gboolean independent);
   200 
   201 /**
   202  * Creates a new status type with some default values (
   203  * saveable and not independent).
   204  *
   205  * @param primitive     The primitive status type.
   206  * @param id            The ID of the status type, or @c NULL to use the id of
   207  *                      the primitive status type.
   208  * @param name          The name presented to the user, or @c NULL to use the
   209  *                      name of the primitive status type.
   210  * @param user_settable TRUE if this is a status the user can manually set.
   211  *
   212  * @return A new status type.
   213  */
   214 PurpleStatusType *purple_status_type_new(PurpleStatusPrimitive primitive,
   215 									 const char *id, const char *name,
   216 									 gboolean user_settable);
   217 
   218 /**
   219  * Creates a new status type with attributes.
   220  *
   221  * @param primitive     The primitive status type.
   222  * @param id            The ID of the status type, or @c NULL to use the id of
   223  *                      the primitive status type.
   224  * @param name          The name presented to the user, or @c NULL to use the
   225  *                      name of the primitive status type.
   226  * @param saveable      TRUE if the information set for this status by the
   227  *                      user can be saved for future sessions.
   228  * @param user_settable TRUE if this is a status the user can manually set.
   229  * @param independent   TRUE if this is an independent (non-exclusive)
   230  *                      status type.
   231  * @param attr_id       The ID of the first attribute.
   232  * @param attr_name     The name of the first attribute.
   233  * @param attr_value    The value type of the first attribute attribute.
   234  * @param ...           Additional attribute information.
   235  *
   236  * @return A new status type.
   237  */
   238 PurpleStatusType *purple_status_type_new_with_attrs(PurpleStatusPrimitive primitive,
   239 												const char *id,
   240 												const char *name,
   241 												gboolean saveable,
   242 												gboolean user_settable,
   243 												gboolean independent,
   244 												const char *attr_id,
   245 												const char *attr_name,
   246 												PurpleValue *attr_value, ...) G_GNUC_NULL_TERMINATED;
   247 
   248 /**
   249  * Destroys a status type.
   250  *
   251  * @param status_type The status type to destroy.
   252  */
   253 void purple_status_type_destroy(PurpleStatusType *status_type);
   254 
   255 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   256 /**
   257  * Sets a status type's primary attribute.
   258  *
   259  * The value for the primary attribute is used as the description for
   260  * the particular status type. An example is an away message. The message
   261  * would be the primary attribute.
   262  *
   263  * @param status_type The status type.
   264  * @param attr_id     The ID of the primary attribute.
   265  *
   266  * @deprecated This function isn't used and should be removed in 3.0.0.
   267  */
   268 void purple_status_type_set_primary_attr(PurpleStatusType *status_type,
   269 									   const char *attr_id);
   270 #endif
   271 
   272 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   273 /**
   274  * Adds an attribute to a status type.
   275  *
   276  * @param status_type The status type to add the attribute to.
   277  * @param id          The ID of the attribute.
   278  * @param name        The name presented to the user.
   279  * @param value       The value type of this attribute.
   280  *
   281  * @deprecated This function isn't needed and should be removed in 3.0.0.
   282  *             Status type attributes should be set when the status type
   283  *             is created, in the call to purple_status_type_new_with_attrs.
   284  */
   285 void purple_status_type_add_attr(PurpleStatusType *status_type, const char *id,
   286 							   const char *name, PurpleValue *value);
   287 #endif
   288 
   289 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   290 /**
   291  * Adds multiple attributes to a status type.
   292  *
   293  * @param status_type The status type to add the attribute to.
   294  * @param id          The ID of the first attribute.
   295  * @param name        The description of the first attribute.
   296  * @param value       The value type of the first attribute attribute.
   297  * @param ...         Additional attribute information.
   298  *
   299  * @deprecated This function isn't needed and should be removed in 3.0.0.
   300  *             Status type attributes should be set when the status type
   301  *             is created, in the call to purple_status_type_new_with_attrs.
   302  */
   303 void purple_status_type_add_attrs(PurpleStatusType *status_type, const char *id,
   304 								const char *name, PurpleValue *value, ...) G_GNUC_NULL_TERMINATED;
   305 #endif
   306 
   307 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   308 /**
   309  * Adds multiple attributes to a status type using a va_list.
   310  *
   311  * @param status_type The status type to add the attribute to.
   312  * @param args        The va_list of attributes.
   313  *
   314  * @deprecated This function isn't needed and should be removed in 3.0.0.
   315  *             Status type attributes should be set when the status type
   316  *             is created, in the call to purple_status_type_new_with_attrs.
   317  */
   318 void purple_status_type_add_attrs_vargs(PurpleStatusType *status_type,
   319 									  va_list args);
   320 #endif
   321 
   322 /**
   323  * Returns the primitive type of a status type.
   324  *
   325  * @param status_type The status type.
   326  *
   327  * @return The primitive type of the status type.
   328  */
   329 PurpleStatusPrimitive purple_status_type_get_primitive(
   330 	const PurpleStatusType *status_type);
   331 
   332 /**
   333  * Returns the ID of a status type.
   334  *
   335  * @param status_type The status type.
   336  *
   337  * @return The ID of the status type.
   338  */
   339 const char *purple_status_type_get_id(const PurpleStatusType *status_type);
   340 
   341 /**
   342  * Returns the name of a status type.
   343  *
   344  * @param status_type The status type.
   345  *
   346  * @return The name of the status type.
   347  */
   348 const char *purple_status_type_get_name(const PurpleStatusType *status_type);
   349 
   350 /**
   351  * Returns whether or not the status type is saveable.
   352  *
   353  * @param status_type The status type.
   354  *
   355  * @return TRUE if user-defined statuses based off this type are saveable.
   356  *         FALSE otherwise.
   357  */
   358 gboolean purple_status_type_is_saveable(const PurpleStatusType *status_type);
   359 
   360 /**
   361  * Returns whether or not the status type can be set or modified by the
   362  * user.
   363  *
   364  * @param status_type The status type.
   365  *
   366  * @return TRUE if the status type can be set or modified by the user.
   367  *         FALSE if it's a protocol-set setting.
   368  */
   369 gboolean purple_status_type_is_user_settable(const PurpleStatusType *status_type);
   370 
   371 /**
   372  * Returns whether or not the status type is independent.
   373  *
   374  * Independent status types are non-exclusive. If other status types on
   375  * the same hierarchy level are set, this one will not be affected.
   376  *
   377  * @param status_type The status type.
   378  *
   379  * @return TRUE if the status type is independent, or FALSE otherwise.
   380  */
   381 gboolean purple_status_type_is_independent(const PurpleStatusType *status_type);
   382 
   383 /**
   384  * Returns whether the status type is exclusive.
   385  *
   386  * @param status_type The status type.
   387  *
   388  * @return TRUE if the status type is exclusive, FALSE otherwise.
   389  */
   390 gboolean purple_status_type_is_exclusive(const PurpleStatusType *status_type);
   391 
   392 /**
   393  * Returns whether or not a status type is available.
   394  *
   395  * Available status types are online and possibly invisible, but not away.
   396  *
   397  * @param status_type The status type.
   398  *
   399  * @return TRUE if the status is available, or FALSE otherwise.
   400  */
   401 gboolean purple_status_type_is_available(const PurpleStatusType *status_type);
   402 
   403 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   404 /**
   405  * Returns a status type's primary attribute ID.
   406  *
   407  * @param type The status type.
   408  *
   409  * @return The primary attribute's ID.
   410  *
   411  * @deprecated This function isn't used and should be removed in 3.0.0.
   412  */
   413 const char *purple_status_type_get_primary_attr(const PurpleStatusType *type);
   414 #endif
   415 
   416 /**
   417  * Returns the attribute with the specified ID.
   418  *
   419  * @param status_type The status type containing the attribute.
   420  * @param id          The ID of the desired attribute.
   421  *
   422  * @return The attribute, if found. NULL otherwise.
   423  */
   424 PurpleStatusAttr *purple_status_type_get_attr(const PurpleStatusType *status_type,
   425 										  const char *id);
   426 
   427 /**
   428  * Returns a list of all attributes in a status type.
   429  *
   430  * @param status_type The status type.
   431  *
   432  * @constreturn The list of attributes.
   433  */
   434 GList *purple_status_type_get_attrs(const PurpleStatusType *status_type);
   435 
   436 /**
   437  * Find the PurpleStatusType with the given id.
   438  *
   439  * @param status_types A list of status types.  Often account->status_types.
   440  * @param id The unique ID of the status type you wish to find.
   441  *
   442  * @return The status type with the given ID, or NULL if one could
   443  *         not be found.
   444  */
   445 const PurpleStatusType *purple_status_type_find_with_id(GList *status_types,
   446 													const char *id);
   447 
   448 /*@}*/
   449 
   450 /**************************************************************************/
   451 /** @name PurpleStatusAttr API                                              */
   452 /**************************************************************************/
   453 /*@{*/
   454 
   455 /**
   456  * Creates a new status attribute.
   457  *
   458  * @param id         The ID of the attribute.
   459  * @param name       The name presented to the user.
   460  * @param value_type The type of data contained in the attribute.
   461  *
   462  * @return A new status attribute.
   463  */
   464 PurpleStatusAttr *purple_status_attr_new(const char *id, const char *name,
   465 									 PurpleValue *value_type);
   466 
   467 /**
   468  * Destroys a status attribute.
   469  *
   470  * @param attr The status attribute to destroy.
   471  */
   472 void purple_status_attr_destroy(PurpleStatusAttr *attr);
   473 
   474 /**
   475  * Returns the ID of a status attribute.
   476  *
   477  * @param attr The status attribute.
   478  *
   479  * @return The status attribute's ID.
   480  */
   481 const char *purple_status_attr_get_id(const PurpleStatusAttr *attr);
   482 
   483 /**
   484  * Returns the name of a status attribute.
   485  *
   486  * @param attr The status attribute.
   487  *
   488  * @return The status attribute's name.
   489  */
   490 const char *purple_status_attr_get_name(const PurpleStatusAttr *attr);
   491 
   492 /**
   493  * Returns the value of a status attribute.
   494  *
   495  * @param attr The status attribute.
   496  *
   497  * @return The status attribute's value.
   498  */
   499 PurpleValue *purple_status_attr_get_value(const PurpleStatusAttr *attr);
   500 
   501 /*@}*/
   502 
   503 /**************************************************************************/
   504 /** @name PurpleStatus API                                                  */
   505 /**************************************************************************/
   506 /*@{*/
   507 
   508 /**
   509  * Creates a new status.
   510  *
   511  * @param status_type The type of status.
   512  * @param presence    The parent presence.
   513  *
   514  * @return The new status.
   515  */
   516 PurpleStatus *purple_status_new(PurpleStatusType *status_type,
   517 							PurplePresence *presence);
   518 
   519 /**
   520  * Destroys a status.
   521  *
   522  * @param status The status to destroy.
   523  */
   524 void purple_status_destroy(PurpleStatus *status);
   525 
   526 /**
   527  * Sets whether or not a status is active.
   528  *
   529  * This should only be called by the account, conversation, and buddy APIs.
   530  *
   531  * @param status The status.
   532  * @param active The active state.
   533  */
   534 void purple_status_set_active(PurpleStatus *status, gboolean active);
   535 
   536 /**
   537  * Sets whether or not a status is active.
   538  *
   539  * This should only be called by the account, conversation, and buddy APIs.
   540  *
   541  * @param status The status.
   542  * @param active The active state.
   543  * @param args   A list of attributes to set on the status.  This list is
   544  *               composed of key/value pairs, where each key is a valid
   545  *               attribute name for this PurpleStatusType.  The list should
   546  *               be NULL terminated.
   547  */
   548 void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active,
   549 									   va_list args);
   550 
   551 /**
   552  * Sets whether or not a status is active.
   553  *
   554  * This should only be called by the account, conversation, and buddy APIs.
   555  *
   556  * @param status The status.
   557  * @param active The active state.
   558  * @param attrs  A list of attributes to set on the status.  This list is
   559  *               composed of key/value pairs, where each key is a valid
   560  *               attribute name for this PurpleStatusType.  The list is
   561  *               not modified or freed by this function.
   562  */
   563 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
   564 											GList *attrs);
   565 
   566 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   567 /**
   568  * Sets the boolean value of an attribute in a status with the specified ID.
   569  *
   570  * @param status The status.
   571  * @param id     The attribute ID.
   572  * @param value  The boolean value.
   573  *
   574  * @deprecated This function is only used by status.c and should be made
   575  *             static in 3.0.0.
   576  */
   577 void purple_status_set_attr_boolean(PurpleStatus *status, const char *id,
   578 								  gboolean value);
   579 #endif
   580 
   581 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   582 /**
   583  * Sets the integer value of an attribute in a status with the specified ID.
   584  *
   585  * @param status The status.
   586  * @param id     The attribute ID.
   587  * @param value  The integer value.
   588  *
   589  * @deprecated This function is only used by status.c and should be made
   590  *             static in 3.0.0.
   591  */
   592 void purple_status_set_attr_int(PurpleStatus *status, const char *id,
   593 							  int value);
   594 #endif
   595 
   596 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   597 /**
   598  * Sets the string value of an attribute in a status with the specified ID.
   599  *
   600  * @param status The status.
   601  * @param id     The attribute ID.
   602  * @param value  The string value.
   603  *
   604  * @deprecated This function is only used by status.c and should be made
   605  *             static in 3.0.0.
   606  */
   607 void purple_status_set_attr_string(PurpleStatus *status, const char *id,
   608 								 const char *value);
   609 #endif
   610 
   611 /**
   612  * Returns the status's type.
   613  *
   614  * @param status The status.
   615  *
   616  * @return The status's type.
   617  */
   618 PurpleStatusType *purple_status_get_type(const PurpleStatus *status);
   619 
   620 /**
   621  * Returns the status's presence.
   622  *
   623  * @param status The status.
   624  *
   625  * @return The status's presence.
   626  */
   627 PurplePresence *purple_status_get_presence(const PurpleStatus *status);
   628 
   629 /**
   630  * Returns the status's type ID.
   631  *
   632  * This is a convenience method for
   633  * purple_status_type_get_id(purple_status_get_type(status)).
   634  *
   635  * @param status The status.
   636  *
   637  * @return The status's ID.
   638  */
   639 const char *purple_status_get_id(const PurpleStatus *status);
   640 
   641 /**
   642  * Returns the status's name.
   643  *
   644  * This is a convenience method for
   645  * purple_status_type_get_name(purple_status_get_type(status)).
   646  *
   647  * @param status The status.
   648  *
   649  * @return The status's name.
   650  */
   651 const char *purple_status_get_name(const PurpleStatus *status);
   652 
   653 /**
   654  * Returns whether or not a status is independent.
   655  *
   656  * This is a convenience method for
   657  * purple_status_type_is_independent(purple_status_get_type(status)).
   658  *
   659  * @param status The status.
   660  *
   661  * @return TRUE if the status is independent, or FALSE otherwise.
   662  */
   663 gboolean purple_status_is_independent(const PurpleStatus *status);
   664 
   665 /**
   666  * Returns whether or not a status is exclusive.
   667  *
   668  * This is a convenience method for
   669  * purple_status_type_is_exclusive(purple_status_get_type(status)).
   670  *
   671  * @param status The status.
   672  *
   673  * @return TRUE if the status is exclusive, FALSE otherwise.
   674  */
   675 gboolean purple_status_is_exclusive(const PurpleStatus *status);
   676 
   677 /**
   678  * Returns whether or not a status is available.
   679  *
   680  * Available statuses are online and possibly invisible, but not away or idle.
   681  *
   682  * This is a convenience method for
   683  * purple_status_type_is_available(purple_status_get_type(status)).
   684  *
   685  * @param status The status.
   686  *
   687  * @return TRUE if the status is available, or FALSE otherwise.
   688  */
   689 gboolean purple_status_is_available(const PurpleStatus *status);
   690 
   691 /**
   692  * Returns the active state of a status.
   693  *
   694  * @param status The status.
   695  *
   696  * @return The active state of the status.
   697  */
   698 gboolean purple_status_is_active(const PurpleStatus *status);
   699 
   700 /**
   701  * Returns whether or not a status is considered 'online'
   702  *
   703  * @param status The status.
   704  *
   705  * @return TRUE if the status is considered online, FALSE otherwise
   706  */
   707 gboolean purple_status_is_online(const PurpleStatus *status);
   708 
   709 /**
   710  * Returns the value of an attribute in a status with the specified ID.
   711  *
   712  * @param status The status.
   713  * @param id     The attribute ID.
   714  *
   715  * @return The value of the attribute.
   716  */
   717 PurpleValue *purple_status_get_attr_value(const PurpleStatus *status,
   718 									  const char *id);
   719 
   720 /**
   721  * Returns the boolean value of an attribute in a status with the specified ID.
   722  *
   723  * @param status The status.
   724  * @param id     The attribute ID.
   725  *
   726  * @return The boolean value of the attribute.
   727  */
   728 gboolean purple_status_get_attr_boolean(const PurpleStatus *status,
   729 									  const char *id);
   730 
   731 /**
   732  * Returns the integer value of an attribute in a status with the specified ID.
   733  *
   734  * @param status The status.
   735  * @param id     The attribute ID.
   736  *
   737  * @return The integer value of the attribute.
   738  */
   739 int purple_status_get_attr_int(const PurpleStatus *status, const char *id);
   740 
   741 /**
   742  * Returns the string value of an attribute in a status with the specified ID.
   743  *
   744  * @param status The status.
   745  * @param id     The attribute ID.
   746  *
   747  * @return The string value of the attribute.
   748  */
   749 const char *purple_status_get_attr_string(const PurpleStatus *status,
   750 										const char *id);
   751 
   752 /**
   753  * Compares two statuses for availability.
   754  *
   755  * @param status1 The first status.
   756  * @param status2 The second status.
   757  *
   758  * @return -1 if @a status1 is more available than @a status2.
   759  *          0 if @a status1 is equal to @a status2.
   760  *          1 if @a status2 is more available than @a status1.
   761  */
   762 gint purple_status_compare(const PurpleStatus *status1, const PurpleStatus *status2);
   763 
   764 /*@}*/
   765 
   766 /**************************************************************************/
   767 /** @name PurplePresence API                                                */
   768 /**************************************************************************/
   769 /*@{*/
   770 
   771 /**
   772  * Creates a new presence.
   773  *
   774  * @param context The presence context.
   775  *
   776  * @return A new presence.
   777  */
   778 PurplePresence *purple_presence_new(PurplePresenceContext context);
   779 
   780 /**
   781  * Creates a presence for an account.
   782  *
   783  * @param account The account.
   784  *
   785  * @return The new presence.
   786  */
   787 PurplePresence *purple_presence_new_for_account(PurpleAccount *account);
   788 
   789 /**
   790  * Creates a presence for a conversation.
   791  *
   792  * @param conv The conversation.
   793  *
   794  * @return The new presence.
   795  */
   796 PurplePresence *purple_presence_new_for_conv(PurpleConversation *conv);
   797 
   798 /**
   799  * Creates a presence for a buddy.
   800  *
   801  * @param buddy The buddy.
   802  *
   803  * @return The new presence.
   804  */
   805 PurplePresence *purple_presence_new_for_buddy(PurpleBuddy *buddy);
   806 
   807 /**
   808  * Destroys a presence.
   809  *
   810  * All statuses added to this list will be destroyed along with
   811  * the presence.
   812  *
   813  * @param presence The presence to destroy.
   814  */
   815 void purple_presence_destroy(PurplePresence *presence);
   816 
   817 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   818 /**
   819  * Adds a status to a presence.
   820  *
   821  * @param presence The presence.
   822  * @param status   The status to add.
   823  *
   824  * @deprecated This function is only used by purple_presence_add_list,
   825  *             and both should be removed in 3.0.0.
   826  */
   827 void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status);
   828 #endif
   829 
   830 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
   831 /**
   832  * Adds a list of statuses to the presence.
   833  *
   834  * @param presence    The presence.
   835  * @param source_list The source list of statuses to add, which is not
   836  *                    modified or freed by this function.
   837  *
   838  * @deprecated This function isn't used and should be removed in 3.0.0.
   839  */
   840 void purple_presence_add_list(PurplePresence *presence, GList *source_list);
   841 #endif
   842 
   843 /**
   844  * Sets the active state of a status in a presence.
   845  *
   846  * Only independent statuses can be set unactive. Normal statuses can only
   847  * be set active, so if you wish to disable a status, set another
   848  * non-independent status to active, or use purple_presence_switch_status().
   849  *
   850  * @param presence  The presence.
   851  * @param status_id The ID of the status.
   852  * @param active    The active state.
   853  */
   854 void purple_presence_set_status_active(PurplePresence *presence,
   855 									 const char *status_id, gboolean active);
   856 
   857 /**
   858  * Switches the active status in a presence.
   859  *
   860  * This is similar to purple_presence_set_status_active(), except it won't
   861  * activate independent statuses.
   862  *
   863  * @param presence The presence.
   864  * @param status_id The status ID to switch to.
   865  */
   866 void purple_presence_switch_status(PurplePresence *presence,
   867 								 const char *status_id);
   868 
   869 /**
   870  * Sets the idle state and time on a presence.
   871  *
   872  * @param presence  The presence.
   873  * @param idle      The idle state.
   874  * @param idle_time The idle time, if @a idle is TRUE.  This
   875  *                  is the time at which the user became idle,
   876  *                  in seconds since the epoch.  If this value is
   877  *                  unknown then 0 should be used.
   878  */
   879 void purple_presence_set_idle(PurplePresence *presence, gboolean idle,
   880 							time_t idle_time);
   881 
   882 /**
   883  * Sets the login time on a presence.
   884  *
   885  * @param presence   The presence.
   886  * @param login_time The login time.
   887  */
   888 void purple_presence_set_login_time(PurplePresence *presence, time_t login_time);
   889 
   890 
   891 /**
   892  * Returns the presence's context.
   893  *
   894  * @param presence The presence.
   895  *
   896  * @return The presence's context.
   897  */
   898 PurplePresenceContext purple_presence_get_context(const PurplePresence *presence);
   899 
   900 /**
   901  * Returns a presence's account.
   902  *
   903  * @param presence The presence.
   904  *
   905  * @return The presence's account.
   906  */
   907 PurpleAccount *purple_presence_get_account(const PurplePresence *presence);
   908 
   909 /**
   910  * Returns a presence's conversation.
   911  *
   912  * @param presence The presence.
   913  *
   914  * @return The presence's conversation.
   915  */
   916 PurpleConversation *purple_presence_get_conversation(const PurplePresence *presence);
   917 
   918 /**
   919  * Returns a presence's chat user.
   920  *
   921  * @param presence The presence.
   922  *
   923  * @return The chat's user.
   924  */
   925 const char *purple_presence_get_chat_user(const PurplePresence *presence);
   926 
   927 /**
   928  * Returns the presence's buddy.
   929  *
   930  * @param presence The presence.
   931  *
   932  * @return The presence's buddy.
   933  */
   934 PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence);
   935 
   936 /**
   937  * Returns all the statuses in a presence.
   938  *
   939  * @param presence The presence.
   940  *
   941  * @constreturn The statuses.
   942  */
   943 GList *purple_presence_get_statuses(const PurplePresence *presence);
   944 
   945 /**
   946  * Returns the status with the specified ID from a presence.
   947  *
   948  * @param presence  The presence.
   949  * @param status_id The ID of the status.
   950  *
   951  * @return The status if found, or NULL.
   952  */
   953 PurpleStatus *purple_presence_get_status(const PurplePresence *presence,
   954 									 const char *status_id);
   955 
   956 /**
   957  * Returns the active exclusive status from a presence.
   958  *
   959  * @param presence The presence.
   960  *
   961  * @return The active exclusive status.
   962  */
   963 PurpleStatus *purple_presence_get_active_status(const PurplePresence *presence);
   964 
   965 /**
   966  * Returns whether or not a presence is available.
   967  *
   968  * Available presences are online and possibly invisible, but not away or idle.
   969  *
   970  * @param presence The presence.
   971  *
   972  * @return TRUE if the presence is available, or FALSE otherwise.
   973  */
   974 gboolean purple_presence_is_available(const PurplePresence *presence);
   975 
   976 /**
   977  * Returns whether or not a presence is online.
   978  *
   979  * @param presence The presence.
   980  *
   981  * @return TRUE if the presence is online, or FALSE otherwise.
   982  */
   983 gboolean purple_presence_is_online(const PurplePresence *presence);
   984 
   985 /**
   986  * Returns whether or not a status in a presence is active.
   987  *
   988  * A status is active if itself or any of its sub-statuses are active.
   989  *
   990  * @param presence  The presence.
   991  * @param status_id The ID of the status.
   992  *
   993  * @return TRUE if the status is active, or FALSE.
   994  */
   995 gboolean purple_presence_is_status_active(const PurplePresence *presence,
   996 										const char *status_id);
   997 
   998 /**
   999  * Returns whether or not a status with the specified primitive type
  1000  * in a presence is active.
  1001  *
  1002  * A status is active if itself or any of its sub-statuses are active.
  1003  *
  1004  * @param presence  The presence.
  1005  * @param primitive The status primitive.
  1006  *
  1007  * @return TRUE if the status is active, or FALSE.
  1008  */
  1009 gboolean purple_presence_is_status_primitive_active(
  1010 	const PurplePresence *presence, PurpleStatusPrimitive primitive);
  1011 
  1012 /**
  1013  * Returns whether or not a presence is idle.
  1014  *
  1015  * @param presence The presence.
  1016  *
  1017  * @return TRUE if the presence is idle, or FALSE otherwise.
  1018  *         If the presence is offline (purple_presence_is_online()
  1019  *         returns FALSE) then FALSE is returned.
  1020  */
  1021 gboolean purple_presence_is_idle(const PurplePresence *presence);
  1022 
  1023 /**
  1024  * Returns the presence's idle time.
  1025  *
  1026  * @param presence The presence.
  1027  *
  1028  * @return The presence's idle time.
  1029  */
  1030 time_t purple_presence_get_idle_time(const PurplePresence *presence);
  1031 
  1032 /**
  1033  * Returns the presence's login time.
  1034  *
  1035  * @param presence The presence.
  1036  *
  1037  * @return The presence's login time.
  1038  */
  1039 time_t purple_presence_get_login_time(const PurplePresence *presence);
  1040 
  1041 /**
  1042  * Compares two presences for availability.
  1043  *
  1044  * @param presence1 The first presence.
  1045  * @param presence2 The second presence.
  1046  *
  1047  * @return -1 if @a presence1 is more available than @a presence2.
  1048  *          0 if @a presence1 is equal to @a presence2.
  1049  *          1 if @a presence1 is less available than @a presence2.
  1050  */
  1051 gint purple_presence_compare(const PurplePresence *presence1,
  1052 						   const PurplePresence *presence2);
  1053 
  1054 /*@}*/
  1055 
  1056 /**************************************************************************/
  1057 /** @name Status subsystem                                                */
  1058 /**************************************************************************/
  1059 /*@{*/
  1060 
  1061 /**
  1062  * Get the handle for the status subsystem.
  1063  *
  1064  * @return the handle to the status subsystem
  1065  */
  1066 void *purple_status_get_handle(void);
  1067 
  1068 /**
  1069  * Initializes the status subsystem.
  1070  */
  1071 void purple_status_init(void);
  1072 
  1073 /**
  1074  * Uninitializes the status subsystem.
  1075  */
  1076 void purple_status_uninit(void);
  1077 
  1078 /*@}*/
  1079 
  1080 #ifdef __cplusplus
  1081 }
  1082 #endif
  1083 
  1084 #endif /* _PURPLE_STATUS_H_ */