Frameworks/libpurple.framework/Versions/0.6.2/Headers/blist.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2571 Frameworks/libpurple.framework/Versions/0.6.0/Headers/blist.h@75fb8ee8f2e6
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file blist.h Buddy List API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @see @ref blist-signals
Evan@653
     5
 */
Evan@653
     6
Evan@653
     7
/* purple
Evan@653
     8
 *
Evan@653
     9
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
    10
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    11
 * source distribution.
Evan@653
    12
 *
Evan@653
    13
 * This program is free software; you can redistribute it and/or modify
Evan@653
    14
 * it under the terms of the GNU General Public License as published by
Evan@653
    15
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    16
 * (at your option) any later version.
Evan@653
    17
 *
Evan@653
    18
 * This program is distributed in the hope that it will be useful,
Evan@653
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    21
 * GNU General Public License for more details.
Evan@653
    22
 *
Evan@653
    23
 * You should have received a copy of the GNU General Public License
Evan@653
    24
 * along with this program; if not, write to the Free Software
Evan@653
    25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    26
 */
Evan@653
    27
#ifndef _PURPLE_BLIST_H_
Evan@653
    28
#define _PURPLE_BLIST_H_
Evan@653
    29
Evan@653
    30
/* I can't believe I let ChipX86 inspire me to write good code. -Sean */
Evan@653
    31
Evan@653
    32
#include <glib.h>
Evan@653
    33
Evan@653
    34
/** @copydoc _PurpleBuddyList */
Evan@653
    35
typedef struct _PurpleBuddyList PurpleBuddyList;
Evan@653
    36
/** @copydoc _PurpleBlistUiOps */
Evan@653
    37
typedef struct _PurpleBlistUiOps PurpleBlistUiOps;
Evan@653
    38
/** @copydoc _PurpleBlistNode */
Evan@653
    39
typedef struct _PurpleBlistNode PurpleBlistNode;
Evan@653
    40
Evan@653
    41
/** @copydoc _PurpleChat */
Evan@653
    42
typedef struct _PurpleChat PurpleChat;
Evan@653
    43
/** @copydoc _PurpleGroup */
Evan@653
    44
typedef struct _PurpleGroup PurpleGroup;
Evan@653
    45
/** @copydoc _PurpleContact */
Evan@653
    46
typedef struct _PurpleContact PurpleContact;
Evan@653
    47
/** @copydoc _PurpleBuddy */
Evan@653
    48
typedef struct _PurpleBuddy PurpleBuddy;
Evan@653
    49
Evan@653
    50
/**************************************************************************/
Evan@653
    51
/* Enumerations                                                           */
Evan@653
    52
/**************************************************************************/
Evan@653
    53
typedef enum
Evan@653
    54
{
Evan@653
    55
	PURPLE_BLIST_GROUP_NODE,
Evan@653
    56
	PURPLE_BLIST_CONTACT_NODE,
Evan@653
    57
	PURPLE_BLIST_BUDDY_NODE,
Evan@653
    58
	PURPLE_BLIST_CHAT_NODE,
Evan@653
    59
	PURPLE_BLIST_OTHER_NODE
Evan@653
    60
Evan@653
    61
} PurpleBlistNodeType;
Evan@653
    62
Evan@653
    63
#define PURPLE_BLIST_NODE_IS_CHAT(n)    (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE)
Evan@653
    64
#define PURPLE_BLIST_NODE_IS_BUDDY(n)   (purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE)
Evan@653
    65
#define PURPLE_BLIST_NODE_IS_CONTACT(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CONTACT_NODE)
Evan@653
    66
#define PURPLE_BLIST_NODE_IS_GROUP(n)   (purple_blist_node_get_type(n) == PURPLE_BLIST_GROUP_NODE)
Evan@653
    67
Evan@653
    68
#define PURPLE_BUDDY_IS_ONLINE(b) \
Evan@653
    69
	((b) != NULL && purple_account_is_connected(purple_buddy_get_account(b)) && \
Evan@653
    70
	 purple_presence_is_online(purple_buddy_get_presence(b)))
Evan@653
    71
Evan@653
    72
typedef enum
Evan@653
    73
{
Evan@653
    74
	PURPLE_BLIST_NODE_FLAG_NO_SAVE      = 1 << 0 /**< node should not be saved with the buddy list */
Evan@653
    75
Evan@653
    76
} PurpleBlistNodeFlags;
Evan@653
    77
Evan@1427
    78
/**
Evan@1427
    79
 * @since 2.6.0
Evan@1427
    80
 */
Evan@1427
    81
#define PURPLE_BLIST_NODE(obj) ((PurpleBlistNode *)(obj))
Evan@1427
    82
Evan@653
    83
#define PURPLE_BLIST_NODE_HAS_FLAG(b, f) (purple_blist_node_get_flags((PurpleBlistNode*)(b)) & (f))
Evan@653
    84
#define PURPLE_BLIST_NODE_SHOULD_SAVE(b) (! PURPLE_BLIST_NODE_HAS_FLAG(b, PURPLE_BLIST_NODE_FLAG_NO_SAVE))
Evan@653
    85
Evan@653
    86
#define PURPLE_BLIST_NODE_NAME(n) (purple_blist_node_get_type(n) == PURPLE_BLIST_CHAT_NODE  ? purple_chat_get_name((PurpleChat*)n) :        \
Evan@653
    87
				     purple_blist_node_get_type(n) == PURPLE_BLIST_BUDDY_NODE ? purple_buddy_get_name((PurpleBuddy*)n) : NULL)
Evan@653
    88
Evan@1427
    89
/**
Evan@1427
    90
 * @since 2.6.0
Evan@1427
    91
 */
Evan@1427
    92
#define PURPLE_GROUP(obj) ((PurpleGroup *)(obj))
Evan@1427
    93
Evan@1427
    94
/**
Evan@1427
    95
 * @since 2.6.0
Evan@1427
    96
 */
Evan@1427
    97
#define PURPLE_CONTACT(obj) ((PurpleContact *)(obj))
Evan@1427
    98
Evan@1427
    99
/**
Evan@1427
   100
 * @since 2.6.0
Evan@1427
   101
 */
Evan@1427
   102
#define PURPLE_BUDDY(obj) ((PurpleBuddy *)(obj))
Evan@1427
   103
Evan@1427
   104
/**
Evan@1427
   105
 * @since 2.6.0
Evan@1427
   106
 */
Evan@1427
   107
#define PURPLE_CHAT(obj) ((PurpleChat *)(obj))
Evan@1427
   108
Evan@653
   109
#include "account.h"
Evan@653
   110
#include "buddyicon.h"
Evan@653
   111
#include "status.h"
Evan@653
   112
Evan@653
   113
/**************************************************************************/
Evan@653
   114
/* Data Structures                                                        */
Evan@653
   115
/**************************************************************************/
Evan@653
   116
Evan@653
   117
#if !(defined PURPLE_HIDE_STRUCTS) || (defined _PURPLE_BLIST_C_)
Evan@653
   118
Evan@653
   119
/**
Evan@653
   120
 * A Buddy list node.  This can represent a group, a buddy, or anything else.
zacw@2069
   121
 * This is a base class for PurpleBuddy, PurpleContact, PurpleGroup, and for
zacw@2069
   122
 * anything else that wants to put itself in the buddy list. */
Evan@653
   123
struct _PurpleBlistNode {
Evan@653
   124
	PurpleBlistNodeType type;             /**< The type of node this is       */
Evan@653
   125
	PurpleBlistNode *prev;                /**< The sibling before this buddy. */
Evan@653
   126
	PurpleBlistNode *next;                /**< The sibling after this buddy.  */
Evan@653
   127
	PurpleBlistNode *parent;              /**< The parent of this node        */
Evan@653
   128
	PurpleBlistNode *child;               /**< The child of this node         */
Evan@653
   129
	GHashTable *settings;               /**< per-node settings              */
Evan@653
   130
	void          *ui_data;             /**< The UI can put data here.      */
Evan@653
   131
	PurpleBlistNodeFlags flags;           /**< The buddy flags                */
Evan@653
   132
};
Evan@653
   133
Evan@653
   134
/**
Evan@653
   135
 * A buddy.  This contains everything Purple will ever need to know about someone on the buddy list.  Everything.
Evan@653
   136
 */
