source: protocols/nogaim.h @ f6c963b

Last change on this file since f6c963b was f6c963b, checked in by Wilmer van der Gaast <wilmer@…>, at 2007-04-21T04:13:21Z

Renamed some more prpl functions.

  • Property mode set to 100644
File size: 8.5 KB
RevLine 
[b7d3cc34]1  /********************************************************************\
2  * BitlBee -- An IRC to other IM-networks gateway                     *
3  *                                                                    *
4  * Copyright 2002-2004 Wilmer van der Gaast and others                *
5  \********************************************************************/
6
7/*
[6bbb939]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.
[b7d3cc34]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)
[6bbb939]18 * Copyright 2002-2007 Wilmer van der Gaast <wilmer@gaast.net>
[b7d3cc34]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"
[0a3c243]42#include "account.h"
[b7d3cc34]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 BUDDY_ALIAS_MAXLEN 388   /* because MSN names can be 387 characters */
53
[1c8a7a2]54#define WEBSITE "http://www.bitlbee.org/"
[b7d3cc34]55#define GAIM_AWAY_CUSTOM "Custom"
56
[9624fdf]57/* Sharing flags between all kinds of things. I just hope I won't hit any
58   limits before 32-bit machines become extinct. ;-) */
[6bbb939]59#define OPT_LOGGED_IN   0x00000001
60#define OPT_LOGGING_OUT 0x00000002
61#define OPT_AWAY        0x00000004
62#define OPT_DOES_HTML   0x00000010
[9624fdf]63#define OPT_TYPING      0x00000100
64#define OPT_THINKING    0x00000200
[fb62f81f]65
[b7d3cc34]66/* ok. now the fun begins. first we create a connection structure */
[0da65d5]67struct im_connection
[192b80a]68{
[0a3c243]69        account_t *acc;
[6bbb939]70        u_int32_t flags;
[b7d3cc34]71       
[192b80a]72        /* each connection then can have its own protocol-specific data */
73        void *proto_data;
74       
[b7d3cc34]75        /* all connections need an input watcher */
76        int inpa;
[192b80a]77        guint keepalive;
[b7d3cc34]78       
79        /* buddy list stuff. there is still a global groups for the buddy list, but
80         * we need to maintain our own set of buddies, and our own permit/deny lists */
81        GSList *permit;
82        GSList *deny;
83        int permdeny;
84       
85        char displayname[128];
86        char *away;
87       
88        int evil;
89       
90        /* BitlBee */
91        irc_t *irc;
92       
[0da65d5]93        struct groupchat *conversations;
[b7d3cc34]94};
95
[0da65d5]96struct groupchat {
97        struct im_connection *ic;
[b7d3cc34]98
99        /* stuff used just for chat */
[fa29d093]100        GList *in_room;
101        GList *ignored;
102       
103        /* BitlBee */
[0da65d5]104        struct groupchat *next;
[fa29d093]105        char *channel;
106        char *title;
107        char joined;
108        void *data;
[b7d3cc34]109};
110
111struct buddy {
112        char name[80];
113        char show[BUDDY_ALIAS_MAXLEN];
[fa29d093]114        int present;
[b7d3cc34]115        int evil;
116        time_t signon;
117        time_t idle;
[fa29d093]118        int uc;
[b7d3cc34]119        guint caps; /* woohoo! */
120        void *proto_data; /* what a hack */
[0da65d5]121        struct im_connection *ic; /* the connection it belongs to */
[b7d3cc34]122};
123
124struct prpl {
125        int options;
[7b23afd]126        const char *name;
[b7d3cc34]127
[0da65d5]128        /* Added this one to be able to add per-account settings, don't think
129           it should be used for anything else. */
130        void (* init)           (account_t *);
131        /* These should all be pretty obvious. */
[0a3c243]132        void (* login)          (account_t *);
[0da65d5]133        void (* keepalive)      (struct im_connection *);
134        void (* logout)         (struct im_connection *);
135       
[f6c963b]136        int  (* buddy_msg)      (struct im_connection *, char *to, char *message, int flags);
[0da65d5]137        void (* set_away)       (struct im_connection *, char *state, char *message);
138        void (* get_away)       (struct im_connection *, char *who);
[9624fdf]139        int  (* send_typing)    (struct im_connection *, char *who, int flags);
[0da65d5]140       
141        /* For now BitlBee doesn't really handle groups, just set it to NULL. */
142        void (* add_buddy)      (struct im_connection *, char *name, char *group);
143        void (* remove_buddy)   (struct im_connection *, char *name, char *group);
144       
145        /* Block list stuff. */
146        void (* add_permit)     (struct im_connection *, char *who);
147        void (* add_deny)       (struct im_connection *, char *who);
148        void (* rem_permit)     (struct im_connection *, char *who);
149        void (* rem_deny)       (struct im_connection *, char *who);
150        /* Doesn't actually have UI hooks. */
151        void (* set_permit_deny)(struct im_connection *);
152       
153        /* Request profile info. Free-formatted stuff, the IM module gives back
[84b045d]154           this info via imcb_log(). */
[0da65d5]155        void (* get_info)       (struct im_connection *, char *who);
156        void (* set_my_name)    (struct im_connection *, char *name);
157        void (* set_name)       (struct im_connection *, char *who, char *name);
[192b80a]158       
159        /* Group chat stuff. */
[0da65d5]160        void (* chat_invite)    (struct groupchat *, char *who, char *message);
161        void (* chat_leave)     (struct groupchat *);
[f6c963b]162        void (* chat_msg)       (struct groupchat *, char *message, int flags);
[0da65d5]163        struct groupchat *
164             (* chat_with)      (struct im_connection *, char *who);
165        struct groupchat *
166             (* chat_join)      (struct im_connection *, char *chat, char *nick, char *password);
[192b80a]167       
[0da65d5]168        GList *(* away_states)(struct im_connection *ic);
[192b80a]169       
170        /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */
[5b52a48]171        int (* handle_cmp) (const char *who1, const char *who2);
[b7d3cc34]172};
173
[84b045d]174/* im_api core stuff. */
175void nogaim_init();
[b7d3cc34]176G_MODULE_EXPORT GSList *get_connections();
[f6c963b]177G_MODULE_EXPORT struct prpl *find_protocol( const char *name );
178G_MODULE_EXPORT void register_protocol( struct prpl * );
[b7d3cc34]179
[84b045d]180/* Connection management. */
181G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc );
182G_MODULE_EXPORT void imcb_free( struct im_connection *ic );
183G_MODULE_EXPORT void imcb_connected( struct im_connection *ic );
[c2fb3809]184G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect );
[b7d3cc34]185
[84b045d]186/* Communicating with the user. */
187G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... );
188G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... );
189G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont );
190G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname );
[b7d3cc34]191
[84b045d]192/* Buddy management */
[f0cb961]193G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group );
194G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group );
195G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle );
196G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, char *handle, char *realname );
[84b045d]197
198/* Buddy activity */
[6bbb939]199G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message );
200/* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle );
[9624fdf]201G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at );
202G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags );
[84b045d]203
[61ae52c]204/* Groupchats */
205G_MODULE_EXPORT void imcb_chat_invited( struct im_connection *ic, char *handle, char *who, char *msg, GList *data );
206G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle );
207G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );
208G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
209G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
210G_MODULE_EXPORT void imcb_chat_removed( struct groupchat *c );
211struct groupchat *chat_by_channel( char *channel );
212
[84b045d]213/* Actions, or whatever. */
214int imc_set_away( struct im_connection *ic, char *away );
215int imc_buddy_msg( struct im_connection *ic, char *handle, char *msg, int flags );
216int imc_chat_msg( struct groupchat *c, char *msg, int flags );
217
218void imc_add_allow( struct im_connection *ic, char *handle );
219void imc_rem_allow( struct im_connection *ic, char *handle );
220void imc_add_block( struct im_connection *ic, char *handle );
221void imc_rem_block( struct im_connection *ic, char *handle );
222
223/* Misc. stuff */
224char *set_eval_away_devoice( set_t *set, char *value );
225gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond );
226void cancel_auto_reconnect( struct account *a );
227
[b7d3cc34]228#endif
Note: See TracBrowser for help on using the repository browser.