These changes are reuired to make the Windows installer build.
[pidgin-git.git] / libpurple / blist.h
bloba053d081c69b955ba76160daec4a8197b0954d27
1 /**
2 * @file blist.h Buddy List API
3 * @ingroup core
4 * @see @ref blist-signals
5 */
7 /* purple
9 * Purple is the legal property of its developers, whose names are too numerous
10 * to list here. Please refer to the COPYRIGHT file distributed with this
11 * source distribution.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef _PURPLE_BLIST_H_
28 #define _PURPLE_BLIST_H_
30 /* I can't believe I let ChipX86 inspire me to write good code. -Sean */
32 #include <glib.h>
34 /** @copydoc _PurpleBuddyList */
35 typedef struct _PurpleBuddyList PurpleBuddyList;
36 /** @copydoc _PurpleBlistUiOps */
37 typedef struct _PurpleBlistUiOps PurpleBlistUiOps;
38 /** @copydoc _PurpleBlistNode */
39 typedef struct _PurpleBlistNode PurpleBlistNode;
41 /** @copydoc _PurpleChat */
42 typedef struct _PurpleChat PurpleChat;
43 /** @copydoc _PurpleGroup */
44 typedef struct _PurpleGroup PurpleGroup;
45 /** @copydoc _PurpleContact */
46 typedef struct _PurpleContact PurpleContact;
47 /** @copydoc _PurpleBuddy */
48 typedef struct _PurpleBuddy PurpleBuddy;
50 /**************************************************************************/
51 /* Enumerations */
52 /**************************************************************************/
53 typedef enum
55 PURPLE_BLIST_GROUP_NODE,
56 PURPLE_BLIST_CONTACT_NODE,
57 PURPLE_BLIST_BUDDY_NODE,
58 PURPLE_BLIST_CHAT_NODE,
59 PURPLE_BLIST_OTHER_NODE
61 } PurpleBlistNodeType;
63 #define PURPLE_BLIST_NODE_IS_CHAT(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE)
64 #define PURPLE_BLIST_NODE_IS_BUDDY(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE)
65 #define PURPLE_BLIST_NODE_IS_CONTACT(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CONTACT_NODE)
66 #define PURPLE_BLIST_NODE_IS_GROUP(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_GROUP_NODE)
68 #define PURPLE_BUDDY_IS_ONLINE(b) \
69 ((b) != NULL && purple_account_is_connected(purple_buddy_get_account(b)) && \
70 purple_presence_is_online(purple_buddy_get_presence(b)))
72 typedef enum
74 PURPLE_BLIST_NODE_FLAG_NO_SAVE = 1 << 0 /**< node should not be saved with the buddy list */
76 } PurpleBlistNodeFlags;
78 /**
79 * @since 2.6.0
81 #define PURPLE_BLIST_NODE(obj) ((PurpleBlistNode *)(obj))
83 #define PURPLE_BLIST_NODE_HAS_FLAG(b, f) (purple_blist_node_get_flags((PurpleBlistNode*)(b)) & (f))
84 #define PURPLE_BLIST_NODE_SHOULD_SAVE(b) (! PURPLE_BLIST_NODE_HAS_FLAG(b, PURPLE_BLIST_NODE_FLAG_NO_SAVE))
86 #define PURPLE_BLIST_NODE_NAME(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE ? purple_chat_get_name((PurpleChat*)n) : \
87 purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE ? purple_buddy_get_name((PurpleBuddy*)n) : NULL)
89 /**
90 * @since 2.6.0
92 #define PURPLE_GROUP(obj) ((PurpleGroup *)(obj))
94 /**
95 * @since 2.6.0
97 #define PURPLE_CONTACT(obj) ((PurpleContact *)(obj))
99 /**
100 * @since 2.6.0
102 #define PURPLE_BUDDY(obj) ((PurpleBuddy *)(obj))
105 * @since 2.6.0
107 #define PURPLE_CHAT(obj) ((PurpleChat *)(obj))
109 #include "account.h"
110 #include "buddyicon.h"
111 #include "media.h"
112 #include "status.h"
114 /**************************************************************************/
115 /* Data Structures */
116 /**************************************************************************/
118 #if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_BLIST_C_)
121 * A Buddy list node. This can represent a group, a buddy, or anything else.
122 * This is a base class for PurpleBuddy, PurpleContact, PurpleGroup, and for
123 * anything else that wants to put itself in the buddy list. */
124 struct _PurpleBlistNode {
125 PurpleBlistNodeType type; /**< The type of node this is */
126 PurpleBlistNode *prev; /**< The sibling before this buddy. */
127 PurpleBlistNode *next; /**< The sibling after this buddy. */
128 PurpleBlistNode *parent; /**< The parent of this node */
129 PurpleBlistNode *child; /**< The child of this node */
130 GHashTable *settings; /**< per-node settings */
131 void *ui_data; /**< The UI can put data here. */
132 PurpleBlistNodeFlags flags; /**< The buddy flags */
136 * A buddy. This contains everything Purple will ever need to know about someone on the buddy list. Everything.
138 struct _PurpleBuddy {
139 PurpleBlistNode node; /**< The node that this buddy inherits from */
140 char *name; /**< The name of the buddy. */
141 char *alias; /**< The user-set alias of the buddy */
142 char *server_alias; /**< The server-specified alias of the buddy. (i.e. MSN "Friendly Names") */
143 void *proto_data; /**< This allows the prpl to associate whatever data it wants with a buddy */
144 PurpleBuddyIcon *icon; /**< The buddy icon. */
145 PurpleAccount *account; /**< the account this buddy belongs to */
146 PurplePresence *presence;
147 PurpleMediaCaps media_caps; /**< The media capabilities of the buddy. */
151 * A contact. This contains everything Purple will ever need to know about a contact.
153 struct _PurpleContact {
154 PurpleBlistNode node; /**< The node that this contact inherits from. */
155 char *alias; /**< The user-set alias of the contact */
156 int totalsize; /**< The number of buddies in this contact */
157 int currentsize; /**< The number of buddies in this contact corresponding to online accounts */
158 int online; /**< The number of buddies in this contact who are currently online */
159 PurpleBuddy *priority; /**< The "top" buddy for this contact */
160 gboolean priority_valid; /**< Is priority valid? */
165 * A group. This contains everything Purple will ever need to know about a group.
167 struct _PurpleGroup {
168 PurpleBlistNode node; /**< The node that this group inherits from */
169 char *name; /**< The name of this group. */
170 int totalsize; /**< The number of chats and contacts in this group */
171 int currentsize; /**< The number of chats and contacts in this group corresponding to online accounts */
172 int online; /**< The number of chats and contacts in this group who are currently online */
176 * A chat. This contains everything Purple needs to put a chat room in the
177 * buddy list.
179 struct _PurpleChat {
180 PurpleBlistNode node; /**< The node that this chat inherits from */
181 char *alias; /**< The display name of this chat. */
182 GHashTable *components; /**< the stuff the protocol needs to know to join the chat */
183 PurpleAccount *account; /**< The account this chat is attached to */
187 * The Buddy List
189 struct _PurpleBuddyList {
190 PurpleBlistNode *root; /**< The first node in the buddy list */
191 GHashTable *buddies; /**< Every buddy in this list */
192 void *ui_data; /**< UI-specific data. */
195 #endif /* PURPLE_HIDE_STRUCTS && PURPLE_BLIST_STRUCTS */
198 * Buddy list UI operations.
200 * Any UI representing a buddy list must assign a filled-out PurpleBlistUiOps
201 * structure to the buddy list core.
203 struct _PurpleBlistUiOps
205 void (*new_list)(PurpleBuddyList *list); /**< Sets UI-specific data on a buddy list. */
206 void (*new_node)(PurpleBlistNode *node); /**< Sets UI-specific data on a node. */
207 void (*show)(PurpleBuddyList *list); /**< The core will call this when it's finished doing its core stuff */
208 void (*update)(PurpleBuddyList *list,
209 PurpleBlistNode *node); /**< This will update a node in the buddy list. */
210 void (*remove)(PurpleBuddyList *list,
211 PurpleBlistNode *node); /**< This removes a node from the list */
212 void (*destroy)(PurpleBuddyList *list); /**< When the list is destroyed, this is called to destroy the UI. */
213 void (*set_visible)(PurpleBuddyList *list,
214 gboolean show); /**< Hides or unhides the buddy list */
215 void (*request_add_buddy)(PurpleAccount *account, const char *username,
216 const char *group, const char *alias);
217 void (*request_add_chat)(PurpleAccount *account, PurpleGroup *group,
218 const char *alias, const char *name);
219 void (*request_add_group)(void);
222 * This is called when a node has been modified and should be saved.
224 * Implementation of this UI op is OPTIONAL. If not implemented, it will
225 * be set to a fallback function that saves data to blist.xml like in
226 * previous libpurple versions.
228 * @param node The node which has been modified.
230 * @since 2.6.0.
232 void (*save_node)(PurpleBlistNode *node);
235 * Called when a node is about to be removed from the buddy list.
236 * The UI op should update the relevant data structures to remove this
237 * node (for example, removing a buddy from the group this node is in).
239 * Implementation of this UI op is OPTIONAL. If not implemented, it will
240 * be set to a fallback function that saves data to blist.xml like in
241 * previous libpurple versions.
243 * @param node The node which has been modified.
244 * @since 2.6.0.
246 void (*remove_node)(PurpleBlistNode *node);
249 * Called to save all the data for an account. If the UI sets this,
250 * the callback must save the privacy and buddy list data for an account.
251 * If the account is NULL, save the data for all accounts.
253 * Implementation of this UI op is OPTIONAL. If not implemented, it will
254 * be set to a fallback function that saves data to blist.xml like in
255 * previous libpurple versions.
257 * @param account The account whose data to save. If NULL, save all data
258 * for all accounts.
259 * @since 2.6.0.
261 void (*save_account)(PurpleAccount *account);
263 void (*_purple_reserved1)(void);
266 #ifdef __cplusplus
267 extern "C" {
268 #endif
270 /**************************************************************************/
271 /** @name Buddy List API */
272 /**************************************************************************/
273 /*@{*/
276 * Creates a new buddy list
278 * @return The new buddy list.
279 * @deprecated In 3.0.0, this will be handled by purple_blist_init()
281 PurpleBuddyList *purple_blist_new(void);
284 * Sets the main buddy list.
286 * @param blist The buddy list you want to use.
287 * @deprecated In 3.0.0, this will be handled by purple_blist_init()
289 void purple_set_blist(PurpleBuddyList *blist);
292 * Returns the main buddy list.
294 * @return The main buddy list.
296 PurpleBuddyList *purple_get_blist(void);
299 * Returns the root node of the main buddy list.
301 * @return The root node.
303 PurpleBlistNode *purple_blist_get_root(void);
306 * Returns a list of every buddy in the list. Use of this function is
307 * discouraged if you do not actually need every buddy in the list. Use
308 * purple_find_buddies instead.
310 * @return A list of every buddy in the list. Caller is responsible for
311 * freeing the list.
313 * @see purple_find_buddies
314 * @since 2.6.0
316 GSList *purple_blist_get_buddies(void);
319 * Returns the UI data for the list.
321 * @return The UI data for the list.
323 * @since 2.6.0
325 gpointer purple_blist_get_ui_data(void);
328 * Sets the UI data for the list.
330 * @param ui_data The UI data for the list.
332 * @since 2.6.0
334 void purple_blist_set_ui_data(gpointer ui_data);
337 * Returns the next node of a given node. This function is to be used to iterate
338 * over the tree returned by purple_get_blist.
340 * @param node A node.
341 * @param offline Whether to include nodes for offline accounts
342 * @return The next node
343 * @see purple_blist_node_get_parent
344 * @see purple_blist_node_get_first_child
345 * @see purple_blist_node_get_sibling_next
346 * @see purple_blist_node_get_sibling_prev
348 PurpleBlistNode *purple_blist_node_next(PurpleBlistNode *node, gboolean offline);
351 * Returns the parent node of a given node.
353 * @param node A node.
354 * @return The parent node.
355 * @since 2.4.0
356 * @see purple_blist_node_get_first_child
357 * @see purple_blist_node_get_sibling_next
358 * @see purple_blist_node_get_sibling_prev
359 * @see purple_blist_node_next
361 PurpleBlistNode *purple_blist_node_get_parent(PurpleBlistNode *node);
364 * Returns the the first child node of a given node.
366 * @param node A node.
367 * @return The child node.
368 * @since 2.4.0
369 * @see purple_blist_node_get_parent
370 * @see purple_blist_node_get_sibling_next
371 * @see purple_blist_node_get_sibling_prev
372 * @see purple_blist_node_next
374 PurpleBlistNode *purple_blist_node_get_first_child(PurpleBlistNode *node);
377 * Returns the sibling node of a given node.
379 * @param node A node.
380 * @return The sibling node.
381 * @since 2.4.0
382 * @see purple_blist_node_get_parent
383 * @see purple_blist_node_get_first_child
384 * @see purple_blist_node_get_sibling_prev
385 * @see purple_blist_node_next
387 PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node);
390 * Returns the previous sibling node of a given node.
392 * @param node A node.
393 * @return The sibling node.
394 * @since 2.4.0
395 * @see purple_blist_node_get_parent
396 * @see purple_blist_node_get_first_child
397 * @see purple_blist_node_get_sibling_next
398 * @see purple_blist_node_next
400 PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node);
403 * Returns the UI data of a given node.
405 * @param node The node.
406 * @return The UI data.
407 * @since 2.6.0
409 gpointer purple_blist_node_get_ui_data(const PurpleBlistNode *node);
412 * Sets the UI data of a given node.
414 * @param node The node.
415 * @param ui_data The UI data.
417 * @since 2.6.0
419 void purple_blist_node_set_ui_data(PurpleBlistNode *node, gpointer ui_data);
422 * Shows the buddy list, creating a new one if necessary.
424 void purple_blist_show(void);
428 * Destroys the buddy list window.
430 * @deprecated The UI is responsible for cleaning up the
431 * PurpleBuddyList->ui_data. purple_blist_uninit() will free the
432 * PurpleBuddyList* itself.
434 void purple_blist_destroy(void);
437 * Hides or unhides the buddy list.
439 * @param show Whether or not to show the buddy list
441 void purple_blist_set_visible(gboolean show);
444 * Updates a buddy's status.
446 * This should only be called from within Purple.
448 * @param buddy The buddy whose status has changed.
449 * @param old_status The status from which we are changing.
451 void purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status);
454 * Updates a node's custom icon.
456 * @param node The PurpleBlistNode whose custom icon has changed.
458 * @since 2.5.0
460 void purple_blist_update_node_icon(PurpleBlistNode *node);
462 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
464 * Updates a buddy's icon.
466 * @param buddy The buddy whose buddy icon has changed
467 * @deprecated Use purple_blist_update_node_icon() instead.
469 void purple_blist_update_buddy_icon(PurpleBuddy *buddy);
470 #endif
473 * Renames a buddy in the buddy list.
475 * @param buddy The buddy whose name will be changed.
476 * @param name The new name of the buddy.
478 void purple_blist_rename_buddy(PurpleBuddy *buddy, const char *name);
481 * Aliases a contact in the buddy list.
483 * @param contact The contact whose alias will be changed.
484 * @param alias The contact's alias.
486 void purple_blist_alias_contact(PurpleContact *contact, const char *alias);
489 * Aliases a buddy in the buddy list.
491 * @param buddy The buddy whose alias will be changed.
492 * @param alias The buddy's alias.
494 void purple_blist_alias_buddy(PurpleBuddy *buddy, const char *alias);
497 * Sets the server-sent alias of a buddy in the buddy list.
498 * PRPLs should call serv_got_alias() instead of this.
500 * @param buddy The buddy whose alias will be changed.
501 * @param alias The buddy's "official" alias.
503 void purple_blist_server_alias_buddy(PurpleBuddy *buddy, const char *alias);
506 * Aliases a chat in the buddy list.
508 * @param chat The chat whose alias will be changed.
509 * @param alias The chat's new alias.
511 void purple_blist_alias_chat(PurpleChat *chat, const char *alias);
514 * Renames a group
516 * @param group The group to rename
517 * @param name The new name
519 void purple_blist_rename_group(PurpleGroup *group, const char *name);
522 * Creates a new chat for the buddy list
524 * @param account The account this chat will get added to
525 * @param alias The alias of the new chat
526 * @param components The info the prpl needs to join the chat. The
527 * hash function should be g_str_hash() and the
528 * equal function should be g_str_equal().
529 * @return A newly allocated chat
531 PurpleChat *purple_chat_new(PurpleAccount *account, const char *alias, GHashTable *components);
534 * Destroys a chat
536 * @param chat The chat to destroy
538 void purple_chat_destroy(PurpleChat *chat);
541 * Adds a new chat to the buddy list.
543 * The chat will be inserted right after node or appended to the end
544 * of group if node is NULL. If both are NULL, the buddy will be added to
545 * the "Chats" group.
547 * @param chat The new chat who gets added
548 * @param group The group to add the new chat to.
549 * @param node The insertion point
551 void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node);
554 * Creates a new buddy.
556 * This function only creates the PurpleBuddy. Use purple_blist_add_buddy
557 * to add the buddy to the list and purple_account_add_buddy to sync up
558 * with the server.
560 * @param account The account this buddy will get added to
561 * @param name The name of the new buddy
562 * @param alias The alias of the new buddy (or NULL if unaliased)
563 * @return A newly allocated buddy
565 * @see purple_account_add_buddy
566 * @see purple_blist_add_buddy
568 PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias);
571 * Destroys a buddy
573 * @param buddy The buddy to destroy
575 void purple_buddy_destroy(PurpleBuddy *buddy);
578 * Sets a buddy's icon.
580 * This should only be called from within Purple. You probably want to
581 * call purple_buddy_icon_set_data().
583 * @param buddy The buddy.
584 * @param icon The buddy icon.
586 * @see purple_buddy_icon_set_data()
588 void purple_buddy_set_icon(PurpleBuddy *buddy, PurpleBuddyIcon *icon);
591 * Returns a buddy's account.
593 * @param buddy The buddy.
595 * @return The account
597 PurpleAccount *purple_buddy_get_account(const PurpleBuddy *buddy);
600 * Returns a buddy's name
602 * @param buddy The buddy.
604 * @return The name.
606 const char *purple_buddy_get_name(const PurpleBuddy *buddy);
609 * Returns a buddy's icon.
611 * @param buddy The buddy.
613 * @return The buddy icon.
615 PurpleBuddyIcon *purple_buddy_get_icon(const PurpleBuddy *buddy);
618 * Returns a buddy's protocol-specific data.
620 * This should only be called from the associated prpl.
622 * @param buddy The buddy.
623 * @return The protocol data.
625 * @see purple_buddy_set_protocol_data()
626 * @since 2.6.0
628 gpointer purple_buddy_get_protocol_data(const PurpleBuddy *buddy);
631 * Sets a buddy's protocol-specific data.
633 * This should only be called from the associated prpl.
635 * @param buddy The buddy.
636 * @param data The data.
638 * @see purple_buddy_get_protocol_data()
639 * @since 2.6.0
641 void purple_buddy_set_protocol_data(PurpleBuddy *buddy, gpointer data);
644 * Returns a buddy's contact.
646 * @param buddy The buddy.
648 * @return The buddy's contact.
650 PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy);
653 * Returns a buddy's presence.
655 * @param buddy The buddy.
657 * @return The buddy's presence.
659 PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy);
662 * Gets the media caps from a buddy.
664 * @param buddy The buddy.
665 * @return The media caps.
667 * @since 2.7.0
669 PurpleMediaCaps purple_buddy_get_media_caps(const PurpleBuddy *buddy);
672 * Sets the media caps for a buddy.
674 * @param buddy The PurpleBuddy.
675 * @param media_caps The PurpleMediaCaps.
677 void purple_buddy_set_media_caps(PurpleBuddy *buddy, PurpleMediaCaps media_caps);
680 * Adds a new buddy to the buddy list.
682 * The buddy will be inserted right after node or prepended to the
683 * group if node is NULL. If both are NULL, the buddy will be added to
684 * the "Buddies" group.
686 * @param buddy The new buddy who gets added
687 * @param contact The optional contact to place the buddy in.
688 * @param group The group to add the new buddy to.
689 * @param node The insertion point. Pass in NULL to add the node as
690 * the first child in the given group.
692 void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node);
695 * Creates a new group
697 * You can't have more than one group with the same name. Sorry. If you pass
698 * this the name of a group that already exists, it will return that group.
700 * @param name The name of the new group
701 * @return A new group struct
703 PurpleGroup *purple_group_new(const char *name);
706 * Destroys a group
708 * @param group The group to destroy
710 void purple_group_destroy(PurpleGroup *group);
713 * Adds a new group to the buddy list.
715 * The new group will be inserted after insert or prepended to the list if
716 * node is NULL.
718 * @param group The group
719 * @param node The insertion point
721 void purple_blist_add_group(PurpleGroup *group, PurpleBlistNode *node);
724 * Creates a new contact
726 * @return A new contact struct
728 PurpleContact *purple_contact_new(void);
731 * Destroys a contact
733 * @param contact The contact to destroy
735 void purple_contact_destroy(PurpleContact *contact);
738 * Gets the PurpleGroup from a PurpleContact
740 * @param contact The contact
741 * @return The group
743 * @since 2.7.0
745 PurpleGroup *purple_contact_get_group(const PurpleContact *contact);
748 * Adds a new contact to the buddy list.
750 * The new contact will be inserted after insert or prepended to the list if
751 * node is NULL.
753 * @param contact The contact
754 * @param group The group to add the contact to
755 * @param node The insertion point
757 void purple_blist_add_contact(PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node);
760 * Merges two contacts
762 * All of the buddies from source will be moved to target
764 * @param source The contact to merge
765 * @param node The place to merge to (a buddy or contact)
767 void purple_blist_merge_contact(PurpleContact *source, PurpleBlistNode *node);
770 * Returns the highest priority buddy for a given contact.
772 * @param contact The contact
773 * @return The highest priority buddy
775 PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact);
777 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
779 * Sets the alias for a contact.
781 * @param contact The contact
782 * @param alias The alias to set, or NULL to unset
784 * @deprecated Use purple_blist_alias_contact() instead.
786 void purple_contact_set_alias(PurpleContact *contact, const char *alias);
787 #endif
790 * Gets the alias for a contact.
792 * @param contact The contact
793 * @return The alias, or NULL if it is not set.
795 const char *purple_contact_get_alias(PurpleContact *contact);
798 * Determines whether an account owns any buddies in a given contact
800 * @param contact The contact to search through.
801 * @param account The account.
803 * @return TRUE if there are any buddies from account in the contact, or FALSE otherwise.
805 gboolean purple_contact_on_account(PurpleContact *contact, PurpleAccount *account);
808 * Invalidates the priority buddy so that the next call to
809 * purple_contact_get_priority_buddy recomputes it.
811 * @param contact The contact
813 void purple_contact_invalidate_priority_buddy(PurpleContact *contact);
816 * Removes a buddy from the buddy list and frees the memory allocated to it.
817 * This doesn't actually try to remove the buddy from the server list.
819 * @param buddy The buddy to be removed
821 * @see purple_account_remove_buddy
823 void purple_blist_remove_buddy(PurpleBuddy *buddy);
826 * Removes a contact, and any buddies it contains, and frees the memory
827 * allocated to it. This calls purple_blist_remove_buddy and therefore
828 * doesn't remove the buddies from the server list.
830 * @param contact The contact to be removed
832 * @see purple_blist_remove_buddy
834 void purple_blist_remove_contact(PurpleContact *contact);
837 * Removes a chat from the buddy list and frees the memory allocated to it.
839 * @param chat The chat to be removed
841 void purple_blist_remove_chat(PurpleChat *chat);
844 * Removes a group from the buddy list and frees the memory allocated to it and to
845 * its children
847 * @param group The group to be removed
849 void purple_blist_remove_group(PurpleGroup *group);
852 * Returns the alias of a buddy.
854 * @param buddy The buddy whose name will be returned.
855 * @return The alias (if set), server alias (if set),
856 * or NULL.
858 const char *purple_buddy_get_alias_only(PurpleBuddy *buddy);
861 * Gets the server alias for a buddy.
863 * @param buddy The buddy whose name will be returned
864 * @return The server alias, or NULL if it is not set.
866 const char *purple_buddy_get_server_alias(PurpleBuddy *buddy);
869 * Returns the correct name to display for a buddy, taking the contact alias
870 * into account. In order of precedence: the buddy's alias; the buddy's
871 * contact alias; the buddy's server alias; the buddy's user name.
873 * @param buddy The buddy whose name will be returned
874 * @return The appropriate name or alias, or NULL.
877 const char *purple_buddy_get_contact_alias(PurpleBuddy *buddy);
879 #if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
881 * Returns the correct alias for this user, ignoring server aliases. Used
882 * when a user-recognizable name is required. In order: buddy's alias; buddy's
883 * contact alias; buddy's user name.
885 * @param buddy The buddy whose alias will be returned.
886 * @return The appropriate name or alias.
887 * @deprecated Try purple_buddy_get_alias(), if server aliases are okay.
889 const char *purple_buddy_get_local_alias(PurpleBuddy *buddy);
890 #endif
893 * Returns the correct name to display for a buddy. In order of precedence:
894 * the buddy's alias; the buddy's server alias; the buddy's contact alias;
895 * the buddy's user name.
897 * @param buddy The buddy whose name will be returned.
898 * @return The appropriate name or alias, or NULL
900 const char *purple_buddy_get_alias(PurpleBuddy *buddy);
903 * Returns the local alias for the buddy, or @c NULL if none exists.
905 * @param buddy The buddy
906 * @return The local alias for the buddy
908 * @since 2.6.0
910 const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy);
913 * Returns the correct name to display for a blist chat.
915 * @param chat The chat whose name will be returned.
916 * @return The alias (if set), or first component value.
918 const char *purple_chat_get_name(PurpleChat *chat);
921 * Finds the buddy struct given a name and an account
923 * @param account The account this buddy belongs to
924 * @param name The buddy's name
925 * @return The buddy or NULL if the buddy does not exist
927 PurpleBuddy *purple_find_buddy(PurpleAccount *account, const char *name);
930 * Finds the buddy struct given a name, an account, and a group
932 * @param account The account this buddy belongs to
933 * @param name The buddy's name
934 * @param group The group to look in
935 * @return The buddy or NULL if the buddy does not exist in the group
937 PurpleBuddy *purple_find_buddy_in_group(PurpleAccount *account, const char *name,
938 PurpleGroup *group);
941 * Finds all PurpleBuddy structs given a name and an account
943 * @param account The account this buddy belongs to
944 * @param name The buddy's name (or NULL to return all buddies for the account)
946 * @return A GSList of buddies (which must be freed), or NULL if the buddy doesn't exist
948 GSList *purple_find_buddies(PurpleAccount *account, const char *name);
952 * Finds a group by name
954 * @param name The group's name
955 * @return The group or NULL if the group does not exist
957 PurpleGroup *purple_find_group(const char *name);
960 * Finds a chat by name.
962 * @param account The chat's account.
963 * @param name The chat's name.
965 * @return The chat, or @c NULL if the chat does not exist.
967 PurpleChat *purple_blist_find_chat(PurpleAccount *account, const char *name);
970 * Returns the group of which the chat is a member.
972 * @param chat The chat.
974 * @return The parent group, or @c NULL if the chat is not in a group.
976 PurpleGroup *purple_chat_get_group(PurpleChat *chat);
979 * Returns the account the chat belongs to.
981 * @param chat The chat.
983 * @return The account the chat belongs to.
985 * @since 2.4.0
987 PurpleAccount *purple_chat_get_account(PurpleChat *chat);
990 * Get a hashtable containing information about a chat.
992 * @param chat The chat.
994 * @constreturn The hashtable.
996 * @since 2.4.0
998 GHashTable *purple_chat_get_components(PurpleChat *chat);
1001 * Returns the group of which the buddy is a member.
1003 * @param buddy The buddy
1004 * @return The group or NULL if the buddy is not in a group
1006 PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy);
1010 * Returns a list of accounts that have buddies in this group
1012 * @param g The group
1014 * @return A GSList of accounts (which must be freed), or NULL if the group
1015 * has no accounts.
1017 GSList *purple_group_get_accounts(PurpleGroup *g);
1020 * Determines whether an account owns any buddies in a given group
1022 * @param g The group to search through.
1023 * @param account The account.
1025 * @return TRUE if there are any buddies in the group, or FALSE otherwise.
1027 gboolean purple_group_on_account(PurpleGroup *g, PurpleAccount *account);
1030 * Returns the name of a group.
1032 * @param group The group.
1034 * @return The name of the group.
1036 const char *purple_group_get_name(PurpleGroup *group);
1039 * Called when an account connects. Tells the UI to update all the
1040 * buddies.
1042 * @param account The account
1044 void purple_blist_add_account(PurpleAccount *account);
1048 * Called when an account disconnects. Sets the presence of all the buddies to 0
1049 * and tells the UI to update them.
1051 * @param account The account
1053 void purple_blist_remove_account(PurpleAccount *account);
1057 * Determines the total size of a group
1059 * @param group The group
1060 * @param offline Count buddies in offline accounts
1061 * @return The number of buddies in the group
1063 int purple_blist_get_group_size(PurpleGroup *group, gboolean offline);
1066 * Determines the number of online buddies in a group
1068 * @param group The group
1069 * @return The number of online buddies in the group, or 0 if the group is NULL
1071 int purple_blist_get_group_online_count(PurpleGroup *group);
1073 /*@}*/
1075 /****************************************************************************************/
1076 /** @name Buddy list file management API */
1077 /****************************************************************************************/
1080 * Loads the buddy list from ~/.purple/blist.xml.
1082 void purple_blist_load(void);
1085 * Schedule a save of the blist.xml file. This is used by the privacy
1086 * API whenever the privacy settings are changed. If you make a change
1087 * to blist.xml using one of the functions in the buddy list API, then
1088 * the buddy list is saved automatically, so you should not need to
1089 * call this.
1091 void purple_blist_schedule_save(void);
1094 * Requests from the user information needed to add a buddy to the
1095 * buddy list.
1097 * @param account The account the buddy is added to.
1098 * @param username The username of the buddy.
1099 * @param group The name of the group to place the buddy in.
1100 * @param alias The optional alias for the buddy.
1102 void purple_blist_request_add_buddy(PurpleAccount *account, const char *username,
1103 const char *group, const char *alias);
1106 * Requests from the user information needed to add a chat to the
1107 * buddy list.
1109 * @param account The account the buddy is added to.
1110 * @param group The optional group to add the chat to.
1111 * @param alias The optional alias for the chat.
1112 * @param name The required chat name.
1114 void purple_blist_request_add_chat(PurpleAccount *account, PurpleGroup *group,
1115 const char *alias, const char *name);
1118 * Requests from the user information needed to add a group to the
1119 * buddy list.
1121 void purple_blist_request_add_group(void);
1124 * Associates a boolean with a node in the buddy list
1126 * @param node The node to associate the data with
1127 * @param key The identifier for the data
1128 * @param value The value to set
1130 void purple_blist_node_set_bool(PurpleBlistNode *node, const char *key, gboolean value);
1133 * Retrieves a named boolean setting from a node in the buddy list
1135 * @param node The node to retrieve the data from
1136 * @param key The identifier of the data
1138 * @return The value, or FALSE if there is no setting
1140 gboolean purple_blist_node_get_bool(PurpleBlistNode *node, const char *key);
1143 * Associates an integer with a node in the buddy list
1145 * @param node The node to associate the data with
1146 * @param key The identifier for the data
1147 * @param value The value to set
1149 void purple_blist_node_set_int(PurpleBlistNode *node, const char *key, int value);
1152 * Retrieves a named integer setting from a node in the buddy list
1154 * @param node The node to retrieve the data from
1155 * @param key The identifier of the data
1157 * @return The value, or 0 if there is no setting
1159 int purple_blist_node_get_int(PurpleBlistNode *node, const char *key);
1162 * Associates a string with a node in the buddy list
1164 * @param node The node to associate the data with
1165 * @param key The identifier for the data
1166 * @param value The value to set
1168 void purple_blist_node_set_string(PurpleBlistNode *node, const char *key,
1169 const char *value);
1172 * Retrieves a named string setting from a node in the buddy list
1174 * @param node The node to retrieve the data from
1175 * @param key The identifier of the data
1177 * @return The value, or NULL if there is no setting
1179 const char *purple_blist_node_get_string(PurpleBlistNode *node, const char *key);
1182 * Removes a named setting from a blist node
1184 * @param node The node from which to remove the setting
1185 * @param key The name of the setting
1187 void purple_blist_node_remove_setting(PurpleBlistNode *node, const char *key);
1190 * Set the flags for the given node. Setting a node's flags will overwrite
1191 * the old flags, so if you want to save them, you must first call
1192 * purple_blist_node_get_flags and modify that appropriately.
1194 * @param node The node on which to set the flags.
1195 * @param flags The flags to set. This is a bitmask.
1197 void purple_blist_node_set_flags(PurpleBlistNode *node, PurpleBlistNodeFlags flags);
1200 * Get the current flags on a given node.
1202 * @param node The node from which to get the flags.
1204 * @return The flags on the node. This is a bitmask.
1206 PurpleBlistNodeFlags purple_blist_node_get_flags(PurpleBlistNode *node);
1209 * Get the type of a given node.
1211 * @param node The node.
1213 * @return The type of the node.
1215 * @since 2.1.0
1217 PurpleBlistNodeType purple_blist_node_get_type(PurpleBlistNode *node);
1219 /*@}*/
1222 * Retrieves the extended menu items for a buddy list node.
1223 * @param n The blist node for which to obtain the extended menu items.
1224 * @return A list of PurpleMenuAction items, as harvested by the
1225 * blist-node-extended-menu signal.
1227 GList *purple_blist_node_get_extended_menu(PurpleBlistNode *n);
1229 /**************************************************************************/
1230 /** @name UI Registration Functions */
1231 /**************************************************************************/
1232 /*@{*/
1235 * Sets the UI operations structure to be used for the buddy list.
1237 * @param ops The ops struct.
1239 void purple_blist_set_ui_ops(PurpleBlistUiOps *ops);
1242 * Returns the UI operations structure to be used for the buddy list.
1244 * @return The UI operations structure.
1246 PurpleBlistUiOps *purple_blist_get_ui_ops(void);
1248 /*@}*/
1250 /**************************************************************************/
1251 /** @name Buddy List Subsystem */
1252 /**************************************************************************/
1253 /*@{*/
1256 * Returns the handle for the buddy list subsystem.
1258 * @return The buddy list subsystem handle.
1260 void *purple_blist_get_handle(void);
1263 * Initializes the buddy list subsystem.
1265 void purple_blist_init(void);
1268 * Uninitializes the buddy list subsystem.
1270 void purple_blist_uninit(void);
1272 /*@}*/
1274 #ifdef __cplusplus
1276 #endif
1278 #endif /* _PURPLE_BLIST_H_ */