[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 | /* |
---|
| 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 */ |
---|
[192b80a] | 71 | struct gaim_connection |
---|
| 72 | { |
---|
[b7d3cc34] | 73 | struct prpl *prpl; |
---|
| 74 | guint32 flags; |
---|
| 75 | |
---|
[192b80a] | 76 | /* each connection then can have its own protocol-specific data */ |
---|
| 77 | void *proto_data; |
---|
| 78 | |
---|
[b7d3cc34] | 79 | /* all connections need an input watcher */ |
---|
| 80 | int inpa; |
---|
[192b80a] | 81 | guint keepalive; |
---|
[b7d3cc34] | 82 | |
---|
| 83 | /* buddy list stuff. there is still a global groups for the buddy list, but |
---|
| 84 | * we need to maintain our own set of buddies, and our own permit/deny lists */ |
---|
| 85 | GSList *permit; |
---|
| 86 | GSList *deny; |
---|
| 87 | int permdeny; |
---|
| 88 | |
---|
| 89 | struct aim_user *user; |
---|
| 90 | |
---|
| 91 | char username[64]; |
---|
| 92 | char displayname[128]; |
---|
| 93 | char password[32]; |
---|
| 94 | |
---|
| 95 | char *away; |
---|
| 96 | |
---|
| 97 | int evil; |
---|
| 98 | gboolean wants_to_die; /* defaults to FALSE */ |
---|
| 99 | |
---|
| 100 | /* BitlBee */ |
---|
| 101 | irc_t *irc; |
---|
| 102 | |
---|
| 103 | struct conversation *conversations; |
---|
| 104 | }; |
---|
| 105 | |
---|
| 106 | /* struct buddy_chat went away and got merged with this. */ |
---|
| 107 | struct conversation { |
---|
| 108 | struct gaim_connection *gc; |
---|
| 109 | |
---|
| 110 | /* stuff used just for chat */ |
---|
| 111 | GList *in_room; |
---|
| 112 | GList *ignored; |
---|
| 113 | int id; |
---|
| 114 | |
---|
| 115 | /* BitlBee */ |
---|
| 116 | struct conversation *next; |
---|
| 117 | char *channel; |
---|
| 118 | char *title; |
---|
| 119 | char joined; |
---|
| 120 | void *data; |
---|
| 121 | }; |
---|
| 122 | |
---|
| 123 | struct buddy { |
---|
| 124 | char name[80]; |
---|
| 125 | char show[BUDDY_ALIAS_MAXLEN]; |
---|
| 126 | int present; |
---|
| 127 | int evil; |
---|
| 128 | time_t signon; |
---|
| 129 | time_t idle; |
---|
| 130 | int uc; |
---|
| 131 | guint caps; /* woohoo! */ |
---|
| 132 | void *proto_data; /* what a hack */ |
---|
| 133 | struct gaim_connection *gc; /* the connection it belongs to */ |
---|
| 134 | }; |
---|
| 135 | |
---|
| 136 | struct aim_user { |
---|
| 137 | char username[64]; |
---|
| 138 | char alias[SELF_ALIAS_LEN]; |
---|
| 139 | char password[32]; |
---|
| 140 | char user_info[2048]; |
---|
| 141 | int options; |
---|
[7b23afd] | 142 | struct prpl *prpl; |
---|
[b7d3cc34] | 143 | /* prpls can use this to save information about the user, |
---|
| 144 | * like which server to connect to, etc */ |
---|
| 145 | char proto_opt[7][256]; |
---|
| 146 | |
---|
| 147 | struct gaim_connection *gc; |
---|
| 148 | irc_t *irc; |
---|
| 149 | }; |
---|
| 150 | |
---|
| 151 | struct prpl { |
---|
| 152 | int options; |
---|
[7b23afd] | 153 | const char *name; |
---|
[b7d3cc34] | 154 | |
---|
| 155 | void (* login) (struct aim_user *); |
---|
[192b80a] | 156 | void (* keepalive) (struct gaim_connection *); |
---|
[b7d3cc34] | 157 | void (* close) (struct gaim_connection *); |
---|
[192b80a] | 158 | |
---|
[b7d3cc34] | 159 | int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); |
---|
| 160 | void (* set_away) (struct gaim_connection *, char *state, char *message); |
---|
| 161 | void (* get_away) (struct gaim_connection *, char *who); |
---|
[192b80a] | 162 | int (* send_typing) (struct gaim_connection *, char *who, int typing); |
---|
| 163 | |
---|
[b7d3cc34] | 164 | void (* add_buddy) (struct gaim_connection *, char *name); |
---|
[192b80a] | 165 | void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); |
---|
[b7d3cc34] | 166 | void (* remove_buddy) (struct gaim_connection *, char *name, char *group); |
---|
| 167 | void (* add_permit) (struct gaim_connection *, char *name); |
---|
| 168 | void (* add_deny) (struct gaim_connection *, char *name); |
---|
| 169 | void (* rem_permit) (struct gaim_connection *, char *name); |
---|
| 170 | void (* rem_deny) (struct gaim_connection *, char *name); |
---|
| 171 | void (* set_permit_deny)(struct gaim_connection *); |
---|
[192b80a] | 172 | |
---|
| 173 | void (* set_info) (struct gaim_connection *, char *info); |
---|
| 174 | void (* get_info) (struct gaim_connection *, char *who); |
---|
| 175 | void (* alias_buddy) (struct gaim_connection *, char *who); /* save/store buddy's alias on server list/roster */ |
---|
| 176 | |
---|
| 177 | /* Group chat stuff. */ |
---|
[b7d3cc34] | 178 | void (* join_chat) (struct gaim_connection *, GList *data); |
---|
| 179 | void (* chat_invite) (struct gaim_connection *, int id, char *who, char *message); |
---|
| 180 | void (* chat_leave) (struct gaim_connection *, int id); |
---|
| 181 | int (* chat_send) (struct gaim_connection *, int id, char *message); |
---|
| 182 | int (* chat_open) (struct gaim_connection *, char *who); |
---|
[192b80a] | 183 | |
---|
| 184 | /* DIE! */ |
---|
[b7d3cc34] | 185 | char *(* get_status_string) (struct gaim_connection *gc, int stat); |
---|
[192b80a] | 186 | |
---|
| 187 | GList *(* away_states)(struct gaim_connection *gc); |
---|
| 188 | |
---|
| 189 | /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ |
---|
[9cb9868] | 190 | int (* cmp_buddynames) (const char *who1, const char *who2); |
---|
[b7d3cc34] | 191 | }; |
---|
| 192 | |
---|
| 193 | #define UC_UNAVAILABLE 1 |
---|
| 194 | |
---|
| 195 | /* JABBER */ |
---|
| 196 | #define UC_AWAY (0x02 | UC_UNAVAILABLE) |
---|
| 197 | #define UC_CHAT 0x04 |
---|
| 198 | #define UC_XA (0x08 | UC_UNAVAILABLE) |
---|
| 199 | #define UC_DND (0x10 | UC_UNAVAILABLE) |
---|
| 200 | |
---|
| 201 | G_MODULE_EXPORT GSList *get_connections(); |
---|
[7b23afd] | 202 | G_MODULE_EXPORT struct prpl *find_protocol(const char *name); |
---|
| 203 | G_MODULE_EXPORT void register_protocol(struct prpl *); |
---|
[b7d3cc34] | 204 | |
---|
| 205 | /* nogaim.c */ |
---|
| 206 | int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); |
---|
| 207 | int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); |
---|
| 208 | |
---|
| 209 | void nogaim_init(); |
---|
| 210 | int proto_away( struct gaim_connection *gc, char *away ); |
---|
| 211 | char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); |
---|
| 212 | |
---|
| 213 | gboolean auto_reconnect( gpointer data ); |
---|
| 214 | void cancel_auto_reconnect( struct account *a ); |
---|
| 215 | |
---|
| 216 | /* multi.c */ |
---|
| 217 | G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( struct aim_user *user ); |
---|
| 218 | G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc ); |
---|
| 219 | G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg ); |
---|
| 220 | G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg ); |
---|
| 221 | G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg ); |
---|
| 222 | G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ); |
---|
| 223 | G_MODULE_EXPORT void account_online( struct gaim_connection *gc ); |
---|
| 224 | G_MODULE_EXPORT void account_offline( struct gaim_connection *gc ); |
---|
| 225 | G_MODULE_EXPORT void signoff( struct gaim_connection *gc ); |
---|
| 226 | |
---|
| 227 | /* dialogs.c */ |
---|
| 228 | G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ); |
---|
| 229 | G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont ); |
---|
| 230 | |
---|
| 231 | /* list.c */ |
---|
| 232 | G_MODULE_EXPORT int bud_list_cache_exists( struct gaim_connection *gc ); |
---|
| 233 | G_MODULE_EXPORT void do_import( struct gaim_connection *gc, void *null ); |
---|
| 234 | G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ); |
---|
| 235 | G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle ); |
---|
| 236 | G_MODULE_EXPORT void do_export( struct gaim_connection *gc ); |
---|
| 237 | G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc ); |
---|
| 238 | |
---|
| 239 | G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname ); |
---|
| 240 | |
---|
| 241 | /* buddy_chat.c */ |
---|
| 242 | G_MODULE_EXPORT void add_chat_buddy( struct conversation *b, char *handle ); |
---|
| 243 | G_MODULE_EXPORT void remove_chat_buddy( struct conversation *b, char *handle, char *reason ); |
---|
| 244 | |
---|
| 245 | /* prpl.c */ |
---|
| 246 | G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg ); |
---|
| 247 | |
---|
| 248 | /* server.c */ |
---|
| 249 | G_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 ); |
---|
| 250 | G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); |
---|
[e7f46c5] | 251 | G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout, int type ); |
---|
[b7d3cc34] | 252 | G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data ); |
---|
| 253 | G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ); |
---|
| 254 | G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ); |
---|
| 255 | G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); |
---|
| 256 | |
---|
| 257 | /* prefs.c */ |
---|
| 258 | G_MODULE_EXPORT void build_block_list(); |
---|
| 259 | G_MODULE_EXPORT void build_allow_list(); |
---|
| 260 | |
---|
| 261 | struct conversation *conv_findchannel( char *channel ); |
---|
| 262 | |
---|
| 263 | #endif |
---|