source: protocols/nogaim.h @ 7b23afd

Last change on this file since 7b23afd was 7b23afd, checked in by Jelmer Vernooij <jelmer@…>, at 2005-11-07T16:16:18Z

Migrate my pluginable branch to use Wilmers' branch as parent

  • Property mode set to 100644
File size: 12.2 KB
Line 
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
9 *
10 * Gaim without gaim - for BitlBee
11 *
12 * This file contains functions called by the Gaim IM-modules. It contains
13 * some struct and type definitions from Gaim.
14 *
15 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
16 *                          (and possibly other members of the Gaim team)
17 * Copyright 2002-2004 Wilmer van der Gaast <lintux@lintux.cx>
18 */
19
20/*
21  This program is free software; you can redistribute it and/or modify
22  it under the terms of the GNU General Public License as published by
23  the Free Software Foundation; either version 2 of the License, or
24  (at your option) any later version.
25
26  This program is distributed in the hope that it will be useful,
27  but WITHOUT ANY WARRANTY; without even the implied warranty of
28  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  GNU General Public License for more details.
30
31  You should have received a copy of the GNU General Public License with
32  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
33  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
34  Suite 330, Boston, MA  02111-1307  USA
35*/
36
37#ifndef _NOGAIM_H
38#define _NOGAIM_H
39
40#include "bitlbee.h"
41#include "proxy.h"
42#include "md5.h"
43#include "sha.h"
44
45
46#define BUF_LEN MSG_LEN
47#define BUF_LONG ( BUF_LEN * 2 )
48#define MSG_LEN 2048
49#define BUF_LEN MSG_LEN
50
51#define SELF_ALIAS_LEN 400
52#define BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
53
54#define PERMIT_ALL      1
55#define PERMIT_NONE     2
56#define PERMIT_SOME     3
57#define DENY_SOME       4
58
59#define WEBSITE "http://www.bitlee.org/"
60#define IM_FLAG_AWAY 0x0020
61#define OPT_CONN_HTML 0x00000001
62#define OPT_LOGGED_IN 0x00010000
63#define GAIM_AWAY_CUSTOM "Custom"
64
65#define GAIM_LOGO       0
66#define GAIM_ERROR      1
67#define GAIM_WARNING    2
68#define GAIM_INFO       3
69
70/* ok. now the fun begins. first we create a connection structure */
71struct gaim_connection {
72        /* we need to do either oscar or TOC */
73        /* we make this as an int in case if we want to add more protocols later */
74        struct prpl *prpl;
75        guint32 flags;
76       
77        /* all connections need an input watcher */
78        int inpa;
79       
80        /* buddy list stuff. there is still a global groups for the buddy list, but
81         * we need to maintain our own set of buddies, and our own permit/deny lists */
82        GSList *permit;
83        GSList *deny;
84        int permdeny;
85       
86        /* all connections need a list of chats, even if they don't have chat */
87        GSList *buddy_chats;
88       
89        /* each connection then can have its own protocol-specific data */
90        void *proto_data;
91       
92        struct aim_user *user;
93       
94        char username[64];
95        char displayname[128];
96        char password[32];
97        guint keepalive;
98        /* stuff needed for per-connection idle times */
99        guint idle_timer;
100        time_t login_time;
101        time_t lastsent;
102        int is_idle;
103       
104        char *away;
105        int is_auto_away;
106       
107        int evil;
108        gboolean wants_to_die; /* defaults to FALSE */
109       
110        /* BitlBee */
111        irc_t *irc;
112        int lstitems;  /* added for msnP8 */
113       
114        struct conversation *conversations;
115};
116
117/* struct buddy_chat went away and got merged with this. */
118struct conversation {
119        struct gaim_connection *gc;
120
121        /* stuff used just for chat */
122        GList *in_room;
123        GList *ignored;
124        int id;
125       
126        /* BitlBee */
127        struct conversation *next;
128        char *channel;
129        char *title;
130        char joined;
131        void *data;
132};
133
134struct buddy {
135        char name[80];
136        char show[BUDDY_ALIAS_MAXLEN];
137        int present;
138        int evil;
139        time_t signon;
140        time_t idle;
141        int uc;
142        guint caps; /* woohoo! */
143        void *proto_data; /* what a hack */
144        struct gaim_connection *gc; /* the connection it belongs to */
145};
146
147struct aim_user {
148        char username[64];
149        char alias[SELF_ALIAS_LEN]; 
150        char password[32];
151        char user_info[2048];
152        int options;
153        struct prpl *prpl;
154        /* prpls can use this to save information about the user,
155         * like which server to connect to, etc */
156        char proto_opt[7][256];
157
158        struct gaim_connection *gc;
159        irc_t *irc;
160};
161
162struct ft
163{
164        const char *filename;
165       
166        /* Total number of bytes in file */
167        size_t total_bytes;
168       
169        /* Current number of bytes received */
170        size_t cur_bytes;
171};
172
173struct ft_request
174{
175        const char *filename;
176        struct gaim_connection *gc;
177};
178
179typedef void (*ft_recv_handler) (struct ft *, void *data, size_t len);
180
181struct prpl {
182        int options;
183        const char *name;
184
185        /* for ICQ and Yahoo, who have off/on per-conversation options */
186        /* char *checkbox; this should be per-connection */
187
188        GList *(* away_states)(struct gaim_connection *gc);
189        GList *(* actions)();
190        void   (* do_action)(struct gaim_connection *, char *);
191        /* user_opts returns a GList* of g_malloc'd struct proto_user_opts */
192        GList *(* user_opts)();
193        GList *(* chat_info)(struct gaim_connection *);
194
195        /* all the server-related functions */
196
197        /* a lot of these (like get_dir) are protocol-dependent and should be removed. ones like
198         * set_dir (which is also protocol-dependent) can stay though because there's a dialog
199         * (i.e. the prpl says you can set your dir info, the ui shows a dialog and needs to call
200         * set_dir in order to set it) */
201
202        void (* login)          (struct aim_user *);
203        void (* close)          (struct gaim_connection *);
204        int  (* send_im)        (struct gaim_connection *, char *who, char *message, int len, int away);
205        int  (* send_typing)    (struct gaim_connection *, char *who, int typing);
206        void (* set_info)       (struct gaim_connection *, char *info);
207        void (* get_info)       (struct gaim_connection *, char *who);
208        void (* set_away)       (struct gaim_connection *, char *state, char *message);
209        void (* get_away)       (struct gaim_connection *, char *who);
210        void (* set_idle)       (struct gaim_connection *, int idletime);
211        void (* add_buddy)      (struct gaim_connection *, char *name);
212        void (* remove_buddy)   (struct gaim_connection *, char *name, char *group);
213        void (* add_permit)     (struct gaim_connection *, char *name);
214        void (* add_deny)       (struct gaim_connection *, char *name);
215        void (* rem_permit)     (struct gaim_connection *, char *name);
216        void (* rem_deny)       (struct gaim_connection *, char *name);
217        void (* set_permit_deny)(struct gaim_connection *);
218        void (* join_chat)      (struct gaim_connection *, GList *data);
219        void (* chat_invite)    (struct gaim_connection *, int id, char *who, char *message);
220        void (* chat_leave)     (struct gaim_connection *, int id);
221        void (* chat_whisper)   (struct gaim_connection *, int id, char *who, char *message);
222        int  (* chat_send)      (struct gaim_connection *, int id, char *message);
223        int  (* chat_open)      (struct gaim_connection *, char *who);
224        void (* keepalive)      (struct gaim_connection *);
225
226        /* get "chat buddy" info and away message */
227        void (* get_cb_info)    (struct gaim_connection *, int, char *who);
228        void (* get_cb_away)    (struct gaim_connection *, int, char *who);
229
230        /* save/store buddy's alias on server list/roster */
231        void (* alias_buddy)    (struct gaim_connection *, char *who);
232
233        /* change a buddy's group on a server list/roster */
234        void (* group_buddy)    (struct gaim_connection *, char *who, char *old_group, char *new_group);
235
236        /* file transfers */
237        struct ft_send_req *(* req_send_file) (struct gaim_connection *, const char *file);
238        void (* send_file_part) (struct gaim_connection *, struct ft*, void *data, size_t length);
239        void (* accept_recv_file) (struct gaim_connection *, struct ft*, ft_recv_handler);
240
241        void (* buddy_free)     (struct buddy *);
242
243        char *(* get_status_string) (struct gaim_connection *gc, int stat);
244};
245
246#define UC_UNAVAILABLE  1
247
248/* JABBER */
249#define UC_AWAY (0x02 | UC_UNAVAILABLE)
250#define UC_CHAT  0x04
251#define UC_XA   (0x08 | UC_UNAVAILABLE)
252#define UC_DND  (0x10 | UC_UNAVAILABLE)
253
254G_MODULE_EXPORT GSList *get_connections();
255G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
256G_MODULE_EXPORT void register_protocol(struct prpl *);
257
258/* nogaim.c */
259int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags);
260int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg );
261
262G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf );
263char *set_eval_charset( irc_t *irc, set_t *set, char *value );
264
265void nogaim_init();
266int proto_away( struct gaim_connection *gc, char *away );
267char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value );
268int handle_cmp( char *a, char *b, struct prpl *protocol );
269
270gboolean auto_reconnect( gpointer data );
271void cancel_auto_reconnect( struct account *a );
272
273/* multi.c */
274G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( struct aim_user *user );
275G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc );
276G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg );
277G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg );
278G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg );
279G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... );
280G_MODULE_EXPORT void account_online( struct gaim_connection *gc );
281G_MODULE_EXPORT void account_offline( struct gaim_connection *gc );
282G_MODULE_EXPORT void signoff( struct gaim_connection *gc );
283
284/* dialogs.c */
285G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title );
286G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont );
287
288/* list.c */
289G_MODULE_EXPORT int bud_list_cache_exists( struct gaim_connection *gc );
290G_MODULE_EXPORT void do_import( struct gaim_connection *gc, void *null );
291G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname );
292G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle );
293G_MODULE_EXPORT void do_export( struct gaim_connection *gc );
294G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc );
295
296G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname );
297
298/* buddy_chat.c */
299G_MODULE_EXPORT void add_chat_buddy( struct conversation *b, char *handle );
300G_MODULE_EXPORT void remove_chat_buddy( struct conversation *b, char *handle, char *reason );
301
302/* prpl.c */
303G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg );
304
305/* server.c */                   
306G_MODULE_EXPORT void serv_got_update( struct gaim_connection *gc, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
307G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
308G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout );
309G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data );
310G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle );
311G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime );
312G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id );
313/* void serv_finish_login( struct gaim_connection *gc ); */
314
315/* util.c */
316G_MODULE_EXPORT char *utf8_to_str( const char *in );
317G_MODULE_EXPORT char *str_to_utf8( const char *in );
318G_MODULE_EXPORT void strip_linefeed( gchar *text );
319G_MODULE_EXPORT char *add_cr( char *text );
320G_MODULE_EXPORT char *tobase64( const char *text );
321G_MODULE_EXPORT char *normalize( const char *s );
322G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec );
323G_MODULE_EXPORT void strip_html( char *msg );
324G_MODULE_EXPORT char * escape_html(const char *html);
325G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value);
326
327/* file transfers */
328G_MODULE_EXPORT void ft_progress( struct ft *, int);
329G_MODULE_EXPORT void ft_incoming( struct ft_request * );
330G_MODULE_EXPORT void ft_accepted( struct ft_request *, struct ft *);
331G_MODULE_EXPORT void ft_denied( struct ft_request *, const char *reason);
332
333/* prefs.c */
334G_MODULE_EXPORT void build_block_list();
335G_MODULE_EXPORT void build_allow_list();
336
337struct conversation *conv_findchannel( char *channel );
338
339
340#endif
Note: See TracBrowser for help on using the repository browser.