[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; |
---|
[ebaebfe] | 30 | |
---|
| 31 | typedef struct bee |
---|
| 32 | { |
---|
| 33 | struct set *set; |
---|
| 34 | |
---|
| 35 | GSList *users; |
---|
[81e04e1] | 36 | struct account *accounts; /* TODO(wilmer): Use GSList here too? */ |
---|
[ebaebfe] | 37 | |
---|
[10a96f4] | 38 | const struct bee_ui_funcs *ui; |
---|
[ebaebfe] | 39 | void *ui_data; |
---|
| 40 | } bee_t; |
---|
| 41 | |
---|
| 42 | bee_t *bee_new(); |
---|
| 43 | void bee_free( bee_t *b ); |
---|
[10a96f4] | 44 | |
---|
| 45 | typedef enum |
---|
| 46 | { |
---|
[e63507a] | 47 | BEE_USER_ONLINE = 1, /* Compatibility with old OPT_LOGGED_IN flag */ |
---|
| 48 | BEE_USER_AWAY = 4, /* Compatibility with old OPT_AWAY flag */ |
---|
[10a96f4] | 49 | } bee_user_flags_t; |
---|
| 50 | |
---|
| 51 | typedef struct bee_user |
---|
| 52 | { |
---|
| 53 | struct im_connection *ic; |
---|
| 54 | char *handle; |
---|
| 55 | char *fullname; |
---|
| 56 | char *group; |
---|
| 57 | |
---|
[81e04e1] | 58 | bee_user_flags_t flags; |
---|
| 59 | char *status; |
---|
[10a96f4] | 60 | char *status_msg; |
---|
| 61 | |
---|
| 62 | bee_t *bee; |
---|
| 63 | void *ui_data; |
---|
| 64 | } bee_user_t; |
---|
| 65 | |
---|
| 66 | typedef struct bee_ui_funcs |
---|
| 67 | { |
---|
| 68 | gboolean (*user_new)( bee_t *bee, struct bee_user *bu ); |
---|
| 69 | gboolean (*user_free)( bee_t *bee, struct bee_user *bu ); |
---|
[1d39159] | 70 | gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu ); |
---|
[81e04e1] | 71 | gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old ); |
---|
[f012a9f] | 72 | gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at ); |
---|
[10a96f4] | 73 | } bee_ui_funcs_t; |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | /* bee.c */ |
---|
| 77 | bee_t *bee_new(); |
---|
| 78 | void bee_free( bee_t *b ); |
---|
| 79 | |
---|
| 80 | /* bee_user.c */ |
---|
| 81 | bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle ); |
---|
| 82 | int bee_user_free( bee_t *bee, struct im_connection *ic, const char *handle ); |
---|
| 83 | bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle ); |
---|
[d860a8d] | 84 | int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags ); |
---|
| 85 | |
---|
| 86 | /* Callbacks from IM modules to core: */ |
---|
| 87 | /* Buddy activity */ |
---|
| 88 | /* To manipulate the status of a handle. |
---|
| 89 | * - flags can be |='d with OPT_* constants. You will need at least: |
---|
| 90 | * OPT_LOGGED_IN and OPT_AWAY. |
---|
| 91 | * - 'state' and 'message' can be NULL */ |
---|
| 92 | G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); |
---|
| 93 | /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); |
---|
| 94 | /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ |
---|
[fb117aee] | 95 | G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, guint32 flags, time_t sent_at ); |
---|
[10a96f4] | 96 | |
---|
| 97 | #endif /* __BEE_H__ */ |
---|