mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 08:13:14 +02:00
Fixed many crashes with DCC chat
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-04-12
|
||||
ChangeLog - 2006-04-15
|
||||
|
||||
Version 0.1.9 (under dev!):
|
||||
* fixed many crashes with DCC chat
|
||||
* added new option to customize input prompt
|
||||
* added nick modes
|
||||
* fixed commands 332, 333 (/topic now ok when channel is not opened)
|
||||
@@ -12,7 +13,6 @@ Version 0.1.9 (under dev!):
|
||||
* added hostnames associeted to nicks (available for /ban completion)
|
||||
* added "+p" mode for channels, fixed mode display in status bar
|
||||
* added nick alignment options
|
||||
* fixed crash when closing DCC chat buffer
|
||||
* fixed /names command: now displays result when not on a channel
|
||||
* fixed refresh bug (too many refresh) when terminal is resized
|
||||
* fixed nicklist display bugs when on top or bottom of chat window
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
* FlashCode, 2006-04-15
|
||||
|
||||
Important release notes for 0.1.9:
|
||||
|
||||
- please close all DCC chat buffers before using /upgrade command,
|
||||
otherwise you may experience problems with DCC chats.
|
||||
|
||||
* FlashCode, 2006-03-18
|
||||
|
||||
WeeChat 0.1.8 released.
|
||||
|
||||
@@ -58,15 +58,6 @@ leave and rejoin a channel
|
||||
channel: channel name for cycle
|
||||
part_message: part message (displayed to other users)
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [nickname [file]]</command>
|
||||
<programlisting>
|
||||
starts DCC (file or chat) or close chat
|
||||
|
||||
action: 'send' (file) or 'chat' or 'close' (chat)
|
||||
nickname: nickname to send file or chat
|
||||
file: filename (on local host)
|
||||
|
||||
</programlisting>
|
||||
<command>dehalfop [nickname [nickname]]</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -66,6 +66,15 @@ disconnect from a server
|
||||
|
||||
servername: server name to disconnect
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [nickname [file]]</command>
|
||||
<programlisting>
|
||||
starts DCC (file or chat) or close chat
|
||||
|
||||
action: 'send' (file) or 'chat' or 'close' (chat)
|
||||
nickname: nickname to send file or chat
|
||||
file: filename (on local host)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -58,15 +58,6 @@ quitter et rejoindre un canal
|
||||
canal: canal pour le cycle
|
||||
message_de_fin: message de fin (affiché aux autres utilisateurs)
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [pseudo [fichier]]</command>
|
||||
<programlisting>
|
||||
démarre le DCC (fichier ou discussion) ou ferme une discussion
|
||||
|
||||
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
|
||||
pseudo: pseudo pour envoyer le fichier ou discuter
|
||||
fichier: nom du fichier (sur la machine locale)
|
||||
|
||||
</programlisting>
|
||||
<command>dehalfop [pseudo [pseudo]]</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -66,6 +66,15 @@ se d
|
||||
|
||||
nom_serveur: nom du serveur pour se déconnecter
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [pseudo [fichier]]</command>
|
||||
<programlisting>
|
||||
démarre le DCC (fichier ou discussion) ou ferme une discussion
|
||||
|
||||
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
|
||||
pseudo: pseudo pour envoyer le fichier ou discuter
|
||||
fichier: nom du fichier (sur la machine locale)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<programlisting>
|
||||
|
||||
+561
-556
File diff suppressed because it is too large
Load Diff
+177
-49
@@ -86,6 +86,12 @@ t_weechat_command weechat_commands[] =
|
||||
N_("[servername]"),
|
||||
N_("servername: server name to disconnect"),
|
||||
"%S", 0, 1, weechat_cmd_disconnect, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat) or close chat"),
|
||||
N_("action [nickname [file]]"),
|
||||
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
|
||||
"nickname: nickname to send file or chat\n"
|
||||
" file: filename (on local host)"),
|
||||
"chat|send|close %n %f", 1, MAX_ARGS, NULL, weechat_cmd_dcc },
|
||||
{ "debug", N_("print debug messages"),
|
||||
N_("dump | windows"),
|
||||
N_(" dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)\n"
|
||||
@@ -902,6 +908,17 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
free (command);
|
||||
return 0;
|
||||
}
|
||||
if (channel && channel->dcc_chat)
|
||||
{
|
||||
irc_display_prefix (server, channel->buffer, PREFIX_ERROR);
|
||||
gui_printf (channel->buffer,
|
||||
_("%s command \"%s\" can not be "
|
||||
"executed on DCC CHAT buffer\n"),
|
||||
WEECHAT_ERROR,
|
||||
irc_commands[i].command_name);
|
||||
free (command);
|
||||
return 0;
|
||||
}
|
||||
if (irc_commands[i].cmd_function_args)
|
||||
return_code = (int) (irc_commands[i].cmd_function_args)
|
||||
(server, channel, argc, argv);
|
||||
@@ -942,7 +959,7 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
t_irc_nick *ptr_nick;
|
||||
int plugin_args_length;
|
||||
int plugin_args_length, text_sent;
|
||||
char *command_with_colors, *command_encoded, *command_with_colors2;
|
||||
char *plugin_args;
|
||||
|
||||
@@ -968,11 +985,22 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
|
||||
command_encoded = channel_iconv_encode (server, channel,
|
||||
(command_with_colors) ? command_with_colors : command);
|
||||
text_sent = 1;
|
||||
if (CHANNEL(buffer)->dcc_chat)
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
|
||||
"%s\r\n",
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : command));
|
||||
{
|
||||
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
|
||||
{
|
||||
irc_display_prefix (server, buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
|
||||
WEECHAT_ERROR);
|
||||
text_sent = 0;
|
||||
}
|
||||
else
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
|
||||
"%s\r\n",
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : command));
|
||||
}
|
||||
else
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(buffer)->name,
|
||||
@@ -981,25 +1009,14 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
|
||||
command_with_colors2 = (command_with_colors) ?
|
||||
(char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;
|
||||
|
||||
if (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
|
||||
if (text_sent)
|
||||
{
|
||||
irc_display_nick (buffer, NULL, server->nick,
|
||||
MSG_TYPE_NICK, 1, COLOR_WIN_NICK_SELF, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
(command_with_colors2) ?
|
||||
command_with_colors2 : command);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
|
||||
if (ptr_nick)
|
||||
if ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
irc_display_nick (buffer, ptr_nick, NULL,
|
||||
MSG_TYPE_NICK, 1, -1, 0);
|
||||
irc_display_nick (buffer, NULL, server->nick,
|
||||
MSG_TYPE_NICK, 1, COLOR_WIN_NICK_SELF, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
@@ -1009,10 +1026,25 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot find nick for sending message\n"),
|
||||
WEECHAT_ERROR);
|
||||
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (buffer, ptr_nick, NULL,
|
||||
MSG_TYPE_NICK, 1, -1, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
(command_with_colors2) ?
|
||||
command_with_colors2 : command);
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot find nick for sending message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,32 +1375,44 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SERVER(buffer))
|
||||
if (CHANNEL(buffer)
|
||||
&& (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
if (SERVER(buffer)->is_connected
|
||||
&& CHANNEL(buffer)
|
||||
&& CHANNEL(buffer)->nicks)
|
||||
{
|
||||
pos = strstr (arguments, "close ");
|
||||
if (pos)
|
||||
pos += 6;
|
||||
CHANNEL(buffer)->close = 1;
|
||||
irc_cmd_send_part (SERVER(buffer),
|
||||
CHANNEL(buffer),
|
||||
pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (SERVER(buffer),
|
||||
CHANNEL(buffer)->name);
|
||||
if (ptr_channel)
|
||||
channel_free (SERVER(buffer),
|
||||
ptr_channel);
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
ptr_channel = CHANNEL(buffer);
|
||||
gui_buffer_free (ptr_channel->buffer, 1);
|
||||
channel_free (SERVER(buffer), ptr_channel);
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_draw_buffer_input (buffer, 1);
|
||||
}
|
||||
else
|
||||
gui_buffer_free (buffer, 1);
|
||||
{
|
||||
if (SERVER(buffer))
|
||||
{
|
||||
if (SERVER(buffer)->is_connected
|
||||
&& CHANNEL(buffer)
|
||||
&& CHANNEL(buffer)->nicks)
|
||||
{
|
||||
pos = strstr (arguments, "close ");
|
||||
if (pos)
|
||||
pos += 6;
|
||||
CHANNEL(buffer)->close = 1;
|
||||
irc_cmd_send_part (SERVER(buffer),
|
||||
CHANNEL(buffer),
|
||||
pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search_any (SERVER(buffer),
|
||||
CHANNEL(buffer)->name);
|
||||
if (ptr_channel)
|
||||
channel_free (SERVER(buffer),
|
||||
ptr_channel);
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
}
|
||||
@@ -1847,6 +1891,90 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_dcc: DCC control (file or chat)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_dcc (t_irc_server *server, t_irc_channel *channel,
|
||||
char *arguments)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
char *pos_nick, *pos_file;
|
||||
|
||||
irc_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
/* DCC SEND file */
|
||||
if (strncasecmp (arguments, "send", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
pos_file = strchr (pos_nick, ' ');
|
||||
if (!pos_file)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
pos_file[0] = '\0';
|
||||
pos_file++;
|
||||
while (pos_file[0] == ' ')
|
||||
pos_file++;
|
||||
|
||||
dcc_send_request (server, DCC_FILE_SEND, pos_nick, pos_file);
|
||||
}
|
||||
/* DCC CHAT */
|
||||
else if (strncasecmp (arguments, "chat", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc chat");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
dcc_send_request (server, DCC_CHAT_SEND, pos_nick, NULL);
|
||||
}
|
||||
/* close DCC CHAT */
|
||||
else if (ascii_strcasecmp (arguments, "close") == 0)
|
||||
{
|
||||
if (BUFFER_IS_PRIVATE(buffer) &&
|
||||
CHANNEL(buffer)->dcc_chat)
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
}
|
||||
/* unknown DCC action */
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong arguments for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_debug_display_windows: display tree of windows
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,7 @@ extern int weechat_cmd_builtin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_dcc (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_debug (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_disconnect (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_help (t_irc_server *, t_irc_channel *, int, char **);
|
||||
|
||||
@@ -358,7 +358,8 @@ completion_list_add_channel_nicks (t_completion *completion)
|
||||
ptr_nick->nick);
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
@@ -406,7 +407,8 @@ completion_list_add_channel_nicks_hosts (t_completion *completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE))
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
@@ -998,7 +1000,8 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
|
||||
}
|
||||
|
||||
if (!completion->completion_list && completion->channel &&
|
||||
(((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
&& (completion->context == COMPLETION_NICK))
|
||||
{
|
||||
/* nick completion in private (only other nick and self) */
|
||||
@@ -1192,7 +1195,8 @@ completion_nick (t_completion *completion)
|
||||
if (!completion->channel)
|
||||
return;
|
||||
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
if (!(completion->completion_list))
|
||||
{
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ fifo_exec (char *text)
|
||||
}
|
||||
if (ptr_server && pos)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, pos + 1);
|
||||
ptr_channel = channel_search_any (ptr_server, pos + 1);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
|
||||
@@ -1208,7 +1208,7 @@ session_load_dcc (FILE *file)
|
||||
return 0;
|
||||
if (string && string[0])
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, string);
|
||||
ptr_channel = channel_search_any (ptr_server, string);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
session_crash (file, _("channel not found for DCC"));
|
||||
@@ -1399,7 +1399,7 @@ session_load_buffer (FILE *file)
|
||||
|
||||
if (channel_name)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, channel_name);
|
||||
ptr_channel = channel_search_any (ptr_server, channel_name);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
session_crash (file, _("channel not found for buffer"));
|
||||
|
||||
@@ -2041,7 +2041,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
}
|
||||
|
||||
/* infos about current buffer */
|
||||
/* infos about current server buffer */
|
||||
if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
@@ -2082,6 +2082,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* infos about current channel/pv buffer */
|
||||
if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
@@ -2093,8 +2095,12 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_CHANNEL);
|
||||
if ((!CHANNEL(ptr_win->buffer)->nicks)
|
||||
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE))
|
||||
if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE)
|
||||
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (!CHANNEL(ptr_win->buffer)->nicks))
|
||||
|| ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (CHANNEL(ptr_win->buffer)->dcc_chat)
|
||||
&& (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0)))
|
||||
wprintw (ptr_win->win_status, "(%s)",
|
||||
CHANNEL(ptr_win->buffer)->name);
|
||||
else
|
||||
@@ -2140,8 +2146,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
|
||||
/* display DCC if private is DCC CHAT */
|
||||
if ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
&& (CHANNEL(ptr_win->buffer)->dcc_chat))
|
||||
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
|
||||
@@ -487,7 +487,7 @@ gui_buffer_search (char *server, char *channel)
|
||||
{
|
||||
if (ptr_server)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, channel);
|
||||
ptr_channel = channel_search_any (ptr_server, channel);
|
||||
if (ptr_channel)
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
|
||||
+3
-1
@@ -133,7 +133,9 @@ enum t_weechat_color
|
||||
|
||||
#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer))
|
||||
#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL))
|
||||
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE))
|
||||
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \
|
||||
((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \
|
||||
|| (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT)))
|
||||
|
||||
#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer))
|
||||
|
||||
|
||||
+53
-26
@@ -53,7 +53,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
fprintf (stderr, _("%s cannot allocate new channel"), WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
@@ -143,6 +143,7 @@ channel_free_all (t_irc_server *server)
|
||||
|
||||
/*
|
||||
* channel_search: returns pointer on a channel with name
|
||||
* WARNING: DCC chat channels are not returned by this function
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
@@ -150,6 +151,28 @@ channel_search (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type != CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_search_any: returns pointer on a channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
channel_search_any (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
@@ -162,6 +185,28 @@ channel_search (t_irc_server *server, char *channel_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_search_dcc: returns pointer on a DCC chat channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
channel_search_dcc (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* string_is_channel: returns 1 if string is channel
|
||||
*/
|
||||
@@ -381,14 +426,16 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
ptr_channel = channel_search (ptr_dcc->server, ptr_dcc->nick);
|
||||
ptr_channel = channel_search_dcc (ptr_dcc->server, ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHANNEL_TYPE_PRIVATE,
|
||||
{
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHANNEL_TYPE_DCC_CHAT,
|
||||
ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
BUFFER_TYPE_STANDARD, 0);
|
||||
}
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
|
||||
@@ -400,26 +447,6 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_remove_dcc: remove a DCC CHAT
|
||||
*/
|
||||
|
||||
void
|
||||
channel_remove_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
for (ptr_channel = ptr_dcc->server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((t_irc_dcc *)(ptr_channel->dcc_chat) == ptr_dcc)
|
||||
{
|
||||
ptr_channel->dcc_chat = NULL;
|
||||
gui_redraw_buffer (ptr_channel->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_get_notify_level: get channel notify level
|
||||
*/
|
||||
|
||||
@@ -64,12 +64,6 @@ t_irc_command irc_commands[] =
|
||||
N_(" channel: channel name for cycle\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 1, NULL, irc_cmd_send_cycle, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat) or close chat"),
|
||||
N_("action [nickname [file]]"),
|
||||
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
|
||||
"nickname: nickname to send file or chat\n"
|
||||
" file: filename (on local host)"),
|
||||
"chat|send|close %n %f", 1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
{ "dehalfop", N_("removes half channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 1, irc_cmd_send_dehalfop, NULL, NULL },
|
||||
|
||||
+23
-14
@@ -283,10 +283,10 @@ dcc_connect (t_irc_dcc *ptr_dcc)
|
||||
else
|
||||
ptr_dcc->status = DCC_CONNECTING;
|
||||
|
||||
if (ptr_dcc->sock == -1)
|
||||
if (ptr_dcc->sock < 0)
|
||||
{
|
||||
ptr_dcc->sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (ptr_dcc->sock == -1)
|
||||
if (ptr_dcc->sock < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -344,6 +344,20 @@ dcc_free (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_dcc *new_dcc_list;
|
||||
|
||||
/* DCC CHAT with channel => remove channel
|
||||
(to prevent channel from becoming standard pv) */
|
||||
if (ptr_dcc->channel)
|
||||
{
|
||||
/* check if channel is used for another active DCC CHAT */
|
||||
if (!ptr_dcc->channel->dcc_chat
|
||||
|| (DCC_ENDED(((t_irc_dcc *)(ptr_dcc->channel->dcc_chat))->status)))
|
||||
{
|
||||
gui_buffer_free (ptr_dcc->channel->buffer, 1);
|
||||
channel_free (ptr_dcc->server, ptr_dcc->channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove DCC from list */
|
||||
if (ptr_dcc->prev_dcc)
|
||||
{
|
||||
(ptr_dcc->prev_dcc)->next_dcc = ptr_dcc->next_dcc;
|
||||
@@ -351,10 +365,10 @@ dcc_free (t_irc_dcc *ptr_dcc)
|
||||
}
|
||||
else
|
||||
new_dcc_list = ptr_dcc->next_dcc;
|
||||
|
||||
if (ptr_dcc->next_dcc)
|
||||
(ptr_dcc->next_dcc)->prev_dcc = ptr_dcc->prev_dcc;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (ptr_dcc->nick)
|
||||
free (ptr_dcc->nick);
|
||||
if (ptr_dcc->unterminated_message)
|
||||
@@ -444,20 +458,15 @@ dcc_close (t_irc_dcc *ptr_dcc, int status)
|
||||
}
|
||||
}
|
||||
|
||||
ptr_dcc->channel = NULL;
|
||||
|
||||
if (DCC_IS_CHAT(ptr_dcc->type))
|
||||
channel_remove_dcc (ptr_dcc);
|
||||
|
||||
if (DCC_IS_FILE(ptr_dcc->type))
|
||||
dcc_calculate_speed (ptr_dcc, 1);
|
||||
|
||||
if (ptr_dcc->sock != -1)
|
||||
if (ptr_dcc->sock >= 0)
|
||||
{
|
||||
close (ptr_dcc->sock);
|
||||
ptr_dcc->sock = -1;
|
||||
}
|
||||
if (ptr_dcc->file != -1)
|
||||
if (ptr_dcc->file >= 0)
|
||||
{
|
||||
close (ptr_dcc->file);
|
||||
ptr_dcc->file = -1;
|
||||
@@ -950,7 +959,7 @@ dcc_send_request (t_irc_server *server, int type, char *nick, char *filename)
|
||||
|
||||
/* open socket for DCC */
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == -1)
|
||||
if (sock < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
@@ -1110,7 +1119,7 @@ dcc_chat_sendf (t_irc_dcc *ptr_dcc, char *fmt, ...)
|
||||
char *buf2;
|
||||
int size_buf;
|
||||
|
||||
if (!ptr_dcc || (ptr_dcc->sock == -1))
|
||||
if (!ptr_dcc || (ptr_dcc->sock < 0))
|
||||
return;
|
||||
|
||||
va_start (args, fmt);
|
||||
@@ -1488,7 +1497,7 @@ dcc_end ()
|
||||
|
||||
for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
|
||||
{
|
||||
if (ptr_dcc->sock != -1)
|
||||
if (ptr_dcc->sock >= 0)
|
||||
{
|
||||
if (ptr_dcc->status == DCC_ACTIVE)
|
||||
weechat_log_printf (_("Aborting active DCC: \"%s\" from %s\n"),
|
||||
|
||||
+2
-1
@@ -2553,7 +2553,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((ptr_channel->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (ptr_channel->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
ptr_nick = NULL;
|
||||
else
|
||||
ptr_nick = nick_search (ptr_channel, nick);
|
||||
|
||||
@@ -611,87 +611,6 @@ irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_dcc: start DCC (file or chat)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_dcc (t_irc_server *server, t_irc_channel *channel,
|
||||
char *arguments)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
char *pos_nick, *pos_file;
|
||||
|
||||
irc_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
/* DCC SEND file */
|
||||
if (strncasecmp (arguments, "send", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
pos_file = strchr (pos_nick, ' ');
|
||||
if (!pos_file)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
pos_file[0] = '\0';
|
||||
pos_file++;
|
||||
while (pos_file[0] == ' ')
|
||||
pos_file++;
|
||||
|
||||
dcc_send_request (server, DCC_FILE_SEND, pos_nick, pos_file);
|
||||
}
|
||||
else if (strncasecmp (arguments, "chat", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc chat");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
dcc_send_request (server, DCC_CHAT_SEND, pos_nick, NULL);
|
||||
}
|
||||
else if (ascii_strcasecmp (arguments, "close") == 0)
|
||||
{
|
||||
if (BUFFER_IS_PRIVATE(buffer) &&
|
||||
CHANNEL(buffer)->dcc_chat)
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong arguments for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_dehalfop: remove half operator privileges from nickname(s)
|
||||
*/
|
||||
@@ -1616,14 +1535,6 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BUFFER_IS_SERVER(buffer))
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s \"%s\" command can not be executed on a server buffer\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(buffer)->name;
|
||||
pos_args = arguments;
|
||||
}
|
||||
|
||||
+6
-5
@@ -81,9 +81,10 @@ struct t_irc_nick
|
||||
|
||||
#define CHANNEL_PREFIX "#&+!"
|
||||
|
||||
#define CHANNEL_TYPE_UNKNOWN -1
|
||||
#define CHANNEL_TYPE_CHANNEL 0
|
||||
#define CHANNEL_TYPE_PRIVATE 1
|
||||
#define CHANNEL_TYPE_UNKNOWN -1
|
||||
#define CHANNEL_TYPE_CHANNEL 0
|
||||
#define CHANNEL_TYPE_PRIVATE 1
|
||||
#define CHANNEL_TYPE_DCC_CHAT 2
|
||||
|
||||
#define NUM_CHANNEL_MODES 8
|
||||
#define CHANNEL_MODE_INVITE 0
|
||||
@@ -369,6 +370,8 @@ extern t_irc_channel *channel_new (t_irc_server *, int, char *);
|
||||
extern void channel_free (t_irc_server *, t_irc_channel *);
|
||||
extern void channel_free_all (t_irc_server *);
|
||||
extern t_irc_channel *channel_search (t_irc_server *, char *);
|
||||
extern t_irc_channel *channel_search_any (t_irc_server *, char *);
|
||||
extern t_irc_channel *channel_search_dcc (t_irc_server *, char *);
|
||||
extern int string_is_channel (char *);
|
||||
extern char *channel_get_charset_decode_iso (t_irc_server *, t_irc_channel *);
|
||||
extern char *channel_get_charset_decode_utf (t_irc_server *, t_irc_channel *);
|
||||
@@ -379,7 +382,6 @@ extern void channel_remove_away (t_irc_channel *);
|
||||
extern void channel_check_away (t_irc_server *, t_irc_channel *, int);
|
||||
extern void channel_set_away (t_irc_channel *, char *, int);
|
||||
extern int channel_create_dcc (t_irc_dcc *);
|
||||
extern void channel_remove_dcc (t_irc_dcc *);
|
||||
extern int channel_get_notify_level (t_irc_server *, t_irc_channel *);
|
||||
extern void channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
|
||||
extern void channel_print_log (t_irc_channel *);
|
||||
@@ -438,7 +440,6 @@ extern int irc_cmd_send_away (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ctcp (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_cycle (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_dcc (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_cmd_send_deop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_cmd_send_devoice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
|
||||
+2
-2
@@ -1,9 +1,10 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2006-04-12
|
||||
ChangeLog - 2006-04-15
|
||||
|
||||
Version 0.1.9 (under dev!):
|
||||
* fixed many crashes with DCC chat
|
||||
* added new option to customize input prompt
|
||||
* added nick modes
|
||||
* fixed commands 332, 333 (/topic now ok when channel is not opened)
|
||||
@@ -12,7 +13,6 @@ Version 0.1.9 (under dev!):
|
||||
* added hostnames associeted to nicks (available for /ban completion)
|
||||
* added "+p" mode for channels, fixed mode display in status bar
|
||||
* added nick alignment options
|
||||
* fixed crash when closing DCC chat buffer
|
||||
* fixed /names command: now displays result when not on a channel
|
||||
* fixed refresh bug (too many refresh) when terminal is resized
|
||||
* fixed nicklist display bugs when on top or bottom of chat window
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
* FlashCode, 2006-04-15
|
||||
|
||||
Important release notes for 0.1.9:
|
||||
|
||||
- please close all DCC chat buffers before using /upgrade command,
|
||||
otherwise you may experience problems with DCC chats.
|
||||
|
||||
* FlashCode, 2006-03-18
|
||||
|
||||
WeeChat 0.1.8 released.
|
||||
|
||||
@@ -58,15 +58,6 @@ leave and rejoin a channel
|
||||
channel: channel name for cycle
|
||||
part_message: part message (displayed to other users)
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [nickname [file]]</command>
|
||||
<programlisting>
|
||||
starts DCC (file or chat) or close chat
|
||||
|
||||
action: 'send' (file) or 'chat' or 'close' (chat)
|
||||
nickname: nickname to send file or chat
|
||||
file: filename (on local host)
|
||||
|
||||
</programlisting>
|
||||
<command>dehalfop [nickname [nickname]]</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -66,6 +66,15 @@ disconnect from a server
|
||||
|
||||
servername: server name to disconnect
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [nickname [file]]</command>
|
||||
<programlisting>
|
||||
starts DCC (file or chat) or close chat
|
||||
|
||||
action: 'send' (file) or 'chat' or 'close' (chat)
|
||||
nickname: nickname to send file or chat
|
||||
file: filename (on local host)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -58,15 +58,6 @@ quitter et rejoindre un canal
|
||||
canal: canal pour le cycle
|
||||
message_de_fin: message de fin (affiché aux autres utilisateurs)
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [pseudo [fichier]]</command>
|
||||
<programlisting>
|
||||
démarre le DCC (fichier ou discussion) ou ferme une discussion
|
||||
|
||||
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
|
||||
pseudo: pseudo pour envoyer le fichier ou discuter
|
||||
fichier: nom du fichier (sur la machine locale)
|
||||
|
||||
</programlisting>
|
||||
<command>dehalfop [pseudo [pseudo]]</command>
|
||||
<programlisting>
|
||||
|
||||
@@ -66,6 +66,15 @@ se d
|
||||
|
||||
nom_serveur: nom du serveur pour se déconnecter
|
||||
|
||||
</programlisting>
|
||||
<command>dcc action [pseudo [fichier]]</command>
|
||||
<programlisting>
|
||||
démarre le DCC (fichier ou discussion) ou ferme une discussion
|
||||
|
||||
action: 'send' (envoi de fichier) ou 'chat' (discussion) ou 'close' (fermeture discussion)
|
||||
pseudo: pseudo pour envoyer le fichier ou discuter
|
||||
fichier: nom du fichier (sur la machine locale)
|
||||
|
||||
</programlisting>
|
||||
<command>debug dump | windows</command>
|
||||
<programlisting>
|
||||
|
||||
+564
-559
File diff suppressed because it is too large
Load Diff
+598
-615
File diff suppressed because it is too large
Load Diff
+565
-560
File diff suppressed because it is too large
Load Diff
+568
-561
File diff suppressed because it is too large
Load Diff
+565
-560
File diff suppressed because it is too large
Load Diff
+561
-556
File diff suppressed because it is too large
Load Diff
+177
-49
@@ -86,6 +86,12 @@ t_weechat_command weechat_commands[] =
|
||||
N_("[servername]"),
|
||||
N_("servername: server name to disconnect"),
|
||||
"%S", 0, 1, weechat_cmd_disconnect, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat) or close chat"),
|
||||
N_("action [nickname [file]]"),
|
||||
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
|
||||
"nickname: nickname to send file or chat\n"
|
||||
" file: filename (on local host)"),
|
||||
"chat|send|close %n %f", 1, MAX_ARGS, NULL, weechat_cmd_dcc },
|
||||
{ "debug", N_("print debug messages"),
|
||||
N_("dump | windows"),
|
||||
N_(" dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)\n"
|
||||
@@ -902,6 +908,17 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string
|
||||
free (command);
|
||||
return 0;
|
||||
}
|
||||
if (channel && channel->dcc_chat)
|
||||
{
|
||||
irc_display_prefix (server, channel->buffer, PREFIX_ERROR);
|
||||
gui_printf (channel->buffer,
|
||||
_("%s command \"%s\" can not be "
|
||||
"executed on DCC CHAT buffer\n"),
|
||||
WEECHAT_ERROR,
|
||||
irc_commands[i].command_name);
|
||||
free (command);
|
||||
return 0;
|
||||
}
|
||||
if (irc_commands[i].cmd_function_args)
|
||||
return_code = (int) (irc_commands[i].cmd_function_args)
|
||||
(server, channel, argc, argv);
|
||||
@@ -942,7 +959,7 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
t_irc_nick *ptr_nick;
|
||||
int plugin_args_length;
|
||||
int plugin_args_length, text_sent;
|
||||
char *command_with_colors, *command_encoded, *command_with_colors2;
|
||||
char *plugin_args;
|
||||
|
||||
@@ -968,11 +985,22 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
|
||||
command_encoded = channel_iconv_encode (server, channel,
|
||||
(command_with_colors) ? command_with_colors : command);
|
||||
text_sent = 1;
|
||||
if (CHANNEL(buffer)->dcc_chat)
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
|
||||
"%s\r\n",
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : command));
|
||||
{
|
||||
if (((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat))->sock < 0)
|
||||
{
|
||||
irc_display_prefix (server, buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (buffer, "%s DCC CHAT is closed\n",
|
||||
WEECHAT_ERROR);
|
||||
text_sent = 0;
|
||||
}
|
||||
else
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat),
|
||||
"%s\r\n",
|
||||
(command_encoded) ? command_encoded :
|
||||
((command_with_colors) ? command_with_colors : command));
|
||||
}
|
||||
else
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(buffer)->name,
|
||||
@@ -981,25 +1009,14 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
|
||||
command_with_colors2 = (command_with_colors) ?
|
||||
(char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;
|
||||
|
||||
if (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
|
||||
if (text_sent)
|
||||
{
|
||||
irc_display_nick (buffer, NULL, server->nick,
|
||||
MSG_TYPE_NICK, 1, COLOR_WIN_NICK_SELF, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
(command_with_colors2) ?
|
||||
command_with_colors2 : command);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
|
||||
if (ptr_nick)
|
||||
if ((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
irc_display_nick (buffer, ptr_nick, NULL,
|
||||
MSG_TYPE_NICK, 1, -1, 0);
|
||||
irc_display_nick (buffer, NULL, server->nick,
|
||||
MSG_TYPE_NICK, 1, COLOR_WIN_NICK_SELF, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
@@ -1009,10 +1026,25 @@ user_command (t_irc_server *server, t_irc_channel *channel, char *command, int o
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot find nick for sending message\n"),
|
||||
WEECHAT_ERROR);
|
||||
ptr_nick = nick_search (CHANNEL(buffer), server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (buffer, ptr_nick, NULL,
|
||||
MSG_TYPE_NICK, 1, -1, 0);
|
||||
gui_printf_type (buffer,
|
||||
MSG_TYPE_MSG,
|
||||
"%s%s\n",
|
||||
GUI_COLOR(COLOR_WIN_CHAT),
|
||||
(command_with_colors2) ?
|
||||
command_with_colors2 : command);
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
_("%s cannot find nick for sending message\n"),
|
||||
WEECHAT_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,32 +1375,44 @@ weechat_cmd_buffer (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SERVER(buffer))
|
||||
if (CHANNEL(buffer)
|
||||
&& (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
if (SERVER(buffer)->is_connected
|
||||
&& CHANNEL(buffer)
|
||||
&& CHANNEL(buffer)->nicks)
|
||||
{
|
||||
pos = strstr (arguments, "close ");
|
||||
if (pos)
|
||||
pos += 6;
|
||||
CHANNEL(buffer)->close = 1;
|
||||
irc_cmd_send_part (SERVER(buffer),
|
||||
CHANNEL(buffer),
|
||||
pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (SERVER(buffer),
|
||||
CHANNEL(buffer)->name);
|
||||
if (ptr_channel)
|
||||
channel_free (SERVER(buffer),
|
||||
ptr_channel);
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
ptr_channel = CHANNEL(buffer);
|
||||
gui_buffer_free (ptr_channel->buffer, 1);
|
||||
channel_free (SERVER(buffer), ptr_channel);
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
gui_draw_buffer_input (buffer, 1);
|
||||
}
|
||||
else
|
||||
gui_buffer_free (buffer, 1);
|
||||
{
|
||||
if (SERVER(buffer))
|
||||
{
|
||||
if (SERVER(buffer)->is_connected
|
||||
&& CHANNEL(buffer)
|
||||
&& CHANNEL(buffer)->nicks)
|
||||
{
|
||||
pos = strstr (arguments, "close ");
|
||||
if (pos)
|
||||
pos += 6;
|
||||
CHANNEL(buffer)->close = 1;
|
||||
irc_cmd_send_part (SERVER(buffer),
|
||||
CHANNEL(buffer),
|
||||
pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search_any (SERVER(buffer),
|
||||
CHANNEL(buffer)->name);
|
||||
if (ptr_channel)
|
||||
channel_free (SERVER(buffer),
|
||||
ptr_channel);
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
gui_buffer_free (buffer, 1);
|
||||
}
|
||||
}
|
||||
gui_draw_buffer_status (buffer, 1);
|
||||
}
|
||||
@@ -1847,6 +1891,90 @@ weechat_cmd_connect (t_irc_server *server, t_irc_channel *channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_dcc: DCC control (file or chat)
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_cmd_dcc (t_irc_server *server, t_irc_channel *channel,
|
||||
char *arguments)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
char *pos_nick, *pos_file;
|
||||
|
||||
irc_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
/* DCC SEND file */
|
||||
if (strncasecmp (arguments, "send", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
pos_file = strchr (pos_nick, ' ');
|
||||
if (!pos_file)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
pos_file[0] = '\0';
|
||||
pos_file++;
|
||||
while (pos_file[0] == ' ')
|
||||
pos_file++;
|
||||
|
||||
dcc_send_request (server, DCC_FILE_SEND, pos_nick, pos_file);
|
||||
}
|
||||
/* DCC CHAT */
|
||||
else if (strncasecmp (arguments, "chat", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc chat");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
dcc_send_request (server, DCC_CHAT_SEND, pos_nick, NULL);
|
||||
}
|
||||
/* close DCC CHAT */
|
||||
else if (ascii_strcasecmp (arguments, "close") == 0)
|
||||
{
|
||||
if (BUFFER_IS_PRIVATE(buffer) &&
|
||||
CHANNEL(buffer)->dcc_chat)
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
}
|
||||
/* unknown DCC action */
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong arguments for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_cmd_debug_display_windows: display tree of windows
|
||||
*/
|
||||
|
||||
@@ -79,6 +79,7 @@ extern int weechat_cmd_builtin (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_charset (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_clear (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_connect (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_dcc (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int weechat_cmd_debug (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_disconnect (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int weechat_cmd_help (t_irc_server *, t_irc_channel *, int, char **);
|
||||
|
||||
@@ -358,7 +358,8 @@ completion_list_add_channel_nicks (t_completion *completion)
|
||||
ptr_nick->nick);
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
@@ -406,7 +407,8 @@ completion_list_add_channel_nicks_hosts (t_completion *completion)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE))
|
||||
{
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
@@ -998,7 +1000,8 @@ completion_find_context (t_completion *completion, char *buffer, int size, int p
|
||||
}
|
||||
|
||||
if (!completion->completion_list && completion->channel &&
|
||||
(((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
&& (completion->context == COMPLETION_NICK))
|
||||
{
|
||||
/* nick completion in private (only other nick and self) */
|
||||
@@ -1192,7 +1195,8 @@ completion_nick (t_completion *completion)
|
||||
if (!completion->channel)
|
||||
return;
|
||||
|
||||
if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
{
|
||||
if (!(completion->completion_list))
|
||||
{
|
||||
|
||||
@@ -156,7 +156,7 @@ fifo_exec (char *text)
|
||||
}
|
||||
if (ptr_server && pos)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, pos + 1);
|
||||
ptr_channel = channel_search_any (ptr_server, pos + 1);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
irc_display_prefix (NULL, NULL, PREFIX_ERROR);
|
||||
|
||||
@@ -1208,7 +1208,7 @@ session_load_dcc (FILE *file)
|
||||
return 0;
|
||||
if (string && string[0])
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, string);
|
||||
ptr_channel = channel_search_any (ptr_server, string);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
session_crash (file, _("channel not found for DCC"));
|
||||
@@ -1399,7 +1399,7 @@ session_load_buffer (FILE *file)
|
||||
|
||||
if (channel_name)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, channel_name);
|
||||
ptr_channel = channel_search_any (ptr_server, channel_name);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
session_crash (file, _("channel not found for buffer"));
|
||||
|
||||
@@ -2041,7 +2041,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
wprintw (ptr_win->win_status, "] ");
|
||||
}
|
||||
|
||||
/* infos about current buffer */
|
||||
/* infos about current server buffer */
|
||||
if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
@@ -2082,6 +2082,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* infos about current channel/pv buffer */
|
||||
if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer))
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
@@ -2093,8 +2095,12 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
wprintw (ptr_win->win_status, ":");
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_CHANNEL);
|
||||
if ((!CHANNEL(ptr_win->buffer)->nicks)
|
||||
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE))
|
||||
if (((CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_PRIVATE)
|
||||
&& (CHANNEL(ptr_win->buffer)->type != CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (!CHANNEL(ptr_win->buffer)->nicks))
|
||||
|| ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (CHANNEL(ptr_win->buffer)->dcc_chat)
|
||||
&& (((t_irc_dcc *)(CHANNEL(ptr_win->buffer)->dcc_chat))->sock < 0)))
|
||||
wprintw (ptr_win->win_status, "(%s)",
|
||||
CHANNEL(ptr_win->buffer)->name);
|
||||
else
|
||||
@@ -2140,8 +2146,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
|
||||
}
|
||||
|
||||
/* display DCC if private is DCC CHAT */
|
||||
if ((CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_PRIVATE)
|
||||
&& (CHANNEL(ptr_win->buffer)->dcc_chat))
|
||||
if (CHANNEL(ptr_win->buffer)->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
{
|
||||
gui_window_set_weechat_color (ptr_win->win_status,
|
||||
COLOR_WIN_STATUS_DELIMITERS);
|
||||
|
||||
@@ -487,7 +487,7 @@ gui_buffer_search (char *server, char *channel)
|
||||
{
|
||||
if (ptr_server)
|
||||
{
|
||||
ptr_channel = channel_search (ptr_server, channel);
|
||||
ptr_channel = channel_search_any (ptr_server, channel);
|
||||
if (ptr_channel)
|
||||
ptr_buffer = ptr_channel->buffer;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,9 @@ enum t_weechat_color
|
||||
|
||||
#define BUFFER_IS_SERVER(buffer) ((SERVER(buffer) || (buffer->all_servers)) && !CHANNEL(buffer))
|
||||
#define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_CHANNEL))
|
||||
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE))
|
||||
#define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && \
|
||||
((CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE) \
|
||||
|| (CHANNEL(buffer)->type == CHANNEL_TYPE_DCC_CHAT)))
|
||||
|
||||
#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer))
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name)
|
||||
fprintf (stderr, _("%s cannot allocate new channel"), WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
@@ -143,6 +143,7 @@ channel_free_all (t_irc_server *server)
|
||||
|
||||
/*
|
||||
* channel_search: returns pointer on a channel with name
|
||||
* WARNING: DCC chat channels are not returned by this function
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
@@ -150,6 +151,28 @@ channel_search (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type != CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_search_any: returns pointer on a channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
channel_search_any (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
@@ -162,6 +185,28 @@ channel_search (t_irc_server *server, char *channel_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_search_dcc: returns pointer on a DCC chat channel with name
|
||||
*/
|
||||
|
||||
t_irc_channel *
|
||||
channel_search_dcc (t_irc_server *server, char *channel_name)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (!server || !channel_name)
|
||||
return NULL;
|
||||
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((ptr_channel->type == CHANNEL_TYPE_DCC_CHAT)
|
||||
&& (ascii_strcasecmp (ptr_channel->name, channel_name) == 0))
|
||||
return ptr_channel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* string_is_channel: returns 1 if string is channel
|
||||
*/
|
||||
@@ -381,14 +426,16 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
ptr_channel = channel_search (ptr_dcc->server, ptr_dcc->nick);
|
||||
ptr_channel = channel_search_dcc (ptr_dcc->server, ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHANNEL_TYPE_PRIVATE,
|
||||
{
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHANNEL_TYPE_DCC_CHAT,
|
||||
ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel,
|
||||
BUFFER_TYPE_STANDARD, 0);
|
||||
}
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
|
||||
@@ -400,26 +447,6 @@ channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_remove_dcc: remove a DCC CHAT
|
||||
*/
|
||||
|
||||
void
|
||||
channel_remove_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
for (ptr_channel = ptr_dcc->server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if ((t_irc_dcc *)(ptr_channel->dcc_chat) == ptr_dcc)
|
||||
{
|
||||
ptr_channel->dcc_chat = NULL;
|
||||
gui_redraw_buffer (ptr_channel->buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_get_notify_level: get channel notify level
|
||||
*/
|
||||
|
||||
@@ -64,12 +64,6 @@ t_irc_command irc_commands[] =
|
||||
N_(" channel: channel name for cycle\n"
|
||||
"part_message: part message (displayed to other users)"),
|
||||
"%p", 0, MAX_ARGS, 1, NULL, irc_cmd_send_cycle, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat) or close chat"),
|
||||
N_("action [nickname [file]]"),
|
||||
N_(" action: 'send' (file) or 'chat' or 'close' (chat)\n"
|
||||
"nickname: nickname to send file or chat\n"
|
||||
" file: filename (on local host)"),
|
||||
"chat|send|close %n %f", 1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
{ "dehalfop", N_("removes half channel operator status from nickname(s)"),
|
||||
N_("[nickname [nickname]]"), "",
|
||||
"", 0, MAX_ARGS, 1, irc_cmd_send_dehalfop, NULL, NULL },
|
||||
|
||||
+23
-14
@@ -283,10 +283,10 @@ dcc_connect (t_irc_dcc *ptr_dcc)
|
||||
else
|
||||
ptr_dcc->status = DCC_CONNECTING;
|
||||
|
||||
if (ptr_dcc->sock == -1)
|
||||
if (ptr_dcc->sock < 0)
|
||||
{
|
||||
ptr_dcc->sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (ptr_dcc->sock == -1)
|
||||
if (ptr_dcc->sock < 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -344,6 +344,20 @@ dcc_free (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_dcc *new_dcc_list;
|
||||
|
||||
/* DCC CHAT with channel => remove channel
|
||||
(to prevent channel from becoming standard pv) */
|
||||
if (ptr_dcc->channel)
|
||||
{
|
||||
/* check if channel is used for another active DCC CHAT */
|
||||
if (!ptr_dcc->channel->dcc_chat
|
||||
|| (DCC_ENDED(((t_irc_dcc *)(ptr_dcc->channel->dcc_chat))->status)))
|
||||
{
|
||||
gui_buffer_free (ptr_dcc->channel->buffer, 1);
|
||||
channel_free (ptr_dcc->server, ptr_dcc->channel);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove DCC from list */
|
||||
if (ptr_dcc->prev_dcc)
|
||||
{
|
||||
(ptr_dcc->prev_dcc)->next_dcc = ptr_dcc->next_dcc;
|
||||
@@ -351,10 +365,10 @@ dcc_free (t_irc_dcc *ptr_dcc)
|
||||
}
|
||||
else
|
||||
new_dcc_list = ptr_dcc->next_dcc;
|
||||
|
||||
if (ptr_dcc->next_dcc)
|
||||
(ptr_dcc->next_dcc)->prev_dcc = ptr_dcc->prev_dcc;
|
||||
|
||||
|
||||
/* free data */
|
||||
if (ptr_dcc->nick)
|
||||
free (ptr_dcc->nick);
|
||||
if (ptr_dcc->unterminated_message)
|
||||
@@ -444,20 +458,15 @@ dcc_close (t_irc_dcc *ptr_dcc, int status)
|
||||
}
|
||||
}
|
||||
|
||||
ptr_dcc->channel = NULL;
|
||||
|
||||
if (DCC_IS_CHAT(ptr_dcc->type))
|
||||
channel_remove_dcc (ptr_dcc);
|
||||
|
||||
if (DCC_IS_FILE(ptr_dcc->type))
|
||||
dcc_calculate_speed (ptr_dcc, 1);
|
||||
|
||||
if (ptr_dcc->sock != -1)
|
||||
if (ptr_dcc->sock >= 0)
|
||||
{
|
||||
close (ptr_dcc->sock);
|
||||
ptr_dcc->sock = -1;
|
||||
}
|
||||
if (ptr_dcc->file != -1)
|
||||
if (ptr_dcc->file >= 0)
|
||||
{
|
||||
close (ptr_dcc->file);
|
||||
ptr_dcc->file = -1;
|
||||
@@ -950,7 +959,7 @@ dcc_send_request (t_irc_server *server, int type, char *nick, char *filename)
|
||||
|
||||
/* open socket for DCC */
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == -1)
|
||||
if (sock < 0)
|
||||
{
|
||||
irc_display_prefix (server, server->buffer, PREFIX_ERROR);
|
||||
gui_printf (server->buffer,
|
||||
@@ -1110,7 +1119,7 @@ dcc_chat_sendf (t_irc_dcc *ptr_dcc, char *fmt, ...)
|
||||
char *buf2;
|
||||
int size_buf;
|
||||
|
||||
if (!ptr_dcc || (ptr_dcc->sock == -1))
|
||||
if (!ptr_dcc || (ptr_dcc->sock < 0))
|
||||
return;
|
||||
|
||||
va_start (args, fmt);
|
||||
@@ -1488,7 +1497,7 @@ dcc_end ()
|
||||
|
||||
for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
|
||||
{
|
||||
if (ptr_dcc->sock != -1)
|
||||
if (ptr_dcc->sock >= 0)
|
||||
{
|
||||
if (ptr_dcc->status == DCC_ACTIVE)
|
||||
weechat_log_printf (_("Aborting active DCC: \"%s\" from %s\n"),
|
||||
|
||||
@@ -2553,7 +2553,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *nick, char *arguments
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
if (ptr_channel->type == CHANNEL_TYPE_PRIVATE)
|
||||
if ((ptr_channel->type == CHANNEL_TYPE_PRIVATE)
|
||||
|| (ptr_channel->type == CHANNEL_TYPE_DCC_CHAT))
|
||||
ptr_nick = NULL;
|
||||
else
|
||||
ptr_nick = nick_search (ptr_channel, nick);
|
||||
|
||||
@@ -611,87 +611,6 @@ irc_cmd_send_cycle (t_irc_server *server, t_irc_channel *channel,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_dcc: start DCC (file or chat)
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_dcc (t_irc_server *server, t_irc_channel *channel,
|
||||
char *arguments)
|
||||
{
|
||||
t_gui_buffer *buffer;
|
||||
char *pos_nick, *pos_file;
|
||||
|
||||
irc_find_context (server, channel, NULL, &buffer);
|
||||
|
||||
/* DCC SEND file */
|
||||
if (strncasecmp (arguments, "send", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
pos_file = strchr (pos_nick, ' ');
|
||||
if (!pos_file)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc send");
|
||||
return -1;
|
||||
}
|
||||
pos_file[0] = '\0';
|
||||
pos_file++;
|
||||
while (pos_file[0] == ' ')
|
||||
pos_file++;
|
||||
|
||||
dcc_send_request (server, DCC_FILE_SEND, pos_nick, pos_file);
|
||||
}
|
||||
else if (strncasecmp (arguments, "chat", 4) == 0)
|
||||
{
|
||||
pos_nick = strchr (arguments, ' ');
|
||||
if (!pos_nick)
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc chat");
|
||||
return -1;
|
||||
}
|
||||
while (pos_nick[0] == ' ')
|
||||
pos_nick++;
|
||||
|
||||
dcc_send_request (server, DCC_CHAT_SEND, pos_nick, NULL);
|
||||
}
|
||||
else if (ascii_strcasecmp (arguments, "close") == 0)
|
||||
{
|
||||
if (BUFFER_IS_PRIVATE(buffer) &&
|
||||
CHANNEL(buffer)->dcc_chat)
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s wrong arguments for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "dcc");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_dehalfop: remove half operator privileges from nickname(s)
|
||||
*/
|
||||
@@ -1616,14 +1535,6 @@ irc_cmd_send_part (t_irc_server *server, t_irc_channel *channel,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BUFFER_IS_SERVER(buffer))
|
||||
{
|
||||
irc_display_prefix (NULL, server->buffer, PREFIX_ERROR);
|
||||
gui_printf_nolog (server->buffer,
|
||||
_("%s \"%s\" command can not be executed on a server buffer\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(buffer)->name;
|
||||
pos_args = arguments;
|
||||
}
|
||||
|
||||
@@ -81,9 +81,10 @@ struct t_irc_nick
|
||||
|
||||
#define CHANNEL_PREFIX "#&+!"
|
||||
|
||||
#define CHANNEL_TYPE_UNKNOWN -1
|
||||
#define CHANNEL_TYPE_CHANNEL 0
|
||||
#define CHANNEL_TYPE_PRIVATE 1
|
||||
#define CHANNEL_TYPE_UNKNOWN -1
|
||||
#define CHANNEL_TYPE_CHANNEL 0
|
||||
#define CHANNEL_TYPE_PRIVATE 1
|
||||
#define CHANNEL_TYPE_DCC_CHAT 2
|
||||
|
||||
#define NUM_CHANNEL_MODES 8
|
||||
#define CHANNEL_MODE_INVITE 0
|
||||
@@ -369,6 +370,8 @@ extern t_irc_channel *channel_new (t_irc_server *, int, char *);
|
||||
extern void channel_free (t_irc_server *, t_irc_channel *);
|
||||
extern void channel_free_all (t_irc_server *);
|
||||
extern t_irc_channel *channel_search (t_irc_server *, char *);
|
||||
extern t_irc_channel *channel_search_any (t_irc_server *, char *);
|
||||
extern t_irc_channel *channel_search_dcc (t_irc_server *, char *);
|
||||
extern int string_is_channel (char *);
|
||||
extern char *channel_get_charset_decode_iso (t_irc_server *, t_irc_channel *);
|
||||
extern char *channel_get_charset_decode_utf (t_irc_server *, t_irc_channel *);
|
||||
@@ -379,7 +382,6 @@ extern void channel_remove_away (t_irc_channel *);
|
||||
extern void channel_check_away (t_irc_server *, t_irc_channel *, int);
|
||||
extern void channel_set_away (t_irc_channel *, char *, int);
|
||||
extern int channel_create_dcc (t_irc_dcc *);
|
||||
extern void channel_remove_dcc (t_irc_dcc *);
|
||||
extern int channel_get_notify_level (t_irc_server *, t_irc_channel *);
|
||||
extern void channel_set_notify_level (t_irc_server *, t_irc_channel *, int);
|
||||
extern void channel_print_log (t_irc_channel *);
|
||||
@@ -438,7 +440,6 @@ extern int irc_cmd_send_away (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ban (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_ctcp (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_cycle (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_dcc (t_irc_server *, t_irc_channel *, char *);
|
||||
extern int irc_cmd_send_dehalfop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_cmd_send_deop (t_irc_server *, t_irc_channel *, int, char **);
|
||||
extern int irc_cmd_send_devoice (t_irc_server *, t_irc_channel *, int, char **);
|
||||
|
||||
Reference in New Issue
Block a user