1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 02:33:02 +01:00

kill file transfer if writing fails

This commit is contained in:
Jfreegman 2013-11-29 19:26:59 -05:00
parent 57c2872b75
commit a02bbfa643
3 changed files with 10 additions and 3 deletions

View File

@ -188,7 +188,12 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int num, uint8_t receive
break;
case TOX_FILECONTROL_KILL:
wprintw(ctx->history, "File transfer for '%s' failed.\n", filename);
friends[num].file_receiver.pending[filenum] = false;
if (receive_send == 1)
friends[num].file_receiver.pending[filenum] = false;
else
close_file_sender(filenum);
break;
case TOX_FILECONTROL_FINISHED:
wprintw(ctx->history, "File transfer for '%s' complete.\n", filename);
@ -214,6 +219,7 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, u
wattron(ctx->history, COLOR_PAIR(RED));
wprintw(ctx->history, "* Error writing to file.\n");
wattroff(ctx->history, COLOR_PAIR(RED));
tox_file_send_control(m, num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
return;
}
@ -221,6 +227,7 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, u
wattron(ctx->history, COLOR_PAIR(RED));
wprintw(ctx->history, "* Error writing to file.\n");
wattroff(ctx->history, COLOR_PAIR(RED));
tox_file_send_control(m, num, 1, filenum, TOX_FILECONTROL_KILL, 0, 0);
}
fclose(file_to_save);

View File

@ -18,7 +18,7 @@
extern char *DATA_FILE;
extern int store_data(Tox *m, char *path);
GroupChat groupchats[MAX_GROUPCHAT_NUM];
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
int num_groupchats = 0;
static int max_groupchat_index = 0;

View File

@ -352,7 +352,7 @@ static void load_data(Tox *m, char *path)
}
}
static void close_file_sender(int i)
void close_file_sender(int i)
{
fclose(file_senders[i].file);
memset(&file_senders[i], 0, sizeof(FileSender));