summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h67
1 files changed, 52 insertions, 15 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 4afdf7c3..14c9f616 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -352,6 +352,29 @@ typedef enum TOX_PROXY_TYPE {
352 352
353 353
354/** 354/**
355 * Type of savedata to create the Tox instance from.
356 */
357typedef enum TOX_SAVEDATA_TYPE {
358
359 /**
360 * No savedata.
361 */
362 TOX_SAVEDATA_TYPE_NONE,
363
364 /**
365 * Savedata is one that was obtained from tox_get_savedata
366 */
367 TOX_SAVEDATA_TYPE_TOX_SAVE,
368
369 /**
370 * Savedata is a secret key of length TOX_SECRET_KEY_SIZE
371 */
372 TOX_SAVEDATA_TYPE_SECRET_KEY,
373
374} TOX_SAVEDATA_TYPE;
375
376
377/**
355 * This struct contains all the startup options for Tox. You can either allocate 378 * This struct contains all the startup options for Tox. You can either allocate
356 * this object yourself, and pass it to tox_options_default, or call 379 * this object yourself, and pass it to tox_options_default, or call
357 * tox_options_new to get a new default options object. 380 * tox_options_new to get a new default options object.
@@ -432,6 +455,24 @@ struct Tox_Options {
432 */ 455 */
433 uint16_t tcp_port; 456 uint16_t tcp_port;
434 457
458
459 /**
460 * The type of savedata to load from.
461 */
462 TOX_SAVEDATA_TYPE savedata_type;
463
464
465 /**
466 * The savedata.
467 */
468 const uint8_t *savedata_data;
469
470
471 /**
472 * The length of the savedata.
473 */
474 size_t savedata_length;
475
435}; 476};
436 477
437 478
@@ -561,21 +602,17 @@ typedef enum TOX_ERR_NEW {
561 * This function will bring the instance into a valid state. Running the event 602 * This function will bring the instance into a valid state. Running the event
562 * loop with a new instance will operate correctly. 603 * loop with a new instance will operate correctly.
563 * 604 *
564 * If the data parameter is not NULL, this function will load the Tox instance
565 * from a byte array previously filled by tox_get_savedata.
566 *
567 * If loading failed or succeeded only partially, the new or partially loaded 605 * If loading failed or succeeded only partially, the new or partially loaded
568 * instance is returned and an error code is set. 606 * instance is returned and an error code is set.
569 * 607 *
570 * @param options An options object as described above. If this parameter is 608 * @param options An options object as described above. If this parameter is
571 * NULL, the default options are used. 609 * NULL, the default options are used.
572 * @param data A byte array containing data previously stored by tox_get_savedata.
573 * @param length The length of the byte array data. If this parameter is 0, the
574 * data parameter is ignored.
575 * 610 *
576 * @see tox_iterate for the event loop. 611 * @see tox_iterate for the event loop.
612 *
613 * @return A new Tox instance pointer on success or NULL on failure.
577 */ 614 */
578Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t length, TOX_ERR_NEW *error); 615Tox *tox_new(const struct Tox_Options *options, TOX_ERR_NEW *error);
579 616
580/** 617/**
581 * Releases all resources associated with the Tox instance and disconnects from 618 * Releases all resources associated with the Tox instance and disconnects from
@@ -642,13 +679,8 @@ typedef enum TOX_ERR_BOOTSTRAP {
642 * Sends a "get nodes" request to the given bootstrap node with IP, port, and 679 * Sends a "get nodes" request to the given bootstrap node with IP, port, and
643 * public key to setup connections. 680 * public key to setup connections.
644 * 681 *
645 * This function will attempt to connect to the node using UDP and TCP at the 682 * This function will attempt to connect to the node using UDP. You must use
646 * same time. 683 * this function even if Tox_Options.udp_enabled was set to false.
647 *
648 * Tox will use the node as a TCP relay in case Tox_Options.udp_enabled was
649 * false, and also to connect to friends that are in TCP-only mode. Tox will
650 * also use the TCP connection when NAT hole punching is slow, and later switch
651 * to UDP if hole punching succeeds.
652 * 684 *
653 * @param address The hostname or IP address (IPv4 or IPv6) of the node. 685 * @param address The hostname or IP address (IPv4 or IPv6) of the node.
654 * @param port The port on the host on which the bootstrap Tox instance is 686 * @param port The port on the host on which the bootstrap Tox instance is
@@ -1559,7 +1591,7 @@ enum TOX_FILE_KIND {
1559 TOX_FILE_KIND_DATA, 1591 TOX_FILE_KIND_DATA,
1560 1592
1561 /** 1593 /**
1562 * Avatar filename. This consists of tox_hash(image). 1594 * Avatar file_id. This consists of tox_hash(image).
1563 * Avatar data. This consists of the image data. 1595 * Avatar data. This consists of the image data.
1564 * 1596 *
1565 * Avatars can be sent at any time the client wishes. Generally, a client will 1597 * Avatars can be sent at any time the client wishes. Generally, a client will
@@ -1749,6 +1781,11 @@ typedef enum TOX_ERR_FILE_GET {
1749 TOX_ERR_FILE_GET_OK, 1781 TOX_ERR_FILE_GET_OK,
1750 1782
1751 /** 1783 /**
1784 * One of the arguments to the function was NULL when it was not expected.
1785 */
1786 TOX_ERR_FILE_GET_NULL,
1787
1788 /**
1752 * The friend_number passed did not designate a valid friend. 1789 * The friend_number passed did not designate a valid friend.
1753 */ 1790 */
1754 TOX_ERR_FILE_GET_FRIEND_NOT_FOUND, 1791 TOX_ERR_FILE_GET_FRIEND_NOT_FOUND,