00001
00025 #ifndef _GAIM_BLIST_H_
00026 #define _GAIM_BLIST_H_
00027
00028
00029
00030 #include <glib.h>
00031
00032 typedef struct _GaimBuddyList GaimBuddyList;
00033 typedef struct _GaimBlistUiOps GaimBlistUiOps;
00034 typedef struct _GaimBlistNode GaimBlistNode;
00035
00036 typedef struct _GaimBlistNodeAction GaimBlistNodeAction;
00037
00038 typedef struct _GaimChat GaimChat;
00039 typedef struct _GaimGroup GaimGroup;
00040 typedef struct _GaimContact GaimContact;
00041 typedef struct _GaimBuddy GaimBuddy;
00042
00043 #include "account.h"
00044 #include "buddyicon.h"
00045
00046
00047
00048
00049 typedef enum
00050 {
00051 GAIM_BLIST_GROUP_NODE,
00052 GAIM_BLIST_CONTACT_NODE,
00053 GAIM_BLIST_BUDDY_NODE,
00054 GAIM_BLIST_CHAT_NODE,
00055 GAIM_BLIST_OTHER_NODE
00056
00057 } GaimBlistNodeType;
00058
00059 #define GAIM_BLIST_NODE_IS_CHAT(n) ((n)->type == GAIM_BLIST_CHAT_NODE)
00060 #define GAIM_BLIST_NODE_IS_BUDDY(n) ((n)->type == GAIM_BLIST_BUDDY_NODE)
00061 #define GAIM_BLIST_NODE_IS_CONTACT(n) ((n)->type == GAIM_BLIST_CONTACT_NODE)
00062 #define GAIM_BLIST_NODE_IS_GROUP(n) ((n)->type == GAIM_BLIST_GROUP_NODE)
00063
00064 typedef enum
00065 {
00066 GAIM_BUDDY_SIGNING_OFF = -1,
00067 GAIM_BUDDY_OFFLINE = 0,
00068 GAIM_BUDDY_ONLINE,
00069 GAIM_BUDDY_SIGNING_ON
00070
00071 } GaimBuddyPresenceState;
00072
00073 #define GAIM_BUDDY_IS_ONLINE(b) ((b)->account->gc && \
00074 ((b)->present == GAIM_BUDDY_ONLINE || \
00075 (b)->present == GAIM_BUDDY_SIGNING_ON))
00076
00077 typedef enum
00078 {
00079 GAIM_BLIST_NODE_FLAG_NO_SAVE = 1,
00080 } GaimBlistNodeFlags;
00081
00082 #define GAIM_BLIST_NODE_HAS_FLAG(b, f) ((b)->flags & (f))
00083 #define GAIM_BLIST_NODE_SHOULD_SAVE(b) (! GAIM_BLIST_NODE_HAS_FLAG(b, GAIM_BLIST_NODE_FLAG_NO_SAVE))
00084
00085
00086
00087
00088
00089
00093 struct _GaimBlistNode {
00094 GaimBlistNodeType type;
00095 GaimBlistNode *prev;
00096 GaimBlistNode *next;
00097 GaimBlistNode *parent;
00098 GaimBlistNode *child;
00099 GHashTable *settings;
00100 void *ui_data;
00101 GaimBlistNodeFlags flags;
00102 };
00103
00107 struct _GaimBuddy {
00108 GaimBlistNode node;
00109 char *name;
00110 char *alias;
00111 char *server_alias;
00112 GaimBuddyPresenceState present;
00114 int evil;
00115 time_t signon;
00116 int idle;
00117 int uc;
00118 void *proto_data;
00119 GaimBuddyIcon *icon;
00120 GaimAccount *account;
00121 guint timer;
00122 };
00123
00127 struct _GaimContact {
00128 GaimBlistNode node;
00129 char *alias;
00130 int totalsize;
00131 int currentsize;
00132 int online;
00133 GaimBuddy *priority;
00134 };
00135
00136
00140 struct _GaimGroup {
00141 GaimBlistNode node;
00142 char *name;
00143 int totalsize;
00144 int currentsize;
00145 int online;
00146 };
00147
00152 struct _GaimChat {
00153 GaimBlistNode node;
00154 char *alias;
00155 GHashTable *components;
00156 GaimAccount *account;
00157 };
00158
00159
00163 struct _GaimBuddyList {
00164 GaimBlistNode *root;
00165 GHashTable *buddies;
00166 GaimBlistUiOps *ui_ops;
00168 void *ui_data;
00169 };
00170
00177 struct _GaimBlistUiOps
00178 {
00179 void (*new_list)(GaimBuddyList *list);
00180 void (*new_node)(GaimBlistNode *node);
00181 void (*show)(GaimBuddyList *list);
00182 void (*update)(GaimBuddyList *list,
00183 GaimBlistNode *node);
00184 void (*remove)(GaimBuddyList *list,
00185 GaimBlistNode *node);
00186 void (*destroy)(GaimBuddyList *list);
00187 void (*set_visible)(GaimBuddyList *list,
00188 gboolean show);
00189 void (*request_add_buddy)(GaimAccount *account, const char *username,
00190 const char *group, const char *alias);
00191 void (*request_add_chat)(GaimAccount *account, GaimGroup *group,
00192 const char *alias, const char *name);
00193 void (*request_add_group)(void);
00194 };
00195
00196
00197 struct _GaimBlistNodeAction {
00198 char *label;
00199 void (*callback)(GaimBlistNode *, gpointer);
00200 gpointer data;
00201 };
00202
00203
00204 #ifdef __cplusplus
00205 extern "C" {
00206 #endif
00207
00208
00210
00216 GaimBuddyList *gaim_blist_new();
00217
00223 void gaim_set_blist(GaimBuddyList *blist);
00224
00230 GaimBuddyList *gaim_get_blist(void);
00231
00236 void gaim_blist_show();
00237
00238
00242 void gaim_blist_destroy();
00243
00249 void gaim_blist_set_visible(gboolean show);
00250
00259 void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status);
00260
00261
00268 void gaim_blist_update_buddy_presence(GaimBuddy *buddy, gboolean online);
00269
00276 void gaim_blist_update_buddy_signon(GaimBuddy *buddy, time_t signon);
00277
00284 void gaim_blist_update_buddy_idle(GaimBuddy *buddy, int idle);
00285
00286
00293 void gaim_blist_update_buddy_evil(GaimBuddy *buddy, int warning);
00294
00300 void gaim_blist_update_buddy_icon(GaimBuddy *buddy);
00301
00308 void gaim_blist_rename_buddy(GaimBuddy *buddy, const char *name);
00309
00310
00317 void gaim_blist_alias_buddy(GaimBuddy *buddy, const char *alias);
00318
00325 void gaim_blist_server_alias_buddy(GaimBuddy *buddy, const char *alias);
00326
00333 void gaim_blist_alias_chat(GaimChat *chat, const char *alias);
00334
00341 void gaim_blist_rename_group(GaimGroup *group, const char *name);
00342
00351 GaimChat *gaim_chat_new(GaimAccount *account, const char *alias, GHashTable *components);
00352
00359 char *gaim_chat_get_display_name(GaimChat *chat);
00360
00372 void gaim_blist_add_chat(GaimChat *chat, GaimGroup *group, GaimBlistNode *node);
00373
00382 GaimBuddy *gaim_buddy_new(GaimAccount *account, const char *screenname, const char *alias);
00383
00395 void gaim_buddy_set_icon(GaimBuddy *buddy, GaimBuddyIcon *icon);
00396
00404 GaimBuddyIcon *gaim_buddy_get_icon(const GaimBuddy *buddy);
00405
00413 GaimContact *gaim_buddy_get_contact(GaimBuddy *buddy);
00414
00427 void gaim_blist_add_buddy(GaimBuddy *buddy, GaimContact *contact, GaimGroup *group, GaimBlistNode *node);
00428
00438 GaimGroup *gaim_group_new(const char *name);
00439
00449 void gaim_blist_add_group(GaimGroup *group, GaimBlistNode *node);
00450
00456 GaimContact *gaim_contact_new();
00457
00468 void gaim_blist_add_contact(GaimContact *contact, GaimGroup *group, GaimBlistNode *node);
00469
00478 void gaim_blist_merge_contact(GaimContact *source, GaimBlistNode *node);
00479
00486 GaimBuddy *gaim_contact_get_priority_buddy(GaimContact *contact);
00487
00494 void gaim_contact_set_alias(GaimContact *contact, const char *alias);
00495
00502 const char *gaim_contact_get_alias(GaimContact *contact);
00503
00512 gboolean gaim_contact_on_account(GaimContact *contact, GaimAccount *account);
00513
00514
00520 void gaim_blist_remove_buddy(GaimBuddy *buddy);
00521
00528 void gaim_blist_remove_contact(GaimContact *contact);
00529
00535 void gaim_blist_remove_chat(GaimChat *chat);
00536
00543 void gaim_blist_remove_group(GaimGroup *group);
00544
00552 const char *gaim_buddy_get_alias_only(GaimBuddy *buddy);
00553
00554
00564 const char *gaim_buddy_get_contact_alias(GaimBuddy *buddy);
00565
00566
00575 const char *gaim_buddy_get_alias(GaimBuddy *buddy);
00576
00583 const char *gaim_chat_get_name(GaimChat *chat);
00584
00592 GaimBuddy *gaim_find_buddy(GaimAccount *account, const char *name);
00593
00602 GaimBuddy *gaim_find_buddy_in_group(GaimAccount *account, const char *name,
00603 GaimGroup *group);
00604
00613 GSList *gaim_find_buddies(GaimAccount *account, const char *name);
00614
00615
00622 GaimGroup *gaim_find_group(const char *name);
00623
00632 GaimChat *gaim_blist_find_chat(GaimAccount *account, const char *name);
00633
00641 GaimGroup *gaim_chat_get_group(GaimChat *chat);
00642
00649 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy);
00650
00651
00659 GSList *gaim_group_get_accounts(GaimGroup *g);
00660
00669 gboolean gaim_group_on_account(GaimGroup *g, GaimAccount *account);
00670
00677 void gaim_blist_add_account(GaimAccount *account);
00678
00679
00686 void gaim_blist_remove_account(GaimAccount *account);
00687
00688
00696 int gaim_blist_get_group_size(GaimGroup *group, gboolean offline);
00697
00704 int gaim_blist_get_group_online_count(GaimGroup *group);
00705
00708
00710
00711
00717 void gaim_blist_sync();
00718
00725 void gaim_blist_parse_toc_buddy_list(GaimAccount *account, char *config);
00726
00727
00731 void gaim_blist_load();
00732
00742 void gaim_blist_request_add_buddy(GaimAccount *account, const char *username,
00743 const char *group, const char *alias);
00744
00754 void gaim_blist_request_add_chat(GaimAccount *account, GaimGroup *group,
00755 const char *alias, const char *name);
00756
00761 void gaim_blist_request_add_group(void);
00762
00770 void gaim_blist_node_set_bool(GaimBlistNode *node, const char *key, gboolean value);
00771
00780 gboolean gaim_blist_node_get_bool(GaimBlistNode *node, const char *key);
00781
00789 void gaim_blist_node_set_int(GaimBlistNode *node, const char *key, int value);
00790
00799 int gaim_blist_node_get_int(GaimBlistNode *node, const char *key);
00800
00808 void gaim_blist_node_set_string(GaimBlistNode *node, const char *key,
00809 const char *value);
00810
00819 const char *gaim_blist_node_get_string(GaimBlistNode *node, const char *key);
00820
00827 void gaim_blist_node_remove_setting(GaimBlistNode *node, const char *key);
00828
00838 GList *gaim_blist_node_get_extended_menu(GaimBlistNode *n);
00839
00840
00848 GaimBlistNodeAction *gaim_blist_node_action_new(char *label,
00849 void (*callback)(GaimBlistNode *, gpointer), gpointer data);
00850
00851
00852
00854
00862 void gaim_blist_set_ui_ops(GaimBlistUiOps *ops);
00863
00869 GaimBlistUiOps *gaim_blist_get_ui_ops(void);
00870
00873
00875
00883 void *gaim_blist_get_handle(void);
00884
00888 void gaim_blist_init(void);
00889
00893 void gaim_blist_uninit(void);
00894
00897 #ifdef __cplusplus
00898 }
00899 #endif
00900
00901 #endif