Evan@653
   137
struct _PurpleBuddy {
Evan@653
   138
	PurpleBlistNode node;                     /**< The node that this buddy inherits from */
Evan@1427
   139
	char *name;                             /**< The name of the buddy. */
Evan@653
   140
	char *alias;                            /**< The user-set alias of the buddy */
Evan@653
   141
	char *server_alias;                     /**< The server-specified alias of the buddy.  (i.e. MSN "Friendly Names") */
Evan@653
   142
	void *proto_data;                       /**< This allows the prpl to associate whatever data it wants with a buddy */
Evan@653
   143
	PurpleBuddyIcon *icon;                    /**< The buddy icon. */
Evan@653
   144
	PurpleAccount *account;					/**< the account this buddy belongs to */
Evan@653
   145
	PurplePresence *presence;
Evan@653
   146
};
Evan@653
   147
Evan@653
   148
/**
Evan@653
   149
 * A contact.  This contains everything Purple will ever need to know about a contact.
Evan@653
   150
 */
Evan@653
   151
struct _PurpleContact {
Evan@653
   152
	PurpleBlistNode node;		/**< The node that this contact inherits from. */
Evan@653
   153
	char *alias;            /**< The user-set alias of the contact */
Evan@653
   154
	int totalsize;		    /**< The number of buddies in this contact */
Evan@653
   155
	int currentsize;	    /**< The number of buddies in this contact corresponding to online accounts */
Evan@653
   156
	int online;			    /**< The number of buddies in this contact who are currently online */
Evan@653
   157
	PurpleBuddy *priority;    /**< The "top" buddy for this contact */
Evan@653
   158
	gboolean priority_valid; /**< Is priority valid? */
Evan@653
   159
};
Evan@653
   160
Evan@653
   161
Evan@653
   162
/**
Evan@653
   163
 * A group.  This contains everything Purple will ever need to know about a group.
Evan@653
   164
 */
Evan@653
   165
struct _PurpleGroup {
Evan@653
   166
	PurpleBlistNode node;                    /**< The node that this group inherits from */
Evan@653
   167
	char *name;                            /**< The name of this group. */
Evan@653
   168
	int totalsize;			       /**< The number of chats and contacts in this group */
Evan@653
   169
	int currentsize;		       /**< The number of chats and contacts in this group corresponding to online accounts */
Evan@653
   170
	int online;			       /**< The number of chats and contacts in this group who are currently online */
Evan@653
   171
};
Evan@653
   172
Evan@653
   173
/**
Evan@653
   174
 * A chat.  This contains everything Purple needs to put a chat room in the
Evan@653
   175
 * buddy list.
Evan@653
   176
 */
Evan@653
   177
struct _PurpleChat {
Evan@653
   178
	PurpleBlistNode node;      /**< The node that this chat inherits from */
Evan@653
   179
	char *alias;             /**< The display name of this chat. */
Evan@653
   180
	GHashTable *components;  /**< the stuff the protocol needs to know to join the chat */
Evan@653
   181
	PurpleAccount *account; /**< The account this chat is attached to */
Evan@653
   182
};
Evan@653
   183
Evan@653
   184
/**
Evan@653
   185
 * The Buddy List
Evan@653
   186
 */
Evan@653
   187
struct _PurpleBuddyList {
Evan@653
   188
	PurpleBlistNode *root;          /**< The first node in the buddy list */
Evan@653
   189
	GHashTable *buddies;          /**< Every buddy in this list */
Evan@653
   190
	void *ui_data;                /**< UI-specific data. */
Evan@653
   191
};
Evan@653
   192
Evan@1427
   193
#endif /* PURPLE_HIDE_STRUCTS && PURPLE_BLIST_STRUCTS */
Evan@1427
   194
Evan@653
   195
/**
Evan@653
   196
 * Buddy list UI operations.
Evan@653
   197
 *
Evan@653
   198
 * Any UI representing a buddy list must assign a filled-out PurpleBlistUiOps
Evan@653
   199
 * structure to the buddy list core.
Evan@653
   200
 */
Evan@653
   201
struct _PurpleBlistUiOps
Evan@653
   202
{
Evan@653
   203
	void (*new_list)(PurpleBuddyList *list); /**< Sets UI-specific data on a buddy list. */
Evan@653
   204
	void (*new_node)(PurpleBlistNode *node); /**< Sets UI-specific data on a node. */
Evan@653
   205
	void (*show)(PurpleBuddyList *list);     /**< The core will call this when it's finished doing its core stuff */
Evan@653
   206
	void (*update)(PurpleBuddyList *list,
Evan@653
   207
		       PurpleBlistNode *node);       /**< This will update a node in the buddy list. */
Evan@653
   208
	void (*remove)(PurpleBuddyList *list,
Evan@653
   209
		       PurpleBlistNode *node);       /**< This removes a node from the list */
zacw@2069
   210
	void (*destroy)(PurpleBuddyList *list);  /**< When the list is destroyed, this is called to destroy the UI. */
Evan@653
   211
	void (*set_visible)(PurpleBuddyList *list,
Evan@653
   212
			    gboolean show);            /**< Hides or unhides the buddy list */
Evan@653
   213
	void (*request_add_buddy)(PurpleAccount *account, const char *username,
Evan@653
   214
							  const char *group, const char *alias);
Evan@653
   215
	void (*request_add_chat)(PurpleAccount *account, PurpleGroup *group,
Evan@653
   216
							 const char *alias, const char *name);
Evan@653
   217
	void (*request_add_group)(void);
Evan@653
   218
Evan@2571
   219
	/**
Evan@2571
   220
	 * This is called when a node has been modified and should be saved.
Evan@2571
   221
	 *
Evan@2571
   222
	 * Implementation of this UI op is OPTIONAL. If not implemented, it will
Evan@2571
   223
	 * be set to a fallback function that saves data to blist.xml like in
Evan@2571
   224
	 * previous libpurple versions.
Evan@2571
   225
	 *
Evan@2571
   226
	 * @attrib node    The node which has been modified.
Evan@2571
   227
	 *
Evan@2571
   228
	 * @since 2.6.0.
Evan@2571
   229
	 */
Evan@2571
   230
	void (*save_node)(PurpleBlistNode *node);
Evan@2571
   231
Evan@2571
   232
	/**
Evan@2571
   233
	 * Called when a node is about to be removed from the buddy list.
Evan@2571
   234
	 * The UI op should update the relevant data structures to remove this
Evan@2571
   235
	 * node (for example, removing a buddy from the group this node is in).
Evan@2571
   236
	 *
Evan@2571
   237
	 * Implementation of this UI op is OPTIONAL. If not implemented, it will
Evan@2571
   238
	 * be set to a fallback function that saves data to blist.xml like in
Evan@2571
   239
	 * previous libpurple versions.
Evan@2571
   240
	 *
Evan@2571
   241
	 * @attrib node  The node which has been modified.
Evan@2571
   242
	 * @since 2.6.0.
Evan@2571
   243
	 */
Evan@2571
   244
	void (*remove_node)(PurpleBlistNode *node);
Evan@2571
   245
Evan@2571
   246
	/**
Evan@2571
   247
	 * Called to save all the data for an account. If the UI sets this,
Evan@2571
   248
	 * the callback must save the privacy and buddy list data for an account.
Evan@2571
   249
	 * If the account is NULL, save the data for all accounts.
Evan@2571
   250
	 *
Evan@2571
   251
	 * Implementation of this UI op is OPTIONAL. If not implemented, it will
Evan@2571
   252
	 * be set to a fallback function that saves data to blist.xml like in
Evan@2571
   253
	 * previous libpurple versions.
Evan@2571
   254
	 *
Evan@2571
   255
	 * @attrib account  The account whose data to save. If NULL, save all data
Evan@2571
   256
	 *                  for all accounts.
Evan@2571
   257
	 * @since 2.6.0.
Evan@2571
   258
	 */
Evan@2571
   259
	void (*save_account)(PurpleAccount *account);
Evan@2571
   260
Evan@653
   261
	void (*_purple_reserved1)(void);
Evan@653
   262
};
Evan@653
   263
Evan@653
   264
#ifdef __cplusplus
Evan@653
   265
