[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 */ |
---|
| 71 | struct 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 | int protocol; |
---|
| 75 | struct prpl *prpl; |
---|
| 76 | guint32 flags; |
---|
| 77 | |
---|
| 78 | /* all connections need an input watcher */ |
---|
| 79 | int inpa; |
---|
| 80 | |
---|
| 81 | /* buddy list stuff. there is still a global groups for the buddy list, but |
---|
| 82 | * we need to maintain our own set of buddies, and our own permit/deny lists */ |
---|
| 83 | GSList *permit; |
---|
| 84 | GSList *deny; |
---|
| 85 | int permdeny; |
---|
| 86 | |
---|
| 87 | /* all connections need a list of chats, even if they don't have chat */ |
---|
| 88 | GSList *buddy_chats; |
---|
| 89 | |
---|
| 90 | /* each connection then can have its own protocol-specific data */ |
---|
| 91 | void *proto_data; |
---|
| 92 | |
---|
| 93 | struct aim_user *user; |
---|
| 94 | |
---|
| 95 | char username[64]; |
---|
| 96 | char displayname[128]; |
---|
| 97 | char password[32]; |
---|
| 98 | guint keepalive; |
---|
| 99 | /* stuff needed for per-connection idle times */ |
---|
| 100 | guint idle_timer; |
---|
| 101 | time_t login_time; |
---|
| 102 | time_t lastsent; |
---|
| 103 | int is_idle; |
---|
| 104 | |
---|
| 105 | char *away; |
---|
| 106 | int is_auto_away; |
---|
| 107 | |
---|
| 108 | int evil; |
---|
| 109 | gboolean wants_to_die; /* defaults to FALSE */ |
---|
| 110 | |
---|
| 111 | /* BitlBee */ |
---|
| 112 | irc_t *irc; |
---|
| 113 | int lstitems; /* added for msnP8 */ |
---|
| 114 | |
---|
| 115 | struct conversation *conversations; |
---|
| 116 | }; |
---|
| 117 | |
---|
| 118 | /* struct buddy_chat went away and got merged with this. */ |
---|
| 119 | struct conversation { |
---|
| 120 | struct gaim_connection *gc; |
---|
| 121 | |
---|
| 122 | /* stuff used just for chat */ |
---|
| 123 | GList *in_room; |
---|
| 124 | GList *ignored; |
---|
| 125 | int id; |
---|
| 126 | |
---|
| 127 | /* BitlBee */ |
---|
| 128 | struct conversation *next; |
---|
| 129 | char *channel; |
---|
| 130 | char *title; |
---|
| 131 | char joined; |
---|
| 132 | void *data; |
---|
| 133 | }; |
---|
| 134 | |
---|
| 135 | struct buddy { |
---|
| 136 | char name[80]; |
---|
| 137 | char show[BUDDY_ALIAS_MAXLEN]; |
---|
| 138 | int present; |
---|
| 139 | int evil; |
---|
| 140 | time_t signon; |
---|
| 141 | time_t idle; |
---|
| 142 | int uc; |
---|
| 143 | guint caps; /* woohoo! */ |
---|
| 144 | void *proto_data; /* what a hack */ |
---|
| 145 | struct gaim_connection *gc; /* the connection it belongs to */ |
---|
| 146 | }; |
---|
| 147 | |
---|
| 148 | struct aim_user { |
---|
| 149 | char username[64]; |
---|
| 150 | char alias[SELF_ALIAS_LEN]; |
---|
| 151 | char password[32]; |
---|
| 152 | char user_info[2048]; |
---|
| 153 | int options; |
---|
| 154 | int protocol; |
---|
| 155 | /* prpls can use this to save information about the user, |
---|
| 156 | * like which server to connect to, etc */ |
---|
| 157 | char proto_opt[7][256]; |
---|
| 158 | |
---|
| 159 | struct gaim_connection *gc; |
---|
| 160 | irc_t *irc; |
---|
| 161 | }; |
---|
| 162 | |
---|
| 163 | struct prpl { |
---|
| 164 | int protocol; |
---|
| 165 | int options; |
---|
| 166 | char *(* name)(); |
---|
| 167 | |
---|
| 168 | /* for ICQ and Yahoo, who have off/on per-conversation options */ |
---|
| 169 | /* char *checkbox; this should be per-connection */ |
---|
| 170 | |
---|
| 171 | GList *(* away_states)(struct gaim_connection *gc); |
---|
| 172 | GList *(* actions)(); |
---|
| 173 | void (* do_action)(struct gaim_connection *, char *); |
---|
| 174 | /* user_opts returns a GList* of g_malloc'd struct proto_user_opts */ |
---|
| 175 | GList *(* user_opts)(); |
---|
| 176 | GList *(* chat_info)(struct gaim_connection *); |
---|
| 177 | |
---|
| 178 | /* all the server-related functions */ |
---|
| 179 | |
---|
| 180 | /* a lot of these (like get_dir) are protocol-dependent and should be removed. ones like |
---|
| 181 | * set_dir (which is also protocol-dependent) can stay though because there's a dialog |
---|
| 182 | * (i.e. the prpl says you can set your dir info, the ui shows a dialog and needs to call |
---|
| 183 | * set_dir in order to set it) */ |
---|
| 184 | |
---|
| 185 | void (* login) (struct aim_user *); |
---|
| 186 | void (* close) (struct gaim_connection *); |
---|
| 187 | int (* send_im) (struct gaim_connection *, char *who, char *message, int len, int away); |
---|
| 188 | int (* send_typing) (struct gaim_connection *, char *who, int typing); |
---|
| 189 | void (* set_info) (struct gaim_connection *, char *info); |
---|
| 190 | void (* get_info) (struct gaim_connection *, char *who); |
---|
| 191 | void (* set_away) (struct gaim_connection *, char *state, char *message); |
---|
| 192 | void (* get_away) (struct gaim_connection *, char *who); |
---|
| 193 | void (* set_idle) (struct gaim_connection *, int idletime); |
---|
| 194 | void (* add_buddy) (struct gaim_connection *, char *name); |
---|
| 195 | void (* remove_buddy) (struct gaim_connection *, char *name, char *group); |
---|
| 196 | void (* add_permit) (struct gaim_connection *, char *name); |
---|
| 197 | void (* add_deny) (struct gaim_connection *, char *name); |
---|
| 198 | void (* rem_permit) (struct gaim_connection *, char *name); |
---|
| 199 | void (* rem_deny) (struct gaim_connection *, char *name); |
---|
| 200 | void (* set_permit_deny)(struct gaim_connection *); |
---|
| 201 | void (* join_chat) (struct gaim_connection *, GList *data); |
---|
| 202 | void (* chat_invite) (struct gaim_connection *, int id, char *who, char *message); |
---|
| 203 | void (* chat_leave) (struct gaim_connection *, int id); |
---|
| 204 | void (* chat_whisper) (struct gaim_connection *, int id, char *who, char *message); |
---|
| 205 | int (* chat_send) (struct gaim_connection *, int id, char *message); |
---|
| 206 | int (* chat_open) (struct gaim_connection *, char *who); |
---|
| 207 | void (* keepalive) (struct gaim_connection *); |
---|
| 208 | |
---|
| 209 | /* get "chat buddy" info and away message */ |
---|
| 210 | void (* get_cb_info) (struct gaim_connection *, int, char *who); |
---|
| 211 | void (* get_cb_away) (struct gaim_connection *, int, char *who); |
---|
| 212 | |
---|
| 213 | /* save/store buddy's alias on server list/roster */ |
---|
| 214 | void (* alias_buddy) (struct gaim_connection *, char *who); |
---|
| 215 | |
---|
| 216 | /* change a buddy's group on a server list/roster */ |
---|
| 217 | void (* group_buddy) (struct gaim_connection *, char *who, char *old_group, char *new_group); |
---|
| 218 | |
---|
| 219 | void (* buddy_free) (struct buddy *); |
---|
| 220 | |
---|
| 221 | char *(* get_status_string) (struct gaim_connection *gc, int stat); |
---|
[9cb9868] | 222 | |
---|
| 223 | int (* cmp_buddynames) (const char *who1, const char *who2); |
---|
[b7d3cc34] | 224 | }; |
---|
| 225 | |
---|
| 226 | #define PROTO_TOC 0 |
---|
| 227 | #define PROTO_OSCAR 1 |
---|
| 228 | #define PROTO_YAHOO 2 |
---|
| 229 | #define PROTO_ICQ 3 |
---|
| 230 | #define PROTO_MSN 4 |
---|
| 231 | #define PROTO_IRC 5 |
---|
| 232 | #define PROTO_FTP 6 |
---|
| 233 | #define PROTO_VGATE 7 |
---|
| 234 | #define PROTO_JABBER 8 |
---|
| 235 | #define PROTO_NAPSTER 9 |
---|
| 236 | #define PROTO_ZEPHYR 10 |
---|
| 237 | #define PROTO_GADUGADU 11 |
---|
| 238 | #define PROTO_MAX 16 |
---|
| 239 | |
---|
| 240 | extern char proto_name[PROTO_MAX][8]; |
---|
| 241 | |
---|
| 242 | #define UC_UNAVAILABLE 1 |
---|
| 243 | |
---|
| 244 | /* JABBER */ |
---|
| 245 | #define UC_AWAY (0x02 | UC_UNAVAILABLE) |
---|
| 246 | #define UC_CHAT 0x04 |
---|
| 247 | #define UC_XA (0x08 | UC_UNAVAILABLE) |
---|
| 248 | #define UC_DND (0x10 | UC_UNAVAILABLE) |
---|
| 249 | |
---|
| 250 | G_MODULE_EXPORT GSList *get_connections(); |
---|
| 251 | extern struct prpl *proto_prpl[16]; |
---|
| 252 | |
---|
| 253 | /* nogaim.c */ |
---|
| 254 | int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); |
---|
| 255 | int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); |
---|
| 256 | |
---|
| 257 | G_MODULE_EXPORT signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t size, size_t maxbuf ); |
---|
| 258 | char *set_eval_charset( irc_t *irc, set_t *set, char *value ); |
---|
| 259 | |
---|
| 260 | void nogaim_init(); |
---|
| 261 | int proto_away( struct gaim_connection *gc, char *away ); |
---|
| 262 | char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); |
---|
| 263 | |
---|
| 264 | gboolean auto_reconnect( gpointer data ); |
---|
| 265 | void cancel_auto_reconnect( struct account *a ); |
---|
| 266 | |
---|
| 267 | /* multi.c */ |
---|
| 268 | G_MODULE_EXPORT struct gaim_connection *new_gaim_conn( struct aim_user *user ); |
---|
| 269 | G_MODULE_EXPORT void destroy_gaim_conn( struct gaim_connection *gc ); |
---|
| 270 | G_MODULE_EXPORT void set_login_progress( struct gaim_connection *gc, int step, char *msg ); |
---|
| 271 | G_MODULE_EXPORT void hide_login_progress( struct gaim_connection *gc, char *msg ); |
---|
| 272 | G_MODULE_EXPORT void hide_login_progress_error( struct gaim_connection *gc, char *msg ); |
---|
| 273 | G_MODULE_EXPORT void serv_got_crap( struct gaim_connection *gc, char *format, ... ); |
---|
| 274 | G_MODULE_EXPORT void account_online( struct gaim_connection *gc ); |
---|
| 275 | G_MODULE_EXPORT void account_offline( struct gaim_connection *gc ); |
---|
| 276 | G_MODULE_EXPORT void signoff( struct gaim_connection *gc ); |
---|
| 277 | |
---|
| 278 | /* dialogs.c */ |
---|
| 279 | G_MODULE_EXPORT void do_error_dialog( struct gaim_connection *gc, char *msg, char *title ); |
---|
| 280 | G_MODULE_EXPORT void do_ask_dialog( struct gaim_connection *gc, char *msg, void *data, void *doit, void *dont ); |
---|
| 281 | |
---|
| 282 | /* list.c */ |
---|
| 283 | G_MODULE_EXPORT int bud_list_cache_exists( struct gaim_connection *gc ); |
---|
| 284 | G_MODULE_EXPORT void do_import( struct gaim_connection *gc, void *null ); |
---|
| 285 | G_MODULE_EXPORT void add_buddy( struct gaim_connection *gc, char *group, char *handle, char *realname ); |
---|
| 286 | G_MODULE_EXPORT struct buddy *find_buddy( struct gaim_connection *gc, char *handle ); |
---|
| 287 | G_MODULE_EXPORT void do_export( struct gaim_connection *gc ); |
---|
| 288 | G_MODULE_EXPORT void signoff_blocked( struct gaim_connection *gc ); |
---|
| 289 | |
---|
| 290 | G_MODULE_EXPORT void serv_buddy_rename( struct gaim_connection *gc, char *handle, char *realname ); |
---|
| 291 | |
---|
| 292 | /* buddy_chat.c */ |
---|
| 293 | G_MODULE_EXPORT void add_chat_buddy( struct conversation *b, char *handle ); |
---|
| 294 | G_MODULE_EXPORT void remove_chat_buddy( struct conversation *b, char *handle, char *reason ); |
---|
| 295 | |
---|
| 296 | /* prpl.c */ |
---|
| 297 | G_MODULE_EXPORT void show_got_added( struct gaim_connection *gc, char *id, char *handle, const char *realname, const char *msg ); |
---|
| 298 | |
---|
| 299 | /* server.c */ |
---|
| 300 | 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 ); |
---|
| 301 | G_MODULE_EXPORT void serv_got_im( struct gaim_connection *gc, char *handle, char *msg, guint32 flags, time_t mtime, gint len ); |
---|
| 302 | G_MODULE_EXPORT void serv_got_typing( struct gaim_connection *gc, char *handle, int timeout ); |
---|
| 303 | G_MODULE_EXPORT void serv_got_chat_invite( struct gaim_connection *gc, char *handle, char *who, char *msg, GList *data ); |
---|
| 304 | G_MODULE_EXPORT struct conversation *serv_got_joined_chat( struct gaim_connection *gc, int id, char *handle ); |
---|
| 305 | G_MODULE_EXPORT void serv_got_chat_in( struct gaim_connection *gc, int id, char *who, int whisper, char *msg, time_t mtime ); |
---|
| 306 | G_MODULE_EXPORT void serv_got_chat_left( struct gaim_connection *gc, int id ); |
---|
| 307 | /* void serv_finish_login( struct gaim_connection *gc ); */ |
---|
| 308 | |
---|
| 309 | /* util.c */ |
---|
| 310 | G_MODULE_EXPORT char *utf8_to_str( const char *in ); |
---|
| 311 | G_MODULE_EXPORT char *str_to_utf8( const char *in ); |
---|
| 312 | G_MODULE_EXPORT void strip_linefeed( gchar *text ); |
---|
| 313 | G_MODULE_EXPORT char *add_cr( char *text ); |
---|
| 314 | G_MODULE_EXPORT char *tobase64( const char *text ); |
---|
| 315 | G_MODULE_EXPORT char *normalize( const char *s ); |
---|
| 316 | G_MODULE_EXPORT time_t get_time( int year, int month, int day, int hour, int min, int sec ); |
---|
| 317 | G_MODULE_EXPORT void strip_html( char *msg ); |
---|
| 318 | G_MODULE_EXPORT char * escape_html(const char *html); |
---|
| 319 | G_MODULE_EXPORT void info_string_append(GString *str, char *newline, char *name, char *value); |
---|
| 320 | |
---|
| 321 | #ifdef WITH_MSN |
---|
| 322 | /* msn.c */ |
---|
| 323 | G_MODULE_EXPORT void msn_init( struct prpl *ret ); |
---|
| 324 | #endif |
---|
| 325 | |
---|
| 326 | #ifdef WITH_OSCAR |
---|
| 327 | /* oscar.c */ |
---|
| 328 | G_MODULE_EXPORT void oscar_init( struct prpl *ret ); |
---|
| 329 | #endif |
---|
| 330 | |
---|
| 331 | #ifdef WITH_JABBER |
---|
| 332 | /* jabber.c */ |
---|
| 333 | G_MODULE_EXPORT void jabber_init( struct prpl *ret ); |
---|
| 334 | #endif |
---|
| 335 | |
---|
| 336 | #ifdef WITH_YAHOO |
---|
| 337 | /* yahoo.c */ |
---|
| 338 | G_MODULE_EXPORT void byahoo_init( struct prpl *ret ); |
---|
| 339 | #endif |
---|
| 340 | |
---|
| 341 | /* prefs.c */ |
---|
| 342 | G_MODULE_EXPORT void build_block_list(); |
---|
| 343 | G_MODULE_EXPORT void build_allow_list(); |
---|
| 344 | |
---|
| 345 | struct conversation *conv_findchannel( char *channel ); |
---|
| 346 | |
---|
| 347 | |
---|
| 348 | #endif |
---|