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, ...);
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, ...);
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 const 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 
00520 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
00521                                             const GList *attrs);
00522 
00530 void purple_status_set_attr_boolean(PurpleStatus *status, const char *id,
00531                                   gboolean value);
00532 
00540 void purple_status_set_attr_int(PurpleStatus *status, const char *id,
00541                               int value);
00542 
00550 void purple_status_set_attr_string(PurpleStatus *status, const char *id,
00551                                  const char *value);
00552 
00560 PurpleStatusType *purple_status_get_type(const PurpleStatus *status);
00561 
00569 PurplePresence *purple_status_get_presence(const PurpleStatus *status);
00570 
00581 const char *purple_status_get_id(const PurpleStatus *status);
00582 
00593 const char *purple_status_get_name(const PurpleStatus *status);
00594 
00605 gboolean purple_status_is_independent(const PurpleStatus *status);
00606 
00617 gboolean purple_status_is_exclusive(const PurpleStatus *status);
00618 
00631 gboolean purple_status_is_available(const PurpleStatus *status);
00632 
00640 gboolean purple_status_is_active(const PurpleStatus *status);
00641 
00649 gboolean purple_status_is_online(const PurpleStatus *status);
00650 
00659 PurpleValue *purple_status_get_attr_value(const PurpleStatus *status,
00660                                       const char *id);
00661 
00670 gboolean purple_status_get_attr_boolean(const PurpleStatus *status,
00671                                       const char *id);
00672 
00681 int purple_status_get_attr_int(const PurpleStatus *status, const char *id);
00682 
00691 const char *purple_status_get_attr_string(const PurpleStatus *status,
00692                                         const char *id);
00693 
00704 gint purple_status_compare(const PurpleStatus *status1, const PurpleStatus *status2);
00705 
00708 /**************************************************************************/
00710 /**************************************************************************/
00720 PurplePresence *purple_presence_new(PurplePresenceContext context);
00721 
00729 PurplePresence *purple_presence_new_for_account(PurpleAccount *account);
00730 
00738 PurplePresence *purple_presence_new_for_conv(PurpleConversation *conv);
00739 
00747 PurplePresence *purple_presence_new_for_buddy(PurpleBuddy *buddy);
00748 
00757 void purple_presence_destroy(PurplePresence *presence);
00758 
00765 void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status);
00766 
00773 void purple_presence_add_list(PurplePresence *presence, const GList *source_list);
00774 
00786 void purple_presence_set_status_active(PurplePresence *presence,
00787                                      const char *status_id, gboolean active);
00788 
00798 void purple_presence_switch_status(PurplePresence *presence,
00799                                  const char *status_id);
00800 
00810 void purple_presence_set_idle(PurplePresence *presence, gboolean idle,
00811                             time_t idle_time);
00812 
00819 void purple_presence_set_login_time(PurplePresence *presence, time_t login_time);
00820 
00821 
00829 PurplePresenceContext purple_presence_get_context(const PurplePresence *presence);
00830 
00838 PurpleAccount *purple_presence_get_account(const PurplePresence *presence);
00839 
00847 PurpleConversation *purple_presence_get_conversation(const PurplePresence *presence);
00848 
00856 const char *purple_presence_get_chat_user(const PurplePresence *presence);
00857 
00865 PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence);
00866 
00874 const GList *purple_presence_get_statuses(const PurplePresence *presence);
00875 
00884 PurpleStatus *purple_presence_get_status(const PurplePresence *presence,
00885                                      const char *status_id);
00886 
00894 PurpleStatus *purple_presence_get_active_status(const PurplePresence *presence);
00895 
00905 gboolean purple_presence_is_available(const PurplePresence *presence);
00906 
00914 gboolean purple_presence_is_online(const PurplePresence *presence);
00915 
00926 gboolean purple_presence_is_status_active(const PurplePresence *presence,
00927                                         const char *status_id);
00928 
00940 gboolean purple_presence_is_status_primitive_active(
00941     const PurplePresence *presence, PurpleStatusPrimitive primitive);
00942 
00952 gboolean purple_presence_is_idle(const PurplePresence *presence);
00953 
00961 time_t purple_presence_get_idle_time(const PurplePresence *presence);
00962 
00970 time_t purple_presence_get_login_time(const PurplePresence *presence);
00971 
00982 gint purple_presence_compare(const PurplePresence *presence1,
00983                            const PurplePresence *presence2);
00984 
00987 /**************************************************************************/
00989 /**************************************************************************/
00997 void *purple_status_get_handle(void);
00998 
01002 void purple_status_init(void);
01003 
01007 void purple_status_uninit(void);
01008 
01011 #ifdef __cplusplus
01012 }
01013 #endif
01014 
01015 #endif /* _PURPLE_STATUS_H_ */