mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 15:23:26 +01:00
close file transfers on exit & fixes
This commit is contained in:
parent
8cf3043dd3
commit
04b394d6dd
@ -123,7 +123,7 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
|
||||
void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||
{
|
||||
if (num_file_senders >= MAX_FILES) {
|
||||
if (max_file_senders_index >= (MAX_FILES-1)) {
|
||||
wprintw(window,"Please wait for some of your outgoing file transfers to complete.\n");
|
||||
return;
|
||||
}
|
||||
@ -176,14 +176,14 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
|
||||
file_senders[i].file = file_to_send;
|
||||
file_senders[i].filenum = (uint8_t) filenum;
|
||||
file_senders[i].friendnum = self->num;
|
||||
file_senders[i].timestamp = (uint64_t)time(NULL);
|
||||
file_senders[i].timestamp = (uint64_t) time(NULL);
|
||||
file_senders[i].piecelen = fread(file_senders[i].nextpiece, 1,
|
||||
tox_filedata_size(m, self->num), file_to_send);
|
||||
|
||||
wprintw(window, "Sending file: '%s'\n", path);
|
||||
|
||||
if (i == num_file_senders)
|
||||
++num_file_senders;
|
||||
if (i == max_file_senders_index)
|
||||
++max_file_senders_index;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -239,10 +239,11 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key)
|
||||
} else
|
||||
/* Add printable chars to buffer and print on input space */
|
||||
#if HAVE_WIDECHAR
|
||||
if (iswprint(key)) {
|
||||
if (iswprint(key))
|
||||
#else
|
||||
if (isprint(key)) {
|
||||
if (isprint(key))
|
||||
#endif
|
||||
{
|
||||
if (ctx->pos < (MAX_STR_SIZE-1)) {
|
||||
mvwaddstr(self->window, y, x, wc_to_char(key));
|
||||
ctx->line[ctx->pos++] = key;
|
||||
|
20
src/main.c
20
src/main.c
@ -356,19 +356,19 @@ static void close_file_sender(int i)
|
||||
|
||||
int j;
|
||||
|
||||
for (j = num_file_senders; j > 0; --j) {
|
||||
for (j = max_file_senders_index; j > 0; --j) {
|
||||
if (file_senders[j-1].active)
|
||||
break;
|
||||
}
|
||||
|
||||
num_file_senders = j;
|
||||
max_file_senders_index = j;
|
||||
}
|
||||
|
||||
static void do_file_senders(Tox *m)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_file_senders; ++i) {
|
||||
for (i = 0; i < max_file_senders_index; ++i) {
|
||||
if (!file_senders[i].active)
|
||||
continue;
|
||||
|
||||
@ -419,9 +419,23 @@ static void do_file_senders(Tox *m)
|
||||
}
|
||||
}
|
||||
|
||||
/* This should only be called on exit */
|
||||
static void close_file_transfers(Tox *m)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < max_file_senders_index; ++i) {
|
||||
if (!file_senders[i].active)
|
||||
continue;
|
||||
|
||||
fclose(file_senders[i].file);
|
||||
}
|
||||
}
|
||||
|
||||
void exit_toxic(Tox *m)
|
||||
{
|
||||
store_data(m, DATA_FILE);
|
||||
close_file_transfers(m);
|
||||
free(DATA_FILE);
|
||||
free(SRVLIST_FILE);
|
||||
free(prompt->stb);
|
||||
|
@ -122,7 +122,7 @@ typedef struct {
|
||||
} FileSender;
|
||||
|
||||
FileSender file_senders[MAX_FILES];
|
||||
uint8_t num_file_senders;
|
||||
uint8_t max_file_senders_index;
|
||||
|
||||
typedef struct {
|
||||
uint8_t filenames[MAX_FILES][MAX_STR_SIZE];
|
||||
|
Loading…
Reference in New Issue
Block a user