1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/*
* IRC protocol support for Ayttm
*
* Copyright (C) 2001, Erik Inge Bolso <knan@mo.himolde.no>
* and others
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* irc.h
*/
#include "libproxy/networking.h"
/* RFC1459 and RFC2812 defines max message size
including \n == 512 bytes, but being tolerant of
violations is nice nevertheless. */
#define BUF_LEN 512*2
#define AY_IRC_GET_HANDLE(handle,nick,addr,size) {\
strncpy(handle, nick, size);\
strncat(handle, "@", size-strlen(handle));\
strncat(handle, addr, size-strlen(handle));\
}
#define DBG_IRC do_irc_debug
typedef struct irc_local_account_type {
char password[MAX_PREF_LEN];
int fd_tag;
int keepalive_tag;
int connect_tag;
int activity_tag;
char *buff;
int buff_user;
LList *friends;
LList *channel_list;
LList *current_rooms;
irc_account *ia;
void (*got_public_chatrooms) (LList *list, void *data);
void *public_chatroom_callback_data;
AyConnection *connection;
} irc_local_account;
typedef struct irc_account_type {
char server[255];
char realserver[255];
int status;
int idle;
gboolean dummy;
} ay_irc_account;
typedef struct _irc_info {
char *whois_info;
eb_account *me;
char *fullmessage;
} irc_info;
static int is_setting_state = 0;
/* Denotes the end of list in irc_command_action array (irc_ca) ... */
#define IRC_END_COMMAND ""
/* Max command and action strings length in an irc_command_action struct */
#define MAX_IRC_COMMAND_LEN 255
#define MAX_IRC_ACTION_LEN 255
/* IRC_COMMAND_TYPE: type of command in an irc_command_action struct. */
enum IRC_COMMAND_TYPE {
IRC_COMMAND_BUILTIN = 1,
IRC_COMMAND_USER_DEF = 2
};
enum {
IRC_WELCOME = 0xaa77aa,
IRC_TOPIC = 0x775500,
IRC_MOTD = 0x885588,
IRC_KICK = 0xAA6600,
IRC_CTCP_TIME = 0xaabb44,
IRC_CTCP_ACTION = 0x00aa00,
IRC_CTCP_VERSION = 0x00bbbb
};
typedef struct irc_command_action_type {
char command[MAX_IRC_COMMAND_LEN];
char action[MAX_IRC_ACTION_LEN];
enum IRC_COMMAND_TYPE command_type;
} irc_command_action;
/* Local prototypes */
static int ay_irc_query_connected(eb_account *account);
static void ay_irc_login(eb_local_account *account);
static void ay_irc_logout(eb_local_account *ela);
static int ay_irc_send_im(eb_local_account *account_from,
eb_account *account_to, char *message);
static eb_local_account *ay_irc_read_local_config(LList *pairs);
static LList *ay_irc_write_local_config(eb_local_account *account);
static eb_account *ay_irc_read_config(eb_account *ea, LList *config);
static LList *ay_irc_get_states();
static int ay_irc_get_current_state(eb_local_account *account);
static void ay_irc_set_current_state(eb_local_account *account, int state);
static char *ay_irc_check_login(const char *user, const char *pass);
static void ay_irc_add_user(eb_account *account);
static void ay_irc_del_user(eb_account *account);
static int ay_irc_is_suitable(eb_local_account *local, eb_account *remote);
static eb_account *ay_irc_new_account(eb_local_account *ela,
const char *account);
static const char *ay_irc_get_status_string(eb_account *account);
static void *ay_irc_get_status_pixbuf(eb_account *account);
static void ay_irc_set_idle(eb_local_account *account, int idle);
static void ay_irc_set_away(eb_local_account *account, char *message, int away);
static void ay_irc_send_file(eb_local_account *from, eb_account *to,
char *file);
static void irc_info_update(info_window *iw);
static void irc_info_data_cleanup(info_window *iw);
static void ay_irc_get_info(eb_local_account *account_from,
eb_account *account_to);
static void ay_irc_join_chat_room(Conversation *room);
static void ay_irc_leave_chat_room(Conversation *room);
static int ay_irc_send_chat_room_message(Conversation *room, char *message);
static void ay_irc_send_invite(eb_local_account *account, Conversation *room,
char *user, const char *message);
static Conversation *ay_irc_make_chat_room(char *name,
eb_local_account *account, int is_public);
static Conversation *ay_irc_start_conversation(const char *name,
eb_local_account *account, int is_room, int is_public, int send_join);
static void ay_irc_accept_invite(eb_local_account *account, void *invitation);
static void ay_irc_decline_invite(eb_local_account *account, void *invitation);
static void eb_irc_read_prefs_config(LList *values);
static LList *eb_irc_write_prefs_config();
static void irc_connect_cb(AyConnection *con, AyConnectionStatus error,
void *data);
void irc_finish_login(eb_local_account *ela);
static irc_callbacks *ay_irc_map_callbacks(void);
|