Wed, 03 Sep 2003 05:21:04 +0000
[gaim-migrate @ 7247]
Fixed documentation errors so Doxygen no longer complains.
| 5228 | 1 | /** |
|
5497
da3c08f3af25
[gaim-migrate @ 5893]
Mark Doliner <markdoliner@pidgin.im>
parents:
5277
diff
changeset
|
2 | * @file blist.h Buddy List API |
| 5228 | 3 | * @ingroup core |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 7 | * Copyright (C) 2003, Sean Egan <sean.egan@binghamton.edu> | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
8 | * |
| 5228 | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | * GNU General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | */ | |
| 23 | ||
| 24 | /* I can't believe I let ChipX86 inspire me to write good code. -Sean */ | |
| 25 | ||
| 6695 | 26 | #ifndef _BLIST_H_ |
| 27 | #define _BLIST_H_ | |
| 5228 | 28 | |
| 29 | #include <glib.h> | |
| 30 | ||
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
31 | typedef struct _GaimBlistNode GaimBlistNode; |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
32 | |
| 6695 | 33 | typedef struct _GaimBlistChat GaimBlistChat; |
| 34 | typedef struct _GaimGroup GaimGroup; | |
| 35 | typedef struct _GaimContact GaimContact; | |
| 36 | typedef struct _GaimBuddy GaimBuddy; | |
|
5564
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
37 | |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
38 | #include "account.h" |
|
1779a1bfbdb8
[gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
39 | |
| 5228 | 40 | /**************************************************************************/ |
| 41 | /* Enumerations */ | |
| 42 | /**************************************************************************/ | |
| 43 | enum gaim_blist_node_type { | |
| 44 | GAIM_BLIST_GROUP_NODE, | |
| 6695 | 45 | GAIM_BLIST_CONTACT_NODE, |
| 5228 | 46 | GAIM_BLIST_BUDDY_NODE, |
| 5234 | 47 | GAIM_BLIST_CHAT_NODE, |
| 6063 | 48 | GAIM_BLIST_OTHER_NODE |
| 5228 | 49 | }; |
| 50 | ||
| 5234 | 51 | #define GAIM_BLIST_NODE_IS_CHAT(n) ((n)->type == GAIM_BLIST_CHAT_NODE) |
| 5228 | 52 | #define GAIM_BLIST_NODE_IS_BUDDY(n) ((n)->type == GAIM_BLIST_BUDDY_NODE) |
| 6695 | 53 | #define GAIM_BLIST_NODE_IS_CONTACT(n) ((n)->type == GAIM_BLIST_CONTACT_NODE) |
| 5228 | 54 | #define GAIM_BLIST_NODE_IS_GROUP(n) ((n)->type == GAIM_BLIST_GROUP_NODE) |
| 55 | ||
| 56 | enum gaim_buddy_presence_state { | |
| 57 | GAIM_BUDDY_SIGNING_OFF = -1, | |
| 58 | GAIM_BUDDY_OFFLINE = 0, | |
| 59 | GAIM_BUDDY_ONLINE, | |
| 6063 | 60 | GAIM_BUDDY_SIGNING_ON |
| 5228 | 61 | }; |
| 62 | ||
| 6695 | 63 | #define GAIM_BUDDY_IS_ONLINE(b) ((b)->account->gc && \ |
| 64 | ((b)->present == GAIM_BUDDY_ONLINE || \ | |
| 65 | (b)->present == GAIM_BUDDY_SIGNING_ON)) | |
| 5228 | 66 | |
| 67 | ||
| 68 | /**************************************************************************/ | |
| 69 | /* Data Structures */ | |
| 70 | /**************************************************************************/ | |
| 71 | ||
| 72 | /** | |
| 73 | * A Buddy list node. This can represent a group, a buddy, or anything else. This is a base class for struct buddy and | |
| 74 | * struct group and for anything else that wants to put itself in the buddy list. */ | |
| 75 | struct _GaimBlistNode { | |
| 76 | enum gaim_blist_node_type type; /**< The type of node this is */ | |
| 77 | GaimBlistNode *prev; /**< The sibling before this buddy. */ | |
| 78 | GaimBlistNode *next; /**< The sibling after this buddy. */ | |
| 79 | GaimBlistNode *parent; /**< The parent of this node */ | |
| 80 | GaimBlistNode *child; /**< The child of this node */ | |
| 81 | void *ui_data; /**< The UI can put data here. */ | |
| 82 | }; | |
| 83 | ||
| 84 | /** | |
| 85 | * A buddy. This contains everything Gaim will ever need to know about someone on the buddy list. Everything. | |
| 86 | */ | |
| 6695 | 87 | struct _GaimBuddy { |
| 5228 | 88 | GaimBlistNode node; /**< The node that this buddy inherits from */ |
| 89 | char *name; /**< The screenname of the buddy. */ | |
| 90 | char *alias; /**< The user-set alias of the buddy */ | |
| 6695 | 91 | char *server_alias; /**< The server-specified alias of the buddy. (i.e. MSN "Friendly Names") */ |
| 5228 | 92 | enum gaim_buddy_presence_state present; /**< This is 0 if the buddy appears offline, 1 if he appears online, and 2 if |
| 93 | he has recently signed on */ | |
| 94 | int evil; /**< The warning level */ | |
| 95 | time_t signon; /**< The time the buddy signed on. */ | |
| 96 | int idle; /**< The time the buddy has been idle in minutes. */ | |
| 97 | int uc; /**< This is a cryptic bitmask that makes sense only to the prpl. This will get changed */ | |
| 98 | void *proto_data; /**< This allows the prpl to associate whatever data it wants with a buddy */ | |
| 6695 | 99 | GaimAccount *account; /**< the account this buddy belongs to */ |
| 5228 | 100 | GHashTable *settings; /**< per-buddy settings from the XML buddy list, set by plugins and the likes. */ |
| 101 | guint timer; /**< The timer handle. */ | |
| 102 | }; | |
| 103 | ||
| 104 | /** | |
| 6695 | 105 | * A contact. This contains everything Gaim will ever need to know about a contact. |
| 106 | */ | |
| 107 | struct _GaimContact { | |
| 108 | GaimBlistNode node; /**< The node that this contact inherits from. */ | |
| 109 | int totalsize; /**< The number of buddies in this contact */ | |
| 110 | int currentsize; /**< The number of buddies in this contact corresponding to online accounts */ | |
| 111 | int online; /**< The number of buddies in this contact who are currently online */ | |
| 112 | }; | |
| 113 | ||
| 114 | ||
| 115 | /** | |
| 5228 | 116 | * A group. This contains everything Gaim will ever need to know about a group. |
| 117 | */ | |
| 6695 | 118 | struct _GaimGroup { |
| 5228 | 119 | GaimBlistNode node; /**< The node that this group inherits from */ |
| 120 | char *name; /**< The name of this group. */ | |
| 6695 | 121 | int totalsize; /**< The number of chats and contacts in this group */ |
| 122 | int currentsize; /**< The number of chats and contacts in this group corresponding to online accounts */ | |
| 123 | int online; /**< The number of chats and contacts in this group who are currently online */ | |
| 5228 | 124 | GHashTable *settings; /**< per-group settings from the XML buddy list, set by plugins and the likes. */ |
| 125 | }; | |
| 126 | ||
| 5234 | 127 | /** |
| 6695 | 128 | * A chat. This contains everything Gaim needs to put a chat room in the |
| 5234 | 129 | * buddy list. |
| 130 | */ | |
| 6695 | 131 | struct _GaimBlistChat { |
| 5234 | 132 | GaimBlistNode node; /**< The node that this chat inherits from */ |
| 133 | char *alias; /**< The display name of this chat. */ | |
| 134 | GHashTable *components; /**< the stuff the protocol needs to know to join the chat */ | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
135 | GaimAccount *account; /**< The account this chat is attached to */ |
| 5906 | 136 | GHashTable *settings; /**< per-chat settings from the XML buddy list, set by plugins and the likes. */ |
| 5234 | 137 | }; |
| 138 | ||
| 5228 | 139 | |
| 140 | /** | |
| 141 | * The Buddy List | |
| 142 | */ | |
| 143 | struct gaim_buddy_list { | |
| 144 | GaimBlistNode *root; /**< The first node in the buddy list */ | |
| 5247 | 145 | GHashTable *buddies; /**< Every buddy in this list */ |
| 5228 | 146 | struct gaim_blist_ui_ops *ui_ops; /**< The UI operations for the buddy list */ |
| 147 | ||
| 148 | void *ui_data; /**< UI-specific data. */ | |
| 149 | }; | |
| 150 | ||
| 151 | /** | |
| 152 | * Buddy list UI operations. | |
| 153 | * | |
| 154 | * Any UI representing a buddy list must assign a filled-out gaim_window_ops | |
| 155 | * structure to the buddy list core. | |
| 156 | */ | |
| 157 | struct gaim_blist_ui_ops | |
| 158 | { | |
| 159 | void (*new_list)(struct gaim_buddy_list *list); /**< Sets UI-specific data on a buddy list. */ | |
| 160 | void (*new_node)(GaimBlistNode *node); /**< Sets UI-specific data on a node. */ | |
| 161 | void (*show)(struct gaim_buddy_list *list); /**< The core will call this when its finished doing it's core stuff */ | |
| 6695 | 162 | void (*update)(struct gaim_buddy_list *list, |
| 5228 | 163 | GaimBlistNode *node); /**< This will update a node in the buddy list. */ |
| 164 | void (*remove)(struct gaim_buddy_list *list, | |
| 165 | GaimBlistNode *node); /**< This removes a node from the list */ | |
| 166 | void (*destroy)(struct gaim_buddy_list *list); /**< When the list gets destroyed, this gets called to destroy the UI. */ | |
| 167 | void (*set_visible)(struct gaim_buddy_list *list, | |
| 168 | gboolean show); /**< Hides or unhides the buddy list */ | |
| 169 | ||
| 170 | }; | |
| 171 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
172 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
173 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
174 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
175 | |
| 5228 | 176 | /**************************************************************************/ |
| 177 | /** @name Buddy List API */ | |
| 178 | /**************************************************************************/ | |
| 179 | /*@{*/ | |
| 180 | ||
| 181 | /** | |
| 182 | * Creates a new buddy list | |
| 183 | */ | |
| 184 | struct gaim_buddy_list *gaim_blist_new(); | |
| 185 | ||
| 186 | /** | |
| 187 | * Sets the main buddy list. | |
| 188 | * | |
| 189 | * @return The main buddy list. | |
| 190 | */ | |
| 191 | void gaim_set_blist(struct gaim_buddy_list *blist); | |
| 192 | ||
| 193 | /** | |
| 194 | * Returns the main buddy list. | |
| 195 | * | |
| 196 | * @return The main buddy list. | |
| 197 | */ | |
| 198 | struct gaim_buddy_list *gaim_get_blist(void); | |
| 199 | ||
| 200 | /** | |
| 201 | * Shows the buddy list, creating a new one if necessary. | |
| 202 | * | |
| 203 | */ | |
| 204 | void gaim_blist_show(); | |
| 205 | ||
| 206 | ||
| 207 | /** | |
| 208 | * Destroys the buddy list window. | |
| 209 | */ | |
| 210 | void gaim_blist_destroy(); | |
| 211 | ||
| 212 | /** | |
| 213 | * Hides or unhides the buddy list. | |
| 214 | * | |
| 215 | * @param show Whether or not to show the buddy list | |
| 216 | */ | |
| 217 | void gaim_blist_set_visible(gboolean show); | |
| 218 | ||
| 219 | /** | |
| 220 | * Updates a buddy's status. | |
| 5234 | 221 | * |
| 5228 | 222 | * This needs to not take an int. |
| 223 | * | |
| 224 | * @param buddy The buddy whose status has changed | |
| 225 | * @param status The new status in cryptic prpl-understood code | |
| 226 | */ | |
| 6695 | 227 | void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status); |
| 5228 | 228 | |
| 229 | ||
| 230 | /** | |
| 231 | * Updates a buddy's presence. | |
| 232 | * | |
| 233 | * @param buddy The buddy whose presence has changed | |
| 234 | * @param presence The new presence | |
| 235 | */ | |
| 6695 | 236 | void gaim_blist_update_buddy_presence(GaimBuddy *buddy, int presence); |
| 5228 | 237 | |
| 238 | ||
| 239 | /** | |
| 240 | * Updates a buddy's idle time. | |
| 241 | * | |
| 242 | * @param buddy The buddy whose idle time has changed | |
| 243 | * @param idle The buddy's idle time in minutes. | |
| 244 | */ | |
| 6695 | 245 | void gaim_blist_update_buddy_idle(GaimBuddy *buddy, int idle); |
| 5228 | 246 | |
| 247 | ||
| 248 | /** | |
| 249 | * Updates a buddy's warning level. | |
| 250 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
251 | * @param buddy The buddy whose warning level has changed. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
252 | * @param warning The warning level as an int from 0 to 100. |
| 5228 | 253 | */ |
| 6695 | 254 | void gaim_blist_update_buddy_evil(GaimBuddy *buddy, int warning); |
| 5228 | 255 | |
| 256 | /** | |
| 257 | * Updates a buddy's icon. | |
| 258 | * | |
| 259 | * @param buddy The buddy whose buddy icon has changed | |
| 260 | */ | |
| 6695 | 261 | void gaim_blist_update_buddy_icon(GaimBuddy *buddy); |
| 5228 | 262 | |
| 263 | ||
| 264 | ||
| 265 | /** | |
| 266 | * Renames a buddy in the buddy list. | |
| 267 | * | |
| 268 | * @param buddy The buddy whose name will be changed. | |
| 269 | * @param name The new name of the buddy. | |
| 270 | */ | |
| 6695 | 271 | void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name); |
| 5228 | 272 | |
| 273 | ||
| 274 | /** | |
| 275 | * Aliases a buddy in the buddy list. | |
| 276 | * | |
| 277 | * @param buddy The buddy whose alias will be changed. | |
| 278 | * @param alias The buddy's alias. | |
| 279 | */ | |
| 6695 | 280 | void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias); |
| 5228 | 281 | |
| 5234 | 282 | /** |
|
6059
9934c862ca14
[gaim-migrate @ 6509]
John Silvestri <john.silvestri@gmail.com>
parents:
6058
diff
changeset
|
283 | * Sets the server-sent alias of a buddy in the buddy list. |
|
6058
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
284 | * |
|
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
285 | * @param buddy The buddy whose alias will be changed. |
|
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
286 | * @param alias The buddy's "official" alias. |
|
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
287 | */ |
| 6695 | 288 | void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias); |
|
6058
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
289 | |
|
0d5c66a5da5d
[gaim-migrate @ 6508]
Mark Doliner <markdoliner@pidgin.im>
parents:
6036
diff
changeset
|
290 | /** |
| 5234 | 291 | * Aliases a chat in the buddy list. |
| 292 | * | |
| 293 | * @param chat The chat whose alias will be changed. | |
| 294 | * @param alias The chat's new alias. | |
| 295 | */ | |
| 6695 | 296 | void gaim_blist_alias_chat(GaimBlistChat *chat, const char *alias); |
| 5228 | 297 | |
| 298 | /** | |
| 299 | * Renames a group | |
| 300 | * | |
| 301 | * @param group The group to rename | |
| 302 | * @param name The new name | |
| 303 | */ | |
| 6695 | 304 | void gaim_blist_rename_group(GaimGroup *group, const char *name); |
| 5228 | 305 | |
| 5234 | 306 | /** |
| 307 | * Creates a new chat for the buddy list | |
| 308 | * | |
| 309 | * @param account The account this chat will get added to | |
| 310 | * @param alias The alias of the new chat | |
| 311 | * @param components The info the prpl needs to join the chat | |
| 312 | * @return A newly allocated chat | |
| 313 | */ | |
| 6695 | 314 | GaimBlistChat *gaim_blist_chat_new(GaimAccount *account, const char *alias, GHashTable *components); |
| 5234 | 315 | |
| 316 | /** | |
| 6034 | 317 | * Gets the alias of the chat, or the chat name if the alias does not exist |
| 318 | * | |
| 319 | * @param chat The chat | |
| 320 | * @return The display name of the chat | |
| 321 | */ | |
| 6695 | 322 | char *gaim_blist_chat_get_display_name(GaimBlistChat *chat); |
| 6034 | 323 | |
| 324 | /** | |
| 5234 | 325 | * Adds a new chat to the buddy list. |
| 326 | * | |
| 327 | * The chat will be inserted right after node or appended to the end | |
| 328 | * of group if node is NULL. If both are NULL, the buddy will be added to | |
| 329 | * the "Chats" group. | |
| 330 | * | |
| 331 | * @param chat The new chat who gets added | |
| 332 | * @param group The group to add the new chat to. | |
| 333 | * @param node The insertion point | |
| 334 | */ | |
| 6695 | 335 | void gaim_blist_add_chat(GaimBlistChat *chat, GaimGroup *group, GaimBlistNode *node); |
| 5228 | 336 | |
| 337 | /** | |
| 338 | * Creates a new buddy | |
| 339 | * | |
| 340 | * @param account The account this buddy will get added to | |
| 341 | * @param screenname The screenname of the new buddy | |
| 342 | * @param alias The alias of the new buddy (or NULL if unaliased) | |
| 343 | * @return A newly allocated buddy | |
| 344 | */ | |
| 6695 | 345 | GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias); |
| 5228 | 346 | |
| 347 | /** | |
| 348 | * Adds a new buddy to the buddy list. | |
| 349 | * | |
| 6695 | 350 | * The buddy will be inserted right after node or prepended to the |
| 351 | * group if node is NULL. If both are NULL, the buddy will be added to | |
| 5228 | 352 | * the "Buddies" group. |
| 353 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
354 | * @param buddy The new buddy who gets added |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
355 | * @param contact The optional contact to place the buddy in. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
356 | * @param group The group to add the new buddy to. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
357 | * @param node The insertion point |
| 5228 | 358 | */ |
| 6695 | 359 | void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node); |
| 5228 | 360 | |
| 361 | /** | |
| 362 | * Creates a new group | |
| 363 | * | |
| 6695 | 364 | * You can't have more than one group with the same name. Sorry. If you pass |
| 365 | * this the * name of a group that already exists, it will return that group. | |
| 5228 | 366 | * |
| 367 | * @param name The name of the new group | |
| 6695 | 368 | * @return A new group struct |
| 5228 | 369 | */ |
| 6695 | 370 | GaimGroup *gaim_group_new(const char *name); |
| 5228 | 371 | |
| 372 | /** | |
| 373 | * Adds a new group to the buddy list. | |
| 374 | * | |
| 6695 | 375 | * The new group will be inserted after insert or prepended to the list if |
| 376 | * node is NULL. | |
| 377 | * | |
| 378 | * @param group The group | |
| 379 | * @param node The insertion point | |
| 380 | */ | |
| 381 | void gaim_blist_add_group(GaimGroup *group, GaimBlistNode *node); | |
| 382 | ||
| 383 | /** | |
| 384 | * Creates a new contact | |
| 5228 | 385 | * |
| 6695 | 386 | * @return A new contact struct |
| 5228 | 387 | */ |
| 6695 | 388 | GaimContact *gaim_contact_new(); |
| 389 | ||
| 390 | /** | |
| 391 | * Adds a new contact to the buddy list. | |
| 392 | * | |
| 393 | * The new contact will be inserted after insert or prepended to the list if | |
| 394 | * node is NULL. | |
| 395 | * | |
| 396 | * @param contact The contact | |
| 397 | * @param group The group to add the contact to | |
| 398 | * @param node The insertion point | |
| 399 | */ | |
| 400 | void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node); | |
| 401 | ||
| 402 | /** | |
| 403 | * Returns the highest priority buddy for a given contact. | |
| 404 | * | |
| 405 | * @param contact The contact | |
| 406 | * @return The highest priority buddy | |
| 407 | */ | |
| 408 | GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact); | |
| 5228 | 409 | |
| 410 | /** | |
| 411 | * Removes a buddy from the buddy list and frees the memory allocated to it. | |
| 412 | * | |
| 413 | * @param buddy The buddy to be removed | |
| 414 | */ | |
| 6695 | 415 | void gaim_blist_remove_buddy(GaimBuddy *buddy); |
| 416 | ||
| 417 | /** | |
| 418 | * Removes a contact, and any buddies it contains, and frees the memory | |
| 419 | * allocated to it. | |
| 420 | * | |
| 421 | * @param contact The contact to be removed | |
| 422 | */ | |
| 423 | void gaim_blist_remove_contact(GaimContact *contact); | |
| 5228 | 424 | |
| 425 | /** | |
| 5234 | 426 | * Removes a chat from the buddy list and frees the memory allocated to it. |
| 427 | * | |
| 428 | * @param chat The chat to be removed | |
| 429 | */ | |
| 6695 | 430 | void gaim_blist_remove_chat(GaimBlistChat *chat); |
| 5234 | 431 | |
| 432 | /** | |
| 5228 | 433 | * Removes a group from the buddy list and frees the memory allocated to it and to |
| 434 | * its children | |
| 435 | * | |
| 436 | * @param group The group to be removed | |
| 437 | */ | |
| 6695 | 438 | void gaim_blist_remove_group(GaimGroup *group); |
| 5228 | 439 | |
| 440 | /** | |
| 441 | * Returns the alias of a buddy. | |
| 442 | * | |
| 443 | * @param buddy The buddy whose name will be returned. | |
| 444 | * @return The alias (if set), server alias (if option is set), or NULL. | |
| 445 | */ | |
| 6695 | 446 | const char *gaim_get_buddy_alias_only(GaimBuddy *buddy); |
| 5228 | 447 | |
| 448 | ||
| 449 | /** | |
| 450 | * Returns the correct name to display for a buddy. | |
| 451 | * | |
| 452 | * @param buddy The buddy whose name will be returned. | |
| 453 | * @return The alias (if set), server alias (if option is set), screenname, or "Unknown" | |
| 454 | */ | |
| 6695 | 455 | const char *gaim_get_buddy_alias(GaimBuddy *buddy); |
| 5228 | 456 | |
| 457 | /** | |
| 458 | * Finds the buddy struct given a screenname and an account | |
| 459 | * | |
| 5758 | 460 | * @param name The buddy's screenname or NULL to search for more buddies with the same screenname |
| 461 | * as the previous search | |
| 5228 | 462 | * @param account The account this buddy belongs to |
| 463 | * @return The buddy or NULL if the buddy does not exist | |
| 464 | */ | |
| 6695 | 465 | GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name); |
| 6245 | 466 | |
| 467 | /** | |
| 468 | * Finds all buddies struct given a screenname and an account | |
| 469 | * | |
| 470 | * @param name The buddy's screenname | |
| 471 | * @param account The account this buddy belongs to | |
| 472 | * | |
| 473 | * @return A GSList of buddies (which must be freed), or NULL if the buddy doesn't exist | |
| 474 | */ | |
| 475 | GSList *gaim_find_buddies(GaimAccount *account, const char *name); | |
| 476 | ||
| 5228 | 477 | |
| 478 | /** | |
| 479 | * Finds a group by name | |
| 480 | * | |
| 481 | * @param name The groups name | |
| 482 | * @return The group or NULL if the group does not exist | |
| 483 | */ | |
| 6695 | 484 | GaimGroup *gaim_find_group(const char *name); |
| 485 | ||
| 486 | /** | |
| 487 | * Finds a contact | |
| 488 | * | |
| 489 | * @param group The group to look in | |
| 490 | * @param name The name to look for | |
| 491 | * @return The contact or NULL if the contact does not exist | |
| 492 | */ | |
| 493 | GaimContact *gaim_find_contact(GaimGroup *group, const char *name); | |
| 5228 | 494 | |
| 495 | /** | |
|
6456
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
496 | * Finds a chat by name. |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
497 | * |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
498 | * @param account The chat's account. |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
499 | * @param name The chat's name. |
|
6456
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
500 | * |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
501 | * @return The chat, or @c NULL if the chat does not exist. |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
502 | */ |
| 6695 | 503 | GaimBlistChat *gaim_blist_find_chat(GaimAccount *account, const char *name); |
|
6456
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
504 | |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
505 | /** |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
506 | * Returns the group of which the chat is a member. |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
507 | * |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
508 | * @param chat The chat. |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
509 | * |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
510 | * @return The parent group, or @c NULL if the chat is not in a group. |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
511 | */ |
| 6695 | 512 | GaimGroup *gaim_blist_chat_get_group(GaimBlistChat *chat); |
|
6456
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
513 | |
|
e4e7dee16c1a
[gaim-migrate @ 6965]
Christian Hammond <chipx86@chipx86.com>
parents:
6245
diff
changeset
|
514 | /** |
| 5228 | 515 | * Returns the group of which the buddy is a member. |
| 516 | * | |
| 517 | * @param buddy The buddy | |
| 518 | * @return The group or NULL if the buddy is not in a group | |
| 519 | */ | |
| 6695 | 520 | GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy); |
| 5228 | 521 | |
| 522 | ||
| 523 | /** | |
| 524 | * Returns a list of accounts that have buddies in this group | |
| 525 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
526 | * @param g The group |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
527 | * |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
528 | * @return A list of gaim_accounts |
| 5228 | 529 | */ |
| 6695 | 530 | GSList *gaim_group_get_accounts(GaimGroup *g); |
| 5228 | 531 | |
| 532 | /** | |
| 533 | * Determines whether an account owns any buddies in a given group | |
| 534 | * | |
| 535 | * @param g The group to search through. | |
| 536 | * @param account The account. | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
537 | * |
|
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
538 | * @return TRUE if there are any buddies in the group, or FALSE otherwise. |
| 5228 | 539 | */ |
| 6695 | 540 | gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account); |
| 5228 | 541 | |
| 542 | /** | |
| 5234 | 543 | * Called when an account gets signed on. Tells the UI to update all the |
| 544 | * buddies. | |
| 545 | * | |
| 546 | * @param account The account | |
| 547 | */ | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
548 | void gaim_blist_add_account(GaimAccount *account); |
| 5234 | 549 | |
| 550 | ||
| 551 | /** | |
| 5228 | 552 | * Called when an account gets signed off. Sets the presence of all the buddies to 0 |
| 553 | * and tells the UI to update them. | |
| 554 | * | |
| 6695 | 555 | * @param account The account |
| 5228 | 556 | */ |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
557 | void gaim_blist_remove_account(GaimAccount *account); |
| 5228 | 558 | |
| 559 | ||
| 560 | /** | |
| 561 | * Determines the total size of a group | |
| 562 | * | |
| 563 | * @param group The group | |
| 564 | * @param offline Count buddies in offline accounts | |
| 565 | * @return The number of buddies in the group | |
| 566 | */ | |
| 6695 | 567 | int gaim_blist_get_group_size(GaimGroup *group, gboolean offline); |
| 5228 | 568 | |
| 569 | /** | |
| 570 | * Determines the number of online buddies in a group | |
| 571 | * | |
| 572 | * @param group The group | |
| 573 | * @return The number of online buddies in the group, or 0 if the group is NULL | |
| 574 | */ | |
| 6695 | 575 | int gaim_blist_get_group_online_count(GaimGroup *group); |
| 5228 | 576 | |
| 577 | /*@}*/ | |
| 578 | ||
| 579 | /****************************************************************************************/ | |
| 580 | /** @name Buddy list file management API */ | |
| 581 | /****************************************************************************************/ | |
| 582 | ||
| 583 | /*@{*/ | |
| 584 | /** | |
| 585 | * Saves the buddy list to file | |
| 586 | */ | |
| 587 | void gaim_blist_save(); | |
| 588 | ||
| 589 | /** | |
| 590 | * Parses the toc-style buddy list used in older versions of Gaim and for SSI in toc.c | |
| 591 | * | |
| 592 | * @param account This is the account that the buddies and groups from config will get added to | |
| 593 | * @param config This is the toc-style buddy list data | |
| 594 | */ | |
|
5563
d5a7852aa0cb
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5497
diff
changeset
|
595 | void parse_toc_buddy_list(GaimAccount *account, char *config); |
| 5228 | 596 | |
| 597 | ||
| 598 | /** | |
| 599 | * Loads the buddy list from ~/.gaim/blist.xml. | |
| 600 | */ | |
| 601 | void gaim_blist_load(); | |
| 602 | ||
| 603 | /** | |
| 604 | * Associates some data with the group in the xml buddy list | |
| 605 | * | |
| 606 | * @param g The group the data is associated with | |
| 607 | * @param key The key used to retrieve the data | |
| 608 | * @param value The data to set | |
| 609 | */ | |
| 6695 | 610 | void gaim_group_set_setting(GaimGroup *g, const char *key, const char *value); |
| 5228 | 611 | |
| 612 | /** | |
| 613 | * Retrieves data from the XML buddy list set by gaim_group_set_setting()) | |
| 614 | * | |
| 615 | * @param g The group to retrieve data from | |
| 616 | * @param key The key to retrieve the data with | |
| 617 | * @return The associated data or NULL if no data is associated | |
| 618 | */ | |
| 6695 | 619 | char *gaim_group_get_setting(GaimGroup *g, const char *key); |
| 5228 | 620 | |
| 5906 | 621 | /** |
| 622 | * Associates some data with the chat in the xml buddy list | |
| 623 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
624 | * @param c The chat the data is associated with |
| 5906 | 625 | * @param key The key used to retrieve the data |
| 626 | * @param value The data to set | |
| 627 | */ | |
| 6695 | 628 | void gaim_blist_chat_set_setting(GaimBlistChat *c, const char *key, const char *value); |
| 5906 | 629 | |
| 630 | /** | |
| 631 | * Retrieves data from the XML buddy list set by gaim_chat_set_setting()) | |
| 632 | * | |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
633 | * @param c The chat to retrieve data from |
| 5906 | 634 | * @param key The key to retrieve the data with |
|
6720
cdc5348dd848
[gaim-migrate @ 7247]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
635 | * |
| 5906 | 636 | * @return The associated data or NULL if no data is associated |
| 637 | */ | |
| 6695 | 638 | char *gaim_blist_chat_get_setting(GaimBlistChat *c, const char *key); |
| 5228 | 639 | |
| 640 | /** | |
| 641 | * Associates some data with the buddy in the xml buddy list | |
| 642 | * | |
| 643 | * @param b The buddy the data is associated with | |
| 644 | * @param key The key used to retrieve the data | |
| 645 | * @param value The data to set | |
| 646 | */ | |
| 6695 | 647 | void gaim_buddy_set_setting(GaimBuddy *b, const char *key, const char *value); |
| 5228 | 648 | |
| 649 | /** | |
| 650 | * Retrieves data from the XML buddy list set by gaim_buddy_set_setting()) | |
| 651 | * | |
| 652 | * @param b The buddy to retrieve data from | |
| 653 | * @param key The key to retrieve the data with | |
| 654 | * @return The associated data or NULL if no data is associated | |
| 655 | */ | |
| 6695 | 656 | char *gaim_buddy_get_setting(GaimBuddy *b, const char *key); |
| 5228 | 657 | |
| 658 | /*@}*/ | |
| 659 | ||
| 660 | /**************************************************************************/ | |
| 661 | /** @name UI Registration Functions */ | |
| 662 | /**************************************************************************/ | |
| 663 | /*@{*/ | |
| 664 | ||
| 665 | /** | |
| 666 | * Sets the UI operations structure to be used for the buddy list. | |
| 667 | * | |
| 668 | * @param ops The ops struct. | |
| 669 | */ | |
| 670 | void gaim_set_blist_ui_ops(struct gaim_blist_ui_ops *ops); | |
| 671 | ||
| 672 | /** | |
| 673 | * Returns the UI operations structure to be used for the buddy list. | |
| 674 | * | |
| 675 | * @return The UI operations structure. | |
| 676 | */ | |
| 677 | struct gaim_blist_ui_ops *gaim_get_blist_ui_ops(void); | |
| 678 | ||
| 679 | /*@}*/ | |
| 680 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
681 | /**************************************************************************/ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
682 | /** @name Buddy List Subsystem */ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
683 | /**************************************************************************/ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
684 | /*@{*/ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
685 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
686 | /** |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
687 | * Returns the handle for the buddy list subsystem. |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
688 | * |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
689 | * @return The buddy list subsystem handle. |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
690 | */ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
691 | void *gaim_blist_get_handle(void); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
692 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
693 | /** |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
694 | * Initializes the buddy list subsystem. |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
695 | */ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
696 | void gaim_blist_init(void); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
697 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
698 | /** |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
699 | * Uninitializes the buddy list subsystem. |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
700 | */ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
701 | void gaim_blist_uninit(void); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
702 | |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
703 | /*@}*/ |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6456
diff
changeset
|
704 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
705 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
706 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
707 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5906
diff
changeset
|
708 | |
| 6695 | 709 | #endif /* _BLIST_H_ */ |