source: protocols/bee.h @ 7b71feb

Last change on this file since 7b71feb was ad404ab, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-06-03T00:20:53Z

Restore add_* handle_unknown settings.

  • Property mode set to 100644
File size: 5.8 KB
Line 
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
29struct bee_ui_funcs;
30struct groupchat;
31
32typedef struct bee
33{
34        struct set *set;
35       
36        GSList *users;
37        GSList *groups;
38        struct account *accounts; /* TODO(wilmer): Use GSList here too? */
39       
40        /* Symbolic, to refer to the local user (who has no real bee_user
41           object). Not to be used by anything except so far imcb_chat_add/
42           remove_buddy(). This seems slightly cleaner than abusing NULL. */
43        struct bee_user *user;
44       
45        const struct bee_ui_funcs *ui;
46        void *ui_data;
47} bee_t;
48
49bee_t *bee_new();
50void bee_free( bee_t *b );
51
52typedef enum
53{
54        BEE_USER_ONLINE = 1,    /* Compatibility with old OPT_LOGGED_IN flag */
55        BEE_USER_AWAY = 4,      /* Compatibility with old OPT_AWAY flag */
56        BEE_USER_LOCAL = 256,   /* Locally-added contacts (not in real contact list) */
57} bee_user_flags_t;
58
59typedef struct bee_user
60{
61        struct im_connection *ic;
62        char *handle;
63        char *fullname;
64        struct bee_group *group;
65
66        bee_user_flags_t flags;
67        char *status;
68        char *status_msg;
69       
70        bee_t *bee;
71        void *ui_data;
72} bee_user_t;
73
74typedef struct bee_group
75{
76        char *key;
77        char *name;
78} bee_group_t;
79
80typedef struct bee_ui_funcs
81{
82        gboolean (*user_new)( bee_t *bee, struct bee_user *bu );
83        gboolean (*user_free)( bee_t *bee, struct bee_user *bu );
84        gboolean (*user_fullname)( bee_t *bee, bee_user_t *bu );
85        gboolean (*user_status)( bee_t *bee, struct bee_user *bu, struct bee_user *old );
86        gboolean (*user_msg)( bee_t *bee, bee_user_t *bu, const char *msg, time_t sent_at );
87        gboolean (*user_typing)( bee_t *bee, bee_user_t *bu, guint32 flags );
88       
89        gboolean (*chat_new)( bee_t *bee, struct groupchat *c );
90        gboolean (*chat_free)( bee_t *bee, struct groupchat *c );
91        gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *text );
92        gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at );
93        gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );
94        gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );
95        gboolean (*chat_topic)( bee_t *bee, struct groupchat *c, const char *new, bee_user_t *bu );
96        gboolean (*chat_name_hint)( bee_t *bee, struct groupchat *c, const char *name );
97       
98        struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size );
99        gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft );
100        void (*ft_close)( struct im_connection *ic, struct file_transfer *ft );
101        void (*ft_finished)( struct im_connection *ic, struct file_transfer *ft );
102} bee_ui_funcs_t;
103
104
105/* bee.c */
106bee_t *bee_new();
107void bee_free( bee_t *b );
108
109/* bee_user.c */
110bee_user_t *bee_user_new( bee_t *bee, struct im_connection *ic, const char *handle, bee_user_flags_t flags );
111int bee_user_free( bee_t *bee, bee_user_t *bu );
112bee_user_t *bee_user_by_handle( bee_t *bee, struct im_connection *ic, const char *handle );
113int bee_user_msg( bee_t *bee, bee_user_t *bu, const char *msg, int flags );
114bee_group_t *bee_group_by_name( bee_t *bee, const char *name, gboolean creat );
115void bee_group_free( bee_t *bee );
116
117/* Callbacks from IM modules to core: */
118/* Buddy activity */
119/* To manipulate the status of a handle.
120 * - flags can be |='d with OPT_* constants. You will need at least:
121 *   OPT_LOGGED_IN and OPT_AWAY.
122 * - 'state' and 'message' can be NULL */
123G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
124/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
125/* Call when a handle says something. 'flags' and 'sent_at may be just 0. */
126G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, guint32 flags, time_t sent_at );
127
128/* bee_chat.c */
129#if 0
130struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle );
131void imcb_chat_name_hint( struct groupchat *c, const char *name );
132void imcb_chat_free( struct groupchat *c );
133void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at );
134void imcb_chat_log( struct groupchat *c, char *format, ... );
135void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at );
136void imcb_chat_add_buddy( struct groupchat *b, const char *handle );
137void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason );
138static int remove_chat_buddy_silent( struct groupchat *b, const char *handle );
139#endif
140int bee_chat_msg( bee_t *bee, struct groupchat *c, const char *msg, int flags );
141struct groupchat *bee_chat_by_title( bee_t *bee, struct im_connection *ic, const char *title );
142
143#endif /* __BEE_H__ */
Note: See TracBrowser for help on using the repository browser.