extern "C" {
Evan@653
   266
#endif
Evan@653
   267
Evan@653
   268
/**************************************************************************/
Evan@653
   269
/** @name Buddy List API                                                  */
Evan@653
   270
/**************************************************************************/
Evan@653
   271
/*@{*/
Evan@653
   272
Evan@653
   273
/**
Evan@653
   274
 * Creates a new buddy list
Evan@653
   275
 *
Evan@653
   276
 * @return The new buddy list.
zacw@2536
   277
 * @deprecated In 3.0.0, this will be handled by purple_blist_init()
Evan@653
   278
 */
Evan@653
   279
PurpleBuddyList *purple_blist_new(void);
Evan@653
   280
Evan@653
   281
/**
Evan@653
   282
 * Sets the main buddy list.
Evan@653
   283
 *
Evan@653
   284
 * @param blist The buddy list you want to use.
zacw@2536
   285
 * @deprecated In 3.0.0, this will be handled by purple_blist_init()
Evan@653
   286
 */
Evan@653
   287
void purple_set_blist(PurpleBuddyList *blist);
Evan@653
   288
Evan@653
   289
/**
Evan@653
   290
 * Returns the main buddy list.
Evan@653
   291
 *
Evan@653
   292
 * @return The main buddy list.
Evan@653
   293
 */
Evan@653
   294
PurpleBuddyList *purple_get_blist(void);
Evan@653
   295
Evan@653
   296
/**
Evan@653
   297
 * Returns the root node of the main buddy list.
Evan@653
   298
 *
Evan@653
   299
 * @return The root node.
Evan@653
   300
 */
Evan@653
   301
PurpleBlistNode *purple_blist_get_root(void);
Evan@653
   302
Evan@653
   303
/**
zacw@2151
   304
 * Returns a list of every buddy in the list.  Use of this function is
zacw@2151
   305
 * discouraged if you do not actually need every buddy in the list.  Use
zacw@2151
   306
 * purple_find_buddies instead.
Evan@1427
   307
 *
zacw@1759
   308
 * @return A list of every buddy in the list. Caller is responsible for
zacw@1759
   309
 *         freeing the list.
Evan@1427
   310
 *
zacw@2151
   311
 * @see purple_find_buddies
Evan@1427
   312
 * @since 2.6.0
Evan@1427
   313
 */
zacw@1759
   314
GSList *purple_blist_get_buddies(void);
Evan@1427
   315
Evan@1427
   316
/**
Evan@1427
   317
 * Returns the UI data for the list.
Evan@1427
   318
 *
Evan@1427
   319
 * @return The UI data for the list.
Evan@1427
   320
 *
Evan@1427
   321
 * @since 2.6.0
Evan@1427
   322
 */
zacw@2069
   323
gpointer purple_blist_get_ui_data(void);
Evan@1427
   324
Evan@1427
   325
/**
Evan@1427
   326
 * Sets the UI data for the list.
Evan@1427
   327
 *
Evan@1427
   328
 * @param ui_data The UI data for the list.
Evan@1427
   329
 *
Evan@1427
   330
 * @since 2.6.0
Evan@1427
   331
 */
zacw@2069
   332
void purple_blist_set_ui_data(gpointer ui_data);
Evan@1427
   333
Evan@1427
   334
/**
Evan@653
   335
 * Returns the next node of a given node. This function is to be used to iterate
Evan@653
   336
 * over the tree returned by purple_get_blist.
Evan@653
   337
 *
Evan@653
   338
 * @param node		A node.
Evan@653
   339
 * @param offline	Whether to include nodes for offline accounts
Evan@653
   340
 * @return	The next node
Evan@653
   341
 * @see purple_blist_node_get_parent
Evan@653
   342
 * @see purple_blist_node_get_first_child
Evan@653
   343
 * @see purple_blist_node_get_sibling_next
Evan@653
   344
 * @see purple_blist_node_get_sibling_prev
Evan@653
   345
 */
Evan@653
   346
PurpleBlistNode *purple_blist_node_next(PurpleBlistNode *node, gboolean offline);
Evan@653
   347
Evan@653
   348
/**
Evan@653
   349
 * Returns the parent node of a given node.
Evan@653
   350
 *
Evan@653
   351
 * @param node A node.
Evan@653
   352
 * @return  The parent node.
Evan@653
   353
 * @since 2.4.0
Evan@653
   354
 * @see purple_blist_node_get_first_child
Evan@653
   355
 * @see purple_blist_node_get_sibling_next
Evan@653
   356
 * @see purple_blist_node_get_sibling_prev
Evan@653
   357
 * @see purple_blist_node_next
Evan@653
   358
 */
Evan@653
   359
PurpleBlistNode *purple_blist_node_get_parent(PurpleBlistNode *node);
Evan@653
   360
Evan@653
   361
/**
Evan@653
   362
 * Returns the the first child node of a given node.
Evan@653
   363
 *
Evan@653
   364
 * @param node A node.
Evan@653
   365
 * @return  The child node.
Evan@653
   366
 * @since 2.4.0
Evan@653
   367
 * @see purple_blist_node_get_parent
Evan@653
   368
 * @see purple_blist_node_get_sibling_next
Evan@653
   369
 * @see purple_blist_node_get_sibling_prev
Evan@653
   370
 * @see purple_blist_node_next
Evan@653
   371
 */
Evan@653
   372
PurpleBlistNode *purple_blist_node_get_first_child(PurpleBlistNode *node);
Evan@653
   373
Evan@653
   374
/**
Evan@653
   375
 * Returns the sibling node of a given node.
Evan@653
   376
 *
Evan@653
   377
 * @param node A node.
Evan@653
   378
 * @return  The sibling node.
Evan@653
   379
 * @since 2.4.0
Evan@653
   380
 * @see purple_blist_node_get_parent
Evan@653
   381
 * @see purple_blist_node_get_first_child
Evan@653
   382
 * @see purple_blist_node_get_sibling_prev
Evan@653
   383
 * @see purple_blist_node_next
Evan@653
   384
 */
Evan@653
   385
PurpleBlistNode *purple_blist_node_get_sibling_next(PurpleBlistNode *node);
Evan@653
   386
Evan@653
   387
/**
Evan@653
   388
 * Returns the previous sibling node of a given node.
Evan@653
   389
 *
Evan@653
   390
 * @param node A node.
Evan@653
   391
 * @return  The sibling node.
Evan@653
   392
 * @since 2.4.0
Evan@653
   393
 * @see purple_blist_node_get_parent
Evan@653
   394
 * @see purple_blist_node_get_first_child
Evan@653
   395
 * @see purple_blist_node_get_sibling_next
Evan@653
   396
 * @see purple_blist_node_next
Evan@653
   397
 */
Evan@653
   398
PurpleBlistNode *purple_blist_node_get_sibling_prev(PurpleBlistNode *node);
Evan@653
   399
Evan@653
   400
/**
Evan@1427
   401
 * Returns the UI data of a given node.
Evan@1427
   402
 *
Evan@1427
   403
 * @param node The node.
Evan@1427
   404
 * @return The UI data.
Evan@1427
   405
 * @since 2.6.0
Evan@1427
   406
 */
zacw@2069
   407
gpointer purple_blist_node_get_ui_data(const PurpleBlistNode *node);
Evan@1427
   408
Evan@1427
   409
/**
Evan@1427
   410
 * Sets the UI data of a given node.
Evan@1427
   411
 *
Evan@1427
   412
 * @param node The node.
Evan@1427
   413
 * @param ui_data The UI data.
Evan@1427
   414
 *
Evan@1427
   415
 * @since 2.6.0
Evan@1427
   416
 */
zacw@2069
   417
void purple_blist_node_set_ui_data(PurpleBlistNode *node, gpointer ui_data);
Evan@1427
   418
Evan@1427
   419
/**
Evan@653
   420
 * Shows the buddy list, creating a new one if necessary.
Evan@653
   421
 */
Evan@653
   422
void purple_blist_show(void);
Evan@653
   423
Evan@653
   424
Evan@653
   425
/**
Evan@653
   426
 * Destroys the buddy list window.
zacw@2536
   427
 *
zacw@2536
   428
 * @deprecated The UI is responsible for cleaning up the
zacw@2536
   429
 *             PurpleBuddyList->ui_data. purple_blist_uninit() will free the
zacw@2536
   430
 *             PurpleBuddyList* itself.
Evan@653
   431
 */
Evan@653
   432
void purple_blist_destroy(void);
Evan@653
   433
Evan@653
   434
/**
Evan@653
   435
 * Hides or unhides the buddy list.
Evan@653
   436
 *
Evan@653
   437
 * @param show   Whether or not to show the buddy list
Evan@653
   438
 */
Evan@653
   439
void purple_blist_set_visible(gboolean show);
Evan@653
   440
Evan@653
   441
/**
Evan@653
   442
 * Updates a buddy's status.
Evan@653
   443
 *
zacw@2069
   444
 * This should only be called from within Purple.
zacw@2069
   445
 *
Evan@653
   446
 * @param buddy      The buddy whose status has changed.
Evan@653
   447
 * @param old_status The status from which we are changing.
Evan@653
   448
 */
Evan@653
   449
void purple_blist_update_buddy_status(PurpleBuddy *buddy, PurpleStatus *old_status);
Evan@653
   450
Evan@653
   451
/**
Evan@653
   452
 * Updates a node's custom icon.
Evan@653
   453
 *
Evan@653
   454
 * @param node  The PurpleBlistNode whose custom icon has changed.
Evan@1427
   455
 *
Evan@653
   456
 * @since 2.5.0
Evan@653
   457
 */
Evan@653
   458
void purple_blist_update_node_icon(PurpleBlistNode *node);
Evan@653
   459
Evan@653
   460
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
Evan@653
   461
/**
Evan@653
   462
 * Updates a buddy's icon.
Evan@653
   463
 *
Evan@653
   464
 * @param buddy  The buddy whose buddy icon has changed
Evan@653
   465
 * @deprecated Use purple_blist_update_node_icon() instead.
Evan@653
   466
 */
Evan@653
   467
void purple_blist_update_buddy_icon(PurpleBuddy *buddy);
Evan@653
   468
#endif
Evan@653
   469
Evan@653
   470
/**
Evan@653
   471
 * Renames a buddy in the buddy list.
Evan@653
   472
 *
Evan@653
   473
 * @param buddy  The buddy whose name will be changed.
Evan@653
   474
 * @param name   The new name of the buddy.
Evan@653
   475
 */
Evan@653
   476
void purple_blist_rename_buddy(PurpleBuddy *buddy, const char *name);
Evan@653
   477
Evan@653
   478
/**
Evan@653
   479
 * Aliases a contact in the buddy list.
Evan@653
   480
 *
Evan@653
   481
 * @param contact The contact whose alias will be changed.
Evan@653
   482
 * @param alias   The contact's alias.
Evan@653
   483
 */
Evan@653
   484
void purple_blist_alias_contact(PurpleContact *contact, const char *alias);
Evan@653
   485
Evan@653
   486
/**
Evan@653
   487
 * Aliases a buddy in the buddy list.
Evan@653
   488
 *
Evan@653
   489
 * @param buddy  The buddy whose alias will be changed.
Evan@653
   490
 * @param alias  The buddy's alias.
Evan@653
   491
 */
Evan@653
   492
void purple_blist_alias_buddy(PurpleBuddy *buddy, const char *alias);
Evan@653
   493
Evan@653
   494
/**
Evan@653
   495
 * Sets the server-sent alias of a buddy in the buddy list.
Evan@653
   496
 * PRPLs should call serv_got_alias() instead of this.
Evan@653
   497
 *
Evan@653
   498
 * @param buddy  The buddy whose alias will be changed.
Evan@653
   499
 * @param alias  The buddy's "official" alias.
Evan@653
   500
 */
Evan@653
   501
void purple_blist_server_alias_buddy(PurpleBuddy *buddy, const char *alias);
Evan@653
   502
Evan@653
   503
/**
Evan@653
   504
 * Aliases a chat in the buddy list.
Evan@653
   505
 *
Evan@653
   506
 * @param chat  The chat whose alias will be changed.
Evan@653
   507
 * @param alias The chat's new alias.
Evan@653
   508
 */
Evan@653
   509
void purple_blist_alias_chat(PurpleChat *chat, const char *alias);
Evan@653
   510
Evan@653
   511
/**
Evan@653
   512
 * Renames a group
Evan@653
   513
 *
Evan@653
   514
 * @param group  The group to rename
Evan@653
   515
 * @param name   The new name
Evan@653
   516
 */
Evan@653
   517
void purple_blist_rename_group(PurpleGroup *group, const char *name);
Evan@653
   518
Evan@653
   519
/**
Evan@653
   520
 * Creates a new chat for the buddy list
Evan@653
   521
 *
Evan@653
   522
 * @param account    The account this chat will get added to
Evan@653
   523
 * @param alias      The alias of the new chat
Evan@653
   524
 * @param components The info the prpl needs to join the chat.  The
Evan@653
   525
 *                   hash function should be g_str_hash() and the
Evan@653
   526
 *                   equal function should be g_str_equal().
Evan@653
   527
 * @return           A newly allocated chat
Evan@653
   528
 */
Evan@653
   529
PurpleChat *purple_chat_new(PurpleAccount *account, const char *alias, GHashTable *components);
Evan@653
   530
Evan@653
   531
/**
zacw@1759
   532
 * Destroys a chat
zacw@1759
   533
 *
zacw@1759
   534
 * @param chat       The chat to destroy
zacw@1759
   535
 */
zacw@1759
   536
void purple_chat_destroy(PurpleChat *chat);
zacw@1759
   537
zacw@1759
   538
/**
Evan@653
   539
 * Adds a new chat to the buddy list.
Evan@653
   540
 *
Evan@653
   541
 * The chat will be inserted right after node or appended to the end
Evan@653
   542
 * of group if node is NULL.  If both are NULL, the buddy will be added to
Evan@653
   543
 * the "Chats" group.
Evan@653
   544
 *
Evan@653
   545
 * @param chat  The new chat who gets added
Evan@653
   546
 * @param group  The group to add the new chat to.
Evan@653
   547
 * @param node   The insertion point
Evan@653
   548
 */
Evan@653
   549
void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node);
Evan@653
   550
