1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 10:13:12 +02:00

IRC DCC chat and file (without resume) reintroduced, via xfer plugin (called by /dcc command)

This commit is contained in:
Sebastien Helleu
2008-05-06 16:51:30 +02:00
parent e7a16efa0c
commit e9603acb1a
37 changed files with 2155 additions and 1271 deletions
+1 -174
View File
@@ -45,41 +45,7 @@ struct t_irc_dcc *irc_dcc_list = NULL; /* DCC files & chat list */
struct t_irc_dcc *irc_last_dcc = NULL; /* last DCC in list */
/*
* irc_dcc_channel_for_chat: create channel for DCC chat
*/
/*
void
irc_dcc_channel_for_chat (struct t_irc_dcc *dcc)
{
if (!irc_channel_create_dcc (dcc))
{
gui_chat_printf_error (dcc->server->buffer,
_("%s can't associate DCC chat with private "
"buffer (maybe private buffer has already "
"DCC CHAT?)\n"),
WEECHAT_ERROR);
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
return;
}
gui_chat_printf_type (dcc->channel->buffer, GUI_MSG_TYPE_MSG,
cfg_look_prefix_info, cfg_col_chat_prefix_info,
_("Connected to %s%s %s(%s%d.%d.%d.%d%s)%s via DCC "
"chat\n"),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
dcc->nick,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_HOST),
dcc->addr >> 24,
(dcc->addr >> 16) & 0xff,
(dcc->addr >> 8) & 0xff,
dcc->addr & 0xff,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT));
}
*/
/*
* irc_dcc_chat_remove_channel: remove a buffer for DCC chat
*/
@@ -167,142 +133,3 @@ irc_dcc_start_resume (struct t_irc_server *server, char *filename, int port,
WEECHAT_ERROR, filename, port, pos_start);
}
*/
/*
* irc_dcc_handle: receive/send data for all active DCC
*/
/*
void
irc_dcc_handle ()
{
struct t_irc_dcc *dcc;
fd_set read_fd;
static struct timeval timeout;
int sock;
struct sockaddr_in addr;
socklen_t length;
for (dcc = irc_dcc_list; dcc; dcc = dcc->next_dcc)
{
// check DCC timeout
if (IRC_DCC_IS_FILE(dcc->type) && !IRC_DCC_ENDED(dcc->status))
{
if ((irc_cfg_dcc_timeout != 0)
&& (time (NULL) > dcc->last_activity + irc_cfg_dcc_timeout))
{
gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: timeout\n"),
WEECHAT_ERROR);
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
continue;
}
}
if (dcc->status == IRC_DCC_CONNECTING)
{
if (dcc->type == IRC_DCC_FILE_SEND)
{
FD_ZERO (&read_fd);
FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
// something to read on socket?
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
if (FD_ISSET (dcc->sock, &read_fd))
{
dcc->last_activity = time (NULL);
length = sizeof (addr);
sock = accept (dcc->sock,
(struct sockaddr *) &addr, &length);
close (dcc->sock);
dcc->sock = -1;
if (sock < 0)
{
gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to "
"create socket for "
"sending file\n"),
WEECHAT_ERROR);
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
continue;
}
dcc->sock = sock;
if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
gui_chat_printf_error (dcc->server->buffer,
_("%s DCC: unable to set "
"'nonblock' option for "
"socket\n"),
WEECHAT_ERROR);
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
continue;
}
dcc->addr = ntohl (addr.sin_addr.s_addr);
dcc->status = IRC_DCC_ACTIVE;
dcc->start_transfer = time (NULL);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
irc_dcc_file_send_fork (dcc);
}
}
}
if (dcc->type == IRC_DCC_FILE_RECV)
{
if (dcc->child_read != -1)
irc_dcc_file_child_read (dcc);
}
}
if (dcc->status == IRC_DCC_WAITING)
{
if (dcc->type == IRC_DCC_CHAT_SEND)
{
FD_ZERO (&read_fd);
FD_SET (dcc->sock, &read_fd);
timeout.tv_sec = 0;
timeout.tv_usec = 0;
// something to read on socket?
if (select (FD_SETSIZE, &read_fd, NULL, NULL, &timeout) > 0)
{
if (FD_ISSET (dcc->sock, &read_fd))
{
length = sizeof (addr);
sock = accept (dcc->sock, (struct sockaddr *) &addr, &length);
close (dcc->sock);
dcc->sock = -1;
if (sock < 0)
{
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
continue;
}
dcc->sock = sock;
if (fcntl (dcc->sock, F_SETFL, O_NONBLOCK) == -1)
{
irc_dcc_close (dcc, IRC_DCC_FAILED);
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
continue;
}
dcc->addr = ntohl (addr.sin_addr.s_addr);
dcc->status = IRC_DCC_ACTIVE;
irc_dcc_redraw (WEECHAT_HOTLIST_MESSAGE);
irc_dcc_channel_for_chat (dcc);
}
}
}
}
if (dcc->status == IRC_DCC_ACTIVE)
{
if (IRC_DCC_IS_CHAT(dcc->type))
irc_dcc_chat_recv (dcc);
else
irc_dcc_file_child_read (dcc);
}
}
}
*/