summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/curses/gui-display.c41
-rw-r--r--src/gui/curses/gui-input.c59
-rw-r--r--src/irc/irc-dcc.c22
-rw-r--r--src/irc/irc.h3
4 files changed, 119 insertions, 6 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c
index 15b229040..e57b7ba44 100644
--- a/src/gui/curses/gui-display.c
+++ b/src/gui/curses/gui-display.c
@@ -1134,6 +1134,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
char format[32];
char *ptr_nickname;
int input_width;
+ t_dcc *dcc_selected;
if (!gui_ok)
return;
@@ -1202,8 +1203,44 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase)
{
if (buffer->dcc)
{
- snprintf (format, 32, "%%-%ds", input_width);
- mvwprintw (ptr_win->win_input, 0, 0, format, "");
+ dcc_selected = (ptr_win->dcc_selected) ? (t_dcc *) ptr_win->dcc_selected : dcc_list;
+ if (dcc_selected)
+ {
+ switch (dcc_selected->status)
+ {
+ case DCC_WAITING:
+ if ((dcc_selected->type == DCC_CHAT_RECV)
+ || (dcc_selected->type == DCC_FILE_RECV))
+ {
+ mvwprintw (ptr_win->win_input, 0, 0,
+ _(" [A] Accept"));
+ wprintw (ptr_win->win_input, _(" [C] Cancel"));
+ wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
+ }
+ else
+ {
+ mvwprintw (ptr_win->win_input, 0, 0,
+ _(" [C] Cancel"));
+ wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
+ }
+ break;
+ case DCC_CONNECTING:
+ case DCC_ACTIVE:
+ mvwprintw (ptr_win->win_input, 0, 0,
+ _(" [C] Cancel"));
+ wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
+ break;
+ case DCC_DONE:
+ case DCC_FAILED:
+ case DCC_ABORTED:
+ mvwprintw (ptr_win->win_input, 0, 0,
+ _(" [R] Remove"));
+ wprintw (ptr_win->win_input, _(" [Q] Close DCC view"));
+ break;
+ }
+ }
+ else
+ mvwprintw (ptr_win->win_input, 0, 0, _(" [Q] Close DCC view"));
wclrtoeol (ptr_win->win_input);
if (ptr_win == gui_current_window)
move (ptr_win->win_y + ptr_win->win_height - 1,
diff --git a/src/gui/curses/gui-input.c b/src/gui/curses/gui-input.c
index b37d6c816..b94e8d9d8 100644
--- a/src/gui/curses/gui-input.c
+++ b/src/gui/curses/gui-input.c
@@ -52,6 +52,7 @@ gui_read_keyb ()
int key, i;
t_gui_buffer *ptr_buffer;
char new_char[2];
+ t_dcc *dcc_selected;
key = getch ();
if (key != ERR)
@@ -104,6 +105,7 @@ gui_read_keyb ()
gui_current_window->dcc_selected =
((t_dcc *)(gui_current_window->dcc_selected))->prev_dcc;
gui_draw_buffer_chat (gui_current_window->buffer, 1);
+ gui_draw_buffer_input (gui_current_window->buffer, 1);
}
}
}
@@ -160,6 +162,7 @@ gui_read_keyb ()
gui_current_window->dcc_selected =
dcc_list->next_dcc;
gui_draw_buffer_chat (gui_current_window->buffer, 1);
+ gui_draw_buffer_input (gui_current_window->buffer, 1);
}
}
}
@@ -500,7 +503,61 @@ gui_read_keyb ()
break;
/* other key => add to input buffer */
default:
- if (!gui_current_window->buffer->dcc)
+ if (gui_current_window->buffer->dcc)
+ {
+ dcc_selected = (gui_current_window->dcc_selected) ?
+ (t_dcc *) gui_current_window->dcc_selected : dcc_list;
+ switch (key)
+ {
+ /* accept DCC */
+ 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_accept (dcc_selected);
+ }
+ break;
+ /* cancel DCC */
+ case 'c':
+ case 'C':
+ if (dcc_selected
+ && ((dcc_selected->status == DCC_WAITING)
+ || (dcc_selected->status == DCC_CONNECTING)
+ || (dcc_selected->status == DCC_ACTIVE)))
+ {
+ dcc_close (dcc_selected, DCC_ABORTED);
+ gui_redraw_buffer (gui_current_window->buffer);
+ }
+ break;
+ /* close DCC window */
+ case 'q':
+ case 'Q':
+ gui_buffer_free (gui_current_window->buffer, 1);
+ break;
+ /* remove from DCC list */
+ case 'r':
+ case 'R':
+ if (dcc_selected
+ && (((dcc_selected->type == DCC_CHAT_RECV)
+ || (dcc_selected->type == DCC_FILE_RECV))
+ && ((dcc_selected->status == DCC_DONE)
+ || (dcc_selected->status == DCC_FAILED)
+ || (dcc_selected->status == DCC_ABORTED))))
+ {
+ if (dcc_selected->next_dcc)
+ gui_current_window->dcc_selected = dcc_selected->next_dcc;
+ else
+ gui_current_window->dcc_selected = NULL;
+ dcc_free (dcc_selected);
+ gui_redraw_buffer (gui_current_window->buffer);
+ }
+ break;
+ }
+ }
+ else
{
/*gui_printf (gui_current_window->buffer,
"[Debug] key pressed = %d, hex = %02X, octal = %o\n", key, key, key);*/
diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c
index d338bd82b..9b8e115cd 100644
--- a/src/irc/irc-dcc.c
+++ b/src/irc/irc-dcc.c
@@ -55,7 +55,7 @@ dcc_redraw (int highlight)
gui_draw_buffer_chat (gui_get_dcc_buffer (), 0);
if (highlight)
{
- hotlist_add (1, gui_get_dcc_buffer ());
+ hotlist_add (highlight, gui_get_dcc_buffer ());
gui_draw_buffer_status (gui_current_window->buffer, 0);
}
}
@@ -92,16 +92,32 @@ dcc_send ()
}
/*
- * dcc_free: free DCC struct
+ * dcc_free: free DCC struct and remove it from list
*/
void
dcc_free (t_dcc *ptr_dcc)
{
+ t_dcc *new_dcc_list;
+
+ if (ptr_dcc->prev_dcc)
+ {
+ (ptr_dcc->prev_dcc)->next_dcc = ptr_dcc->next_dcc;
+ new_dcc_list = dcc_list;
+ }
+ else
+ new_dcc_list = ptr_dcc->next_dcc;
+
+ if (ptr_dcc->next_dcc)
+ (ptr_dcc->next_dcc)->prev_dcc = ptr_dcc->prev_dcc;
+
if (ptr_dcc->nick)
free (ptr_dcc->nick);
if (ptr_dcc->filename)
free (ptr_dcc->filename);
+
+ free (ptr_dcc);
+ dcc_list = new_dcc_list;
}
/*
@@ -276,7 +292,7 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic
|| ( (type == DCC_FILE_RECV) && (cfg_dcc_auto_accept_files) ) )
dcc_accept (new_dcc);
else
- hotlist_add (2, gui_get_dcc_buffer ());
+ dcc_redraw (2);
gui_draw_buffer_status (gui_current_window->buffer, 0);
return new_dcc;
diff --git a/src/irc/irc.h b/src/irc/irc.h
index 9ce6238f1..b90bd7654 100644
--- a/src/irc/irc.h
+++ b/src/irc/irc.h
@@ -248,6 +248,9 @@ extern int nick_get_max_length (t_irc_channel *);
/* DCC functions (irc-dcc.c) */
extern void dcc_send ();
+extern void dcc_free (t_dcc *);
+extern void dcc_close (t_dcc *, int);
+extern void dcc_accept (t_dcc *);
extern t_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, char *,
unsigned int);
extern void dcc_handle ();