Evan@653
   551
/**
zacw@2069
   552
 * Creates a new buddy.
zacw@2069
   553
 *
zacw@2069
   554
 * This function only creates the PurpleBuddy. Use purple_blist_add_buddy
zacw@2069
   555
 * to add the buddy to the list and purple_account_add_buddy to sync up
zacw@2069
   556
 * with the server.
Evan@653
   557
 *
Evan@653
   558
 * @param account    The account this buddy will get added to
Evan@1427
   559
 * @param name       The name of the new buddy
Evan@653
   560
 * @param alias      The alias of the new buddy (or NULL if unaliased)
Evan@653
   561
 * @return           A newly allocated buddy
zacw@2069
   562
 *
zacw@2069
   563
 * @see purple_account_add_buddy
zacw@2069
   564
 * @see purple_blist_add_buddy
Evan@653
   565
 */
Evan@1427
   566
PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias);
Evan@653
   567
Evan@653
   568
/**
zacw@1759
   569
 * Destroys a buddy
zacw@1759
   570
 *
zacw@1759
   571
 * @param buddy     The buddy to destroy
zacw@1759
   572
 */
zacw@1759
   573
void purple_buddy_destroy(PurpleBuddy *buddy);
zacw@1759
   574
zacw@1759
   575
/**
Evan@653
   576
 * Sets a buddy's icon.
Evan@653
   577
 *
Evan@653
   578
 * This should only be called from within Purple. You probably want to
Evan@653
   579
 * call purple_buddy_icon_set_data().
Evan@653
   580
 *
Evan@653
   581
 * @param buddy The buddy.
Evan@653
   582
 * @param icon  The buddy icon.
Evan@653
   583
 *
Evan@653
   584
 * @see purple_buddy_icon_set_data()
Evan@653
   585
 */
Evan@653
   586
void purple_buddy_set_icon(PurpleBuddy *buddy, PurpleBuddyIcon *icon);
Evan@653
   587
Evan@653
   588
/**
Evan@653
   589
 * Returns a buddy's account.
Evan@653
   590
 *
Evan@653
   591
 * @param buddy The buddy.
Evan@653
   592
 *
Evan@653
   593
 * @return The account
Evan@653
   594
 */
Evan@653
   595
