summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/tox.c13
-rw-r--r--toxcore/tox.h9
2 files changed, 20 insertions, 2 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index ea19753f..ded2da6d 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -359,7 +359,7 @@ void tox_callback_statusmessage(Tox *tox, void (*function)(Messenger *tox, int,
359void tox_callback_userstatus(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata) 359void tox_callback_userstatus(Tox *tox, void (*_function)(Tox *tox, int, TOX_USERSTATUS, void *), void *userdata)
360{ 360{
361 Messenger *m = tox; 361 Messenger *m = tox;
362 typedef void (*function_type)(Messenger *, int, USERSTATUS, void *); 362 typedef void (*function_type)(Messenger *, int, USERSTATUS, void *);
363 function_type function = (function_type)_function; 363 function_type function = (function_type)_function;
364 m_callback_userstatus(m, function, userdata); 364 m_callback_userstatus(m, function, userdata);
365} 365}
@@ -551,6 +551,17 @@ int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *d
551 Messenger *m = tox; 551 Messenger *m = tox;
552 return file_data(m, friendnumber, filenumber, data, length); 552 return file_data(m, friendnumber, filenumber, data, length);
553} 553}
554
555/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata()
556 *
557 * return size on success
558 * return 0 on failure (currently will never return 0)
559 */
560int tox_filedata_size(Tox *tox, int friendnumber)
561{
562 return MAX_DATA_SIZE - crypto_box_MACBYTES - 3;
563}
564
554/* Give the number of bytes left to be sent/received. 565/* Give the number of bytes left to be sent/received.
555 * 566 *
556 * send_receive is 0 if we want the sending files, 1 if we want the receiving. 567 * send_receive is 0 if we want the sending files, 1 if we want the receiving.
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 3594b1c1..db4e6b57 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -435,7 +435,7 @@ int tox_group_message_send(Tox *tox, int groupnumber, uint8_t *message, uint32_t
435 * HOW TO SEND FILES CORRECTLY: 435 * HOW TO SEND FILES CORRECTLY:
436 * 1. Use tox_new_filesender(...) to create a new file sender. 436 * 1. Use tox_new_filesender(...) to create a new file sender.
437 * 2. Wait for the callback set with tox_callback_file_control(...) to be called with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT 437 * 2. Wait for the callback set with tox_callback_file_control(...) to be called with receive_send == 1 and control_type == TOX_FILECONTROL_ACCEPT
438 * 3. Send the data with tox_file_senddata(...) 438 * 3. Send the data with tox_file_senddata(...) with chunk size tox_filedata_size(...)
439 * 4. When sending is done, send a tox_file_sendcontrol(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED 439 * 4. When sending is done, send a tox_file_sendcontrol(...) with send_receive = 0 and message_id = TOX_FILECONTROL_FINISHED
440 * 440 *
441 * HOW TO RECEIVE FILES CORRECTLY: 441 * HOW TO RECEIVE FILES CORRECTLY:
@@ -508,6 +508,13 @@ int tox_file_sendcontrol(Tox *tox, int friendnumber, uint8_t send_receive, uint8
508 */ 508 */
509int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length); 509int tox_file_senddata(Tox *tox, int friendnumber, uint8_t filenumber, uint8_t *data, uint16_t length);
510 510
511/* Returns the recommended/maximum size of the filedata you send with tox_file_senddata()
512 *
513 * return size on success
514 * return 0 on failure (currently will never return 0)
515 */
516int tox_filedata_size(Tox *tox, int friendnumber);
517
511/* Give the number of bytes left to be sent/received. 518/* Give the number of bytes left to be sent/received.
512 * 519 *
513 * send_receive is 0 if we want the sending files, 1 if we want the receiving. 520 * send_receive is 0 if we want the sending files, 1 if we want the receiving.