zephyr: Remove unused defines and headers.
[pidgin-git.git] / libpurple / status.h
blobdde2a49b795a118b6fb3d815ab4bf216fbdabc41
1 /*
2 * purple
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.
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
23 #ifndef PURPLE_STATUS_H
24 #define PURPLE_STATUS_H
25 /**
26 * SECTION:status
27 * @section_id: libpurple-status
28 * @short_description: <filename>status.h</filename>
29 * @title: Status Object API
32 #define PURPLE_TYPE_STATUS (purple_status_get_type())
33 typedef struct _PurpleStatus PurpleStatus;
35 #define PURPLE_TYPE_STATUS_TYPE (purple_status_type_get_type())
37 /**
38 * PurpleStatusType:
40 * PurpleStatusType's are created by each protocol. They outline the
41 * available statuses of the protocol. AIM, for example, supports
42 * an available state with an optional available message, an away
43 * state with a mandatory message, and an invisible state (which is
44 * technically "independent" of the other two, but we'll get into
45 * that later). PurpleStatusTypes are very permanent. They are
46 * hardcoded in each protocol and will not change often. And because
47 * they are hardcoded, they do not need to be saved to any XML file.
49 typedef struct _PurpleStatusType PurpleStatusType;
51 #define PURPLE_TYPE_STATUS_ATTRIBUTE (purple_status_attribute_get_type())
53 typedef struct _PurpleStatusAttribute PurpleStatusAttribute;
55 #define PURPLE_TYPE_MOOD (purple_mood_get_type())
57 typedef struct {
58 const char *mood;
59 const char *description;
60 gpointer *padding;
61 } PurpleMood;
63 /**
64 * PurpleStatusPrimitive:
65 * @PURPLE_STATUS_UNSET: The status is not set
66 * @PURPLE_STATUS_OFFLINE: The status is offline
67 * @PURPLE_STATUS_AVAILABLE: The status is available
68 * @PURPLE_STATUS_UNAVAILABLE: The status is unavailable
69 * @PURPLE_STATUS_INVISIBLE: The stuatus is invisible
70 * @PURPLE_STATUS_AWAY: The status is away
71 * @PURPLE_STATUS_EXTENDED_AWAY: The status is extended away/do not disturb
72 * @PURPLE_STATUS_MOBILE: The status is mobile
73 * @PURPLE_STATUS_TUNE: The status includes a song title
74 * @PURPLE_STATUS_MOOD: The status includes a mood
75 * @PURPLE_STATUS_NUM_PRIMITIVES: The number of #PurpleStatusPrimitive<!-- -->s
77 * A primitive defining the basic structure of a status type.
80 * If you add a value to this enum, make sure you update
81 * the status_primitive_map and primitive_scores arrays in status.c.
83 typedef enum
85 PURPLE_STATUS_UNSET = 0,
86 PURPLE_STATUS_OFFLINE,
87 PURPLE_STATUS_AVAILABLE,
88 PURPLE_STATUS_UNAVAILABLE,
89 PURPLE_STATUS_INVISIBLE,
90 PURPLE_STATUS_AWAY,
91 PURPLE_STATUS_EXTENDED_AWAY,
92 PURPLE_STATUS_MOBILE,
93 PURPLE_STATUS_TUNE,
94 PURPLE_STATUS_MOOD,
96 PURPLE_STATUS_NUM_PRIMITIVES, /*< skip >*/
97 } PurpleStatusPrimitive;
99 #include "presence.h"
101 #define PURPLE_TUNE_ARTIST "tune_artist"
102 #define PURPLE_TUNE_TITLE "tune_title"
103 #define PURPLE_TUNE_ALBUM "tune_album"
104 #define PURPLE_TUNE_GENRE "tune_genre"
105 #define PURPLE_TUNE_COMMENT "tune_comment"
106 #define PURPLE_TUNE_TRACK "tune_track"
107 #define PURPLE_TUNE_TIME "tune_time"
108 #define PURPLE_TUNE_YEAR "tune_year"
109 #define PURPLE_TUNE_URL "tune_url"
110 #define PURPLE_TUNE_FULL "tune_full"
112 #define PURPLE_MOOD_NAME "mood"
113 #define PURPLE_MOOD_COMMENT "moodtext"
115 G_BEGIN_DECLS
117 /**************************************************************************/
118 /* PurpleStatusPrimitive API */
119 /**************************************************************************/
122 * purple_primitive_get_id_from_type:
123 * @type: A primitive status type.
125 * Lookup the id of a primitive status type based on the type. This
126 * ID is a unique plain-text name of the status, without spaces.
128 * Returns: The unique ID for this type.
130 const char *purple_primitive_get_id_from_type(PurpleStatusPrimitive type);
133 * purple_primitive_get_name_from_type:
134 * @type: A primitive status type.
136 * Lookup the name of a primitive status type based on the type. This
137 * name is the plain-English name of the status type. It is usually one
138 * or two words.
140 * Returns: The name of this type, suitable for users to see.
142 const char *purple_primitive_get_name_from_type(PurpleStatusPrimitive type);
145 * purple_primitive_get_type_from_id:
146 * @id: The unique ID of a primitive status type.
148 * Lookup the value of a primitive status type based on the id. The
149 * ID is a unique plain-text name of the status, without spaces.
151 * Returns: The PurpleStatusPrimitive value.
153 PurpleStatusPrimitive purple_primitive_get_type_from_id(const char *id);
155 /**************************************************************************/
156 /* PurpleStatusType API */
157 /**************************************************************************/
160 * purple_status_type_get_type:
162 * Returns: The #GType for the #PurpleStatusType boxed structure.
164 GType purple_status_type_get_type(void);
167 * purple_status_type_new_full:
168 * @primitive: The primitive status type.
169 * @id: The ID of the status type, or %NULL to use the id of
170 * the primitive status type.
171 * @name: The name presented to the user, or %NULL to use the
172 * name of the primitive status type.
173 * @saveable: TRUE if the information set for this status by the
174 * user can be saved for future sessions.
175 * @user_settable: TRUE if this is a status the user can manually set.
176 * @independent: TRUE if this is an independent (non-exclusive)
177 * status type.
179 * Creates a new status type.
181 * Returns: A new status type.
183 PurpleStatusType *purple_status_type_new_full(PurpleStatusPrimitive primitive,
184 const char *id, const char *name,
185 gboolean saveable,
186 gboolean user_settable,
187 gboolean independent);
190 * purple_status_type_new:
191 * @primitive: The primitive status type.
192 * @id: The ID of the status type, or %NULL to use the id of
193 * the primitive status type.
194 * @name: The name presented to the user, or %NULL to use the
195 * name of the primitive status type.
196 * @user_settable: TRUE if this is a status the user can manually set.
198 * Creates a new status type with some default values (
199 * saveable and not independent).
201 * Returns: A new status type.
203 PurpleStatusType *purple_status_type_new(PurpleStatusPrimitive primitive,
204 const char *id, const char *name,
205 gboolean user_settable);
208 * purple_status_type_new_with_attrs:
209 * @primitive: The primitive status type.
210 * @id: The ID of the status type, or %NULL to use the id of
211 * the primitive status type.
212 * @name: The name presented to the user, or %NULL to use the
213 * name of the primitive status type.
214 * @saveable: TRUE if the information set for this status by the
215 * user can be saved for future sessions.
216 * @user_settable: TRUE if this is a status the user can manually set.
217 * @independent: TRUE if this is an independent (non-exclusive)
218 * status type.
219 * @attr_id: The ID of the first attribute.
220 * @attr_name: The name of the first attribute.
221 * @attr_value: The value type of the first attribute.
222 * @...: Additional attribute information.
224 * Creates a new status type with attributes.
226 * Returns: A new status type.
228 PurpleStatusType *purple_status_type_new_with_attrs(PurpleStatusPrimitive primitive,
229 const char *id,
230 const char *name,
231 gboolean saveable,
232 gboolean user_settable,
233 gboolean independent,
234 const char *attr_id,
235 const char *attr_name,
236 GValue *attr_value, ...) G_GNUC_NULL_TERMINATED;
239 * purple_status_type_destroy:
240 * @status_type: The status type to destroy.
242 * Destroys a status type.
244 void purple_status_type_destroy(PurpleStatusType *status_type);
247 * purple_status_type_get_primitive:
248 * @status_type: The status type.
250 * Returns the primitive type of a status type.
252 * Returns: The primitive type of the status type.
254 PurpleStatusPrimitive purple_status_type_get_primitive(
255 const PurpleStatusType *status_type);
258 * purple_status_type_get_id:
259 * @status_type: The status type.
261 * Returns the ID of a status type.
263 * Returns: The ID of the status type.
265 const char *purple_status_type_get_id(const PurpleStatusType *status_type);
268 * purple_status_type_get_name:
269 * @status_type: The status type.
271 * Returns the name of a status type.
273 * Returns: The name of the status type.
275 const char *purple_status_type_get_name(const PurpleStatusType *status_type);
278 * purple_status_type_is_saveable:
279 * @status_type: The status type.
281 * Returns whether or not the status type is saveable.
283 * Returns: TRUE if user-defined statuses based off this type are saveable.
284 * FALSE otherwise.
286 gboolean purple_status_type_is_saveable(const PurpleStatusType *status_type);
289 * purple_status_type_is_user_settable:
290 * @status_type: The status type.
292 * Returns whether or not the status type can be set or modified by the
293 * user.
295 * Returns: TRUE if the status type can be set or modified by the user.
296 * FALSE if it's a protocol-set setting.
298 gboolean purple_status_type_is_user_settable(const PurpleStatusType *status_type);
301 * purple_status_type_is_independent:
302 * @status_type: The status type.
304 * Returns whether or not the status type is independent.
306 * Independent status types are non-exclusive. If other status types on
307 * the same hierarchy level are set, this one will not be affected.
309 * Returns: TRUE if the status type is independent, or FALSE otherwise.
311 gboolean purple_status_type_is_independent(const PurpleStatusType *status_type);
314 * purple_status_type_is_exclusive:
315 * @status_type: The status type.
317 * Returns whether the status type is exclusive.
319 * Returns: TRUE if the status type is exclusive, FALSE otherwise.
321 gboolean purple_status_type_is_exclusive(const PurpleStatusType *status_type);
324 * purple_status_type_is_available:
325 * @status_type: The status type.
327 * Returns whether or not a status type is available.
329 * Available status types are online and possibly invisible, but not away.
331 * Returns: TRUE if the status is available, or FALSE otherwise.
333 gboolean purple_status_type_is_available(const PurpleStatusType *status_type);
336 * purple_status_type_get_attr:
337 * @status_type: The status type containing the attribute.
338 * @id: The ID of the desired attribute.
340 * Returns the attribute with the specified ID.
342 * Returns: The attribute, if found. NULL otherwise.
344 PurpleStatusAttribute *purple_status_type_get_attr(const PurpleStatusType *status_type,
345 const char *id);
348 * purple_status_type_get_attrs:
349 * @status_type: The status type.
351 * Returns a list of all attributes in a status type.
353 * Returns: (element-type PurpleStatusAttribute) (transfer none): The list of attributes.
355 GList *purple_status_type_get_attrs(const PurpleStatusType *status_type);
358 * purple_status_type_find_with_id:
359 * @status_types: (element-type PurpleStatus) (transfer none): A list of status
360 * types. Often account->status_types.
361 * @id: The unique ID of the status type you wish to find.
363 * Find the PurpleStatusType with the given id.
365 * Returns: The status type with the given ID, or NULL if one could
366 * not be found.
368 const PurpleStatusType *purple_status_type_find_with_id(GList *status_types,
369 const char *id);
371 /**************************************************************************/
372 /* PurpleStatusAttribute API */
373 /**************************************************************************/
376 * purple_status_attribute_get_type:
378 * Returns: The #GType for the #PurpleStatusAttribute boxed structure.
380 GType purple_status_attribute_get_type(void);
383 * purple_status_attribute_new:
384 * @id: The ID of the attribute.
385 * @name: The name presented to the user.
386 * @value_type: The type of data contained in the attribute.
388 * Creates a new status attribute.
390 * Returns: A new status attribute.
392 PurpleStatusAttribute *purple_status_attribute_new(const char *id, const char *name,
393 GValue *value_type);
396 * purple_status_attribute_destroy:
397 * @attr: The status attribute to destroy.
399 * Destroys a status attribute.
401 void purple_status_attribute_destroy(PurpleStatusAttribute *attr);
404 * purple_status_attribute_get_id:
405 * @attr: The status attribute.
407 * Returns the ID of a status attribute.
409 * Returns: The status attribute's ID.
411 const char *purple_status_attribute_get_id(const PurpleStatusAttribute *attr);
414 * purple_status_attribute_get_name:
415 * @attr: The status attribute.
417 * Returns the name of a status attribute.
419 * Returns: The status attribute's name.
421 const char *purple_status_attribute_get_name(const PurpleStatusAttribute *attr);
424 * purple_status_attribute_get_value:
425 * @attr: The status attribute.
427 * Returns the value of a status attribute.
429 * Returns: The status attribute's value.
431 GValue *purple_status_attribute_get_value(const PurpleStatusAttribute *attr);
433 /**************************************************************************/
434 /* PurpleMood API */
435 /**************************************************************************/
438 * purple_mood_get_type:
440 * Returns: The #GType for the #PurpleMood boxed structure.
442 GType purple_mood_get_type(void);
444 /**************************************************************************/
445 /* PurpleStatus API */
446 /**************************************************************************/
449 * purple_status_get_type:
451 * Returns: The #GType for the Status object.
453 G_DECLARE_FINAL_TYPE(PurpleStatus, purple_status, PURPLE, STATUS, GObject)
456 * purple_status_new:
457 * @status_type: The type of status.
458 * @presence: The parent presence.
460 * Creates a new status.
462 * Returns: The new status.
464 PurpleStatus *purple_status_new(PurpleStatusType *status_type,
465 PurplePresence *presence);
468 * purple_status_set_active:
469 * @status: The status.
470 * @active: The active state.
472 * Sets whether or not a status is active.
474 * This should only be called by the account, conversation, and buddy APIs.
476 void purple_status_set_active(PurpleStatus *status, gboolean active);
479 * purple_status_set_active_with_attrs:
480 * @status: The status.
481 * @active: The active state.
482 * @args: A list of attributes to set on the status. This list is
483 * composed of key/value pairs, where each key is a valid
484 * attribute name for this PurpleStatusType. The list should
485 * be NULL terminated.
487 * Sets whether or not a status is active.
489 * This should only be called by the account, conversation, and buddy APIs.
491 void purple_status_set_active_with_attrs(PurpleStatus *status, gboolean active,
492 va_list args);
495 * purple_status_set_active_with_attrs_list:
496 * @status: The status.
497 * @active: The active state.
498 * @attrs: A list of attributes to set on the status. This list is
499 * composed of key/value pairs, where each key is a valid
500 * attribute name for this PurpleStatusType. The list is
501 * not modified or freed by this function.
503 * Sets whether or not a status is active.
505 * This should only be called by the account, conversation, and buddy APIs.
507 void purple_status_set_active_with_attrs_list(PurpleStatus *status, gboolean active,
508 GList *attrs);
511 * purple_status_get_status_type:
512 * @status: The status.
514 * Returns the status's type.
516 * Returns: The status's type.
518 PurpleStatusType *purple_status_get_status_type(PurpleStatus *status);
521 * purple_status_get_presence:
522 * @status: The status.
524 * Returns the status's presence.
526 * Returns: (transfer none): The status's presence.
528 PurplePresence *purple_status_get_presence(PurpleStatus *status);
531 * purple_status_get_id:
532 * @status: The status.
534 * Returns the status's type ID.
536 * This is a convenience method for
537 * purple_status_type_get_id(purple_status_get_status_type(status)).
539 * Returns: The status's ID.
541 const char *purple_status_get_id(PurpleStatus *status);
544 * purple_status_get_name:
545 * @status: The status.
547 * Returns the status's name.
549 * This is a convenience method for
550 * purple_status_type_get_name(purple_status_get_status_type(status)).
552 * Returns: The status's name.
554 const char *purple_status_get_name(PurpleStatus *status);
557 * purple_status_is_independent:
558 * @status: The status.
560 * Returns whether or not a status is independent.
562 * This is a convenience method for
563 * purple_status_type_is_independent(purple_status_get_status_type(status)).
565 * Returns: TRUE if the status is independent, or FALSE otherwise.
567 gboolean purple_status_is_independent(PurpleStatus *status);
570 * purple_status_is_exclusive:
571 * @status: The status.
573 * Returns whether or not a status is exclusive.
575 * This is a convenience method for
576 * purple_status_type_is_exclusive(purple_status_get_status_type(status)).
578 * Returns: TRUE if the status is exclusive, FALSE otherwise.
580 gboolean purple_status_is_exclusive(PurpleStatus *status);
583 * purple_status_is_available:
584 * @status: The status.
586 * Returns whether or not a status is available.
588 * Available statuses are online and possibly invisible, but not away or idle.
590 * This is a convenience method for
591 * purple_status_type_is_available(purple_status_get_status_type(status)).
593 * Returns: TRUE if the status is available, or FALSE otherwise.
595 gboolean purple_status_is_available(PurpleStatus *status);
598 * purple_status_is_active:
599 * @status: The status.
601 * Returns the active state of a status.
603 * Returns: The active state of the status.
605 gboolean purple_status_is_active(PurpleStatus *status);
608 * purple_status_is_online:
609 * @status: The status.
611 * Returns whether or not a status is considered 'online'
613 * Returns: TRUE if the status is considered online, FALSE otherwise
615 gboolean purple_status_is_online(PurpleStatus *status);
618 * purple_status_get_attr_value:
619 * @status: The status.
620 * @id: The attribute ID.
622 * Returns the value of an attribute in a status with the specified ID.
624 * Returns: The value of the attribute.
626 GValue *purple_status_get_attr_value(PurpleStatus *status,
627 const char *id);
630 * purple_status_get_attr_boolean:
631 * @status: The status.
632 * @id: The attribute ID.
634 * Returns the boolean value of an attribute in a status with the specified ID.
636 * Returns: The boolean value of the attribute.
638 gboolean purple_status_get_attr_boolean(PurpleStatus *status,
639 const char *id);
642 * purple_status_get_attr_int:
643 * @status: The status.
644 * @id: The attribute ID.
646 * Returns the integer value of an attribute in a status with the specified ID.
648 * Returns: The integer value of the attribute.
650 int purple_status_get_attr_int(PurpleStatus *status, const char *id);
653 * purple_status_get_attr_string:
654 * @status: The status.
655 * @id: The attribute ID.
657 * Returns the string value of an attribute in a status with the specified ID.
659 * Returns: The string value of the attribute.
661 const char *purple_status_get_attr_string(PurpleStatus *status, const char *id);
664 * purple_status_compare:
665 * @status1: The first status.
666 * @status2: The second status.
668 * Compares two statuses for availability.
670 * Returns: -1 if @status1 is more available than @status2.
671 * 0 if @status1 is equal to @status2.
672 * 1 if @status2 is more available than @status1.
674 gint purple_status_compare(PurpleStatus *status1, PurpleStatus *status2);
676 /**************************************************************************/
677 /* Statuses subsystem */
678 /**************************************************************************/
681 * purple_statuses_get_handle:
683 * Get the handle for the status subsystem.
685 * Returns: the handle to the status subsystem
687 void *purple_statuses_get_handle(void);
690 * purple_statuses_init:
692 * Initializes the status subsystem.
694 void purple_statuses_init(void);
697 * purple_statuses_uninit:
699 * Uninitializes the status subsystem.
701 void purple_statuses_uninit(void);
703 G_END_DECLS
705 #endif /* PURPLE_STATUS_H */