PurpleAccount *purple_buddy_get_account(const PurpleBuddy *buddy);
Evan@653
   596
Evan@653
   597
/**
Evan@653
   598
 * Returns a buddy's name
Evan@653
   599
 *
Evan@653
   600
 * @param buddy The buddy.
Evan@653
   601
 *
Evan@653
   602
 * @return The name.
Evan@653
   603
 */
Evan@653
   604
const char *purple_buddy_get_name(const PurpleBuddy *buddy);
Evan@653
   605
Evan@653
   606
/**
Evan@653
   607
 * Returns a buddy's icon.
Evan@653
   608
 *
Evan@653
   609
 * @param buddy The buddy.
Evan@653
   610
 *
Evan@653
   611
 * @return The buddy icon.
Evan@653
   612
 */
Evan@653
   613
PurpleBuddyIcon *purple_buddy_get_icon(const PurpleBuddy *buddy);
Evan@653
   614
Evan@653
   615
/**
Evan@1427
   616
 * Returns a buddy's protocol-specific data.
Evan@1427
   617
 *
Evan@1427
   618
 * This should only be called from the associated prpl.
Evan@1427
   619
 *
Evan@1427
   620
 * @param buddy The buddy.
Evan@1427
   621
 * @return      The protocol data.
Evan@1427
   622
 *
Evan@1427
   623
 * @see purple_buddy_set_protocol_data()
Evan@1427
   624
 * @since 2.6.0
Evan@1427
   625
 */
Evan@1427
   626
gpointer purple_buddy_get_protocol_data(const PurpleBuddy *buddy);
Evan@1427
   627
Evan@1427
   628
/**
Evan@1427
   629
 * Sets a buddy's protocol-specific data.
Evan@1427
   630
 *
Evan@1427
   631
 * This should only be called from the associated prpl.
Evan@1427
   632
 *
Evan@1427
   633
 * @param buddy The buddy.
Evan@1427
   634
 * @param data  The data.
Evan@1427
   635
 *
Evan@1427
   636
 * @see purple_buddy_get_protocol_data()
Evan@1427
   637
 * @since 2.6.0
Evan@1427
   638
 */
Evan@1427
   639
void purple_buddy_set_protocol_data(PurpleBuddy *buddy, gpointer data);
Evan@1427
   640
Evan@1427
   641
/**
Evan@653
   642
 * Returns a buddy's contact.
Evan@653
   643
 *
Evan@653
   644
 * @param buddy The buddy.
Evan@653
   645
 *
Evan@653
   646
 * @return The buddy's contact.
Evan@653
   647
 */
Evan@653
   648
PurpleContact *purple_buddy_get_contact(PurpleBuddy *buddy);
Evan@653
   649
Evan@653
   650
/**
Evan@653
   651
 * Returns a buddy's presence.
Evan@653
   652
 *
Evan@653
   653
 * @param buddy The buddy.
Evan@653
   654
 *
Evan@653
   655
 * @return The buddy's presence.
Evan@653
   656
 */
Evan@653
   657
PurplePresence *purple_buddy_get_presence(const PurpleBuddy *buddy);
Evan@653
   658
Evan@653
   659
/**
Evan@653
   660
 * Adds a new buddy to the buddy list.
Evan@653
   661
 *
Evan@653
   662
 * The buddy will be inserted right after node or prepended to the
Evan@653
   663
 * group if node is NULL.  If both are NULL, the buddy will be added to
Evan@653
   664
 * the "Buddies" group.
Evan@653
   665
 *
Evan@653
   666
 * @param buddy   The new buddy who gets added
Evan@653
   667
 * @param contact The optional contact to place the buddy in.
Evan@653
   668
 * @param group   The group to add the new buddy to.
Evan@653
   669
 * @param node    The insertion point.  Pass in NULL to add the node as
Evan@1427
   670
 *                the first child in the given group.
Evan@653
   671
 */
Evan@653
   672
void purple_blist_add_buddy(PurpleBuddy *buddy, PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node);
Evan@653
   673
Evan@653
   674
/**
Evan@653
   675
 * Creates a new group
Evan@653
   676
 *
Evan@653
   677
 * You can't have more than one group with the same name.  Sorry.  If you pass
zacw@2069
   678
 * this the name of a group that already exists, it will return that group.
Evan@653
   679
 *
Evan@653
   680
 * @param name   The name of the new group
Evan@653
   681
 * @return       A new group struct
Evan@653
   682
*/
Evan@653
   683
PurpleGroup *purple_group_new(const char *name);
Evan@653
   684
Evan@653
   685
/**
zacw@1759
   686
 * Destroys a group
zacw@1759
   687
 *
zacw@1759
   688
 * @param group  The group to destroy
zacw@1759
   689
*/
zacw@1759
   690
void purple_group_destroy(PurpleGroup *group);
zacw@1759
   691
zacw@1759
   692
/**
Evan@653
   693
 * Adds a new group to the buddy list.
Evan@653
   694
 *
Evan@653
   695
 * The new group will be inserted after insert or prepended to the list if
Evan@653
   696
 * node is NULL.
Evan@653
   697
 *
Evan@653
   698
 * @param group  The group
Evan@653
   699
 * @param node   The insertion point
Evan@653
   700
 */
Evan@653
   701
void purple_blist_add_group(PurpleGroup *group, PurpleBlistNode *node);
Evan@653
   702
Evan@653
   703
/**
Evan@653
   704
 * Creates a new contact
Evan@653
   705
 *
Evan@653
   706
 * @return       A new contact struct
Evan@653
   707
 */
Evan@653
   708
PurpleContact *purple_contact_new(void);
Evan@653
   709
Evan@653
   710
/**
zacw@1759
   711
 * Destroys a contact
zacw@1759
   712
 *
zacw@1759
   713
 * @param contact  The contact to destroy
zacw@1759
   714
 */
zacw@1759
   715
void purple_contact_destroy(PurpleContact *contact);
zacw@1759
   716
zacw@1759
   717
/**
Evan@653
   718
 * Adds a new contact to the buddy list.
Evan@653
   719
 *
Evan@653
   720
 * The new contact will be inserted after insert or prepended to the list if
Evan@653
   721
 * node is NULL.
Evan@653
   722
 *
Evan@653
   723
 * @param contact The contact
Evan@653
   724
 * @param group   The group to add the contact to
Evan@653
   725
 * @param node    The insertion point
Evan@653
   726
 */
Evan@653
   727
void purple_blist_add_contact(PurpleContact *contact, PurpleGroup *group, PurpleBlistNode *node);
Evan@653
   728
Evan@653
   729
/**
Evan@653
   730
 * Merges two contacts
Evan@653
   731
 *
Evan@653
   732
 * All of the buddies from source will be moved to target
Evan@653
   733
 *
Evan@653
   734
 * @param source  The contact to merge
Evan@653
   735
 * @param node    The place to merge to (a buddy or contact)
Evan@653
   736
 */
Evan@653
   737
void purple_blist_merge_contact(PurpleContact *source, PurpleBlistNode *node);
Evan@653
   738
Evan@653
   739
/**
Evan@653
   740
 * Returns the highest priority buddy for a given contact.
Evan@653
   741
 *
Evan@653
   742
 * @param contact  The contact
Evan@653
   743
 * @return The highest priority buddy
Evan@653
   744
 */
Evan@653
   745
PurpleBuddy *purple_contact_get_priority_buddy(PurpleContact *contact);
Evan@653
   746
Evan@653
   747
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
Evan@653
   748
/**
Evan@653
   749
 * Sets the alias for a contact.
Evan@653
   750
 *
Evan@653
   751
 * @param contact  The contact
Evan@653
   752
 * @param alias    The alias to set, or NULL to unset
Evan@653
   753
 *
Evan@653
   754
 * @deprecated Use purple_blist_alias_contact() instead.
Evan@653
   755
 */
Evan@653
   756
void purple_contact_set_alias(PurpleContact *contact, const char *alias);
Evan@653
   757
#endif
Evan@653
   758
Evan@653
   759
/**
Evan@653
   760
 * Gets the alias for a contact.
Evan@653
   761
 *
Evan@653
   762
 * @param contact  The contact
Evan@653
   763
 * @return  The alias, or NULL if it is not set.
Evan@653
   764
 */
Evan@653
   765
