diff options
Diffstat (limited to 'toxcore/tox.c')
-rw-r--r-- | toxcore/tox.c | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index 1d7118be..21e8bf75 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -473,7 +473,90 @@ int tox_group_message_send(void *tox, int groupnumber, uint8_t *message, uint32_ | |||
473 | 473 | ||
474 | 474 | ||
475 | 475 | ||
476 | /******************END OF GROUP CHAT FUNCTIONS************************/ | 476 | /****************FILE SENDING FUNCTIONS*****************/ |
477 | |||
478 | |||
479 | /* Set the callback for file send requests. | ||
480 | * | ||
481 | * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length, void *userdata) | ||
482 | */ | ||
483 | void tox_callback_file_sendrequest(void *tox, void (*function)(Messenger *tox, int, uint8_t, uint64_t, uint8_t *, | ||
484 | uint16_t, | ||
485 | void *), void *userdata) | ||
486 | { | ||
487 | Messenger *m = tox; | ||
488 | callback_file_sendrequest(m, function, userdata); | ||
489 | } | ||
490 | /* Set the callback for file control requests. | ||
491 | * | ||
492 | * Function(Tox *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t control_type, uint8_t *data, uint16_t length, void *userdata) | ||
493 | * | ||
494 | */ | ||
495 | void tox_callback_file_control(void *tox, void (*function)(Messenger *tox, int, uint8_t, uint8_t, uint8_t, uint8_t *, | ||
496 | uint16_t, void *), void *userdata) | ||
497 | { | ||
498 | Messenger *m = tox; | ||
499 | callback_file_control(m, function, userdata); | ||
500 | } | ||
501 | /* Set the callback for file data. | ||
502 | * | ||
503 | * Function(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length, void *userdata) | ||
504 | * | ||
505 | */ | ||
506 | void tox_callback_file_data(void *tox, void (*function)(Messenger *tox, int, uint8_t, uint8_t *, uint16_t length, | ||
507 | void *), | ||
508 | void *userdata) | ||
509 | |||
510 | { | ||
511 | Messenger *m = tox; | ||
512 | callback_file_data(m, function, userdata); | ||
513 | } | ||
514 | /* Send a file send request. | ||
515 | * Maximum filename length is 255 bytes. | ||
516 | * return file number on success | ||
517 | * return -1 on failure | ||
518 | */ | ||
519 | int tox_new_filesender(void *tox, int friendnumber, uint64_t filesize, uint8_t *filename, uint16_t filename_length) | ||
520 | { | ||
521 | Messenger *m = tox; | ||
522 | return new_filesender(m, friendnumber, filesize, filename, filename_length); | ||
523 | } | ||
524 | /* Send a file control request. | ||
525 | * send_receive is 0 if we want the control packet to target a sending file, 1 if it targets a receiving file. | ||
526 | * | ||
527 | * return 1 on success | ||
528 | * return 0 on failure | ||
529 | */ | ||
530 | int tox_file_sendcontrol(void *tox, int friendnumber, uint8_t send_receive, uint8_t filenumber, uint8_t message_id, | ||
531 | uint8_t *data, uint16_t length) | ||
532 | { | ||
533 | Messenger *m = tox; | ||
534 | return file_control(m, friendnumber, send_receive, filenumber, message_id, data, length); | ||
535 | } | ||
536 | /* Send file data. | ||
537 | * | ||
538 | * return 1 on success | ||
539 | * return 0 on failure | ||
540 | */ | ||
541 | int tox_file_senddata(void *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length) | ||
542 | { | ||
543 | Messenger *m = tox; | ||
544 | return file_data(m, friendnumber, filenumber, data, length); | ||
545 | } | ||
546 | /* Give the number of bytes left to be sent/received. | ||
547 | * | ||
548 | * send_receive is 0 if we want the sending files, 1 if we want the receiving. | ||
549 | * | ||
550 | * return number of bytes remaining to be sent/received on success | ||
551 | * return 0 on failure | ||
552 | */ | ||
553 | uint64_t tox_file_dataremaining(void *tox, int friendnumber, uint8_t filenumber, uint8_t send_receive) | ||
554 | { | ||
555 | Messenger *m = tox; | ||
556 | return file_dataremaining(m, friendnumber, filenumber, send_receive); | ||
557 | } | ||
558 | |||
559 | /***************END OF FILE SENDING FUNCTIONS******************/ | ||
477 | 560 | ||
478 | /* Use these functions to bootstrap the client. | 561 | /* Use these functions to bootstrap the client. |
479 | * Sends a get nodes request to the given node with ip port and public_key. | 562 | * Sends a get nodes request to the given node with ip port and public_key. |