status.h
Go to the documentation of this file.
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 
85 typedef struct _PurpleStatusType PurpleStatusType;
86 typedef struct _PurpleStatusAttr PurpleStatusAttr;
87 typedef struct _PurplePresence PurplePresence;
88 typedef struct _PurpleStatus PurpleStatus;
89 
90 typedef struct _PurpleMood {
91  const char *mood;
92  const char *description;
93  gpointer *padding;
94 } PurpleMood;
95 
101 typedef enum
102 {
103  PURPLE_PRESENCE_CONTEXT_UNSET = 0,
104  PURPLE_PRESENCE_CONTEXT_ACCOUNT,
105  PURPLE_PRESENCE_CONTEXT_CONV,
106  PURPLE_PRESENCE_CONTEXT_BUDDY
107 
109 
113 /*
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.
116  */
117 typedef enum
118 {
119  PURPLE_STATUS_UNSET = 0,
120  PURPLE_STATUS_OFFLINE,
121  PURPLE_STATUS_AVAILABLE,
122  PURPLE_STATUS_UNAVAILABLE,
123  PURPLE_STATUS_INVISIBLE,
124  PURPLE_STATUS_AWAY,
125  PURPLE_STATUS_EXTENDED_AWAY,
126  PURPLE_STATUS_MOBILE,
127  PURPLE_STATUS_TUNE,
128  PURPLE_STATUS_MOOD,
129  PURPLE_STATUS_NUM_PRIMITIVES
131 
132 #include "account.h"
133 #include "blist.h"
134 #include "conversation.h"
135 #include "value.h"
136 
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"
147 
148 #define PURPLE_MOOD_NAME "mood"
149 #define PURPLE_MOOD_COMMENT "moodtext"
150 
151 #ifdef __cplusplus
152 extern "C" {
153 #endif
154 
155 /**************************************************************************/
157 /**************************************************************************/
169 
180 
190 
193 /**************************************************************************/
195 /**************************************************************************/
215  const char *id, const char *name,
216  gboolean saveable,
217  gboolean user_settable,
218  gboolean independent);
219 
234  const char *id, const char *name,
235  gboolean user_settable);
236 
258  const char *id,
259  const char *name,
260  gboolean saveable,
261  gboolean user_settable,
262  gboolean independent,
263  const char *attr_id,
264  const char *attr_name,
265  PurpleValue *attr_value, ...) G_GNUC_NULL_TERMINATED;
266 
273 
274 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
275 
288  const char *attr_id);
289 #endif
290 
291 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
292 
304 void purple_status_type_add_attr(PurpleStatusType *status_type, const char *id,
305  const char *name, PurpleValue *value);
306 #endif
307 
308 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
309 
322 void purple_status_type_add_attrs(PurpleStatusType *status_type, const char *id,
323  const char *name, PurpleValue *value, ...) G_GNUC_NULL_TERMINATED;
324 #endif
325 
326 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
327 
338  va_list args);
339 #endif
340 
349  const PurpleStatusType *status_type);
350 
358 const char *purple_status_type_get_id(const PurpleStatusType *status_type);
359 
367 const char *purple_status_type_get_name(const PurpleStatusType *status_type);
368 
377 gboolean purple_status_type_is_saveable(const PurpleStatusType *status_type);
378 
388 gboolean purple_status_type_is_user_settable(const PurpleStatusType *status_type);
389 
400 gboolean purple_status_type_is_independent(const PurpleStatusType *status_type);
401 
409 gboolean purple_status_type_is_exclusive(const PurpleStatusType *status_type);
410 
420 gboolean purple_status_type_is_available(const PurpleStatusType *status_type);
421 
422 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
423 
433 #endif
434 
443 PurpleStatusAttr *purple_status_type_get_attr(const PurpleStatusType *status_type,
444  const char *id);
445 
453 GList *purple_status_type_get_attrs(const PurpleStatusType *status_type);
454 
464 const PurpleStatusType *purple_status_type_find_with_id(GList *status_types,
465  const char *id);
466 
469 /**************************************************************************/
471 /**************************************************************************/
483 PurpleStatusAttr *purple_status_attr_new(const char *id, const char *name,
484  PurpleValue *value_type);
485 
491 void purple_status_attr_destroy(PurpleStatusAttr *attr);
492 
500 const char *purple_status_attr_get_id(const PurpleStatusAttr *attr);
501 
509 const char *purple_status_attr_get_name(const PurpleStatusAttr *attr);
510 
518 PurpleValue *purple_status_attr_get_value(const PurpleStatusAttr *attr);
519 
522 /**************************************************************************/
524 /**************************************************************************/
535 PurpleStatus *purple_status_new(PurpleStatusType *status_type,
536  PurplePresence *presence);
537 
543 void purple_status_destroy(PurpleStatus *status);
544 
553 void purple_status_set_active(PurpleStatus *status, gboolean active);
554 
567 void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active,
568  va_list args);
569 
582 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
583  GList *attrs);
584 
585 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
586 
596 void purple_status_set_attr_boolean(PurpleStatus *status, const char *id,
597  gboolean value);
598 #endif
599 
600 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
601 
611 void purple_status_set_attr_int(PurpleStatus *status, const char *id,
612  int value);
613 #endif
614 
615 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
616 
626 void purple_status_set_attr_string(PurpleStatus *status, const char *id,
627  const char *value);
628 #endif
629 
637 PurpleStatusType *purple_status_get_type(const PurpleStatus *status);
638 
646 PurplePresence *purple_status_get_presence(const PurpleStatus *status);
647 
658 const char *purple_status_get_id(const PurpleStatus *status);
659 
670 const char *purple_status_get_name(const PurpleStatus *status);
671 
682 gboolean purple_status_is_independent(const PurpleStatus *status);
683 
694 gboolean purple_status_is_exclusive(const PurpleStatus *status);
695 
708 gboolean purple_status_is_available(const PurpleStatus *status);
709 
717 gboolean purple_status_is_active(const PurpleStatus *status);
718 
726 gboolean purple_status_is_online(const PurpleStatus *status);
727 
736 PurpleValue *purple_status_get_attr_value(const PurpleStatus *status,
737  const char *id);
738 
747 gboolean purple_status_get_attr_boolean(const PurpleStatus *status,
748  const char *id);
749 
758 int purple_status_get_attr_int(const PurpleStatus *status, const char *id);
759 
768 const char *purple_status_get_attr_string(const PurpleStatus *status,
769  const char *id);
770 
781 gint purple_status_compare(const PurpleStatus *status1, const PurpleStatus *status2);
782 
785 /**************************************************************************/
787 /**************************************************************************/
797 PurplePresence *purple_presence_new(PurplePresenceContext context);
798 
806 PurplePresence *purple_presence_new_for_account(PurpleAccount *account);
807 
815 PurplePresence *purple_presence_new_for_conv(PurpleConversation *conv);
816 
824 PurplePresence *purple_presence_new_for_buddy(PurpleBuddy *buddy);
825 
834 void purple_presence_destroy(PurplePresence *presence);
835 
836 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
837 
846 void purple_presence_add_status(PurplePresence *presence, PurpleStatus *status);
847 #endif
848 
849 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_STATUS_C_)
850 
859 void purple_presence_add_list(PurplePresence *presence, GList *source_list);
860 #endif
861 
873 void purple_presence_set_status_active(PurplePresence *presence,
874  const char *status_id, gboolean active);
875 
885 void purple_presence_switch_status(PurplePresence *presence,
886  const char *status_id);
887 
898 void purple_presence_set_idle(PurplePresence *presence, gboolean idle,
899  time_t idle_time);
900 
907 void purple_presence_set_login_time(PurplePresence *presence, time_t login_time);
908 
909 
917 PurplePresenceContext purple_presence_get_context(const PurplePresence *presence);
918 
926 PurpleAccount *purple_presence_get_account(const PurplePresence *presence);
927 
935 PurpleConversation *purple_presence_get_conversation(const PurplePresence *presence);
936 
944 const char *purple_presence_get_chat_user(const PurplePresence *presence);
945 
953 PurpleBuddy *purple_presence_get_buddy(const PurplePresence *presence);
954 
962 GList *purple_presence_get_statuses(const PurplePresence *presence);
963 
972 PurpleStatus *purple_presence_get_status(const PurplePresence *presence,
973  const char *status_id);
974 
982 PurpleStatus *purple_presence_get_active_status(const PurplePresence *presence);
983 
993 gboolean purple_presence_is_available(const PurplePresence *presence);
994 
1002 gboolean purple_presence_is_online(const PurplePresence *presence);
1003 
1014 gboolean purple_presence_is_status_active(const PurplePresence *presence,
1015  const char *status_id);
1016 
1029  const PurplePresence *presence, PurpleStatusPrimitive primitive);
1030 
1040 gboolean purple_presence_is_idle(const PurplePresence *presence);
1041 
1049 time_t purple_presence_get_idle_time(const PurplePresence *presence);
1050 
1058 time_t purple_presence_get_login_time(const PurplePresence *presence);
1059 
1070 gint purple_presence_compare(const PurplePresence *presence1,
1071  const PurplePresence *presence2);
1072 
1075 /**************************************************************************/
1077 /**************************************************************************/
1085 void *purple_status_get_handle(void);
1086 
1090 void purple_status_init(void);
1091 
1095 void purple_status_uninit(void);
1096 
1099 #ifdef __cplusplus
1100 }
1101 #endif
1102 
1103 #endif /* _PURPLE_STATUS_H_ */