const char *purple_contact_get_alias(PurpleContact *contact);
Evan@653
   766
Evan@653
   767
/**
Evan@653
   768
 * Determines whether an account owns any buddies in a given contact
Evan@653
   769
 *
Evan@653
   770
 * @param contact  The contact to search through.
Evan@653
   771
 * @param account  The account.
Evan@653
   772
 *
Evan@653
   773
 * @return TRUE if there are any buddies from account in the contact, or FALSE otherwise.
Evan@653
   774
 */
Evan@653
   775
gboolean purple_contact_on_account(PurpleContact *contact, PurpleAccount *account);
Evan@653
   776
Evan@653
   777
/**
Evan@653
   778
 * Invalidates the priority buddy so that the next call to
Evan@653
   779
 * purple_contact_get_priority_buddy recomputes it.
Evan@653
   780
 *
Evan@653
   781
 * @param contact  The contact
Evan@653
   782
 */
Evan@653
   783
void purple_contact_invalidate_priority_buddy(PurpleContact *contact);
Evan@653
   784
Evan@653
   785
/**
Evan@653
   786
 * Removes a buddy from the buddy list and frees the memory allocated to it.
zacw@2069
   787
 * This doesn't actually try to remove the buddy from the server list.
Evan@653
   788
 *
Evan@653
   789
 * @param buddy   The buddy to be removed
zacw@2069
   790
 *
zacw@2069
   791
 * @see purple_account_remove_buddy
Evan@653
   792
 */
Evan@653
   793
void purple_blist_remove_buddy(PurpleBuddy *buddy);
Evan@653
   794
Evan@653
   795
/**
Evan@653
   796
 * Removes a contact, and any buddies it contains, and frees the memory
zacw@2069
   797
 * allocated to it. This calls purple_blist_remove_buddy and therefore
zacw@2069
   798
 * doesn't remove the buddies from the server list.
Evan@653
   799
 *
Evan@653
   800
 * @param contact The contact to be removed
zacw@2069
   801
 *
zacw@2069
   802
 * @see purple_blist_remove_buddy
Evan@653
   803
 */
Evan@653
   804
void purple_blist_remove_contact(PurpleContact *contact);
Evan@653
   805
Evan@653
   806
/**
Evan@653
   807
 * Removes a chat from the buddy list and frees the memory allocated to it.
Evan@653
   808
 *
Evan@653
   809
 * @param chat   The chat to be removed
Evan@653
   810
 */
Evan@653
   811
void purple_blist_remove_chat(PurpleChat *chat);
Evan@653
   812
Evan@653
   813
/**
Evan@653
   814
 * Removes a group from the buddy list and frees the memory allocated to it and to
Evan@653
   815
 * its children
Evan@653
   816
 *
Evan@653
   817
 * @param group   The group to be removed
Evan@653
   818
 */
Evan@653
   819
void purple_blist_remove_group(PurpleGroup *group);
Evan@653
   820
Evan@653
   821
/**
Evan@653
   822
 * Returns the alias of a buddy.
Evan@653
   823
 *
Evan@653
   824
 * @param buddy   The buddy whose name will be returned.
Evan@653
   825
 * @return        The alias (if set), server alias (if set),
Evan@653
   826
 *                or NULL.
Evan@653
   827
 */
Evan@653
   828
const char *purple_buddy_get_alias_only(PurpleBuddy *buddy);
Evan@653
   829
Evan@653
   830
/**
Evan@653
   831
 * Gets the server alias for a buddy.
Evan@653
   832
 *
Evan@653
   833
 * @param buddy  The buddy whose name will be returned
Evan@653
   834
 * @return  The server alias, or NULL if it is not set.
Evan@653
   835
 */
Evan@653
   836
const char *purple_buddy_get_server_alias(PurpleBuddy *buddy);
Evan@653
   837
Evan@653
   838
/**
Evan@653
   839
 * Returns the correct name to display for a buddy, taking the contact alias
Evan@653
   840
 * into account. In order of precedence: the buddy's alias; the buddy's
Evan@653
   841
 * contact alias; the buddy's server alias; the buddy's user name.
Evan@653
   842
 *
Evan@653
   843
 * @param buddy  The buddy whose name will be returned
Evan@653
   844
 * @return       The appropriate name or alias, or NULL.
Evan@653
   845
 *
Evan@653
   846
 */
Evan@653
   847
const char *purple_buddy_get_contact_alias(PurpleBuddy *buddy);
Evan@653
   848
Evan@1427
   849
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_BLIST_C_)
Evan@653
   850
/**
Evan@653
   851
 * Returns the correct alias for this user, ignoring server aliases.  Used
Evan@653
   852
 * when a user-recognizable name is required.  In order: buddy's alias; buddy's
Evan@653
   853
 * contact alias; buddy's user name.
Evan@1427
   854
 *
Evan@653
   855
 * @param buddy  The buddy whose alias will be returned.
Evan@653
   856
 * @return       The appropriate name or alias.
Evan@1427
   857
 * @deprecated   Try purple_buddy_get_alias(), if server aliases are okay.
Evan@653
   858
 */
Evan@653
   859
const char *purple_buddy_get_local_alias(PurpleBuddy *buddy);
Evan@1427
   860
#endif
Evan@653
   861
Evan@653
   862
/**
Evan@653
   863
 * Returns the correct name to display for a buddy. In order of precedence:
Evan@653
   864
 * the buddy's alias; the buddy's server alias; the buddy's contact alias;
Evan@653
   865
 * the buddy's user name.
Evan@653
   866
 *
Evan@653
   867
 * @param buddy   The buddy whose name will be returned.
Evan@653
   868
 * @return        The appropriate name or alias, or NULL
Evan@653
   869
 */
Evan@653
   870
const char *purple_buddy_get_alias(PurpleBuddy *buddy);
Evan@653
   871
Evan@653
   872
/**
Evan@1427
   873
 * Returns the local alias for the buddy, or @c NULL if none exists.
Evan@1427
   874
 *
Evan@1427
   875
 * @param buddy  The buddy
Evan@1427
   876
 * @return       The local alias for the buddy
Evan@1427
   877
 *
Evan@1427
   878
 * @since 2.6.0
Evan@1427
   879
 */
Evan@1427
   880
const char *purple_buddy_get_local_buddy_alias(PurpleBuddy *buddy);
Evan@1427
   881
Evan@1427
   882
/**
Evan@653
   883
 * Returns the correct name to display for a blist chat.
Evan@653
   884
 *
Evan@653
   885
 * @param chat   The chat whose name will be returned.
Evan@653
   886
 * @return       The alias (if set), or first component value.
Evan@653
   887
 */
Evan@653
   888
const char *purple_chat_get_name(PurpleChat *chat);
Evan@653
   889
Evan@653
   890
/**
Evan@1427
   891
 * Finds the buddy struct given a name and an account
Evan@653
   892
 *
Evan@653
   893
 * @param account The account this buddy belongs to
Evan@1427
   894
 * @param name    The buddy's name
Evan@653
   895
 * @return        The buddy or NULL if the buddy does not exist
Evan@653
   896
 */
Evan@653
   897
PurpleBuddy *purple_find_buddy(PurpleAccount *account, const char *name);
Evan@653
   898
Evan@653
   899
/**
Evan@1427
   900
 * Finds the buddy struct given a name, an account, and a group
Evan@653
   901
 *
Evan@653
   902
 * @param account The account this buddy belongs to
Evan@1427
   903
 * @param name    The buddy's name
Evan@653
   904
 * @param group   The group to look in
Evan@653
   905
 * @return        The buddy or NULL if the buddy does not exist in the group
Evan@653
   906
 */
Evan@653
   907
PurpleBuddy *purple_find_buddy_in_group(PurpleAccount *account, const char *name,
Evan@653
   908
		PurpleGroup *group);
Evan@653
   909
Evan@653
   910
/**
Evan@1427
   911
 * Finds all PurpleBuddy structs given a name and an account
Evan@653
   912
 *
Evan@653
   913
 * @param account The account this buddy belongs to
zacw@2069
   914
 * @param name    The buddy's name (or NULL to return all buddies for the account)
Evan@653
   915
 *
Evan@653
   916
 * @return        A GSList of buddies (which must be freed), or NULL if the buddy doesn't exist
Evan@653
   917
 */
Evan@653
   918
