source: protocols/nogaim.h @ 84b045d

Last change on this file since 84b045d was 84b045d, checked in by Wilmer van der Gaast <wilmer@…>, at 2007-04-16T01:03:08Z

s/imc/imcb/ for callback functions. Moved things aroundin nogaim.h a
little bit, grouping things by category instead of original Gaim 0.58
filename.

  • Property mode set to 100644
File size: 8.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 <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 displayname[128];
83        char *away;
84       
85        int evil;
86       
87        /* BitlBee */
88        irc_t *irc;
89       
90        struct groupchat *conversations;
91};
92
93/* struct buddy_chat went away and got merged with this. */
94struct groupchat {
95        struct im_connection *ic;
96
97        /* stuff used just for chat */
98        GList *in_room;
99        GList *ignored;
100       
101        /* BitlBee */
102        struct groupchat *next;
103        char *channel;
104        char *title;
105        char joined;
106        void *data;
107};
108
109struct buddy {
110        char name[80];
111        char show[BUDDY_ALIAS_MAXLEN];
112        int present;
113        int evil;
114        time_t signon;
115        time_t idle;
116        int uc;
117        guint caps; /* woohoo! */
118        void *proto_data; /* what a hack */
119        struct im_connection *ic; /* the connection it belongs to */
120};
121
122struct prpl {
123        int options;
124        const char *name;
125
126        /* Added this one to be able to add per-account settings, don't think
127           it should be used for anything else. */
128        void (* init)           (account_t *);
129        /* These should all be pretty obvious. */
130        void (* login)          (account_t *);
131        void (* keepalive)      (struct im_connection *);
132        void (* logout)         (struct im_connection *);
133       
134        int  (* send_im)        (struct im_connection *, char *to, char *message, int flags);
135        void (* set_away)       (struct im_connection *, char *state, char *message);
136        void (* get_away)       (struct im_connection *, char *who);
137        int  (* send_typing)    (struct im_connection *, char *who, int typing);
138       
139        /* For now BitlBee doesn't really handle groups, just set it to NULL. */
140        void (* add_buddy)      (struct im_connection *, char *name, char *group);
141        void (* remove_buddy)   (struct im_connection *, char *name, char *group);
142       
143        /* Block list stuff. */
144        void (* add_permit)     (struct im_connection *, char *who);
145        void (* add_deny)       (struct im_connection *, char *who);
146        void (* rem_permit)     (struct im_connection *, char *who);
147        void (* rem_deny)       (struct im_connection *, char *who);
148        /* Doesn't actually have UI hooks. */
149        void (* set_permit_deny)(struct im_connection *);
150       
151        /* Request profile info. Free-formatted stuff, the IM module gives back
152           this info via imcb_log(). */
153        void (* get_info)       (struct im_connection *, char *who);
154        void (* set_my_name)    (struct im_connection *, char *name);
155        void (* set_name)       (struct im_connection *, char *who, char *name);
156       
157        /* Group chat stuff. */
158        void (* chat_invite)    (struct groupchat *, char *who, char *message);
159        void (* chat_leave)     (struct groupchat *);
160        void (* chat_send)      (struct groupchat *, char *message, int flags);
161        struct groupchat *
162             (* chat_with)      (struct im_connection *, char *who);
163        struct groupchat *
164             (* chat_join)      (struct im_connection *, char *chat, char *nick, char *password);
165       
166        /* DIE! */
167        char *(* get_status_string) (struct im_connection *ic, int stat);
168       
169        GList *(* away_states)(struct im_connection *ic);
170       
171        /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */
172        int (* handle_cmp) (const char *who1, const char *who2);
173};
174
175#define UC_UNAVAILABLE  1
176
177/* im_api core stuff. */
178void nogaim_init();
179G_MODULE_EXPORT GSList *get_connections();
180G_MODULE_EXPORT struct prpl *find_protocol(const char *name);
181G_MODULE_EXPORT void register_protocol(struct prpl *);
182
183/* Connection management. */
184G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc );
185G_MODULE_EXPORT void imcb_free( struct im_connection *ic );
186G_MODULE_EXPORT void imcb_connected( struct im_connection *ic );
187G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect );
188
189/* Communicating with the user. */
190G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... );
191G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... );
192G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont );
193G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname );
194
195/* Groupchats */
196G_MODULE_EXPORT void add_chat_buddy( struct groupchat *b, char *handle );
197G_MODULE_EXPORT void remove_chat_buddy( struct groupchat *b, char *handle, char *reason );
198G_MODULE_EXPORT void serv_got_chat_invite( struct im_connection *ic, char *handle, char *who, char *msg, GList *data );
199G_MODULE_EXPORT struct groupchat *serv_got_joined_chat( struct im_connection *ic, char *handle );
200G_MODULE_EXPORT void serv_got_chat_in( struct groupchat *c, char *who, int whisper, char *msg, time_t mtime );
201G_MODULE_EXPORT void serv_got_chat_left( struct groupchat *c );
202struct groupchat *chat_by_channel( char *channel );
203struct groupchat *chat_by_id( int id );
204
205/* Buddy management */
206G_MODULE_EXPORT void add_buddy( struct im_connection *ic, char *group, char *handle, char *realname );
207G_MODULE_EXPORT struct buddy *find_buddy( struct im_connection *ic, char *handle );
208G_MODULE_EXPORT void serv_buddy_rename( struct im_connection *ic, char *handle, char *realname );
209
210/* Buddy activity */
211G_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 );
212G_MODULE_EXPORT void serv_got_im( struct im_connection *ic, char *handle, char *msg, guint32 flags, time_t mtime, gint len );
213G_MODULE_EXPORT void serv_got_typing( struct im_connection *ic, char *handle, int timeout, int type );
214
215/* Actions, or whatever. */
216int imc_set_away( struct im_connection *ic, char *away );
217int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
218int imc_chat_msg( struct groupchat *c, char *msg, int flags );
219
220void imc_add_allow( struct im_connection *ic, char *handle );
221void imc_rem_allow( struct im_connection *ic, char *handle );
222void imc_add_block( struct im_connection *ic, char *handle );
223void imc_rem_block( struct im_connection *ic, char *handle );
224
225/* Misc. stuff */
226char *set_eval_away_devoice( set_t *set, char *value );
227gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
228void cancel_auto_reconnect( struct account *a );
229
230#endif
Note: See TracBrowser for help on using the repository browser.