[10a96f4] | 1 | /********************************************************************\ |
---|
| 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
| 4 | * Copyright 2002-2010 Wilmer van der Gaast and others * |
---|
| 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* Stuff to handle, save and search buddies */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
| 22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
| 23 | Suite 330, Boston, MA 02111-1307 USA |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #ifndef __BEE_H__ |
---|
| 27 | #define __BEE_H__ |
---|
| 28 | |
---|
| 29 | struct bee_ui_funcs; |
---|
[aea8b68] | 30 | struct groupchat; |
---|
[ebaebfe] | 31 | |
---|
| 32 | typedef struct bee |
---|
| 33 | { |
---|
| 34 | struct set *set; |
---|
| 35 | |
---|
| 36 | GSList *users; |
---|
[81e04e1] | 37 | struct account *accounts; /* TODO(wilmer): Use GSList here too? */ |
---|
[ebaebfe] | 38 | |
---|
[aea8b68] | 39 | /* Symbolic, to refer to the local user (who has no real bee_user |
---|
| 40 | object). Not to be used by anything except so far imcb_chat_add/ |
---|
| 41 | remove_buddy(). This seems slightly cleaner than abusing NULL. */ |
---|
| 42 | struct bee_user *user; |
---|
| 43 | |
---|
[10a96f4] | 44 | const struct bee_ui_funcs *ui; |
---|
[ebaebfe] | 45 | void *ui_data; |
---|
| 46 | } bee_t; |
---|
| 47 | |
---|
| 48 | bee_t *bee_new(); |
---|
| 49 | void bee_free( bee_t *b ); |
---|
[10a96f4] | 50 | |
---|
| 51 | typedef enum |
---|
| 52 | { |
---|
[e63507a] | 53 | BEE_USER_ONLINE = 1, /* Compatibility with old OPT_LOGGED_IN flag */ |
---|
| 54 | BEE_USER_AWAY = 4, /* Compatibility with old OPT_AWAY flag */ |
---|
[10a96f4] | 55 | } bee_user_flags_t; |
---|
| 56 | |
---|
| 57 | typedef struct bee_user |
---|
| 58 | { |
---|
| 59 | struct im_connection *ic; |
---|
| 60 | char *handle; |
---|
| 61 | char *fullname; |
---|
| 62 | char *group; |
---|
| 63 | |
---|
[81e04e1] | 64 | bee_user_flags_t flags; |
---|
| 65 | char *status; |
---|
[10a96f4] | 66 | char *status_msg; |
---|
| 67 | |
---|
| 68 | bee_t *bee; |
---|
| 69 | void *ui_data; |
---|
| 70 | } bee_user_t; |
---|
| 71 | |
---|
| 72 | typedef struct bee_ui_funcs |
---|
| 73 | { |
---|
| 74 | gboolean (*user_new)( bee_t *bee, struct bee_user *bu ); |
---|
| 75 | gboolean (*user_free)( bee_t *bee, struct bee_user *bu ); |
---|
[1d39159] | 76 | gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu ); |
---|
[81e04e1] | 77 | gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old ); |
---|
[f012a9f] | 78 | gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at ); |
---|
[573dab0] | 79 | gboolean (*user_typing)( bee_t *bee, bee_user_t *bu, guint32 flags ); |
---|
[17a6ee9] | 80 | |
---|
[aea8b68] | 81 | gboolean (*chat_new)( bee_t *bee, struct groupchat *c ); |
---|
| 82 | gboolean (*chat_free)( bee_t *bee, struct groupchat *c ); |
---|
[27e2c66] | 83 | gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *text ); |
---|
| 84 | gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at ); |
---|
[aea8b68] | 85 | gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); |
---|
| 86 | gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); |
---|
[d343eaa] | 87 | gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name ); |
---|
[aea8b68] | 88 | |
---|
[17a6ee9] | 89 | struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size ); |
---|
| 90 | gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft ); |
---|
| 91 | void (*ft_close)( struct im_connection *ic, struct file_transfer *ft ); |
---|
| 92 | void (*ft_finished)( struct im_connection *ic, struct file_transfer *ft ); |
---|
[10a96f4] | 93 | } bee_ui_funcs_t; |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | /* bee.c */ |
---|
| 97 | bee_t *bee_new(); |
---|
| 98 | void bee_free( bee_t *b ); |
---|
| 99 | |
---|
| 100 | /* bee_user.c */ |
---|
| 101 | bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle ); |
---|
[eabc9d2] | 102 | int bee_user_free( bee_t *bee, bee_user_t *bu ); |
---|
[10a96f4] | 103 | bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle ); |
---|
[d860a8d] | 104 | int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags ); |
---|
| 105 | |
---|
| 106 | /* Callbacks from IM modules to core: */ |
---|
| 107 | /* Buddy activity */ |
---|
| 108 | /* To manipulate the status of a handle. |
---|
| 109 | * - flags can be |='d with OPT_* constants. You will need at least: |
---|
| 110 | * OPT_LOGGED_IN and OPT_AWAY. |
---|
| 111 | * - 'state' and 'message' can be NULL */ |
---|
| 112 | G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); |
---|
| 113 | /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); |
---|
| 114 | /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ |
---|
[fb117aee] | 115 | G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, guint32 flags, time_t sent_at ); |
---|
[10a96f4] | 116 | |
---|
[aea8b68] | 117 | /* bee_chat.c */ |
---|
| 118 | #if 0 |
---|
| 119 | struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); |
---|
| 120 | void imcb_chat_name_hint( struct groupchat *c, const char *name ); |
---|
| 121 | void imcb_chat_free( struct groupchat *c ); |
---|
| 122 | void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ); |
---|
| 123 | void imcb_chat_log( struct groupchat *c, char *format, ... ); |
---|
| 124 | void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); |
---|
| 125 | void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); |
---|
| 126 | void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ); |
---|
| 127 | static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); |
---|
| 128 | #endif |
---|
[a87754b] | 129 | int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags ); |
---|
[aea8b68] | 130 | |
---|
[10a96f4] | 131 | #endif /* __BEE_H__ */ |
---|