mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
Added/renamed some files, many changes in IRC sources for running as plugin (still under development)
This commit is contained in:
@@ -14,12 +14,15 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
SET(LIB_IRC_SRC irc.h irc-commands.c irc-send.c irc-recv.c irc-server.c
|
||||
irc-channel.c irc-nick.c irc-mode.c irc-dcc.c irc-ignore.c irc-display.c)
|
||||
SET(LIB_PROTOCOL_IRC_SRC irc.h irc-buffer.c irc-buffer.h irc-channel.c
|
||||
irc-channel.h irc-command.c irc-command.h irc-color.c irc-color.h irc-config.c
|
||||
irc-config.h irc-core.c irc-dcc.c irc-dcc.h irc-display.c irc-input.c irc-log.c
|
||||
irc-mode.c irc-nick.c irc-nick.h irc-protocol.c irc-protocol.h irc-server.c
|
||||
irc-server.h)
|
||||
|
||||
CHECK_INCLUDE_FILES("regex.h" HAVE_REGEX_H)
|
||||
CHECK_FUNCTION_EXISTS(regexec HAVE_REGEXEC)
|
||||
CHECK_FUNCTION_EXISTS(uname HAVE_UNAME)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
ADD_LIBRARY(weechat_irc STATIC ${LIB_IRC_SRC})
|
||||
ADD_LIBRARY(weechat_protocol_irc STATIC ${LIB_PROTOCOL_IRC_SRC})
|
||||
|
||||
+29
-12
@@ -16,16 +16,33 @@
|
||||
|
||||
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GNUTLS_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = lib_weechat_irc.a
|
||||
libdir = ${weechat_libdir}/plugins
|
||||
|
||||
lib_weechat_irc_a_SOURCES = irc.h \
|
||||
irc-commands.c \
|
||||
irc-send.c \
|
||||
irc-recv.c \
|
||||
irc-server.c \
|
||||
irc-channel.c \
|
||||
irc-nick.c \
|
||||
irc-mode.c \
|
||||
irc-dcc.c \
|
||||
irc-ignore.c \
|
||||
irc-display.c
|
||||
lib_LTLIBRARIES = irc.la
|
||||
|
||||
irc_la_SOURCES = irc.h \
|
||||
irc-buffer.c \
|
||||
irc-buffer.h \
|
||||
irc-channel.c \
|
||||
irc-channel.h \
|
||||
irc-command.c \
|
||||
irc-command.h \
|
||||
irc-color.c \
|
||||
irc-color.h \
|
||||
irc-config.c \
|
||||
irc-config.h \
|
||||
irc-core.c \
|
||||
irc-dcc.c \
|
||||
irc-dcc.h \
|
||||
irc-display.c \
|
||||
irc-input.c \
|
||||
irc-log.c \
|
||||
irc-mode.c \
|
||||
irc-nick.c \
|
||||
irc-nick.h \
|
||||
irc-protocol.c \
|
||||
irc-protocol.h \
|
||||
irc-server.c \
|
||||
irc-server.h
|
||||
irc_la_LDFLAGS = -module
|
||||
irc_la_LIBADD = $(GNUTLS_LFLAGS)
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-buffer.c: manages buffers for IRC protocol */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../core/utf8.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_buffer_data_create: create protocol data (for GUI buffer)
|
||||
*/
|
||||
|
||||
t_irc_buffer_data *
|
||||
irc_buffer_data_create (t_irc_server *server)
|
||||
{
|
||||
t_irc_buffer_data *buffer_data;
|
||||
|
||||
buffer_data = (t_irc_buffer_data *)malloc (sizeof (t_irc_buffer_data));
|
||||
if (!buffer_data)
|
||||
return NULL;
|
||||
|
||||
buffer_data->server = server;
|
||||
buffer_data->channel = NULL;
|
||||
buffer_data->all_servers = irc_cfg_irc_one_server_buffer;
|
||||
|
||||
return buffer_data;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_buffer_data_free: free protocol data (in GUI buffer)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_buffer_data_free (t_gui_buffer *buffer)
|
||||
{
|
||||
free ((t_irc_buffer_data *)buffer->protocol_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_buffer_servers_search: search servers buffer
|
||||
* (when same buffer is used for all servers)
|
||||
*/
|
||||
|
||||
t_gui_buffer *
|
||||
irc_buffer_servers_search ()
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (IRC_BUFFER_ALL_SERVERS(ptr_buffer))
|
||||
return ptr_buffer;
|
||||
|
||||
}
|
||||
|
||||
/* buffer not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_buffer_merge_servers: merge server buffers in one buffer
|
||||
*/
|
||||
|
||||
void
|
||||
irc_buffer_merge_servers (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer_server, *ptr_buffer, *new_ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
/* new server buffer is the first server buffer found */
|
||||
for (ptr_buffer_server = gui_buffers; ptr_buffer_server;
|
||||
ptr_buffer_server = ptr_buffer_server->next_buffer)
|
||||
{
|
||||
if ((ptr_buffer_server->protocol == irc_protocol)
|
||||
&& (IRC_BUFFER_SERVER(ptr_buffer_server))
|
||||
&& (!IRC_BUFFER_CHANNEL(ptr_buffer_server)))
|
||||
break;
|
||||
}
|
||||
|
||||
/* no server buffer found */
|
||||
if (!ptr_buffer_server)
|
||||
return;
|
||||
|
||||
ptr_buffer = gui_buffers;
|
||||
while (ptr_buffer)
|
||||
{
|
||||
if ((ptr_buffer->protocol == irc_protocol)
|
||||
&& (ptr_buffer != ptr_buffer_server)
|
||||
&& (IRC_BUFFER_SERVER(ptr_buffer))
|
||||
&& (!IRC_BUFFER_CHANNEL(ptr_buffer)))
|
||||
{
|
||||
ptr_server = IRC_BUFFER_SERVER(ptr_buffer);
|
||||
|
||||
/* add (by pointer artefact) lines from buffer found to server buffer */
|
||||
if (ptr_buffer->lines)
|
||||
{
|
||||
if (ptr_buffer_server->lines)
|
||||
{
|
||||
ptr_buffer->lines->prev_line =
|
||||
ptr_buffer_server->last_line;
|
||||
ptr_buffer_server->last_line->next_line =
|
||||
ptr_buffer->lines;
|
||||
ptr_buffer_server->last_line =
|
||||
ptr_buffer->last_line;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_buffer_server->lines = ptr_buffer->lines;
|
||||
ptr_buffer_server->last_line = ptr_buffer->last_line;
|
||||
}
|
||||
}
|
||||
|
||||
/* free buffer but not lines, because they're now used by
|
||||
our unique server buffer */
|
||||
new_ptr_buffer = ptr_buffer->next_buffer;
|
||||
ptr_buffer->lines = NULL;
|
||||
gui_buffer_free (ptr_buffer, 1);
|
||||
ptr_buffer = new_ptr_buffer;
|
||||
|
||||
/* asociate server with new server buffer */
|
||||
ptr_server->buffer = ptr_buffer_server;
|
||||
}
|
||||
else
|
||||
ptr_buffer = ptr_buffer->next_buffer;
|
||||
}
|
||||
|
||||
IRC_BUFFER_ALL_SERVERS(ptr_buffer_server) = 1;
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_buffer_split_server: split the server buffer into many buffers (one by server)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_buffer_split_server (t_gui_window *window)
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
char *log_filename;
|
||||
|
||||
ptr_buffer = gui_buffer_servers_search ();
|
||||
|
||||
if (ptr_buffer)
|
||||
{
|
||||
if (IRC_BUFFER_SERVER(ptr_buffer))
|
||||
{
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (ptr_server->buffer
|
||||
&& (ptr_server != IRC_BUFFER_SERVER(ptr_buffer))
|
||||
&& (ptr_server->buffer == ptr_buffer))
|
||||
{
|
||||
ptr_server->buffer = NULL;
|
||||
log_filename = irc_log_get_filename (ptr_server->name,
|
||||
NULL,
|
||||
0);
|
||||
gui_buffer_new (window, 0,
|
||||
ptr_server->name,
|
||||
ptr_server->name,
|
||||
GUI_BUFFER_ATTRIB_TEXT |
|
||||
GUI_BUFFER_ATTRIB_INPUT |
|
||||
GUI_BUFFER_ATTRIB_NICKS,
|
||||
irc_protocol,
|
||||
irc_buffer_data_create (ptr_server),
|
||||
&irc_buffer_data_free,
|
||||
GUI_NOTIFY_LEVEL_DEFAULT,
|
||||
NULL, ptr_server->nick,
|
||||
irc_cfg_log_auto_server, log_filename,
|
||||
0);
|
||||
if (log_filename)
|
||||
free (log_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
IRC_BUFFER_ALL_SERVERS(ptr_buffer) = 0;
|
||||
gui_status_draw (window->buffer, 1);
|
||||
gui_input_draw (window->buffer, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_BUFFER_H
|
||||
#define __WEECHAT_IRC_BUFFER_H 1
|
||||
|
||||
#include "irc-server.h"
|
||||
#include "irc-channel.h"
|
||||
|
||||
#define IRC_BUFFER_SERVER(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->server)
|
||||
#define IRC_BUFFER_CHANNEL(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->channel)
|
||||
#define IRC_BUFFER_ALL_SERVERS(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->all_servers)
|
||||
|
||||
#define IRC_BUFFER_GET_SERVER(buffer) \
|
||||
t_irc_server *ptr_server = IRC_BUFFER_SERVER(buffer)
|
||||
#define IRC_BUFFER_GET_CHANNEL(buffer) \
|
||||
t_irc_channel *ptr_channel = IRC_BUFFER_CHANNEL(buffer)
|
||||
#define IRC_BUFFER_GET_SERVER_CHANNEL(buffer) \
|
||||
t_irc_server *ptr_server = IRC_BUFFER_SERVER(buffer); \
|
||||
t_irc_channel *ptr_channel = IRC_BUFFER_CHANNEL(buffer)
|
||||
|
||||
/* protocol data for GUI buffers */
|
||||
|
||||
typedef struct t_irc_buffer_data t_irc_buffer_data;
|
||||
|
||||
struct t_irc_buffer_data
|
||||
{
|
||||
t_irc_server *server;
|
||||
t_irc_channel *channel;
|
||||
int all_servers;
|
||||
};
|
||||
|
||||
#endif /* irc-buffer.h */
|
||||
@@ -27,24 +27,28 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../core/utf8.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_channel_new: allocate a new channel for a server and add it to the
|
||||
* server queue
|
||||
* irc_channel_new: allocate a new channel for a server and add it to servers
|
||||
* list
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
irc_channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
irc_channel_new (t_irc_server *server, int channel_type, char *channel_name,
|
||||
int switch_to_channel)
|
||||
{
|
||||
t_irc_channel *new_channel;
|
||||
t_gui_buffer *new_buffer;
|
||||
int attribs, log_buffer;
|
||||
char *log_filename;
|
||||
|
||||
/* alloc memory for new channel */
|
||||
if ((new_channel = (t_irc_channel *) malloc (sizeof (t_irc_channel))) == NULL)
|
||||
@@ -53,6 +57,40 @@ irc_channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
log_buffer = 0;
|
||||
attribs = GUI_BUFFER_ATTRIB_TEXT | GUI_BUFFER_ATTRIB_INPUT |
|
||||
GUI_BUFFER_ATTRIB_NICKS;
|
||||
switch (channel_type)
|
||||
{
|
||||
case IRC_CHANNEL_TYPE_CHANNEL:
|
||||
if (irc_cfg_log_auto_channel)
|
||||
log_buffer = 1;
|
||||
attribs |= GUI_BUFFER_ATTRIB_NICKLIST;
|
||||
break;
|
||||
case IRC_CHANNEL_TYPE_PRIVATE:
|
||||
case IRC_CHANNEL_TYPE_DCC_CHAT:
|
||||
if (irc_cfg_log_auto_private)
|
||||
log_buffer = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
log_filename = irc_log_get_filename (server->name, channel_name,
|
||||
(channel_type == IRC_CHANNEL_TYPE_DCC_CHAT));
|
||||
new_buffer = gui_buffer_new (gui_current_window, 0,
|
||||
server->name, channel_name,
|
||||
attribs,
|
||||
irc_protocol,
|
||||
irc_buffer_data_create (server),
|
||||
&irc_buffer_data_free,
|
||||
GUI_NOTIFY_LEVEL_DEFAULT,
|
||||
channel_name, server->nick,
|
||||
log_buffer, log_filename,
|
||||
switch_to_channel);
|
||||
if (log_filename)
|
||||
free (log_filename);
|
||||
if (!new_buffer)
|
||||
return NULL;
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
@@ -70,11 +108,14 @@ irc_channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
new_channel->nick_completion_reset = 0;
|
||||
new_channel->nicks = NULL;
|
||||
new_channel->last_nick = NULL;
|
||||
new_channel->buffer = NULL;
|
||||
new_channel->buffer = new_buffer;
|
||||
new_channel->nicks_speaking = NULL;
|
||||
new_channel->last_nick_speaking = NULL;
|
||||
|
||||
/* add new channel to queue */
|
||||
IRC_BUFFER_CHANNEL(new_buffer) = new_channel;
|
||||
new_buffer->notify_level = irc_channel_get_notify_level (server, new_channel);
|
||||
|
||||
/* add new channel to channels list */
|
||||
new_channel->prev_channel = server->last_channel;
|
||||
new_channel->next_channel = NULL;
|
||||
if (server->channels)
|
||||
@@ -88,7 +129,7 @@ irc_channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_channel_free: free a channel and remove it from channels queue
|
||||
* irc_channel_free: free a channel and remove it from channels list
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -110,7 +151,7 @@ irc_channel_free (t_irc_server *server, t_irc_channel *channel)
|
||||
}
|
||||
}
|
||||
|
||||
/* remove channel from queue */
|
||||
/* remove channel from channels list */
|
||||
if (server->last_channel == channel)
|
||||
server->last_channel = channel->prev_channel;
|
||||
if (channel->prev_channel)
|
||||
@@ -172,7 +213,7 @@ irc_channel_search (t_irc_server *server, char *channel_name)
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type != IRC_CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
&& (weechat_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
@@ -193,7 +234,7 @@ irc_channel_search_any (t_irc_server *server, char *channel_name)
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ascii_strcasecmp (ptr_channel->name, channel_name) == 0)
|
||||
if (weechat_strcasecmp (ptr_channel->name, channel_name) == 0)
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
@@ -216,7 +257,7 @@ irc_channel_search_any_without_buffer (t_irc_server *server, char *channel_name)
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (!ptr_channel->buffer
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
&& (weechat_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
@@ -238,7 +279,7 @@ irc_channel_search_dcc (t_irc_server *server, char *channel_name)
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
&& (weechat_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
@@ -289,8 +330,8 @@ irc_channel_check_away (t_irc_server *server, t_irc_channel *channel, int force)
|
||||
{
|
||||
if (channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
if (force || (cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= cfg_irc_away_check_max_nicks))
|
||||
if (force || (irc_cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= irc_cfg_irc_away_check_max_nicks))
|
||||
{
|
||||
channel->checking_away++;
|
||||
irc_server_sendf (server, "WHO %s", channel->name);
|
||||
@@ -331,11 +372,9 @@ irc_channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
ptr_channel = irc_channel_new (ptr_dcc->server,
|
||||
IRC_CHANNEL_TYPE_DCC_CHAT,
|
||||
ptr_dcc->nick);
|
||||
ptr_dcc->nick, 0);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
GUI_BUFFER_TYPE_STANDARD, 0);
|
||||
}
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
@@ -452,7 +491,7 @@ irc_channel_print_log (t_irc_channel *channel)
|
||||
weechat_log_printf (" away_message . . . . : '%s'\n", channel->away_message);
|
||||
weechat_log_printf (" cycle. . . . . . . . : %d\n", channel->cycle);
|
||||
weechat_log_printf (" close. . . . . . . . : %d\n", channel->close);
|
||||
weechat_log_printf (" display_creation_date: %d\n", channel->close);
|
||||
weechat_log_printf (" display_creation_date: %d\n", channel->display_creation_date);
|
||||
weechat_log_printf (" nicks. . . . . . . . : 0x%X\n", channel->nicks);
|
||||
weechat_log_printf (" last_nick. . . . . . : 0x%X\n", channel->last_nick);
|
||||
weechat_log_printf (" buffer . . . . . . . : 0x%X\n", channel->buffer);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_CHANNEL_H
|
||||
#define __WEECHAT_IRC_CHANNEL_H 1
|
||||
|
||||
#include "irc-nick.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
#define IRC_CHANNEL_PREFIX "#&+!"
|
||||
|
||||
/* channel types */
|
||||
#define IRC_CHANNEL_TYPE_UNKNOWN -1
|
||||
#define IRC_CHANNEL_TYPE_CHANNEL 0
|
||||
#define IRC_CHANNEL_TYPE_PRIVATE 1
|
||||
#define IRC_CHANNEL_TYPE_DCC_CHAT 2
|
||||
|
||||
#define IRC_CHANNEL_NICKS_SPEAKING_LIMIT 32
|
||||
|
||||
typedef struct t_irc_channel t_irc_channel;
|
||||
|
||||
struct t_irc_channel
|
||||
{
|
||||
int type; /* channel type */
|
||||
void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
|
||||
char *name; /* name of channel (exemple: "#abc") */
|
||||
char *topic; /* topic of channel (host for private) */
|
||||
char *modes; /* channel modes */
|
||||
int limit; /* user limit (0 is limit not set) */
|
||||
char *key; /* channel key (NULL if no key is set) */
|
||||
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
|
||||
int checking_away; /* = 1 if checking away with WHO cmd */
|
||||
char *away_message; /* to display away only once in private */
|
||||
int cycle; /* currently cycling (/part then /join) */
|
||||
int close; /* close request (/buffer close) */
|
||||
int display_creation_date; /* 1 if creation date should be displayed*/
|
||||
int nick_completion_reset; /* 1 if nick completion should be rebuilt*/
|
||||
/* there was some join/part on channel */
|
||||
t_irc_nick *nicks; /* nicks on the channel */
|
||||
t_irc_nick *last_nick; /* last nick on the channel */
|
||||
t_weelist *nicks_speaking; /* nicks speaking (for smart completion) */
|
||||
t_weelist *last_nick_speaking; /* last nick speaking */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for channel */
|
||||
t_irc_channel *prev_channel; /* link to previous channel */
|
||||
t_irc_channel *next_channel; /* link to next channel */
|
||||
};
|
||||
|
||||
#endif /* irc-channel.h */
|
||||
@@ -0,0 +1,359 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-color.c: IRC color decoding/encidong in messages */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc-color.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_color_decode: parses a message (coming from IRC server),
|
||||
* if keep_colors == 0: remove any color/style in message
|
||||
* otherwise change colors by internal WeeChat color codes
|
||||
* if keep_eechat_attr == 0: remove any weechat color/style attribute
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
irc_color_decode (unsigned char *string, int keep_irc_colors, int keep_weechat_attr)
|
||||
{
|
||||
/*unsigned char *out;
|
||||
int out_length, out_pos, length;
|
||||
char str_fg[3], str_bg[3];
|
||||
int fg, bg, attr;*/
|
||||
|
||||
(void) string;
|
||||
(void) keep_irc_colors;
|
||||
(void) keep_weechat_attr;
|
||||
|
||||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
out_pos = 0;
|
||||
while (string && string[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case IRC_COLOR_BOLD_CHAR:
|
||||
case IRC_COLOR_RESET_CHAR:
|
||||
case IRC_COLOR_FIXED_CHAR:
|
||||
case IRC_COLOR_REVERSE_CHAR:
|
||||
case IRC_COLOR_REVERSE2_CHAR:
|
||||
case IRC_COLOR_ITALIC_CHAR:
|
||||
case IRC_COLOR_UNDERLINE_CHAR:
|
||||
if (keep_irc_colors)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_COLOR_CHAR:
|
||||
string++;
|
||||
str_fg[0] = '\0';
|
||||
str_bg[0] = '\0';
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
str_fg[0] = string[0];
|
||||
str_fg[1] = '\0';
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
str_fg[1] = string[0];
|
||||
str_fg[2] = '\0';
|
||||
string++;
|
||||
}
|
||||
}
|
||||
if (string[0] == ',')
|
||||
{
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
str_bg[0] = string[0];
|
||||
str_bg[1] = '\0';
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
str_bg[1] = string[0];
|
||||
str_bg[2] = '\0';
|
||||
string++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keep_irc_colors)
|
||||
{
|
||||
if (!str_fg[0] && !str_bg[0])
|
||||
out[out_pos++] = IRC_COLOR_COLOR_CHAR;
|
||||
else
|
||||
{
|
||||
attr = 0;
|
||||
if (str_fg[0])
|
||||
{
|
||||
sscanf (str_fg, "%d", &fg);
|
||||
fg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[fg][1];
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
sscanf (str_bg, "%d", &bg);
|
||||
bg %= GUI_NUM_IRC_COLORS;
|
||||
attr |= gui_irc_colors[bg][1];
|
||||
}
|
||||
if (attr & A_BOLD)
|
||||
{
|
||||
out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR;
|
||||
out[out_pos++] = IRC_COLOR_BOLD_CHAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR;
|
||||
out[out_pos++] = IRC_COLOR_BOLD_CHAR;
|
||||
}
|
||||
out[out_pos++] = IRC_COLOR_COLOR_CHAR;
|
||||
if (str_fg[0])
|
||||
{
|
||||
out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0';
|
||||
out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0';
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
out[out_pos++] = ',';
|
||||
out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0';
|
||||
out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_COLOR_CHAR:
|
||||
if (keep_weechat_attr)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]) && isdigit (string[1]))
|
||||
{
|
||||
if (keep_weechat_attr)
|
||||
{
|
||||
out[out_pos++] = string[0];
|
||||
out[out_pos++] = string[1];
|
||||
}
|
||||
string += 2;
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_SET_CHAR:
|
||||
case GUI_ATTR_WEECHAT_REMOVE_CHAR:
|
||||
if (keep_weechat_attr)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (string[0])
|
||||
{
|
||||
if (keep_weechat_attr)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
break;
|
||||
case GUI_ATTR_WEECHAT_RESET_CHAR:
|
||||
if (keep_weechat_attr)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
length = utf8_char_size ((char *)string);
|
||||
if (length == 0)
|
||||
length = 1;
|
||||
memcpy (out + out_pos, string, length);
|
||||
out_pos += length;
|
||||
string += length;
|
||||
}
|
||||
}
|
||||
out[out_pos] = '\0';
|
||||
return out;*/
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_color_decode_for_user_entry: parses a message (coming from IRC server),
|
||||
* and replaces colors/bold/.. by ^C, ^B, ..
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
irc_color_decode_for_user_entry (unsigned char *string)
|
||||
{
|
||||
/*unsigned char *out;
|
||||
int out_length, out_pos, length;*/
|
||||
|
||||
(void) string;
|
||||
|
||||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
out_pos = 0;
|
||||
while (string && string[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case IRC_COLOR_BOLD_CHAR:
|
||||
out[out_pos++] = 0x02; // ^B
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_FIXED_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_RESET_CHAR:
|
||||
out[out_pos++] = 0x0F; // ^O
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_REVERSE_CHAR:
|
||||
case IRC_COLOR_REVERSE2_CHAR:
|
||||
out[out_pos++] = 0x12; // ^R
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_ITALIC_CHAR:
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_UNDERLINE_CHAR:
|
||||
out[out_pos++] = 0x15; // ^U
|
||||
string++;
|
||||
break;
|
||||
case IRC_COLOR_COLOR_CHAR:
|
||||
out[out_pos++] = 0x03; // ^C
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
length = utf8_char_size ((char *)string);
|
||||
if (length == 0)
|
||||
length = 1;
|
||||
memcpy (out + out_pos, string, length);
|
||||
out_pos += length;
|
||||
string += length;
|
||||
}
|
||||
}
|
||||
out[out_pos] = '\0';
|
||||
return out;*/
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_color_encode: parses a message (entered by user), and
|
||||
* encode special chars (^Cb, ^Cc, ..) in IRC colors
|
||||
* if keep_colors == 0: remove any color/style in message
|
||||
* otherwise: keep colors
|
||||
* After use, string returned has to be free()
|
||||
*/
|
||||
|
||||
unsigned char *
|
||||
irc_color_encode (unsigned char *string, int keep_colors)
|
||||
{
|
||||
/*unsigned char *out;
|
||||
int out_length, out_pos, length;*/
|
||||
|
||||
(void) string;
|
||||
(void) keep_colors;
|
||||
|
||||
return NULL;
|
||||
|
||||
/*out_length = (strlen ((char *)string) * 2) + 1;
|
||||
out = (unsigned char *)malloc (out_length);
|
||||
if (!out)
|
||||
return NULL;
|
||||
|
||||
out_pos = 0;
|
||||
while (string && string[0] && (out_pos < out_length - 1))
|
||||
{
|
||||
switch (string[0])
|
||||
{
|
||||
case 0x02: // ^B
|
||||
if (keep_colors)
|
||||
out[out_pos++] = IRC_COLOR_BOLD_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 0x03: // ^C
|
||||
if (keep_colors)
|
||||
out[out_pos++] = IRC_COLOR_COLOR_CHAR;
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
if (string[0] == ',')
|
||||
{
|
||||
if (keep_colors)
|
||||
out[out_pos++] = ',';
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
if (isdigit (string[0]))
|
||||
{
|
||||
if (keep_colors)
|
||||
out[out_pos++] = string[0];
|
||||
string++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x0F: // ^O
|
||||
if (keep_colors)
|
||||
out[out_pos++] = IRC_COLOR_RESET_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 0x12: // ^R
|
||||
if (keep_colors)
|
||||
out[out_pos++] = IRC_COLOR_REVERSE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
case 0x15: // ^U
|
||||
if (keep_colors)
|
||||
out[out_pos++] = IRC_COLOR_UNDERLINE_CHAR;
|
||||
string++;
|
||||
break;
|
||||
default:
|
||||
length = utf8_char_size ((char *)string);
|
||||
if (length == 0)
|
||||
length = 1;
|
||||
memcpy (out + out_pos, string, length);
|
||||
out_pos += length;
|
||||
string += length;
|
||||
}
|
||||
}
|
||||
out[out_pos] = '\0';
|
||||
return out;*/
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_COLOR_H
|
||||
#define __WEECHAT_IRC_COLOR_H 1
|
||||
|
||||
/* shift ncurses colors for compatibility with colors
|
||||
in IRC messages (same as other IRC clients) */
|
||||
|
||||
#define WEECHAT_COLOR_BLACK COLOR_BLACK
|
||||
#define WEECHAT_COLOR_RED COLOR_BLUE
|
||||
#define WEECHAT_COLOR_GREEN COLOR_GREEN
|
||||
#define WEECHAT_COLOR_YELLOW COLOR_CYAN
|
||||
#define WEECHAT_COLOR_BLUE COLOR_RED
|
||||
#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA
|
||||
#define WEECHAT_COLOR_CYAN COLOR_YELLOW
|
||||
#define WEECHAT_COLOR_WHITE COLOR_WHITE
|
||||
|
||||
/* attributes in IRC messages for color & style (bold, ..) */
|
||||
|
||||
#define IRC_COLOR_BOLD_CHAR '\x02'
|
||||
#define IRC_COLOR_BOLD_STR "\x02"
|
||||
#define IRC_COLOR_COLOR_CHAR '\x03'
|
||||
#define IRC_COLOR_COLOR_STR "\x03"
|
||||
#define IRC_COLOR_RESET_CHAR '\x0F'
|
||||
#define IRC_COLOR_RESET_STR "\x0F"
|
||||
#define IRC_COLOR_FIXED_CHAR '\x11'
|
||||
#define IRC_COLOR_FIXED_STR "\x11"
|
||||
#define IRC_COLOR_REVERSE_CHAR '\x12'
|
||||
#define IRC_COLOR_REVERSE_STR "\x12"
|
||||
#define IRC_COLOR_REVERSE2_CHAR '\x16'
|
||||
#define IRC_COLOR_REVERSE2_STR "\x16"
|
||||
#define IRC_COLOR_ITALIC_CHAR '\x1D'
|
||||
#define IRC_COLOR_ITALIC_STR "\x1D"
|
||||
#define IRC_COLOR_UNDERLINE_CHAR '\x1F'
|
||||
#define IRC_COLOR_UNDERLINE_STR "\x1F"
|
||||
|
||||
#endif /* irc-color.h */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_COMMAND_H
|
||||
#define __WEECHAT_IRC_COMMAND_H 1
|
||||
|
||||
#include "../../core/command.h"
|
||||
|
||||
extern t_weechat_command irc_commands[];
|
||||
|
||||
extern int irc_cmd_admin (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ame (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_amsg (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_away (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_connect (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ctcp (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_cycle (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_dcc (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_dehalfop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_deop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_devoice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_die (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_disconnect (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_halfop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_info (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_invite (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ison (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_join (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kick (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kickban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kill (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_links (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_list (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_lusers (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_me (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_mode (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_motd (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_names (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_nick (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_notice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_op (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_oper (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_part (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ping (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_pong (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_query (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_quit (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_quote (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_reconnect (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_rehash (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_restart (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_service (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_server (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_servlist (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_squery (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_squit (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_stats (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_summon (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_time (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_topic (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_trace (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_unban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_userhost (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_users (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_version (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_voice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_wallops (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_who (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_whois (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_whowas (t_gui_window *, char *, int, char **);
|
||||
|
||||
#endif /* irc-command.h */
|
||||
@@ -1,514 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-commands.c: implementation of IRC commands, according to
|
||||
RFC 1459,2810,2811,2812 */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/command.h"
|
||||
|
||||
|
||||
t_irc_command irc_commands[] =
|
||||
{ { "admin", N_("find information about the administrator of the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_admin, NULL },
|
||||
{ "ame", N_("send a CTCP action to all channels of all connected servers"),
|
||||
N_("message"),
|
||||
N_("message: message to send"),
|
||||
"", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_ame, NULL },
|
||||
{ "amsg", N_("send message to all channels of all connected servers"),
|
||||
N_("text"),
|
||||
N_("text: text to send"),
|
||||
"", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_amsg, NULL },
|
||||
{ "away", N_("toggle away status"),
|
||||
N_("[-all] [message]"),
|
||||
N_(" -all: toggle away status on all connected servers\n"
|
||||
"message: message for away (if no message is given, away status is removed)"),
|
||||
"-all", 0, MAX_ARGS, 1, 0, NULL, irc_send_cmd_away, NULL },
|
||||
{ "ban", N_("bans nicks or hosts"),
|
||||
N_("[channel] [nickname [nickname ...]]"),
|
||||
N_(" channel: channel for ban\n"
|
||||
"nickname: user or host to ban"),
|
||||
"%N", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_ban, NULL },
|
||||
{ "ctcp", N_("send a CTCP message (Client-To-Client Protocol)"),
|
||||
N_("receiver type [arguments]"),
|
||||
N_(" receiver: nick or channel to send CTCP to\n"
|
||||
" type: CTCP type (examples: \"version\", \"ping\", ..)\n"
|
||||
"arguments: arguments for CTCP"),
|
||||
"%c|%n action|ping|version", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_ctcp, NULL },
|
||||
{ "cycle", N_("leave and rejoin a channel"),
|
||||
N_("[channel[,channel]] [part_message]"),
|
||||
N_(" channel: channel name for cycle\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_cycle, NULL },
|
||||
{ "dehalfop", N_("removes half channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_dehalfop, NULL, NULL },
|
||||
{ "deop", N_("removes channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_deop, NULL, NULL },
|
||||
{ "devoice", N_("removes voice from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_devoice, NULL, NULL },
|
||||
{ "die", N_("shutdown the server"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_die, NULL },
|
||||
{ "error", N_("error received from IRC server"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "halfop", N_("gives half channel operator status to nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_halfop, NULL, NULL },
|
||||
{ "info", N_("get information describing the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_info, NULL },
|
||||
{ "invite", N_("invite a nick on a channel"),
|
||||
N_("nickname channel"),
|
||||
N_("nickname: nick to invite\n"
|
||||
" channel: channel to invite"),
|
||||
"%n %c", 1, 2, 0, 1, irc_send_cmd_invite, NULL, irc_recv_cmd_invite },
|
||||
{ "ison", N_("check if a nickname is currently on IRC"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_ison, NULL },
|
||||
{ "join", N_("join a channel"),
|
||||
N_("channel[,channel] [key[,key]]"),
|
||||
N_("channel: channel name to join\n"
|
||||
" key: key to join the channel"),
|
||||
"%C", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_join, irc_recv_cmd_join },
|
||||
{ "kick", N_("forcibly remove a user from a channel"),
|
||||
N_("[channel] nickname [comment]"),
|
||||
N_(" channel: channel where user is\n"
|
||||
"nickname: nickname to kick\n"
|
||||
" comment: comment for kick"),
|
||||
"%n %-", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kick, irc_recv_cmd_kick },
|
||||
{ "kickban", N_("kicks and bans a nick from a channel"),
|
||||
N_("[channel] nickname [comment]"),
|
||||
N_(" channel: channel where user is\n"
|
||||
"nickname: nickname to kick and ban\n"
|
||||
" comment: comment for kick"),
|
||||
"%n %-", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kickban, NULL },
|
||||
{ "kill", N_("close client-server connection"),
|
||||
N_("nickname comment"),
|
||||
N_("nickname: nickname\n"
|
||||
" comment: comment for kill"),
|
||||
"%n %-", 2, MAX_ARGS, 0, 1, NULL, irc_send_cmd_kill, irc_recv_cmd_kill },
|
||||
{ "links", N_("list all servernames which are known by the server answering the query"),
|
||||
N_("[[server] server_mask]"),
|
||||
N_(" server: this server should answer the query\n"
|
||||
"server_mask: list of servers must match this mask"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_links, NULL },
|
||||
{ "list", N_("list channels and their topic"),
|
||||
N_("[channel[,channel] [server]]"),
|
||||
N_("channel: channel to list (a regexp is allowed)\nserver: server name"),
|
||||
NULL, 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_list, NULL },
|
||||
{ "lusers", N_("get statistics about the size of the IRC network"),
|
||||
N_("[mask [target]]"),
|
||||
N_(" mask: servers matching the mask only\n"
|
||||
"target: server for forwarding request"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_lusers, NULL },
|
||||
{ "me", N_("send a CTCP action to the current channel"),
|
||||
N_("message"),
|
||||
N_("message: message to send"),
|
||||
"", 0, MAX_ARGS, 1, 1, NULL, irc_send_cmd_me, NULL },
|
||||
{ "mode", N_("change channel or user mode"),
|
||||
N_("{ channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask] } | "
|
||||
"{ nickname {[+|-]|i|w|s|o} }"),
|
||||
N_("channel modes:\n"
|
||||
" channel: channel name to modify\n"
|
||||
" o: give/take channel operator privileges\n"
|
||||
" p: private channel flag\n"
|
||||
" s: secret channel flag\n"
|
||||
" i: invite-only channel flag\n"
|
||||
" t: topic settable by channel operator only flag\n"
|
||||
" n: no messages to channel from clients on the outside\n"
|
||||
" m: moderated channel\n"
|
||||
" l: set the user limit to channel\n"
|
||||
" b: set a ban mask to keep users out\n"
|
||||
" e: set exception mask\n"
|
||||
" v: give/take the ability to speak on a moderated channel\n"
|
||||
" k: set a channel key (password)\n"
|
||||
"user modes:\n"
|
||||
" nickname: nickname to modify\n"
|
||||
" i: mark a user as invisible\n"
|
||||
" s: mark a user for receive server notices\n"
|
||||
" w: user receives wallops\n"
|
||||
" o: operator flag"),
|
||||
"%c|%m", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_mode, irc_recv_cmd_mode },
|
||||
{ "motd", N_("get the \"Message Of The Day\""),
|
||||
N_("[target]"),
|
||||
N_("target: server name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_motd, NULL },
|
||||
{ "msg", N_("send message to a nick or channel"),
|
||||
N_("receiver[,receiver] text"),
|
||||
N_("receiver: nick or channel (may be mask, '*' = current channel)\n"
|
||||
"text: text to send"),
|
||||
"", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_msg, NULL },
|
||||
{ "names", N_("list nicknames on channels"),
|
||||
N_("[channel[,channel]]"),
|
||||
N_("channel: channel name"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_names, NULL },
|
||||
{ "nick", N_("change current nickname"),
|
||||
N_("[-all] nickname"),
|
||||
N_(" -all: set new nickname for all connected servers\n"
|
||||
"nickname: new nickname"),
|
||||
"-all", 1, 2, 0, 0, irc_send_cmd_nick, NULL, irc_recv_cmd_nick },
|
||||
{ "notice", N_("send notice message to user"),
|
||||
N_("nickname text"),
|
||||
N_("nickname: user to send notice to\n"
|
||||
" text: text to send"),
|
||||
"%n %-", 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_notice, irc_recv_cmd_notice },
|
||||
{ "op", N_("gives channel operator status to nickname(s)"),
|
||||
N_("nickname [nickname]"), "",
|
||||
"", 1, MAX_ARGS, 0, 1, irc_send_cmd_op, NULL, NULL },
|
||||
{ "oper", N_("get operator privileges"),
|
||||
N_("user password"),
|
||||
N_("user/password: used to get privileges on current IRC server"),
|
||||
NULL, 2, 2, 0, 1, NULL, irc_send_cmd_oper, NULL },
|
||||
{ "part", N_("leave a channel"),
|
||||
N_("[channel[,channel]] [part_message]"),
|
||||
N_(" channel: channel name to leave\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 0, 1, NULL, irc_send_cmd_part, irc_recv_cmd_part },
|
||||
{ "ping", N_("ping server"),
|
||||
N_("server1 [server2]"),
|
||||
N_("server1: server to ping\nserver2: forward ping to this server"),
|
||||
NULL, 1, 2, 0, 1, NULL, irc_send_cmd_ping, irc_recv_cmd_ping },
|
||||
{ "pong", N_("answer to a ping message"),
|
||||
N_("daemon [daemon2]"),
|
||||
N_(" daemon: daemon who has responded to Ping message\n"
|
||||
"daemon2: forward message to this daemon"),
|
||||
NULL, 1, 2, 0, 1, NULL, irc_send_cmd_pong, irc_recv_cmd_pong },
|
||||
{ "privmsg", N_("message received"), "", "",
|
||||
"", 0, 0, 1, 1, NULL, NULL, irc_recv_cmd_privmsg },
|
||||
{ "query", N_("send a private message to a nick"),
|
||||
N_("nickname [text]"),
|
||||
N_("nickname: nickname for private conversation\n"
|
||||
" text: text to send"),
|
||||
"%n %-", 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_query, NULL },
|
||||
{ "quit", N_("close all connections and quit"),
|
||||
N_("[quit_message]"),
|
||||
N_("quit_message: quit message (displayed to other users)"),
|
||||
"%q", 0, MAX_ARGS, 1, 0, NULL, irc_send_cmd_quit, irc_recv_cmd_quit },
|
||||
{ "quote", N_("send raw data to server without parsing"),
|
||||
N_("data"),
|
||||
N_("data: raw data to send"),
|
||||
"", 1, MAX_ARGS, 1, 0, NULL, irc_send_cmd_quote, NULL },
|
||||
{ "rehash", N_("tell the server to reload its config file"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_rehash, NULL },
|
||||
{ "restart", N_("tell the server to restart itself"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, irc_send_cmd_restart, NULL },
|
||||
{ "service", N_("register a new service"),
|
||||
N_("nickname reserved distribution type reserved info"),
|
||||
N_("distribution: visibility of service\n"
|
||||
" type: reserved for future usage"),
|
||||
NULL, 6, 6, 0, 1, NULL, irc_send_cmd_service, NULL },
|
||||
{ "servlist", N_("list services currently connected to the network"),
|
||||
N_("[mask [type]]"),
|
||||
N_("mask: list only services matching this mask\n"
|
||||
"type: list only services of this type"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_servlist, NULL },
|
||||
{ "squery", N_("deliver a message to a service"),
|
||||
N_("service text"),
|
||||
N_("service: name of service\ntext: text to send"),
|
||||
NULL, 2, MAX_ARGS, 1, 1, NULL, irc_send_cmd_squery, NULL },
|
||||
{ "squit", N_("disconnect server links"),
|
||||
N_("server comment"),
|
||||
N_( "server: server name\n"
|
||||
"comment: comment for quit"),
|
||||
NULL, 2, 2, 1, 1, NULL, irc_send_cmd_squit, NULL },
|
||||
{ "stats", N_("query statistics about server"),
|
||||
N_("[query [server]]"),
|
||||
N_(" query: c/h/i/k/l/m/o/y/u (see RFC1459)\n"
|
||||
"server: server name"),
|
||||
NULL, 0, 2, 0, 1, NULL, irc_send_cmd_stats, NULL },
|
||||
{ "summon", N_("give users who are on a host running an IRC server a message "
|
||||
"asking them to please join IRC"),
|
||||
N_("user [target [channel]]"),
|
||||
N_(" user: username\ntarget: server name\n"
|
||||
"channel: channel name"),
|
||||
NULL, 1, 3, 0, 1, NULL, irc_send_cmd_summon, NULL },
|
||||
{ "time", N_("query local time from server"),
|
||||
N_("[target]"),
|
||||
N_("target: query time from specified server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_time, NULL },
|
||||
{ "topic", N_("get/set channel topic"),
|
||||
N_("[channel] [topic]"),
|
||||
N_("channel: channel name\ntopic: new topic for channel "
|
||||
"(if topic is \"-delete\" then topic is deleted)"),
|
||||
"%t|-delete %-", 0, MAX_ARGS, 1, 1, NULL, irc_send_cmd_topic, irc_recv_cmd_topic },
|
||||
{ "trace", N_("find the route to specific server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_trace, NULL },
|
||||
{ "unban", N_("unbans nicks or hosts"),
|
||||
N_("[channel] nickname [nickname ...]"),
|
||||
N_(" channel: channel for unban\n"
|
||||
"nickname: user or host to unban"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_unban, NULL },
|
||||
{ "userhost", N_("return a list of information about nicknames"),
|
||||
N_("nickname [nickname ...]"),
|
||||
N_("nickname: nickname"),
|
||||
"%n", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_userhost, NULL },
|
||||
{ "users", N_("list of users logged into the server"),
|
||||
N_("[target]"),
|
||||
N_("target: server"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_users, NULL },
|
||||
{ "version", N_("gives the version info of nick or server (current or specified)"),
|
||||
N_("[server | nickname]"),
|
||||
N_(" server: server name\n"
|
||||
"nickname: nickname"),
|
||||
NULL, 0, 1, 0, 1, NULL, irc_send_cmd_version, NULL },
|
||||
{ "voice", N_("gives voice to nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 0, 1, irc_send_cmd_voice, NULL, NULL },
|
||||
{ "wallops", N_("send a message to all currently connected users who have "
|
||||
"set the 'w' user mode for themselves"),
|
||||
N_("text"),
|
||||
N_("text to send"),
|
||||
NULL, 1, MAX_ARGS, 1, 1, NULL, irc_send_cmd_wallops, irc_recv_cmd_wallops },
|
||||
{ "who", N_("generate a query which returns a list of information"),
|
||||
N_("[mask [\"o\"]]"),
|
||||
N_("mask: only information which match this mask\n"
|
||||
" o: only operators are returned according to the mask supplied"),
|
||||
"%C", 0, 2, 0, 1, NULL, irc_send_cmd_who, NULL },
|
||||
{ "whois", N_("query information about user(s)"),
|
||||
N_("[server] nickname[,nickname]"),
|
||||
N_(" server: server name\n"
|
||||
"nickname: nickname (may be a mask)"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_whois, NULL },
|
||||
{ "whowas", N_("ask for information about a nickname which no longer exists"),
|
||||
N_("nickname [,nickname [,nickname ...]] [count [target]]"),
|
||||
N_("nickname: nickname to search\n"
|
||||
" count: number of replies to return (full search if negative number)\n"
|
||||
" target: reply should match this mask"),
|
||||
"", 1, MAX_ARGS, 0, 1, NULL, irc_send_cmd_whowas, NULL },
|
||||
{ "001", N_("a server message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_001 },
|
||||
{ "005", N_("a server message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_005 },
|
||||
{ "221", N_("user mode string"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_221 },
|
||||
{ "301", N_("away message"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_301 },
|
||||
{ "302", N_("userhost"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_302 },
|
||||
{ "303", N_("ison"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_303 },
|
||||
{ "305", N_("unaway"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_305 },
|
||||
{ "306", N_("now away"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_306 },
|
||||
{ "307", N_("whois (registered nick)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "310", N_("whois (help mode)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_310 },
|
||||
{ "311", N_("whois (user)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_311 },
|
||||
{ "312", N_("whois (server)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_312 },
|
||||
{ "313", N_("whois (operator)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "314", N_("whowas"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_314 },
|
||||
{ "315", N_("end of /who list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_315 },
|
||||
{ "317", N_("whois (idle)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_317 },
|
||||
{ "318", N_("whois (end)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "319", N_("whois (channels)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_319 },
|
||||
{ "320", N_("whois (identified user)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "321", N_("/list start"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_321 },
|
||||
{ "322", N_("channel (for /list)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_322 },
|
||||
{ "323", N_("/list end"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_323 },
|
||||
{ "324", N_("channel mode"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_324 },
|
||||
{ "326", N_("whois (has oper privs)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "327", N_("whois (host)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_327 },
|
||||
{ "329", N_("channel creation date"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_329 },
|
||||
{ "331", N_("no topic for channel"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_331 },
|
||||
{ "332", N_("topic of channel"),
|
||||
N_("channel :topic"),
|
||||
N_("channel: name of channel\n"
|
||||
" topic: topic of the channel"),
|
||||
NULL, 2, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_332 },
|
||||
{ "333", N_("infos about topic (nick and date changed)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_333 },
|
||||
{ "338", N_("whois (host)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_338 },
|
||||
{ "341", N_("inviting"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_341 },
|
||||
{ "344", N_("channel reop"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_344 },
|
||||
{ "345", N_("end of channel reop list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_345 },
|
||||
{ "348", N_("channel exception list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_348 },
|
||||
{ "349", N_("end of channel exception list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_349 },
|
||||
{ "351", N_("server version"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_351 },
|
||||
{ "352", N_("who"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_352 },
|
||||
{ "353", N_("list of nicks on channel"),
|
||||
N_("channel :[[@|+]nick ...]"),
|
||||
N_("channel: name of channel\n"
|
||||
" nick: nick on the channel"),
|
||||
NULL, 2, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_353 },
|
||||
{ "366", N_("end of /names list"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_366 },
|
||||
{ "367", N_("banlist"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_367 },
|
||||
{ "368", N_("end of banlist"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_368 },
|
||||
{ "378", N_("whois (connecting from)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "379", N_("whois (using modes)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_whois_nick_msg },
|
||||
{ "401", N_("no such nick/channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "402", N_("no such server"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "403", N_("no such channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "404", N_("cannot send to channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "405", N_("too many channels"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "406", N_("was no such nick"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "407", N_("was no such nick"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "409", N_("no origin"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "410", N_("no services"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "411", N_("no recipient"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "412", N_("no text to send"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "413", N_("no toplevel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "414", N_("wilcard in toplevel domain"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "421", N_("unknown command"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "422", N_("MOTD is missing"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "423", N_("no administrative info"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "424", N_("file error"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "431", N_("no nickname given"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "432", N_("erroneous nickname"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_432 },
|
||||
{ "433", N_("nickname already in use"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_433 },
|
||||
{ "436", N_("nickname collision"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "437", N_("resource unavailable"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "438", N_("not authorized to change nickname"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_438 },
|
||||
{ "441", N_("user not in channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "442", N_("not on channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "443", N_("user already on channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "444", N_("user not logged in"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "445", N_("summon has been disabled"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "446", N_("users has been disabled"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "451", N_("you are not registered"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "461", N_("not enough parameters"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "462", N_("you may not register"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "463", N_("your host isn't among the privileged"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "464", N_("password incorrect"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "465", N_("you are banned from this server"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "467", N_("channel key already set"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "470", N_("forwarding to another channel"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "471", N_("channel is already full"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "472", N_("unknown mode char to me"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "473", N_("cannot join channel (invite only)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "474", N_("cannot join channel (banned from channel)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "475", N_("cannot join channel (bad channel key)"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "476", N_("bad channel mask"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "477", N_("channel doesn't support modes"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "481", N_("you're not an IRC operator"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "482", N_("you're not channel operator"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "483", N_("you can't kill a server!"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "484", N_("your connection is restricted!"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "485", N_("user is immune from kick/deop"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "487", N_("network split"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "491", N_("no O-lines for your host"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "501", N_("unknown mode flag"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "502", N_("can't change mode for other users"), "", "",
|
||||
NULL, 0, 0, MAX_ARGS, 1, NULL, NULL, irc_recv_cmd_error },
|
||||
{ "671", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_671 },
|
||||
{ "973", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ "974", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ "975", N_("whois (secure connection)"), "", "",
|
||||
NULL, 0, 0, 0, 1, NULL, NULL, irc_recv_cmd_server_mode_reason },
|
||||
{ NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 1, NULL, NULL, NULL }
|
||||
};
|
||||
@@ -0,0 +1,883 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-config.c: IRC configuration options */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../core/config-option.h"
|
||||
#include "../../core/config-file.h"
|
||||
#include "../../core/hook.h"
|
||||
#include "../../core/util.h"
|
||||
|
||||
|
||||
/* config, irc section */
|
||||
|
||||
int irc_cfg_irc_one_server_buffer;
|
||||
int irc_cfg_irc_open_near_server;
|
||||
char *irc_cfg_irc_nick_prefix;
|
||||
char *irc_cfg_irc_nick_suffix;
|
||||
int irc_cfg_irc_display_away;
|
||||
int irc_cfg_irc_show_away_once;
|
||||
char *irc_cfg_irc_display_away_values[] =
|
||||
{ "off", "local", "channel", NULL };
|
||||
char *irc_cfg_irc_default_msg_part;
|
||||
char *irc_cfg_irc_default_msg_quit;
|
||||
int irc_cfg_irc_notice_as_pv;
|
||||
int irc_cfg_irc_away_check;
|
||||
int irc_cfg_irc_away_check_max_nicks;
|
||||
int irc_cfg_irc_lag_check;
|
||||
int irc_cfg_irc_lag_min_show;
|
||||
int irc_cfg_irc_lag_disconnect;
|
||||
int irc_cfg_irc_anti_flood;
|
||||
char *irc_cfg_irc_highlight;
|
||||
int irc_cfg_irc_colors_receive;
|
||||
int irc_cfg_irc_colors_send;
|
||||
int irc_cfg_irc_send_unknown_commands;
|
||||
|
||||
t_config_option irc_options_irc[] =
|
||||
{ { "irc_one_server_buffer",
|
||||
N_("use same buffer for all servers"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_irc_one_server_buffer, NULL, irc_config_change_one_server_buffer },
|
||||
{ "irc_open_near_server",
|
||||
N_("open new channels/privates near server"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_irc_open_near_server, NULL, irc_config_change_noop },
|
||||
{ "irc_nick_prefix",
|
||||
N_("text to display before nick in chat window"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &irc_cfg_irc_nick_prefix, irc_config_change_noop },
|
||||
{ "irc_nick_suffix",
|
||||
N_("text to display after nick in chat window"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, " |", NULL,
|
||||
NULL, &irc_cfg_irc_nick_suffix, irc_config_change_noop },
|
||||
{ "irc_display_away",
|
||||
N_("display message when (un)marking as away"),
|
||||
OPTION_TYPE_INT_WITH_STRING, 0, 0, 0, "off", irc_cfg_irc_display_away_values,
|
||||
&irc_cfg_irc_display_away, NULL, irc_config_change_noop },
|
||||
{ "irc_show_away_once",
|
||||
N_("show remote away message only once in private"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_irc_show_away_once, NULL, irc_config_change_noop },
|
||||
{ "irc_default_msg_part",
|
||||
N_("default part message (leaving channel) ('%v' will be replaced by "
|
||||
"WeeChat version in string)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "WeeChat %v", NULL,
|
||||
NULL, &irc_cfg_irc_default_msg_part, irc_config_change_noop },
|
||||
{ "irc_default_msg_quit",
|
||||
N_("default quit message ('%v' will be replaced by WeeChat version in "
|
||||
"string)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "WeeChat %v", NULL,
|
||||
NULL, &irc_cfg_irc_default_msg_quit, irc_config_change_noop },
|
||||
{ "irc_notice_as_pv",
|
||||
N_("display notices as private messages"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_irc_notice_as_pv, NULL, irc_config_change_noop },
|
||||
{ "irc_away_check",
|
||||
N_("interval between two checks for away (in minutes, 0 = never check)"),
|
||||
OPTION_TYPE_INT, 0, INT_MAX, 0, NULL, NULL,
|
||||
&irc_cfg_irc_away_check, NULL, irc_config_change_away_check },
|
||||
{ "irc_away_check_max_nicks",
|
||||
N_("do not check away nicks on channels with high number of nicks (0 = unlimited)"),
|
||||
OPTION_TYPE_INT, 0, INT_MAX, 0, NULL, NULL,
|
||||
&irc_cfg_irc_away_check_max_nicks, NULL, irc_config_change_away_check },
|
||||
{ "irc_lag_check",
|
||||
N_("interval between two checks for lag (in seconds)"),
|
||||
OPTION_TYPE_INT, 30, INT_MAX, 60, NULL, NULL,
|
||||
&irc_cfg_irc_lag_check, NULL, irc_config_change_noop },
|
||||
{ "irc_lag_min_show",
|
||||
N_("minimum lag to show (in seconds)"),
|
||||
OPTION_TYPE_INT, 0, INT_MAX, 1, NULL, NULL,
|
||||
&irc_cfg_irc_lag_min_show, NULL, irc_config_change_noop },
|
||||
{ "irc_lag_disconnect",
|
||||
N_("disconnect after important lag (in minutes, 0 = never disconnect)"),
|
||||
OPTION_TYPE_INT, 0, INT_MAX, 5, NULL, NULL,
|
||||
&irc_cfg_irc_lag_disconnect, NULL, irc_config_change_noop },
|
||||
{ "irc_anti_flood",
|
||||
N_("anti-flood: # seconds between two user messages (0 = no anti-flood)"),
|
||||
OPTION_TYPE_INT, 0, 5, 2, NULL, NULL,
|
||||
&irc_cfg_irc_anti_flood, NULL, irc_config_change_noop },
|
||||
{ "irc_highlight",
|
||||
N_("comma separated list of words to highlight (case insensitive comparison, "
|
||||
"words may begin or end with \"*\" for partial match)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &irc_cfg_irc_highlight, irc_config_change_noop },
|
||||
{ "irc_colors_receive",
|
||||
N_("when off, colors codes are ignored in incoming messages"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_irc_colors_receive, NULL, irc_config_change_noop },
|
||||
{ "irc_colors_send",
|
||||
N_("allow user to send colors with special codes (^Cb=bold, ^Ccxx=color, "
|
||||
"^Ccxx,yy=color+background, ^Cu=underline, ^Cr=reverse)"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_irc_colors_send, NULL, irc_config_change_noop },
|
||||
{ "irc_send_unknown_commands",
|
||||
N_("send unknown commands to IRC server"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_irc_send_unknown_commands, NULL, irc_config_change_noop },
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* config, dcc section */
|
||||
|
||||
int irc_cfg_dcc_auto_accept_files;
|
||||
int irc_cfg_dcc_auto_accept_chats;
|
||||
int irc_cfg_dcc_timeout;
|
||||
int irc_cfg_dcc_blocksize;
|
||||
int irc_cfg_dcc_fast_send;
|
||||
char *irc_cfg_dcc_port_range;
|
||||
char *irc_cfg_dcc_own_ip;
|
||||
char *irc_cfg_dcc_download_path;
|
||||
char *irc_cfg_dcc_upload_path;
|
||||
int irc_cfg_dcc_convert_spaces;
|
||||
int irc_cfg_dcc_auto_rename;
|
||||
int irc_cfg_dcc_auto_resume;
|
||||
|
||||
t_config_option irc_options_dcc[] =
|
||||
{ { "dcc_auto_accept_files",
|
||||
N_("automatically accept incoming dcc files"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_dcc_auto_accept_files, NULL, irc_config_change_noop },
|
||||
{ "dcc_auto_accept_chats",
|
||||
N_("automatically accept dcc chats (use carefully!)"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_dcc_auto_accept_chats, NULL, irc_config_change_noop },
|
||||
{ "dcc_timeout",
|
||||
N_("timeout for dcc request (in seconds)"),
|
||||
OPTION_TYPE_INT, 5, INT_MAX, 300, NULL, NULL,
|
||||
&irc_cfg_dcc_timeout, NULL, irc_config_change_noop },
|
||||
{ "dcc_blocksize",
|
||||
N_("block size for dcc packets in bytes (default: 65536)"),
|
||||
OPTION_TYPE_INT, IRC_DCC_MIN_BLOCKSIZE, IRC_DCC_MAX_BLOCKSIZE, 65536, NULL, NULL,
|
||||
&irc_cfg_dcc_blocksize, NULL, irc_config_change_noop },
|
||||
{ "dcc_fast_send",
|
||||
N_("does not wait for ACK when sending file"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_dcc_fast_send, NULL, irc_config_change_noop },
|
||||
{ "dcc_port_range",
|
||||
N_("restricts outgoing dcc to use only ports in the given range "
|
||||
"(useful for NAT) (syntax: a single port, ie. 5000 or a port "
|
||||
"range, ie. 5000-5015, empty value means any port)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &irc_cfg_dcc_port_range, irc_config_change_noop },
|
||||
{ "dcc_own_ip",
|
||||
N_("IP or DNS address used for outgoing dcc "
|
||||
"(if empty, local interface IP is used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &irc_cfg_dcc_own_ip, irc_config_change_noop },
|
||||
{ "dcc_download_path",
|
||||
N_("path for writing incoming files with dcc (default: user home)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "%h/dcc", NULL,
|
||||
NULL, &irc_cfg_dcc_download_path, irc_config_change_noop },
|
||||
{ "dcc_upload_path",
|
||||
N_("path for reading files when sending thru dcc (when no path is "
|
||||
"specified)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "~", NULL,
|
||||
NULL, &irc_cfg_dcc_upload_path, irc_config_change_noop },
|
||||
{ "dcc_convert_spaces",
|
||||
N_("convert spaces to underscores when sending files"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_dcc_convert_spaces, NULL, irc_config_change_noop },
|
||||
{ "dcc_auto_rename",
|
||||
N_("rename incoming files if already exists (add '.1', '.2', ...)"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_dcc_auto_rename, NULL, irc_config_change_noop },
|
||||
{ "dcc_auto_resume",
|
||||
N_("automatically resume dcc transfer if connection with remote host is "
|
||||
"loosed"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_dcc_auto_resume, NULL, irc_config_change_noop },
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* config, log section */
|
||||
|
||||
int irc_cfg_log_auto_server;
|
||||
int irc_cfg_log_auto_channel;
|
||||
int irc_cfg_log_auto_private;
|
||||
int irc_cfg_log_hide_nickserv_pwd;
|
||||
|
||||
t_config_option irc_options_log[] =
|
||||
{ { "log_auto_server",
|
||||
N_("automatically log server messages"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_log_auto_server, NULL, irc_config_change_log },
|
||||
{ "log_auto_channel",
|
||||
N_("automatically log channel chats"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_log_auto_channel, NULL, irc_config_change_log },
|
||||
{ "log_auto_private",
|
||||
N_("automatically log private chats"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&irc_cfg_log_auto_private, NULL, irc_config_change_log },
|
||||
{ "log_hide_nickserv_pwd",
|
||||
N_("hide password displayed by nickserv"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&irc_cfg_log_hide_nickserv_pwd, NULL, irc_config_change_noop },
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* config, server section */
|
||||
|
||||
static t_irc_server cfg_server;
|
||||
|
||||
t_config_option irc_options_server[] =
|
||||
{ { "server_name",
|
||||
N_("name associated to IRC server (for display only)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.name), NULL },
|
||||
{ "server_autoconnect",
|
||||
N_("automatically connect to server when WeeChat is starting"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&(cfg_server.autoconnect), NULL, NULL },
|
||||
{ "server_autoreconnect",
|
||||
N_("automatically reconnect to server when disconnected"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&(cfg_server.autoreconnect), NULL, NULL },
|
||||
{ "server_autoreconnect_delay",
|
||||
N_("delay (in seconds) before trying again to reconnect to server"),
|
||||
OPTION_TYPE_INT, 0, 65535, 30, NULL, NULL,
|
||||
&(cfg_server.autoreconnect_delay), NULL, NULL },
|
||||
{ "server_address",
|
||||
N_("IP address or hostname of IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.address), NULL },
|
||||
{ "server_port",
|
||||
N_("port for connecting to server"),
|
||||
OPTION_TYPE_INT, 0, 65535, 6667, NULL, NULL,
|
||||
&(cfg_server.port), NULL, NULL },
|
||||
{ "server_ipv6",
|
||||
N_("use IPv6 protocol for server communication"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&(cfg_server.ipv6), NULL, NULL },
|
||||
{ "server_ssl",
|
||||
N_("use SSL for server communication"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, NULL, NULL,
|
||||
&(cfg_server.ssl), NULL, NULL },
|
||||
{ "server_password",
|
||||
N_("password for IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.password), NULL },
|
||||
{ "server_nick1",
|
||||
N_("nickname to use on IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.nick1), NULL },
|
||||
{ "server_nick2",
|
||||
N_("alternate nickname to use on IRC server (if nickname is already used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.nick2), NULL },
|
||||
{ "server_nick3",
|
||||
N_("2nd alternate nickname to use on IRC server (if alternate nickname is "
|
||||
"already used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.nick3), NULL },
|
||||
{ "server_username",
|
||||
N_("user name to use on IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.username), NULL },
|
||||
{ "server_realname",
|
||||
N_("real name to use on IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.realname), NULL },
|
||||
{ "server_hostname",
|
||||
N_("custom hostname/IP for server (optional, if empty local hostname is "
|
||||
"used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.hostname), NULL },
|
||||
{ "server_command",
|
||||
N_("command(s) to run when connected to server (many commands should be "
|
||||
"separated by ';', use '\\;' for a semicolon, special variables $nick, "
|
||||
"$channel and $server are replaced by their value)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.command), NULL },
|
||||
{ "server_command_delay",
|
||||
N_("delay (in seconds) after command was executed (example: give some time "
|
||||
"for authentication)"),
|
||||
OPTION_TYPE_INT, 0, 3600, 0, NULL, NULL,
|
||||
&(cfg_server.command_delay), NULL, NULL },
|
||||
{ "server_autojoin",
|
||||
N_("comma separated list of channels to join when connected to server "
|
||||
"(example: \"#chan1,#chan2,#chan3 key1,key2\")"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.autojoin), NULL },
|
||||
{ "server_autorejoin",
|
||||
N_("automatically rejoin channels when kicked"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL,
|
||||
&(cfg_server.autorejoin), NULL, NULL },
|
||||
{ "server_notify_levels",
|
||||
N_("comma separated list of notify levels for channels of this server "
|
||||
"(format: #channel:1,..), a channel name '*' is reserved for server "
|
||||
"default notify level"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0, "", NULL,
|
||||
NULL, &(cfg_server.notify_levels), irc_config_change_notify_levels },
|
||||
{ NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
char *weechat_protocol_config_sections[] =
|
||||
{ "irc", "dcc",
|
||||
"log", "server",
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_option *weechat_protocol_config_options[] =
|
||||
{ irc_options_irc, irc_options_dcc,
|
||||
irc_options_log, NULL,
|
||||
NULL };
|
||||
|
||||
t_config_func_read_option *irc_config_read_functions[] =
|
||||
{ config_file_read_option, config_file_read_option,
|
||||
config_file_read_option, irc_config_read_server,
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_func_write_options *irc_config_write_functions[] =
|
||||
{ config_file_write_options, config_file_write_options,
|
||||
config_file_write_options, irc_config_write_servers,
|
||||
NULL
|
||||
};
|
||||
|
||||
t_config_func_write_options *irc_config_write_default_functions[] =
|
||||
{ config_file_write_options_default_values, config_file_write_options_default_values,
|
||||
config_file_write_options_default_values, irc_config_write_servers_default_values,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* irc_config_change_noop: called when an option is changed by /set command
|
||||
* and that no special action is needed after that
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_noop ()
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_one_server_buffer: called when the "one server buffer"
|
||||
* setting is changed
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_one_server_buffer ()
|
||||
{
|
||||
if (irc_cfg_irc_one_server_buffer)
|
||||
irc_buffer_merge_servers (gui_current_window);
|
||||
else
|
||||
irc_buffer_split_server (gui_current_window);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_away_check: called when away check is changed
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_away_check ()
|
||||
{
|
||||
if (irc_hook_timer_check_away)
|
||||
{
|
||||
weechat_hook_remove (irc_hook_timer_check_away);
|
||||
irc_hook_timer_check_away = NULL;
|
||||
}
|
||||
if (irc_cfg_irc_away_check == 0)
|
||||
{
|
||||
/* reset away flag for all nicks/chans/servers */
|
||||
irc_server_remove_away ();
|
||||
}
|
||||
weechat_hook_add_timer (irc_cfg_irc_away_check * 60 * 1000,
|
||||
irc_server_timer_check_away,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_log: called when log settings are changed
|
||||
* (for server/channel/private logging)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_log ()
|
||||
{
|
||||
t_gui_buffer *ptr_buffer;
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||
ptr_buffer = ptr_buffer->next_buffer)
|
||||
{
|
||||
if (ptr_buffer->protocol == irc_protocol)
|
||||
{
|
||||
ptr_server = irc_server_search (ptr_buffer->category);
|
||||
ptr_channel = irc_channel_search (ptr_server, ptr_buffer->name);
|
||||
|
||||
if (ptr_server && !ptr_channel)
|
||||
{
|
||||
if (irc_cfg_log_auto_server && !ptr_buffer->log_file)
|
||||
gui_log_start (ptr_buffer);
|
||||
else if (!irc_cfg_log_auto_server && ptr_buffer->log_file)
|
||||
gui_log_end (ptr_buffer);
|
||||
}
|
||||
if (ptr_server && ptr_channel)
|
||||
{
|
||||
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
|
||||
{
|
||||
if (irc_cfg_log_auto_channel && !ptr_buffer->log_file)
|
||||
gui_log_start (ptr_buffer);
|
||||
else if (!irc_cfg_log_auto_channel && ptr_buffer->log_file)
|
||||
gui_log_end (ptr_buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (irc_cfg_log_auto_private && !ptr_buffer->log_file)
|
||||
gui_log_start (ptr_buffer);
|
||||
else if (!irc_cfg_log_auto_private && ptr_buffer->log_file)
|
||||
gui_log_end (ptr_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_change_notify_levels: called when notify level is changed
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_change_notify_levels ()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_create_dirs: create configuratoin directories (read from configuration file)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_config_create_dirs ()
|
||||
{
|
||||
char *dir1, *dir2;
|
||||
|
||||
/* create DCC download directory */
|
||||
dir1 = weechat_strreplace (irc_cfg_dcc_download_path, "~", getenv ("HOME"));
|
||||
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
|
||||
(void) weechat_create_dir (dir2, 0700);
|
||||
if (dir1)
|
||||
free (dir1);
|
||||
if (dir2)
|
||||
free (dir2);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_get_server_option_ptr: get a pointer to a server configuration option
|
||||
*/
|
||||
|
||||
void *
|
||||
irc_config_get_server_option_ptr (t_irc_server *server, char *option_name)
|
||||
{
|
||||
if (weechat_strcasecmp (option_name, "server_name") == 0)
|
||||
return (void *)(&server->name);
|
||||
if (weechat_strcasecmp (option_name, "server_autoconnect") == 0)
|
||||
return (void *)(&server->autoconnect);
|
||||
if (weechat_strcasecmp (option_name, "server_autoreconnect") == 0)
|
||||
return (void *)(&server->autoreconnect);
|
||||
if (weechat_strcasecmp (option_name, "server_autoreconnect_delay") == 0)
|
||||
return (void *)(&server->autoreconnect_delay);
|
||||
if (weechat_strcasecmp (option_name, "server_address") == 0)
|
||||
return (void *)(&server->address);
|
||||
if (weechat_strcasecmp (option_name, "server_port") == 0)
|
||||
return (void *)(&server->port);
|
||||
if (weechat_strcasecmp (option_name, "server_ipv6") == 0)
|
||||
return (void *)(&server->ipv6);
|
||||
if (weechat_strcasecmp (option_name, "server_ssl") == 0)
|
||||
return (void *)(&server->ssl);
|
||||
if (weechat_strcasecmp (option_name, "server_password") == 0)
|
||||
return (void *)(&server->password);
|
||||
if (weechat_strcasecmp (option_name, "server_nick1") == 0)
|
||||
return (void *)(&server->nick1);
|
||||
if (weechat_strcasecmp (option_name, "server_nick2") == 0)
|
||||
return (void *)(&server->nick2);
|
||||
if (weechat_strcasecmp (option_name, "server_nick3") == 0)
|
||||
return (void *)(&server->nick3);
|
||||
if (weechat_strcasecmp (option_name, "server_username") == 0)
|
||||
return (void *)(&server->username);
|
||||
if (weechat_strcasecmp (option_name, "server_realname") == 0)
|
||||
return (void *)(&server->realname);
|
||||
if (weechat_strcasecmp (option_name, "server_hostname") == 0)
|
||||
return (void *)(&server->hostname);
|
||||
if (weechat_strcasecmp (option_name, "server_command") == 0)
|
||||
return (void *)(&server->command);
|
||||
if (weechat_strcasecmp (option_name, "server_command_delay") == 0)
|
||||
return (void *)(&server->command_delay);
|
||||
if (weechat_strcasecmp (option_name, "server_autojoin") == 0)
|
||||
return (void *)(&server->autojoin);
|
||||
if (weechat_strcasecmp (option_name, "server_autorejoin") == 0)
|
||||
return (void *)(&server->autorejoin);
|
||||
if (weechat_strcasecmp (option_name, "server_notify_levels") == 0)
|
||||
return (void *)(&server->notify_levels);
|
||||
/* option not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_set_server_value: set new value for an option of a server
|
||||
* return: 0 if success
|
||||
* -1 if option not found
|
||||
* -2 if bad value
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_set_server_value (t_irc_server *server, char *option_name,
|
||||
char *value)
|
||||
{
|
||||
t_config_option *ptr_option;
|
||||
int i;
|
||||
void *ptr_data;
|
||||
int int_value;
|
||||
|
||||
ptr_data = irc_config_get_server_option_ptr (server, option_name);
|
||||
if (!ptr_data)
|
||||
return -1;
|
||||
|
||||
ptr_option = NULL;
|
||||
for (i = 0; irc_options_server[i].name; i++)
|
||||
{
|
||||
/* if option found, return pointer */
|
||||
if (weechat_strcasecmp (irc_options_server[i].name, option_name) == 0)
|
||||
{
|
||||
ptr_option = &irc_options_server[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ptr_option)
|
||||
return -1;
|
||||
|
||||
switch (ptr_option->type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
int_value = config_option_option_get_boolean_value (value);
|
||||
switch (int_value)
|
||||
{
|
||||
case BOOL_TRUE:
|
||||
*((int *)(ptr_data)) = BOOL_TRUE;
|
||||
break;
|
||||
case BOOL_FALSE:
|
||||
*((int *)(ptr_data)) = BOOL_FALSE;
|
||||
break;
|
||||
default:
|
||||
return -2;
|
||||
}
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
int_value = atoi (value);
|
||||
if ((int_value < ptr_option->min) || (int_value > ptr_option->max))
|
||||
return -2;
|
||||
*((int *)(ptr_data)) = int_value;
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
int_value = config_option_get_pos_array_values (ptr_option->array_values,
|
||||
value);
|
||||
if (int_value < 0)
|
||||
return -2;
|
||||
*((int *)(ptr_data)) = int_value;
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
if (!gui_color_assign ((int *)ptr_data, value))
|
||||
return -2;
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
if (*((char **)ptr_data))
|
||||
free (*((char **)ptr_data));
|
||||
*((char **)ptr_data) = strdup (value);
|
||||
break;
|
||||
}
|
||||
if (ptr_option->handler_change != NULL)
|
||||
(void) (ptr_option->handler_change());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_allocate_server: allocate a new server
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_allocate_server (char *filename, int line_number)
|
||||
{
|
||||
if (!cfg_server.name
|
||||
|| !cfg_server.address
|
||||
|| cfg_server.port < 0
|
||||
|| !cfg_server.nick1
|
||||
|| !cfg_server.nick2
|
||||
|| !cfg_server.nick3
|
||||
|| !cfg_server.username
|
||||
|| !cfg_server.realname)
|
||||
{
|
||||
irc_server_free_all ();
|
||||
gui_chat_printf (NULL,
|
||||
_("%s %s, line %d: new server, but previous was "
|
||||
"incomplete\n"),
|
||||
WEECHAT_WARNING, filename, line_number);
|
||||
return 0;
|
||||
|
||||
}
|
||||
if (irc_server_name_already_exists (cfg_server.name))
|
||||
{
|
||||
irc_server_free_all ();
|
||||
gui_chat_printf (NULL,
|
||||
_("%s %s, line %d: server '%s' already exists\n"),
|
||||
WEECHAT_WARNING, filename, line_number,
|
||||
cfg_server.name);
|
||||
return 0;
|
||||
}
|
||||
if (!irc_server_new (cfg_server.name,
|
||||
cfg_server.autoconnect, cfg_server.autoreconnect,
|
||||
cfg_server.autoreconnect_delay, 0, cfg_server.address,
|
||||
cfg_server.port, cfg_server.ipv6, cfg_server.ssl,
|
||||
cfg_server.password, cfg_server.nick1,
|
||||
cfg_server.nick2, cfg_server.nick3,
|
||||
cfg_server.username, cfg_server.realname,
|
||||
cfg_server.hostname, cfg_server.command,
|
||||
cfg_server.command_delay, cfg_server.autojoin,
|
||||
cfg_server.autorejoin, cfg_server.notify_levels))
|
||||
{
|
||||
irc_server_free_all ();
|
||||
gui_chat_printf (NULL,
|
||||
_("%s %s, line %d: unable to create server\n"),
|
||||
WEECHAT_WARNING, filename, line_number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
irc_server_destroy (&cfg_server);
|
||||
irc_server_init (&cfg_server);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_read_server: read a server option in configuration file
|
||||
* Return: 0 = successful
|
||||
* -1 = option not found
|
||||
* -2 = bad format/value
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_read_server (t_config_option *options,
|
||||
char *option_name, char *value)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) options;
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
if (value[0])
|
||||
{
|
||||
/* bind key (overwrite any binding with same key) */
|
||||
gui_keyboard_bind (option_name, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unbin key if no value given */
|
||||
gui_keyboard_unbind (option_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* does nothing for new [key] section */
|
||||
}
|
||||
|
||||
/* all ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_read: read IRC configuration file
|
||||
* return: 0 = successful
|
||||
* -1 = configuration file file not found
|
||||
* -2 = error in configuration file
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_read ()
|
||||
{
|
||||
irc_server_init (&cfg_server);
|
||||
|
||||
return config_file_read (weechat_protocol_config_sections,
|
||||
weechat_protocol_config_options,
|
||||
irc_config_read_functions,
|
||||
irc_config_write_default_functions,
|
||||
IRC_CONFIG_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_write_servers: write servers sections in configuration file
|
||||
* Return: 0 = successful
|
||||
* -1 = write error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_write_servers (FILE *file, char *section_name,
|
||||
t_config_option *options)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) options;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (!ptr_server->temp_server)
|
||||
{
|
||||
weechat_iconv_fprintf (file, "\n[%s]\n", section_name);
|
||||
weechat_iconv_fprintf (file, "server_name = \"%s\"\n", ptr_server->name);
|
||||
weechat_iconv_fprintf (file, "server_autoconnect = %s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect = %s\n",
|
||||
(ptr_server->autoreconnect) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect_delay = %d\n",
|
||||
ptr_server->autoreconnect_delay);
|
||||
weechat_iconv_fprintf (file, "server_address = \"%s\"\n", ptr_server->address);
|
||||
weechat_iconv_fprintf (file, "server_port = %d\n", ptr_server->port);
|
||||
weechat_iconv_fprintf (file, "server_ipv6 = %s\n",
|
||||
(ptr_server->ipv6) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_ssl = %s\n",
|
||||
(ptr_server->ssl) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_password = \"%s\"\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", ptr_server->nick1);
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"%s\"\n", ptr_server->nick2);
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"%s\"\n", ptr_server->nick3);
|
||||
weechat_iconv_fprintf (file, "server_username = \"%s\"\n", ptr_server->username);
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", ptr_server->realname);
|
||||
weechat_iconv_fprintf (file, "server_hostname = \"%s\"\n",
|
||||
(ptr_server->hostname) ? ptr_server->hostname : "");
|
||||
weechat_iconv_fprintf (file, "server_command = \"%s\"\n",
|
||||
(ptr_server->command) ? ptr_server->command : "");
|
||||
weechat_iconv_fprintf (file, "server_command_delay = %d\n", ptr_server->command_delay);
|
||||
weechat_iconv_fprintf (file, "server_autojoin = \"%s\"\n",
|
||||
(ptr_server->autojoin) ? ptr_server->autojoin : "");
|
||||
weechat_iconv_fprintf (file, "server_autorejoin = %s\n",
|
||||
(ptr_server->autorejoin) ? "on" : "off");
|
||||
weechat_iconv_fprintf (file, "server_notify_levels = \"%s\"\n",
|
||||
(ptr_server->notify_levels) ? ptr_server->notify_levels : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* all ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_write_server_default_values: write server section with default values
|
||||
* in configuration file
|
||||
* Return: 0 = successful
|
||||
* -1 = write error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_write_server_default_values (FILE *file, char *section_name,
|
||||
t_config_option *options)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) options;
|
||||
|
||||
struct passwd *my_passwd;
|
||||
char *realname, *pos;
|
||||
|
||||
weechat_iconv_fprintf (file, "\n[%s]\n", section_name);
|
||||
|
||||
weechat_iconv_fprintf (file, "server_name = \"freenode\"\n");
|
||||
weechat_iconv_fprintf (file, "server_autoconnect = on\n");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect = on\n");
|
||||
weechat_iconv_fprintf (file, "server_autoreconnect_delay = 30\n");
|
||||
weechat_iconv_fprintf (file, "server_address = \"irc.freenode.net\"\n");
|
||||
weechat_iconv_fprintf (file, "server_port = 6667\n");
|
||||
weechat_iconv_fprintf (file, "server_ipv6 = off\n");
|
||||
weechat_iconv_fprintf (file, "server_ssl = off\n");
|
||||
weechat_iconv_fprintf (file, "server_password = \"\"\n");
|
||||
|
||||
/* Get the user's name from /etc/passwd */
|
||||
if ((my_passwd = getpwuid (geteuid ())) != NULL)
|
||||
{
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"%s\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"%s1\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"%s2\"\n", my_passwd->pw_name);
|
||||
weechat_iconv_fprintf (file, "server_username = \"%s\"\n", my_passwd->pw_name);
|
||||
if ((!my_passwd->pw_gecos)
|
||||
|| (my_passwd->pw_gecos[0] == '\0')
|
||||
|| (my_passwd->pw_gecos[0] == ',')
|
||||
|| (my_passwd->pw_gecos[0] == ' '))
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n", my_passwd->pw_name);
|
||||
else
|
||||
{
|
||||
realname = strdup (my_passwd->pw_gecos);
|
||||
pos = strchr (realname, ',');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
weechat_iconv_fprintf (file, "server_realname = \"%s\"\n",
|
||||
realname);
|
||||
if (pos)
|
||||
pos[0] = ',';
|
||||
free (realname);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* default values if /etc/passwd can't be read */
|
||||
weechat_iconv_fprintf (file, "server_nick1 = \"weechat1\"\n");
|
||||
weechat_iconv_fprintf (file, "server_nick2 = \"weechat2\"\n");
|
||||
weechat_iconv_fprintf (file, "server_nick3 = \"weechat3\"\n");
|
||||
weechat_iconv_fprintf (file, "server_username = \"weechat\"\n");
|
||||
weechat_iconv_fprintf (file, "server_realname = \"weechat\"\n");
|
||||
}
|
||||
|
||||
weechat_iconv_fprintf (file, "server_hostname = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_command = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_command_delay = 0\n");
|
||||
weechat_iconv_fprintf (file, "server_autojoin = \"\"\n");
|
||||
weechat_iconv_fprintf (file, "server_autorejoin = on\n");
|
||||
weechat_iconv_fprintf (file, "server_notify_levels = \"\"\n");
|
||||
|
||||
/* all ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_write: write IRC configuration file
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_write ()
|
||||
{
|
||||
return config_file_write (weechat_protocol_config_sections,
|
||||
weechat_protocol_config_options,
|
||||
irc_config_write_functions,
|
||||
IRC_CONFIG_NAME);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_CONFIG_H
|
||||
#define __WEECHAT_IRC_CONFIG_H 1
|
||||
|
||||
#include "../../core/config-option.h"
|
||||
|
||||
#define IRC_CONFIG_NAME "irc.rc"
|
||||
|
||||
#define CFG_IRC_DISPLAY_AWAY_OFF 0
|
||||
#define CFG_IRC_DISPLAY_AWAY_LOCAL 1
|
||||
#define CFG_IRC_DISPLAY_AWAY_CHANNEL 2
|
||||
|
||||
extern int irc_cfg_irc_one_server_buffer;
|
||||
extern int irc_cfg_irc_open_near_server;
|
||||
extern char *irc_cfg_irc_nick_prefix;
|
||||
extern char *irc_cfg_irc_nick_suffix;
|
||||
extern int irc_cfg_irc_display_away;
|
||||
extern int irc_cfg_irc_show_away_once;
|
||||
extern char *irc_cfg_irc_default_msg_part;
|
||||
extern char *irc_cfg_irc_default_msg_quit;
|
||||
extern int irc_cfg_irc_notice_as_pv;
|
||||
extern int irc_cfg_irc_away_check;
|
||||
extern int irc_cfg_irc_away_check_max_nicks;
|
||||
extern int irc_cfg_irc_lag_check;
|
||||
extern int irc_cfg_irc_lag_min_show;
|
||||
extern int irc_cfg_irc_lag_disconnect;
|
||||
extern int irc_cfg_irc_anti_flood;
|
||||
extern char *irc_cfg_irc_highlight;
|
||||
extern int irc_cfg_irc_colors_receive;
|
||||
extern int irc_cfg_irc_colors_send;
|
||||
extern int irc_cfg_irc_send_unknown_commands;
|
||||
|
||||
extern int irc_cfg_dcc_auto_accept_files;
|
||||
extern int irc_cfg_dcc_auto_accept_chats;
|
||||
extern int irc_cfg_dcc_timeout;
|
||||
extern int irc_cfg_dcc_blocksize;
|
||||
extern int irc_cfg_dcc_fast_send;
|
||||
extern char *irc_cfg_dcc_port_range;
|
||||
extern char *irc_cfg_dcc_own_ip;
|
||||
extern char *irc_cfg_dcc_download_path;
|
||||
extern char *irc_cfg_dcc_upload_path;
|
||||
extern int irc_cfg_dcc_convert_spaces;
|
||||
extern int irc_cfg_dcc_auto_rename;
|
||||
extern int irc_cfg_dcc_auto_resume;
|
||||
|
||||
extern int irc_cfg_log_auto_server;
|
||||
extern int irc_cfg_log_auto_channel;
|
||||
extern int irc_cfg_log_auto_private;
|
||||
extern int irc_cfg_log_hide_nickserv_pwd;
|
||||
|
||||
extern void irc_config_change_noop ();
|
||||
extern void irc_config_change_one_server_buffer ();
|
||||
extern void irc_config_change_away_check ();
|
||||
extern void irc_config_change_log ();
|
||||
extern void irc_config_change_notify_levels ();
|
||||
extern int irc_config_read_server (t_config_option *, char *, char *);
|
||||
extern int irc_config_read ();
|
||||
extern int irc_config_write_servers (FILE *, char *, t_config_option *);
|
||||
extern int irc_config_write_servers_default_values (FILE *, char *,
|
||||
t_config_option *);
|
||||
extern int irc_config_write ();
|
||||
|
||||
#endif /* irc-config.h */
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-core.c: main IRC functions */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
char protocol_name[] = _PROTOCOL_NAME;
|
||||
char protocol_version[] = _PROTOCOL_VERSION;
|
||||
char protocol_description[] = _PROTOCOL_DESC;
|
||||
|
||||
t_weechat_protocol *irc_protocol;
|
||||
t_weechat_hook *irc_hook_timer = NULL;
|
||||
t_weechat_hook *irc_hook_timer_check_away = NULL;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* weechat_protocol_init: initialize IRC protocol
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_init (t_weechat_protocol *protocol)
|
||||
{
|
||||
irc_protocol = protocol;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* init GnuTLS */
|
||||
gnutls_global_init ();
|
||||
gnutls_certificate_allocate_credentials (&gnutls_xcred);
|
||||
gnutls_certificate_set_x509_trust_file (gnutls_xcred, "ca.pem", GNUTLS_X509_FMT_PEM);
|
||||
#endif
|
||||
|
||||
irc_config_read ();
|
||||
|
||||
return PROTOCOL_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_run: run IRC protocol: auto-connect to servers
|
||||
* and start timers
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_run ()
|
||||
{
|
||||
irc_server_auto_connect (1, 0);
|
||||
|
||||
irc_hook_timer = weechat_hook_add_timer (1 * 1000,
|
||||
irc_server_timer,
|
||||
NULL);
|
||||
if (irc_cfg_irc_away_check != 0)
|
||||
weechat_hook_add_timer (irc_cfg_irc_away_check * 60 * 1000,
|
||||
irc_server_timer_check_away,
|
||||
NULL);
|
||||
|
||||
return PROTOCOL_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_input_data: read data from user input
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_input_data (t_gui_window *window, char *data)
|
||||
{
|
||||
return irc_input_data (window, data);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_config_read: read IRC configuration file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_config_read ()
|
||||
{
|
||||
return irc_config_read ();
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_config_write: write IRC configuration file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_config_write ()
|
||||
{
|
||||
return irc_config_write ();
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_dump: dump protocol data in WeeChat log file
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_dump ()
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
irc_server_print_log (ptr_server);
|
||||
|
||||
for (ptr_channel = ptr_server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
irc_channel_print_log (ptr_channel);
|
||||
|
||||
for (ptr_nick = ptr_channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
irc_nick_print_log (ptr_nick);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
irc_dcc_print_log ();
|
||||
|
||||
return PROTOCOL_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_protocol_end: end IRC protocol
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_protocol_end ()
|
||||
{
|
||||
if (irc_hook_timer)
|
||||
weechat_hook_remove (irc_hook_timer);
|
||||
|
||||
irc_server_disconnect_all ();
|
||||
irc_dcc_end ();
|
||||
irc_server_free_all ();
|
||||
|
||||
irc_config_write ();
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
/* GnuTLS end */
|
||||
gnutls_certificate_free_credentials (gnutls_xcred);
|
||||
gnutls_global_deinit();
|
||||
#endif
|
||||
|
||||
return PROTOCOL_RC_OK;
|
||||
}
|
||||
+283
-293
@@ -39,12 +39,11 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/hotlist.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
@@ -68,7 +67,7 @@ irc_dcc_redraw (int highlight)
|
||||
gui_window_redraw_buffer (ptr_buffer);
|
||||
if (highlight && gui_add_hotlist && (ptr_buffer->num_displayed == 0))
|
||||
{
|
||||
hotlist_add (highlight, NULL, NULL, ptr_buffer, 0);
|
||||
gui_hotlist_add (highlight, NULL, ptr_buffer, 0);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
@@ -125,7 +124,7 @@ irc_dcc_file_is_resumable (t_irc_dcc *ptr_dcc, char *filename)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (!cfg_dcc_auto_resume)
|
||||
if (!irc_cfg_dcc_auto_resume)
|
||||
return 0;
|
||||
|
||||
if (access (filename, W_OK) == 0)
|
||||
@@ -160,7 +159,7 @@ irc_dcc_find_filename (t_irc_dcc *ptr_dcc)
|
||||
if (!IRC_DCC_IS_FILE(ptr_dcc->type))
|
||||
return;
|
||||
|
||||
dir1 = weechat_strreplace (cfg_dcc_download_path, "~", getenv ("HOME"));
|
||||
dir1 = weechat_strreplace (irc_cfg_dcc_download_path, "~", getenv ("HOME"));
|
||||
if (!dir1)
|
||||
return;
|
||||
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
|
||||
@@ -195,10 +194,10 @@ irc_dcc_find_filename (t_irc_dcc *ptr_dcc)
|
||||
return;
|
||||
|
||||
/* if auto rename is not set, then abort DCC */
|
||||
if (!cfg_dcc_auto_rename)
|
||||
if (!irc_cfg_dcc_auto_rename)
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -206,7 +205,7 @@ irc_dcc_find_filename (t_irc_dcc *ptr_dcc)
|
||||
if (!filename2)
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return;
|
||||
}
|
||||
ptr_dcc->filename_suffix = 0;
|
||||
@@ -454,32 +453,33 @@ irc_dcc_close (t_irc_dcc *ptr_dcc, int status)
|
||||
|
||||
ptr_dcc->status = status;
|
||||
|
||||
if ((status == IRC_DCC_DONE) || (status == IRC_DCC_ABORTED) || (status == IRC_DCC_FAILED))
|
||||
if ((status == IRC_DCC_DONE) || (status == IRC_DCC_ABORTED)
|
||||
|| (status == IRC_DCC_FAILED))
|
||||
{
|
||||
if (IRC_DCC_IS_FILE(ptr_dcc->type))
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_INFO);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
ptr_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
gui_chat_printf_info (ptr_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
ptr_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
if (ptr_dcc->local_filename)
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_(" (local filename: %s%s%s)"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
ptr_dcc->local_filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
gui_chat_printf (ptr_dcc->server->buffer,
|
||||
_(" (local filename: %s%s%s)"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
ptr_dcc->local_filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
if (ptr_dcc->type == IRC_DCC_FILE_SEND)
|
||||
gui_printf (ptr_dcc->server->buffer, _(" sent to "));
|
||||
gui_chat_printf (ptr_dcc->server->buffer,
|
||||
_(" sent to "));
|
||||
else
|
||||
gui_printf (ptr_dcc->server->buffer, _(" received from "));
|
||||
gui_printf (ptr_dcc->server->buffer, "%s%s%s: %s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(status == IRC_DCC_DONE) ? _("OK") : _("FAILED"));
|
||||
gui_chat_printf (ptr_dcc->server->buffer,
|
||||
_(" received from "));
|
||||
gui_chat_printf (ptr_dcc->server->buffer, "%s%s%s: %s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
(status == IRC_DCC_DONE) ? _("OK") : _("FAILED"));
|
||||
irc_dcc_file_child_kill (ptr_dcc);
|
||||
}
|
||||
}
|
||||
@@ -491,18 +491,18 @@ irc_dcc_close (t_irc_dcc *ptr_dcc, int status)
|
||||
ptr_buffer = ptr_dcc->channel->buffer;
|
||||
else
|
||||
ptr_buffer = ptr_dcc->server->buffer;
|
||||
irc_display_prefix (ptr_dcc->server, ptr_buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (ptr_buffer,
|
||||
_("DCC chat closed with %s%s %s(%s%d.%d.%d.%d%s)\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_HOST),
|
||||
ptr_dcc->addr >> 24,
|
||||
(ptr_dcc->addr >> 16) & 0xff,
|
||||
(ptr_dcc->addr >> 8) & 0xff,
|
||||
ptr_dcc->addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
gui_chat_printf_info (ptr_buffer,
|
||||
_("DCC chat closed with %s%s "
|
||||
"%s(%s%d.%d.%d.%d%s)\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HOST),
|
||||
ptr_dcc->addr >> 24,
|
||||
(ptr_dcc->addr >> 16) & 0xff,
|
||||
(ptr_dcc->addr >> 8) & 0xff,
|
||||
ptr_dcc->addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -545,31 +545,30 @@ irc_dcc_channel_for_chat (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
if (!irc_channel_create_dcc (ptr_dcc))
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s can't associate DCC chat with private buffer "
|
||||
"(maybe private buffer has already DCC CHAT?)\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_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 (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return;
|
||||
}
|
||||
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->channel->buffer,
|
||||
GUI_PREFIX_INFO);
|
||||
gui_printf_type (ptr_dcc->channel->buffer, GUI_MSG_TYPE_MSG,
|
||||
_("Connected to %s%s %s(%s%d.%d.%d.%d%s)%s via DCC chat\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_HOST),
|
||||
ptr_dcc->addr >> 24,
|
||||
(ptr_dcc->addr >> 16) & 0xff,
|
||||
(ptr_dcc->addr >> 8) & 0xff,
|
||||
ptr_dcc->addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
gui_chat_printf_type (ptr_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),
|
||||
ptr_dcc->nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HOST),
|
||||
ptr_dcc->addr >> 24,
|
||||
(ptr_dcc->addr >> 16) & 0xff,
|
||||
(ptr_dcc->addr >> 8) & 0xff,
|
||||
ptr_dcc->addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -601,7 +600,7 @@ irc_dcc_recv_connect_init (t_irc_dcc *ptr_dcc)
|
||||
if (!irc_dcc_connect (ptr_dcc))
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -618,7 +617,7 @@ irc_dcc_recv_connect_init (t_irc_dcc *ptr_dcc)
|
||||
irc_dcc_channel_for_chat (ptr_dcc);
|
||||
}
|
||||
}
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -637,7 +636,7 @@ irc_dcc_accept (t_irc_dcc *ptr_dcc)
|
||||
"PRIVMSG %s :\01DCC RESUME %s %d %u\01",
|
||||
ptr_dcc->nick, ptr_dcc->filename,
|
||||
ptr_dcc->port, ptr_dcc->start_resume);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
else
|
||||
irc_dcc_recv_connect_init (ptr_dcc);
|
||||
@@ -653,7 +652,8 @@ irc_dcc_accept_resume (t_irc_server *server, char *filename, int port,
|
||||
{
|
||||
t_irc_dcc *ptr_dcc;
|
||||
|
||||
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_SEND, IRC_DCC_CONNECTING, port);
|
||||
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_SEND, IRC_DCC_CONNECTING,
|
||||
port);
|
||||
if (ptr_dcc)
|
||||
{
|
||||
ptr_dcc->pos = pos_start;
|
||||
@@ -667,24 +667,24 @@ irc_dcc_accept_resume (t_irc_server *server, char *filename, int port,
|
||||
ptr_dcc->nick, ptr_dcc->filename,
|
||||
ptr_dcc->port, ptr_dcc->start_resume);
|
||||
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_INFO);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s resumed at position %u\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
ptr_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
ptr_dcc->start_resume);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (ptr_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s resumed at position %u\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
ptr_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
ptr_dcc->start_resume);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s can't resume file \"%s\" (port: %d, start position: %u): DCC not found or ended\n"),
|
||||
WEECHAT_ERROR, filename, port, pos_start);
|
||||
gui_chat_printf (server->buffer,
|
||||
_("%s can't resume file \"%s\" (port: %d, start "
|
||||
"position: %u): DCC not found or ended\n"),
|
||||
WEECHAT_ERROR, filename, port, pos_start);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_dcc_start_resume: called when "DCC ACCEPT" is received (resume accepted by sender)
|
||||
* irc_dcc_start_resume: called when "DCC ACCEPT" is received
|
||||
* (resume accepted by sender)
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -693,7 +693,8 @@ irc_dcc_start_resume (t_irc_server *server, char *filename, int port,
|
||||
{
|
||||
t_irc_dcc *ptr_dcc;
|
||||
|
||||
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_RECV, IRC_DCC_CONNECTING, port);
|
||||
ptr_dcc = irc_dcc_search (server, IRC_DCC_FILE_RECV, IRC_DCC_CONNECTING,
|
||||
port);
|
||||
if (ptr_dcc)
|
||||
{
|
||||
ptr_dcc->pos = pos_start;
|
||||
@@ -703,9 +704,10 @@ irc_dcc_start_resume (t_irc_server *server, char *filename, int port,
|
||||
irc_dcc_recv_connect_init (ptr_dcc);
|
||||
}
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s can't resume file \"%s\" (port: %d, start position: %u): DCC not found or ended\n"),
|
||||
WEECHAT_ERROR, filename, port, pos_start);
|
||||
gui_chat_printf (server->buffer,
|
||||
_("%s can't resume file \"%s\" (port: %d, start "
|
||||
"position: %u): DCC not found or ended\n"),
|
||||
WEECHAT_ERROR, filename, port, pos_start);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -736,12 +738,12 @@ irc_dcc_alloc ()
|
||||
new_dcc->child_read = -1;
|
||||
new_dcc->child_write = -1;
|
||||
new_dcc->unterminated_message = NULL;
|
||||
new_dcc->fast_send = cfg_dcc_fast_send;
|
||||
new_dcc->fast_send = irc_cfg_dcc_fast_send;
|
||||
new_dcc->file = -1;
|
||||
new_dcc->filename = NULL;
|
||||
new_dcc->local_filename = NULL;
|
||||
new_dcc->filename_suffix = -1;
|
||||
new_dcc->blocksize = cfg_dcc_blocksize;
|
||||
new_dcc->blocksize = irc_cfg_dcc_blocksize;
|
||||
new_dcc->size = 0;
|
||||
new_dcc->pos = 0;
|
||||
new_dcc->ack = 0;
|
||||
@@ -776,10 +778,9 @@ irc_dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char
|
||||
new_dcc = irc_dcc_alloc ();
|
||||
if (!new_dcc)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for new DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for new DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -822,96 +823,92 @@ irc_dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char
|
||||
/* write info message on server buffer */
|
||||
if (type == IRC_DCC_FILE_RECV)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer,
|
||||
_("Incoming DCC file from %s%s%s (%s%d.%d.%d.%d%s)%s: %s%s%s, %s%lu%s bytes\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_HOST),
|
||||
addr >> 24,
|
||||
(addr >> 16) & 0xff,
|
||||
(addr >> 8) & 0xff,
|
||||
addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
size,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Incoming DCC file from %s%s%s "
|
||||
"(%s%d.%d.%d.%d%s)%s: %s%s%s, "
|
||||
"%s%lu%s bytes\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HOST),
|
||||
addr >> 24,
|
||||
(addr >> 16) & 0xff,
|
||||
(addr >> 8) & 0xff,
|
||||
addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
size,
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
if (type == IRC_DCC_FILE_SEND)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer,
|
||||
_("Sending DCC file to %s%s%s: %s%s%s "
|
||||
"(local filename: %s%s%s), %s%lu%s bytes\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
local_filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
size,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Sending DCC file to %s%s%s: %s%s%s "
|
||||
"(local filename: %s%s%s), %s%lu%s bytes\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
local_filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
size,
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
if (type == IRC_DCC_CHAT_RECV)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer,
|
||||
_("Incoming DCC chat request from %s%s%s "
|
||||
"(%s%d.%d.%d.%d%s)\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_HOST),
|
||||
addr >> 24,
|
||||
(addr >> 16) & 0xff,
|
||||
(addr >> 8) & 0xff,
|
||||
addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Incoming DCC chat request from %s%s%s "
|
||||
"(%s%d.%d.%d.%d%s)\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HOST),
|
||||
addr >> 24,
|
||||
(addr >> 16) & 0xff,
|
||||
(addr >> 8) & 0xff,
|
||||
addr & 0xff,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
if (type == IRC_DCC_CHAT_SEND)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer,
|
||||
_("Sending DCC chat request to %s%s\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Sending DCC chat request to %s%s\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
nick);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
|
||||
if (IRC_DCC_IS_FILE(type) && (!new_dcc->local_filename))
|
||||
{
|
||||
irc_dcc_close (new_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (IRC_DCC_IS_FILE(type) && (new_dcc->start_resume > 0))
|
||||
{
|
||||
irc_display_prefix (new_dcc->server, new_dcc->server->buffer,
|
||||
GUI_PREFIX_INFO);
|
||||
gui_printf (new_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s (local filename: %s%s%s) "
|
||||
"will be resumed at position %u\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
new_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
new_dcc->local_filename,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
new_dcc->start_resume);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
gui_chat_printf_info (new_dcc->server->buffer,
|
||||
_("DCC: file %s%s%s (local filename: %s%s%s) "
|
||||
"will be resumed at position %u\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
new_dcc->filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
new_dcc->local_filename,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
new_dcc->start_resume);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
|
||||
/* connect if needed and redraw DCC buffer */
|
||||
@@ -920,16 +917,16 @@ irc_dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char
|
||||
if (!irc_dcc_connect (new_dcc))
|
||||
{
|
||||
irc_dcc_close (new_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( (type == IRC_DCC_CHAT_RECV) && (cfg_dcc_auto_accept_chats) )
|
||||
|| ( (type == IRC_DCC_FILE_RECV) && (cfg_dcc_auto_accept_files) ) )
|
||||
if ( ( (type == IRC_DCC_CHAT_RECV) && (irc_cfg_dcc_auto_accept_chats) )
|
||||
|| ( (type == IRC_DCC_FILE_RECV) && (irc_cfg_dcc_auto_accept_files) ) )
|
||||
irc_dcc_accept (new_dcc);
|
||||
else
|
||||
irc_dcc_redraw (HOTLIST_PRIVATE);
|
||||
irc_dcc_redraw (GUI_HOTLIST_PRIVATE);
|
||||
gui_status_draw (gui_current_window->buffer, 0);
|
||||
|
||||
return new_dcc;
|
||||
@@ -969,7 +966,8 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
filename2 = weechat_strreplace (filename, "~", getenv ("HOME"));
|
||||
else
|
||||
{
|
||||
dir1 = weechat_strreplace (cfg_dcc_upload_path, "~", getenv ("HOME"));
|
||||
dir1 = weechat_strreplace (irc_cfg_dcc_upload_path, "~",
|
||||
getenv ("HOME"));
|
||||
if (!dir1)
|
||||
return;
|
||||
dir2 = weechat_strreplace (dir1, "%h", weechat_home);
|
||||
@@ -982,10 +980,9 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
strlen (filename) + 4);
|
||||
if (!filename2)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for DCC SEND\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for DCC SEND\n"),
|
||||
WEECHAT_ERROR);
|
||||
return;
|
||||
}
|
||||
strcpy (filename2, dir2);
|
||||
@@ -1002,10 +999,9 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
/* check if file exists */
|
||||
if (stat (filename2, &st) == -1)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot access file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename2);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot access file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename2);
|
||||
if (filename2)
|
||||
free (filename2);
|
||||
return;
|
||||
@@ -1016,18 +1012,19 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
|
||||
/* look up the IP address from dcc_own_ip, if set */
|
||||
local_addr = 0;
|
||||
if (cfg_dcc_own_ip && cfg_dcc_own_ip[0])
|
||||
if (irc_cfg_dcc_own_ip && irc_cfg_dcc_own_ip[0])
|
||||
{
|
||||
host = gethostbyname (cfg_dcc_own_ip);
|
||||
host = gethostbyname (irc_cfg_dcc_own_ip);
|
||||
if (host)
|
||||
{
|
||||
memcpy (&tmpaddr, host->h_addr_list[0], sizeof(struct in_addr));
|
||||
local_addr = ntohl (tmpaddr.s_addr);
|
||||
}
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s could not find address for '%s'. Falling back to local IP.\n"),
|
||||
WEECHAT_WARNING, cfg_dcc_own_ip);
|
||||
gui_chat_printf (server->buffer,
|
||||
_("%s could not find address for '%s'. Falling "
|
||||
"back to local IP.\n"),
|
||||
WEECHAT_WARNING, irc_cfg_dcc_own_ip);
|
||||
}
|
||||
|
||||
/* use the local interface, from the server socket */
|
||||
@@ -1044,10 +1041,9 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot create socket for DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot create socket for DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
if (filename2)
|
||||
free (filename2);
|
||||
return;
|
||||
@@ -1057,10 +1053,10 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
|
||||
port = 0;
|
||||
|
||||
if (cfg_dcc_port_range && cfg_dcc_port_range[0])
|
||||
if (irc_cfg_dcc_port_range && irc_cfg_dcc_port_range[0])
|
||||
{
|
||||
/* find a free port in the specified range */
|
||||
args = sscanf (cfg_dcc_port_range, "%d-%d", &port_start, &port_end);
|
||||
args = sscanf (irc_cfg_dcc_port_range, "%d-%d", &port_start, &port_end);
|
||||
if (args > 0)
|
||||
{
|
||||
port = port_start;
|
||||
@@ -1102,10 +1098,9 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
if (port == -1)
|
||||
{
|
||||
/* Could not find any port to bind */
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot find available port for DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot find available port for DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
close (sock);
|
||||
if (filename2)
|
||||
free (filename2);
|
||||
@@ -1128,7 +1123,7 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
{
|
||||
if (pos[0] == ' ')
|
||||
{
|
||||
if (cfg_dcc_convert_spaces)
|
||||
if (irc_cfg_dcc_convert_spaces)
|
||||
pos[0] = '_';
|
||||
else
|
||||
spaces = 1;
|
||||
@@ -1139,17 +1134,17 @@ irc_dcc_send_request (t_irc_server *server, int type, char *nick, char *filename
|
||||
|
||||
/* add DCC entry and listen to socket */
|
||||
if (type == IRC_DCC_CHAT_SEND)
|
||||
ptr_dcc = irc_dcc_add (server, IRC_DCC_CHAT_SEND, local_addr, port, nick, sock,
|
||||
NULL, NULL, 0);
|
||||
ptr_dcc = irc_dcc_add (server, IRC_DCC_CHAT_SEND, local_addr, port,
|
||||
nick, sock, NULL, NULL, 0);
|
||||
else
|
||||
ptr_dcc = irc_dcc_add (server, IRC_DCC_FILE_SEND, local_addr, port, nick, sock,
|
||||
short_filename, filename2, st.st_size);
|
||||
ptr_dcc = irc_dcc_add (server, IRC_DCC_FILE_SEND, local_addr, port,
|
||||
nick, sock, short_filename, filename2,
|
||||
st.st_size);
|
||||
if (!ptr_dcc)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot send DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot send DCC\n"),
|
||||
WEECHAT_ERROR);
|
||||
close (sock);
|
||||
if (short_filename)
|
||||
free (short_filename);
|
||||
@@ -1216,16 +1211,17 @@ irc_dcc_chat_sendf (t_irc_dcc *ptr_dcc, char *fmt, ...)
|
||||
size_buf = strlen (buffer);
|
||||
#ifdef DEBUG
|
||||
buffer[size_buf - 2] = '\0';
|
||||
gui_printf (ptr_dcc->server->buffer, "[DEBUG] Sending to remote host (DCC CHAT) >>> %s\n", buffer);
|
||||
gui_chat_printf (ptr_dcc->server->buffer,
|
||||
"[DEBUG] Sending to remote host (DCC CHAT) >>> %s\n",
|
||||
buffer);
|
||||
buffer[size_buf - 2] = '\r';
|
||||
#endif
|
||||
if (irc_dcc_chat_send (ptr_dcc, buffer, strlen (buffer)) <= 0)
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s error sending data to \"%s\" via DCC CHAT\n"),
|
||||
WEECHAT_ERROR, ptr_dcc->nick);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s error sending data to \"%s\" via DCC "
|
||||
"CHAT\n"),
|
||||
WEECHAT_ERROR, ptr_dcc->nick);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -1304,27 +1300,33 @@ irc_dcc_chat_recv (t_irc_dcc *ptr_dcc)
|
||||
|
||||
if (ptr_buf)
|
||||
{
|
||||
if (irc_recv_is_highlight (ptr_buf, ptr_dcc->server->nick))
|
||||
if (irc_protocol_is_highlight (ptr_buf, ptr_dcc->server->nick))
|
||||
{
|
||||
irc_display_nick (ptr_dcc->channel->buffer, NULL, ptr_dcc->nick,
|
||||
GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT, 1,
|
||||
GUI_COLOR_WIN_CHAT_HIGHLIGHT, 0);
|
||||
irc_display_nick (ptr_dcc->channel->buffer, NULL,
|
||||
ptr_dcc->nick,
|
||||
GUI_MSG_TYPE_NICK | GUI_MSG_TYPE_HIGHLIGHT,
|
||||
1,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_HIGHLIGHT), 0);
|
||||
if ((cfg_look_infobar_delay_highlight > 0)
|
||||
&& (ptr_dcc->channel->buffer != gui_current_window->buffer))
|
||||
{
|
||||
gui_infobar_printf (cfg_look_infobar_delay_highlight,
|
||||
GUI_COLOR_WIN_INFOBAR_HIGHLIGHT,
|
||||
GUI_COLOR_INFOBAR_HIGHLIGHT,
|
||||
_("Private %s> %s"),
|
||||
ptr_dcc->nick, ptr_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
irc_display_nick (ptr_dcc->channel->buffer, NULL, ptr_dcc->nick,
|
||||
GUI_MSG_TYPE_NICK, 1, GUI_COLOR_WIN_NICK_PRIVATE, 0);
|
||||
gui_printf_type (ptr_dcc->channel->buffer, GUI_MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
ptr_buf);
|
||||
irc_display_nick (ptr_dcc->channel->buffer, NULL,
|
||||
ptr_dcc->nick,
|
||||
GUI_MSG_TYPE_NICK, 1,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK_OTHER), 0);
|
||||
gui_chat_printf_type (ptr_dcc->channel->buffer,
|
||||
GUI_MSG_TYPE_MSG,
|
||||
NULL, -1,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
ptr_buf);
|
||||
}
|
||||
|
||||
ptr_buf = next_ptr_buf;
|
||||
@@ -1336,7 +1338,7 @@ irc_dcc_chat_recv (t_irc_dcc *ptr_dcc)
|
||||
else
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_ABORTED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1352,13 +1354,11 @@ irc_dcc_file_create_pipe (t_irc_dcc *ptr_dcc)
|
||||
|
||||
if (pipe (child_pipe) < 0)
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to create pipe\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to create pipe\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1580,47 +1580,41 @@ irc_dcc_file_child_read (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
/* errors for sender */
|
||||
case IRC_DCC_ERROR_READ_LOCAL:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to read local file\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to read local "
|
||||
"file\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
case IRC_DCC_ERROR_SEND_BLOCK:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to send block to receiver\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to send block to "
|
||||
"receiver\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
case IRC_DCC_ERROR_READ_ACK:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to read ACK from receiver\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to read ACK from "
|
||||
"receiver\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
/* errors for receiver */
|
||||
case IRC_DCC_ERROR_CONNECT_SENDER:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to connect to sender\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to connect to "
|
||||
"sender\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
case IRC_DCC_ERROR_RECV_BLOCK:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to receive block from sender\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to receive block "
|
||||
"from sender\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
case IRC_DCC_ERROR_WRITE_LOCAL:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to write local file\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to write local "
|
||||
"file\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1634,18 +1628,18 @@ irc_dcc_file_child_read (t_irc_dcc *ptr_dcc)
|
||||
ptr_dcc->status = IRC_DCC_ACTIVE;
|
||||
ptr_dcc->start_transfer = time (NULL);
|
||||
ptr_dcc->last_check_time = time (NULL);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
}
|
||||
else
|
||||
irc_dcc_redraw (HOTLIST_LOW);
|
||||
irc_dcc_redraw (GUI_HOTLIST_LOW);
|
||||
break;
|
||||
case IRC_DCC_DONE:
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_DONE);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
break;
|
||||
case IRC_DCC_FAILED:
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1669,13 +1663,11 @@ irc_dcc_file_send_fork (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
/* fork failed */
|
||||
case -1:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to fork\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to fork\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return;
|
||||
/* child process */
|
||||
case 0:
|
||||
@@ -1712,13 +1704,11 @@ irc_dcc_file_recv_fork (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
/* fork failed */
|
||||
case -1:
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to fork\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to fork\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
return;
|
||||
/* child process */
|
||||
case 0:
|
||||
@@ -1750,15 +1740,14 @@ irc_dcc_handle ()
|
||||
/* check DCC timeout */
|
||||
if (IRC_DCC_IS_FILE(ptr_dcc->type) && !IRC_DCC_ENDED(ptr_dcc->status))
|
||||
{
|
||||
if ((cfg_dcc_timeout != 0) && (time (NULL) > ptr_dcc->last_activity + cfg_dcc_timeout))
|
||||
if ((irc_cfg_dcc_timeout != 0)
|
||||
&& (time (NULL) > ptr_dcc->last_activity + irc_cfg_dcc_timeout))
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: timeout\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: timeout\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1779,36 +1768,37 @@ irc_dcc_handle ()
|
||||
{
|
||||
ptr_dcc->last_activity = time (NULL);
|
||||
length = sizeof (addr);
|
||||
sock = accept (ptr_dcc->sock, (struct sockaddr *) &addr, &length);
|
||||
sock = accept (ptr_dcc->sock,
|
||||
(struct sockaddr *) &addr, &length);
|
||||
close (ptr_dcc->sock);
|
||||
ptr_dcc->sock = -1;
|
||||
if (sock < 0)
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to create socket for sending file\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to "
|
||||
"create socket for "
|
||||
"sending file\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
continue;
|
||||
}
|
||||
ptr_dcc->sock = sock;
|
||||
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
|
||||
{
|
||||
irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer,
|
||||
GUI_PREFIX_ERROR);
|
||||
gui_printf (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to set 'nonblock' option for socket\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (ptr_dcc->server->buffer,
|
||||
_("%s DCC: unable to set "
|
||||
"'nonblock' option for "
|
||||
"socket\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
continue;
|
||||
}
|
||||
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
|
||||
ptr_dcc->status = IRC_DCC_ACTIVE;
|
||||
ptr_dcc->start_transfer = time (NULL);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
irc_dcc_file_send_fork (ptr_dcc);
|
||||
}
|
||||
}
|
||||
@@ -1841,19 +1831,19 @@ irc_dcc_handle ()
|
||||
if (sock < 0)
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
continue;
|
||||
}
|
||||
ptr_dcc->sock = sock;
|
||||
if (fcntl (ptr_dcc->sock, F_SETFL, O_NONBLOCK) == -1)
|
||||
{
|
||||
irc_dcc_close (ptr_dcc, IRC_DCC_FAILED);
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
continue;
|
||||
}
|
||||
ptr_dcc->addr = ntohl (addr.sin_addr.s_addr);
|
||||
ptr_dcc->status = IRC_DCC_ACTIVE;
|
||||
irc_dcc_redraw (HOTLIST_MSG);
|
||||
irc_dcc_redraw (GUI_HOTLIST_MSG);
|
||||
irc_dcc_channel_for_chat (ptr_dcc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_DCC_H
|
||||
#define __WEECHAT_IRC_DCC_H 1
|
||||
|
||||
/* DCC types */
|
||||
|
||||
#define IRC_DCC_CHAT_RECV 0 /* receiving DCC chat */
|
||||
#define IRC_DCC_CHAT_SEND 1 /* sending DCC chat */
|
||||
#define IRC_DCC_FILE_RECV 2 /* incoming DCC file */
|
||||
#define IRC_DCC_FILE_SEND 3 /* sending DCC file */
|
||||
|
||||
/* DCC status */
|
||||
|
||||
#define IRC_DCC_WAITING 0 /* waiting for host answer */
|
||||
#define IRC_DCC_CONNECTING 1 /* connecting to host */
|
||||
#define IRC_DCC_ACTIVE 2 /* sending/receiving data */
|
||||
#define IRC_DCC_DONE 3 /* transfer done */
|
||||
#define IRC_DCC_FAILED 4 /* DCC failed */
|
||||
#define IRC_DCC_ABORTED 5 /* DCC aborted by user */
|
||||
|
||||
/* DCC blocksize (for file) */
|
||||
|
||||
#define IRC_DCC_MIN_BLOCKSIZE 1024 /* min DCC block size when sending file*/
|
||||
#define IRC_DCC_MAX_BLOCKSIZE 102400 /* max DCC block size when sending file*/
|
||||
|
||||
/* DCC errors (for file) */
|
||||
|
||||
#define IRC_DCC_NO_ERROR 0 /* no error to report, all ok! */
|
||||
#define IRC_DCC_ERROR_READ_LOCAL 1 /* unable to read local file */
|
||||
#define IRC_DCC_ERROR_SEND_BLOCK 2 /* unable to send block to receiver */
|
||||
#define IRC_DCC_ERROR_READ_ACK 3 /* unable to read ACK from receiver */
|
||||
#define IRC_DCC_ERROR_CONNECT_SENDER 4 /* unable to connect to sender */
|
||||
#define IRC_DCC_ERROR_RECV_BLOCK 5 /* unable to recv block from sender */
|
||||
#define IRC_DCC_ERROR_WRITE_LOCAL 6 /* unable to write to local file */
|
||||
|
||||
/* DCC macros for type */
|
||||
|
||||
#define IRC_DCC_IS_CHAT(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_CHAT_SEND))
|
||||
#define IRC_DCC_IS_FILE(type) ((type == IRC_DCC_FILE_RECV) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
#define IRC_DCC_IS_RECV(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_FILE_RECV))
|
||||
#define IRC_DCC_IS_SEND(type) ((type == IRC_DCC_CHAT_SEND) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
|
||||
/* DCC macro for status */
|
||||
|
||||
#define IRC_DCC_ENDED(status) ((status == IRC_DCC_DONE) || \
|
||||
(status == IRC_DCC_FAILED) || \
|
||||
(status == IRC_DCC_ABORTED))
|
||||
|
||||
typedef struct t_irc_dcc t_irc_dcc;
|
||||
|
||||
struct t_irc_dcc
|
||||
{
|
||||
t_irc_server *server; /* irc server */
|
||||
t_irc_channel *channel; /* irc channel (for DCC chat only) */
|
||||
int type; /* DCC type (file/chat, send/receive) */
|
||||
int status; /* DCC status (waiting, sending, ..) */
|
||||
time_t start_time; /* the time when DCC started */
|
||||
time_t start_transfer; /* the time when DCC transfer started */
|
||||
unsigned long addr; /* IP address */
|
||||
int port; /* port */
|
||||
char *nick; /* remote nick */
|
||||
int sock; /* socket for connection */
|
||||
pid_t child_pid; /* pid of child process (sending/recving)*/
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
int fast_send; /* fase send for files: does not wait ACK*/
|
||||
int file; /* local file (for reading or writing) */
|
||||
char *filename; /* filename (given by sender) */
|
||||
char *local_filename; /* local filename (with path) */
|
||||
int filename_suffix; /* suffix (.1 for ex) if renaming file */
|
||||
int blocksize; /* block size for sending file */
|
||||
unsigned long size; /* file size */
|
||||
unsigned long pos; /* number of bytes received/sent */
|
||||
unsigned long ack; /* number of bytes received OK */
|
||||
unsigned long start_resume; /* start of resume (in bytes) */
|
||||
time_t last_check_time; /* last time we looked at bytes sent/recv*/
|
||||
unsigned long last_check_pos; /* bytes sent/recv at last check */
|
||||
time_t last_activity; /* time of last byte received/sent */
|
||||
unsigned long bytes_per_sec; /* bytes per second */
|
||||
unsigned long eta; /* estimated time of arrival */
|
||||
t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */
|
||||
t_irc_dcc *next_dcc; /* link to next dcc file/chat */
|
||||
};
|
||||
|
||||
extern t_irc_dcc *irc_dcc_list;
|
||||
extern t_irc_dcc *irc_last_dcc;
|
||||
extern char *irc_dcc_status_string[6];
|
||||
|
||||
#endif /* irc-dcc.h */
|
||||
+178
-224
@@ -28,10 +28,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../core/utf8.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
@@ -87,84 +87,32 @@ irc_display_hide_password (char *string, int look_for_nickserv)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_prefix: display a prefix for action/info/error msg
|
||||
* prefix must be 3 chars length
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_prefix (t_irc_server *server, t_gui_buffer *buffer, char *prefix)
|
||||
{
|
||||
int type;
|
||||
char format[32];
|
||||
|
||||
type = GUI_MSG_TYPE_INFO | GUI_MSG_TYPE_PREFIX;
|
||||
|
||||
if (!cfg_log_plugin_msg && (strcmp (prefix, GUI_PREFIX_PLUGIN) == 0))
|
||||
type |= GUI_MSG_TYPE_NOLOG;
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
if (cfg_look_align_other
|
||||
&& (GUI_BUFFER_IS_CHANNEL(buffer) || GUI_BUFFER_IS_PRIVATE(buffer)))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", cfg_look_align_size - 2);
|
||||
gui_printf_type (buffer, GUI_MSG_TYPE_NICK, format, " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (prefix[0] == prefix[2])
|
||||
{
|
||||
gui_printf_type (buffer, type, "%s%c%s%c%s%c ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1),
|
||||
prefix[0],
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX2),
|
||||
prefix[1],
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1),
|
||||
prefix[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (prefix, GUI_PREFIX_JOIN) == 0)
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_JOIN), prefix);
|
||||
else if (strcmp (prefix, GUI_PREFIX_PART) == 0)
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PART), prefix);
|
||||
else
|
||||
gui_printf_type (buffer, type, "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_PREFIX1), prefix);
|
||||
}
|
||||
if (server && (server->buffer == buffer) && buffer->all_servers)
|
||||
{
|
||||
gui_printf_type (buffer, type, "%s[%s%s%s] ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER), server->name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
}
|
||||
gui_printf_type (buffer, type, GUI_NO_COLOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_display_nick: display nick in chat window
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
int type, int display_around, int force_color, int no_nickmode)
|
||||
int type, int display_around, char *force_color, int no_nickmode)
|
||||
{
|
||||
char format[32], *ptr_nickname;
|
||||
int max_align, i, nickname_length, external_nick, length, spaces;
|
||||
int disable_prefix_suffix;
|
||||
|
||||
t_irc_server *ptr_server;
|
||||
t_irc_channel *ptr_channel;
|
||||
int is_private, max_align, i, nickname_length, external_nick;
|
||||
int length, spaces, disable_prefix_suffix;
|
||||
|
||||
max_align = (cfg_look_align_size_max >= cfg_look_align_size) ?
|
||||
cfg_look_align_size_max : cfg_look_align_size;
|
||||
|
||||
ptr_server = irc_server_search (buffer->category);
|
||||
ptr_channel = irc_channel_search (ptr_server, buffer->name);
|
||||
is_private = (ptr_channel && (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL));
|
||||
|
||||
ptr_nickname = strdup ((nick) ? nick->nick : nickname);
|
||||
if (!ptr_nickname)
|
||||
return;
|
||||
nickname_length = utf8_width_screen (ptr_nickname);
|
||||
external_nick = (!nick && !GUI_BUFFER_IS_PRIVATE(buffer));
|
||||
external_nick = (!nick && !is_private);
|
||||
disable_prefix_suffix = ((cfg_look_align_nick != CFG_LOOK_ALIGN_NICK_NONE)
|
||||
&& ((int)strlen (cfg_look_nick_prefix) +
|
||||
(int)strlen (cfg_look_nick_suffix) > max_align - 4));
|
||||
@@ -202,9 +150,10 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
/* display prefix */
|
||||
if (display_around && !disable_prefix_suffix
|
||||
&& cfg_look_nick_prefix && cfg_look_nick_prefix[0])
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
cfg_look_nick_prefix);
|
||||
gui_chat_printf_type (buffer, type, NULL, -1,
|
||||
"%s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
cfg_look_nick_prefix);
|
||||
|
||||
/* display spaces before nick, if needed */
|
||||
if (display_around
|
||||
@@ -212,43 +161,43 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
&& (spaces > 0))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", spaces);
|
||||
gui_printf_type (buffer, type, format, " ");
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, format, " ");
|
||||
}
|
||||
|
||||
/* display nick mode */
|
||||
if (nick && cfg_look_nickmode)
|
||||
{
|
||||
if (nick->flags & IRC_NICK_CHANOWNER)
|
||||
gui_printf_type (buffer, type, "%s~",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s~",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX1));
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN)
|
||||
gui_printf_type (buffer, type, "%s&",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s&",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX1));
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN2)
|
||||
gui_printf_type (buffer, type, "%s!",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s!",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX1));
|
||||
else if (nick->flags & IRC_NICK_OP)
|
||||
gui_printf_type (buffer, type, "%s@",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_OP));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s@",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX1));
|
||||
else if (nick->flags & IRC_NICK_HALFOP)
|
||||
gui_printf_type (buffer, type, "%s%%",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_HALFOP));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s%%",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX2));
|
||||
else if (nick->flags & IRC_NICK_VOICE)
|
||||
gui_printf_type (buffer, type, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_VOICE));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX3));
|
||||
else if (nick->flags & IRC_NICK_CHANUSER)
|
||||
gui_printf_type (buffer, type, "%s-",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_CHANUSER));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s-",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_PREFIX4));
|
||||
else if (cfg_look_nickmode_empty && !no_nickmode)
|
||||
gui_printf_type (buffer, type, "%s ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s ",
|
||||
GUI_COLOR(GUI_COLOR_CHAT));
|
||||
}
|
||||
|
||||
/* display nick */
|
||||
if (external_nick)
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
"(");
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
"(");
|
||||
if (display_around && (spaces < 0))
|
||||
{
|
||||
i = nickname_length + spaces - 1;
|
||||
@@ -262,26 +211,26 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
ptr_nickname[i] = '\0';
|
||||
}
|
||||
if (display_around)
|
||||
gui_printf_type_nick (buffer, type,
|
||||
(nick) ? nick->nick : nickname,
|
||||
"%s%s",
|
||||
(force_color >= 0) ?
|
||||
GUI_COLOR(force_color) :
|
||||
GUI_COLOR((nick) ? nick->color : GUI_COLOR_WIN_CHAT),
|
||||
ptr_nickname);
|
||||
gui_chat_printf_type_nick (buffer, type,
|
||||
(nick) ? nick->nick : nickname,
|
||||
NULL, -1,
|
||||
"%s%s",
|
||||
(force_color) ? force_color :
|
||||
GUI_COLOR((nick) ?
|
||||
nick->color : cfg_col_chat),
|
||||
ptr_nickname);
|
||||
else
|
||||
gui_printf_type (buffer, type,
|
||||
"%s%s",
|
||||
(force_color >= 0) ?
|
||||
GUI_COLOR(force_color) :
|
||||
GUI_COLOR((nick) ? nick->color : GUI_COLOR_WIN_CHAT),
|
||||
ptr_nickname);
|
||||
gui_chat_printf_type (buffer, type, NULL, -1,
|
||||
"%s%s",
|
||||
(force_color) ? force_color :
|
||||
GUI_COLOR((nick) ? nick->color : cfg_col_chat),
|
||||
ptr_nickname);
|
||||
if (display_around && (spaces < 0))
|
||||
gui_printf_type (buffer, type, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_WIN_NICK_MORE));
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s+",
|
||||
GUI_COLOR(GUI_COLOR_NICKLIST_MORE));
|
||||
if (external_nick)
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
")");
|
||||
|
||||
/* display spaces after nick, if needed */
|
||||
@@ -290,19 +239,19 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
|
||||
&& (spaces > 0))
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", spaces);
|
||||
gui_printf_type (buffer, type, format, " ");
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, format, " ");
|
||||
}
|
||||
|
||||
/* display suffix */
|
||||
if (display_around && !disable_prefix_suffix
|
||||
&& cfg_look_nick_suffix && cfg_look_nick_suffix[0])
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
cfg_look_nick_suffix);
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
cfg_look_nick_suffix);
|
||||
|
||||
gui_printf_type (buffer, type, "%s%s",
|
||||
GUI_NO_COLOR,
|
||||
(display_around) ? " " : "");
|
||||
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
|
||||
GUI_NO_COLOR,
|
||||
(display_around) ? " " : "");
|
||||
free (ptr_nickname);
|
||||
}
|
||||
|
||||
@@ -324,18 +273,20 @@ irc_display_away (t_irc_server *server, char *string1, char *string2)
|
||||
if (cfg_look_align_other)
|
||||
{
|
||||
snprintf (format, 32, "%%-%ds", cfg_look_align_size + 1);
|
||||
gui_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK,
|
||||
format, " ");
|
||||
gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK,
|
||||
NULL, -1,
|
||||
format, " ");
|
||||
}
|
||||
gui_printf_nolog (ptr_channel->buffer,
|
||||
"%s[%s%s%s %s: %s%s]\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
server->nick,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
string1,
|
||||
string2,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
gui_chat_printf_nolog (ptr_channel->buffer,
|
||||
NULL, -1,
|
||||
"%s[%s%s%s %s: %s%s]\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
server->nick,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
string1,
|
||||
string2,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,34 +296,34 @@ irc_display_away (t_irc_server *server, char *string1, char *string2)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_display_mode (t_irc_server *server, t_gui_buffer *buffer,
|
||||
irc_display_mode (t_gui_buffer *buffer,
|
||||
char *channel_name, char *nick_name, char set_flag,
|
||||
char *symbol, char *nick_host, char *message, char *param)
|
||||
{
|
||||
irc_display_prefix (server, buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (buffer, "%s[%s%s%s/%s%c%s%s] %s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
(channel_name) ?
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL) :
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
(channel_name) ? channel_name : nick_name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_CHANNEL),
|
||||
set_flag,
|
||||
symbol,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
nick_host);
|
||||
gui_chat_printf_info (buffer,
|
||||
"%s[%s%s%s/%s%c%s%s] %s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
(channel_name) ?
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL) :
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
(channel_name) ? channel_name : nick_name,
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
|
||||
set_flag,
|
||||
symbol,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
nick_host);
|
||||
if (param)
|
||||
gui_printf (buffer, " %s%s %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
message,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_NICK),
|
||||
param);
|
||||
gui_chat_printf (buffer, " %s%s %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
message,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK),
|
||||
param);
|
||||
else
|
||||
gui_printf (buffer, " %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
message);
|
||||
gui_chat_printf (buffer, " %s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
message);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -387,101 +338,104 @@ irc_display_server (t_irc_server *server, int with_detail)
|
||||
|
||||
if (with_detail)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
gui_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
|
||||
server->name,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK));
|
||||
gui_chat_printf (NULL, "\n");
|
||||
gui_chat_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_SERVER),
|
||||
server->name,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"),
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
|
||||
|
||||
gui_printf (NULL, " server_autoconnect . . . . : %s%s\n",
|
||||
(server->autoconnect) ? _("on") : _("off"),
|
||||
(server->temp_server) ?
|
||||
_(" (temporary server, will not be saved)") : "");
|
||||
gui_printf (NULL, " server_autoreconnect . . . : %s\n",
|
||||
(server->autoreconnect) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_autoreconnect_delay : %d %s\n",
|
||||
server->autoreconnect_delay,
|
||||
_("seconds"));
|
||||
gui_printf (NULL, " server_address . . . . . . : %s\n",
|
||||
server->address);
|
||||
gui_printf (NULL, " server_port . . . . . . . : %d\n",
|
||||
server->port);
|
||||
gui_printf (NULL, " server_ipv6 . . . . . . . : %s\n",
|
||||
(server->ipv6) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_ssl . . . . . . . . : %s\n",
|
||||
(server->ssl) ? _("on") : _("off"));
|
||||
gui_printf (NULL, " server_password . . . . . : %s\n",
|
||||
(server->password && server->password[0]) ?
|
||||
_("(hidden)") : "");
|
||||
gui_printf (NULL, " server_nick1/2/3 . . . . . : %s %s/ %s%s %s/ %s%s\n",
|
||||
server->nick1,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
server->nick2,
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
server->nick3);
|
||||
gui_printf (NULL, " server_username . . . . . : %s\n",
|
||||
server->username);
|
||||
gui_printf (NULL, " server_realname . . . . . : %s\n",
|
||||
server->realname);
|
||||
gui_printf (NULL, " server_hostname . . . . . : %s\n",
|
||||
(server->hostname) ? server->hostname : "");
|
||||
gui_chat_printf (NULL, " server_autoconnect . . . . : %s%s\n",
|
||||
(server->autoconnect) ? _("on") : _("off"),
|
||||
(server->temp_server) ?
|
||||
_(" (temporary server, will not be saved)") : "");
|
||||
gui_chat_printf (NULL, " server_autoreconnect . . . : %s\n",
|
||||
(server->autoreconnect) ? _("on") : _("off"));
|
||||
gui_chat_printf (NULL, " server_autoreconnect_delay : %d %s\n",
|
||||
server->autoreconnect_delay,
|
||||
_("seconds"));
|
||||
gui_chat_printf (NULL, " server_address . . . . . . : %s\n",
|
||||
server->address);
|
||||
gui_chat_printf (NULL, " server_port . . . . . . . : %d\n",
|
||||
server->port);
|
||||
gui_chat_printf (NULL, " server_ipv6 . . . . . . . : %s\n",
|
||||
(server->ipv6) ? _("on") : _("off"));
|
||||
gui_chat_printf (NULL, " server_ssl . . . . . . . . : %s\n",
|
||||
(server->ssl) ? _("on") : _("off"));
|
||||
gui_chat_printf (NULL, " server_password . . . . . : %s\n",
|
||||
(server->password && server->password[0]) ?
|
||||
_("(hidden)") : "");
|
||||
gui_chat_printf (NULL, " server_nick1/2/3 . . . . . : "
|
||||
"%s %s/ %s%s %s/ %s%s\n",
|
||||
server->nick1,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
server->nick2,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
server->nick3);
|
||||
gui_chat_printf (NULL, " server_username . . . . . : %s\n",
|
||||
server->username);
|
||||
gui_chat_printf (NULL, " server_realname . . . . . : %s\n",
|
||||
server->realname);
|
||||
gui_chat_printf (NULL, " server_hostname . . . . . : %s\n",
|
||||
(server->hostname) ? server->hostname : "");
|
||||
if (server->command && server->command[0])
|
||||
string = strdup (server->command);
|
||||
else
|
||||
string = NULL;
|
||||
if (string)
|
||||
{
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
if (irc_cfg_log_hide_nickserv_pwd)
|
||||
irc_display_hide_password (string, 1);
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
string);
|
||||
gui_chat_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
string);
|
||||
free (string);
|
||||
}
|
||||
else
|
||||
gui_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
gui_printf (NULL, " server_command_delay . . . : %d %s\n",
|
||||
server->command_delay,
|
||||
_("seconds"));
|
||||
gui_printf (NULL, " server_autojoin . . . . . : %s\n",
|
||||
(server->autojoin && server->autojoin[0]) ?
|
||||
server->autojoin : "");
|
||||
gui_printf (NULL, " server_notify_levels . . . : %s\n",
|
||||
(server->notify_levels && server->notify_levels[0]) ?
|
||||
server->notify_levels : "");
|
||||
gui_chat_printf (NULL, " server_command . . . . . . : %s\n",
|
||||
(server->command && server->command[0]) ?
|
||||
server->command : "");
|
||||
gui_chat_printf (NULL, " server_command_delay . . . : %d %s\n",
|
||||
server->command_delay,
|
||||
_("seconds"));
|
||||
gui_chat_printf (NULL, " server_autojoin . . . . . : %s\n",
|
||||
(server->autojoin && server->autojoin[0]) ?
|
||||
server->autojoin : "");
|
||||
gui_chat_printf (NULL, " server_notify_levels . . . : %s\n",
|
||||
(server->notify_levels && server->notify_levels[0]) ?
|
||||
server->notify_levels : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (NULL, " %s %s%s ",
|
||||
(server->is_connected) ? "*" : " ",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_SERVER),
|
||||
server->name);
|
||||
gui_printf (NULL, "%s[%s%s",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"));
|
||||
gui_chat_printf (NULL, " %s %s%s ",
|
||||
(server->is_connected) ? "*" : " ",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_SERVER),
|
||||
server->name);
|
||||
gui_chat_printf (NULL, "%s[%s%s",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
(server->is_connected) ?
|
||||
_("connected") : _("not connected"));
|
||||
if (server->is_connected)
|
||||
{
|
||||
num_channels = irc_server_get_channel_count (server);
|
||||
num_pv = irc_server_get_pv_count (server);
|
||||
gui_printf (NULL, ", ");
|
||||
gui_printf (NULL, NG_("%d channel", "%d channels", num_channels),
|
||||
num_channels);
|
||||
gui_printf (NULL, ", ");
|
||||
gui_printf (NULL, _("%d pv"), num_pv);
|
||||
gui_chat_printf (NULL, ", ");
|
||||
gui_chat_printf (NULL,
|
||||
NG_("%d channel", "%d channels",
|
||||
num_channels),
|
||||
num_channels);
|
||||
gui_chat_printf (NULL, ", ");
|
||||
gui_chat_printf (NULL, _("%d pv"), num_pv);
|
||||
}
|
||||
gui_printf (NULL, "%s]%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT_DARK),
|
||||
GUI_COLOR(GUI_COLOR_WIN_CHAT),
|
||||
(server->temp_server) ? _(" (temporary)") : "");
|
||||
gui_chat_printf (NULL, "%s]%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
(server->temp_server) ? _(" (temporary)") : "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,440 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-ignore.c: manages IRC ignore list */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/command.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/util.h"
|
||||
|
||||
|
||||
t_irc_ignore *irc_ignore = NULL;
|
||||
t_irc_ignore *last_irc_ignore = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* irc_ignore_check_mask: return 1 is mask1 and mask2 are the same host
|
||||
* anyone or both strings may have user and/or host after
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_check_mask (char *mask1, char *mask2)
|
||||
{
|
||||
char *m1, *m2, *pos;
|
||||
int match;
|
||||
|
||||
if (!mask1 || !mask1[0] || !mask2 || !mask2[0])
|
||||
return 0;
|
||||
|
||||
m1 = strdup (mask1);
|
||||
m2 = strdup (mask2);
|
||||
|
||||
pos = strchr (m1, '!');
|
||||
if (!pos)
|
||||
{
|
||||
/* remove '!' from m2 */
|
||||
pos = strchr (m2, '!');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
}
|
||||
pos = strchr (m2, '!');
|
||||
if (!pos)
|
||||
{
|
||||
/* remove '!' from m1 */
|
||||
pos = strchr (m1, '!');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
}
|
||||
|
||||
/* TODO: use regexp to match both masks */
|
||||
match = ascii_strcasecmp (m1, m2);
|
||||
|
||||
free (m1);
|
||||
free (m2);
|
||||
|
||||
return (match == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_match: check if pointed ignore matches with arguments
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_match (t_irc_ignore *ptr_ignore, char *mask, char *type,
|
||||
char *channel_name, char *server_name)
|
||||
{
|
||||
/* check mask */
|
||||
if ((strcmp (mask, "*") != 0) && (strcmp (ptr_ignore->mask, "*") != 0)
|
||||
&& (!irc_ignore_check_mask (ptr_ignore->mask, mask)))
|
||||
return 0;
|
||||
|
||||
/* mask is matching, go on with type */
|
||||
if ((strcmp (type, "*") != 0) && (strcmp (ptr_ignore->type, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->type, type) != 0))
|
||||
return 0;
|
||||
|
||||
/* mask and type matching, go on with server */
|
||||
if (server_name && server_name[0])
|
||||
{
|
||||
if ((strcmp (server_name, "*") != 0) && (strcmp (ptr_ignore->server_name, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->server_name, server_name) != 0))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (ptr_ignore->server_name, "*") != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* mask, type and server matching, go on with channel */
|
||||
if (channel_name && channel_name[0])
|
||||
{
|
||||
if ((strcmp (channel_name, "*") != 0) && (strcmp (ptr_ignore->channel_name, "*") != 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->channel_name, channel_name) != 0))
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp (ptr_ignore->channel_name, "*") != 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* all is matching => we find a ignore! */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_check: check if an ignore is set for arguments
|
||||
* return 1 if at least one ignore exists (message should NOT be displayed)
|
||||
* 0 if no ignore found (message will be displayed)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_check (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
if (!mask || !mask[0] || !type || !type[0])
|
||||
return 0;
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if (irc_ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* no ignore found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search: search for an ignore
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_search (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
if ((ascii_strcasecmp (ptr_ignore->mask, mask) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->type, type) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->channel_name, channel_name) == 0)
|
||||
&& (ascii_strcasecmp (ptr_ignore->server_name, server_name) == 0))
|
||||
return ptr_ignore;
|
||||
}
|
||||
|
||||
/* ignore not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_add: add an ignore in list
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_add (char *mask, char *type, char *channel_name, char *server_name)
|
||||
{
|
||||
int type_index;
|
||||
t_irc_command *command_ptr;
|
||||
t_irc_ignore *new_ignore;
|
||||
|
||||
if (!mask || !mask[0] || !type || !type[0] || !channel_name || !channel_name[0]
|
||||
|| !server_name || !server_name[0])
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s too few arguments for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
weechat_log_printf ("Adding ignore: mask:'%s', type:'%s', channel:'%s', "
|
||||
"server:'%s'\n",
|
||||
mask, type, channel_name, server_name);
|
||||
#endif
|
||||
|
||||
type_index = -1;
|
||||
command_ptr = NULL;
|
||||
|
||||
if ((strcmp (mask, "*") == 0) && (strcmp (type, "*") == 0))
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s mask or type/command should be non generic value for ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (irc_ignore_search (mask, type, channel_name, server_name))
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s ignore already exists\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create new ignore */
|
||||
new_ignore = (t_irc_ignore *) malloc (sizeof (t_irc_ignore));
|
||||
if (new_ignore)
|
||||
{
|
||||
new_ignore->mask = strdup (mask);
|
||||
new_ignore->type = strdup (type);
|
||||
new_ignore->server_name = strdup (server_name);
|
||||
new_ignore->channel_name = strdup (channel_name);
|
||||
|
||||
/* add new ignore to queue */
|
||||
new_ignore->prev_ignore = last_irc_ignore;
|
||||
new_ignore->next_ignore = NULL;
|
||||
if (irc_ignore)
|
||||
last_irc_ignore->next_ignore = new_ignore;
|
||||
else
|
||||
irc_ignore = new_ignore;
|
||||
last_irc_ignore = new_ignore;
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_ERROR);
|
||||
gui_printf (NULL,
|
||||
_("%s not enough memory to create ignore\n"),
|
||||
WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_add_from_config: add an ignore to list, read from config file
|
||||
* (comma serparated values)
|
||||
*/
|
||||
|
||||
t_irc_ignore *
|
||||
irc_ignore_add_from_config (char *string)
|
||||
{
|
||||
t_irc_ignore *new_ignore;
|
||||
char *string2;
|
||||
char *pos_mask, *pos_type, *pos_channel, *pos_server;
|
||||
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
new_ignore = NULL;
|
||||
string2 = strdup (string);
|
||||
|
||||
pos_mask = string2;
|
||||
pos_type = strchr (pos_mask, ',');
|
||||
if (pos_type)
|
||||
{
|
||||
pos_type[0] = '\0';
|
||||
pos_type++;
|
||||
pos_channel = strchr (pos_type, ',');
|
||||
if (pos_channel)
|
||||
{
|
||||
pos_channel[0] = '\0';
|
||||
pos_channel++;
|
||||
pos_server = strchr (pos_channel, ',');
|
||||
if (pos_server)
|
||||
{
|
||||
pos_server[0] = '\0';
|
||||
pos_server++;
|
||||
new_ignore = irc_ignore_add (pos_mask, pos_type, pos_channel, pos_server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free (string2);
|
||||
return new_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_free: free an ignore
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_free (t_irc_ignore *ptr_ignore)
|
||||
{
|
||||
t_irc_ignore *new_irc_ignore;
|
||||
|
||||
/* free data */
|
||||
if (ptr_ignore->mask)
|
||||
free (ptr_ignore->mask);
|
||||
if (ptr_ignore->type)
|
||||
free (ptr_ignore->type);
|
||||
if (ptr_ignore->channel_name)
|
||||
free (ptr_ignore->channel_name);
|
||||
if (ptr_ignore->server_name)
|
||||
free (ptr_ignore->server_name);
|
||||
|
||||
/* remove ignore from queue */
|
||||
if (last_irc_ignore == ptr_ignore)
|
||||
last_irc_ignore = ptr_ignore->prev_ignore;
|
||||
if (ptr_ignore->prev_ignore)
|
||||
{
|
||||
(ptr_ignore->prev_ignore)->next_ignore = ptr_ignore->next_ignore;
|
||||
new_irc_ignore = irc_ignore;
|
||||
}
|
||||
else
|
||||
new_irc_ignore = ptr_ignore->next_ignore;
|
||||
|
||||
if (ptr_ignore->next_ignore)
|
||||
(ptr_ignore->next_ignore)->prev_ignore = ptr_ignore->prev_ignore;
|
||||
|
||||
free (ptr_ignore);
|
||||
irc_ignore = new_irc_ignore;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_free_all: free all ignores
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_free_all ()
|
||||
{
|
||||
while (irc_ignore)
|
||||
irc_ignore_free (irc_ignore);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search_free: search and free ignore(s)
|
||||
* return: number of ignore found and deleted
|
||||
* 0 if no ignore found
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_search_free (char *mask, char *type,
|
||||
char *channel_name, char *server_name)
|
||||
{
|
||||
int found;
|
||||
t_irc_ignore *ptr_ignore, *next_ignore;
|
||||
|
||||
found = 0;
|
||||
ptr_ignore = irc_ignore;
|
||||
while (ptr_ignore)
|
||||
{
|
||||
if (irc_ignore_match (ptr_ignore, mask, type, channel_name, server_name))
|
||||
{
|
||||
found++;
|
||||
if (found == 1)
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
next_ignore = ptr_ignore->next_ignore;
|
||||
irc_ignore_free (ptr_ignore);
|
||||
ptr_ignore = next_ignore;
|
||||
}
|
||||
else
|
||||
ptr_ignore = ptr_ignore->next_ignore;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_search_free_by_number: search and free ignore(s) by number
|
||||
* return: 1 if ignore found and deleted
|
||||
* 0 if ignore not found
|
||||
*/
|
||||
|
||||
int
|
||||
irc_ignore_search_free_by_number (int number)
|
||||
{
|
||||
int i;
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
if (number < 1)
|
||||
return 0;
|
||||
|
||||
i = 0;
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
i++;
|
||||
if (i == number)
|
||||
{
|
||||
gui_printf (NULL, "\n");
|
||||
irc_display_prefix (NULL, NULL, GUI_PREFIX_INFO);
|
||||
weechat_cmd_ignore_display (_("Removing ignore:"), ptr_ignore);
|
||||
irc_ignore_free (ptr_ignore);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ignore number not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_ignore_print_log: print ignore list in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_ignore_print_log ()
|
||||
{
|
||||
t_irc_ignore *ptr_ignore;
|
||||
|
||||
weechat_log_printf ("[ignore list]\n");
|
||||
|
||||
for (ptr_ignore = irc_ignore; ptr_ignore;
|
||||
ptr_ignore = ptr_ignore->next_ignore)
|
||||
{
|
||||
weechat_log_printf ("\n");
|
||||
weechat_log_printf (" -> ignore at 0x%X:\n", ptr_ignore);
|
||||
weechat_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask);
|
||||
weechat_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type);
|
||||
weechat_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name);
|
||||
weechat_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name);
|
||||
weechat_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore);
|
||||
weechat_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-input.c: IRC input data (read from user) */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../core/utf8.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_input_user_message_display: display user message
|
||||
*/
|
||||
|
||||
void
|
||||
irc_input_user_message_display (t_gui_window *window, char *text)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
|
||||
|
||||
if ((ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
|
||||
|| (ptr_channel->type == IRC_CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
irc_display_nick (window->buffer, NULL, ptr_server->nick,
|
||||
GUI_MSG_TYPE_NICK, 1,
|
||||
GUI_COLOR(GUI_COLOR_CHAT_NICK_SELF), 0);
|
||||
gui_chat_printf_type (window->buffer,
|
||||
GUI_MSG_TYPE_MSG,
|
||||
NULL, -1,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
text);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (window->buffer, ptr_nick, NULL,
|
||||
GUI_MSG_TYPE_NICK, 1, NULL, 0);
|
||||
gui_chat_printf_type (window->buffer,
|
||||
GUI_MSG_TYPE_MSG,
|
||||
NULL, -1,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(GUI_COLOR_CHAT),
|
||||
text);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf_error (ptr_server->buffer,
|
||||
_("%s cannot find nick for sending "
|
||||
"message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_input_send_user_message: send a PRIVMSG message, and split it
|
||||
* if > 512 bytes
|
||||
*/
|
||||
|
||||
void
|
||||
irc_input_send_user_message (t_gui_window *window, char *text)
|
||||
{
|
||||
int max_length;
|
||||
char *pos, *pos_next, *pos_max, *next, saved_char, *last_space;
|
||||
|
||||
IRC_BUFFER_GET_SERVER_CHANNEL(window->buffer);
|
||||
|
||||
if (!ptr_server || !ptr_channel || !text || !text[0])
|
||||
return;
|
||||
|
||||
if (!ptr_server->is_connected)
|
||||
{
|
||||
gui_chat_printf_error (window->buffer,
|
||||
_("%s you are not connected to server\n"),
|
||||
WEECHAT_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
next = NULL;
|
||||
last_space = NULL;
|
||||
saved_char = '\0';
|
||||
|
||||
max_length = 512 - 16 - 65 - 10 - strlen (ptr_server->nick) -
|
||||
strlen (ptr_channel->name);
|
||||
|
||||
if (max_length > 0)
|
||||
{
|
||||
if ((int)strlen (text) > max_length)
|
||||
{
|
||||
pos = text;
|
||||
pos_max = text + max_length;
|
||||
while (pos && pos[0])
|
||||
{
|
||||
if (pos[0] == ' ')
|
||||
last_space = pos;
|
||||
pos_next = utf8_next_char (pos);
|
||||
if (pos_next > pos_max)
|
||||
break;
|
||||
pos = pos_next;
|
||||
}
|
||||
if (last_space && (last_space < pos))
|
||||
pos = last_space + 1;
|
||||
saved_char = pos[0];
|
||||
pos[0] = '\0';
|
||||
next = pos;
|
||||
}
|
||||
}
|
||||
|
||||
irc_server_sendf_queued (ptr_server, "PRIVMSG %s :%s",
|
||||
ptr_channel->name, text);
|
||||
irc_input_user_message_display (window, text);
|
||||
|
||||
if (next)
|
||||
{
|
||||
next[0] = saved_char;
|
||||
irc_input_send_user_message (window, next);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_input_data: read data from user input
|
||||
* Return: PROTOCOL_RC_OK if ok
|
||||
* PROTOCOL_RC_KO if error
|
||||
*/
|
||||
|
||||
int
|
||||
irc_input_data (t_gui_window *window, char *data)
|
||||
{
|
||||
char *data_with_colors;
|
||||
|
||||
IRC_BUFFER_GET_CHANNEL(window->buffer);
|
||||
|
||||
if (ptr_channel)
|
||||
{
|
||||
data_with_colors = (char *)irc_color_encode ((unsigned char *)data,
|
||||
irc_cfg_irc_colors_send);
|
||||
|
||||
if (ptr_channel->dcc_chat)
|
||||
{
|
||||
if (((t_irc_dcc *)(ptr_channel->dcc_chat))->sock < 0)
|
||||
{
|
||||
gui_chat_printf_error_nolog (window->buffer,
|
||||
"%s DCC CHAT is closed\n",
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_dcc_chat_sendf ((t_irc_dcc *)(ptr_channel->dcc_chat),
|
||||
"%s\r\n",
|
||||
(data_with_colors) ? data_with_colors : data);
|
||||
irc_input_user_message_display (window,
|
||||
(data_with_colors) ?
|
||||
data_with_colors : data);
|
||||
}
|
||||
}
|
||||
else
|
||||
irc_input_send_user_message (window,
|
||||
(data_with_colors) ? data_with_colors : data);
|
||||
|
||||
if (data_with_colors)
|
||||
free (data_with_colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_printf_error_nolog (window->buffer,
|
||||
_("This buffer is not a channel!\n"));
|
||||
return PROTOCOL_RC_KO;
|
||||
}
|
||||
|
||||
return PROTOCOL_RC_OK;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-log.c: log IRC buffers to files */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
|
||||
|
||||
/*
|
||||
* irc_log_get_filename: get filename for an IRC buffer log file
|
||||
* Note: result has to be free() after use
|
||||
*/
|
||||
|
||||
char *
|
||||
irc_log_fet_filename (char *server_name, char *channel_name, int dcc_chat)
|
||||
{
|
||||
int length;
|
||||
char *log_path, *log_path2;
|
||||
char *server_name2, *channel_name2;
|
||||
char *log_filename;
|
||||
|
||||
if (!server_name)
|
||||
return NULL;
|
||||
|
||||
log_path = weechat_strreplace (cfg_log_path, "~", getenv ("HOME"));
|
||||
log_path2 = weechat_strreplace (log_path, "%h", weechat_home);
|
||||
|
||||
if (channel_name)
|
||||
{
|
||||
server_name2 = NULL;
|
||||
channel_name2 = weechat_strreplace (channel_name, DIR_SEPARATOR, "_");
|
||||
}
|
||||
else
|
||||
{
|
||||
server_name2 = weechat_strreplace (server_name, DIR_SEPARATOR, "_");
|
||||
channel_name2 = NULL;
|
||||
}
|
||||
|
||||
if (!log_path || !log_path2 || (!channel_name && !server_name2)
|
||||
|| (channel_name && !channel_name2))
|
||||
{
|
||||
weechat_log_printf (_("Not enough memory to write log file \"%s\"\n"),
|
||||
(log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
|
||||
if (log_path)
|
||||
free (log_path);
|
||||
if (log_path2)
|
||||
free (log_path2);
|
||||
if (server_name2)
|
||||
free (server_name2);
|
||||
if (channel_name2)
|
||||
free (channel_name2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
length = strlen (log_path2) + 128;
|
||||
if (channel_name2)
|
||||
length += strlen (channel_name2);
|
||||
else
|
||||
length += strlen (server_name2);
|
||||
|
||||
log_filename = (char *) malloc (length);
|
||||
if (!log_filename)
|
||||
{
|
||||
weechat_log_printf (_("Not enough memory to write log file \"%s\"\n"),
|
||||
(log_path2) ? log_path2 : ((log_path) ? log_path : cfg_log_path));
|
||||
free (log_path);
|
||||
free (log_path2);
|
||||
if (server_name2)
|
||||
free (server_name2);
|
||||
if (channel_name2)
|
||||
free (channel_name2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy (log_filename, log_path2);
|
||||
|
||||
free (log_path);
|
||||
free (log_path2);
|
||||
|
||||
if (log_filename[strlen (log_filename) - 1] != DIR_SEPARATOR_CHAR)
|
||||
strcat (log_filename, DIR_SEPARATOR);
|
||||
|
||||
/* server buffer */
|
||||
if (!channel_name2)
|
||||
{
|
||||
strcat (log_filename, server_name2);
|
||||
strcat (log_filename, ".");
|
||||
}
|
||||
|
||||
/* DCC chat buffer */
|
||||
if (channel_name2 && dcc_chat)
|
||||
{
|
||||
strcat (log_filename, "dcc.");
|
||||
}
|
||||
|
||||
/* channel buffer */
|
||||
if (channel_name2)
|
||||
{
|
||||
strcat (log_filename, channel_name2);
|
||||
strcat (log_filename, ".");
|
||||
}
|
||||
|
||||
/* append WeeChat suffix */
|
||||
strcat (log_filename, "weechatlog");
|
||||
|
||||
if (server_name2)
|
||||
free (server_name2);
|
||||
if (channel_name2)
|
||||
free (channel_name2);
|
||||
|
||||
return log_filename;
|
||||
}
|
||||
@@ -26,9 +26,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ irc_mode_channel_set_nick (t_irc_channel *channel, char *nick,
|
||||
char set_flag, int flag)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
t_gui_nick *ptr_gui_nick;
|
||||
int sort_index, color_prefix;
|
||||
char prefix;
|
||||
|
||||
if (nick)
|
||||
{
|
||||
@@ -48,8 +51,19 @@ irc_mode_channel_set_nick (t_irc_channel *channel, char *nick,
|
||||
if (ptr_nick)
|
||||
{
|
||||
IRC_NICK_SET_FLAG(ptr_nick, (set_flag == '+'), flag);
|
||||
irc_nick_resort (channel, ptr_nick);
|
||||
gui_nicklist_draw (channel->buffer, 1, 1);
|
||||
ptr_gui_nick = gui_nicklist_search (channel->buffer,
|
||||
ptr_nick->nick);
|
||||
if (ptr_gui_nick)
|
||||
{
|
||||
irc_nick_get_gui_infos (ptr_nick, &sort_index, &prefix,
|
||||
&color_prefix);
|
||||
gui_nicklist_update (channel->buffer, ptr_gui_nick, NULL,
|
||||
sort_index,
|
||||
ptr_gui_nick->color_nick,
|
||||
prefix,
|
||||
color_prefix);
|
||||
gui_nicklist_draw (channel->buffer, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +111,7 @@ irc_mode_channel_set (t_irc_server *server, t_irc_channel *channel,
|
||||
pos_args++;
|
||||
while (pos_args[0] == ' ')
|
||||
pos_args++;
|
||||
argv = explode_string (pos_args, " ", 0, &argc);
|
||||
argv = weechat_explode_string (pos_args, " ", 0, &argc);
|
||||
if (argc > 0)
|
||||
current_arg = argc - 1;
|
||||
}
|
||||
@@ -198,7 +212,7 @@ irc_mode_channel_set (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
|
||||
if (argv)
|
||||
free_exploded_string (argv);
|
||||
weechat_free_exploded_string (argv);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -309,7 +323,7 @@ irc_mode_nick_prefix_allowed (t_irc_server *server, char prefix)
|
||||
{
|
||||
str[0] = prefix;
|
||||
str[1] = '\0';
|
||||
return (strpbrk (str, IRC_DEFAULT_PREFIXES_LIST)) ? 1 : 0;
|
||||
return (strpbrk (str, IRC_NICK_DEFAULT_PREFIXES_LIST)) ? 1 : 0;
|
||||
}
|
||||
|
||||
return (strchr (server->prefix, prefix) != NULL);
|
||||
|
||||
+117
-170
@@ -27,12 +27,12 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/utf8.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../core/utf8.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -51,145 +51,68 @@ irc_nick_find_color (t_irc_nick *nick)
|
||||
}
|
||||
color = (color % cfg_look_color_nicks_number);
|
||||
|
||||
return GUI_COLOR_WIN_NICK_1 + color;
|
||||
return GUI_COLOR_CHAT_NICK1 + color;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_score_for_sort: return score for sorting nick, according to privileges
|
||||
* irc_nick_get_gui_infos: get GUI infos for a nick (sort_index, prefix,
|
||||
* prefix color)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_score_for_sort (t_irc_nick *nick)
|
||||
void
|
||||
irc_nick_get_gui_infos (t_irc_nick *nick,
|
||||
int *sort_index, char *prefix, int *color_prefix)
|
||||
{
|
||||
if (nick->flags & IRC_NICK_CHANOWNER)
|
||||
return -128;
|
||||
if (nick->flags & IRC_NICK_CHANADMIN)
|
||||
return -64;
|
||||
if (nick->flags & IRC_NICK_CHANADMIN2)
|
||||
return -32;
|
||||
if (nick->flags & IRC_NICK_OP)
|
||||
return -16;
|
||||
if (nick->flags & IRC_NICK_HALFOP)
|
||||
return -8;
|
||||
if (nick->flags & IRC_NICK_VOICE)
|
||||
return -4;
|
||||
if (nick->flags & IRC_NICK_CHANUSER)
|
||||
return -2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_compare: compare two nicks
|
||||
* return: -1 is nick1 < nick2
|
||||
* 0 if nick1 = nick2
|
||||
* +1 if nick1 > nick2
|
||||
* status sort: operator > voice > normal nick
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_compare (t_irc_nick *nick1, t_irc_nick *nick2)
|
||||
{
|
||||
int score1, score2, comp;
|
||||
|
||||
score1 = irc_nick_score_for_sort (nick1);
|
||||
score2 = irc_nick_score_for_sort (nick2);
|
||||
|
||||
comp = ascii_strcasecmp (nick1->nick, nick2->nick);
|
||||
if (comp > 0)
|
||||
score1++;
|
||||
if (comp < 0)
|
||||
score2++;
|
||||
|
||||
/* nick1 > nick2 */
|
||||
if (score1 > score2)
|
||||
return 1;
|
||||
/* nick1 < nick2 */
|
||||
if (score1 < score2)
|
||||
return -1;
|
||||
/* nick1 == nick2 */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_find_pos: find position for a nick (for sorting nick list)
|
||||
*/
|
||||
|
||||
t_irc_nick *
|
||||
irc_nick_find_pos (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (irc_nick_compare (nick, ptr_nick) < 0)
|
||||
return ptr_nick;
|
||||
*sort_index = 1;
|
||||
*prefix = '~';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_insert_sorted: insert nick into sorted list
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_insert_sorted (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
t_irc_nick *pos_nick;
|
||||
|
||||
if (channel->nicks)
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN)
|
||||
{
|
||||
pos_nick = irc_nick_find_pos (channel, nick);
|
||||
|
||||
if (pos_nick)
|
||||
{
|
||||
/* insert nick into the list (before nick found) */
|
||||
nick->prev_nick = pos_nick->prev_nick;
|
||||
nick->next_nick = pos_nick;
|
||||
if (pos_nick->prev_nick)
|
||||
pos_nick->prev_nick->next_nick = nick;
|
||||
else
|
||||
channel->nicks = nick;
|
||||
pos_nick->prev_nick = nick;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add nick to the end */
|
||||
nick->prev_nick = channel->last_nick;
|
||||
nick->next_nick = NULL;
|
||||
channel->last_nick->next_nick = nick;
|
||||
channel->last_nick = nick;
|
||||
}
|
||||
*sort_index = 2;
|
||||
*prefix = '&';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
|
||||
}
|
||||
else if (nick->flags & IRC_NICK_CHANADMIN2)
|
||||
{
|
||||
*sort_index = 3;
|
||||
*prefix = '!';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
|
||||
}
|
||||
else if (nick->flags & IRC_NICK_OP)
|
||||
{
|
||||
*sort_index = 4;
|
||||
*prefix = '@';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX1;
|
||||
}
|
||||
else if (nick->flags & IRC_NICK_HALFOP)
|
||||
{
|
||||
*sort_index = 5;
|
||||
*prefix = '%';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX2;
|
||||
}
|
||||
else if (nick->flags & IRC_NICK_VOICE)
|
||||
{
|
||||
*sort_index = 6;
|
||||
*prefix = '+';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX3;
|
||||
}
|
||||
else if (nick->flags & IRC_NICK_CHANUSER)
|
||||
{
|
||||
*sort_index = 7;
|
||||
*prefix = '-';
|
||||
*color_prefix = GUI_COLOR_NICKLIST_PREFIX4;
|
||||
}
|
||||
else
|
||||
{
|
||||
nick->prev_nick = NULL;
|
||||
nick->next_nick = NULL;
|
||||
channel->nicks = nick;
|
||||
channel->last_nick = nick;
|
||||
*sort_index = 8;
|
||||
*prefix = ' ';
|
||||
*color_prefix = GUI_COLOR_NICKLIST;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_resort: resort nick in the list
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_resort (t_irc_channel *channel, t_irc_nick *nick)
|
||||
{
|
||||
/* temporarly remove nick from list */
|
||||
if (nick == channel->nicks)
|
||||
channel->nicks = nick->next_nick;
|
||||
else
|
||||
nick->prev_nick->next_nick = nick->next_nick;
|
||||
if (nick->next_nick)
|
||||
nick->next_nick->prev_nick = nick->prev_nick;
|
||||
if (nick == channel->last_nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
|
||||
/* insert again nick into sorted list */
|
||||
irc_nick_insert_sorted (channel, nick);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_new: allocate a new nick for a channel and add it to the nick list
|
||||
*/
|
||||
@@ -200,6 +123,9 @@ irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
|
||||
int is_halfop, int has_voice, int is_chanuser)
|
||||
{
|
||||
t_irc_nick *new_nick;
|
||||
t_gui_nick *ptr_gui_nick;
|
||||
int sort_index, color_prefix;
|
||||
char prefix;
|
||||
|
||||
/* nick already exists on this channel? */
|
||||
if ((new_nick = irc_nick_search (channel, nick_name)))
|
||||
@@ -212,7 +138,15 @@ irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
|
||||
IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
|
||||
IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
|
||||
irc_nick_resort (channel, new_nick);
|
||||
irc_nick_get_gui_infos (new_nick, &sort_index, &prefix, &color_prefix);
|
||||
ptr_gui_nick = gui_nicklist_search (channel->buffer, new_nick->nick);
|
||||
if (ptr_gui_nick)
|
||||
gui_nicklist_update (channel->buffer, ptr_gui_nick, NULL,
|
||||
sort_index,
|
||||
ptr_gui_nick->color_nick,
|
||||
prefix,
|
||||
color_prefix);
|
||||
|
||||
return new_nick;
|
||||
}
|
||||
|
||||
@@ -231,33 +165,56 @@ irc_nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name,
|
||||
IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
|
||||
IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
|
||||
IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
|
||||
if (ascii_strcasecmp (new_nick->nick, server->nick) == 0)
|
||||
new_nick->color = GUI_COLOR_WIN_NICK_SELF;
|
||||
if (weechat_strcasecmp (new_nick->nick, server->nick) == 0)
|
||||
new_nick->color = GUI_COLOR_CHAT_NICK_SELF;
|
||||
else
|
||||
new_nick->color = irc_nick_find_color (new_nick);
|
||||
|
||||
irc_nick_insert_sorted (channel, new_nick);
|
||||
|
||||
/* add nick to end of list */
|
||||
new_nick->prev_nick = channel->last_nick;
|
||||
if (channel->nicks)
|
||||
channel->last_nick->next_nick = new_nick;
|
||||
else
|
||||
channel->nicks = new_nick;
|
||||
channel->last_nick = new_nick;
|
||||
new_nick->next_nick = NULL;
|
||||
|
||||
channel->nicks_count++;
|
||||
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
|
||||
/* add nick to buffer nicklist */
|
||||
irc_nick_get_gui_infos (new_nick, &sort_index, &prefix, &color_prefix);
|
||||
gui_nicklist_add (channel->buffer, new_nick->nick, sort_index,
|
||||
GUI_COLOR_NICKLIST, prefix, color_prefix);
|
||||
|
||||
/* all is ok, return address of new nick */
|
||||
return new_nick;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_change: change nickname and move it if necessary (list is sorted)
|
||||
* irc_nick_change: change nickname
|
||||
*/
|
||||
|
||||
void
|
||||
irc_nick_change (t_irc_channel *channel, t_irc_nick *nick, char *new_nick)
|
||||
irc_nick_change (t_irc_server *server, t_irc_channel *channel,
|
||||
t_irc_nick *nick, char *new_nick)
|
||||
{
|
||||
int nick_is_me;
|
||||
t_weelist *ptr_weelist;
|
||||
t_gui_nick *ptr_nick;
|
||||
|
||||
/* update buffer nick */
|
||||
ptr_nick = gui_nicklist_search (channel->buffer, nick->nick);
|
||||
if (ptr_nick)
|
||||
gui_nicklist_update (channel->buffer, ptr_nick, new_nick,
|
||||
ptr_nick->sort_index,
|
||||
ptr_nick->color_nick,
|
||||
ptr_nick->prefix,
|
||||
ptr_nick->color_prefix);
|
||||
|
||||
nick_is_me = (strcmp (nick->nick, server->nick) == 0) ? 1 : 0;
|
||||
|
||||
nick_is_me = (strcmp (nick->nick, GUI_SERVER(channel->buffer)->nick) == 0) ? 1 : 0;
|
||||
|
||||
if (!nick_is_me && channel->nicks_speaking)
|
||||
{
|
||||
ptr_weelist = weelist_search (channel->nicks_speaking, nick->nick);
|
||||
@@ -273,16 +230,13 @@ irc_nick_change (t_irc_channel *channel, t_irc_nick *nick, char *new_nick)
|
||||
free (nick->nick);
|
||||
nick->nick = strdup (new_nick);
|
||||
if (nick_is_me)
|
||||
nick->color = GUI_COLOR_WIN_NICK_SELF;
|
||||
nick->color = GUI_COLOR_CHAT_NICK_SELF;
|
||||
else
|
||||
nick->color = irc_nick_find_color (nick);
|
||||
|
||||
/* insert again nick into sorted list */
|
||||
irc_nick_resort (channel, nick);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_free: free a nick and remove it from nicks queue
|
||||
* irc_nick_free: free a nick and remove it from nicks list
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -293,7 +247,10 @@ irc_nick_free (t_irc_channel *channel, t_irc_nick *nick)
|
||||
if (!channel || !nick)
|
||||
return;
|
||||
|
||||
/* remove nick from queue */
|
||||
/* remove nick from buffer nicklist */
|
||||
(void) gui_nicklist_remove (channel->buffer, nick->nick);
|
||||
|
||||
/* remove nick from nicks list */
|
||||
if (channel->last_nick == nick)
|
||||
channel->last_nick = nick->prev_nick;
|
||||
if (nick->prev_nick)
|
||||
@@ -316,7 +273,7 @@ irc_nick_free (t_irc_channel *channel, t_irc_nick *nick)
|
||||
free (nick->host);
|
||||
free (nick);
|
||||
channel->nicks = new_nicks;
|
||||
|
||||
|
||||
channel->nick_completion_reset = 1;
|
||||
}
|
||||
|
||||
@@ -353,7 +310,7 @@ irc_nick_search (t_irc_channel *channel, char *nickname)
|
||||
for (ptr_nick = channel->nicks; ptr_nick;
|
||||
ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
if (ascii_strcasecmp (ptr_nick->nick, nickname) == 0)
|
||||
if (weechat_strcasecmp (ptr_nick->nick, nickname) == 0)
|
||||
return ptr_nick;
|
||||
}
|
||||
return NULL;
|
||||
@@ -398,26 +355,6 @@ irc_nick_count (t_irc_channel *channel, int *total, int *count_op,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_get_max_length: returns longer nickname on a channel
|
||||
*/
|
||||
|
||||
int
|
||||
irc_nick_get_max_length (t_irc_channel *channel)
|
||||
{
|
||||
int length, max_length;
|
||||
t_irc_nick *ptr_nick;
|
||||
|
||||
max_length = 0;
|
||||
for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
|
||||
{
|
||||
length = utf8_width_screen (ptr_nick->nick);
|
||||
if (length > max_length)
|
||||
max_length = length;
|
||||
}
|
||||
return max_length;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_set_away: set/unset away status for a channel
|
||||
*/
|
||||
@@ -425,14 +362,24 @@ irc_nick_get_max_length (t_irc_channel *channel)
|
||||
void
|
||||
irc_nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
|
||||
{
|
||||
if ((cfg_irc_away_check > 0)
|
||||
&& ((cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= cfg_irc_away_check_max_nicks)))
|
||||
t_gui_nick *ptr_nick;
|
||||
|
||||
if ((irc_cfg_irc_away_check > 0)
|
||||
&& ((irc_cfg_irc_away_check_max_nicks == 0) ||
|
||||
(channel->nicks_count <= irc_cfg_irc_away_check_max_nicks)))
|
||||
{
|
||||
if (((is_away) && (!(nick->flags & IRC_NICK_AWAY))) ||
|
||||
((!is_away) && (nick->flags & IRC_NICK_AWAY)))
|
||||
{
|
||||
IRC_NICK_SET_FLAG(nick, is_away, IRC_NICK_AWAY);
|
||||
ptr_nick = gui_nicklist_search (channel->buffer, nick->nick);
|
||||
if (ptr_nick)
|
||||
gui_nicklist_update (channel->buffer, ptr_nick, NULL,
|
||||
ptr_nick->sort_index,
|
||||
(is_away) ? GUI_COLOR_NICKLIST_AWAY :
|
||||
GUI_COLOR_NICKLIST,
|
||||
ptr_nick->prefix,
|
||||
ptr_nick->color_prefix);
|
||||
gui_nicklist_draw (channel->buffer, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -445,7 +392,7 @@ irc_nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away)
|
||||
void
|
||||
irc_nick_print_log (t_irc_nick *nick)
|
||||
{
|
||||
weechat_log_printf ("=> nick %s (addr:0x%X)]\n", nick->nick, nick);
|
||||
weechat_log_printf ("=> nick %s (addr:0x%X):\n", nick->nick, nick);
|
||||
weechat_log_printf (" host . . . . . : %s\n", nick->host);
|
||||
weechat_log_printf (" flags. . . . . : %d\n", nick->flags);
|
||||
weechat_log_printf (" color. . . . . : %d\n", nick->color);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_NICK_H
|
||||
#define __WEECHAT_IRC_NICK_H 1
|
||||
|
||||
#define IRC_NICK_DEFAULT_PREFIXES_LIST "@%+~&!-"
|
||||
|
||||
#define IRC_NICK_CHANOWNER 1
|
||||
#define IRC_NICK_CHANADMIN 2
|
||||
#define IRC_NICK_OP 4
|
||||
#define IRC_NICK_HALFOP 8
|
||||
#define IRC_NICK_VOICE 16
|
||||
#define IRC_NICK_AWAY 32
|
||||
#define IRC_NICK_CHANADMIN2 64
|
||||
#define IRC_NICK_CHANUSER 128
|
||||
#define IRC_NICK_SET_FLAG(nick, set, flag) \
|
||||
if (set) \
|
||||
nick->flags |= flag; \
|
||||
else \
|
||||
nick->flags &= 0xFFFF - flag;
|
||||
|
||||
typedef struct t_irc_nick t_irc_nick;
|
||||
|
||||
struct t_irc_nick
|
||||
{
|
||||
char *nick; /* nickname */
|
||||
char *host; /* full hostname */
|
||||
int flags; /* chanowner/chanadmin (unrealircd), */
|
||||
/* op, halfop, voice, away */
|
||||
int color; /* color for nickname in chat window */
|
||||
t_irc_nick *prev_nick; /* link to previous nick on the channel */
|
||||
t_irc_nick *next_nick; /* link to next nick on the channel */
|
||||
};
|
||||
|
||||
#endif /* irc-nick.h */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_PROTOCOL_H
|
||||
#define __WEECHAT_IRC_PROTOCOL_H 1
|
||||
|
||||
typedef int (t_irc_recv_func)(t_irc_server *, char *, char *, char *, char *,
|
||||
int, int);
|
||||
|
||||
typedef struct t_irc_protocol_msg t_irc_protocol_msg;
|
||||
|
||||
struct t_irc_protocol_msg
|
||||
{
|
||||
char *name; /* IRC message name */
|
||||
char *description; /* message description */
|
||||
t_irc_recv_func *recv_function; /* function called when msg is received */
|
||||
};
|
||||
|
||||
#endif /* irc-protocol.h */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+350
-181
@@ -42,16 +42,14 @@
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "../../common/weechat.h"
|
||||
#include "../../core/weechat.h"
|
||||
#include "irc.h"
|
||||
#include "../../common/log.h"
|
||||
#include "../../common/util.h"
|
||||
#include "../../common/weeconfig.h"
|
||||
#include "../../core/hook.h"
|
||||
#include "../../core/log.h"
|
||||
#include "../../core/util.h"
|
||||
#include "../../core/weechat-config.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
#ifdef PLUGINS
|
||||
#include "../../plugins/plugins.h"
|
||||
#endif
|
||||
|
||||
|
||||
t_irc_server *irc_servers = NULL;
|
||||
@@ -60,8 +58,6 @@ t_irc_server *last_irc_server = NULL;
|
||||
t_irc_message *irc_recv_msgq = NULL;
|
||||
t_irc_message *irc_msgq_last_msg = NULL;
|
||||
|
||||
int irc_check_away = 0;
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
const int gnutls_cert_type_prio[] = { GNUTLS_CRT_X509, GNUTLS_CRT_OPENPGP, 0 };
|
||||
#if LIBGNUTLS_VERSION_NUMBER >= 0x010700
|
||||
@@ -109,6 +105,7 @@ irc_server_init (t_irc_server *server)
|
||||
server->child_read = -1;
|
||||
server->child_write = -1;
|
||||
server->sock = -1;
|
||||
server->hook_fd = NULL;
|
||||
server->is_connected = 0;
|
||||
server->ssl_connected = 0;
|
||||
server->unterminated_message = NULL;
|
||||
@@ -125,14 +122,13 @@ irc_server_init (t_irc_server *server)
|
||||
server->lag = 0;
|
||||
server->lag_check_time.tv_sec = 0;
|
||||
server->lag_check_time.tv_usec = 0;
|
||||
server->lag_next_check = time (NULL) + cfg_irc_lag_check;
|
||||
server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check;
|
||||
server->cmd_list_regexp = NULL;
|
||||
server->queue_msg = 0;
|
||||
server->last_user_message = 0;
|
||||
server->outqueue = NULL;
|
||||
server->last_outqueue = NULL;
|
||||
server->buffer = NULL;
|
||||
server->saved_buffer = NULL;
|
||||
server->channels = NULL;
|
||||
server->last_channel = NULL;
|
||||
}
|
||||
@@ -250,7 +246,7 @@ irc_server_init_with_url (char *irc_url, t_irc_server *server)
|
||||
|
||||
/* some default values */
|
||||
if (server->port < 0)
|
||||
server->port = IRC_DEFAULT_PORT;
|
||||
server->port = IRC_SERVER_DEFAULT_PORT;
|
||||
server->nick2 = (char *) malloc (strlen (server->nick1) + 2);
|
||||
strcpy (server->nick2, server->nick1);
|
||||
server->nick2 = strcat (server->nick2, "1");
|
||||
@@ -601,15 +597,43 @@ irc_server_rename (t_irc_server *server, char *new_name)
|
||||
int
|
||||
irc_server_send (t_irc_server *server, char *buffer, int size_buf)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!server)
|
||||
return -1;
|
||||
{
|
||||
gui_chat_printf_error (NULL,
|
||||
_("%s error sending data to IRC server: null "
|
||||
"pointer (please report problem to "
|
||||
"developers)"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (size_buf <= 0)
|
||||
{
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s error sending data to IRC server: empty "
|
||||
"buffer (please report problem to "
|
||||
"developers)"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (server->ssl_connected)
|
||||
return gnutls_record_send (server->gnutls_sess, buffer, size_buf);
|
||||
rc = gnutls_record_send (server->gnutls_sess, buffer, size_buf);
|
||||
else
|
||||
#endif
|
||||
return send (server->sock, buffer, size_buf, 0);
|
||||
rc = send (server->sock, buffer, size_buf, 0);
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s error sending data to IRC server (%s)"),
|
||||
WEECHAT_ERROR, strerror (errno));
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -625,15 +649,15 @@ irc_server_outqueue_send (t_irc_server *server)
|
||||
if (server->outqueue)
|
||||
{
|
||||
time_now = time (NULL);
|
||||
if (time_now >= server->last_user_message + cfg_irc_anti_flood)
|
||||
if (time_now >= server->last_user_message + irc_cfg_irc_anti_flood)
|
||||
{
|
||||
if (server->outqueue->message_before_mod)
|
||||
{
|
||||
pos = strchr (server->outqueue->message_before_mod, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
gui_printf_raw_data (server, 1, 0,
|
||||
server->outqueue->message_before_mod);
|
||||
gui_chat_printf_raw_data (server, 1, 0,
|
||||
server->outqueue->message_before_mod);
|
||||
if (pos)
|
||||
pos[0] = '\r';
|
||||
}
|
||||
@@ -642,17 +666,18 @@ irc_server_outqueue_send (t_irc_server *server)
|
||||
pos = strchr (server->outqueue->message_after_mod, '\r');
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
gui_printf_raw_data (server, 1, server->outqueue->modified,
|
||||
server->outqueue->message_after_mod);
|
||||
gui_chat_printf_raw_data (server, 1, server->outqueue->modified,
|
||||
server->outqueue->message_after_mod);
|
||||
if (pos)
|
||||
pos[0] = '\r';
|
||||
}
|
||||
if (irc_server_send (server, server->outqueue->message_after_mod,
|
||||
strlen (server->outqueue->message_after_mod)) <= 0)
|
||||
strlen (server->outqueue->message_after_mod)) < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s error sending data to IRC "
|
||||
"server\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
server->last_user_message = time_now;
|
||||
irc_server_outqueue_free (server, server->outqueue);
|
||||
@@ -675,15 +700,12 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
|
||||
rc = 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
gui_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n", message);
|
||||
gui_chat_printf (server->buffer, "[DEBUG] Sending to server >>> %s\n",
|
||||
message);
|
||||
#endif
|
||||
#ifdef PLUGINS
|
||||
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
|
||||
server->name,
|
||||
message);
|
||||
#else
|
||||
new_msg = NULL;
|
||||
#endif
|
||||
|
||||
/* no changes in new message */
|
||||
if (new_msg && (strcmp (buffer, new_msg) == 0))
|
||||
@@ -711,8 +733,8 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
|
||||
queue = 0;
|
||||
if ((server->queue_msg)
|
||||
&& ((server->outqueue)
|
||||
|| ((cfg_irc_anti_flood > 0)
|
||||
&& (time_now - server->last_user_message < cfg_irc_anti_flood))))
|
||||
|| ((irc_cfg_irc_anti_flood > 0)
|
||||
&& (time_now - server->last_user_message < irc_cfg_irc_anti_flood))))
|
||||
queue = 1;
|
||||
|
||||
/* if queue, then only queue message and send nothing now */
|
||||
@@ -726,14 +748,15 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
|
||||
else
|
||||
{
|
||||
if (first_message)
|
||||
gui_printf_raw_data (server, 1, 0, message);
|
||||
gui_chat_printf_raw_data (server, 1, 0, message);
|
||||
if (new_msg)
|
||||
gui_printf_raw_data (server, 1, 1, ptr_msg);
|
||||
gui_chat_printf_raw_data (server, 1, 1, ptr_msg);
|
||||
if (irc_server_send (server, buffer, strlen (buffer)) <= 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer, _("%s error sending data to IRC server\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s error sending data to IRC "
|
||||
"server\n"),
|
||||
WEECHAT_ERROR);
|
||||
rc = 0;
|
||||
}
|
||||
else
|
||||
@@ -754,7 +777,7 @@ irc_server_send_one_msg (t_irc_server *server, char *message)
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_printf_raw_data (server, 1, 1, _("(message dropped)"));
|
||||
gui_chat_printf_raw_data (server, 1, 1, _("(message dropped)"));
|
||||
if (new_msg)
|
||||
free (new_msg);
|
||||
|
||||
@@ -862,10 +885,10 @@ irc_server_msgq_add_msg (t_irc_server *server, char *msg)
|
||||
message = (t_irc_message *) malloc (sizeof (t_irc_message));
|
||||
if (!message)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for received IRC message\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for received IRC "
|
||||
"message\n"),
|
||||
WEECHAT_ERROR);
|
||||
return;
|
||||
}
|
||||
message->server = server;
|
||||
@@ -875,10 +898,10 @@ irc_server_msgq_add_msg (t_irc_server *server, char *msg)
|
||||
strlen (msg) + 1);
|
||||
if (!message->data)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for received IRC message\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for received IRC "
|
||||
"message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -922,10 +945,10 @@ irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
|
||||
strlen (string) + 1);
|
||||
if (!server->unterminated_message)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for received IRC message\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for received IRC "
|
||||
"message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
else
|
||||
strcat (server->unterminated_message, string);
|
||||
@@ -935,10 +958,10 @@ irc_server_msgq_add_unterminated (t_irc_server *server, char *string)
|
||||
server->unterminated_message = strdup (string);
|
||||
if (!server->unterminated_message)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s not enough memory for received IRC message\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s not enough memory for received IRC "
|
||||
"message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,7 +1020,9 @@ irc_server_msgq_flush ()
|
||||
if (irc_recv_msgq->data)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
gui_printf (gui_current_window->buffer, "[DEBUG] %s\n", irc_recv_msgq->data);
|
||||
gui_chat_printf (gui_current_window->buffer,
|
||||
"[DEBUG] %s\n",
|
||||
irc_recv_msgq->data);
|
||||
#endif
|
||||
ptr_data = irc_recv_msgq->data;
|
||||
while (ptr_data[0] == ' ')
|
||||
@@ -1005,17 +1030,16 @@ irc_server_msgq_flush ()
|
||||
|
||||
if (ptr_data[0])
|
||||
{
|
||||
gui_printf_raw_data (irc_recv_msgq->server, 0, 0, ptr_data);
|
||||
gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 0,
|
||||
ptr_data);
|
||||
#ifdef DEBUG
|
||||
gui_printf (NULL, "[DEBUG] data received from server: %s\n", ptr_data);
|
||||
gui_chat_printf (NULL,
|
||||
"[DEBUG] data received from server: %s\n",
|
||||
ptr_data);
|
||||
#endif
|
||||
#ifdef PLUGINS
|
||||
new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
|
||||
irc_recv_msgq->server->name,
|
||||
ptr_data);
|
||||
#else
|
||||
new_msg = NULL;
|
||||
#endif
|
||||
/* no changes in new message */
|
||||
if (new_msg && (strcmp (ptr_data, new_msg) == 0))
|
||||
{
|
||||
@@ -1036,30 +1060,36 @@ irc_server_msgq_flush ()
|
||||
pos[0] = '\0';
|
||||
|
||||
if (new_msg)
|
||||
gui_printf_raw_data (irc_recv_msgq->server, 0, 1, ptr_msg);
|
||||
gui_chat_printf_raw_data (irc_recv_msgq->server,
|
||||
0, 1, ptr_msg);
|
||||
|
||||
irc_server_parse_message (ptr_msg, &host, &command, &args);
|
||||
irc_server_parse_message (ptr_msg, &host,
|
||||
&command, &args);
|
||||
|
||||
switch (irc_recv_command (irc_recv_msgq->server, ptr_msg, host, command, args))
|
||||
switch (irc_protocol_recv_command (irc_recv_msgq->server,
|
||||
ptr_msg,
|
||||
host, command, args))
|
||||
{
|
||||
case -1:
|
||||
irc_display_prefix (irc_recv_msgq->server,
|
||||
irc_recv_msgq->server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (irc_recv_msgq->server->buffer,
|
||||
_("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command);
|
||||
gui_chat_printf_error (irc_recv_msgq->server->buffer,
|
||||
_("%s Command \"%s\" "
|
||||
"failed!\n"),
|
||||
WEECHAT_ERROR, command);
|
||||
break;
|
||||
case -2:
|
||||
irc_display_prefix (irc_recv_msgq->server,
|
||||
irc_recv_msgq->server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (irc_recv_msgq->server->buffer,
|
||||
_("%s No command to execute!\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (irc_recv_msgq->server->buffer,
|
||||
_("%s No command to "
|
||||
"execute!\n"),
|
||||
WEECHAT_ERROR);
|
||||
break;
|
||||
case -3:
|
||||
irc_display_prefix (irc_recv_msgq->server,
|
||||
irc_recv_msgq->server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (irc_recv_msgq->server->buffer,
|
||||
_("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"),
|
||||
WEECHAT_WARNING, command, host, args);
|
||||
gui_chat_printf_error (irc_recv_msgq->server->buffer,
|
||||
_("%s Unknown command: "
|
||||
"cmd=\"%s\", "
|
||||
"host=\"%s\", "
|
||||
"args=\"%s\"\n"),
|
||||
WEECHAT_WARNING,
|
||||
command, host, args);
|
||||
break;
|
||||
}
|
||||
if (host)
|
||||
@@ -1079,7 +1109,8 @@ irc_server_msgq_flush ()
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_printf_raw_data (irc_recv_msgq->server, 0, 1, _("(message dropped)"));
|
||||
gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 1,
|
||||
_("(message dropped)"));
|
||||
if (new_msg)
|
||||
free (new_msg);
|
||||
}
|
||||
@@ -1099,8 +1130,12 @@ irc_server_msgq_flush ()
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_recv (t_irc_server *server)
|
||||
irc_server_recv (void *arg_server)
|
||||
{
|
||||
t_irc_server *server;
|
||||
|
||||
server = (t_irc_server *)arg_server;
|
||||
|
||||
static char buffer[4096 + 2];
|
||||
int num_read;
|
||||
|
||||
@@ -1109,7 +1144,8 @@ irc_server_recv (t_irc_server *server)
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (server->ssl_connected)
|
||||
num_read = gnutls_record_recv (server->gnutls_sess, buffer, sizeof (buffer) - 2);
|
||||
num_read = gnutls_record_recv (server->gnutls_sess, buffer,
|
||||
sizeof (buffer) - 2);
|
||||
else
|
||||
#endif
|
||||
num_read = recv (server->sock, buffer, sizeof (buffer) - 2, 0);
|
||||
@@ -1122,14 +1158,98 @@ irc_server_recv (t_irc_server *server)
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot read data from socket, disconnecting from server...\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot read data from socket, "
|
||||
"disconnecting from server...\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_disconnect (server, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_timer: timer called each second to perform some operations
|
||||
* on servers
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_timer (void *empty)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
time_t new_time;
|
||||
static struct timeval tv;
|
||||
int diff;
|
||||
|
||||
(void) empty;
|
||||
|
||||
new_time = time (NULL);
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
/* check if reconnection is pending */
|
||||
if ((!ptr_server->is_connected)
|
||||
&& (ptr_server->reconnect_start > 0)
|
||||
&& (new_time >= (ptr_server->reconnect_start + ptr_server->autoreconnect_delay)))
|
||||
irc_server_reconnect (ptr_server);
|
||||
else
|
||||
{
|
||||
if (ptr_server->is_connected)
|
||||
{
|
||||
/* send queued messages */
|
||||
irc_server_outqueue_send (ptr_server);
|
||||
|
||||
/* check for lag */
|
||||
if ((ptr_server->lag_check_time.tv_sec == 0)
|
||||
&& (new_time >= ptr_server->lag_next_check))
|
||||
{
|
||||
irc_server_sendf (ptr_server, "PING %s", ptr_server->address);
|
||||
gettimeofday (&(ptr_server->lag_check_time), NULL);
|
||||
}
|
||||
|
||||
/* check if it's time to autojoin channels (after command delay) */
|
||||
if ((ptr_server->command_time != 0)
|
||||
&& (new_time >= ptr_server->command_time + ptr_server->command_delay))
|
||||
{
|
||||
irc_server_autojoin_channels (ptr_server);
|
||||
ptr_server->command_time = 0;
|
||||
}
|
||||
|
||||
/* lag timeout => disconnect */
|
||||
if ((ptr_server->lag_check_time.tv_sec != 0)
|
||||
&& (irc_cfg_irc_lag_disconnect > 0))
|
||||
{
|
||||
gettimeofday (&tv, NULL);
|
||||
diff = (int) weechat_get_timeval_diff (&(ptr_server->lag_check_time),
|
||||
&tv);
|
||||
if (diff / 1000 > irc_cfg_irc_lag_disconnect * 60)
|
||||
{
|
||||
gui_chat_printf_error (ptr_server->buffer,
|
||||
_("%s lag is high, "
|
||||
"disconnecting from "
|
||||
"server...\n"),
|
||||
WEECHAT_WARNING);
|
||||
irc_server_disconnect (ptr_server, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_timer_check_away: timer called to check away on servers
|
||||
* (according to option "irc_check_away")
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_timer_check_away (void *empty)
|
||||
{
|
||||
(void) empty;
|
||||
|
||||
if (irc_cfg_irc_away_check > 0)
|
||||
irc_server_check_away ();
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_child_kill: kill child process and close pipe
|
||||
*/
|
||||
@@ -1206,24 +1326,47 @@ irc_server_reconnect_schedule (t_irc_server *server)
|
||||
if (server->autoreconnect)
|
||||
{
|
||||
server->reconnect_start = time (NULL);
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer, _("%s: Reconnecting to server in %d seconds\n"),
|
||||
PACKAGE_NAME, server->autoreconnect_delay);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("%s: Reconnecting to server in %d seconds\n"),
|
||||
PACKAGE_NAME, server->autoreconnect_delay);
|
||||
}
|
||||
else
|
||||
server->reconnect_start = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_login: login to IRC server
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_login (t_irc_server *server)
|
||||
{
|
||||
if ((server->password) && (server->password[0]))
|
||||
irc_server_sendf (server, "PASS %s", server->password);
|
||||
|
||||
if (!server->nick)
|
||||
server->nick = strdup (server->nick1);
|
||||
irc_server_sendf (server,
|
||||
"NICK %s\n"
|
||||
"USER %s %s %s :%s",
|
||||
server->nick, server->username, server->username,
|
||||
server->address, server->realname);
|
||||
gui_input_draw (gui_current_window->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_server_child_read: read connection progress from child process
|
||||
*/
|
||||
|
||||
void
|
||||
irc_server_child_read (t_irc_server *server)
|
||||
irc_server_child_read (void *arg_server)
|
||||
{
|
||||
t_irc_server *server;
|
||||
char buffer[1];
|
||||
int num_read;
|
||||
|
||||
server = (t_irc_server *)arg_server;
|
||||
|
||||
num_read = read (server->child_read, buffer, sizeof (buffer));
|
||||
if (num_read > 0)
|
||||
{
|
||||
@@ -1239,10 +1382,10 @@ irc_server_child_read (t_irc_server *server)
|
||||
(gnutls_transport_ptr) ((unsigned long) server->sock));
|
||||
if (gnutls_handshake (server->gnutls_sess) < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s gnutls handshake failed\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s GnuTLS handshake "
|
||||
"failed\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
return;
|
||||
@@ -1251,62 +1394,61 @@ irc_server_child_read (t_irc_server *server)
|
||||
#endif
|
||||
/* kill child and login to server */
|
||||
irc_server_child_kill (server);
|
||||
irc_send_login (server);
|
||||
irc_server_login (server);
|
||||
weechat_hook_remove (server->hook_fd);
|
||||
server->hook_fd = weechat_hook_add_fd (server->sock,
|
||||
WEECHAT_HOOK_FD_READ,
|
||||
irc_server_recv,
|
||||
server);
|
||||
break;
|
||||
/* adress not found */
|
||||
case '1':
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
if (cfg_proxy_use)
|
||||
gui_printf (server->buffer,
|
||||
_("%s proxy address \"%s\" not found\n"),
|
||||
WEECHAT_ERROR, server->address);
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s address \"%s\" not found\n"),
|
||||
WEECHAT_ERROR, server->address);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
(cfg_proxy_use) ?
|
||||
_("%s proxy address \"%s\" not "
|
||||
"found\n") :
|
||||
_("%s address \"%s\" not found\n"),
|
||||
WEECHAT_ERROR, server->address);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
break;
|
||||
/* IP address not found */
|
||||
case '2':
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
if (cfg_proxy_use)
|
||||
gui_printf (server->buffer,
|
||||
_("%s proxy IP address not found\n"), WEECHAT_ERROR);
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s IP address not found\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
(cfg_proxy_use) ?
|
||||
_("%s proxy IP address not found\n") :
|
||||
_("%s IP address not found\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
break;
|
||||
/* connection refused */
|
||||
case '3':
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
if (cfg_proxy_use)
|
||||
gui_printf (server->buffer,
|
||||
_("%s proxy connection refused\n"), WEECHAT_ERROR);
|
||||
else
|
||||
gui_printf (server->buffer,
|
||||
_("%s connection refused\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
(cfg_proxy_use) ?
|
||||
_("%s proxy connection refused\n") :
|
||||
_("%s connection refused\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
break;
|
||||
/* proxy fails to connect to server */
|
||||
case '4':
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s proxy fails to establish connection to "
|
||||
"server (check username/password if used)\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s proxy fails to establish "
|
||||
"connection to "
|
||||
"server (check username/password if "
|
||||
"used)\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
break;
|
||||
/* fails to set local hostname/IP */
|
||||
case '5':
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s unable to set local hostname/IP\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s unable to set local "
|
||||
"hostname/IP\n"),
|
||||
WEECHAT_ERROR);
|
||||
irc_server_close_connection (server);
|
||||
irc_server_reconnect_schedule (server);
|
||||
break;
|
||||
@@ -1808,6 +1950,8 @@ irc_server_child (t_irc_server *server)
|
||||
|
||||
/*
|
||||
* irc_server_connect: connect to an IRC server
|
||||
* Return: 1 if ok
|
||||
* 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -1817,46 +1961,70 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
#ifndef __CYGWIN__
|
||||
pid_t pid;
|
||||
#endif
|
||||
char *log_filename;
|
||||
|
||||
if (!server->buffer)
|
||||
{
|
||||
log_filename = irc_log_get_filename (server->name, NULL, 0);
|
||||
server->buffer = gui_buffer_new (gui_current_window, 0,
|
||||
server->name, server->name,
|
||||
GUI_BUFFER_ATTRIB_TEXT | GUI_BUFFER_ATTRIB_INPUT |
|
||||
GUI_BUFFER_ATTRIB_NICKS,
|
||||
irc_protocol,
|
||||
irc_buffer_data_create (server),
|
||||
&irc_buffer_data_free,
|
||||
GUI_NOTIFY_LEVEL_DEFAULT,
|
||||
NULL, server->nick,
|
||||
irc_cfg_log_auto_server, log_filename,
|
||||
1);
|
||||
if (log_filename)
|
||||
free (log_filename);
|
||||
if (!server->buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef HAVE_GNUTLS
|
||||
if (server->ssl)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot connect with SSL since WeeChat was not built "
|
||||
"with GNUtls support\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot connect with SSL since WeeChat "
|
||||
"was not built with GnuTLS support\n"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
if (cfg_proxy_use)
|
||||
{
|
||||
gui_printf (server->buffer,
|
||||
_("%s: connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"),
|
||||
PACKAGE_NAME, server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "",
|
||||
cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port,
|
||||
(cfg_proxy_ipv6) ? " (IPv6)" : "");
|
||||
weechat_log_printf (_("Connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"),
|
||||
{
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("%s: connecting to server %s:%d%s%s via %s "
|
||||
"proxy %s:%d%s...\n"),
|
||||
PACKAGE_NAME, server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "",
|
||||
cfg_proxy_type_values[cfg_proxy_type],
|
||||
cfg_proxy_address, cfg_proxy_port,
|
||||
(cfg_proxy_ipv6) ? " (IPv6)" : "");
|
||||
weechat_log_printf (_("Connecting to server %s:%d%s%s via %s proxy "
|
||||
"%s:%d%s...\n"),
|
||||
server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "",
|
||||
cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port,
|
||||
cfg_proxy_type_values[cfg_proxy_type],
|
||||
cfg_proxy_address, cfg_proxy_port,
|
||||
(cfg_proxy_ipv6) ? " (IPv6)" : "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->buffer,
|
||||
_("%s: connecting to server %s:%d%s%s...\n"),
|
||||
PACKAGE_NAME, server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "");
|
||||
weechat_log_printf (_("Connecting to server %s:%d%s%s...\n"),
|
||||
{
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("%s: connecting to server %s:%d%s%s...\n"),
|
||||
PACKAGE_NAME, server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "");
|
||||
weechat_log_printf (_("Connecting to server %s:%d%s%s...\n"),
|
||||
server->address, server->port,
|
||||
(server->ipv6) ? " (IPv6)" : "",
|
||||
(server->ssl) ? " (SSL)" : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* close any opened connection and kill child process if running */
|
||||
irc_server_close_connection (server);
|
||||
@@ -1868,15 +2036,17 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
{
|
||||
if (gnutls_init (&server->gnutls_sess, GNUTLS_CLIENT) != 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s gnutls init error\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s GnuTLS init error\n"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
gnutls_set_default_priority (server->gnutls_sess);
|
||||
gnutls_certificate_type_set_priority (server->gnutls_sess, gnutls_cert_type_prio);
|
||||
gnutls_certificate_type_set_priority (server->gnutls_sess,
|
||||
gnutls_cert_type_prio);
|
||||
gnutls_protocol_set_priority (server->gnutls_sess, gnutls_prot_prio);
|
||||
gnutls_credentials_set (server->gnutls_sess, GNUTLS_CRD_CERTIFICATE, gnutls_xcred);
|
||||
gnutls_credentials_set (server->gnutls_sess, GNUTLS_CRD_CERTIFICATE,
|
||||
gnutls_xcred);
|
||||
server->ssl_connected = 1;
|
||||
}
|
||||
#endif
|
||||
@@ -1884,9 +2054,9 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
/* create pipe for child process */
|
||||
if (pipe (child_pipe) < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot create pipe\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot create pipe\n"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
server->child_read = child_pipe[0];
|
||||
@@ -1899,9 +2069,9 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
server->sock = socket ((server->ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
|
||||
if (server->sock == -1)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot create socket\n"), WEECHAT_ERROR);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot create socket\n"),
|
||||
WEECHAT_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1910,10 +2080,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
if (setsockopt (server->sock, SOL_SOCKET, SO_REUSEADDR,
|
||||
(void *) &set, sizeof (set)) == -1)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot set socket option \"SO_REUSEADDR\"\n"),
|
||||
WEECHAT_WARNING);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot set socket option "
|
||||
"\"SO_REUSEADDR\"\n"),
|
||||
WEECHAT_WARNING);
|
||||
}
|
||||
|
||||
/* set SO_KEEPALIVE option for socket */
|
||||
@@ -1921,10 +2091,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
if (setsockopt (server->sock, SOL_SOCKET, SO_KEEPALIVE,
|
||||
(void *) &set, sizeof (set)) == -1)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot set socket option \"SO_KEEPALIVE\"\n"),
|
||||
WEECHAT_WARNING);
|
||||
gui_chat_printf_error (server->buffer,
|
||||
_("%s cannot set socket option "
|
||||
"\"SO_KEEPALIVE\"\n"),
|
||||
WEECHAT_WARNING);
|
||||
}
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
@@ -1950,6 +2120,10 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
}
|
||||
/* parent process */
|
||||
server->child_pid = pid;
|
||||
server->hook_fd = weechat_hook_add_fd (server->child_read,
|
||||
WEECHAT_HOOK_FD_READ,
|
||||
irc_server_child_read,
|
||||
server);
|
||||
#endif
|
||||
|
||||
server->disable_autojoin = disable_autojoin;
|
||||
@@ -1964,9 +2138,8 @@ irc_server_connect (t_irc_server *server, int disable_autojoin)
|
||||
void
|
||||
irc_server_reconnect (t_irc_server *server)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer, _("%s: Reconnecting to server...\n"),
|
||||
PACKAGE_NAME);
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Reconnecting to server...\n"));
|
||||
server->reconnect_start = 0;
|
||||
|
||||
if (irc_server_connect (server, 0))
|
||||
@@ -1990,9 +2163,6 @@ irc_server_auto_connect (int auto_connect, int temp_server)
|
||||
if ( ((temp_server) && (ptr_server->temp_server))
|
||||
|| ((!temp_server) && (auto_connect) && (ptr_server->autoconnect)) )
|
||||
{
|
||||
(void) gui_buffer_new (gui_current_window, ptr_server, NULL,
|
||||
GUI_BUFFER_TYPE_STANDARD, 1);
|
||||
gui_window_redraw_buffer (gui_current_window->buffer);
|
||||
if (!irc_server_connect (ptr_server, 0))
|
||||
irc_server_reconnect_schedule (ptr_server);
|
||||
}
|
||||
@@ -2015,8 +2185,8 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
irc_nick_free_all (ptr_channel);
|
||||
irc_display_prefix (NULL, ptr_channel->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (ptr_channel->buffer, _("Disconnected from server!\n"));
|
||||
gui_chat_printf_info (ptr_channel->buffer,
|
||||
_("Disconnected from server!\n"));
|
||||
gui_nicklist_draw (ptr_channel->buffer, 1, 1);
|
||||
gui_status_draw (ptr_channel->buffer, 1);
|
||||
}
|
||||
@@ -2025,10 +2195,8 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
|
||||
irc_server_close_connection (server);
|
||||
|
||||
if (server->buffer)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, GUI_PREFIX_INFO);
|
||||
gui_printf (server->buffer, _("Disconnected from server!\n"));
|
||||
}
|
||||
gui_chat_printf_info (server->buffer,
|
||||
_("Disconnected from server!\n"));
|
||||
|
||||
if (server->nick_modes)
|
||||
{
|
||||
@@ -2045,7 +2213,7 @@ irc_server_disconnect (t_irc_server *server, int reconnect)
|
||||
server->lag = 0;
|
||||
server->lag_check_time.tv_sec = 0;
|
||||
server->lag_check_time.tv_usec = 0;
|
||||
server->lag_next_check = time (NULL) + cfg_irc_lag_check;
|
||||
server->lag_next_check = time (NULL) + irc_cfg_irc_lag_check;
|
||||
|
||||
if ((reconnect) && (server->autoreconnect))
|
||||
irc_server_reconnect_schedule (server);
|
||||
@@ -2106,7 +2274,7 @@ irc_server_autojoin_channels (t_irc_server *server)
|
||||
{
|
||||
/* auto-join when connecting to server for first time */
|
||||
if (!server->disable_autojoin && server->autojoin && server->autojoin[0])
|
||||
irc_send_cmd_join (server, NULL, server->autojoin);
|
||||
irc_cmd_join_server (server, server->autojoin);
|
||||
}
|
||||
|
||||
server->disable_autojoin = 0;
|
||||
@@ -2386,6 +2554,7 @@ irc_server_print_log (t_irc_server *server)
|
||||
weechat_log_printf (" child_read . . . . : %d\n", server->child_read);
|
||||
weechat_log_printf (" child_write . . . . : %d\n", server->child_write);
|
||||
weechat_log_printf (" sock. . . . . . . . : %d\n", server->sock);
|
||||
weechat_log_printf (" hook_fd . . . . . . : 0x%X\n", server->hook_fd);
|
||||
weechat_log_printf (" is_connected. . . . : %d\n", server->is_connected);
|
||||
weechat_log_printf (" ssl_connected . . . : %d\n", server->ssl_connected);
|
||||
weechat_log_printf (" unterminated_message: '%s'\n", server->unterminated_message);
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_SERVER_H
|
||||
#define __WEECHAT_IRC_SERVER_H 1
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
#include "irc-channel.h"
|
||||
#include "../../core/hook.h"
|
||||
#include "../../gui/gui.h"
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 256
|
||||
#endif
|
||||
|
||||
#define IRC_SERVER_DEFAULT_PORT 6667
|
||||
#define IRC_SERVER_DEFAULT_PREFIXES_LIST "@%+~&!-"
|
||||
|
||||
#define irc_server_sendf_queued(server, fmt, argz...) \
|
||||
if (server) \
|
||||
{ \
|
||||
server->queue_msg = 1; \
|
||||
irc_server_sendf (server, fmt, ##argz); \
|
||||
server->queue_msg = 0; \
|
||||
}
|
||||
|
||||
/* output queue of messages to server (for sending slowly to server) */
|
||||
|
||||
typedef struct t_irc_outqueue t_irc_outqueue;
|
||||
|
||||
struct t_irc_outqueue
|
||||
{
|
||||
char *message_before_mod; /* message before any modifier */
|
||||
char *message_after_mod; /* message after modifier(s) */
|
||||
int modified; /* message was modified by modifier(s) */
|
||||
t_irc_outqueue *next_outqueue; /* pointer to next message in queue */
|
||||
t_irc_outqueue *prev_outqueue; /* pointer to previous message in queue */
|
||||
};
|
||||
|
||||
typedef struct t_irc_server t_irc_server;
|
||||
|
||||
struct t_irc_server
|
||||
{
|
||||
/* user choices */
|
||||
char *name; /* internal name of server */
|
||||
int autoconnect; /* = 1 if auto connect at startup */
|
||||
int autoreconnect; /* = 1 if auto reco when disconnected */
|
||||
int autoreconnect_delay; /* delay before trying again reconnect */
|
||||
int temp_server; /* server is temporary (not saved!) */
|
||||
char *address; /* address of server (IP or name) */
|
||||
int port; /* port for server (6667 by default) */
|
||||
int ipv6; /* use IPv6 protocol */
|
||||
int ssl; /* SSL protocol */
|
||||
char *password; /* password for server */
|
||||
char *nick1; /* first nickname for the server */
|
||||
char *nick2; /* alternate nickname */
|
||||
char *nick3; /* 2nd alternate nickname */
|
||||
char *username; /* user name */
|
||||
char *realname; /* real name */
|
||||
char *hostname; /* custom hostname */
|
||||
char *command; /* command to run once connected */
|
||||
int command_delay; /* delay after execution of command */
|
||||
char *autojoin; /* channels to automatically join */
|
||||
int autorejoin; /* auto rejoin channels when kicked */
|
||||
char *notify_levels; /* channels notify levels */
|
||||
|
||||
/* internal vars */
|
||||
pid_t child_pid; /* pid of child process (connecting) */
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
int sock; /* socket for server (IPv4 or IPv6) */
|
||||
t_weechat_hook *hook_fd; /* hook for server socket or child pipe */
|
||||
int is_connected; /* 1 if WeeChat is connected to server */
|
||||
int ssl_connected; /* = 1 if connected with SSL */
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */
|
||||
#endif
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
char *nick; /* current nickname */
|
||||
char *nick_modes; /* nick modes */
|
||||
char *prefix; /* nick prefix allowed (from msg 005) */
|
||||
time_t reconnect_start; /* this time + delay = reconnect time */
|
||||
time_t command_time; /* this time + command_delay = time to */
|
||||
/* autojoin channels */
|
||||
int reconnect_join; /* 1 if channels opened to rejoin */
|
||||
int disable_autojoin; /* 1 if user asked to not autojoin chans */
|
||||
int is_away; /* 1 is user is marked as away */
|
||||
char *away_message; /* away message, NULL if not away */
|
||||
time_t away_time; /* time() when user marking as away */
|
||||
int lag; /* lag (in milliseconds) */
|
||||
struct timeval lag_check_time; /* last time lag was checked (ping sent) */
|
||||
time_t lag_next_check; /* time for next check */
|
||||
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
|
||||
int queue_msg; /* set to 1 when queue (out) is required */
|
||||
time_t last_user_message; /* time of last user message (anti flood)*/
|
||||
t_irc_outqueue *outqueue; /* queue for outgoing user messages */
|
||||
t_irc_outqueue *last_outqueue; /* last outgoing user message */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for server */
|
||||
t_irc_channel *channels; /* opened channels on server */
|
||||
t_irc_channel *last_channel; /* last opened channal on server */
|
||||
t_irc_server *prev_server; /* link to previous server */
|
||||
t_irc_server *next_server; /* link to next server */
|
||||
};
|
||||
|
||||
/* IRC messages */
|
||||
|
||||
typedef struct t_irc_message t_irc_message;
|
||||
|
||||
struct t_irc_message
|
||||
{
|
||||
t_irc_server *server; /* server pointer for received msg */
|
||||
char *data; /* message content */
|
||||
t_irc_message *next_message; /* link to next message */
|
||||
};
|
||||
|
||||
extern t_irc_server *irc_servers;
|
||||
#ifdef HAVE_GNUTLS
|
||||
extern const int gnutls_cert_type_prio[];
|
||||
extern const int gnutls_prot_prio[];
|
||||
#endif
|
||||
extern t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
|
||||
|
||||
#endif /* irc-server.h */
|
||||
+222
-519
@@ -20,339 +20,250 @@
|
||||
#ifndef __WEECHAT_IRC_H
|
||||
#define __WEECHAT_IRC_H 1
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "irc-buffer.h"
|
||||
#include "irc-color.h"
|
||||
#include "irc-command.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-server.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-dcc.h"
|
||||
#include "irc-protocol.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <regex.h>
|
||||
#include "../protocol.h"
|
||||
|
||||
#ifdef HAVE_GNUTLS
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
#define _PROTOCOL_NAME "irc"
|
||||
#define _PROTOCOL_VERSION "0.1"
|
||||
#define _PROTOCOL_DESC "IRC (Internet Relay Chat)"
|
||||
|
||||
#include "../../gui/gui.h"
|
||||
extern t_weechat_protocol *irc_protocol;
|
||||
extern t_weechat_hook *irc_hook_timer, *irc_hook_timer_check_away;
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 256
|
||||
#endif
|
||||
/* buffer functions (irc-buffer.c) */
|
||||
|
||||
#define IRC_DEFAULT_PORT 6667
|
||||
#define IRC_DEFAULT_PREFIXES_LIST "@%+~&!-"
|
||||
extern t_irc_buffer_data *irc_buffer_data_create (t_irc_server *);
|
||||
extern void irc_buffer_data_free (t_gui_buffer *);
|
||||
extern void irc_buffer_merge_servers (t_gui_window *);
|
||||
extern void irc_buffer_split_server (t_gui_window *);
|
||||
|
||||
/* nick types */
|
||||
/* channel functions (irc-channel.c) */
|
||||
|
||||
#define IRC_NICK_CHANOWNER 1
|
||||
#define IRC_NICK_CHANADMIN 2
|
||||
#define IRC_NICK_OP 4
|
||||
#define IRC_NICK_HALFOP 8
|
||||
#define IRC_NICK_VOICE 16
|
||||
#define IRC_NICK_AWAY 32
|
||||
#define IRC_NICK_CHANADMIN2 64
|
||||
#define IRC_NICK_CHANUSER 128
|
||||
#define IRC_NICK_SET_FLAG(nick, set, flag) \
|
||||
if (set) \
|
||||
nick->flags |= flag; \
|
||||
else \
|
||||
nick->flags &= 0xFFFF - flag;
|
||||
extern t_irc_channel *irc_channel_new (t_irc_server *, int, char *, int);
|
||||
extern void irc_channel_free (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_free_all (t_irc_server *);
|
||||
extern t_irc_channel *irc_channel_search (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any_without_buffer (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_dcc (t_irc_server *, char *);
|
||||
extern int irc_channel_is_channel (char *);
|
||||
extern void irc_channel_remove_away (t_irc_channel *);
|
||||
extern void irc_channel_check_away (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_set_away (t_irc_channel *, char *, int);
|
||||
extern int irc_channel_create_dcc (t_irc_dcc *);
|
||||
extern int irc_channel_get_notify_level (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_add_nick_speaking (t_irc_channel *, char *);
|
||||
extern void irc_channel_print_log (t_irc_channel *);
|
||||
|
||||
#define irc_server_sendf_queued(server, fmt, argz...) \
|
||||
if (server) \
|
||||
{ \
|
||||
server->queue_msg = 1; \
|
||||
irc_server_sendf (server, fmt, ##argz); \
|
||||
server->queue_msg = 0; \
|
||||
}
|
||||
/* color functions (irc-color.c) */
|
||||
|
||||
typedef struct t_irc_nick t_irc_nick;
|
||||
extern unsigned char *irc_color_decode (unsigned char *, int, int);
|
||||
extern unsigned char *irc_color_decode_for_user_entry (unsigned char *);
|
||||
extern unsigned char *irc_color_encode (unsigned char *, int);
|
||||
|
||||
struct t_irc_nick
|
||||
{
|
||||
char *nick; /* nickname */
|
||||
char *host; /* full hostname */
|
||||
int flags; /* chanowner/chanadmin (unrealircd), */
|
||||
/* op, halfop, voice, away */
|
||||
int color; /* color for nickname in chat window */
|
||||
t_irc_nick *prev_nick; /* link to previous nick on the channel */
|
||||
t_irc_nick *next_nick; /* link to next nick on the channel */
|
||||
};
|
||||
/* IRC commands (irc-command.c) */
|
||||
|
||||
#define IRC_CHANNEL_PREFIX "#&+!"
|
||||
extern int irc_cmd_admin (t_gui_window *, char *, int, char **);
|
||||
extern void irc_cmd_mode_nicks (t_irc_server *, char *, char *, char *, int, char **);
|
||||
extern int irc_cmd_ame (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_amsg (t_gui_window *, char *, int, char **);
|
||||
extern void irc_cmd_away_server (t_irc_server *, char *);
|
||||
extern int irc_cmd_away (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ctcp (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_cycle (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_dehalfop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_deop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_devoice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_die (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_halfop (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_info (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_invite (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ison (t_gui_window *, char *, int, char **);
|
||||
extern void irc_cmd_join_server (t_irc_server *, char *);
|
||||
extern int irc_cmd_join (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kick (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kickban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_kill (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_links (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_list (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_lusers (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_me (t_gui_window *, char *, int, char **);
|
||||
extern void irc_cmd_mode_server (t_irc_server *, char *);
|
||||
extern int irc_cmd_mode (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_motd (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_msg (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_names (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_nick (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_notice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_op (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_oper (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_part (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_ping (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_pong (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_query (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_quit (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_quote (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_rehash (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_restart (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_service (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_servlist (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_squery (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_squit (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_stats (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_summon (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_time (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_topic (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_trace (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_unban (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_userhost (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_users (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_version (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_voice (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_wallops (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_who (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_whois (t_gui_window *, char *, int, char **);
|
||||
extern int irc_cmd_whowas (t_gui_window *, char *, int, char **);
|
||||
|
||||
/* channel types */
|
||||
#define IRC_CHANNEL_TYPE_UNKNOWN -1
|
||||
#define IRC_CHANNEL_TYPE_CHANNEL 0
|
||||
#define IRC_CHANNEL_TYPE_PRIVATE 1
|
||||
#define IRC_CHANNEL_TYPE_DCC_CHAT 2
|
||||
/* config functions (irc-config.c) */
|
||||
|
||||
#define IRC_CHANNEL_NICKS_SPEAKING_LIMIT 32
|
||||
extern void irc_config_create_dirs ();
|
||||
extern void *irc_config_get_server_option_ptr (t_irc_server *, char *);
|
||||
extern int irc_config_set_server_value (t_irc_server *, char *, char *);
|
||||
extern int irc_config_read ();
|
||||
extern int irc_config_write ();
|
||||
|
||||
typedef struct t_irc_channel t_irc_channel;
|
||||
/* DCC functions (irc-dcc.c) */
|
||||
|
||||
struct t_irc_channel
|
||||
{
|
||||
int type; /* channel type */
|
||||
void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */
|
||||
char *name; /* name of channel (exemple: "#abc") */
|
||||
char *topic; /* topic of channel (host for private) */
|
||||
char *modes; /* channel modes */
|
||||
int limit; /* user limit (0 is limit not set) */
|
||||
char *key; /* channel key (NULL if no key is set) */
|
||||
int nicks_count; /* # nicks on channel (0 if dcc/pv) */
|
||||
int checking_away; /* = 1 if checking away with WHO cmd */
|
||||
char *away_message; /* to display away only once in private */
|
||||
int cycle; /* currently cycling (/part then /join) */
|
||||
int close; /* close request (/buffer close) */
|
||||
int display_creation_date; /* 1 if creation date should be displayed */
|
||||
int nick_completion_reset; /* 1 if nick completion should be rebuilt */
|
||||
/* there was some join/part on channel */
|
||||
t_irc_nick *nicks; /* nicks on the channel */
|
||||
t_irc_nick *last_nick; /* last nick on the channel */
|
||||
t_weelist *nicks_speaking; /* nicks speaking (for smart completion) */
|
||||
t_weelist *last_nick_speaking; /* last nick speaking */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for channel */
|
||||
t_irc_channel *prev_channel; /* link to previous channel */
|
||||
t_irc_channel *next_channel; /* link to next channel */
|
||||
};
|
||||
extern void irc_dcc_redraw (int);
|
||||
extern void irc_dcc_free (t_irc_dcc *);
|
||||
extern void irc_dcc_close (t_irc_dcc *, int);
|
||||
extern void irc_dcc_chat_remove_channel (t_irc_channel *);
|
||||
extern void irc_dcc_accept (t_irc_dcc *);
|
||||
extern void irc_dcc_accept_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern void irc_dcc_start_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern t_irc_dcc *irc_dcc_alloc ();
|
||||
extern t_irc_dcc *irc_dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
|
||||
char *, char *, unsigned long);
|
||||
extern void irc_dcc_send_request (t_irc_server *, int, char *, char *);
|
||||
extern void irc_dcc_chat_sendf (t_irc_dcc *, char *, ...);
|
||||
extern void irc_dcc_file_send_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_file_recv_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_handle ();
|
||||
extern void irc_dcc_end ();
|
||||
extern void irc_dcc_print_log ();
|
||||
|
||||
/* server types */
|
||||
/* display functions (irc-diplay.c) */
|
||||
|
||||
typedef struct t_irc_outqueue t_irc_outqueue;
|
||||
extern void irc_display_hide_password (char *, int);
|
||||
extern void irc_display_nick (t_gui_buffer *, t_irc_nick *, char *, int,
|
||||
int, char *, int);
|
||||
extern void irc_display_away (t_irc_server *, char *, char *);
|
||||
extern void irc_display_mode (t_gui_buffer *, char *, char *,
|
||||
char, char *, char *, char *, char *);
|
||||
extern void irc_display_server (t_irc_server *ptr_server, int);
|
||||
|
||||
struct t_irc_outqueue
|
||||
{
|
||||
char *message_before_mod; /* message before any modifier */
|
||||
char *message_after_mod; /* message after modifier(s) */
|
||||
int modified; /* message was modified by modifier(s) */
|
||||
t_irc_outqueue *next_outqueue; /* pointer to next message in queue */
|
||||
t_irc_outqueue *prev_outqueue; /* pointer to previous message in queue */
|
||||
};
|
||||
/* input functions (irc-input.c) */
|
||||
|
||||
typedef struct t_irc_server t_irc_server;
|
||||
extern int irc_input_data (t_gui_window *, char *);
|
||||
|
||||
struct t_irc_server
|
||||
{
|
||||
/* user choices */
|
||||
char *name; /* internal name of server */
|
||||
int autoconnect; /* = 1 if auto connect at startup */
|
||||
int autoreconnect; /* = 1 if auto reco when disconnected */
|
||||
int autoreconnect_delay; /* delay before trying again reconnect */
|
||||
int temp_server; /* server is temporary (will not be saved)*/
|
||||
char *address; /* address of server (IP or name) */
|
||||
int port; /* port for server (6667 by default) */
|
||||
int ipv6; /* use IPv6 protocol */
|
||||
int ssl; /* SSL protocol */
|
||||
char *password; /* password for server */
|
||||
char *nick1; /* first nickname for the server */
|
||||
char *nick2; /* alternate nickname */
|
||||
char *nick3; /* 2nd alternate nickname */
|
||||
char *username; /* user name */
|
||||
char *realname; /* real name */
|
||||
char *hostname; /* custom hostname */
|
||||
char *command; /* command to run once connected */
|
||||
int command_delay; /* delay after execution of command */
|
||||
char *autojoin; /* channels to automatically join */
|
||||
int autorejoin; /* auto rejoin channels when kicked */
|
||||
char *notify_levels; /* channels notify levels */
|
||||
|
||||
/* internal vars */
|
||||
pid_t child_pid; /* pid of child process (connecting) */
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
int sock; /* socket for server (IPv4 or IPv6) */
|
||||
int is_connected; /* 1 if WeeChat is connected to server */
|
||||
int ssl_connected; /* = 1 if connected with SSL */
|
||||
#ifdef HAVE_GNUTLS
|
||||
gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */
|
||||
#endif
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
char *nick; /* current nickname */
|
||||
char *nick_modes; /* nick modes */
|
||||
char *prefix; /* nick prefix allowed (from msg 005) */
|
||||
time_t reconnect_start; /* this time + delay = reconnect time */
|
||||
time_t command_time; /* this time + command_delay = time to */
|
||||
/* autojoin channels */
|
||||
int reconnect_join; /* 1 if channels opened to rejoin */
|
||||
int disable_autojoin; /* 1 if user asked to not autojoin chans */
|
||||
int is_away; /* 1 is user is marked as away */
|
||||
char *away_message; /* away message, NULL if not away */
|
||||
time_t away_time; /* time() when user marking as away */
|
||||
int lag; /* lag (in milliseconds) */
|
||||
struct timeval lag_check_time; /* last time lag was checked (ping sent) */
|
||||
time_t lag_next_check; /* time for next check */
|
||||
regex_t *cmd_list_regexp; /* compiled Regular Expression for /list */
|
||||
int queue_msg; /* set to 1 when queue (out) is required */
|
||||
time_t last_user_message; /* time of last user message (anti flood) */
|
||||
t_irc_outqueue *outqueue; /* queue for outgoing user messages */
|
||||
t_irc_outqueue *last_outqueue; /* last outgoing user message */
|
||||
t_gui_buffer *buffer; /* GUI buffer allocated for server */
|
||||
t_gui_buffer *saved_buffer; /* channel before jumping to next server */
|
||||
t_irc_channel *channels; /* opened channels on server */
|
||||
t_irc_channel *last_channel; /* last opened channal on server */
|
||||
t_irc_server *prev_server; /* link to previous server */
|
||||
t_irc_server *next_server; /* link to next server */
|
||||
};
|
||||
/* log functions (irc-log.c) */
|
||||
extern char *irc_log_get_filename (char *, char *, int);
|
||||
|
||||
/* irc commands */
|
||||
/* mode functions (irc-mode.c) */
|
||||
|
||||
typedef int (t_irc_recv_func)(t_irc_server *, char *, char *, char *);
|
||||
extern void irc_mode_channel_set (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_mode_user_set (t_irc_server *, char *);
|
||||
extern int irc_mode_nick_prefix_allowed (t_irc_server *, char);
|
||||
|
||||
typedef struct t_irc_command t_irc_command;
|
||||
/* nick functions (irc-nick.c) */
|
||||
|
||||
struct t_irc_command
|
||||
{
|
||||
char *command_name; /* IRC command name */
|
||||
char *command_description; /* command description (for /help) */
|
||||
char *arguments; /* command arguments (for /help) */
|
||||
char *arguments_description; /* arguments description (for /help) */
|
||||
char *completion_template; /* template for completion */
|
||||
/* NULL=no completion, ""=default (nick) */
|
||||
int min_arg, max_arg; /* min & max number of arguments */
|
||||
int conversion; /* = 1 if cmd args are converted (charset */
|
||||
/* and color) before sending to server */
|
||||
int needs_connection; /* = 1 if cmd needs server connection */
|
||||
int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **);
|
||||
/* function called when user enters cmd */
|
||||
int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *);
|
||||
/* function called when user enters cmd */
|
||||
t_irc_recv_func *recv_function; /* function called when cmd is received */
|
||||
};
|
||||
extern int irc_nick_find_color (t_irc_nick *);
|
||||
extern void irc_nick_get_gui_infos (t_irc_nick *, int *, char *, int *);
|
||||
extern t_irc_nick *irc_nick_new (t_irc_server *, t_irc_channel *, char *,
|
||||
int, int, int, int, int, int, int);
|
||||
extern void irc_nick_change (t_irc_server *, t_irc_channel *, t_irc_nick *, char *);
|
||||
extern void irc_nick_free (t_irc_channel *, t_irc_nick *);
|
||||
extern void irc_nick_free_all (t_irc_channel *);
|
||||
extern t_irc_nick *irc_nick_search (t_irc_channel *, char *);
|
||||
extern void irc_nick_count (t_irc_channel *, int *, int *, int *, int *, int *);
|
||||
extern void irc_nick_set_away (t_irc_channel *, t_irc_nick *, int);
|
||||
extern void irc_nick_print_log (t_irc_nick *);
|
||||
|
||||
/* irc messages */
|
||||
/* IRC protocol (irc-protocol.c) */
|
||||
|
||||
typedef struct t_irc_message t_irc_message;
|
||||
|
||||
struct t_irc_message
|
||||
{
|
||||
t_irc_server *server; /* server pointer for received msg */
|
||||
char *data; /* message content */
|
||||
t_irc_message *next_message; /* link to next message */
|
||||
};
|
||||
|
||||
/* DCC types */
|
||||
|
||||
#define IRC_DCC_CHAT_RECV 0 /* receiving DCC chat */
|
||||
#define IRC_DCC_CHAT_SEND 1 /* sending DCC chat */
|
||||
#define IRC_DCC_FILE_RECV 2 /* incoming DCC file */
|
||||
#define IRC_DCC_FILE_SEND 3 /* sending DCC file */
|
||||
|
||||
/* DCC status */
|
||||
|
||||
#define IRC_DCC_WAITING 0 /* waiting for host answer */
|
||||
#define IRC_DCC_CONNECTING 1 /* connecting to host */
|
||||
#define IRC_DCC_ACTIVE 2 /* sending/receiving data */
|
||||
#define IRC_DCC_DONE 3 /* transfer done */
|
||||
#define IRC_DCC_FAILED 4 /* DCC failed */
|
||||
#define IRC_DCC_ABORTED 5 /* DCC aborted by user */
|
||||
|
||||
/* DCC blocksize (for file) */
|
||||
|
||||
#define IRC_DCC_MIN_BLOCKSIZE 1024 /* min DCC block size when sending file */
|
||||
#define IRC_DCC_MAX_BLOCKSIZE 102400 /* max DCC block size when sending file */
|
||||
|
||||
/* DCC errors (for file) */
|
||||
|
||||
#define IRC_DCC_NO_ERROR 0 /* no error to report, all ok! */
|
||||
#define IRC_DCC_ERROR_READ_LOCAL 1 /* unable to read local file */
|
||||
#define IRC_DCC_ERROR_SEND_BLOCK 2 /* unable to send block to receiver */
|
||||
#define IRC_DCC_ERROR_READ_ACK 3 /* unable to read ACK from receiver */
|
||||
#define IRC_DCC_ERROR_CONNECT_SENDER 4 /* unable to connect to sender */
|
||||
#define IRC_DCC_ERROR_RECV_BLOCK 5 /* unable to recv block from sender */
|
||||
#define IRC_DCC_ERROR_WRITE_LOCAL 6 /* unable to write to local file */
|
||||
|
||||
/* DCC macros for type */
|
||||
|
||||
#define IRC_DCC_IS_CHAT(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_CHAT_SEND))
|
||||
#define IRC_DCC_IS_FILE(type) ((type == IRC_DCC_FILE_RECV) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
#define IRC_DCC_IS_RECV(type) ((type == IRC_DCC_CHAT_RECV) || \
|
||||
(type == IRC_DCC_FILE_RECV))
|
||||
#define IRC_DCC_IS_SEND(type) ((type == IRC_DCC_CHAT_SEND) || \
|
||||
(type == IRC_DCC_FILE_SEND))
|
||||
|
||||
/* DCC macro for status */
|
||||
|
||||
#define IRC_DCC_ENDED(status) ((status == IRC_DCC_DONE) || \
|
||||
(status == IRC_DCC_FAILED) || \
|
||||
(status == IRC_DCC_ABORTED))
|
||||
|
||||
typedef struct t_irc_dcc t_irc_dcc;
|
||||
|
||||
struct t_irc_dcc
|
||||
{
|
||||
t_irc_server *server; /* irc server */
|
||||
t_irc_channel *channel; /* irc channel (for DCC chat only) */
|
||||
int type; /* DCC type (file/chat, send/receive) */
|
||||
int status; /* DCC status (waiting, sending, ..) */
|
||||
time_t start_time; /* the time when DCC started */
|
||||
time_t start_transfer; /* the time when DCC transfer started */
|
||||
unsigned long addr; /* IP address */
|
||||
int port; /* port */
|
||||
char *nick; /* remote nick */
|
||||
int sock; /* socket for connection */
|
||||
pid_t child_pid; /* pid of child process (sending/recving) */
|
||||
int child_read; /* to read into child pipe */
|
||||
int child_write; /* to write into child pipe */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
int fast_send; /* fase send for files: does not wait ACK */
|
||||
int file; /* local file (for reading or writing) */
|
||||
char *filename; /* filename (given by sender) */
|
||||
char *local_filename; /* local filename (with path) */
|
||||
int filename_suffix; /* suffix (.1 for ex) if renaming file */
|
||||
int blocksize; /* block size for sending file */
|
||||
unsigned long size; /* file size */
|
||||
unsigned long pos; /* number of bytes received/sent */
|
||||
unsigned long ack; /* number of bytes received OK */
|
||||
unsigned long start_resume; /* start of resume (in bytes) */
|
||||
time_t last_check_time; /* last time we looked at bytes sent/recv */
|
||||
unsigned long last_check_pos; /* bytes sent/recv at last check */
|
||||
time_t last_activity; /* time of last byte received/sent */
|
||||
unsigned long bytes_per_sec; /* bytes per second */
|
||||
unsigned long eta; /* estimated time of arrival */
|
||||
t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */
|
||||
t_irc_dcc *next_dcc; /* link to next dcc file/chat */
|
||||
};
|
||||
|
||||
/* ignore types */
|
||||
|
||||
/* pre-defined ignore types, all other types are made with IRC commands */
|
||||
/* for example: part join quit notice invite ... */
|
||||
|
||||
#define IRC_IGNORE_ACTION "action"
|
||||
#define IRC_IGNORE_CTCP "ctcp"
|
||||
#define IRC_IGNORE_DCC "dcc"
|
||||
#define IRC_IGNORE_PRIVATE "pv"
|
||||
|
||||
typedef struct t_irc_ignore t_irc_ignore;
|
||||
|
||||
struct t_irc_ignore
|
||||
{
|
||||
char *mask; /* nickname or mask */
|
||||
char *type; /* type of ignore */
|
||||
char *channel_name; /* name of channel, "*" == all */
|
||||
char *server_name; /* name of server, "*" == all */
|
||||
t_irc_ignore *prev_ignore; /* pointer to previous ignore */
|
||||
t_irc_ignore *next_ignore; /* pointer to next ignore */
|
||||
};
|
||||
|
||||
/* variables */
|
||||
|
||||
extern t_irc_command irc_commands[];
|
||||
extern t_irc_server *irc_servers;
|
||||
#ifdef HAVE_GNUTLS
|
||||
extern const int gnutls_cert_type_prio[];
|
||||
extern const int gnutls_prot_prio[];
|
||||
#endif
|
||||
extern t_irc_message *irc_recv_msgq, *irc_msgq_last_msg;
|
||||
extern int irc_check_away;
|
||||
extern t_irc_dcc *irc_dcc_list;
|
||||
extern t_irc_dcc *irc_last_dcc;
|
||||
extern char *irc_dcc_status_string[6];
|
||||
extern t_irc_ignore *irc_ignore;
|
||||
extern t_irc_ignore *irc_last_ignore;
|
||||
extern int irc_protocol_is_highlight (char *, char *);
|
||||
extern int irc_protocol_recv_command (t_irc_server *, char *, char *, char *, char *);
|
||||
extern int irc_protocol_cmd_error (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_invite (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_join (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_kick (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_kill (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_mode (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_nick (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_notice (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_part (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_ping (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_pong (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_privmsg (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_quit (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_server_mode_reason (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_server_msg (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_server_reply (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_topic (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_wallops (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_001 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_005 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_221 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_301 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_302 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_303 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_305 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_306 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_whois_nick_msg (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_310 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_311 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_312 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_314 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_315 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_317 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_319 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_321 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_322 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_323 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_324 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_327 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_329 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_331 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_332 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_333 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_338 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_341 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_344 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_345 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_348 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_349 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_351 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_352 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_353 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_365 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_366 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_367 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_368 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_432 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_433 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_438 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
extern int irc_protocol_cmd_671 (t_irc_server *, char *, char *, char *, char *, int, int);
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
@@ -372,8 +283,10 @@ extern int irc_server_send (t_irc_server *, char *, int);
|
||||
extern void irc_server_outqueue_send (t_irc_server *);
|
||||
extern void irc_server_sendf (t_irc_server *, char *, ...);
|
||||
extern void irc_server_parse_message (char *, char **, char **, char **);
|
||||
extern void irc_server_recv (t_irc_server *);
|
||||
extern void irc_server_child_read (t_irc_server *);
|
||||
extern void irc_server_recv (void *);
|
||||
extern void irc_server_timer (void *);
|
||||
extern void irc_server_timer_check_away (void *);
|
||||
extern void irc_server_child_read (void *);
|
||||
extern void irc_server_convbase64_8x3_to_6x4 (char *, char*);
|
||||
extern void irc_server_base64encode (char *, char *);
|
||||
extern int irc_server_pass_httpproxy (int, char*, int);
|
||||
@@ -400,214 +313,4 @@ extern int irc_server_get_default_notify_level (t_irc_server *);
|
||||
extern void irc_server_set_default_notify_level (t_irc_server *, int);
|
||||
extern void irc_server_print_log (t_irc_server *);
|
||||
|
||||
/* channel functions (irc-channel.c) */
|
||||
|
||||
extern t_irc_channel *irc_channel_new (t_irc_server *, int, char *);
|
||||
extern void irc_channel_free (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_free_all (t_irc_server *);
|
||||
extern t_irc_channel *irc_channel_search (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_any_without_buffer (t_irc_server *, char *);
|
||||
extern t_irc_channel *irc_channel_search_dcc (t_irc_server *, char *);
|
||||
extern int irc_channel_is_channel (char *);
|
||||
extern void irc_channel_remove_away (t_irc_channel *);
|
||||
extern void irc_channel_check_away (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_set_away (t_irc_channel *, char *, int);
|
||||
extern int irc_channel_create_dcc (t_irc_dcc *);
|
||||
extern int irc_channel_get_notify_level (t_irc_server *, t_irc_channel *);
|
||||
extern void irc_channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
|
||||
extern void irc_channel_add_nick_speaking (t_irc_channel *, char *);
|
||||
extern void irc_channel_print_log (t_irc_channel *);
|
||||
|
||||
/* nick functions (irc-nick.c) */
|
||||
|
||||
extern int irc_nick_find_color (t_irc_nick *);
|
||||
extern t_irc_nick *irc_nick_new (t_irc_server *, t_irc_channel *, char *,
|
||||
int, int, int, int, int, int, int);
|
||||
extern void irc_nick_resort (t_irc_channel *, t_irc_nick *);
|
||||
extern void irc_nick_change (t_irc_channel *, t_irc_nick *, char *);
|
||||
extern void irc_nick_free (t_irc_channel *, t_irc_nick *);
|
||||
extern void irc_nick_free_all (t_irc_channel *);
|
||||
extern t_irc_nick *irc_nick_search (t_irc_channel *, char *);
|
||||
extern void irc_nick_count (t_irc_channel *, int *, int *, int *, int *, int *);
|
||||
extern int irc_nick_get_max_length (t_irc_channel *);
|
||||
extern void irc_nick_set_away (t_irc_channel *, t_irc_nick *, int);
|
||||
extern void irc_nick_print_log (t_irc_nick *);
|
||||
|
||||
/* mode functions (irc-mode.c) */
|
||||
|
||||
extern void irc_mode_channel_set (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_mode_user_set (t_irc_server *, char *);
|
||||
extern int irc_mode_nick_prefix_allowed (t_irc_server *, char);
|
||||
|
||||
/* DCC functions (irc-dcc.c) */
|
||||
|
||||
extern void irc_dcc_redraw (int);
|
||||
extern void irc_dcc_free (t_irc_dcc *);
|
||||
extern void irc_dcc_close (t_irc_dcc *, int);
|
||||
extern void irc_dcc_chat_remove_channel (t_irc_channel *);
|
||||
extern void irc_dcc_accept (t_irc_dcc *);
|
||||
extern void irc_dcc_accept_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern void irc_dcc_start_resume (t_irc_server *, char *, int, unsigned long);
|
||||
extern t_irc_dcc *irc_dcc_alloc ();
|
||||
extern t_irc_dcc *irc_dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
|
||||
char *, char *, unsigned long);
|
||||
extern void irc_dcc_send_request (t_irc_server *, int, char *, char *);
|
||||
extern void irc_dcc_chat_sendf (t_irc_dcc *, char *, ...);
|
||||
extern void irc_dcc_file_send_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_file_recv_fork (t_irc_dcc *);
|
||||
extern void irc_dcc_handle ();
|
||||
extern void irc_dcc_end ();
|
||||
extern void irc_dcc_print_log ();
|
||||
|
||||
/* IRC display (irc-diplay.c) */
|
||||
|
||||
extern void irc_display_hide_password (char *, int);
|
||||
extern void irc_display_prefix (t_irc_server *, t_gui_buffer *, char *);
|
||||
extern void irc_display_nick (t_gui_buffer *, t_irc_nick *, char *, int,
|
||||
int, int, int);
|
||||
extern void irc_display_away (t_irc_server *, char *, char *);
|
||||
extern void irc_display_mode (t_irc_server *, t_gui_buffer *, char *, char *,
|
||||
char, char *, char *, char *, char *);
|
||||
extern void irc_display_server (t_irc_server *ptr_server, int);
|
||||
|
||||
/* IRC commands issued by user (irc-send.c) */
|
||||
|
||||
extern void irc_send_login (t_irc_server *);
|
||||
extern int irc_send_cmd_admin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ame (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_amsg (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_away (t_irc_server *, char *);
|
||||
extern int irc_send_cmd_away (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ctcp (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_cycle (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_deop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_devoice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_die (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_halfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_info (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_invite (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_ison (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_join (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kick (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kickban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_kill (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_links (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_list (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_lusers (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_me (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_mode (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_mode_nicks (t_irc_server *, char *, char *, char *, int, char **);
|
||||
extern int irc_send_cmd_motd (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_msg (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_names (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_nick (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_notice (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_op (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_oper (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_part (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_ping (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_pong (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_query (t_irc_server *, t_irc_channel *, char *);
|
||||
extern void irc_send_quit_server (t_irc_server *, char *);
|
||||
extern int irc_send_cmd_quit (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_quote (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_rehash (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_restart (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_service (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_servlist (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_squery (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_squit (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_stats (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_summon (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_time (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_topic (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_trace (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_unban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_userhost (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_users (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_version (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_voice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_send_cmd_wallops (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_who (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_whois (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_send_cmd_whowas (t_irc_server *, t_irc_channel *, char *);
|
||||
|
||||
/* IRC commands executed when received from server (irc-recv.c) */
|
||||
|
||||
extern int irc_recv_is_highlight (char *, char *);
|
||||
extern int irc_recv_command (t_irc_server *, char *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_error (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_invite (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_join (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_kick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_kill (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_mode (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_nick (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_notice (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_part (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_ping (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_pong (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_privmsg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_quit (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_mode_reason (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_server_reply (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_topic (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_wallops (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_001 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_005 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_221 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_301 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_302 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_303 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_305 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_306 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_whois_nick_msg (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_310 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_311 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_312 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_314 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_315 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_317 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_319 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_321 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_322 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_323 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_324 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_327 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_329 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_331 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_332 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_333 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_338 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_341 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_344 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_345 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_348 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_349 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_351 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_352 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_353 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_365 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_366 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_367 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_368 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_432 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_433 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_438 (t_irc_server *, char *, char *, char *);
|
||||
extern int irc_recv_cmd_671 (t_irc_server *, char *, char *, char *);
|
||||
|
||||
/* ignore functions (irc-ignore.c) */
|
||||
|
||||
extern int irc_ignore_check (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *irc_ignore_add (char *, char *, char *, char *);
|
||||
extern t_irc_ignore *irc_ignore_add_from_config (char *);
|
||||
extern void irc_ignore_free_all ();
|
||||
extern int irc_ignore_search_free (char *, char *, char *, char *);
|
||||
extern int irc_ignore_search_free_by_number (int);
|
||||
extern void irc_ignore_print_log ();
|
||||
|
||||
#endif /* irc.h */
|
||||
|
||||
Reference in New Issue
Block a user