GSList *purple_find_buddies(PurpleAccount *account, const char *name);
Evan@653
   919
Evan@653
   920
Evan@653
   921
/**
Evan@653
   922
 * Finds a group by name
Evan@653
   923
 *
Evan@653
   924
 * @param name    The group's name
Evan@653
   925
 * @return        The group or NULL if the group does not exist
Evan@653
   926
 */
Evan@653
   927
PurpleGroup *purple_find_group(const char *name);
Evan@653
   928
Evan@653
   929
/**
Evan@653
   930
 * Finds a chat by name.
Evan@653
   931
 *
Evan@653
   932
 * @param account The chat's account.
Evan@653
   933
 * @param name    The chat's name.
Evan@653
   934
 *
Evan@653
   935
 * @return The chat, or @c NULL if the chat does not exist.
Evan@653
   936
 */
Evan@653
   937
PurpleChat *purple_blist_find_chat(PurpleAccount *account, const char *name);
Evan@653
   938
Evan@653
   939
/**
Evan@653
   940
 * Returns the group of which the chat is a member.
Evan@653
   941
 *
Evan@653
   942
 * @param chat The chat.
Evan@653
   943
 *
Evan@653
   944
 * @return The parent group, or @c NULL if the chat is not in a group.
Evan@653
   945
 */
Evan@653
   946
PurpleGroup *purple_chat_get_group(PurpleChat *chat);
Evan@653
   947
Evan@653
   948
/**
Evan@653
   949
 * Returns the account the chat belongs to.
Evan@653
   950
 *
Evan@653
   951
 * @param chat  The chat.
Evan@653
   952
 *
Evan@653
   953
 * @return  The account the chat belongs to.
Evan@1427
   954
 *
Evan@653
   955
 * @since 2.4.0
Evan@653
   956
 */
Evan@653
   957
PurpleAccount *purple_chat_get_account(PurpleChat *chat);
Evan@653
   958
Evan@653
   959
/**
Evan@653
   960
 * Get a hashtable containing information about a chat.
Evan@653
   961
 *
Evan@653
   962
 * @param chat  The chat.
Evan@653
   963
 *
Evan@653
   964
 * @constreturn  The hashtable.
Evan@1427
   965
 *
Evan@653
   966
 * @since 2.4.0
Evan@653
   967
 */
Evan@653
   968
GHashTable *purple_chat_get_components(PurpleChat *chat);
Evan@653
   969
Evan@653
   970
/**
Evan@653
   971
 * Returns the group of which the buddy is a member.
Evan@653
   972
 *
Evan@653
   973
 * @param buddy   The buddy
Evan@653
   974
 * @return        The group or NULL if the buddy is not in a group
Evan@653
   975
 */
Evan@653
   976
PurpleGroup *purple_buddy_get_group(PurpleBuddy *buddy);
Evan@653
   977
Evan@653
   978
Evan@653
   979
/**
Evan@653
   980
 * Returns a list of accounts that have buddies in this group
Evan@653
   981
 *
Evan@653
   982
 * @param g The group
Evan@653
   983
 *
Evan@653
   984
 * @return A GSList of accounts (which must be freed), or NULL if the group
Evan@653
   985
 *         has no accounts.
Evan@653
   986
 */
Evan@653
   987
GSList *purple_group_get_accounts(PurpleGroup *g);
Evan@653
   988
Evan@653
   989
/**
Evan@653
   990
 * Determines whether an account owns any buddies in a given group
Evan@653
   991
 *
Evan@653
   992
 * @param g       The group to search through.
Evan@653
   993
 * @param account The account.
Evan@653
   994
 *
Evan@653
   995
 * @return TRUE if there are any buddies in the group, or FALSE otherwise.
Evan@653
   996
 */
Evan@653
   997
gboolean purple_group_on_account(PurpleGroup *g, PurpleAccount *account);
Evan@653
   998
Evan@653
   999
/**
Evan@653
  1000
 * Returns the name of a group.
Evan@653
  1001
 *
Evan@653
  1002
 * @param group The group.
Evan@653
  1003
 *
Evan@653
  1004
 * @return The name of the group.
Evan@653
  1005
 */
Evan@653
  1006
const char *purple_group_get_name(PurpleGroup *group);
Evan@653
  1007
Evan@653
  1008
/**
zacw@2069
  1009
 * Called when an account connects.  Tells the UI to update all the
Evan@653
  1010
 * buddies.
Evan@653
  1011
 *
Evan@653
  1012
 * @param account   The account
Evan@653
  1013
 */
Evan@653
  1014
void purple_blist_add_account(PurpleAccount *account);
Evan@653
  1015
Evan@653
  1016
Evan@653
  1017
/**
zacw@2069
  1018
 * Called when an account disconnects.  Sets the presence of all the buddies to 0
Evan@653
  1019
 * and tells the UI to update them.
Evan@653
  1020
 *
Evan@653
  1021
 * @param account   The account
Evan@653
  1022
 */
Evan@653
  1023
void purple_blist_remove_account(PurpleAccount *account);
Evan@653
  1024
Evan@653
  1025
Evan@653
  1026
/**
Evan@653
  1027
 * Determines the total size of a group
Evan@653
  1028
 *
Evan@653
  1029
 * @param group  The group
Evan@653
  1030
 * @param offline Count buddies in offline accounts
Evan@653
  1031
 * @return The number of buddies in the group
Evan@653
  1032
 */
Evan@653
  1033
int purple_blist_get_group_size(PurpleGroup *group, gboolean offline);
Evan@653
  1034
Evan@653
  1035
/**
Evan@653
  1036
 * Determines the number of online buddies in a group
Evan@653
  1037
 *
Evan@653
  1038
 * @param group The group
Evan@653
  1039
 * @return The number of online buddies in the group, or 0 if the group is NULL
Evan@653
  1040
 */
Evan@653
  1041
int purple_blist_get_group_online_count(PurpleGroup *group);
Evan@653
  1042
Evan@653
  1043
/*@}*/
Evan@653
  1044
Evan@653
  1045
/****************************************************************************************/
Evan@653
  1046
/** @name Buddy list file management API                                                */
Evan@653
  1047
/****************************************************************************************/
Evan@653
  1048
Evan@653
  1049
/**
Evan@653
  1050
 * Loads the buddy list from ~/.purple/blist.xml.
Evan@653
  1051
 */
Evan@653
  1052
void purple_blist_load(void);
Evan@653
  1053
Evan@653
  1054
/**
Evan@653
  1055
 * Schedule a save of the blist.xml file.  This is used by the privacy
Evan@653
  1056
 * API whenever the privacy settings are changed.  If you make a change
Evan@653
  1057
 * to blist.xml using one of the functions in the buddy list API, then
Evan@653
  1058
 * the buddy list is saved automatically, so you should not need to
Evan@653
  1059
 * call this.
Evan@653
  1060
 */
Evan@653
  1061
void purple_blist_schedule_save(void);
Evan@653
  1062
Evan@653
  1063
/**
Evan@653
  1064
 * Requests from the user information needed to add a buddy to the
Evan@653
  1065
 * buddy list.
Evan@653
  1066
 *
Evan@653
  1067
 * @param account  The account the buddy is added to.
Evan@653
  1068
 * @param username The username of the buddy.
Evan@653
  1069
 * @param group    The name of the group to place the buddy in.
Evan@653
  1070
 * @param alias    The optional alias for the buddy.
Evan@653
  1071
 */
Evan@653
  1072
void purple_blist_request_add_buddy(PurpleAccount *account, const char *username,
Evan@653
  1073
								  const char *group, const char *alias);
Evan@653
  1074
Evan@653
  1075
/**
Evan@653
  1076
 * Requests from the user information needed to add a chat to the
Evan@653
  1077
 * buddy list.
Evan@653
  1078
 *
Evan@653
  1079
 * @param account The account the buddy is added to.
Evan@653
  1080
 * @param group   The optional group to add the chat to.
Evan@653
  1081
 * @param alias   The optional alias for the chat.
Evan@653
  1082
 * @param name    The required chat name.
Evan@653
  1083
 */
Evan@653
  1084
void purple_blist_request_add_chat(PurpleAccount *account, PurpleGroup *group,
Evan@653
  1085
								 const char *alias, const char *name);
Evan@653
  1086
