summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h52
1 files changed, 40 insertions, 12 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index f1b8b893..b255de5e 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -255,6 +255,11 @@ bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
255 */ 255 */
256#define TOX_HASH_LENGTH /*crypto_hash_sha256_BYTES*/ 32 256#define TOX_HASH_LENGTH /*crypto_hash_sha256_BYTES*/ 32
257 257
258/**
259 * The number of bytes in a file id.
260 */
261#define TOX_FILE_ID_LENGTH 32
262
258/******************************************************************************* 263/*******************************************************************************
259 * 264 *
260 * :: Global enumerations 265 * :: Global enumerations
@@ -1412,9 +1417,9 @@ enum TOX_FILE_KIND {
1412 * 1417 *
1413 * Clients who receive avatar send requests can reject it (by sending 1418 * Clients who receive avatar send requests can reject it (by sending
1414 * TOX_FILE_CONTROL_CANCEL before any other controls), or accept it (by 1419 * TOX_FILE_CONTROL_CANCEL before any other controls), or accept it (by
1415 * sending TOX_FILE_CONTROL_RESUME). The filename of length TOX_HASH_LENGTH bytes 1420 * sending TOX_FILE_CONTROL_RESUME). The file_id of length TOX_HASH_LENGTH bytes
1416 * will contain the hash. A client can compare this hash with a 1421 * (same length as TOX_FILE_ID_LENGTH) will contain the hash. A client can compare
1417 * saved hash and send TOX_FILE_CONTROL_CANCEL to terminate the avatar 1422 * this hash with a saved hash and send TOX_FILE_CONTROL_CANCEL to terminate the avatar
1418 * transfer if it matches. 1423 * transfer if it matches.
1419 */ 1424 */
1420 TOX_FILE_KIND_AVATAR 1425 TOX_FILE_KIND_AVATAR
@@ -1534,6 +1539,32 @@ typedef void tox_file_recv_control_cb(Tox *tox, uint32_t friend_number, uint32_t
1534void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function, void *user_data); 1539void tox_callback_file_recv_control(Tox *tox, tox_file_recv_control_cb *function, void *user_data);
1535 1540
1536 1541
1542typedef enum TOX_ERR_FILE_GET {
1543 TOX_ERR_FILE_GET_OK,
1544 /**
1545 * The friend_number passed did not designate a valid friend.
1546 */
1547 TOX_ERR_FILE_GET_FRIEND_NOT_FOUND,
1548 /**
1549 * No file transfer with the given file number was found for the given friend.
1550 */
1551 TOX_ERR_FILE_GET_NOT_FOUND
1552} TOX_ERR_FILE_GET;
1553
1554/**
1555 * Copy the file id associated to the file transfer to a byte array.
1556 *
1557 * @param friend_number The friend number of the friend the file is being
1558 * transferred to.
1559 * @param file_number The friend-specific identifier for the file transfer.
1560 * @param file_id A memory region of at least TOX_FILE_ID_LENGTH bytes. If
1561 * this parameter is NULL, this function has no effect.
1562 *
1563 * @return true on success.
1564 */
1565bool tox_file_get_file_id(const Tox *tox, uint32_t friend_number, uint32_t file_number, uint8_t *file_id,
1566 TOX_ERR_FILE_GET *error);
1567
1537/******************************************************************************* 1568/*******************************************************************************
1538 * 1569 *
1539 * :: File transmission: sending 1570 * :: File transmission: sending
@@ -1557,8 +1588,7 @@ typedef enum TOX_ERR_FILE_SEND {
1557 */ 1588 */
1558 TOX_ERR_FILE_SEND_NAME_EMPTY, 1589 TOX_ERR_FILE_SEND_NAME_EMPTY,
1559 /** 1590 /**
1560 * Filename length exceeded 255 bytes or if kind was equal to TOX_FILE_KIND_AVATAR 1591 * Filename length exceeded 255 bytes.
1561 * the length was not TOX_HASH_LENGTH.
1562 */ 1592 */
1563 TOX_ERR_FILE_SEND_NAME_INVALID_LENGTH, 1593 TOX_ERR_FILE_SEND_NAME_INVALID_LENGTH,
1564 /** 1594 /**
@@ -1581,11 +1611,6 @@ typedef enum TOX_ERR_FILE_SEND {
1581 * File transmission occurs in chunks, which are requested through the 1611 * File transmission occurs in chunks, which are requested through the
1582 * `file_request_chunk` event. 1612 * `file_request_chunk` event.
1583 * 1613 *
1584 * File numbers are stable across tox_save/tox_load cycles, so that file
1585 * transfers can be resumed when a client restarts. The client needs to
1586 * associate (friend Public Key, file number) with the local path of the file and
1587 * persist this information to support resuming of transfers across restarts.
1588 *
1589 * If the file contents change during a transfer, the behaviour is unspecified 1614 * If the file contents change during a transfer, the behaviour is unspecified
1590 * in general. What will actually happen depends on the mode in which the file 1615 * in general. What will actually happen depends on the mode in which the file
1591 * was modified and how the client determines the file size. 1616 * was modified and how the client determines the file size.
@@ -1616,6 +1641,9 @@ typedef enum TOX_ERR_FILE_SEND {
1616 * @param kind The meaning of the file to be sent. 1641 * @param kind The meaning of the file to be sent.
1617 * @param file_size Size in bytes of the file the client wants to send, 0 if 1642 * @param file_size Size in bytes of the file the client wants to send, 0 if
1618 * unknown or streaming. 1643 * unknown or streaming.
1644 * @param file_id A file identifier of length TOX_FILE_ID_LENGTH that can be used to
1645 * uniquely identify file transfers across core restarts. If NULL, a random one will
1646 * be generated by core. It can then be obtained by using tox_file_get_file_id().
1619 * @param filename Name of the file. Does not need to be the actual name. This 1647 * @param filename Name of the file. Does not need to be the actual name. This
1620 * name will be sent along with the file send request. 1648 * name will be sent along with the file send request.
1621 * @param filename_length Size in bytes of the filename. 1649 * @param filename_length Size in bytes of the filename.
@@ -1624,8 +1652,8 @@ typedef enum TOX_ERR_FILE_SEND {
1624 * number is per friend. File numbers are reused after a transfer terminates. 1652 * number is per friend. File numbers are reused after a transfer terminates.
1625 * on failure, this function returns UINT32_MAX. 1653 * on failure, this function returns UINT32_MAX.
1626 */ 1654 */
1627uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *filename, 1655uint32_t tox_file_send(Tox *tox, uint32_t friend_number, uint32_t kind, uint64_t file_size, const uint8_t *file_id,
1628 size_t filename_length, TOX_ERR_FILE_SEND *error); 1656 const uint8_t *filename, size_t filename_length, TOX_ERR_FILE_SEND *error);
1629 1657
1630 1658
1631typedef enum TOX_ERR_FILE_SEND_CHUNK { 1659typedef enum TOX_ERR_FILE_SEND_CHUNK {