1 | /********************************************************************\ |
---|
2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
3 | * * |
---|
4 | * Copyright 2002-2004 Wilmer van der Gaast and others * |
---|
5 | \********************************************************************/ |
---|
6 | |
---|
7 | /* |
---|
8 | * nogaim, soon to be known as im_api. Not a separate product (unless |
---|
9 | * someone would be interested in such a thing), just a new name. |
---|
10 | * |
---|
11 | * Gaim without gaim - for BitlBee |
---|
12 | * |
---|
13 | * This file contains functions called by the Gaim IM-modules. It contains |
---|
14 | * some struct and type definitions from Gaim. |
---|
15 | * |
---|
16 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
---|
17 | * (and possibly other members of the Gaim team) |
---|
18 | * Copyright 2002-2007 Wilmer van der Gaast <wilmer@gaast.net> |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | This program is free software; you can redistribute it and/or modify |
---|
23 | it under the terms of the GNU General Public License as published by |
---|
24 | the Free Software Foundation; either version 2 of the License, or |
---|
25 | (at your option) any later version. |
---|
26 | |
---|
27 | This program is distributed in the hope that it will be useful, |
---|
28 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
30 | GNU General Public License for more details. |
---|
31 | |
---|
32 | You should have received a copy of the GNU General Public License with |
---|
33 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
34 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
35 | Suite 330, Boston, MA 02111-1307 USA |
---|
36 | */ |
---|
37 | |
---|
38 | #ifndef _NOGAIM_H |
---|
39 | #define _NOGAIM_H |
---|
40 | |
---|
41 | #include "bitlbee.h" |
---|
42 | #include "account.h" |
---|
43 | #include "proxy.h" |
---|
44 | #include "md5.h" |
---|
45 | #include "sha.h" |
---|
46 | |
---|
47 | #define BUF_LEN MSG_LEN |
---|
48 | #define BUF_LONG ( BUF_LEN * 2 ) |
---|
49 | #define MSG_LEN 2048 |
---|
50 | #define BUF_LEN MSG_LEN |
---|
51 | |
---|
52 | #define SELF_ALIAS_LEN 400 |
---|
53 | #define BUDDY_ALIAS_MAXLEN 388 /* because MSN names can be 387 characters */ |
---|
54 | |
---|
55 | #define WEBSITE "http://www.bitlbee.org/" |
---|
56 | #define GAIM_AWAY_CUSTOM "Custom" |
---|
57 | |
---|
58 | /* Sharing flags between buddies and connections. Or planning to, at least... */ |
---|
59 | #define OPT_LOGGED_IN 0x00000001 |
---|
60 | #define OPT_LOGGING_OUT 0x00000002 |
---|
61 | #define OPT_AWAY 0x00000004 |
---|
62 | #define OPT_DOES_HTML 0x00000010 |
---|
63 | |
---|
64 | /* ok. now the fun begins. first we create a connection structure */ |
---|
65 | struct im_connection |
---|
66 | { |
---|
67 | account_t *acc; |
---|
68 | u_int32_t flags; |
---|
69 | |
---|
70 | /* each connection then can have its own protocol-specific data */ |
---|
71 | void *proto_data; |
---|
72 | |
---|
73 | /* all connections need an input watcher */ |
---|
74 | int inpa; |
---|
75 | guint keepalive; |
---|
76 | |
---|
77 | /* buddy list stuff. there is still a global groups for the buddy list, but |
---|
78 | * we need to maintain our own set of buddies, and our own permit/deny lists */ |
---|
79 | GSList *permit; |
---|
80 | GSList *deny; |
---|
81 | int permdeny; |
---|
82 | |
---|
83 | char displayname[128]; |
---|
84 | char *away; |
---|
85 | |
---|
86 | int evil; |
---|
87 | |
---|
88 | /* BitlBee */ |
---|
89 | irc_t *irc; |
---|
90 | |
---|
91 | struct groupchat *conversations; |
---|
92 | }; |
---|
93 | |
---|
94 | /* struct buddy_chat went away and got merged with this. */ |
---|
95 | struct groupchat { |
---|
96 | struct im_connection *ic; |
---|
97 | |
---|
98 | /* stuff used just for chat */ |
---|
99 | GList *in_room; |
---|
100 | GList *ignored; |
---|
101 | |
---|
102 | /* BitlBee */ |
---|
103 | struct groupchat *next; |
---|
104 | char *channel; |
---|
105 | char *title; |
---|
106 | char joined; |
---|
107 | void *data; |
---|
108 | }; |
---|
109 | |
---|
110 | struct buddy { |
---|
111 | char name[80]; |
---|
112 | char show[BUDDY_ALIAS_MAXLEN]; |
---|
113 | int present; |
---|
114 | int evil; |
---|
115 | time_t signon; |
---|
116 | time_t idle; |
---|
117 | int uc; |
---|
118 | guint caps; /* woohoo! */ |
---|
119 | void *proto_data; /* what a hack */ |
---|
120 | struct im_connection *ic; /* the connection it belongs to */ |
---|
121 | }; |
---|
122 | |
---|
123 | struct prpl { |
---|
124 | int options; |
---|
125 | const char *name; |
---|
126 | |
---|
127 | /* Added this one to be able to add per-account settings, don't think |
---|
128 | it should be used for anything else. */ |
---|
129 | void (* init) (account_t *); |
---|
130 | /* These should all be pretty obvious. */ |
---|
131 | void (* login) (account_t *); |
---|
132 | void (* keepalive) (struct im_connection *); |
---|
133 | void (* logout) (struct im_connection *); |
---|
134 | |
---|
135 | int (* send_im) (struct im_connection *, char *to, char *message, int flags); |
---|
136 | void (* set_away) (struct im_connection *, char *state, char *message); |
---|
137 | void (* get_away) (struct im_connection *, char *who); |
---|
138 | int (* send_typing) (struct im_connection *, char *who, int typing); |
---|
139 | |
---|
140 | /* For now BitlBee doesn't really handle groups, just set it to NULL. */ |
---|
141 | void (* add_buddy) (struct im_connection *, char *name, char *group); |
---|
142 | void (* remove_buddy) (struct im_connection *, char *name, char *group); |
---|
143 | |
---|
144 | /* Block list stuff. */ |
---|
145 | void (* add_permit) (struct im_connection *, char *who); |
---|
146 | void (* add_deny) (struct im_connection *, char *who); |
---|
147 | void (* rem_permit) (struct im_connection *, char *who); |
---|
148 | void (* rem_deny) (struct im_connection *, char *who); |
---|
149 | /* Doesn't actually have UI hooks. */ |
---|
150 | void (* set_permit_deny)(struct im_connection *); |
---|
151 | |
---|
152 | /* Request profile info. Free-formatted stuff, the IM module gives back |
---|
153 | this info via imcb_log(). */ |
---|
154 | void (* get_info) (struct im_connection *, char *who); |
---|
155 | void (* set_my_name) (struct im_connection *, char *name); |
---|
156 | void (* set_name) (struct im_connection *, char *who, char *name); |
---|
157 | |
---|
158 | /* Group chat stuff. */ |
---|
159 | void (* chat_invite) (struct groupchat *, char *who, char *message); |
---|
160 | void (* chat_leave) (struct groupchat *); |
---|
161 | void (* chat_send) (struct groupchat *, char *message, int flags); |
---|
162 | struct groupchat * |
---|
163 | (* chat_with) (struct im_connection *, char *who); |
---|
164 | struct groupchat * |
---|
165 | (* chat_join) (struct im_connection *, char *chat, char *nick, char *password); |
---|
166 | |
---|
167 | GList *(* away_states)(struct im_connection *ic); |
---|
168 | |
---|
169 | /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ |
---|
170 | int (* handle_cmp) (const char *who1, const char *who2); |
---|
171 | }; |
---|
172 | |
---|
173 | #define UC_UNAVAILABLE 1 |
---|
174 | |
---|
175 | /* im_api core stuff. */ |
---|
176 | void nogaim_init(); |
---|
177 | G_MODULE_EXPORT GSList *get_connections(); |
---|
178 | G_MODULE_EXPORT struct prpl *find_protocol(const char *name); |
---|
179 | G_MODULE_EXPORT void register_protocol(struct prpl *); |
---|
180 | |
---|
181 | /* Connection management. */ |
---|
182 | G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc ); |
---|
183 | G_MODULE_EXPORT void imcb_free( struct im_connection *ic ); |
---|
184 | G_MODULE_EXPORT void imcb_connected( struct im_connection *ic ); |
---|
185 | G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect ); |
---|
186 | |
---|
187 | /* Communicating with the user. */ |
---|
188 | G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... ); |
---|
189 | G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... ); |
---|
190 | G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ); |
---|
191 | G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname ); |
---|
192 | |
---|
193 | /* Groupchats */ |
---|
194 | G_MODULE_EXPORT void add_chat_buddy( struct groupchat *b, char *handle ); |
---|
195 | G_MODULE_EXPORT void remove_chat_buddy( struct groupchat *b, char *handle, char *reason ); |
---|
196 | G_MODULE_EXPORT void serv_got_chat_invite( struct im_connection *ic, char *handle, char *who, char *msg, GList *data ); |
---|
197 | G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle ); |
---|
198 | G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime ); |
---|
199 | G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c ); |
---|
200 | struct groupchat *chat_by_channel( char *channel ); |
---|
201 | |
---|
202 | /* Buddy management */ |
---|
203 | G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname ); |
---|
204 | G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle ); |
---|
205 | G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname ); |
---|
206 | |
---|
207 | /* Buddy activity */ |
---|
208 | G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); |
---|
209 | /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); |
---|
210 | G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); |
---|
211 | G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type ); |
---|
212 | |
---|
213 | /* Actions, or whatever. */ |
---|
214 | int imc_set_away( struct im_connection *ic, char *away ); |
---|
215 | int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags ); |
---|
216 | int imc_chat_msg( struct groupchat *c, char *msg, int flags ); |
---|
217 | |
---|
218 | void imc_add_allow( struct im_connection *ic, char *handle ); |
---|
219 | void imc_rem_allow( struct im_connection *ic, char *handle ); |
---|
220 | void imc_add_block( struct im_connection *ic, char *handle ); |
---|
221 | void imc_rem_block( struct im_connection *ic, char *handle ); |
---|
222 | |
---|
223 | /* Misc. stuff */ |
---|
224 | char *set_eval_away_devoice( set_t *set, char *value ); |
---|
225 | gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond ); |
---|
226 | void cancel_auto_reconnect( struct account *a ); |
---|
227 | |
---|
228 | #endif |
---|