summaryrefslogtreecommitdiff
path: root/toxcore/tox.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-29 20:57:25 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-08-29 23:15:39 +0100
commit4692cea75e82d05c4facf97c8853819281f376cf (patch)
treea35ea42b1e3bf461f0444b4ab21afc990bfff6a1 /toxcore/tox.h
parent74ecb0c4606724edfbe977984e9e9d61aa501851 (diff)
Add getters/setters for options.
Diffstat (limited to 'toxcore/tox.h')
-rw-r--r--toxcore/tox.h76
1 files changed, 71 insertions, 5 deletions
diff --git a/toxcore/tox.h b/toxcore/tox.h
index bafa9c87..2424ab8d 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -75,6 +75,9 @@ extern "C" {
75 * enumeration value is outside the valid range of the type. If possible, the 75 * enumeration value is outside the valid range of the type. If possible, the
76 * function will try to use a sane default, but there will be no error code, 76 * function will try to use a sane default, but there will be no error code,
77 * and one possible action for the function to take is to have no effect. 77 * and one possible action for the function to take is to have no effect.
78 *
79 * Integer constants and the memory layout of publicly exposed structs are not
80 * part of the ABI.
78 */ 81 */
79/** \subsection events Events and callbacks 82/** \subsection events Events and callbacks
80 * 83 *
@@ -223,6 +226,10 @@ bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
223 * 226 *
224 * :: Numeric constants 227 * :: Numeric constants
225 * 228 *
229 * The values of these are not part of the ABI. Prefer to use the function
230 * versions of them for code that should remain compatible with future versions
231 * of toxcore.
232 *
226 ******************************************************************************/ 233 ******************************************************************************/
227 234
228 235
@@ -406,12 +413,12 @@ typedef enum TOX_SAVEDATA_TYPE {
406 TOX_SAVEDATA_TYPE_NONE, 413 TOX_SAVEDATA_TYPE_NONE,
407 414
408 /** 415 /**
409 * Savedata is one that was obtained from tox_get_savedata 416 * Savedata is one that was obtained from tox_get_savedata.
410 */ 417 */
411 TOX_SAVEDATA_TYPE_TOX_SAVE, 418 TOX_SAVEDATA_TYPE_TOX_SAVE,
412 419
413 /** 420 /**
414 * Savedata is a secret key of length TOX_SECRET_KEY_SIZE 421 * Savedata is a secret key of length TOX_SECRET_KEY_SIZE.
415 */ 422 */
416 TOX_SAVEDATA_TYPE_SECRET_KEY, 423 TOX_SAVEDATA_TYPE_SECRET_KEY,
417 424
@@ -419,9 +426,18 @@ typedef enum TOX_SAVEDATA_TYPE {
419 426
420 427
421/** 428/**
422 * This struct contains all the startup options for Tox. You can either allocate 429 * This struct contains all the startup options for Tox. You can either
423 * this object yourself, and pass it to tox_options_default, or call 430 * allocate this object yourself, and pass it to tox_options_default, or call tox_options_new to get
424 * tox_options_new to get a new default options object. 431 * a new default options object.
432 *
433 * If you allocate it yourself, be aware that your binary will rely on the
434 * memory layout of this struct. In particular, if additional fields are added
435 * in future versions of the API, code that allocates it itself will become
436 * incompatible.
437 *
438 * The memory layout of this struct (size, alignment, and field order) is not
439 * part of the ABI. To remain compatible, prefer to use tox_options_new to allocate the
440 * object and accessor functions to set the members.
425 */ 441 */
426struct Tox_Options { 442struct Tox_Options {
427 443
@@ -460,6 +476,9 @@ struct Tox_Options {
460 * (255 chars + 1 NUL byte). 476 * (255 chars + 1 NUL byte).
461 * 477 *
462 * This member is ignored (it can be NULL) if proxy_type is TOX_PROXY_TYPE_NONE. 478 * This member is ignored (it can be NULL) if proxy_type is TOX_PROXY_TYPE_NONE.
479 *
480 * The data pointed at by this member is owned by the user, so must
481 * outlive the options object.
463 */ 482 */
464 const char *proxy_host; 483 const char *proxy_host;
465 484
@@ -516,6 +535,9 @@ struct Tox_Options {
516 535
517 /** 536 /**
518 * The savedata. 537 * The savedata.
538 *
539 * The data pointed at by this member is owned by the user, so must
540 * outlive the options object.
519 */ 541 */
520 const uint8_t *savedata_data; 542 const uint8_t *savedata_data;
521 543
@@ -528,6 +550,50 @@ struct Tox_Options {
528}; 550};
529 551
530 552
553bool tox_options_get_ipv6_enabled(const struct Tox_Options *options);
554
555void tox_options_set_ipv6_enabled(struct Tox_Options *options, bool ipv6_enabled);
556
557bool tox_options_get_udp_enabled(const struct Tox_Options *options);
558
559void tox_options_set_udp_enabled(struct Tox_Options *options, bool udp_enabled);
560
561TOX_PROXY_TYPE tox_options_get_proxy_type(const struct Tox_Options *options);
562
563void tox_options_set_proxy_type(struct Tox_Options *options, TOX_PROXY_TYPE type);
564
565const char *tox_options_get_proxy_host(const struct Tox_Options *options);
566
567void tox_options_set_proxy_host(struct Tox_Options *options, const char *host);
568
569uint16_t tox_options_get_proxy_port(const struct Tox_Options *options);
570
571void tox_options_set_proxy_port(struct Tox_Options *options, uint16_t port);
572
573uint16_t tox_options_get_start_port(const struct Tox_Options *options);
574
575void tox_options_set_start_port(struct Tox_Options *options, uint16_t start_port);
576
577uint16_t tox_options_get_end_port(const struct Tox_Options *options);
578
579void tox_options_set_end_port(struct Tox_Options *options, uint16_t end_port);
580
581uint16_t tox_options_get_tcp_port(const struct Tox_Options *options);
582
583void tox_options_set_tcp_port(struct Tox_Options *options, uint16_t tcp_port);
584
585TOX_SAVEDATA_TYPE tox_options_get_savedata_type(const struct Tox_Options *options);
586
587void tox_options_set_savedata_type(struct Tox_Options *options, TOX_SAVEDATA_TYPE type);
588
589const uint8_t *tox_options_get_savedata_data(const struct Tox_Options *options);
590
591void tox_options_set_savedata_data(struct Tox_Options *options, const uint8_t *data, size_t length);
592
593size_t tox_options_get_savedata_length(const struct Tox_Options *options);
594
595void tox_options_set_savedata_length(struct Tox_Options *options, size_t length);
596
531/** 597/**
532 * Initialises a Tox_Options object with the default options. 598 * Initialises a Tox_Options object with the default options.
533 * 599 *