Evan@653
  1087
/**
Evan@653
  1088
 * Requests from the user information needed to add a group to the
Evan@653
  1089
 * buddy list.
Evan@653
  1090
 */
Evan@653
  1091
void purple_blist_request_add_group(void);
Evan@653
  1092
Evan@653
  1093
/**
Evan@653
  1094
 * Associates a boolean with a node in the buddy list
Evan@653
  1095
 *
Evan@653
  1096
 * @param node  The node to associate the data with
Evan@653
  1097
 * @param key   The identifier for the data
Evan@653
  1098
 * @param value The value to set
Evan@653
  1099
 */
Evan@653
  1100
void purple_blist_node_set_bool(PurpleBlistNode *node, const char *key, gboolean value);
Evan@653
  1101
Evan@653
  1102
/**
Evan@653
  1103
 * Retrieves a named boolean setting from a node in the buddy list
Evan@653
  1104
 *
Evan@653
  1105
 * @param node  The node to retrieve the data from
Evan@653
  1106
 * @param key   The identifier of the data
Evan@653
  1107
 *
Evan@653
  1108
 * @return The value, or FALSE if there is no setting
Evan@653
  1109
 */
Evan@653
  1110
gboolean purple_blist_node_get_bool(PurpleBlistNode *node, const char *key);
Evan@653
  1111
Evan@653
  1112
/**
Evan@653
  1113
 * Associates an integer with a node in the buddy list
Evan@653
  1114
 *
Evan@653
  1115
 * @param node  The node to associate the data with
Evan@653
  1116
 * @param key   The identifier for the data
Evan@653
  1117
 * @param value The value to set
Evan@653
  1118
 */
Evan@653
  1119
void purple_blist_node_set_int(PurpleBlistNode *node, const char *key, int value);
Evan@653
  1120
Evan@653
  1121
/**
Evan@653
  1122
 * Retrieves a named integer setting from a node in the buddy list
Evan@653
  1123
 *
Evan@653
  1124
 * @param node  The node to retrieve the data from
Evan@653
  1125
 * @param key   The identifier of the data
Evan@653
  1126
 *
Evan@653
  1127
 * @return The value, or 0 if there is no setting
Evan@653
  1128
 */
Evan@653
  1129
int purple_blist_node_get_int(PurpleBlistNode *node, const char *key);
Evan@653
  1130
Evan@653
  1131
/**
Evan@653
  1132
 * Associates a string with a node in the buddy list
Evan@653
  1133
 *
Evan@653
  1134
 * @param node  The node to associate the data with
Evan@653
  1135
 * @param key   The identifier for the data
Evan@653
  1136
 * @param value The value to set
Evan@653
  1137
 */
Evan@653
  1138
void purple_blist_node_set_string(PurpleBlistNode *node, const char *key,
Evan@653
  1139
		const char *value);
Evan@653
  1140
Evan@653
  1141
/**
Evan@653
  1142
 * Retrieves a named string setting from a node in the buddy list
Evan@653
  1143
 *
Evan@653
  1144
 * @param node  The node to retrieve the data from
Evan@653
  1145
 * @param key   The identifier of the data
Evan@653
  1146
 *
Evan@653
  1147
 * @return The value, or NULL if there is no setting
Evan@653
  1148
 */
Evan@653
  1149
const char *purple_blist_node_get_string(PurpleBlistNode *node, const char *key);
Evan@653
  1150
Evan@653
  1151
/**
Evan@653
  1152
 * Removes a named setting from a blist node
Evan@653
  1153
 *
Evan@653
  1154
 * @param node  The node from which to remove the setting
Evan@653
  1155
 * @param key   The name of the setting
Evan@653
  1156
 */
Evan@653
  1157
void purple_blist_node_remove_setting(PurpleBlistNode *node, const char *key);
Evan@653
  1158
Evan@653
  1159
/**
Evan@653
  1160
 * Set the flags for the given node.  Setting a node's flags will overwrite
Evan@653
  1161
 * the old flags, so if you want to save them, you must first call
Evan@653
  1162
 * purple_blist_node_get_flags and modify that appropriately.
Evan@653
  1163
 *
Evan@653
  1164
 * @param node  The node on which to set the flags.
Evan@653
  1165
 * @param flags The flags to set.  This is a bitmask.
Evan@653
  1166
 */
Evan@653
  1167
void purple_blist_node_set_flags(PurpleBlistNode *node, PurpleBlistNodeFlags flags);
Evan@653
  1168
Evan@653
  1169
/**
Evan@653
  1170
 * Get the current flags on a given node.
Evan@653
  1171
 *
Evan@653
  1172
 * @param node The node from which to get the flags.
Evan@653
  1173
 *
Evan@653
  1174
 * @return The flags on the node.  This is a bitmask.
Evan@653
  1175
 */
Evan@653
  1176
PurpleBlistNodeFlags purple_blist_node_get_flags(PurpleBlistNode *node);
Evan@653
  1177
Evan@653
  1178
/**
Evan@653
  1179
 * Get the type of a given node.
Evan@653
  1180
 *
Evan@653
  1181
 * @param node The node.
Evan@653
  1182
 *
Evan@653
  1183
 * @return The type of the node.
Evan@1427
  1184
 *
Evan@653
  1185
 * @since 2.1.0
Evan@653
  1186
 */
Evan@653
  1187
PurpleBlistNodeType purple_blist_node_get_type(PurpleBlistNode *node);
Evan@653
  1188
Evan@653
  1189
/*@}*/
Evan@653
  1190
Evan@653
  1191
/**
Evan@653
  1192
 * Retrieves the extended menu items for a buddy list node.
Evan@653
  1193
 * @param n The blist node for which to obtain the extended menu items.
Evan@653
  1194
 * @return  A list of PurpleMenuAction items, as harvested by the
Evan@653
  1195
 *          blist-node-extended-menu signal.
Evan@653
  1196
 */
Evan@653
  1197
GList *purple_blist_node_get_extended_menu(PurpleBlistNode *n);
Evan@653
  1198
Evan@653
  1199
/**************************************************************************/
Evan@653
  1200
/** @name UI Registration Functions                                       */
Evan@653
  1201
/**************************************************************************/
Evan@653
  1202
/*@{*/
Evan@653
  1203
Evan@653
  1204
/**
Evan@653
  1205
 * Sets the UI operations structure to be used for the buddy list.
Evan@653
  1206
 *
Evan@653
  1207
 * @param ops The ops struct.
Evan@653
  1208
 */
Evan@653
  1209
void purple_blist_set_ui_ops(PurpleBlistUiOps *ops);
Evan@653
  1210
Evan@653
  1211
/**
Evan@653
  1212
 * Returns the UI operations structure to be used for the buddy list.
Evan@653
  1213
 *
Evan@653
  1214
 * @return The UI operations structure.
Evan@653
  1215
 */
Evan@653
  1216
PurpleBlistUiOps *purple_blist_get_ui_ops(void);
Evan@653
  1217
Evan@653
  1218
/*@}*/
Evan@653
  1219
Evan@653
  1220
/**************************************************************************/
Evan@653
  1221
/** @name Buddy List Subsystem                                            */
Evan@653
  1222
/**************************************************************************/
Evan@653
  1223
/*@{*/
Evan@653
  1224
Evan@653
  1225
/**
Evan@653
  1226
 * Returns the handle for the buddy list subsystem.
Evan@653
  1227
 *
Evan@653
  1228
 * @return The buddy list subsystem handle.
Evan@653
  1229
 */
Evan@653
  1230
void *purple_blist_get_handle(void);
Evan@653
  1231
Evan@653
  1232
/**
Evan@653
  1233
 * Initializes the buddy list subsystem.
Evan@653
  1234
 */
Evan@653
  1235
void purple_blist_init(void);
Evan@653
  1236
Evan@653
  1237
/**
Evan@653
  1238
 * Uninitializes the buddy list subsystem.
Evan@653
  1239
 */
Evan@653
  1240
void purple_blist_uninit(void);
Evan@653
  1241
Evan@653
  1242
/*@}*/
Evan@653
  1243
Evan@653
  1244
#ifdef __cplusplus
Evan@653
  1245
}
Evan@653
  1246
#endif
Evan@653
  1247
Evan@653
  1248
#endif /* _PURPLE_BLIST_H_ */