source: protocols/nogaim.h @ 0da65d5

Last change on this file since 0da65d5 was 0da65d5, checked in by Wilmer van der Gaast <wilmer@…>, at 2007-03-31T05:40:45Z

s/gaim_connection/im_connection/ and some other minor API changes. The rest
will come tomorrow. It compiles, I'll leave the real testing up to someone
else. ;-)

  • Property mode set to 100644
File size: 8.7 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 <wilmer@gaast.net>
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 "account.h"
42#include "proxy.h"
43#include "md5.h"
44#include "sha.h"
45
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 IM_FLAG_AWAY 0x0020
57#define GAIM_AWAY_CUSTOM "Custom"
58
59#define OPT_CONN_HTML   0x00000001
60#define OPT_LOGGED_IN   0x00010000
61#define OPT_LOGGING_OUT 0x00020000
62
63/* ok. now the fun begins. first we create a connection structure */
64struct im_connection
65{
66        account_t *acc;
67        guint32 flags;
68       
69        /* each connection then can have its own protocol-specific data */
70        void *proto_data;
71       
72        /* all connections need an input watcher */
73        int inpa;
74        guint keepalive;
75       
76        /* buddy list stuff. there is still a global groups for the buddy list, but
77         * we need to maintain our own set of buddies, and our own permit/deny lists */
78        GSList *permit;
79        GSList *deny;
80        int permdeny;
81       
82        char username[64];
83        char displayname[128];
84        char password[32];
85       
86        char *away;
87       
88        int evil;
89        gboolean wants_to_die; /* defaults to FALSE */
90       
91        /* BitlBee */
92        irc_t *irc;
93       
94        struct groupchat *conversations;
95};
96
97/* struct buddy_chat went away and got merged with this. */
98struct groupchat {
99        struct im_connection *ic;
100
101        /* stuff used just for chat */
102        GList *in_room;
103        GList *ignored;
104       
105        /* BitlBee */
106        struct groupchat *next;
107        char *channel;
108        char *title;
109        char joined;
110        void *data;
111};
112
113struct buddy {
114        char name[80];
115        char show[BUDDY_ALIAS_MAXLEN];
116        int present;
117        int evil;
118        time_t signon;
119        time_t idle;
120        int uc;
121        guint caps; /* woohoo! */
122        void *proto_data; /* what a hack */
123        struct im_connection *ic; /* the connection it belongs to */
124};
125
126struct prpl {
127        int options;
128        const char *name;
129
130        /* Added this one to be able to add per-account settings, don't think
131           it should be used for anything else. */
132        void (* init)           (account_t *);
133        /* These should all be pretty obvious. */
134        void (* login)          (account_t *);
135        void (* keepalive)      (struct im_connection *);
136        void (* logout)         (struct im_connection *);
137       
138        int  (* send_im)        (struct im_connection *, char *to, char *message, int flags);
139        void (* set_away)       (struct im_connection *, char *state, char *message);
140        void (* get_away)       (struct im_connection *, char *who);
141        int  (* send_typing)    (struct im_connection *, char *who, int typing);
142       
143        /* For now BitlBee doesn't really handle groups, just set it to NULL. */
144        void (* add_buddy)      (struct im_connection *, char *name, char *group);
145        void (* remove_buddy)   (struct im_connection *, char *name, char *group);
146       
147        /* Block list stuff. */
148        void (* add_permit)     (struct im_connection *, char *who);
149        void (* add_deny)       (struct im_connection *, char *who);
150        void (* rem_permit)     (struct im_connection *, char *who);
151        void (* rem_deny)       (struct im_connection *, char *who);
152        /* Doesn't actually have UI hooks. */
153        void (* set_permit_deny)(struct im_connection *);
154       
155        /* Request profile info. Free-formatted stuff, the IM module gives back
156           this info via imc_log(). */
157        void (* get_info)       (struct im_connection *, char *who);
158        void (* set_my_name)    (struct im_connection *, char *name);
159        void (* set_name)       (struct im_connection *, char *who, char *name);
160       
161        /* Group chat stuff. */
162        void (* chat_invite)    (struct groupchat *, char *who, char *message);
163        void (* chat_leave)     (struct groupchat *);
164        void (* chat_send)      (struct groupchat *, char *message, int flags);
165        struct groupchat *
166             (* chat_with)      (struct im_connection *, char *who);
167        struct groupchat *
168             (* chat_join)      (struct im_connection *, char *chat, char *nick, char *password);
169       
170        /* DIE! */
171        char *(* get_status_string) (struct im_connection *ic, int stat);
172       
173        GList *(* away_states)(struct im_connection *ic);
174       
175        /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */
176        int (* handle_cmp) (const char *who1, const char *who2);
177};
178
179#define UC_UNAVAILABLE  1
180
181/* JABBER */
182#define UC_AWAY (0x02 | UC_UNAVAILABLE)
183#define UC_CHAT  0x04
184#define UC_XA   (0x08 | UC_UNAVAILABLE)
185#define UC_DND  (0x10 | UC_UNAVAILABLE)
186
187G_MODULE_EXPORT GSList *get_connections();
188G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
189G_MODULE_EXPORT void register_protocol(struct prpl *);
190
191/* nogaim.c */
192int bim_set_away( struct im_connection *ic, char *away );
193int bim_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
194int bim_chat_msg( struct groupchat *c, char *msg, int flags );
195
196void bim_add_allow( struct im_connection *ic, char *handle );
197void bim_rem_allow( struct im_connection *ic, char *handle );
198void bim_add_block( struct im_connection *ic, char *handle );
199void bim_rem_block( struct im_connection *ic, char *handle );
200
201void nogaim_init();
202char *set_eval_away_devoice( set_t *set, char *value );
203
204gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
205void cancel_auto_reconnect( struct account *a );
206
207/* multi.c */
208G_MODULE_EXPORT struct im_connection *new_gaim_conn( account_t *acc );
209G_MODULE_EXPORT void destroy_gaim_conn( struct im_connection *ic );
210G_MODULE_EXPORT void set_login_progress( struct im_connection *ic, int step, char *msg );
211G_MODULE_EXPORT void hide_login_progress( struct im_connection *ic, char *msg );
212G_MODULE_EXPORT void hide_login_progress_error( struct im_connection *ic, char *msg );
213G_MODULE_EXPORT void serv_got_crap( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
214G_MODULE_EXPORT void account_online( struct im_connection *ic );
215G_MODULE_EXPORT void signoff( struct im_connection *ic );
216
217/* dialogs.c */
218G_MODULE_EXPORT void do_error_dialog( struct im_connection *ic, char *msg, char *title );
219G_MODULE_EXPORT void do_ask_dialog( struct im_connection *ic, char *msg, void *data, void *doit, void *dont );
220
221/* list.c */
222G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname );
223G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle );
224G_MODULE_EXPORT void signoff_blocked( struct im_connection *ic );
225
226G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname );
227
228/* buddy_chat.c */
229G_MODULE_EXPORT void add_chat_buddy( struct groupchat *b, char *handle );
230G_MODULE_EXPORT void remove_chat_buddy( struct groupchat *b, char *handle, char *reason );
231
232/* prpl.c */
233G_MODULE_EXPORT void show_got_added( struct im_connection *ic, char *handle, const char *realname );
234
235/* server.c */
236G_MODULE_EXPORT void serv_got_update( struct im_connection *ic, char *handle, int loggedin, int evil, time_t signon, time_t idle, int type, guint caps );
237G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
238G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type );
239G_MODULE_EXPORT void serv_got_chat_invite( struct im_connection *ic, char *handle, char *who, char *msg, GList *data );
240G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle );
241G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime );
242G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c );
243
244struct groupchat *chat_by_channel( char *channel );
245struct groupchat *chat_by_id( int id );
246
247#endif
Note: See TracBrowser for help on using the repository browser.