diff --git a/src/chat_commands.c b/src/chat_commands.c index f799abe..54100c7 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -166,7 +166,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv if (!file_senders[i].active) { memcpy(file_senders[i].pathname, path, path_len + 1); file_senders[i].active = true; - file_senders[i].chatwin = window; + file_senders[i].toxwin = self; file_senders[i].file = file_to_send; file_senders[i].filenum = (uint8_t) filenum; file_senders[i].friendnum = self->num; diff --git a/src/main.c b/src/main.c index 6b808af..a9f1095 100644 --- a/src/main.c +++ b/src/main.c @@ -379,7 +379,13 @@ static void do_file_senders(Tox *m) /* If file transfer has timed out kill transfer and send kill control */ if (timed_out(file_senders[i].timestamp, current_time, TIMEOUT_FILESENDER)) { - wprintw(file_senders[i].chatwin, "File transfer for '%s' timed out.\n", pathname); + ChatContext *ctx = (ChatContext *) file_senders[i].toxwin->chatwin; + + if (ctx != NULL) { + wprintw(ctx->history, "File transfer for '%s' timed out.\n", pathname); + alert_window(file_senders[i].toxwin); + } + tox_file_sendcontrol(m, friendnum, 0, filenum, TOX_FILECONTROL_KILL, 0, 0); close_file_sender(i); continue; @@ -397,7 +403,13 @@ static void do_file_senders(Tox *m) tox_filedata_size(m, friendnum), fp); if (file_senders[i].piecelen == 0) { - wprintw(file_senders[i].chatwin, "File '%s' successfuly sent.\n", pathname); + ChatContext *ctx = (ChatContext *) file_senders[i].toxwin->chatwin; + + if (ctx != NULL) { + wprintw(ctx->history, "File '%s' successfuly sent.\n", pathname); + alert_window(file_senders[i].toxwin); + } + tox_file_sendcontrol(m, friendnum, 0, filenum, TOX_FILECONTROL_FINISHED, 0, 0); close_file_sender(i); break; diff --git a/src/toxic_windows.h b/src/toxic_windows.h index f2d5cad..8b92ec7 100644 --- a/src/toxic_windows.h +++ b/src/toxic_windows.h @@ -107,7 +107,7 @@ typedef struct { typedef struct { FILE *file; - WINDOW *chatwin; + ToxWindow *toxwin; int friendnum; bool active; uint8_t filenum;