status.h

Go to the documentation of this file.
00001 /*
00002  * purple
00003  *
00004  * Purple is the legal property of its developers, whose names are too numerous
00005  * to list here.  Please refer to the COPYRIGHT file distributed with this
00006  * source distribution.
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 #ifndef _PURPLE_STATUS_H_
00023 #define _PURPLE_STATUS_H_
00024 
00075 typedef struct _PurpleStatusType      PurpleStatusType;
00076 typedef struct _PurpleStatusAttr      PurpleStatusAttr;
00077 typedef struct _PurplePresence        PurplePresence;
00078 typedef struct _PurpleStatus          PurpleStatus;
00079 
00085 typedef enum
00086 {
00087     PURPLE_PRESENCE_CONTEXT_UNSET   = 0,
00088     PURPLE_PRESENCE_CONTEXT_ACCOUNT,
00089     PURPLE_PRESENCE_CONTEXT_CONV,
00090     PURPLE_PRESENCE_CONTEXT_BUDDY
00091 
00092 } PurplePresenceContext;
00093 
00097 typedef enum
00098 {
00099     PURPLE_STATUS_UNSET = 0,
00100     PURPLE_STATUS_OFFLINE,
00101     PURPLE_STATUS_AVAILABLE,
00102     PURPLE_STATUS_UNAVAILABLE,
00103     PURPLE_STATUS_INVISIBLE,
00104     PURPLE_STATUS_AWAY,
00105     PURPLE_STATUS_EXTENDED_AWAY,
00106     PURPLE_STATUS_MOBILE,
00107     PURPLE_STATUS_NUM_PRIMITIVES
00108 
00109 } PurpleStatusPrimitive;
00110 
00111 #include "account.h"
00112 #include "blist.h"
00113 #include "conversation.h"
00114 #include "value.h"
00115 
00116 #ifdef __cplusplus
00117 extern "C" {
00118 #endif
00119 
00120 /**************************************************************************/
00122 /**************************************************************************/
00133 const char *purple_primitive_get_id_from_type(PurpleStatusPrimitive type);
00134 
00144 const char *purple_primitive_get_name_from_type(PurpleStatusPrimitive type);
00145 
00154 PurpleStatusPrimitive purple_primitive_get_type_from_id(const char *id);
00155 
00158 /**************************************************************************/
00160 /**************************************************************************/
00179 PurpleStatusType *purple_status_type_new_full(PurpleStatusPrimitive primitive,
00180                                           const char *id, const char *name,
00181                                           gboolean saveable,
00182                                           gboolean user_settable,
00183                                           gboolean independent);
00184 
00198 PurpleStatusType *purple_status_type_new(PurpleStatusPrimitive primitive,
00199                                      const char *id, const char *name,
00200                                      gboolean user_settable);
00201 
00222 PurpleStatusType *purple_status_type_new_with_attrs(PurpleStatusPrimitive primitive,
00223                                                 const char *id,
00224                                                 const char *name,
00225                                                 gboolean saveable,
00226                                                 gboolean user_settable,
00227                                                 gboolean independent,
00228                                                 const char *attr_id,
00229                                                 const char *attr_name,
00230                                                 PurpleValue *attr_value, ...) G_GNUC_NULL_TERMINATED;
00231 
00237 void purple_status_type_destroy(PurpleStatusType *status_type);
00238 
00249 void purple_status_type_set_primary_attr(PurpleStatusType *status_type,
00250                                        const char *attr_id);
00251 
00260 void purple_status_type_add_attr(PurpleStatusType *status_type, const char *id,
00261                                const char *name, PurpleValue *value);
00262 
00272 void purple_status_type_add_attrs(PurpleStatusType *status_type, const char *id,
00273                                 const char *name, PurpleValue *value, ...) G_GNUC_NULL_TERMINATED;
00274 
00281 void purple_status_type_add_attrs_vargs(PurpleStatusType *status_type,
00282                                       va_list args);
00283 
00291 PurpleStatusPrimitive purple_status_type_get_primitive(
00292     const PurpleStatusType *status_type);
00293 
00301 const char *purple_status_type_get_id(const PurpleStatusType *status_type);
00302 
00310 const char *purple_status_type_get_name(const PurpleStatusType *status_type);
00311 
00320 gboolean purple_status_type_is_saveable(const PurpleStatusType *status_type);
00321 
00331 gboolean purple_status_type_is_user_settable(const PurpleStatusType *status_type);
00332 
00343 gboolean purple_status_type_is_independent(const PurpleStatusType *status_type);
00344 
00352 gboolean purple_status_type_is_exclusive(const PurpleStatusType *status_type);
00353 
00363 gboolean purple_status_type_is_available(const PurpleStatusType *status_type);
00364 
00372 const char *purple_status_type_get_primary_attr(const PurpleStatusType *type);
00373 
00382 PurpleStatusAttr *purple_status_type_get_attr(const PurpleStatusType *status_type,
00383                                           const char *id);
00384 
00392 GList *purple_status_type_get_attrs(const PurpleStatusType *status_type);
00393 
00403 const PurpleStatusType *purple_status_type_find_with_id(GList *status_types,
00404                                                     const char *id);
00405 
00408 /**************************************************************************/
00410 /**************************************************************************/
00422 PurpleStatusAttr *purple_status_attr_new(const char *id, const char *name,
00423                                      PurpleValue *value_type);
00424 
00430 void purple_status_attr_destroy(PurpleStatusAttr *attr);
00431 
00439 const char *purple_status_attr_get_id(const PurpleStatusAttr *attr);
00440 
00448 const char *purple_status_attr_get_name(const PurpleStatusAttr *attr);
00449 
00457 PurpleValue *purple_status_attr_get_value(const PurpleStatusAttr *attr);
00458 
00461 /**************************************************************************/
00463 /**************************************************************************/
00474 PurpleStatus *purple_status_new(PurpleStatusType *status_type,
00475                             PurplePresence *presence);
00476 
00482 void purple_status_destroy(PurpleStatus *status);
00483 
00492 void purple_status_set_active(PurpleStatus *status, gboolean active);
00493 
00506 void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active,
00507                                        va_list args);
00508 
00521 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
00522                                             GList *attrs);
00523 
00531 void purple_status_set_attr_boolean(PurpleStatus *status, const char *id,
00532                                   gboolean value);
00533 
00541 void purple_status_set_attr_int(PurpleStatus *status, const char *id,
00542                               int value);
00543 
00551 void purple_status_set_attr_string(PurpleStatus *status, const char *id,
00552                                  const char *value);
00553 
00561 PurpleStatusType *purple_status_get_type(const PurpleStatus *status);
00562 
00570 PurplePresence *purple_status_get_presence(const PurpleStatus *status);
00571 
00582 const char *purple_status_get_id(const PurpleStatus *status);
00583 
00594 const char *purple_status_get_name(const PurpleStatus *status);
00595 
00606 gboolean purple_status_is_independent(const PurpleStatus *status);
00607 
00618 gboolean purple_status_is_exclusive(const PurpleStatus *status);
00619 
00632 gboolean purple_status_is_available(const PurpleStatus *status);
00633 
00641 gboolean purple_status_is_active(const PurpleStatus *status);
00642 
00650 gboolean purple_status_is_online(const PurpleStatus *status);
00651 
00660 PurpleValue *purple_status_get_attr_value(const PurpleStatus *status,
00661                                       const char *id);
00662 
00671 gboolean purple_status_get_attr_boolean(const PurpleStatus *status,
00672                                       const char *id);
00673 
00682 int purple_status_get_attr_int(const PurpleStatus *status, const char *id);
00683 
00692 const char *purple_status_get_attr_string(const PurpleStatus *status,
00693                                         const char *id);
00694 
00705 gint purple_status_compare(const PurpleStatus *status1, const PurpleStatus *status2);
00706 
00709 /**************************************************************************/
00711 /**************************************************************************/
00721 PurplePresence *purple_presence_new(PurplePresenceContext context);
00722 
00730 PurplePresence *purple_presence_new_for_account(PurpleAccount *account);
00731 
00739 PurplePresence *purple_presence_new_for_conv(PurpleConversation *conv);
00740 
00748 PurplePresence *purple_presence_new_for_buddy(PurpleBuddy *buddy);
00749 
00758 void purple_presence_destroy(PurplePresence *presence);
00759 
00766 void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status);
00767 
00775 void purple_presence_add_list(PurplePresence *presence, GList *source_list);
00776 
00788 void purple_presence_set_status_active(PurplePresence *presence,
00789                                      const char *status_id, gboolean active);
00790 
00800 void purple_presence_switch_status(PurplePresence *presence,
00801                                  const char *status_id);
00802 
00812 void purple_presence_set_idle(PurplePresence *presence, gboolean idle,
00813                             time_t idle_time);
00814 
00821 void purple_presence_set_login_time(PurplePresence *presence, time_t login_time);
00822 
00823 
00831 PurplePresenceContext purple_presence_get_context(const PurplePresence *presence);
00832 
00840 PurpleAccount *purple_presence_get_account(const PurplePresence *presence);
00841 
00849 PurpleConversation *purple_presence_get_conversation(const PurplePresence *presence);
00850 
00858 const char *purple_presence_get_chat_user(const PurplePresence *presence);
00859 
00867 PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence);
00868 
00876 GList *purple_presence_get_statuses(const PurplePresence *presence);
00877 
00886 PurpleStatus *purple_presence_get_status(const PurplePresence *presence,
00887                                      const char *status_id);
00888 
00896 PurpleStatus *purple_presence_get_active_status(const PurplePresence *presence);
00897 
00907 gboolean purple_presence_is_available(const PurplePresence *presence);
00908 
00916 gboolean purple_presence_is_online(const PurplePresence *presence);
00917 
00928 gboolean purple_presence_is_status_active(const PurplePresence *presence,
00929                                         const char *status_id);
00930 
00942 gboolean purple_presence_is_status_primitive_active(
00943     const PurplePresence *presence, PurpleStatusPrimitive primitive);
00944 
00954 gboolean purple_presence_is_idle(const PurplePresence *presence);
00955 
00963 time_t purple_presence_get_idle_time(const PurplePresence *presence);
00964 
00972 time_t purple_presence_get_login_time(const PurplePresence *presence);
00973 
00984 gint purple_presence_compare(const PurplePresence *presence1,
00985                            const PurplePresence *presence2);
00986 
00989 /**************************************************************************/
00991 /**************************************************************************/
00999 void *purple_status_get_handle(void);
01000 
01004 void purple_status_init(void);
01005 
01009 void purple_status_uninit(void);
01010 
01013 #ifdef __cplusplus
01014 }
01015 #endif
01016 
01017 #endif /* _PURPLE_STATUS_H_ */