[b7d3cc34] | 1 | /********************************************************************\ |
---|
| 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
| 4 | * Copyright 2002-2004 Wilmer van der Gaast and others * |
---|
| 5 | \********************************************************************/ |
---|
| 6 | |
---|
[3ddb7477] | 7 | /* The IRC-based UI (for now the only one) */ |
---|
[b7d3cc34] | 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
| 22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
| 23 | Suite 330, Boston, MA 02111-1307 USA |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #ifndef _IRC_H |
---|
| 27 | #define _IRC_H |
---|
| 28 | |
---|
| 29 | #define IRC_MAX_LINE 512 |
---|
| 30 | #define IRC_MAX_ARGS 8 |
---|
| 31 | |
---|
| 32 | #define IRC_LOGIN_TIMEOUT 60 |
---|
| 33 | #define IRC_PING_STRING "PinglBee" |
---|
| 34 | |
---|
[aefa533e] | 35 | #define UMODES "abisw" |
---|
[238f828] | 36 | #define UMODES_PRIV "Ro" |
---|
[b7d3cc34] | 37 | #define CMODES "nt" |
---|
| 38 | #define CMODE "t" |
---|
| 39 | #define UMODE "s" |
---|
[39f93f0] | 40 | #define CTYPES "&#" |
---|
[b7d3cc34] | 41 | |
---|
| 42 | typedef enum |
---|
| 43 | { |
---|
[bd9b00f] | 44 | USTATUS_OFFLINE = 0, |
---|
[79e826a] | 45 | USTATUS_AUTHORIZED = 1, |
---|
| 46 | USTATUS_LOGGED_IN = 2, |
---|
| 47 | USTATUS_IDENTIFIED = 4, |
---|
| 48 | USTATUS_SHUTDOWN = 8 |
---|
[b7d3cc34] | 49 | } irc_status_t; |
---|
| 50 | |
---|
[3ddb7477] | 51 | struct irc_user; |
---|
| 52 | |
---|
[b7d3cc34] | 53 | typedef struct irc |
---|
| 54 | { |
---|
| 55 | int fd; |
---|
| 56 | irc_status_t status; |
---|
| 57 | double last_pong; |
---|
| 58 | int pinging; |
---|
| 59 | char *sendbuffer; |
---|
| 60 | char *readbuffer; |
---|
[f9756bd] | 61 | GIConv iconv, oconv; |
---|
[b7d3cc34] | 62 | |
---|
[3ddb7477] | 63 | struct irc_user *root; |
---|
| 64 | struct irc_user *user; |
---|
[b7d3cc34] | 65 | |
---|
[a199d33] | 66 | char *password; /* HACK: Used to save the user's password, but before |
---|
| 67 | logging in, this may contain a password we should |
---|
| 68 | send to identify after USER/NICK are received. */ |
---|
[b7d3cc34] | 69 | |
---|
| 70 | char umode[8]; |
---|
| 71 | |
---|
| 72 | struct query *queries; |
---|
| 73 | struct account *accounts; |
---|
[2c2df7d] | 74 | GSList *file_transfers; |
---|
[ad9feec] | 75 | struct chat *chatrooms; |
---|
[b7d3cc34] | 76 | |
---|
[3ddb7477] | 77 | GSList *users; |
---|
| 78 | GHashTable *nick_user_hash; |
---|
[b7d3cc34] | 79 | GHashTable *watches; |
---|
| 80 | |
---|
| 81 | gint r_watch_source_id; |
---|
| 82 | gint w_watch_source_id; |
---|
| 83 | gint ping_source_id; |
---|
[3ddb7477] | 84 | |
---|
| 85 | struct bee *b; |
---|
[b7d3cc34] | 86 | } irc_t; |
---|
| 87 | |
---|
[3ddb7477] | 88 | typedef struct irc_user |
---|
| 89 | { |
---|
| 90 | char *nick; |
---|
| 91 | char *user; |
---|
| 92 | char *host; |
---|
| 93 | char *fullname; |
---|
| 94 | |
---|
| 95 | /* Nickname in lowercase for case sensitive searches */ |
---|
| 96 | char *key; |
---|
| 97 | |
---|
| 98 | char is_private; |
---|
| 99 | |
---|
| 100 | char *sendbuf; |
---|
| 101 | int sendbuf_len; |
---|
| 102 | guint sendbuf_timer; |
---|
| 103 | int sendbuf_flags; |
---|
| 104 | |
---|
| 105 | //struct user *b; |
---|
| 106 | } irc_user_t; |
---|
| 107 | |
---|
[b7d3cc34] | 108 | #include "user.h" |
---|
| 109 | |
---|
[3ddb7477] | 110 | /* irc.c */ |
---|
[b7d3cc34] | 111 | extern GSList *irc_connection_list; |
---|
| 112 | |
---|
| 113 | irc_t *irc_new( int fd ); |
---|
[a9ca7dd] | 114 | void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
[b7d3cc34] | 115 | void irc_free( irc_t *irc ); |
---|
| 116 | |
---|
[f73b969] | 117 | void irc_process( irc_t *irc ); |
---|
[0431ea1] | 118 | char **irc_parse_line( char *line ); |
---|
[74c119d] | 119 | char *irc_build_line( char **cmd ); |
---|
[b7d3cc34] | 120 | |
---|
[a9ca7dd] | 121 | void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); |
---|
| 122 | void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); |
---|
[3ddb7477] | 123 | void irc_vawrite( irc_t *irc, char *format, va_list params ); |
---|
[b7d3cc34] | 124 | |
---|
[edf9657] | 125 | int irc_check_login( irc_t *irc ); |
---|
[3ddb7477] | 126 | |
---|
| 127 | /* irc_commands.c */ |
---|
| 128 | void irc_exec( irc_t *irc, char **cmd ); |
---|
| 129 | |
---|
| 130 | /* irc_send.c */ |
---|
| 131 | void irc_send_num( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
| 132 | void irc_send_login( irc_t *irc ); |
---|
| 133 | void irc_send_motd( irc_t *irc ); |
---|
| 134 | int irc_usermsg( irc_t *irc, char *format, ... ); |
---|
| 135 | |
---|
| 136 | /* irc_user.c */ |
---|
| 137 | irc_user_t *irc_user_new( irc_t *irc, const char *nick ); |
---|
| 138 | int irc_user_free( irc_t *irc, const char *nick ); |
---|
| 139 | irc_user_t *irc_user_find( irc_t *irc, const char *nick ); |
---|
| 140 | int irc_user_rename( irc_t *irc, const char *old, const char *new ); |
---|
[b7d3cc34] | 141 | |
---|
| 142 | #endif |
---|