mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 20:45:42 +02:00
Added DCC CHAT (send & recv)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-02-26
|
||||
ChangeLog - 2005-02-27
|
||||
|
||||
|
||||
Version 0.1.1 (under dev!):
|
||||
* added new display engine: doesn't cut words at end of lines
|
||||
* added DCC send
|
||||
* added DCC send and DCC chat
|
||||
* connection to IRC server is now made by child process (non blocking)
|
||||
* added support for UnrealIrcd ("~" for chan owner, "&" for chan admin)
|
||||
* new key for window switch (now: F5/F6=switch buffer, F7/F8=switch window)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2005-02-20
|
||||
TODO - 2005-02-27
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -16,10 +16,11 @@ v0.1.1:
|
||||
* General:
|
||||
+ Windows version
|
||||
+ Solaris version
|
||||
- *BSD version
|
||||
+ *BSD version
|
||||
|
||||
* IRC protocol:
|
||||
# "/dcc send" command
|
||||
# "/dcc chat" command (and incoming DCC chats)
|
||||
- customizable CTCP version reply
|
||||
|
||||
* Interface:
|
||||
@@ -34,7 +35,6 @@ Future versions:
|
||||
---------------
|
||||
|
||||
* IRC protocol:
|
||||
- "/dcc chat" command (and incoming DCC chats)
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
|
||||
+240
-197
File diff suppressed because it is too large
Load Diff
+11
-7
@@ -662,23 +662,27 @@ user_command (t_irc_server *server, char *command)
|
||||
command++;
|
||||
if (server && (!BUFFER_IS_SERVER(gui_current_window->buffer)))
|
||||
{
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(gui_current_window->buffer)->name,
|
||||
command);
|
||||
if (CHANNEL(gui_current_window->buffer)->dcc_chat)
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(gui_current_window->buffer)->dcc_chat),
|
||||
"%s\r\n", command);
|
||||
else
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(gui_current_window->buffer)->name,
|
||||
command);
|
||||
|
||||
if (BUFFER_IS_PRIVATE(gui_current_window->buffer))
|
||||
{
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", command);
|
||||
}
|
||||
|
||||
@@ -339,6 +339,9 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"send");
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"close");
|
||||
return;
|
||||
}
|
||||
if (strcasecmp (completion->base_command, "invite") == 0)
|
||||
|
||||
@@ -394,7 +394,7 @@ t_config_option weechat_options_colors[] =
|
||||
{ "col_dcc_waiting", N_("color for \"waiting\" dcc status"),
|
||||
N_("color for \"waiting\" dcc status"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
"white", NULL, &cfg_col_dcc_waiting, NULL, &config_change_color },
|
||||
"lightcyan", NULL, &cfg_col_dcc_waiting, NULL, &config_change_color },
|
||||
{ "col_dcc_connecting", N_("color for \"connecting\" dcc status"),
|
||||
N_("color for \"connecting\" dcc status"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -569,9 +569,8 @@ gui_read_keyb ()
|
||||
case 'a':
|
||||
case 'A':
|
||||
if (dcc_selected
|
||||
&& (((dcc_selected->type == DCC_CHAT_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_RECV))
|
||||
&& (dcc_selected->status == DCC_WAITING)))
|
||||
&& (DCC_IS_RECV(dcc_selected->status))
|
||||
&& (dcc_selected->status == DCC_WAITING))
|
||||
{
|
||||
dcc_accept (dcc_selected);
|
||||
}
|
||||
@@ -580,9 +579,7 @@ gui_read_keyb ()
|
||||
case 'c':
|
||||
case 'C':
|
||||
if (dcc_selected
|
||||
&& ((dcc_selected->status == DCC_WAITING)
|
||||
|| (dcc_selected->status == DCC_CONNECTING)
|
||||
|| (dcc_selected->status == DCC_ACTIVE)))
|
||||
&& (!DCC_ENDED(dcc_selected->status)))
|
||||
{
|
||||
dcc_close (dcc_selected, DCC_ABORTED);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
@@ -594,9 +591,7 @@ gui_read_keyb ()
|
||||
gui_current_window->dcc_selected = NULL;
|
||||
for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
|
||||
{
|
||||
if ((dcc_selected->status == DCC_DONE)
|
||||
|| (dcc_selected->status == DCC_FAILED)
|
||||
|| (dcc_selected->status == DCC_ABORTED))
|
||||
if (DCC_ENDED(ptr_dcc->status))
|
||||
dcc_free (ptr_dcc);
|
||||
}
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
@@ -618,12 +613,7 @@ gui_read_keyb ()
|
||||
case 'r':
|
||||
case 'R':
|
||||
if (dcc_selected
|
||||
&& (((dcc_selected->type == DCC_CHAT_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_SEND))
|
||||
&& ((dcc_selected->status == DCC_DONE)
|
||||
|| (dcc_selected->status == DCC_FAILED)
|
||||
|| (dcc_selected->status == DCC_ABORTED))))
|
||||
&& (DCC_ENDED(dcc_selected->status)))
|
||||
{
|
||||
if (dcc_selected->next_dcc)
|
||||
gui_current_window->dcc_selected = dcc_selected->next_dcc;
|
||||
@@ -775,8 +765,8 @@ gui_main_loop ()
|
||||
FD_SET (ptr_server->child_read, &read_fd);
|
||||
else
|
||||
{
|
||||
if (ptr_server->sock4 >= 0)
|
||||
FD_SET (ptr_server->sock4, &read_fd);
|
||||
if (ptr_server->sock >= 0)
|
||||
FD_SET (ptr_server->sock, &read_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -798,8 +788,8 @@ gui_main_loop ()
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ptr_server->sock4 >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock4, &read_fd)))
|
||||
if ((ptr_server->sock >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock, &read_fd)))
|
||||
server_recv (ptr_server);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-4
@@ -86,13 +86,16 @@
|
||||
#define MSG_TYPE_NOLOG 64
|
||||
|
||||
#define gui_printf_color(buffer, color, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO, color, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO, color, fmt, ##argz)
|
||||
|
||||
#define gui_printf_type(buffer, type, fmt, argz...) \
|
||||
gui_printf_type_color(buffer, type, -1, fmt, ##argz)
|
||||
|
||||
#define gui_printf(buffer, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO, -1, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO, -1, fmt, ##argz)
|
||||
|
||||
#define gui_printf_nolog(buffer, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz)
|
||||
|
||||
typedef struct t_gui_message t_gui_message;
|
||||
|
||||
@@ -313,7 +316,7 @@ extern void gui_init_colors ();
|
||||
extern void gui_set_window_title ();
|
||||
extern void gui_init ();
|
||||
extern void gui_end ();
|
||||
extern void gui_printf_color_type (/*@null@*/ t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_printf_type_color (/*@null@*/ t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_main_loop ();
|
||||
|
||||
#endif /* gui.h */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/weechat.h"
|
||||
@@ -53,6 +54,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name,
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
new_channel->name = strdup (channel_name);
|
||||
new_channel->topic = NULL;
|
||||
memset (new_channel->modes, ' ', sizeof (new_channel->modes));
|
||||
@@ -101,6 +103,14 @@ channel_free (t_irc_server *server, t_irc_channel *channel)
|
||||
if (channel->next_channel)
|
||||
(channel->next_channel)->prev_channel = channel->prev_channel;
|
||||
|
||||
/* close DCC CHAT */
|
||||
if ((t_irc_dcc *)(channel->dcc_chat) &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
|
||||
/* free data */
|
||||
if (channel->name)
|
||||
free (channel->name);
|
||||
@@ -204,3 +214,49 @@ channel_set_away (t_irc_channel *channel, char *nick, int is_away)
|
||||
nick_set_away (channel, ptr_nick, is_away);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_create_dcc: create DCC CHAT channel
|
||||
*/
|
||||
|
||||
int
|
||||
channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
ptr_channel = channel_search (ptr_dcc->server, ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHAT_PRIVATE,
|
||||
ptr_dcc->nick, 0);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
|
||||
return 0;
|
||||
|
||||
ptr_channel->dcc_chat = ptr_dcc;
|
||||
ptr_dcc->channel = ptr_channel;
|
||||
gui_redraw_buffer (ptr_channel->buffer);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ t_irc_command irc_commands[] =
|
||||
N_("nickname type"),
|
||||
N_("nickname: user to send ctcp to\ntype: \"action\" or \"version\""),
|
||||
2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat)"),
|
||||
N_("action nickname [file]"),
|
||||
N_("action: 'send' (file) or 'chat'\n"
|
||||
{ "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)"),
|
||||
2, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
{ "deop", N_("removes channel operator status from nickname(s)"),
|
||||
N_("nickname [nickname]"), "",
|
||||
1, MAX_ARGS, 1, irc_cmd_send_deop, NULL, NULL },
|
||||
|
||||
+487
-156
File diff suppressed because it is too large
Load Diff
+13
-13
@@ -52,9 +52,9 @@ irc_display_prefix (t_gui_buffer *buffer, char *prefix)
|
||||
|
||||
if (prefix[0] == prefix[2])
|
||||
{
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c", prefix[0]);
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX2, "%c", prefix[1]);
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c ", prefix[2]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c", prefix[0]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX2, "%c", prefix[1]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c ", prefix[2]);
|
||||
}
|
||||
else
|
||||
gui_printf_color (buffer, COLOR_WIN_CHAT_PREFIX1, "%s ", prefix);
|
||||
@@ -70,43 +70,43 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, int message_type,
|
||||
int display_around, int color_nick, int no_nickmode)
|
||||
{
|
||||
if (display_around)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type, COLOR_WIN_CHAT_DARK, "<");
|
||||
if (cfg_look_nickmode)
|
||||
{
|
||||
if (nick->is_chanowner)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "~");
|
||||
else if (nick->is_chanadmin)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "&");
|
||||
else if (nick->is_op)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "@");
|
||||
else if (nick->is_halfop)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_HALFOP, "%%");
|
||||
else if (nick->has_voice)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_VOICE, "+");
|
||||
else
|
||||
if (cfg_look_nickmode_empty && !no_nickmode)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_CHAT, " ");
|
||||
}
|
||||
if (color_nick < 0)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_CHAT_HIGHLIGHT,
|
||||
"%s", nick->nick);
|
||||
else
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
(color_nick) ?
|
||||
((cfg_look_color_nicks) ?
|
||||
@@ -115,7 +115,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, int message_type,
|
||||
"%s", nick->nick);
|
||||
|
||||
if (display_around)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type, COLOR_WIN_CHAT_DARK, "> ");
|
||||
}
|
||||
|
||||
|
||||
+173
-102
File diff suppressed because it is too large
Load Diff
+46
-19
File diff suppressed because it is too large
Load Diff
+21
-17
File diff suppressed because it is too large
Load Diff
+17
-2
@@ -71,6 +71,14 @@
|
||||
#define DCC_FAILED 4 /* DCC failed */
|
||||
#define DCC_ABORTED 5 /* DCC aborted by user */
|
||||
|
||||
#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND))
|
||||
#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND))
|
||||
#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV))
|
||||
#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND))
|
||||
|
||||
#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \
|
||||
(status == DCC_ABORTED))
|
||||
|
||||
/* nick types */
|
||||
|
||||
typedef struct t_irc_nick t_irc_nick;
|
||||
@@ -100,6 +108,7 @@ 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[NUM_CHANNEL_MODES+1];/* channel modes */
|
||||
@@ -142,7 +151,7 @@ struct t_irc_server
|
||||
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 sock4; /* socket for server */
|
||||
int sock; /* socket for server */
|
||||
int is_connected; /* 1 if WeeChat is connected to server */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
char *nick; /* current nickname */
|
||||
@@ -198,12 +207,14 @@ 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 (send or receive) */
|
||||
int status; /* DCC status (waiting, sending, ..) */
|
||||
unsigned long addr; /* IP address */
|
||||
int port; /* port */
|
||||
char *nick; /* remote nick */
|
||||
int sock; /* socket for connection */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
int file; /* local file (for reading or writing) */
|
||||
char *filename; /* filename (given by sender) */
|
||||
char *local_filename; /* local filename (with path) */
|
||||
@@ -260,6 +271,8 @@ extern int string_is_channel (char *);
|
||||
extern void channel_remove_away (t_irc_channel *);
|
||||
extern void channel_check_away (t_irc_server *, t_irc_channel *);
|
||||
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 *);
|
||||
|
||||
/* nick functions (irc-nick.c) */
|
||||
|
||||
@@ -275,13 +288,15 @@ extern void nick_set_away (t_irc_channel *, t_irc_nick *, int);
|
||||
|
||||
/* DCC functions (irc-dcc.c) */
|
||||
|
||||
extern void dcc_redraw (int);
|
||||
extern void dcc_free (t_irc_dcc *);
|
||||
extern void dcc_close (t_irc_dcc *, int);
|
||||
extern void dcc_accept (t_irc_dcc *);
|
||||
extern t_irc_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
|
||||
char *, char *, unsigned long);
|
||||
extern void dcc_send_request (t_irc_server *, int, char *, char *);
|
||||
extern void dcc_chat_sendf (t_irc_dcc *, char *, ...);
|
||||
extern void dcc_handle ();
|
||||
extern void dcc_send (t_irc_server *, char *, char *);
|
||||
extern void dcc_end ();
|
||||
|
||||
/* IRC display (irc-diplay.c) */
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2005-02-26
|
||||
ChangeLog - 2005-02-27
|
||||
|
||||
|
||||
Version 0.1.1 (under dev!):
|
||||
* added new display engine: doesn't cut words at end of lines
|
||||
* added DCC send
|
||||
* added DCC send and DCC chat
|
||||
* connection to IRC server is now made by child process (non blocking)
|
||||
* added support for UnrealIrcd ("~" for chan owner, "&" for chan admin)
|
||||
* new key for window switch (now: F5/F6=switch buffer, F7/F8=switch window)
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2005-02-20
|
||||
TODO - 2005-02-27
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -16,10 +16,11 @@ v0.1.1:
|
||||
* General:
|
||||
+ Windows version
|
||||
+ Solaris version
|
||||
- *BSD version
|
||||
+ *BSD version
|
||||
|
||||
* IRC protocol:
|
||||
# "/dcc send" command
|
||||
# "/dcc chat" command (and incoming DCC chats)
|
||||
- customizable CTCP version reply
|
||||
|
||||
* Interface:
|
||||
@@ -34,7 +35,6 @@ Future versions:
|
||||
---------------
|
||||
|
||||
* IRC protocol:
|
||||
- "/dcc chat" command (and incoming DCC chats)
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
|
||||
+247
-216
File diff suppressed because it is too large
Load Diff
+240
-197
File diff suppressed because it is too large
Load Diff
@@ -662,23 +662,27 @@ user_command (t_irc_server *server, char *command)
|
||||
command++;
|
||||
if (server && (!BUFFER_IS_SERVER(gui_current_window->buffer)))
|
||||
{
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(gui_current_window->buffer)->name,
|
||||
command);
|
||||
if (CHANNEL(gui_current_window->buffer)->dcc_chat)
|
||||
dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(gui_current_window->buffer)->dcc_chat),
|
||||
"%s\r\n", command);
|
||||
else
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n",
|
||||
CHANNEL(gui_current_window->buffer)->name,
|
||||
command);
|
||||
|
||||
if (BUFFER_IS_PRIVATE(gui_current_window->buffer))
|
||||
{
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
gui_printf_type_color (CHANNEL(gui_current_window->buffer)->buffer,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", command);
|
||||
}
|
||||
|
||||
@@ -339,6 +339,9 @@ completion_build_list (t_completion *completion, void *channel)
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"send");
|
||||
weelist_add (&completion->completion_list,
|
||||
&completion->last_completion,
|
||||
"close");
|
||||
return;
|
||||
}
|
||||
if (strcasecmp (completion->base_command, "invite") == 0)
|
||||
|
||||
@@ -394,7 +394,7 @@ t_config_option weechat_options_colors[] =
|
||||
{ "col_dcc_waiting", N_("color for \"waiting\" dcc status"),
|
||||
N_("color for \"waiting\" dcc status"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
"white", NULL, &cfg_col_dcc_waiting, NULL, &config_change_color },
|
||||
"lightcyan", NULL, &cfg_col_dcc_waiting, NULL, &config_change_color },
|
||||
{ "col_dcc_connecting", N_("color for \"connecting\" dcc status"),
|
||||
N_("color for \"connecting\" dcc status"),
|
||||
OPTION_TYPE_COLOR, 0, 0, 0,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -569,9 +569,8 @@ gui_read_keyb ()
|
||||
case 'a':
|
||||
case 'A':
|
||||
if (dcc_selected
|
||||
&& (((dcc_selected->type == DCC_CHAT_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_RECV))
|
||||
&& (dcc_selected->status == DCC_WAITING)))
|
||||
&& (DCC_IS_RECV(dcc_selected->status))
|
||||
&& (dcc_selected->status == DCC_WAITING))
|
||||
{
|
||||
dcc_accept (dcc_selected);
|
||||
}
|
||||
@@ -580,9 +579,7 @@ gui_read_keyb ()
|
||||
case 'c':
|
||||
case 'C':
|
||||
if (dcc_selected
|
||||
&& ((dcc_selected->status == DCC_WAITING)
|
||||
|| (dcc_selected->status == DCC_CONNECTING)
|
||||
|| (dcc_selected->status == DCC_ACTIVE)))
|
||||
&& (!DCC_ENDED(dcc_selected->status)))
|
||||
{
|
||||
dcc_close (dcc_selected, DCC_ABORTED);
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
@@ -594,9 +591,7 @@ gui_read_keyb ()
|
||||
gui_current_window->dcc_selected = NULL;
|
||||
for (ptr_dcc = dcc_list; ptr_dcc; ptr_dcc = ptr_dcc->next_dcc)
|
||||
{
|
||||
if ((dcc_selected->status == DCC_DONE)
|
||||
|| (dcc_selected->status == DCC_FAILED)
|
||||
|| (dcc_selected->status == DCC_ABORTED))
|
||||
if (DCC_ENDED(ptr_dcc->status))
|
||||
dcc_free (ptr_dcc);
|
||||
}
|
||||
gui_redraw_buffer (gui_current_window->buffer);
|
||||
@@ -618,12 +613,7 @@ gui_read_keyb ()
|
||||
case 'r':
|
||||
case 'R':
|
||||
if (dcc_selected
|
||||
&& (((dcc_selected->type == DCC_CHAT_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_RECV)
|
||||
|| (dcc_selected->type == DCC_FILE_SEND))
|
||||
&& ((dcc_selected->status == DCC_DONE)
|
||||
|| (dcc_selected->status == DCC_FAILED)
|
||||
|| (dcc_selected->status == DCC_ABORTED))))
|
||||
&& (DCC_ENDED(dcc_selected->status)))
|
||||
{
|
||||
if (dcc_selected->next_dcc)
|
||||
gui_current_window->dcc_selected = dcc_selected->next_dcc;
|
||||
@@ -775,8 +765,8 @@ gui_main_loop ()
|
||||
FD_SET (ptr_server->child_read, &read_fd);
|
||||
else
|
||||
{
|
||||
if (ptr_server->sock4 >= 0)
|
||||
FD_SET (ptr_server->sock4, &read_fd);
|
||||
if (ptr_server->sock >= 0)
|
||||
FD_SET (ptr_server->sock, &read_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -798,8 +788,8 @@ gui_main_loop ()
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ptr_server->sock4 >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock4, &read_fd)))
|
||||
if ((ptr_server->sock >= 0) &&
|
||||
(FD_ISSET (ptr_server->sock, &read_fd)))
|
||||
server_recv (ptr_server);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,16 @@
|
||||
#define MSG_TYPE_NOLOG 64
|
||||
|
||||
#define gui_printf_color(buffer, color, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO, color, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO, color, fmt, ##argz)
|
||||
|
||||
#define gui_printf_type(buffer, type, fmt, argz...) \
|
||||
gui_printf_type_color(buffer, type, -1, fmt, ##argz)
|
||||
|
||||
#define gui_printf(buffer, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO, -1, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO, -1, fmt, ##argz)
|
||||
|
||||
#define gui_printf_nolog(buffer, fmt, argz...) \
|
||||
gui_printf_color_type(buffer, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz)
|
||||
gui_printf_type_color(buffer, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz)
|
||||
|
||||
typedef struct t_gui_message t_gui_message;
|
||||
|
||||
@@ -313,7 +316,7 @@ extern void gui_init_colors ();
|
||||
extern void gui_set_window_title ();
|
||||
extern void gui_init ();
|
||||
extern void gui_end ();
|
||||
extern void gui_printf_color_type (/*@null@*/ t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_printf_type_color (/*@null@*/ t_gui_buffer *, int, int, char *, ...);
|
||||
extern void gui_main_loop ();
|
||||
|
||||
#endif /* gui.h */
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/weechat.h"
|
||||
@@ -53,6 +54,7 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name,
|
||||
|
||||
/* initialize new channel */
|
||||
new_channel->type = channel_type;
|
||||
new_channel->dcc_chat = NULL;
|
||||
new_channel->name = strdup (channel_name);
|
||||
new_channel->topic = NULL;
|
||||
memset (new_channel->modes, ' ', sizeof (new_channel->modes));
|
||||
@@ -101,6 +103,14 @@ channel_free (t_irc_server *server, t_irc_channel *channel)
|
||||
if (channel->next_channel)
|
||||
(channel->next_channel)->prev_channel = channel->prev_channel;
|
||||
|
||||
/* close DCC CHAT */
|
||||
if ((t_irc_dcc *)(channel->dcc_chat) &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(channel->dcc_chat))->status)))
|
||||
{
|
||||
dcc_close ((t_irc_dcc *)(channel->dcc_chat), DCC_ABORTED);
|
||||
dcc_redraw (1);
|
||||
}
|
||||
|
||||
/* free data */
|
||||
if (channel->name)
|
||||
free (channel->name);
|
||||
@@ -204,3 +214,49 @@ channel_set_away (t_irc_channel *channel, char *nick, int is_away)
|
||||
nick_set_away (channel, ptr_nick, is_away);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* channel_create_dcc: create DCC CHAT channel
|
||||
*/
|
||||
|
||||
int
|
||||
channel_create_dcc (t_irc_dcc *ptr_dcc)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
ptr_channel = channel_search (ptr_dcc->server, ptr_dcc->nick);
|
||||
if (!ptr_channel)
|
||||
ptr_channel = channel_new (ptr_dcc->server, CHAT_PRIVATE,
|
||||
ptr_dcc->nick, 0);
|
||||
if (!ptr_channel)
|
||||
return 0;
|
||||
|
||||
if (ptr_channel->dcc_chat &&
|
||||
(!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status)))
|
||||
return 0;
|
||||
|
||||
ptr_channel->dcc_chat = ptr_dcc;
|
||||
ptr_dcc->channel = ptr_channel;
|
||||
gui_redraw_buffer (ptr_channel->buffer);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ t_irc_command irc_commands[] =
|
||||
N_("nickname type"),
|
||||
N_("nickname: user to send ctcp to\ntype: \"action\" or \"version\""),
|
||||
2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL },
|
||||
{ "dcc", N_("starts DCC (file or chat)"),
|
||||
N_("action nickname [file]"),
|
||||
N_("action: 'send' (file) or 'chat'\n"
|
||||
{ "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)"),
|
||||
2, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL },
|
||||
{ "deop", N_("removes channel operator status from nickname(s)"),
|
||||
N_("nickname [nickname]"), "",
|
||||
1, MAX_ARGS, 1, irc_cmd_send_deop, NULL, NULL },
|
||||
|
||||
+487
-156
File diff suppressed because it is too large
Load Diff
@@ -52,9 +52,9 @@ irc_display_prefix (t_gui_buffer *buffer, char *prefix)
|
||||
|
||||
if (prefix[0] == prefix[2])
|
||||
{
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c", prefix[0]);
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX2, "%c", prefix[1]);
|
||||
gui_printf_color_type (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c ", prefix[2]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c", prefix[0]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX2, "%c", prefix[1]);
|
||||
gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c ", prefix[2]);
|
||||
}
|
||||
else
|
||||
gui_printf_color (buffer, COLOR_WIN_CHAT_PREFIX1, "%s ", prefix);
|
||||
@@ -70,43 +70,43 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, int message_type,
|
||||
int display_around, int color_nick, int no_nickmode)
|
||||
{
|
||||
if (display_around)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type, COLOR_WIN_CHAT_DARK, "<");
|
||||
if (cfg_look_nickmode)
|
||||
{
|
||||
if (nick->is_chanowner)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "~");
|
||||
else if (nick->is_chanadmin)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "&");
|
||||
else if (nick->is_op)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_OP, "@");
|
||||
else if (nick->is_halfop)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_HALFOP, "%%");
|
||||
else if (nick->has_voice)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_NICK_VOICE, "+");
|
||||
else
|
||||
if (cfg_look_nickmode_empty && !no_nickmode)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_CHAT, " ");
|
||||
}
|
||||
if (color_nick < 0)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
COLOR_WIN_CHAT_HIGHLIGHT,
|
||||
"%s", nick->nick);
|
||||
else
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type,
|
||||
(color_nick) ?
|
||||
((cfg_look_color_nicks) ?
|
||||
@@ -115,7 +115,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, int message_type,
|
||||
"%s", nick->nick);
|
||||
|
||||
if (display_around)
|
||||
gui_printf_color_type (buffer,
|
||||
gui_printf_type_color (buffer,
|
||||
message_type, COLOR_WIN_CHAT_DARK, "> ");
|
||||
}
|
||||
|
||||
|
||||
+173
-102
File diff suppressed because it is too large
Load Diff
+46
-19
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+17
-2
@@ -71,6 +71,14 @@
|
||||
#define DCC_FAILED 4 /* DCC failed */
|
||||
#define DCC_ABORTED 5 /* DCC aborted by user */
|
||||
|
||||
#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND))
|
||||
#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND))
|
||||
#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV))
|
||||
#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND))
|
||||
|
||||
#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \
|
||||
(status == DCC_ABORTED))
|
||||
|
||||
/* nick types */
|
||||
|
||||
typedef struct t_irc_nick t_irc_nick;
|
||||
@@ -100,6 +108,7 @@ 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[NUM_CHANNEL_MODES+1];/* channel modes */
|
||||
@@ -142,7 +151,7 @@ struct t_irc_server
|
||||
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 sock4; /* socket for server */
|
||||
int sock; /* socket for server */
|
||||
int is_connected; /* 1 if WeeChat is connected to server */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
char *nick; /* current nickname */
|
||||
@@ -198,12 +207,14 @@ 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 (send or receive) */
|
||||
int status; /* DCC status (waiting, sending, ..) */
|
||||
unsigned long addr; /* IP address */
|
||||
int port; /* port */
|
||||
char *nick; /* remote nick */
|
||||
int sock; /* socket for connection */
|
||||
char *unterminated_message; /* beginning of a message in input buf */
|
||||
int file; /* local file (for reading or writing) */
|
||||
char *filename; /* filename (given by sender) */
|
||||
char *local_filename; /* local filename (with path) */
|
||||
@@ -260,6 +271,8 @@ extern int string_is_channel (char *);
|
||||
extern void channel_remove_away (t_irc_channel *);
|
||||
extern void channel_check_away (t_irc_server *, t_irc_channel *);
|
||||
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 *);
|
||||
|
||||
/* nick functions (irc-nick.c) */
|
||||
|
||||
@@ -275,13 +288,15 @@ extern void nick_set_away (t_irc_channel *, t_irc_nick *, int);
|
||||
|
||||
/* DCC functions (irc-dcc.c) */
|
||||
|
||||
extern void dcc_redraw (int);
|
||||
extern void dcc_free (t_irc_dcc *);
|
||||
extern void dcc_close (t_irc_dcc *, int);
|
||||
extern void dcc_accept (t_irc_dcc *);
|
||||
extern t_irc_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, int,
|
||||
char *, char *, unsigned long);
|
||||
extern void dcc_send_request (t_irc_server *, int, char *, char *);
|
||||
extern void dcc_chat_sendf (t_irc_dcc *, char *, ...);
|
||||
extern void dcc_handle ();
|
||||
extern void dcc_send (t_irc_server *, char *, char *);
|
||||
extern void dcc_end ();
|
||||
|
||||
/* IRC display (irc-diplay.c) */
|
||||
|
||||
Reference in New Issue
Block a user