mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
When friend goes offline all his file transfers get removed.
This is now documented in the API. Ported programs in testing/ to this behaviour.
This commit is contained in:
parent
5b7cbc8956
commit
b9e747fd50
@ -1195,6 +1195,22 @@ void write_file(Tox *tox, uint32_t friendnumber, uint32_t filenumber, uint64_t p
|
|||||||
fclose(pFile);
|
fclose(pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata)
|
||||||
|
{
|
||||||
|
if (status)
|
||||||
|
printf("\nOther went online.\n");
|
||||||
|
else {
|
||||||
|
printf("\nOther went offline.\n");
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_FILE_SENDERS; ++i)
|
||||||
|
if (file_senders[i].file != 0 && file_senders[i].friendnum == friend_number) {
|
||||||
|
fclose(file_senders[i].file);
|
||||||
|
file_senders[i].file = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char timeout_getch(Tox *m)
|
char timeout_getch(Tox *m)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
@ -1274,6 +1290,7 @@ int main(int argc, char *argv[])
|
|||||||
tox_callback_file_recv(m, file_request_accept, NULL);
|
tox_callback_file_recv(m, file_request_accept, NULL);
|
||||||
tox_callback_file_request_chunk(m, tox_file_request_chunk, NULL);
|
tox_callback_file_request_chunk(m, tox_file_request_chunk, NULL);
|
||||||
tox_callback_group_namelist_change(m, print_groupnamelistchange, NULL);
|
tox_callback_group_namelist_change(m, print_groupnamelistchange, NULL);
|
||||||
|
tox_callback_friend_connection_status(tox, print_online, NULL);
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
|
@ -211,8 +211,22 @@ void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *
|
|||||||
{
|
{
|
||||||
if (status)
|
if (status)
|
||||||
printf("\nOther went online.\n");
|
printf("\nOther went online.\n");
|
||||||
else
|
else {
|
||||||
printf("\nOther went offline.\n");
|
printf("\nOther went offline.\n");
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_FILE_SENDERS; ++i) {
|
||||||
|
if (file_senders[i].file != 0) {
|
||||||
|
fclose(file_senders[i].file);
|
||||||
|
file_senders[i].file = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_recv[i].file != 0) {
|
||||||
|
fclose(file_recv[i].file);
|
||||||
|
file_recv[i].file = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -1655,6 +1655,9 @@ typedef enum TOX_ERR_FILE_SEND {
|
|||||||
* File transmission occurs in chunks, which are requested through the
|
* File transmission occurs in chunks, which are requested through the
|
||||||
* `file_request_chunk` event.
|
* `file_request_chunk` event.
|
||||||
*
|
*
|
||||||
|
* When a friend goes offline, all file transfers associated with the friend are
|
||||||
|
* purged from core.
|
||||||
|
*
|
||||||
* If the file contents change during a transfer, the behaviour is unspecified
|
* If the file contents change during a transfer, the behaviour is unspecified
|
||||||
* in general. What will actually happen depends on the mode in which the file
|
* in general. What will actually happen depends on the mode in which the file
|
||||||
* was modified and how the client determines the file size.
|
* was modified and how the client determines the file size.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user