summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-02-27 02:40:11 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-02-27 02:40:11 +0000
commit3686d92cb5aa0676601f2e8ee6a2cea74e215bbd (patch)
treeea32bbf47f3d7944fcaa30d2294b27eab28d5e74 /src/gui
parent64c33a829541791298486504e2c1ec451cf49508 (diff)
downloadweechat-3686d92cb5aa0676601f2e8ee6a2cea74e215bbd.zip
Added DCC CHAT (send & recv)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/curses/gui-display.c149
-rw-r--r--src/gui/curses/gui-input.c28
-rw-r--r--src/gui/gui.h11
3 files changed, 104 insertions, 84 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 679c90372..26481f740 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -706,33 +706,42 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
{
if (i >= ptr_win->win_chat_height - 1)
break;
- if ((ptr_dcc->type == DCC_FILE_RECV)
- || (ptr_dcc->type == DCC_FILE_SEND))
+
+ /* nickname and filename */
+ gui_window_set_color (ptr_win->win_chat,
+ (ptr_dcc == dcc_selected) ?
+ COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
+ mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s %s",
+ (ptr_dcc == dcc_selected) ? "***" : " ",
+ ptr_dcc->nick,
+ (DCC_IS_CHAT(ptr_dcc->type)) ?
+ _(ptr_dcc->filename) : ptr_dcc->filename);
+ if (DCC_IS_FILE(ptr_dcc->type))
{
- gui_window_set_color (ptr_win->win_chat,
- (ptr_dcc == dcc_selected) ?
- COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
- mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s %s",
- (ptr_dcc == dcc_selected) ? "***" : " ",
- ptr_dcc->nick, ptr_dcc->filename);
if (ptr_dcc->filename_suffix > 0)
wprintw (ptr_win->win_chat, " (.%d)",
ptr_dcc->filename_suffix);
+ }
+
+ /* status */
+ gui_window_set_color (ptr_win->win_chat,
+ (ptr_dcc == dcc_selected) ?
+ COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
+ mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ",
+ (ptr_dcc == dcc_selected) ? "***" : " ",
+ (DCC_IS_RECV(ptr_dcc->type)) ? "-->>" : "<<--");
+ gui_window_set_color (ptr_win->win_chat,
+ COLOR_DCC_WAITING + ptr_dcc->status);
+ wprintw (ptr_win->win_chat, "%-10s",
+ _(dcc_status_string[ptr_dcc->status]));
+
+ /* other infos */
+ if (DCC_IS_FILE(ptr_dcc->type))
+ {
gui_window_set_color (ptr_win->win_chat,
(ptr_dcc == dcc_selected) ?
- COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
- mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ",
- (ptr_dcc == dcc_selected) ? "***" : " ",
- (ptr_dcc->type == DCC_FILE_RECV) ? "-->>" : "<<--");
- gui_window_set_color (ptr_win->win_chat,
- COLOR_DCC_WAITING + ptr_dcc->status);
- wprintw (ptr_win->win_chat, "%-10s",
- dcc_status_string[ptr_dcc->status]);
- gui_window_set_color (ptr_win->win_chat,
- (ptr_dcc == dcc_selected) ?
- COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
- wprintw (ptr_win->win_chat, " [",
- dcc_status_string[ptr_dcc->status]);
+ COLOR_DCC_SELECTED : COLOR_WIN_CHAT);
+ wprintw (ptr_win->win_chat, " [");
if (ptr_dcc->size == 0)
num_bars = 10;
else
@@ -752,8 +761,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
else
num_unit = 3;
wprintw (ptr_win->win_chat, "] %3lu%% ",
- (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100),
- dcc_status_string[ptr_dcc->status]);
+ (unsigned long)(((long double)(ptr_dcc->pos)/(long double)(ptr_dcc->size))*100));
sprintf (format, "%s %%s / %s %%s",
unit_format[num_unit],
unit_format[num_unit]);
@@ -762,9 +770,14 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase)
unit_name[num_unit],
((long double) ptr_dcc->size) / ((long double)(unit_divide[num_unit])),
unit_name[num_unit]);
- ptr_win->dcc_last_displayed = ptr_dcc;
- i += 2;
}
+ else
+ {
+ wclrtoeol (ptr_win->win_chat);
+ }
+
+ ptr_win->dcc_last_displayed = ptr_dcc;
+ i += 2;
}
}
else
@@ -1089,42 +1102,61 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase)
else
wprintw (ptr_win->win_status, "%s",
CHANNEL(ptr_win->buffer)->name);
- if ((ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer)
- && (CHANNEL(ptr_win->buffer)->type == CHAT_CHANNEL))
+ if (ptr_win->buffer == CHANNEL(ptr_win->buffer)->buffer)
{
/* display channel modes */
- gui_window_set_color (ptr_win->win_status,
- COLOR_WIN_STATUS_DELIMITERS);
- wprintw (ptr_win->win_status, "(");
- gui_window_set_color (ptr_win->win_status,
- COLOR_WIN_STATUS);
- i = 0;
- first_mode = 1;
- while (CHANNEL(ptr_win->buffer)->modes[i])
+ if (CHANNEL(ptr_win->buffer)->type == CHAT_CHANNEL)
{
- if (CHANNEL(ptr_win->buffer)->modes[i] != ' ')
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS_DELIMITERS);
+ wprintw (ptr_win->win_status, "(");
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS);
+ i = 0;
+ first_mode = 1;
+ while (CHANNEL(ptr_win->buffer)->modes[i])
{
- if (first_mode)
+ if (CHANNEL(ptr_win->buffer)->modes[i] != ' ')
{
- wprintw (ptr_win->win_status, "+");
- first_mode = 0;
+ if (first_mode)
+ {
+ wprintw (ptr_win->win_status, "+");
+ first_mode = 0;
+ }
+ wprintw (ptr_win->win_status, "%c",
+ CHANNEL(ptr_win->buffer)->modes[i]);
}
- wprintw (ptr_win->win_status, "%c",
- CHANNEL(ptr_win->buffer)->modes[i]);
+ i++;
}
- i++;
+ if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ')
+ wprintw (ptr_win->win_status, ",%s",
+ CHANNEL(ptr_win->buffer)->key);
+ if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ')
+ wprintw (ptr_win->win_status, ",%d",
+ CHANNEL(ptr_win->buffer)->limit);
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS_DELIMITERS);
+ wprintw (ptr_win->win_status, ")");
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS);
+ }
+
+ /* display DCC if private is DCC CHAT */
+ if ((CHANNEL(ptr_win->buffer)->type == CHAT_PRIVATE)
+ && (CHANNEL(ptr_win->buffer)->dcc_chat))
+ {
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS_DELIMITERS);
+ wprintw (ptr_win->win_status, "(");
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS);
+ wprintw (ptr_win->win_status, "DCC");
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS_DELIMITERS);
+ wprintw (ptr_win->win_status, ")");
+ gui_window_set_color (ptr_win->win_status,
+ COLOR_WIN_STATUS);
}
- if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_KEY] != ' ')
- wprintw (ptr_win->win_status, ",%s",
- CHANNEL(ptr_win->buffer)->key);
- if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ')
- wprintw (ptr_win->win_status, ",%d",
- CHANNEL(ptr_win->buffer)->limit);
- gui_window_set_color (ptr_win->win_status,
- COLOR_WIN_STATUS_DELIMITERS);
- wprintw (ptr_win->win_status, ")");
- gui_window_set_color (ptr_win->win_status,
- COLOR_WIN_STATUS);
}
wprintw (ptr_win->win_status, " ");
}
@@ -1393,8 +1425,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
switch (dcc_selected->status)
{
case DCC_WAITING:
- if ((dcc_selected->type == DCC_CHAT_RECV)
- || (dcc_selected->type == DCC_FILE_RECV))
+ if (DCC_IS_RECV(dcc_selected->type))
wprintw (ptr_win->win_input, _(" [A] Accept"));
wprintw (ptr_win->win_input, _(" [C] Cancel"));
break;
@@ -2271,15 +2302,11 @@ gui_end ()
/* delete all buffers */
while (gui_buffers)
- {
gui_buffer_free (gui_buffers, 0);
- }
/* delete all windows */
while (gui_windows)
- {
gui_window_free (gui_windows);
- }
/* delete general history */
history_general_free ();
@@ -2355,11 +2382,11 @@ gui_add_message (t_gui_buffer *buffer, int type, int color, char *message)
}
/*
- * gui_printf_color_type: display a message in a buffer
+ * gui_printf_type_color: display a message in a buffer
*/
void
-gui_printf_color_type (t_gui_buffer *buffer, int type, int color, char *message, ...)
+gui_printf_type_color (t_gui_buffer *buffer, int type, int color, char *message, ...)
{
static char buf[8192];
char timestamp[16];
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index ca29e837b..9aff7153d 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -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);
}
}
diff --git a/src/gui/gui.h b/src/gui/gui.h
index 7c7ddbc6e..6885ecf3d 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -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 */