summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Tox/libtox/docs/CHANGELOG.md474
-rw-r--r--protocols/Tox/libtox/docs/LICENSE9
-rw-r--r--protocols/Tox/libtox/docs/README.md80
-rw-r--r--protocols/Tox/libtox/src/third_party/cmp/cmp.c4
-rw-r--r--protocols/Tox/libtox/src/toxcore/DHT.c10
-rw-r--r--protocols/Tox/libtox/src/toxcore/Makefile.inc170
-rw-r--r--protocols/Tox/libtox/src/toxcore/Messenger.c124
-rw-r--r--protocols/Tox/libtox/src/toxcore/Messenger.h51
-rw-r--r--protocols/Tox/libtox/src/toxcore/announce.c2
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_connected.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_invite.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_message.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_peer_list_changed.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_peer_name.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/conference_title.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/dht_get_nodes_response.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/file_chunk_request.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/file_recv.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/file_recv_chunk.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/file_recv_control.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_connection_status.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_lossless_packet.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_lossy_packet.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_message.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_name.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_read_receipt.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_request.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_status.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_status_message.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/friend_typing.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_custom_packet.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_custom_private_packet.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_invite.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_join_fail.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_message.c27
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_moderation.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_password.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_peer_exit.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_peer_join.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_peer_limit.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_peer_name.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_peer_status.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_privacy_state.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_private_message.c52
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_self_join.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_topic.c9
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_topic_lock.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/group_voice_state.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/events/self_connection_status.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/friend_connection.c5
-rw-r--r--protocols/Tox/libtox/src/toxcore/group.c4
-rw-r--r--protocols/Tox/libtox/src/toxcore/group_chats.c78
-rw-r--r--protocols/Tox/libtox/src/toxcore/group_chats.h10
-rw-r--r--protocols/Tox/libtox/src/toxcore/group_common.h2
-rw-r--r--protocols/Tox/libtox/src/toxcore/group_pack.c18
-rw-r--r--protocols/Tox/libtox/src/toxcore/group_pack.h4
-rw-r--r--protocols/Tox/libtox/src/toxcore/net_crypto.c161
-rw-r--r--protocols/Tox/libtox/src/toxcore/net_crypto.h9
-rw-r--r--protocols/Tox/libtox/src/toxcore/onion_client.c2
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox.c285
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox.h1247
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_api.c254
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_dispatch.h7
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_event.c86
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_events.h15
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_private.h90
-rw-r--r--protocols/Tox/libtox/src/toxcore/tox_unpack.c110
-rw-r--r--protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.c35
-rw-r--r--protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h32
69 files changed, 2212 insertions, 1459 deletions
diff --git a/protocols/Tox/libtox/docs/CHANGELOG.md b/protocols/Tox/libtox/docs/CHANGELOG.md
index 85da062d93..36bfb39b2c 100644
--- a/protocols/Tox/libtox/docs/CHANGELOG.md
+++ b/protocols/Tox/libtox/docs/CHANGELOG.md
@@ -1,9 +1,483 @@
+## v0.2.20
+
+### Merged PRs:
+
+- [#2788](https://github.com/TokTok/c-toxcore/pull/2788) fix: Add missing free in dht_get_nodes_response event.
+- [#2786](https://github.com/TokTok/c-toxcore/pull/2786) cleanup: Fix all `-Wsign-compare` warnings.
+- [#2785](https://github.com/TokTok/c-toxcore/pull/2785) fix: wrong comment for closelist
+- [#2784](https://github.com/TokTok/c-toxcore/pull/2784) chore: lower cirrus ci timeout drastically
+- [#2783](https://github.com/TokTok/c-toxcore/pull/2783) fix: Return an error instead of crashing on nullptr args in NGC.
+- [#2782](https://github.com/TokTok/c-toxcore/pull/2782) fix(toxav): pass video bit rate as kbit
+- [#2780](https://github.com/TokTok/c-toxcore/pull/2780) chore: Add release-drafter github action.
+- [#2779](https://github.com/TokTok/c-toxcore/pull/2779) chore: Use toktok's cmp instead of upstream.
+- [#2778](https://github.com/TokTok/c-toxcore/pull/2778) cleanup: Sort apk/apt install commands in Dockerfiles.
+- [#2777](https://github.com/TokTok/c-toxcore/pull/2777) chore: Upgrade to FreeBSD 14.1 in cirrus build.
+- [#2772](https://github.com/TokTok/c-toxcore/pull/2772) fix: friend_connections leak on allocation failure.
+- [#2771](https://github.com/TokTok/c-toxcore/pull/2771) fix: events leak that can occur if allocation fails
+- [#2769](https://github.com/TokTok/c-toxcore/pull/2769) chore(ci): new minimum for all android versions is 21
+- [#2768](https://github.com/TokTok/c-toxcore/pull/2768) fix: toxav rtp temp buffer allocation size was too large
+- [#2762](https://github.com/TokTok/c-toxcore/pull/2762) chore(cmake): set options changes as cache and with force
+- [#2761](https://github.com/TokTok/c-toxcore/pull/2761) chore: Fix CI
+- [#2757](https://github.com/TokTok/c-toxcore/pull/2757) fix: Use Opus in the CBR mode
+- [#2755](https://github.com/TokTok/c-toxcore/pull/2755) chore: Fix Circle CI build failing
+- [#2754](https://github.com/TokTok/c-toxcore/pull/2754) docs(toxav): fix docs of toxav.h
+- [#2751](https://github.com/TokTok/c-toxcore/pull/2751) chore(deps): bump golang.org/x/net from 0.17.0 to 0.23.0 in /other/bootstrap_daemon/websocket/websockify
+- [#2747](https://github.com/TokTok/c-toxcore/pull/2747) fix: Memory leak in the bootstrap daemon
+- [#2745](https://github.com/TokTok/c-toxcore/pull/2745) chore: Fix GitHub actions deprecation warnings
+- [#2717](https://github.com/TokTok/c-toxcore/pull/2717) cleanup: Remove useless if clause
+- [#2692](https://github.com/TokTok/c-toxcore/pull/2692) refactor: Make tox-bootstrapd use bool instead of int
+- [#2651](https://github.com/TokTok/c-toxcore/pull/2651) refactor: Make ToxAV independent of toxcore internals.
+
+## v0.2.19
+
+### Merged PRs:
+
+- [#2744](https://github.com/TokTok/c-toxcore/pull/2744) docs: Document that group topic lock is default on.
+- [#2743](https://github.com/TokTok/c-toxcore/pull/2743) docs: Add missing param docs for callbacks.
+- [#2742](https://github.com/TokTok/c-toxcore/pull/2742) chore: Add cmake flag to disable unit tests.
+- [#2741](https://github.com/TokTok/c-toxcore/pull/2741) refactor: Don't expose Tox_System in the public API
+- [#2736](https://github.com/TokTok/c-toxcore/pull/2736) cleanup: A more descriptive error for group invite accept function
+- [#2735](https://github.com/TokTok/c-toxcore/pull/2735) chore: Small API doc fixes
+- [#2732](https://github.com/TokTok/c-toxcore/pull/2732) cleanup: event length naming inconsistencies
+- [#2731](https://github.com/TokTok/c-toxcore/pull/2731) cleanup: align group send err enum order
+- [#2729](https://github.com/TokTok/c-toxcore/pull/2729) cleanup: use typedef for private message ID's in callback
+- [#2728](https://github.com/TokTok/c-toxcore/pull/2728) refactor: Observers/ignored peers can now send and receive custom packets
+- [#2727](https://github.com/TokTok/c-toxcore/pull/2727) feat: add message IDs to private group messages
+- [#2726](https://github.com/TokTok/c-toxcore/pull/2726) refactor: Rename `out` parameters to `out_$something`.
+- [#2718](https://github.com/TokTok/c-toxcore/pull/2718) chore: Use a specific non-broken slimcc version.
+- [#2713](https://github.com/TokTok/c-toxcore/pull/2713) feat: Update and improve the Windows cross-compilation
+- [#2712](https://github.com/TokTok/c-toxcore/pull/2712) chore: Update github actions.
+- [#2710](https://github.com/TokTok/c-toxcore/pull/2710) docs: Update the list of CMake options
+- [#2709](https://github.com/TokTok/c-toxcore/pull/2709) refactor: Remove "mod" and "founder" from group API naming scheme
+- [#2708](https://github.com/TokTok/c-toxcore/pull/2708) docs: add the experimental api build option to INSTALL.md
+- [#2705](https://github.com/TokTok/c-toxcore/pull/2705) refactor: Rename Queries to Query to align with other enums.
+- [#2704](https://github.com/TokTok/c-toxcore/pull/2704) fix: Correct type for conference offline peer numbers.
+- [#2700](https://github.com/TokTok/c-toxcore/pull/2700) test: Add FreeBSD VM action on GitHub.
+- [#2699](https://github.com/TokTok/c-toxcore/pull/2699) test: Add pkgsrc build.
+- [#2698](https://github.com/TokTok/c-toxcore/pull/2698) chore: Only install tox_private.h on request.
+- [#2697](https://github.com/TokTok/c-toxcore/pull/2697) test: Build toxcore on NetBSD (VM).
+- [#2696](https://github.com/TokTok/c-toxcore/pull/2696) fix: save_compatibility_test failing on big-endian systems
+- [#2695](https://github.com/TokTok/c-toxcore/pull/2695) fix: Don't serve files from websockify.
+- [#2691](https://github.com/TokTok/c-toxcore/pull/2691) chore: Release 0.2.19
+- [#2689](https://github.com/TokTok/c-toxcore/pull/2689) fix: Correctly pass extended public keys to group moderation code.
+- [#2686](https://github.com/TokTok/c-toxcore/pull/2686) chore: Compile libsodium reference implementation with compcert.
+- [#2685](https://github.com/TokTok/c-toxcore/pull/2685) cleanup: correct a few nullable annotations
+- [#2684](https://github.com/TokTok/c-toxcore/pull/2684) cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
+- [#2683](https://github.com/TokTok/c-toxcore/pull/2683) fix: Pass array, not array pointer, to `memcmp`.
+- [#2682](https://github.com/TokTok/c-toxcore/pull/2682) cleanup: Never pass `void*` directly to `memcpy`.
+- [#2678](https://github.com/TokTok/c-toxcore/pull/2678) chore: Disable NGC saving by default, enable through Tox_Options.
+- [#2675](https://github.com/TokTok/c-toxcore/pull/2675) cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
+- [#2672](https://github.com/TokTok/c-toxcore/pull/2672) refactor: Use `structs` for extended public/secret keys.
+- [#2671](https://github.com/TokTok/c-toxcore/pull/2671) refactor: Use tox rng to seed the keypair generation.
+- [#2666](https://github.com/TokTok/c-toxcore/pull/2666) cleanup: Small improvements found by PVS Studio.
+- [#2664](https://github.com/TokTok/c-toxcore/pull/2664) docs: Run prettier-markdown on markdown files.
+- [#2662](https://github.com/TokTok/c-toxcore/pull/2662) fix: Correct a few potential null derefs in bootstrap daemon.
+- [#2661](https://github.com/TokTok/c-toxcore/pull/2661) fix: Zero out stack-allocated secret key before return.
+- [#2660](https://github.com/TokTok/c-toxcore/pull/2660) fix: Add missing memunlock of local variable when it goes out of scope.
+- [#2659](https://github.com/TokTok/c-toxcore/pull/2659) cleanup: Simplify custom packet length check in NGC.
+- [#2658](https://github.com/TokTok/c-toxcore/pull/2658) refactor: Make prune_gc_sanctions_list more obviously correct.
+- [#2657](https://github.com/TokTok/c-toxcore/pull/2657) fix: Fix some false positive from PVS Studio.
+- [#2656](https://github.com/TokTok/c-toxcore/pull/2656) docs: Add static analysis tool list to README.
+- [#2655](https://github.com/TokTok/c-toxcore/pull/2655) cleanup: Check that WINXP macro exists before comparing it.
+- [#2652](https://github.com/TokTok/c-toxcore/pull/2652) refactor: Make tox mutex non-recursive.
+- [#2648](https://github.com/TokTok/c-toxcore/pull/2648) docs: Add more documentation to crypto_core.
+- [#2647](https://github.com/TokTok/c-toxcore/pull/2647) docs: Fix up doxyfile.
+- [#2645](https://github.com/TokTok/c-toxcore/pull/2645) refactor: Remove `Tox *` from `tox_dispatch`.
+- [#2644](https://github.com/TokTok/c-toxcore/pull/2644) refactor: Don't rely on tox_dispatch passing tox in tests.
+- [#2643](https://github.com/TokTok/c-toxcore/pull/2643) refactor: Use strong typedef for NGC peer id.
+- [#2642](https://github.com/TokTok/c-toxcore/pull/2642) chore: Use C++ mode for clang-tidy.
+- [#2640](https://github.com/TokTok/c-toxcore/pull/2640) refactor: Use strong `typedef` instead of `struct` for `Socket`.
+- [#2637](https://github.com/TokTok/c-toxcore/pull/2637) chore: Check that both gtest and gmock exist for tests.
+- [#2634](https://github.com/TokTok/c-toxcore/pull/2634) chore: Add some comments to the astyle config.
+- [#2629](https://github.com/TokTok/c-toxcore/pull/2629) chore: Reformat sources with astyle.
+- [#2626](https://github.com/TokTok/c-toxcore/pull/2626) chore: Rename C++ headers to .hh suffixes.
+- [#2624](https://github.com/TokTok/c-toxcore/pull/2624) test: Add slimcc compiler compatibility test.
+- [#2622](https://github.com/TokTok/c-toxcore/pull/2622) cleanup: Add more `const` where possible.
+- [#2621](https://github.com/TokTok/c-toxcore/pull/2621) cleanup: Remove implicit bool conversions.
+- [#2620](https://github.com/TokTok/c-toxcore/pull/2620) chore: Only check the bootstrap daemon checksum on release.
+- [#2617](https://github.com/TokTok/c-toxcore/pull/2617) cleanup: Further `#include` cleanups.
+- [#2614](https://github.com/TokTok/c-toxcore/pull/2614) cleanup: Use Bazel modules to enforce proper `#include` hygiene.
+- [#2612](https://github.com/TokTok/c-toxcore/pull/2612) refactor: Move pack/unpack `IP_Port` from DHT into network module.
+- [#2611](https://github.com/TokTok/c-toxcore/pull/2611) chore: Really fix coverage docker image build.
+- [#2610](https://github.com/TokTok/c-toxcore/pull/2610) chore: Fix post-submit coverage image.
+- [#2609](https://github.com/TokTok/c-toxcore/pull/2609) fix: partially fix a bug that prevented group part messages from sending
+- [#2605](https://github.com/TokTok/c-toxcore/pull/2605) fix: Don't use `memcmp` to compare `IP_Port`s.
+- [#2604](https://github.com/TokTok/c-toxcore/pull/2604) chore: Fix rpm build; add a CI check for it.
+- [#2603](https://github.com/TokTok/c-toxcore/pull/2603) chore: Speed up docker builds a bit by reducing layer count.
+- [#2602](https://github.com/TokTok/c-toxcore/pull/2602) cleanup: Add `const` where possible in auto tests.
+- [#2601](https://github.com/TokTok/c-toxcore/pull/2601) fix: a few off by one errors in group autotests
+- [#2598](https://github.com/TokTok/c-toxcore/pull/2598) refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
+- [#2597](https://github.com/TokTok/c-toxcore/pull/2597) test: Add goblint static analyser.
+- [#2594](https://github.com/TokTok/c-toxcore/pull/2594) cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
+- [#2593](https://github.com/TokTok/c-toxcore/pull/2593) cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
+- [#2592](https://github.com/TokTok/c-toxcore/pull/2592) cleanup: Remove all uses of `SIZEOF_VLA`.
+- [#2591](https://github.com/TokTok/c-toxcore/pull/2591) cleanup: Expand the `Tox_Options` accessor macros.
+- [#2590](https://github.com/TokTok/c-toxcore/pull/2590) test: Add a simple new/delete test for Tox.
+- [#2588](https://github.com/TokTok/c-toxcore/pull/2588) cleanup: Remove plan9 support.
+- [#2587](https://github.com/TokTok/c-toxcore/pull/2587) cleanup: Add comment after every `#endif`.
+- [#2583](https://github.com/TokTok/c-toxcore/pull/2583) test: Fix comment I broke in the events test PR.
+- [#2582](https://github.com/TokTok/c-toxcore/pull/2582) cleanup: Rename group to conference in groupav documentation.
+- [#2581](https://github.com/TokTok/c-toxcore/pull/2581) cleanup: Ensure handler params are named after callback params.
+- [#2580](https://github.com/TokTok/c-toxcore/pull/2580) cleanup: Minor cleanup of event unpack code.
+- [#2578](https://github.com/TokTok/c-toxcore/pull/2578) refactor: Allow NULL pointers for byte arrays in events.
+- [#2577](https://github.com/TokTok/c-toxcore/pull/2577) refactor: Add common msgpack array packer with callback.
+- [#2576](https://github.com/TokTok/c-toxcore/pull/2576) cleanup: make some improvements to group moderation test
+- [#2575](https://github.com/TokTok/c-toxcore/pull/2575) refactor: Pass `this` pointer as first param to s11n callbacks.
+- [#2573](https://github.com/TokTok/c-toxcore/pull/2573) cleanup: skip a do_gc iteration before removing peers marked for deletion
+- [#2572](https://github.com/TokTok/c-toxcore/pull/2572) cleanup: Remove `bin_pack_{new,free}`.
+- [#2568](https://github.com/TokTok/c-toxcore/pull/2568) feat: Add dht_get_nodes_response event to the events system.
+- [#2567](https://github.com/TokTok/c-toxcore/pull/2567) refactor: Use enum-specific pack functions for enum values.
+- [#2566](https://github.com/TokTok/c-toxcore/pull/2566) cleanup: Remove empty test doing nothing.
+- [#2565](https://github.com/TokTok/c-toxcore/pull/2565) refactor: Factor out union pack switch from event packer.
+- [#2564](https://github.com/TokTok/c-toxcore/pull/2564) cleanup: Move the 2-element array pack out of individual events.
+- [#2563](https://github.com/TokTok/c-toxcore/pull/2563) test: Add printf log statement to group_moderation_test.
+- [#2562](https://github.com/TokTok/c-toxcore/pull/2562) chore: add clangd files to .gitignore
+- [#2561](https://github.com/TokTok/c-toxcore/pull/2561) refactor: Move file streaming test to its own file.
+- [#2560](https://github.com/TokTok/c-toxcore/pull/2560) fix(ci): window builds now build in parallel
+- [#2559](https://github.com/TokTok/c-toxcore/pull/2559) refactor: Migrate auto_tests to new events API.
+- [#2557](https://github.com/TokTok/c-toxcore/pull/2557) test: Add C++ classes wrapping system interfaces.
+- [#2555](https://github.com/TokTok/c-toxcore/pull/2555) fix: Remove fatal error for non-erroneous case
+- [#2554](https://github.com/TokTok/c-toxcore/pull/2554) fix: Make all the fuzzers work again, and add a test for protodump.
+- [#2552](https://github.com/TokTok/c-toxcore/pull/2552) fix: Make sure there's enough space for CONSUME1 in fuzzers.
+- [#2551](https://github.com/TokTok/c-toxcore/pull/2551) chore: Move from gcov to llvm source-based coverage.
+- [#2549](https://github.com/TokTok/c-toxcore/pull/2549) fix: issues with packet broadcast error reporting
+- [#2547](https://github.com/TokTok/c-toxcore/pull/2547) test: Add fuzz tests to the coverage run.
+- [#2545](https://github.com/TokTok/c-toxcore/pull/2545) refactor: Use `operator==` for equality tests of `Node_format`.
+- [#2543](https://github.com/TokTok/c-toxcore/pull/2543) refactor(test): Slightly nicer C++ interface to tox Random.
+- [#2542](https://github.com/TokTok/c-toxcore/pull/2542) refactor: packet broadcast functions now return errors
+- [#2541](https://github.com/TokTok/c-toxcore/pull/2541) fix: don't pass garbage data buffer to packet send functions
+- [#2540](https://github.com/TokTok/c-toxcore/pull/2540) cleanup: Make group packet entry creation less error-prone
+- [#2539](https://github.com/TokTok/c-toxcore/pull/2539) refactor: Minor refactoring of get_close_nodes functions.
+- [#2538](https://github.com/TokTok/c-toxcore/pull/2538) refactor: Factor out malloc+memcpy into memdup.
+- [#2536](https://github.com/TokTok/c-toxcore/pull/2536) cleanup: Some more test cleanups, removing overly smart code.
+- [#2531](https://github.com/TokTok/c-toxcore/pull/2531) test: Add more unit tests for `add_to_list`.
+- [#2530](https://github.com/TokTok/c-toxcore/pull/2530) refactor: Assign malloc return to a local variable first.
+- [#2529](https://github.com/TokTok/c-toxcore/pull/2529) test: Add "infer" CI check to github, remove from circle.
+- [#2527](https://github.com/TokTok/c-toxcore/pull/2527) cleanup: Add Toxav alias for ToxAV.
+- [#2526](https://github.com/TokTok/c-toxcore/pull/2526) cleanup: Make Tox_Options a typedef.
+- [#2525](https://github.com/TokTok/c-toxcore/pull/2525) cleanup: Add dynamically derived array sizes to the API.
+- [#2524](https://github.com/TokTok/c-toxcore/pull/2524) cleanup: Add explicit array sizes to toxencryptsave.
+- [#2523](https://github.com/TokTok/c-toxcore/pull/2523) cleanup: Move `tox_get_system` out of the public API.
+- [#2522](https://github.com/TokTok/c-toxcore/pull/2522) cleanup: Make setters take non-const `Tox *`.
+- [#2521](https://github.com/TokTok/c-toxcore/pull/2521) cleanup: Make array params in toxav `[]` instead of `*`.
+- [#2520](https://github.com/TokTok/c-toxcore/pull/2520) cleanup: Mark arrays in the tox API as `[]` instead of `*`.
+- [#2519](https://github.com/TokTok/c-toxcore/pull/2519) refactor: Align group message sending with other send functions.
+- [#2518](https://github.com/TokTok/c-toxcore/pull/2518) cleanup: Add typedefs for public API int identifiers.
+- [#2517](https://github.com/TokTok/c-toxcore/pull/2517) chore: Spellcheck tox-bootstrapd
+- [#2516](https://github.com/TokTok/c-toxcore/pull/2516) chore: Remove settings.yml in favour of hs-github-tools.
+- [#2515](https://github.com/TokTok/c-toxcore/pull/2515) chore: Use GPL license with https.
+- [#2513](https://github.com/TokTok/c-toxcore/pull/2513) chore: Add fetch-sha256 script to update bootstrap node hash.
+- [#2512](https://github.com/TokTok/c-toxcore/pull/2512) cleanup: Move all vptr-to-ptr casts to the beginning of a function.
+- [#2510](https://github.com/TokTok/c-toxcore/pull/2510) cleanup: Use github actions matrix to simplify CI.
+- [#2509](https://github.com/TokTok/c-toxcore/pull/2509) fix: Use QueryPerformanceCounter on windows for monotonic time.
+- [#2508](https://github.com/TokTok/c-toxcore/pull/2508) chore: Add `net_(new|kill)_strerror` to cppcheck's allocators.
+- [#2507](https://github.com/TokTok/c-toxcore/pull/2507) cleanup: Run clang-tidy on headers, as well.
+- [#2506](https://github.com/TokTok/c-toxcore/pull/2506) cleanup: Make TCP connection failures a warning instead of error.
+- [#2505](https://github.com/TokTok/c-toxcore/pull/2505) cleanup: Make all .c files include the headers they need.
+- [#2504](https://github.com/TokTok/c-toxcore/pull/2504) cleanup: Upgrade cppcheck, fix some warnings.
+- [#2503](https://github.com/TokTok/c-toxcore/pull/2503) cleanup: Upgrade to clang-tidy-17 and fix some warnings.
+- [#2502](https://github.com/TokTok/c-toxcore/pull/2502) chore: Use `pkg_search_module` directly in cmake.
+- [#2501](https://github.com/TokTok/c-toxcore/pull/2501) chore: Add `IMPORTED_TARGET` to pkg-config packages.
+- [#2499](https://github.com/TokTok/c-toxcore/pull/2499) cleanup: Use target_link_libraries directly in cmake.
+- [#2498](https://github.com/TokTok/c-toxcore/pull/2498) chore: Simplify msvc build using vcpkg.
+- [#2497](https://github.com/TokTok/c-toxcore/pull/2497) cleanup: Remove NaCl support.
+- [#2494](https://github.com/TokTok/c-toxcore/pull/2494) fix: unpack enum function names in event impl generator
+- [#2493](https://github.com/TokTok/c-toxcore/pull/2493) chore: Disable targets for cross-compilation.
+- [#2491](https://github.com/TokTok/c-toxcore/pull/2491) chore: Build a docker image with coverage info in it.
+- [#2490](https://github.com/TokTok/c-toxcore/pull/2490) cleanup: Some portability/warning fixes for Windows builds.
+- [#2488](https://github.com/TokTok/c-toxcore/pull/2488) fix: Correct a use-after-free and fix some memory leaks.
+- [#2487](https://github.com/TokTok/c-toxcore/pull/2487) refactor: Change all enum-like `#define` sequences into enums.
+- [#2486](https://github.com/TokTok/c-toxcore/pull/2486) refactor: Change the `TCP_PACKET_*` defines into an enum.
+- [#2485](https://github.com/TokTok/c-toxcore/pull/2485) refactor: event generation tool for reorder pr
+- [#2484](https://github.com/TokTok/c-toxcore/pull/2484) chore: Fix make_single_file to support core-only.
+- [#2481](https://github.com/TokTok/c-toxcore/pull/2481) chore: Update github actions `uses`.
+- [#2480](https://github.com/TokTok/c-toxcore/pull/2480) feat: add ngc related unpack functions
+- [#2479](https://github.com/TokTok/c-toxcore/pull/2479) feat: Add `to_string` functions for all public enums.
+- [#2477](https://github.com/TokTok/c-toxcore/pull/2477) test: add real timeout test
+- [#2476](https://github.com/TokTok/c-toxcore/pull/2476) chore: Move s390x build to post-merge.
+- [#2475](https://github.com/TokTok/c-toxcore/pull/2475) refactor: Give `enum-from-int` functions the ability to report errors.
+- [#2474](https://github.com/TokTok/c-toxcore/pull/2474) cleanup: Remove test net support.
+- [#2472](https://github.com/TokTok/c-toxcore/pull/2472) feat: Enable ubsan on bootstrap nodes.
+- [#2470](https://github.com/TokTok/c-toxcore/pull/2470) test: Add check-c run to bazel build.
+- [#2468](https://github.com/TokTok/c-toxcore/pull/2468) fix(test): tests use ipv6 by default, even with USE_IPV6 set to 0
+- [#2466](https://github.com/TokTok/c-toxcore/pull/2466) cleanup: Make group saving/loading more forgiving with data errors
+- [#2465](https://github.com/TokTok/c-toxcore/pull/2465) refactor: replace memset with a loop
+- [#2459](https://github.com/TokTok/c-toxcore/pull/2459) fix: Enable debug flag for ubsan.
+- [#2458](https://github.com/TokTok/c-toxcore/pull/2458) fix: also Install header for private/experimental API functions with autotools
+- [#2456](https://github.com/TokTok/c-toxcore/pull/2456) docs: Remove defunct IRC channel from README.md
+- [#2454](https://github.com/TokTok/c-toxcore/pull/2454) fix: memory leaks
+- [#2453](https://github.com/TokTok/c-toxcore/pull/2453) refactor: Install header for private/experimental API functions
+- [#2452](https://github.com/TokTok/c-toxcore/pull/2452) refactor: replace DEFAULT_TCP_RELAY_PORTS_COUNT with a compile-time calculation
+- [#2451](https://github.com/TokTok/c-toxcore/pull/2451) cleanup: clarify disabling of static assert checks
+- [#2449](https://github.com/TokTok/c-toxcore/pull/2449) cleanup: replace tabs with spaces
+- [#2448](https://github.com/TokTok/c-toxcore/pull/2448) feat: group connection queries now return our own connection type
+- [#2447](https://github.com/TokTok/c-toxcore/pull/2447) fix: Docker tox-bootstrapd hash update failing when using BuildKit
+- [#2446](https://github.com/TokTok/c-toxcore/pull/2446) feat: Add groupchat API function that returns an IP address string for a peer
+- [#2442](https://github.com/TokTok/c-toxcore/pull/2442) perf: Slightly reduce bandwidth usage when there are few nodes.
+- [#2439](https://github.com/TokTok/c-toxcore/pull/2439) test: Make esp32 build actually try to instantiate tox.
+- [#2438](https://github.com/TokTok/c-toxcore/pull/2438) cleanup: Remove explicit layering_check feature.
+- [#2437](https://github.com/TokTok/c-toxcore/pull/2437) chore: Upgrade sonar-scan jvm to java 17.
+- [#2436](https://github.com/TokTok/c-toxcore/pull/2436) fix: Add missing `htons` call when adding configured TCP relay.
+- [#2434](https://github.com/TokTok/c-toxcore/pull/2434) chore: Cancel old PR builds on docker and sonar-scan workflows.
+- [#2432](https://github.com/TokTok/c-toxcore/pull/2432) chore: Use C99 on MSVC instead of C11.
+- [#2430](https://github.com/TokTok/c-toxcore/pull/2430) chore: Retry freebsd tests 2 times.
+- [#2429](https://github.com/TokTok/c-toxcore/pull/2429) test: Add an s390x build (on alpine) for CI.
+- [#2428](https://github.com/TokTok/c-toxcore/pull/2428) chore: Add a compcert docker run script.
+- [#2427](https://github.com/TokTok/c-toxcore/pull/2427) cleanup: Use tcc docker image for CI.
+- [#2424](https://github.com/TokTok/c-toxcore/pull/2424) fix: Fix memory leak in the error path of loading savedata.
+- [#2420](https://github.com/TokTok/c-toxcore/pull/2420) refactor: Use Bin_Pack for packing Node_format.
+- [#2416](https://github.com/TokTok/c-toxcore/pull/2416) chore: Add more logging to loading conferences from savedata.
+- [#2415](https://github.com/TokTok/c-toxcore/pull/2415) refactor: Add a `bin_unpack_bin_max` for max-length arrays.
+- [#2414](https://github.com/TokTok/c-toxcore/pull/2414) fix: inversed return values
+- [#2413](https://github.com/TokTok/c-toxcore/pull/2413) cleanup: Fix GCC compatibility.
+- [#2408](https://github.com/TokTok/c-toxcore/pull/2408) fix: Ensure we have allocators available for the error paths.
+- [#2407](https://github.com/TokTok/c-toxcore/pull/2407) cleanup: Remove redundant `-DSODIUM_EXPORT` from definitions.
+- [#2406](https://github.com/TokTok/c-toxcore/pull/2406) cleanup: Fix a few more clang-tidy warnings.
+- [#2405](https://github.com/TokTok/c-toxcore/pull/2405) cleanup: Fix a few more clang-tidy warnings.
+- [#2404](https://github.com/TokTok/c-toxcore/pull/2404) cleanup: Enforce stricter identifier naming using clang-tidy.
+- [#2396](https://github.com/TokTok/c-toxcore/pull/2396) chore: Add devcontainer setup for codespaces.
+- [#2393](https://github.com/TokTok/c-toxcore/pull/2393) refactor: Add `mem` module to allow tests to override allocators.
+- [#2392](https://github.com/TokTok/c-toxcore/pull/2392) refactor: Make event dispatch ordered by receive time.
+- [#2391](https://github.com/TokTok/c-toxcore/pull/2391) docs: Fix doxygen config and remove some redundant comments.
+- [#2390](https://github.com/TokTok/c-toxcore/pull/2390) chore: Fix the Android CI job
+- [#2389](https://github.com/TokTok/c-toxcore/pull/2389) fix: Add missing `#include <array>`.
+- [#2388](https://github.com/TokTok/c-toxcore/pull/2388) chore: Add missing module dependencies.
+- [#2384](https://github.com/TokTok/c-toxcore/pull/2384) feat: increase NGC lossy custom packet size
+- [#2383](https://github.com/TokTok/c-toxcore/pull/2383) fix: add missing ngc constants getter declarations and definitions
+- [#2381](https://github.com/TokTok/c-toxcore/pull/2381) fix: incorrect documentation
+- [#2380](https://github.com/TokTok/c-toxcore/pull/2380) feat: allow for larger incoming NGC packets
+- [#2371](https://github.com/TokTok/c-toxcore/pull/2371) docs: fix group_peer_exit_cb
+- [#2370](https://github.com/TokTok/c-toxcore/pull/2370) fix: behaviour of group api function
+- [#2369](https://github.com/TokTok/c-toxcore/pull/2369) fix: flaky tcp test
+- [#2367](https://github.com/TokTok/c-toxcore/pull/2367) fix: fuzz support for TCP server
+- [#2364](https://github.com/TokTok/c-toxcore/pull/2364) fix: potential endless loop under extremely high load
+- [#2362](https://github.com/TokTok/c-toxcore/pull/2362) test: enable tcp relay for bootstrap fuzzing
+- [#2361](https://github.com/TokTok/c-toxcore/pull/2361) fix: resolve_bootstrap_node() not checking net_getipport() returned count correctly
+- [#2357](https://github.com/TokTok/c-toxcore/pull/2357) feat: get the number of close dht nodes with announce/store support
+- [#2355](https://github.com/TokTok/c-toxcore/pull/2355) fix: group custom packet size limits
+- [#2354](https://github.com/TokTok/c-toxcore/pull/2354) fix: DHTBootstrap should always respond to version packets with toxcore version
+- [#2351](https://github.com/TokTok/c-toxcore/pull/2351) fix: Increase max group message length by four bytes
+- [#2348](https://github.com/TokTok/c-toxcore/pull/2348) refactor: Make some improvements to how often/when we announce a group
+- [#2341](https://github.com/TokTok/c-toxcore/pull/2341) fix: #1144 by forcing misc_tools to be a static lib
+- [#2340](https://github.com/TokTok/c-toxcore/pull/2340) fix: missing net to host conversion of port in logging in group_chat.c
+- [#2339](https://github.com/TokTok/c-toxcore/pull/2339) fix: missing net to host conversion of port in logging
+- [#2338](https://github.com/TokTok/c-toxcore/pull/2338) fix: bug causing friend group invites to sometimes fail & improve logging
+- [#2333](https://github.com/TokTok/c-toxcore/pull/2333) docs: Update README for bootstrap node docker
+- [#2329](https://github.com/TokTok/c-toxcore/pull/2329) refactor: extract each case in handle packet in messenger
+- [#2327](https://github.com/TokTok/c-toxcore/pull/2327) fix: unlock correct dht_friend
+- [#2325](https://github.com/TokTok/c-toxcore/pull/2325) fix: Remove cmake cache files after copying to container build directory
+- [#2323](https://github.com/TokTok/c-toxcore/pull/2323) docs: Update README.md to include cmp submodule info
+- [#2318](https://github.com/TokTok/c-toxcore/pull/2318) chore: disable warning about pre C99 code
+- [#2317](https://github.com/TokTok/c-toxcore/pull/2317) Refactor: Extract shared key cache into separate file
+- [#2311](https://github.com/TokTok/c-toxcore/pull/2311) cleanup: make it more clear that assert and uint32_t increment both only exist if NDEBUG is not defined
+- [#2291](https://github.com/TokTok/c-toxcore/pull/2291) test: Add a protocol dump test to generate initial fuzzer input.
+- [#2271](https://github.com/TokTok/c-toxcore/pull/2271) chore: Migrate from Appveyor to Azure Pipelines
+- [#2269](https://github.com/TokTok/c-toxcore/pull/2269) feat: Merge the remainder of the new groupchats implementation
+- [#2203](https://github.com/TokTok/c-toxcore/pull/2203) refactor: Store time in Mono_Time in milliseconds.
+- [#1944](https://github.com/TokTok/c-toxcore/pull/1944) chore: tox_new() should return null when savedata loading fails
+
+### Closed issues:
+
+- [#2739](https://github.com/TokTok/c-toxcore/issues/2739) Tox_Options.operating_system is not clear about it being an experimental option
+- [#2734](https://github.com/TokTok/c-toxcore/issues/2734) error compiling on fedora
+- [#2649](https://github.com/TokTok/c-toxcore/issues/2649) create_extended_keypair should use Random and be made deterministic for fuzzing
+- [#2462](https://github.com/TokTok/c-toxcore/issues/2462) Fix code scanning alert - Uncontrolled data used in path expression
+- [#2358](https://github.com/TokTok/c-toxcore/issues/2358) resolve_bootstrap_node assert hit
+- [#2352](https://github.com/TokTok/c-toxcore/issues/2352) SEGV after infinite loop retrying proxy_socks5_read_connection_response
+- [#2335](https://github.com/TokTok/c-toxcore/issues/2335) ipv6 disabled on kernel cmdline disrupts Tox = most tests fail
+- [#2303](https://github.com/TokTok/c-toxcore/issues/2303) Add new group chats events to tox_events and tox_dispatch modules.
+- [#2302](https://github.com/TokTok/c-toxcore/issues/2302) Run strong fuzz tests against NGC
+- [#2301](https://github.com/TokTok/c-toxcore/issues/2301) Implement NGC save/load in hs-toxcore and run round-trip tests against c-toxcore
+- [#2192](https://github.com/TokTok/c-toxcore/issues/2192) Provide official signed release tarballs
+- [#2118](https://github.com/TokTok/c-toxcore/issues/2118) Add a private "get mono_time" API to `tox_private.h` and use it in auto_tests.
+- [#2029](https://github.com/TokTok/c-toxcore/issues/2029) Migrate all auto tests to the events API.
+- [#2014](https://github.com/TokTok/c-toxcore/issues/2014) Add sodium autotools CI build
+- [#1144](https://github.com/TokTok/c-toxcore/issues/1144) DHT_bootstrap should not link against misc_tools
+
+## v0.2.18
+
+### Merged PRs:
+
+- [#2300](https://github.com/TokTok/c-toxcore/pull/2300) chore: Release 0.2.18
+- [#2299](https://github.com/TokTok/c-toxcore/pull/2299) fix: remove the assert because buffer can be larger than UINT16_MAX.
+- [#2297](https://github.com/TokTok/c-toxcore/pull/2297) cleanup: remove unused field last_seen from Onion_Friend
+- [#2289](https://github.com/TokTok/c-toxcore/pull/2289) test: Add a Null_System used in toxsave_harness.
+- [#2288](https://github.com/TokTok/c-toxcore/pull/2288) test: enable additional sanitizers for fuzzing
+- [#2287](https://github.com/TokTok/c-toxcore/pull/2287) fix: Don't allow onion paths to be built from real friends.
+- [#2285](https://github.com/TokTok/c-toxcore/pull/2285) test: Don't abort fuzz test when tox_new fails.
+- [#2284](https://github.com/TokTok/c-toxcore/pull/2284) refactor: Move crypto utilities from util to crypto_core.
+- [#2283](https://github.com/TokTok/c-toxcore/pull/2283) fix: Allow onion paths to be built from more random nodes.
+- [#2282](https://github.com/TokTok/c-toxcore/pull/2282) fix: Fix potential array out-of-bounds in DHT onion path building.
+- [#2281](https://github.com/TokTok/c-toxcore/pull/2281) cleanup: Avoid goto in msi.c.
+- [#2280](https://github.com/TokTok/c-toxcore/pull/2280) test: Improve test hermeticity by using local TCP relay.
+- [#2279](https://github.com/TokTok/c-toxcore/pull/2279) test: Enable fuzzing for TCP.
+- [#2277](https://github.com/TokTok/c-toxcore/pull/2277) refactor: Avoid `static_cast` in `Fuzz_System` functions.
+- [#2275](https://github.com/TokTok/c-toxcore/pull/2275) chore: Downgrade C++ version to 17
+- [#2273](https://github.com/TokTok/c-toxcore/pull/2273) fix: Really fix overrun added in e49a477a
+- [#2272](https://github.com/TokTok/c-toxcore/pull/2272) fix: Add missing return on error
+- [#2270](https://github.com/TokTok/c-toxcore/pull/2270) test: Improve error messages in toxav_basic_test.
+- [#2266](https://github.com/TokTok/c-toxcore/pull/2266) fix: Fixed leak and overrun added in e49a477a
+- [#2263](https://github.com/TokTok/c-toxcore/pull/2263) chore: Upgrade to C++20 in CMake build.
+- [#2261](https://github.com/TokTok/c-toxcore/pull/2261) refactor: Protect array unpacking against invalid lengths.
+- [#2258](https://github.com/TokTok/c-toxcore/pull/2258) refactor: Rename announce functions into their own namespace.
+- [#2257](https://github.com/TokTok/c-toxcore/pull/2257) fix: Format IP as string again in error log.
+- [#2255](https://github.com/TokTok/c-toxcore/pull/2255) fix: Fix a stack overflow triggered by small DHT packets.
+- [#2251](https://github.com/TokTok/c-toxcore/pull/2251) chore: Add MISRA-2012 check using cppcheck's misra addon.
+- [#2250](https://github.com/TokTok/c-toxcore/pull/2250) cleanup: remove populate_path_nodes_tcp
+- [#2249](https://github.com/TokTok/c-toxcore/pull/2249) test: Improve stability of forwarding_test.
+- [#2248](https://github.com/TokTok/c-toxcore/pull/2248) refactor: Use a struct for the `ip_ntoa` buffer.
+- [#2246](https://github.com/TokTok/c-toxcore/pull/2246) fix: Don't crash if RNG init failed.
+- [#2244](https://github.com/TokTok/c-toxcore/pull/2244) refactor: Allow NULL logger; make it no-op in NDEBUG.
+- [#2243](https://github.com/TokTok/c-toxcore/pull/2243) chore: Add initial ESP32 docker build.
+- [#2242](https://github.com/TokTok/c-toxcore/pull/2242) cleanup: Use `static_assert` instead of `assert` where possible.
+- [#2240](https://github.com/TokTok/c-toxcore/pull/2240) chore(deps): Use upstream cmp directly instead of our fork.
+- [#2238](https://github.com/TokTok/c-toxcore/pull/2238) cleanup: Make `*_free` and `kill_*` functions nullable.
+- [#2236](https://github.com/TokTok/c-toxcore/pull/2236) chore: Add dependabot config.
+- [#2234](https://github.com/TokTok/c-toxcore/pull/2234) test: Add more functionality to the bootstrap fuzz harness.
+- [#2233](https://github.com/TokTok/c-toxcore/pull/2233) cleanup: Replace a series of `if` statements with a `switch`.
+- [#2232](https://github.com/TokTok/c-toxcore/pull/2232) test: Add fuzzer support functions for internal toxcore objects.
+- [#2230](https://github.com/TokTok/c-toxcore/pull/2230) feat: Merge group announce portion of new groupchats implementation
+- [#2229](https://github.com/TokTok/c-toxcore/pull/2229) cleanup: Remove layers in the cmake build.
+- [#2228](https://github.com/TokTok/c-toxcore/pull/2228) chore: Fix path to fuzzer binaries in clusterfuzz build.
+- [#2227](https://github.com/TokTok/c-toxcore/pull/2227) cleanup: Disallow stack frames of over 9000 bytes.
+- [#2225](https://github.com/TokTok/c-toxcore/pull/2225) fix: fix typo in git command in INSTALL.md
+- [#2224](https://github.com/TokTok/c-toxcore/pull/2224) cleanup: Add include for assert.h for the fuzzing build.
+- [#2223](https://github.com/TokTok/c-toxcore/pull/2223) chore: Add `uint8_t` version of `bin_pack` for numbers.
+- [#2219](https://github.com/TokTok/c-toxcore/pull/2219) refactor: Rename bin_pack/unpack functions the same as cmp funcs.
+- [#2217](https://github.com/TokTok/c-toxcore/pull/2217) cleanup: Add Network object parameter for addr_resolve.
+- [#2214](https://github.com/TokTok/c-toxcore/pull/2214) cleanup: Remove all uses of `TOX_*_MAX_SIZE` macros.
+- [#2213](https://github.com/TokTok/c-toxcore/pull/2213) cleanup: Remove unused random_testing program.
+- [#2212](https://github.com/TokTok/c-toxcore/pull/2212) cleanup: Expand `CONST_FUNCTION` and remove the macro.
+- [#2211](https://github.com/TokTok/c-toxcore/pull/2211) cleanup: Move definitions of tox_private.h functions to tox_private.c.
+- [#2210](https://github.com/TokTok/c-toxcore/pull/2210) chore: Clone submodules in clusterfuzzlite Dockerfile.
+- [#2208](https://github.com/TokTok/c-toxcore/pull/2208) chore: Remove valgrind build.
+- [#2206](https://github.com/TokTok/c-toxcore/pull/2206) feat: Allow overriding mono_time in tox_new.
+- [#2204](https://github.com/TokTok/c-toxcore/pull/2204) chore: Support producing shared libraries on Windows
+- [#2202](https://github.com/TokTok/c-toxcore/pull/2202) cleanup: Avoid name clash between struct field and function.
+- [#2201](https://github.com/TokTok/c-toxcore/pull/2201) docs: Add information regarding git submodules, cmp to INSTALL.md
+- [#2200](https://github.com/TokTok/c-toxcore/pull/2200) cleanup: Add more null checks in `tox_new`.
+- [#2199](https://github.com/TokTok/c-toxcore/pull/2199) cleanup: Mark Mono_Time const where possible.
+- [#2196](https://github.com/TokTok/c-toxcore/pull/2196) test: Remove save_load_test from autotools build.
+- [#2195](https://github.com/TokTok/c-toxcore/pull/2195) fix: Correct calculation of packet sent time
+- [#2193](https://github.com/TokTok/c-toxcore/pull/2193) perf: Make time move a lot faster in fuzzing runs.
+- [#2190](https://github.com/TokTok/c-toxcore/pull/2190) feat: Add support for custom random number generator.
+- [#2189](https://github.com/TokTok/c-toxcore/pull/2189) chore: Add third_party to toxcore-sources docker image.
+- [#2188](https://github.com/TokTok/c-toxcore/pull/2188) cleanup: Make addr_resolve a private function.
+- [#2187](https://github.com/TokTok/c-toxcore/pull/2187) test: Add DHT and tox_events fuzz tests to the cmake build.
+- [#2186](https://github.com/TokTok/c-toxcore/pull/2186) cleanup: Use `_Static_assert` in gcc/clang.
+- [#2184](https://github.com/TokTok/c-toxcore/pull/2184) test: Add some support functions to make writing fuzzers easier.
+- [#2183](https://github.com/TokTok/c-toxcore/pull/2183) test: Enable more tests for msan.
+- [#2182](https://github.com/TokTok/c-toxcore/pull/2182) test: Improve stability of tox_many_tcp_test.
+- [#2177](https://github.com/TokTok/c-toxcore/pull/2177) feat: Add support for overriding network functions.
+- [#2176](https://github.com/TokTok/c-toxcore/pull/2176) test: try to save the fuzzed save file again
+- [#2175](https://github.com/TokTok/c-toxcore/pull/2175) refactor: Use cmp instead of msgpack-c for events packing.
+- [#2173](https://github.com/TokTok/c-toxcore/pull/2173) chore: Use "master" as the branch in toktok-fuzzer.
+- [#2170](https://github.com/TokTok/c-toxcore/pull/2170) test: Add fuzzer tests to the bazel build.
+- [#2169](https://github.com/TokTok/c-toxcore/pull/2169) feat: Merge moderation portion of new groupchats codebase
+- [#2167](https://github.com/TokTok/c-toxcore/pull/2167) cleanup: Reduce scope of array-typed variables where possible.
+- [#2166](https://github.com/TokTok/c-toxcore/pull/2166) cleanup: Reduce scope of variables as requested by cimple.
+- [#2164](https://github.com/TokTok/c-toxcore/pull/2164) feat: Merge onion_announce changes from new groupchats fork
+- [#2163](https://github.com/TokTok/c-toxcore/pull/2163) chore: Enable memory sanitizer build.
+- [#2160](https://github.com/TokTok/c-toxcore/pull/2160) test: Improve the stability of the save_load test
+- [#2159](https://github.com/TokTok/c-toxcore/pull/2159) chore: Update the Appveyor build to VS2019 to work around conan issues
+- [#2158](https://github.com/TokTok/c-toxcore/pull/2158) cleanup: Expose `struct Tox` to internal code.
+- [#2157](https://github.com/TokTok/c-toxcore/pull/2157) cleanup: Split the huge TCP client packet handler.
+- [#2156](https://github.com/TokTok/c-toxcore/pull/2156) cleanup: Sync doc comments between .h and .c files.
+- [#2155](https://github.com/TokTok/c-toxcore/pull/2155) fix: Eliminate memory leak in toxav.
+- [#2154](https://github.com/TokTok/c-toxcore/pull/2154) test: Speed up toxav_many_test by using fake mono_time.
+- [#2153](https://github.com/TokTok/c-toxcore/pull/2153) docs: Put all the tox public api into a fake "tox" namespace.
+- [#2150](https://github.com/TokTok/c-toxcore/pull/2150) cleanup: Move all the group.h structs into group.c.
+- [#2149](https://github.com/TokTok/c-toxcore/pull/2149) cleanup: Avoid `memset` on structs.
+- [#2147](https://github.com/TokTok/c-toxcore/pull/2147) feat: Store announcements
+- [#2146](https://github.com/TokTok/c-toxcore/pull/2146) chore: Add testing/Dockerfile to the CI build.
+- [#2145](https://github.com/TokTok/c-toxcore/pull/2145) chore: Be even more explicit about integer range bounds.
+- [#2144](https://github.com/TokTok/c-toxcore/pull/2144) cleanup: Minor cleanups in TCP_connection.c.
+- [#2143](https://github.com/TokTok/c-toxcore/pull/2143) fix: Allow port range in DHT_bootstrap.c.
+- [#2142](https://github.com/TokTok/c-toxcore/pull/2142) cleanup: Count re-adding an existing bootstrap node as success.
+- [#2141](https://github.com/TokTok/c-toxcore/pull/2141) cleanup: Disable LAN discovery in TCP-only mode.
+- [#2140](https://github.com/TokTok/c-toxcore/pull/2140) cleanup: Add assertion for decrypted data length.
+- [#2101](https://github.com/TokTok/c-toxcore/pull/2101) cleanup: improve CMakeLists.txt structure
+- [#2100](https://github.com/TokTok/c-toxcore/pull/2100) chore: remove cpufeatures.c
+- [#2098](https://github.com/TokTok/c-toxcore/pull/2098) chore: remove DHT_test.c since it's unused
+
+### Closed issues:
+
+- [#2298](https://github.com/TokTok/c-toxcore/issues/2298) assert makes incorrect assumption
+- [#2256](https://github.com/TokTok/c-toxcore/issues/2256) New Defects reported by Coverity Scan for TokTok/c-toxcore
+- [#2109](https://github.com/TokTok/c-toxcore/issues/2109) Assimilate `messenger_test.c`: replace with public API test
+- [#2012](https://github.com/TokTok/c-toxcore/issues/2012) Support building a DLL on Windows
+- [#907](https://github.com/TokTok/c-toxcore/issues/907) use dll abnormal System.AccessViolationException win7 x32 but x64 no problem
+
+## v0.2.17
+
+### Merged PRs:
+
+- [#2138](https://github.com/TokTok/c-toxcore/pull/2138) chore: Release 0.2.17
+- [#2136](https://github.com/TokTok/c-toxcore/pull/2136) docs: Clean up doxygen comments to be more doxygen-like.
+- [#2135](https://github.com/TokTok/c-toxcore/pull/2135) cleanup: Move test-only functions into tests.
+- [#2134](https://github.com/TokTok/c-toxcore/pull/2134) cleanup: Add explicit callback setters for MSI callbacks.
+- [#2133](https://github.com/TokTok/c-toxcore/pull/2133) cleanup: Remove redundant Messenger and DHT tests.
+- [#2132](https://github.com/TokTok/c-toxcore/pull/2132) cleanup: Remove dependency from LAN_discovery onto DHT.
+- [#2131](https://github.com/TokTok/c-toxcore/pull/2131) cleanup: Split util.c out of the network library.
+- [#2130](https://github.com/TokTok/c-toxcore/pull/2130) cleanup: Remove redundant `()` around `return` expression.
+- [#2128](https://github.com/TokTok/c-toxcore/pull/2128) test: Add unit test for create/handle request packets.
+- [#2127](https://github.com/TokTok/c-toxcore/pull/2127) cleanup: Remove `EAGAIN` from the list of ignored errors.
+- [#2126](https://github.com/TokTok/c-toxcore/pull/2126) cleanup: Remove port from `Broadcast_Info`.
+- [#2125](https://github.com/TokTok/c-toxcore/pull/2125) cleanup: Don't reference local variables in macro bodies.
+- [#2123](https://github.com/TokTok/c-toxcore/pull/2123) cleanup: Remove some more implicit bool conversions.
+- [#2122](https://github.com/TokTok/c-toxcore/pull/2122) chore: Enable a bunch more warnings in GCC builds.
+- [#2120](https://github.com/TokTok/c-toxcore/pull/2120) cleanup: Remove all boolean-int conversions.
+- [#2117](https://github.com/TokTok/c-toxcore/pull/2117) cleanup: Comply with strict include ordering.
+- [#2116](https://github.com/TokTok/c-toxcore/pull/2116) cleanup: Remove more boolean conversions (and a bugfix).
+- [#2115](https://github.com/TokTok/c-toxcore/pull/2115) cleanup: Log at ERROR level when `connect()` fails.
+- [#2114](https://github.com/TokTok/c-toxcore/pull/2114) cleanup: Avoid creating invalid enum values.
+- [#2113](https://github.com/TokTok/c-toxcore/pull/2113) cleanup: Remove superfluous parentheses on the rhs of assignments.
+- [#2108](https://github.com/TokTok/c-toxcore/pull/2108) test: Add mallocfail and proxy test to our coverage runs.
+- [#2106](https://github.com/TokTok/c-toxcore/pull/2106) test: Add test coverage docker build for local tests.
+- [#2105](https://github.com/TokTok/c-toxcore/pull/2105) cleanup: Change valid status of onion friend to bool.
+- [#2104](https://github.com/TokTok/c-toxcore/pull/2104) fix: Report failure to DHT bootstrap back to the client.
+- [#2103](https://github.com/TokTok/c-toxcore/pull/2103) cleanup: Remove more implicit bool conversions.
+- [#2102](https://github.com/TokTok/c-toxcore/pull/2102) cleanup: Mark all local non-pointers as const where possible.
+- [#2099](https://github.com/TokTok/c-toxcore/pull/2099) cleanup: Reduce name shadowing; remove ptr-to-bool conversions.
+- [#2097](https://github.com/TokTok/c-toxcore/pull/2097) cleanup: Remove implicit conversions from `uint32_t` to `bool`.
+- [#2096](https://github.com/TokTok/c-toxcore/pull/2096) cleanup: Return boolean constants, not ints from bool functions.
+- [#2094](https://github.com/TokTok/c-toxcore/pull/2094) fix: Null function pointer dereference.
+- [#2093](https://github.com/TokTok/c-toxcore/pull/2093) cleanup: Remove any disallowed casts.
+- [#2092](https://github.com/TokTok/c-toxcore/pull/2092) perf: fix issue with friend finding taking too long after disconnects.
+- [#2091](https://github.com/TokTok/c-toxcore/pull/2091) cleanup: Avoid casting function pointers.
+- [#2090](https://github.com/TokTok/c-toxcore/pull/2090) refactor: Move `tox_new_log` to `auto_test_support`.
+- [#2088](https://github.com/TokTok/c-toxcore/pull/2088) cleanup: Remove all implicit bool conversions in if-conditions.
+- [#2086](https://github.com/TokTok/c-toxcore/pull/2086) cleanup: Enable most cppcheck warnings as errors.
+- [#2084](https://github.com/TokTok/c-toxcore/pull/2084) fix: out-of-memory condition by corrupted save file
+- [#2079](https://github.com/TokTok/c-toxcore/pull/2079) cleanup: Remove unused execution trace library.
+- [#2078](https://github.com/TokTok/c-toxcore/pull/2078) perf: Refactor onion_client.c do_friends() to reduce network traffic
+- [#2075](https://github.com/TokTok/c-toxcore/pull/2075) chore: Add a .clang-format that mostly agrees with astyle.
+- [#2074](https://github.com/TokTok/c-toxcore/pull/2074) chore: Make coverity scan a nightly job.
+- [#2073](https://github.com/TokTok/c-toxcore/pull/2073) chore: Fix build-args in win32/win64 docker build.
+- [#2072](https://github.com/TokTok/c-toxcore/pull/2072) chore: Simplify and speed up windows builds using docker image.
+- [#2070](https://github.com/TokTok/c-toxcore/pull/2070) chore: Add docker image builds for windows cross compiler.
+- [#2064](https://github.com/TokTok/c-toxcore/pull/2064) fix: toxsave memory leak while loading groups
+
+### Closed issues:
+
+- [#2121](https://github.com/TokTok/c-toxcore/issues/2121) Improve speed and stability of LAN discovery test
+- [#2083](https://github.com/TokTok/c-toxcore/issues/2083) Tox save file format/loader doesn't limit or check the number of frozen peers
+- [#2080](https://github.com/TokTok/c-toxcore/issues/2080) speedup getting online after tox process has been suspended
+- [#2050](https://github.com/TokTok/c-toxcore/issues/2050) Excessive onion friend lookups
+- [#2034](https://github.com/TokTok/c-toxcore/issues/2034) Make coverity-scan workflow a nightly build instead of on master push
+- [#2000](https://github.com/TokTok/c-toxcore/issues/2000) Move win32 docker image build out to dockerfiles
+- [#1990](https://github.com/TokTok/c-toxcore/issues/1990) Add a .clang-format config that matches the astyle config as closely as possible.
+- [#1115](https://github.com/TokTok/c-toxcore/issues/1115) Add empty handler for LAN discovery packets when LAN discovery is disabled
+- [#647](https://github.com/TokTok/c-toxcore/issues/647) `tox_bootstrap` should return an error on unrecoverable `getnodes` failure
+- [#169](https://github.com/TokTok/c-toxcore/issues/169) Get rid of TOX_USER_STATUS_BUSY + 1
+
## v0.2.16
### Merged PRs:
+- [#2071](https://github.com/TokTok/c-toxcore/pull/2071) chore: Release 0.2.16
- [#2069](https://github.com/TokTok/c-toxcore/pull/2069) chore: Simplify and speed up nacl build using toxchat/nacl.
- [#2066](https://github.com/TokTok/c-toxcore/pull/2066) test: Add a profiling script and Dockerfile.
- [#2058](https://github.com/TokTok/c-toxcore/pull/2058) fix: properly deallocate frozen peers
diff --git a/protocols/Tox/libtox/docs/LICENSE b/protocols/Tox/libtox/docs/LICENSE
index 10926e87f1..f288702d2f 100644
--- a/protocols/Tox/libtox/docs/LICENSE
+++ b/protocols/Tox/libtox/docs/LICENSE
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -664,12 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
-
+<https://www.gnu.org/licenses/why-not-lgpl.html>.
diff --git a/protocols/Tox/libtox/docs/README.md b/protocols/Tox/libtox/docs/README.md
index 847ec7cd6f..e7a2b6ba60 100644
--- a/protocols/Tox/libtox/docs/README.md
+++ b/protocols/Tox/libtox/docs/README.md
@@ -1,44 +1,55 @@
# ![Project Tox](https://raw.github.com/TokTok/c-toxcore/master/other/tox.png "Project Tox")
-**Current Coverage:** [![coverage](https://codecov.io/gh/TokTok/c-toxcore/branch/master/graph/badge.svg?token=BRfCKo02De)](https://codecov.io/gh/TokTok/c-toxcore)
+**Current Coverage:**
+[![coverage](https://codecov.io/gh/TokTok/c-toxcore/branch/master/graph/badge.svg?token=BRfCKo02De)](https://codecov.io/gh/TokTok/c-toxcore)
-[**Website**](https://tox.chat) **|** [**Wiki**](https://wiki.tox.chat/) **|** [**Blog**](https://blog.tox.chat/) **|** [**FAQ**](https://wiki.tox.chat/doku.php?id=users:faq) **|** [**Binaries/Downloads**](https://tox.chat/download.html) **|** [**Clients**](https://wiki.tox.chat/doku.php?id=clients) **|** [**Compiling**](/INSTALL.md)
-
-**IRC Channels:** Users: [#tox@libera.chat](https://web.libera.chat/#tox), Developers: [#toktok@libera.chat](https://web.libera.chat/#toktok)
+[**Website**](https://tox.chat) **|** [**Wiki**](https://wiki.tox.chat/) **|**
+[**Blog**](https://blog.tox.chat/) **|**
+[**FAQ**](https://wiki.tox.chat/doku.php?id=users:faq) **|**
+[**Binaries/Downloads**](https://tox.chat/download.html) **|**
+[**Clients**](https://wiki.tox.chat/doku.php?id=clients) **|**
+[**Compiling**](/INSTALL.md)
## What is Tox
Tox is a peer to peer (serverless) instant messenger aimed at making security
and privacy easy to obtain for regular users. It uses
-[NaCl](https://nacl.cr.yp.to/) for its encryption and authentication.
+[libsodium](https://doc.libsodium.org/) (based on
+[NaCl](https://nacl.cr.yp.to/)) for its encryption and authentication.
## IMPORTANT!
### ![Danger: Experimental](other/tox-warning.png)
This is an **experimental** cryptographic network library. It has not been
-formally audited by an independent third party that specializes in
-cryptography or cryptanalysis. **Use this library at your own risk.**
+formally audited by an independent third party that specializes in cryptography
+or cryptanalysis. **Use this library at your own risk.**
-The underlying crypto library [NaCl](https://nacl.cr.yp.to/install.html)
-provides reliable encryption, but the security model has not yet been fully
-specified. See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for
-a discussion on developing a threat model. See other issues for known
-weaknesses (e.g. [issue 426](https://github.com/TokTok/c-toxcore/issues/426)
-describes what can happen if your secret key is stolen).
+The underlying crypto library [libsodium](https://doc.libsodium.org/) provides
+reliable encryption, but the security model has not yet been fully specified.
+See [issue 210](https://github.com/TokTok/c-toxcore/issues/210) for a discussion
+on developing a threat model. See other issues for known weaknesses (e.g.
+[issue 426](https://github.com/TokTok/c-toxcore/issues/426) describes what can
+happen if your secret key is stolen).
## Toxcore Development Roadmap
-The roadmap and changelog are generated from GitHub issues. You may view them
-on the website, where they are updated at least once every 24 hours:
+The roadmap and changelog are generated from GitHub issues. You may view them on
+the website, where they are updated at least once every 24 hours:
-- Changelog: https://toktok.ltd/changelog/c-toxcore
-- Roadmap: https://toktok.ltd/roadmap/c-toxcore
+- Changelog: https://toktok.ltd/changelog/c-toxcore
+- Roadmap: https://toktok.ltd/roadmap/c-toxcore
## Installing toxcore
Detailed installation instructions can be found in [INSTALL.md](INSTALL.md).
+Be advised that due to the addition of `cmp` as a submodule, you now also need
+to initialize the git submodules required by toxcore. This can be done by
+cloning the repo with the following command:
+`git clone --recurse-submodules https://github.com/Toktok/c-toxcore` or by
+running `git submodule update --init` in the root directory of the repo.
+
In a nutshell, if you have [libsodium](https://github.com/jedisct1/libsodium)
installed, run:
@@ -73,17 +84,17 @@ if (err_new != TOX_ERR_NEW_OK) {
}
```
-Here, we simply exit the program, but in a real client you will probably want
-to do some error handling and proper error reporting to the user. The `NULL`
+Here, we simply exit the program, but in a real client you will probably want to
+do some error handling and proper error reporting to the user. The `NULL`
argument given to the first parameter of `tox_new` is the `Tox_Options`. It
-contains various write-once network settings and allows you to load a
-previously serialised instance. See [toxcore/tox.h](tox.h) for details.
+contains various write-once network settings and allows you to load a previously
+serialised instance. See [toxcore/tox.h](tox.h) for details.
### Setting up callbacks
-Toxcore works with callbacks that you can register to listen for certain
-events. Examples of such events are "friend request received" or "friend sent
-a message". Search the API for `tox_callback_*` to find all of them.
+Toxcore works with callbacks that you can register to listen for certain events.
+Examples of such events are "friend request received" or "friend sent a
+message". Search the API for `tox_callback_*` to find all of them.
Here, we will set up callbacks for receiving friend requests and receiving
messages. We will always accept any friend request (because we're a bot), and
@@ -171,3 +182,24 @@ the API documentation in [toxcore/tox.h](toxcore/tox.h) for more information.
- [Another echo bot](https://wiki.tox.chat/developers/client_examples/echo_bot)
- [minitox](https://github.com/hqwrong/minitox) (A minimal tox client)
+
+## SAST Tools
+
+This project uses various tools supporting Static Application Security Testing:
+
+- [clang-tidy](https://clang.llvm.org/extra/clang-tidy/): A clang-based C++
+ "linter" tool.
+- [Coverity](https://scan.coverity.com/): A cloud-based static analyzer service
+ for Java, C/C++, C#, JavaScript, Ruby, or Python that is free for open source
+ projects.
+- [cppcheck](https://cppcheck.sourceforge.io/): A static analyzer for C/C++
+ code.
+- [cpplint](https://github.com/cpplint/cpplint): Static code checker for C++
+- [goblint](https://goblint.in.tum.de/): A static analyzer for multi-threaded C
+ programs, specializing in finding concurrency bugs.
+- [infer](https://github.com/facebook/infer): A static analyzer for Java, C,
+ C++, and Objective-C.
+- [PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source):
+ A static analyzer for C, C++, C#, and Java code.
+- [tokstyle](https://github.com/TokTok/hs-tokstyle): A style checker for TokTok
+ C projects.
diff --git a/protocols/Tox/libtox/src/third_party/cmp/cmp.c b/protocols/Tox/libtox/src/third_party/cmp/cmp.c
index c312efd6c7..c11d23a8a3 100644
--- a/protocols/Tox/libtox/src/third_party/cmp/cmp.c
+++ b/protocols/Tox/libtox/src/third_party/cmp/cmp.c
@@ -865,7 +865,7 @@ bool cmp_write_pfix(cmp_ctx_t *ctx, uint8_t c) {
}
bool cmp_write_nfix(cmp_ctx_t *ctx, int8_t c) {
- if (c >= -32 && c <= -1)
+ if (c >= -0x20 && c <= -1)
return write_fixed_value(ctx, (uint8_t)c);
ctx->error = CMP_ERROR_INPUT_VALUE_TOO_LARGE;
@@ -875,7 +875,7 @@ bool cmp_write_nfix(cmp_ctx_t *ctx, int8_t c) {
bool cmp_write_sfix(cmp_ctx_t *ctx, int8_t c) {
if (c >= 0)
return cmp_write_pfix(ctx, (uint8_t)c);
- if (c >= -32 && c <= -1)
+ if (c >= -0x20 && c <= -1)
return cmp_write_nfix(ctx, c);
ctx->error = CMP_ERROR_INPUT_VALUE_TOO_LARGE;
diff --git a/protocols/Tox/libtox/src/toxcore/DHT.c b/protocols/Tox/libtox/src/toxcore/DHT.c
index 2567d1b5a8..89c85c3463 100644
--- a/protocols/Tox/libtox/src/toxcore/DHT.c
+++ b/protocols/Tox/libtox/src/toxcore/DHT.c
@@ -380,12 +380,12 @@ int dht_create_packet(const Memory *mem, const Random *rng,
const int encrypted_length = encrypt_data_symmetric(shared_key, nonce, plain, plain_length, encrypted);
- if (encrypted_length == -1) {
+ if (encrypted_length < 0) {
mem_delete(mem, encrypted);
return -1;
}
- if (length < 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + encrypted_length) {
+ if (length < 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + (size_t)encrypted_length) {
mem_delete(mem, encrypted);
return -1;
}
@@ -1347,15 +1347,15 @@ static int sendnodes_ipv6(const DHT *dht, const IP_Port *ip_port, const uint8_t
plain[0] = num_nodes;
memcpy(plain + 1 + nodes_length, sendback_data, length);
- const uint32_t crypto_size = 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE;
- const uint32_t data_size = 1 + nodes_length + length + crypto_size;
+ const uint16_t crypto_size = 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE;
+ const uint16_t data_size = 1 + nodes_length + length + crypto_size;
VLA(uint8_t, data, data_size);
const int len = dht_create_packet(dht->mem, dht->rng,
dht->self_public_key, shared_encryption_key, NET_PACKET_SEND_NODES_IPV6,
plain, 1 + nodes_length + length, data, data_size);
- if (len != data_size) {
+ if (len < 0 || (uint32_t)len != data_size) {
return -1;
}
diff --git a/protocols/Tox/libtox/src/toxcore/Makefile.inc b/protocols/Tox/libtox/src/toxcore/Makefile.inc
new file mode 100644
index 0000000000..db3e193243
--- /dev/null
+++ b/protocols/Tox/libtox/src/toxcore/Makefile.inc
@@ -0,0 +1,170 @@
+lib_LTLIBRARIES += libtoxcore.la
+
+libtoxcore_la_include_HEADERS = \
+ ../toxcore/tox.h
+
+libtoxcore_la_includedir = $(includedir)/tox
+
+libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \
+ ../third_party/cmp/cmp.h \
+ ../toxcore/attributes.h \
+ ../toxcore/bin_pack.c \
+ ../toxcore/bin_pack.h \
+ ../toxcore/bin_unpack.c \
+ ../toxcore/bin_unpack.h \
+ ../toxcore/ccompat.c \
+ ../toxcore/ccompat.h \
+ ../toxcore/events/conference_connected.c \
+ ../toxcore/events/conference_invite.c \
+ ../toxcore/events/conference_message.c \
+ ../toxcore/events/conference_peer_list_changed.c \
+ ../toxcore/events/conference_peer_name.c \
+ ../toxcore/events/conference_title.c \
+ ../toxcore/events/dht_get_nodes_response.c \
+ ../toxcore/events/events_alloc.c \
+ ../toxcore/events/events_alloc.h \
+ ../toxcore/events/file_chunk_request.c \
+ ../toxcore/events/file_recv.c \
+ ../toxcore/events/file_recv_chunk.c \
+ ../toxcore/events/file_recv_control.c \
+ ../toxcore/events/friend_connection_status.c \
+ ../toxcore/events/friend_lossless_packet.c \
+ ../toxcore/events/friend_lossy_packet.c \
+ ../toxcore/events/friend_message.c \
+ ../toxcore/events/friend_name.c \
+ ../toxcore/events/friend_read_receipt.c \
+ ../toxcore/events/friend_request.c \
+ ../toxcore/events/friend_status.c \
+ ../toxcore/events/friend_status_message.c \
+ ../toxcore/events/friend_typing.c \
+ ../toxcore/events/self_connection_status.c \
+ ../toxcore/events/group_custom_packet.c \
+ ../toxcore/events/group_custom_private_packet.c \
+ ../toxcore/events/group_invite.c \
+ ../toxcore/events/group_join_fail.c \
+ ../toxcore/events/group_message.c \
+ ../toxcore/events/group_moderation.c \
+ ../toxcore/events/group_password.c \
+ ../toxcore/events/group_peer_exit.c \
+ ../toxcore/events/group_peer_join.c \
+ ../toxcore/events/group_peer_limit.c \
+ ../toxcore/events/group_peer_name.c \
+ ../toxcore/events/group_peer_status.c \
+ ../toxcore/events/group_privacy_state.c \
+ ../toxcore/events/group_private_message.c \
+ ../toxcore/events/group_self_join.c \
+ ../toxcore/events/group_topic.c \
+ ../toxcore/events/group_topic_lock.c \
+ ../toxcore/events/group_voice_state.c \
+ ../toxcore/DHT.h \
+ ../toxcore/DHT.c \
+ ../toxcore/mem.h \
+ ../toxcore/mem.c \
+ ../toxcore/mono_time.h \
+ ../toxcore/mono_time.c \
+ ../toxcore/network.h \
+ ../toxcore/network.c \
+ ../toxcore/crypto_core.h \
+ ../toxcore/crypto_core.c \
+ ../toxcore/crypto_core_pack.h \
+ ../toxcore/crypto_core_pack.c \
+ ../toxcore/timed_auth.h \
+ ../toxcore/timed_auth.c \
+ ../toxcore/ping_array.h \
+ ../toxcore/ping_array.c \
+ ../toxcore/net_crypto.h \
+ ../toxcore/net_crypto.c \
+ ../toxcore/friend_requests.h \
+ ../toxcore/friend_requests.c \
+ ../toxcore/LAN_discovery.h \
+ ../toxcore/LAN_discovery.c \
+ ../toxcore/friend_connection.h \
+ ../toxcore/friend_connection.c \
+ ../toxcore/Messenger.h \
+ ../toxcore/Messenger.c \
+ ../toxcore/ping.h \
+ ../toxcore/ping.c \
+ ../toxcore/shared_key_cache.h \
+ ../toxcore/shared_key_cache.c \
+ ../toxcore/state.h \
+ ../toxcore/state.c \
+ ../toxcore/tox.h \
+ ../toxcore/tox.c \
+ ../toxcore/tox_dispatch.h \
+ ../toxcore/tox_dispatch.c \
+ ../toxcore/tox_event.h \
+ ../toxcore/tox_event.c \
+ ../toxcore/tox_events.h \
+ ../toxcore/tox_events.c \
+ ../toxcore/tox_pack.h \
+ ../toxcore/tox_pack.c \
+ ../toxcore/tox_unpack.h \
+ ../toxcore/tox_unpack.c \
+ ../toxcore/tox_private.c \
+ ../toxcore/tox_private.h \
+ ../toxcore/tox_struct.h \
+ ../toxcore/tox_api.c \
+ ../toxcore/util.h \
+ ../toxcore/util.c \
+ ../toxcore/group.h \
+ ../toxcore/group.c \
+ ../toxcore/group_announce.h \
+ ../toxcore/group_announce.c \
+ ../toxcore/group_onion_announce.c \
+ ../toxcore/group_onion_announce.h \
+ ../toxcore/group_chats.h \
+ ../toxcore/group_chats.c \
+ ../toxcore/group_common.h \
+ ../toxcore/group_connection.c \
+ ../toxcore/group_connection.h \
+ ../toxcore/group_pack.c \
+ ../toxcore/group_pack.h \
+ ../toxcore/group_moderation.c \
+ ../toxcore/group_moderation.h \
+ ../toxcore/onion.h \
+ ../toxcore/onion.c \
+ ../toxcore/logger.h \
+ ../toxcore/logger.c \
+ ../toxcore/onion_announce.h \
+ ../toxcore/onion_announce.c \
+ ../toxcore/onion_client.h \
+ ../toxcore/onion_client.c \
+ ../toxcore/announce.h \
+ ../toxcore/announce.c \
+ ../toxcore/forwarding.h \
+ ../toxcore/forwarding.c \
+ ../toxcore/TCP_client.h \
+ ../toxcore/TCP_client.c \
+ ../toxcore/TCP_common.h \
+ ../toxcore/TCP_common.c \
+ ../toxcore/TCP_server.h \
+ ../toxcore/TCP_server.c \
+ ../toxcore/TCP_connection.h \
+ ../toxcore/TCP_connection.c \
+ ../toxcore/list.c \
+ ../toxcore/list.h
+
+libtoxcore_la_CFLAGS = -I$(top_srcdir) \
+ -I$(top_srcdir)/toxcore \
+ $(LIBSODIUM_CFLAGS) \
+ $(MSGPACK_CFLAGS) \
+ $(PTHREAD_CFLAGS) \
+ -DCMP_NO_FLOAT=1
+
+libtoxcore_la_LDFLAGS = $(LT_LDFLAGS) \
+ $(EXTRA_LT_LDFLAGS) \
+ $(LIBSODIUM_LDFLAGS) \
+ $(MSGPACK_LDFLAGS) \
+ $(MATH_LDFLAGS) \
+ $(RT_LIBS) \
+ $(WINSOCK2_LIBS)
+
+libtoxcore_la_LIBADD = $(LIBSODIUM_LIBS) \
+ $(MSGPACK_LIBS) \
+ $(PTHREAD_LIBS)
+
+if SET_SO_VERSION
+
+EXTRA_libtoxcore_la_DEPENDENCIES = ../so.version
+
+endif
diff --git a/protocols/Tox/libtox/src/toxcore/Messenger.c b/protocols/Tox/libtox/src/toxcore/Messenger.c
index 947edef7e1..7c9730bb63 100644
--- a/protocols/Tox/libtox/src/toxcore/Messenger.c
+++ b/protocols/Tox/libtox/src/toxcore/Messenger.c
@@ -472,10 +472,6 @@ int m_delfriend(Messenger *m, int32_t friendnumber)
return -1;
}
- if (m->friend_connectionstatuschange_internal != nullptr) {
- m->friend_connectionstatuschange_internal(m, friendnumber, false, m->friend_connectionstatuschange_internal_userdata);
- }
-
clear_receipts(m, friendnumber);
remove_request_received(m->fr, m->friendlist[friendnumber].real_pk);
friend_connection_callbacks(m->fr_c, m->friendlist[friendnumber].friendcon_id, MESSENGER_CALLBACK_INDEX, nullptr,
@@ -775,31 +771,31 @@ int m_set_statusmessage(Messenger *m, const uint8_t *status, uint16_t length)
}
non_null()
-static bool userstatus_from_int(uint8_t status, Userstatus *out)
+static bool userstatus_from_int(uint8_t status, Userstatus *out_enum)
{
switch (status) {
case USERSTATUS_NONE: {
- *out = USERSTATUS_NONE;
+ *out_enum = USERSTATUS_NONE;
return true;
}
case USERSTATUS_AWAY: {
- *out = USERSTATUS_AWAY;
+ *out_enum = USERSTATUS_AWAY;
return true;
}
case USERSTATUS_BUSY: {
- *out = USERSTATUS_BUSY;
+ *out_enum = USERSTATUS_BUSY;
return true;
}
case USERSTATUS_INVALID: {
- *out = USERSTATUS_INVALID;
+ *out_enum = USERSTATUS_INVALID;
return true;
}
default: {
- *out = USERSTATUS_INVALID;
+ *out_enum = USERSTATUS_INVALID;
return false;
}
}
@@ -1027,13 +1023,6 @@ void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *funct
m->core_connection_change = function;
}
-void m_callback_connectionstatus_internal_av(Messenger *m, m_friend_connectionstatuschange_internal_cb *function,
- void *userdata)
-{
- m->friend_connectionstatuschange_internal = function;
- m->friend_connectionstatuschange_internal_userdata = userdata;
-}
-
non_null(1) nullable(3)
static void check_friend_tcp_udp(Messenger *m, int32_t friendnumber, void *userdata)
{
@@ -1081,11 +1070,6 @@ static void check_friend_connectionstatus(Messenger *m, int32_t friendnumber, ui
m->friendlist[friendnumber].status = status;
check_friend_tcp_udp(m, friendnumber, userdata);
-
- if (m->friend_connectionstatuschange_internal != nullptr) {
- m->friend_connectionstatuschange_internal(m, friendnumber, is_online,
- m->friend_connectionstatuschange_internal_userdata);
- }
}
}
@@ -1855,23 +1839,6 @@ static int handle_filecontrol(Messenger *m, int32_t friendnumber, bool outbound,
}
}
-/** @brief Set the callback for msi packets. */
-void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata)
-{
- m->msi_packet = function;
- m->msi_packet_userdata = userdata;
-}
-
-/** @brief Send an msi packet.
- *
- * @retval true on success
- * @retval false on failure
- */
-bool m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length)
-{
- return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length, false);
-}
-
static int m_handle_lossy_packet(void *object, int friendcon_id, const uint8_t *data, uint16_t length,
void *userdata)
{
@@ -1881,17 +1848,6 @@ static int m_handle_lossy_packet(void *object, int friendcon_id, const uint8_t *
return 1;
}
- if (data[0] <= PACKET_ID_RANGE_LOSSY_AV_END) {
- const RTP_Packet_Handler *const ph =
- &m->friendlist[friendcon_id].lossy_rtp_packethandlers[data[0] % PACKET_ID_RANGE_LOSSY_AV_SIZE];
-
- if (ph->function != nullptr) {
- return ph->function(m, friendcon_id, data, length, ph->object);
- }
-
- return 1;
- }
-
if (m->lossy_packethandler != nullptr) {
m->lossy_packethandler(m, friendcon_id, data[0], data, length, userdata);
}
@@ -1904,38 +1860,6 @@ void custom_lossy_packet_registerhandler(Messenger *m, m_friend_lossy_packet_cb
m->lossy_packethandler = lossy_packethandler;
}
-int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte, m_lossy_rtp_packet_cb *function,
- void *object)
-{
- if (!m_friend_exists(m, friendnumber)) {
- return -1;
- }
-
- if (byte < PACKET_ID_RANGE_LOSSY_AV_START || byte > PACKET_ID_RANGE_LOSSY_AV_END) {
- return -1;
- }
-
- m->friendlist[friendnumber].lossy_rtp_packethandlers[byte % PACKET_ID_RANGE_LOSSY_AV_SIZE].function = function;
- m->friendlist[friendnumber].lossy_rtp_packethandlers[byte % PACKET_ID_RANGE_LOSSY_AV_SIZE].object = object;
- return 0;
-}
-
-/** @brief High level function to send custom lossy packets.
- *
- * TODO(oxij): this name is confusing, because this function sends both av and custom lossy packets.
- * Meanwhile, m_handle_lossy_packet routes custom packets to custom_lossy_packet_registerhandler
- * as you would expect from its name.
- *
- * I.e. custom_lossy_packet_registerhandler's "custom lossy packet" and this "custom lossy packet"
- * are not the same set of packets.
- *
- * @retval -1 if friend invalid.
- * @retval -2 if length wrong.
- * @retval -3 if first byte invalid.
- * @retval -4 if friend offline.
- * @retval -5 if packet failed to send because of other error.
- * @retval 0 on success.
- */
int m_send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length)
{
if (!m_friend_exists(m, friendnumber)) {
@@ -1946,7 +1870,6 @@ int m_send_custom_lossy_packet(const Messenger *m, int32_t friendnumber, const u
return -2;
}
- // TODO(oxij): send_lossy_cryptpacket makes this check already, similarly for other similar places
if (data[0] < PACKET_ID_RANGE_LOSSY_START || data[0] > PACKET_ID_RANGE_LOSSY_END) {
return -3;
}
@@ -1974,7 +1897,10 @@ static int handle_custom_lossless_packet(void *object, int friend_num, const uin
}
if (packet[0] < PACKET_ID_RANGE_LOSSLESS_CUSTOM_START || packet[0] > PACKET_ID_RANGE_LOSSLESS_CUSTOM_END) {
- return -1;
+ // allow PACKET_ID_MSI packets to be handled by custom packet handler
+ if (packet[0] != PACKET_ID_MSI) {
+ return -1;
+ }
}
if (m->lossless_packethandler != nullptr) {
@@ -2357,20 +2283,6 @@ static int m_handle_packet_file_data(Messenger *m, const int friendcon_id, const
}
non_null(1, 3) nullable(5)
-static int m_handle_packet_msi(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
-{
- if (data_length == 0) {
- return 0;
- }
-
- if (m->msi_packet != nullptr) {
- m->msi_packet(m, friendcon_id, data, data_length, m->msi_packet_userdata);
- }
-
- return 0;
-}
-
-non_null(1, 3) nullable(5)
static int m_handle_packet_invite_groupchat(Messenger *m, const int friendcon_id, const uint8_t *data, const uint16_t data_length, void *userdata)
{
// first two bytes are messenger packet type and group invite type
@@ -2443,7 +2355,7 @@ static int m_handle_packet(void *object, int friendcon_id, const uint8_t *data,
case PACKET_ID_FILE_DATA:
return m_handle_packet_file_data(m, friendcon_id, payload, payload_length, userdata);
case PACKET_ID_MSI:
- return m_handle_packet_msi(m, friendcon_id, payload, payload_length, userdata);
+ return handle_custom_lossless_packet(object, friendcon_id, data, length, userdata);
case PACKET_ID_INVITE_GROUPCHAT:
return m_handle_packet_invite_groupchat(m, friendcon_id, payload, payload_length, userdata);
}
@@ -2468,14 +2380,12 @@ static void do_friends(Messenger *m, void *userdata)
}
}
- if (m->friendlist[i].status == FRIEND_REQUESTED
- || m->friendlist[i].status == FRIEND_CONFIRMED) { /* friend is not online. */
- if (m->friendlist[i].status == FRIEND_REQUESTED) {
- /* If we didn't connect to friend after successfully sending him a friend request the request is deemed
- * unsuccessful so we set the status back to FRIEND_ADDED and try again.
- */
- check_friend_request_timed_out(m, i, temp_time, userdata);
- }
+ if (m->friendlist[i].status == FRIEND_REQUESTED) {
+ /* If we didn't connect to friend after successfully sending him a friend
+ * request the request is deemed unsuccessful so we set the status back to
+ * FRIEND_ADDED and try again.
+ */
+ check_friend_request_timed_out(m, i, temp_time, userdata);
}
if (m->friendlist[i].status == FRIEND_ONLINE) { /* friend is online. */
diff --git a/protocols/Tox/libtox/src/toxcore/Messenger.h b/protocols/Tox/libtox/src/toxcore/Messenger.h
index cace3340b2..998a009f15 100644
--- a/protocols/Tox/libtox/src/toxcore/Messenger.h
+++ b/protocols/Tox/libtox/src/toxcore/Messenger.h
@@ -200,20 +200,10 @@ typedef void m_friend_lossy_packet_cb(Messenger *m, uint32_t friend_number, uint
size_t length, void *user_data);
typedef void m_friend_lossless_packet_cb(Messenger *m, uint32_t friend_number, uint8_t packet_id, const uint8_t *data,
size_t length, void *user_data);
-typedef void m_friend_connectionstatuschange_internal_cb(Messenger *m, uint32_t friend_number,
- bool is_online, void *user_data);
typedef void m_conference_invite_cb(Messenger *m, uint32_t friend_number, const uint8_t *cookie, uint16_t length,
void *user_data);
typedef void m_group_invite_cb(const Messenger *m, uint32_t friend_number, const uint8_t *invite_data, size_t length,
const uint8_t *group_name, size_t group_name_length, void *user_data);
-typedef void m_msi_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length,
- void *user_data);
-typedef int m_lossy_rtp_packet_cb(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object);
-
-typedef struct RTP_Packet_Handler {
- m_lossy_rtp_packet_cb *function;
- void *object;
-} RTP_Packet_Handler;
typedef struct Friend {
uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE];
@@ -243,8 +233,6 @@ typedef struct Friend {
uint32_t num_sending_files;
struct File_Transfers file_receiving[MAX_CONCURRENT_FILE_PIPES];
- RTP_Packet_Handler lossy_rtp_packethandlers[PACKET_ID_RANGE_LOSSY_AV_SIZE];
-
struct Receipts *receipts_start;
struct Receipts *receipts_end;
} Friend;
@@ -301,8 +289,6 @@ struct Messenger {
m_friend_typing_cb *friend_typingchange;
m_friend_read_receipt_cb *read_receipt;
m_friend_connection_status_cb *friend_connectionstatuschange;
- m_friend_connectionstatuschange_internal_cb *friend_connectionstatuschange_internal;
- void *friend_connectionstatuschange_internal_userdata;
struct Group_Chats *conferences_object;
m_conference_invite_cb *conference_invite;
@@ -314,9 +300,6 @@ struct Messenger {
m_file_recv_chunk_cb *file_filedata;
m_file_chunk_request_cb *file_reqchunk;
- m_msi_packet_cb *msi_packet;
- void *msi_packet_userdata;
-
m_friend_lossy_packet_cb *lossy_packethandler;
m_friend_lossless_packet_cb *lossless_packethandler;
@@ -614,10 +597,6 @@ non_null() void m_callback_read_receipt(Messenger *m, m_friend_read_receipt_cb *
*/
non_null() void m_callback_connectionstatus(Messenger *m, m_friend_connection_status_cb *function);
-/** Same as previous but for internal A/V core usage only */
-non_null() void m_callback_connectionstatus_internal_av(
- Messenger *m, m_friend_connectionstatuschange_internal_cb *function, void *userdata);
-
/** @brief Set the callback for typing changes. */
non_null() void m_callback_core_connection(Messenger *m, m_self_connection_status_cb *function);
@@ -731,29 +710,6 @@ non_null(1) nullable(5)
int send_file_data(const Messenger *m, int32_t friendnumber, uint32_t filenumber, uint64_t position,
const uint8_t *data, uint16_t length);
-/*** A/V related */
-
-/** @brief Set the callback for msi packets. */
-non_null(1) nullable(2, 3)
-void m_callback_msi_packet(Messenger *m, m_msi_packet_cb *function, void *userdata);
-
-/** @brief Send an msi packet.
- *
- * @retval true on success
- * @retval false on failure
- */
-non_null()
-bool m_msi_packet(const Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length);
-
-/** @brief Set handlers for lossy rtp packets.
- *
- * @retval -1 on failure.
- * @retval 0 on success.
- */
-non_null(1) nullable(4, 5)
-int m_callback_rtp_packet(Messenger *m, int32_t friendnumber, uint8_t byte,
- m_lossy_rtp_packet_cb *function, void *object);
-
/*** CUSTOM PACKETS */
/** @brief Set handlers for custom lossy packets. */
@@ -761,13 +717,6 @@ non_null() void custom_lossy_packet_registerhandler(Messenger *m, m_friend_lossy
/** @brief High level function to send custom lossy packets.
*
- * TODO(oxij): this name is confusing, because this function sends both av and custom lossy packets.
- * Meanwhile, m_handle_lossy_packet routes custom packets to custom_lossy_packet_registerhandler
- * as you would expect from its name.
- *
- * I.e. custom_lossy_packet_registerhandler's "custom lossy packet" and this "custom lossy packet"
- * are not the same set of packets.
- *
* @retval -1 if friend invalid.
* @retval -2 if length wrong.
* @retval -3 if first byte invalid.
diff --git a/protocols/Tox/libtox/src/toxcore/announce.c b/protocols/Tox/libtox/src/toxcore/announce.c
index b983cb0574..7bda993232 100644
--- a/protocols/Tox/libtox/src/toxcore/announce.c
+++ b/protocols/Tox/libtox/src/toxcore/announce.c
@@ -579,7 +579,7 @@ static int create_reply(Announcements *announce, const IP_Port *source,
const int plain_reply_max_len = (int)reply_max_length -
(1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
- if (plain_reply_max_len < sizeof(uint64_t)) {
+ if (plain_reply_max_len < (int)sizeof(uint64_t)) {
return -1;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_connected.c b/protocols/Tox/libtox/src/toxcore/events/conference_connected.c
index dbd9e4b51a..8aeb17204b 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_connected.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_connected.c
@@ -109,7 +109,10 @@ static Tox_Event_Conference_Connected *tox_events_add_conference_connected(Tox_E
event.type = TOX_EVENT_CONFERENCE_CONNECTED;
event.data.conference_connected = conference_connected;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_connected_free(conference_connected, mem);
+ return nullptr;
+ }
return conference_connected;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_invite.c b/protocols/Tox/libtox/src/toxcore/events/conference_invite.c
index fb1f794bf3..c9b8d14bc1 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_invite.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_invite.c
@@ -177,7 +177,10 @@ static Tox_Event_Conference_Invite *tox_events_add_conference_invite(Tox_Events
event.type = TOX_EVENT_CONFERENCE_INVITE;
event.data.conference_invite = conference_invite;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_invite_free(conference_invite, mem);
+ return nullptr;
+ }
return conference_invite;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_message.c b/protocols/Tox/libtox/src/toxcore/events/conference_message.c
index 74e1123e01..e509827e45 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_message.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_message.c
@@ -193,7 +193,10 @@ static Tox_Event_Conference_Message *tox_events_add_conference_message(Tox_Event
event.type = TOX_EVENT_CONFERENCE_MESSAGE;
event.data.conference_message = conference_message;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_message_free(conference_message, mem);
+ return nullptr;
+ }
return conference_message;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_peer_list_changed.c b/protocols/Tox/libtox/src/toxcore/events/conference_peer_list_changed.c
index 050bfb08f8..f7efd3f806 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_peer_list_changed.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_peer_list_changed.c
@@ -109,7 +109,10 @@ static Tox_Event_Conference_Peer_List_Changed *tox_events_add_conference_peer_li
event.type = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
event.data.conference_peer_list_changed = conference_peer_list_changed;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_peer_list_changed_free(conference_peer_list_changed, mem);
+ return nullptr;
+ }
return conference_peer_list_changed;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_peer_name.c b/protocols/Tox/libtox/src/toxcore/events/conference_peer_name.c
index fc6c255791..930065631f 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_peer_name.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_peer_name.c
@@ -175,7 +175,10 @@ static Tox_Event_Conference_Peer_Name *tox_events_add_conference_peer_name(Tox_E
event.type = TOX_EVENT_CONFERENCE_PEER_NAME;
event.data.conference_peer_name = conference_peer_name;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_peer_name_free(conference_peer_name, mem);
+ return nullptr;
+ }
return conference_peer_name;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/conference_title.c b/protocols/Tox/libtox/src/toxcore/events/conference_title.c
index d761f51285..d8e269032e 100644
--- a/protocols/Tox/libtox/src/toxcore/events/conference_title.c
+++ b/protocols/Tox/libtox/src/toxcore/events/conference_title.c
@@ -175,7 +175,10 @@ static Tox_Event_Conference_Title *tox_events_add_conference_title(Tox_Events *e
event.type = TOX_EVENT_CONFERENCE_TITLE;
event.data.conference_title = conference_title;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_conference_title_free(conference_title, mem);
+ return nullptr;
+ }
return conference_title;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/dht_get_nodes_response.c b/protocols/Tox/libtox/src/toxcore/events/dht_get_nodes_response.c
index 6e03b73ea4..f637b9c93a 100644
--- a/protocols/Tox/libtox/src/toxcore/events/dht_get_nodes_response.c
+++ b/protocols/Tox/libtox/src/toxcore/events/dht_get_nodes_response.c
@@ -158,7 +158,10 @@ static Tox_Event_Dht_Get_Nodes_Response *tox_events_add_dht_get_nodes_response(T
event.type = TOX_EVENT_DHT_GET_NODES_RESPONSE;
event.data.dht_get_nodes_response = dht_get_nodes_response;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_dht_get_nodes_response_free(dht_get_nodes_response, mem);
+ return nullptr;
+ }
return dht_get_nodes_response;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/file_chunk_request.c b/protocols/Tox/libtox/src/toxcore/events/file_chunk_request.c
index 4117ef3c4b..23e5f5bf18 100644
--- a/protocols/Tox/libtox/src/toxcore/events/file_chunk_request.c
+++ b/protocols/Tox/libtox/src/toxcore/events/file_chunk_request.c
@@ -162,7 +162,10 @@ static Tox_Event_File_Chunk_Request *tox_events_add_file_chunk_request(Tox_Event
event.type = TOX_EVENT_FILE_CHUNK_REQUEST;
event.data.file_chunk_request = file_chunk_request;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_file_chunk_request_free(file_chunk_request, mem);
+ return nullptr;
+ }
return file_chunk_request;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/file_recv.c b/protocols/Tox/libtox/src/toxcore/events/file_recv.c
index 45cec44b0d..389ce59830 100644
--- a/protocols/Tox/libtox/src/toxcore/events/file_recv.c
+++ b/protocols/Tox/libtox/src/toxcore/events/file_recv.c
@@ -207,7 +207,10 @@ static Tox_Event_File_Recv *tox_events_add_file_recv(Tox_Events *events, const M
event.type = TOX_EVENT_FILE_RECV;
event.data.file_recv = file_recv;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_file_recv_free(file_recv, mem);
+ return nullptr;
+ }
return file_recv;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/file_recv_chunk.c b/protocols/Tox/libtox/src/toxcore/events/file_recv_chunk.c
index 2edf7c5a7b..619011a4af 100644
--- a/protocols/Tox/libtox/src/toxcore/events/file_recv_chunk.c
+++ b/protocols/Tox/libtox/src/toxcore/events/file_recv_chunk.c
@@ -191,7 +191,10 @@ static Tox_Event_File_Recv_Chunk *tox_events_add_file_recv_chunk(Tox_Events *eve
event.type = TOX_EVENT_FILE_RECV_CHUNK;
event.data.file_recv_chunk = file_recv_chunk;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_file_recv_chunk_free(file_recv_chunk, mem);
+ return nullptr;
+ }
return file_recv_chunk;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/file_recv_control.c b/protocols/Tox/libtox/src/toxcore/events/file_recv_control.c
index 14a34aaf3b..3c575c09a6 100644
--- a/protocols/Tox/libtox/src/toxcore/events/file_recv_control.c
+++ b/protocols/Tox/libtox/src/toxcore/events/file_recv_control.c
@@ -148,7 +148,10 @@ static Tox_Event_File_Recv_Control *tox_events_add_file_recv_control(Tox_Events
event.type = TOX_EVENT_FILE_RECV_CONTROL;
event.data.file_recv_control = file_recv_control;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_file_recv_control_free(file_recv_control, mem);
+ return nullptr;
+ }
return file_recv_control;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_connection_status.c b/protocols/Tox/libtox/src/toxcore/events/friend_connection_status.c
index 330554b05e..68c48695ad 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_connection_status.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_connection_status.c
@@ -132,7 +132,10 @@ static Tox_Event_Friend_Connection_Status *tox_events_add_friend_connection_stat
event.type = TOX_EVENT_FRIEND_CONNECTION_STATUS;
event.data.friend_connection_status = friend_connection_status;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_connection_status_free(friend_connection_status, mem);
+ return nullptr;
+ }
return friend_connection_status;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_lossless_packet.c b/protocols/Tox/libtox/src/toxcore/events/friend_lossless_packet.c
index 17e8fad926..b783e332f0 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_lossless_packet.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_lossless_packet.c
@@ -159,7 +159,10 @@ static Tox_Event_Friend_Lossless_Packet *tox_events_add_friend_lossless_packet(T
event.type = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
event.data.friend_lossless_packet = friend_lossless_packet;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_lossless_packet_free(friend_lossless_packet, mem);
+ return nullptr;
+ }
return friend_lossless_packet;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_lossy_packet.c b/protocols/Tox/libtox/src/toxcore/events/friend_lossy_packet.c
index 6b2e9ed2b0..e3a6ad5f59 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_lossy_packet.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_lossy_packet.c
@@ -159,7 +159,10 @@ static Tox_Event_Friend_Lossy_Packet *tox_events_add_friend_lossy_packet(Tox_Eve
event.type = TOX_EVENT_FRIEND_LOSSY_PACKET;
event.data.friend_lossy_packet = friend_lossy_packet;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_lossy_packet_free(friend_lossy_packet, mem);
+ return nullptr;
+ }
return friend_lossy_packet;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_message.c b/protocols/Tox/libtox/src/toxcore/events/friend_message.c
index befcc74a24..dfd1daea39 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_message.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_message.c
@@ -177,7 +177,10 @@ static Tox_Event_Friend_Message *tox_events_add_friend_message(Tox_Events *event
event.type = TOX_EVENT_FRIEND_MESSAGE;
event.data.friend_message = friend_message;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_message_free(friend_message, mem);
+ return nullptr;
+ }
return friend_message;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_name.c b/protocols/Tox/libtox/src/toxcore/events/friend_name.c
index dfa9b39608..b5a5129724 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_name.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_name.c
@@ -159,7 +159,10 @@ static Tox_Event_Friend_Name *tox_events_add_friend_name(Tox_Events *events, con
event.type = TOX_EVENT_FRIEND_NAME;
event.data.friend_name = friend_name;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_name_free(friend_name, mem);
+ return nullptr;
+ }
return friend_name;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_read_receipt.c b/protocols/Tox/libtox/src/toxcore/events/friend_read_receipt.c
index e5f2f9db52..88808b5825 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_read_receipt.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_read_receipt.c
@@ -130,7 +130,10 @@ static Tox_Event_Friend_Read_Receipt *tox_events_add_friend_read_receipt(Tox_Eve
event.type = TOX_EVENT_FRIEND_READ_RECEIPT;
event.data.friend_read_receipt = friend_read_receipt;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_read_receipt_free(friend_read_receipt, mem);
+ return nullptr;
+ }
return friend_read_receipt;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_request.c b/protocols/Tox/libtox/src/toxcore/events/friend_request.c
index b492c15147..6cd8ac66c7 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_request.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_request.c
@@ -152,7 +152,10 @@ static Tox_Event_Friend_Request *tox_events_add_friend_request(Tox_Events *event
event.type = TOX_EVENT_FRIEND_REQUEST;
event.data.friend_request = friend_request;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_request_free(friend_request, mem);
+ return nullptr;
+ }
return friend_request;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_status.c b/protocols/Tox/libtox/src/toxcore/events/friend_status.c
index 3d7499722b..5af2d451d7 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_status.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_status.c
@@ -132,7 +132,10 @@ static Tox_Event_Friend_Status *tox_events_add_friend_status(Tox_Events *events,
event.type = TOX_EVENT_FRIEND_STATUS;
event.data.friend_status = friend_status;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_status_free(friend_status, mem);
+ return nullptr;
+ }
return friend_status;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_status_message.c b/protocols/Tox/libtox/src/toxcore/events/friend_status_message.c
index ad0519911e..178342f292 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_status_message.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_status_message.c
@@ -159,7 +159,10 @@ static Tox_Event_Friend_Status_Message *tox_events_add_friend_status_message(Tox
event.type = TOX_EVENT_FRIEND_STATUS_MESSAGE;
event.data.friend_status_message = friend_status_message;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_status_message_free(friend_status_message, mem);
+ return nullptr;
+ }
return friend_status_message;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/friend_typing.c b/protocols/Tox/libtox/src/toxcore/events/friend_typing.c
index 692b07fb88..96c719570f 100644
--- a/protocols/Tox/libtox/src/toxcore/events/friend_typing.c
+++ b/protocols/Tox/libtox/src/toxcore/events/friend_typing.c
@@ -130,7 +130,10 @@ static Tox_Event_Friend_Typing *tox_events_add_friend_typing(Tox_Events *events,
event.type = TOX_EVENT_FRIEND_TYPING;
event.data.friend_typing = friend_typing;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_friend_typing_free(friend_typing, mem);
+ return nullptr;
+ }
return friend_typing;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_custom_packet.c b/protocols/Tox/libtox/src/toxcore/events/group_custom_packet.c
index a82e2c3a6c..eb4d49d594 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_custom_packet.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_custom_packet.c
@@ -175,7 +175,10 @@ static Tox_Event_Group_Custom_Packet *tox_events_add_group_custom_packet(Tox_Eve
event.type = TOX_EVENT_GROUP_CUSTOM_PACKET;
event.data.group_custom_packet = group_custom_packet;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_custom_packet_free(group_custom_packet, mem);
+ return nullptr;
+ }
return group_custom_packet;
}
@@ -220,7 +223,7 @@ static Tox_Event_Group_Custom_Packet *tox_event_group_custom_packet_alloc(void *
*****************************************************/
void tox_events_handle_group_custom_packet(
- Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t data_length,
void *user_data)
{
Tox_Event_Group_Custom_Packet *group_custom_packet = tox_event_group_custom_packet_alloc(user_data);
@@ -231,5 +234,5 @@ void tox_events_handle_group_custom_packet(
tox_event_group_custom_packet_set_group_number(group_custom_packet, group_number);
tox_event_group_custom_packet_set_peer_id(group_custom_packet, peer_id);
- tox_event_group_custom_packet_set_data(group_custom_packet, data, length);
+ tox_event_group_custom_packet_set_data(group_custom_packet, data, data_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_custom_private_packet.c b/protocols/Tox/libtox/src/toxcore/events/group_custom_private_packet.c
index 56282f0fb8..f7c1634120 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_custom_private_packet.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_custom_private_packet.c
@@ -175,7 +175,10 @@ static Tox_Event_Group_Custom_Private_Packet *tox_events_add_group_custom_privat
event.type = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
event.data.group_custom_private_packet = group_custom_private_packet;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_custom_private_packet_free(group_custom_private_packet, mem);
+ return nullptr;
+ }
return group_custom_private_packet;
}
@@ -220,7 +223,7 @@ static Tox_Event_Group_Custom_Private_Packet *tox_event_group_custom_private_pac
*****************************************************/
void tox_events_handle_group_custom_private_packet(
- Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t length,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *data, size_t data_length,
void *user_data)
{
Tox_Event_Group_Custom_Private_Packet *group_custom_private_packet = tox_event_group_custom_private_packet_alloc(user_data);
@@ -231,5 +234,5 @@ void tox_events_handle_group_custom_private_packet(
tox_event_group_custom_private_packet_set_group_number(group_custom_private_packet, group_number);
tox_event_group_custom_private_packet_set_peer_id(group_custom_private_packet, peer_id);
- tox_event_group_custom_private_packet_set_data(group_custom_private_packet, data, length);
+ tox_event_group_custom_private_packet_set_data(group_custom_private_packet, data, data_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_invite.c b/protocols/Tox/libtox/src/toxcore/events/group_invite.c
index 0691dcd1fe..6372eb598c 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_invite.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_invite.c
@@ -203,7 +203,10 @@ static Tox_Event_Group_Invite *tox_events_add_group_invite(Tox_Events *events, c
event.type = TOX_EVENT_GROUP_INVITE;
event.data.group_invite = group_invite;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_invite_free(group_invite, mem);
+ return nullptr;
+ }
return group_invite;
}
@@ -248,7 +251,7 @@ static Tox_Event_Group_Invite *tox_event_group_invite_alloc(void *user_data)
*****************************************************/
void tox_events_handle_group_invite(
- Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t length, const uint8_t *group_name, size_t group_name_length,
+ Tox *tox, uint32_t friend_number, const uint8_t *invite_data, size_t invite_data_length, const uint8_t *group_name, size_t group_name_length,
void *user_data)
{
Tox_Event_Group_Invite *group_invite = tox_event_group_invite_alloc(user_data);
@@ -258,6 +261,6 @@ void tox_events_handle_group_invite(
}
tox_event_group_invite_set_friend_number(group_invite, friend_number);
- tox_event_group_invite_set_invite_data(group_invite, invite_data, length);
+ tox_event_group_invite_set_invite_data(group_invite, invite_data, invite_data_length);
tox_event_group_invite_set_group_name(group_invite, group_name, group_name_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_join_fail.c b/protocols/Tox/libtox/src/toxcore/events/group_join_fail.c
index b85896858b..7b95454b84 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_join_fail.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_join_fail.c
@@ -132,7 +132,10 @@ static Tox_Event_Group_Join_Fail *tox_events_add_group_join_fail(Tox_Events *eve
event.type = TOX_EVENT_GROUP_JOIN_FAIL;
event.data.group_join_fail = group_join_fail;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_join_fail_free(group_join_fail, mem);
+ return nullptr;
+ }
return group_join_fail;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_message.c b/protocols/Tox/libtox/src/toxcore/events/group_message.c
index a200f84566..9ed07e43a6 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_message.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_message.c
@@ -27,7 +27,7 @@
struct Tox_Event_Group_Message {
uint32_t group_number;
uint32_t peer_id;
- Tox_Message_Type type;
+ Tox_Message_Type message_type;
uint8_t *message;
uint32_t message_length;
uint32_t message_id;
@@ -60,16 +60,16 @@ uint32_t tox_event_group_message_get_peer_id(const Tox_Event_Group_Message *grou
}
non_null()
-static void tox_event_group_message_set_type(Tox_Event_Group_Message *group_message,
- Tox_Message_Type type)
+static void tox_event_group_message_set_message_type(Tox_Event_Group_Message *group_message,
+ Tox_Message_Type message_type)
{
assert(group_message != nullptr);
- group_message->type = type;
+ group_message->message_type = message_type;
}
-Tox_Message_Type tox_event_group_message_get_type(const Tox_Event_Group_Message *group_message)
+Tox_Message_Type tox_event_group_message_get_message_type(const Tox_Event_Group_Message *group_message)
{
assert(group_message != nullptr);
- return group_message->type;
+ return group_message->message_type;
}
non_null(1) nullable(2)
@@ -143,7 +143,7 @@ bool tox_event_group_message_pack(
return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
- && tox_message_type_pack(event->type, bp)
+ && tox_message_type_pack(event->message_type, bp)
&& bin_pack_bin(bp, event->message, event->message_length)
&& bin_pack_u32(bp, event->message_id);
}
@@ -159,7 +159,7 @@ static bool tox_event_group_message_unpack_into(
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
- && tox_message_type_unpack(&event->type, bu)
+ && tox_message_type_unpack(&event->message_type, bu)
&& bin_unpack_bin(bu, &event->message, &event->message_length)
&& bin_unpack_u32(bu, &event->message_id);
}
@@ -209,7 +209,10 @@ static Tox_Event_Group_Message *tox_events_add_group_message(Tox_Events *events,
event.type = TOX_EVENT_GROUP_MESSAGE;
event.data.group_message = group_message;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_message_free(group_message, mem);
+ return nullptr;
+ }
return group_message;
}
@@ -254,7 +257,7 @@ static Tox_Event_Group_Message *tox_event_group_message_alloc(void *user_data)
*****************************************************/
void tox_events_handle_group_message(
- Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type message_type, const uint8_t *message, size_t message_length, uint32_t message_id,
void *user_data)
{
Tox_Event_Group_Message *group_message = tox_event_group_message_alloc(user_data);
@@ -265,7 +268,7 @@ void tox_events_handle_group_message(
tox_event_group_message_set_group_number(group_message, group_number);
tox_event_group_message_set_peer_id(group_message, peer_id);
- tox_event_group_message_set_type(group_message, type);
- tox_event_group_message_set_message(group_message, message, length);
+ tox_event_group_message_set_message_type(group_message, message_type);
+ tox_event_group_message_set_message(group_message, message, message_length);
tox_event_group_message_set_message_id(group_message, message_id);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_moderation.c b/protocols/Tox/libtox/src/toxcore/events/group_moderation.c
index ba510d5b2a..eb8d3ba41e 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_moderation.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_moderation.c
@@ -164,7 +164,10 @@ static Tox_Event_Group_Moderation *tox_events_add_group_moderation(Tox_Events *e
event.type = TOX_EVENT_GROUP_MODERATION;
event.data.group_moderation = group_moderation;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_moderation_free(group_moderation, mem);
+ return nullptr;
+ }
return group_moderation;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_password.c b/protocols/Tox/libtox/src/toxcore/events/group_password.c
index ad6e86b9d3..14bda0f766 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_password.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_password.c
@@ -159,7 +159,10 @@ static Tox_Event_Group_Password *tox_events_add_group_password(Tox_Events *event
event.type = TOX_EVENT_GROUP_PASSWORD;
event.data.group_password = group_password;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_password_free(group_password, mem);
+ return nullptr;
+ }
return group_password;
}
@@ -204,7 +207,7 @@ static Tox_Event_Group_Password *tox_event_group_password_alloc(void *user_data)
*****************************************************/
void tox_events_handle_group_password(
- Tox *tox, uint32_t group_number, const uint8_t *password, size_t length,
+ Tox *tox, uint32_t group_number, const uint8_t *password, size_t password_length,
void *user_data)
{
Tox_Event_Group_Password *group_password = tox_event_group_password_alloc(user_data);
@@ -214,5 +217,5 @@ void tox_events_handle_group_password(
}
tox_event_group_password_set_group_number(group_password, group_number);
- tox_event_group_password_set_password(group_password, password, length);
+ tox_event_group_password_set_password(group_password, password, password_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_peer_exit.c b/protocols/Tox/libtox/src/toxcore/events/group_peer_exit.c
index 16d1eba7a6..405b4b6c16 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_peer_exit.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_peer_exit.c
@@ -237,7 +237,10 @@ static Tox_Event_Group_Peer_Exit *tox_events_add_group_peer_exit(Tox_Events *eve
event.type = TOX_EVENT_GROUP_PEER_EXIT;
event.data.group_peer_exit = group_peer_exit;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_peer_exit_free(group_peer_exit, mem);
+ return nullptr;
+ }
return group_peer_exit;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_peer_join.c b/protocols/Tox/libtox/src/toxcore/events/group_peer_join.c
index af0d006e87..8dc34befee 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_peer_join.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_peer_join.c
@@ -130,7 +130,10 @@ static Tox_Event_Group_Peer_Join *tox_events_add_group_peer_join(Tox_Events *eve
event.type = TOX_EVENT_GROUP_PEER_JOIN;
event.data.group_peer_join = group_peer_join;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_peer_join_free(group_peer_join, mem);
+ return nullptr;
+ }
return group_peer_join;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_peer_limit.c b/protocols/Tox/libtox/src/toxcore/events/group_peer_limit.c
index 5e2e23558c..157827c560 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_peer_limit.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_peer_limit.c
@@ -130,7 +130,10 @@ static Tox_Event_Group_Peer_Limit *tox_events_add_group_peer_limit(Tox_Events *e
event.type = TOX_EVENT_GROUP_PEER_LIMIT;
event.data.group_peer_limit = group_peer_limit;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_peer_limit_free(group_peer_limit, mem);
+ return nullptr;
+ }
return group_peer_limit;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_peer_name.c b/protocols/Tox/libtox/src/toxcore/events/group_peer_name.c
index f8273e94b4..063a6ab9a3 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_peer_name.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_peer_name.c
@@ -175,7 +175,10 @@ static Tox_Event_Group_Peer_Name *tox_events_add_group_peer_name(Tox_Events *eve
event.type = TOX_EVENT_GROUP_PEER_NAME;
event.data.group_peer_name = group_peer_name;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_peer_name_free(group_peer_name, mem);
+ return nullptr;
+ }
return group_peer_name;
}
@@ -220,7 +223,7 @@ static Tox_Event_Group_Peer_Name *tox_event_group_peer_name_alloc(void *user_dat
*****************************************************/
void tox_events_handle_group_peer_name(
- Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t length,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *name, size_t name_length,
void *user_data)
{
Tox_Event_Group_Peer_Name *group_peer_name = tox_event_group_peer_name_alloc(user_data);
@@ -231,5 +234,5 @@ void tox_events_handle_group_peer_name(
tox_event_group_peer_name_set_group_number(group_peer_name, group_number);
tox_event_group_peer_name_set_peer_id(group_peer_name, peer_id);
- tox_event_group_peer_name_set_name(group_peer_name, name, length);
+ tox_event_group_peer_name_set_name(group_peer_name, name, name_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_peer_status.c b/protocols/Tox/libtox/src/toxcore/events/group_peer_status.c
index 4165d90ec2..d646caec8c 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_peer_status.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_peer_status.c
@@ -148,7 +148,10 @@ static Tox_Event_Group_Peer_Status *tox_events_add_group_peer_status(Tox_Events
event.type = TOX_EVENT_GROUP_PEER_STATUS;
event.data.group_peer_status = group_peer_status;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_peer_status_free(group_peer_status, mem);
+ return nullptr;
+ }
return group_peer_status;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_privacy_state.c b/protocols/Tox/libtox/src/toxcore/events/group_privacy_state.c
index 1c683c255c..3fa081c20a 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_privacy_state.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_privacy_state.c
@@ -132,7 +132,10 @@ static Tox_Event_Group_Privacy_State *tox_events_add_group_privacy_state(Tox_Eve
event.type = TOX_EVENT_GROUP_PRIVACY_STATE;
event.data.group_privacy_state = group_privacy_state;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_privacy_state_free(group_privacy_state, mem);
+ return nullptr;
+ }
return group_privacy_state;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_private_message.c b/protocols/Tox/libtox/src/toxcore/events/group_private_message.c
index 648f707880..9b7f95aa3d 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_private_message.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_private_message.c
@@ -27,9 +27,10 @@
struct Tox_Event_Group_Private_Message {
uint32_t group_number;
uint32_t peer_id;
- Tox_Message_Type type;
+ Tox_Message_Type message_type;
uint8_t *message;
uint32_t message_length;
+ uint32_t message_id;
};
non_null()
@@ -59,16 +60,16 @@ uint32_t tox_event_group_private_message_get_peer_id(const Tox_Event_Group_Priva
}
non_null()
-static void tox_event_group_private_message_set_type(Tox_Event_Group_Private_Message *group_private_message,
- Tox_Message_Type type)
+static void tox_event_group_private_message_set_message_type(Tox_Event_Group_Private_Message *group_private_message,
+ Tox_Message_Type message_type)
{
assert(group_private_message != nullptr);
- group_private_message->type = type;
+ group_private_message->message_type = message_type;
}
-Tox_Message_Type tox_event_group_private_message_get_type(const Tox_Event_Group_Private_Message *group_private_message)
+Tox_Message_Type tox_event_group_private_message_get_message_type(const Tox_Event_Group_Private_Message *group_private_message)
{
assert(group_private_message != nullptr);
- return group_private_message->type;
+ return group_private_message->message_type;
}
non_null(1) nullable(2)
@@ -111,6 +112,19 @@ const uint8_t *tox_event_group_private_message_get_message(const Tox_Event_Group
}
non_null()
+static void tox_event_group_private_message_set_message_id(Tox_Event_Group_Private_Message *group_private_message,
+ uint32_t message_id)
+{
+ assert(group_private_message != nullptr);
+ group_private_message->message_id = message_id;
+}
+uint32_t tox_event_group_private_message_get_message_id(const Tox_Event_Group_Private_Message *group_private_message)
+{
+ assert(group_private_message != nullptr);
+ return group_private_message->message_id;
+}
+
+non_null()
static void tox_event_group_private_message_construct(Tox_Event_Group_Private_Message *group_private_message)
{
*group_private_message = (Tox_Event_Group_Private_Message) {
@@ -126,11 +140,12 @@ static void tox_event_group_private_message_destruct(Tox_Event_Group_Private_Mes
bool tox_event_group_private_message_pack(
const Tox_Event_Group_Private_Message *event, Bin_Pack *bp)
{
- return bin_pack_array(bp, 4)
+ return bin_pack_array(bp, 5)
&& bin_pack_u32(bp, event->group_number)
&& bin_pack_u32(bp, event->peer_id)
- && tox_message_type_pack(event->type, bp)
- && bin_pack_bin(bp, event->message, event->message_length);
+ && tox_message_type_pack(event->message_type, bp)
+ && bin_pack_bin(bp, event->message, event->message_length)
+ && bin_pack_u32(bp, event->message_id);
}
non_null()
@@ -138,14 +153,15 @@ static bool tox_event_group_private_message_unpack_into(
Tox_Event_Group_Private_Message *event, Bin_Unpack *bu)
{
assert(event != nullptr);
- if (!bin_unpack_array_fixed(bu, 4, nullptr)) {
+ if (!bin_unpack_array_fixed(bu, 5, nullptr)) {
return false;
}
return bin_unpack_u32(bu, &event->group_number)
&& bin_unpack_u32(bu, &event->peer_id)
- && tox_message_type_unpack(&event->type, bu)
- && bin_unpack_bin(bu, &event->message, &event->message_length);
+ && tox_message_type_unpack(&event->message_type, bu)
+ && bin_unpack_bin(bu, &event->message, &event->message_length)
+ && bin_unpack_u32(bu, &event->message_id);
}
/*****************************************************
@@ -193,7 +209,10 @@ static Tox_Event_Group_Private_Message *tox_events_add_group_private_message(Tox
event.type = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
event.data.group_private_message = group_private_message;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_private_message_free(group_private_message, mem);
+ return nullptr;
+ }
return group_private_message;
}
@@ -238,7 +257,7 @@ static Tox_Event_Group_Private_Message *tox_event_group_private_message_alloc(vo
*****************************************************/
void tox_events_handle_group_private_message(
- Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type, const uint8_t *message, size_t length,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type message_type, const uint8_t *message, size_t message_length, uint32_t message_id,
void *user_data)
{
Tox_Event_Group_Private_Message *group_private_message = tox_event_group_private_message_alloc(user_data);
@@ -249,6 +268,7 @@ void tox_events_handle_group_private_message(
tox_event_group_private_message_set_group_number(group_private_message, group_number);
tox_event_group_private_message_set_peer_id(group_private_message, peer_id);
- tox_event_group_private_message_set_type(group_private_message, type);
- tox_event_group_private_message_set_message(group_private_message, message, length);
+ tox_event_group_private_message_set_message_type(group_private_message, message_type);
+ tox_event_group_private_message_set_message(group_private_message, message, message_length);
+ tox_event_group_private_message_set_message_id(group_private_message, message_id);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_self_join.c b/protocols/Tox/libtox/src/toxcore/events/group_self_join.c
index 0745e975f8..6cc3080aa6 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_self_join.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_self_join.c
@@ -109,7 +109,10 @@ static Tox_Event_Group_Self_Join *tox_events_add_group_self_join(Tox_Events *eve
event.type = TOX_EVENT_GROUP_SELF_JOIN;
event.data.group_self_join = group_self_join;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_self_join_free(group_self_join, mem);
+ return nullptr;
+ }
return group_self_join;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_topic.c b/protocols/Tox/libtox/src/toxcore/events/group_topic.c
index 23cdd5d354..7588d43f7f 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_topic.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_topic.c
@@ -175,7 +175,10 @@ static Tox_Event_Group_Topic *tox_events_add_group_topic(Tox_Events *events, con
event.type = TOX_EVENT_GROUP_TOPIC;
event.data.group_topic = group_topic;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_topic_free(group_topic, mem);
+ return nullptr;
+ }
return group_topic;
}
@@ -220,7 +223,7 @@ static Tox_Event_Group_Topic *tox_event_group_topic_alloc(void *user_data)
*****************************************************/
void tox_events_handle_group_topic(
- Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t length,
+ Tox *tox, uint32_t group_number, uint32_t peer_id, const uint8_t *topic, size_t topic_length,
void *user_data)
{
Tox_Event_Group_Topic *group_topic = tox_event_group_topic_alloc(user_data);
@@ -231,5 +234,5 @@ void tox_events_handle_group_topic(
tox_event_group_topic_set_group_number(group_topic, group_number);
tox_event_group_topic_set_peer_id(group_topic, peer_id);
- tox_event_group_topic_set_topic(group_topic, topic, length);
+ tox_event_group_topic_set_topic(group_topic, topic, topic_length);
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_topic_lock.c b/protocols/Tox/libtox/src/toxcore/events/group_topic_lock.c
index 36fb49393a..431ff38159 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_topic_lock.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_topic_lock.c
@@ -132,7 +132,10 @@ static Tox_Event_Group_Topic_Lock *tox_events_add_group_topic_lock(Tox_Events *e
event.type = TOX_EVENT_GROUP_TOPIC_LOCK;
event.data.group_topic_lock = group_topic_lock;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_topic_lock_free(group_topic_lock, mem);
+ return nullptr;
+ }
return group_topic_lock;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/group_voice_state.c b/protocols/Tox/libtox/src/toxcore/events/group_voice_state.c
index fba0300389..d9c592b882 100644
--- a/protocols/Tox/libtox/src/toxcore/events/group_voice_state.c
+++ b/protocols/Tox/libtox/src/toxcore/events/group_voice_state.c
@@ -132,7 +132,10 @@ static Tox_Event_Group_Voice_State *tox_events_add_group_voice_state(Tox_Events
event.type = TOX_EVENT_GROUP_VOICE_STATE;
event.data.group_voice_state = group_voice_state;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_group_voice_state_free(group_voice_state, mem);
+ return nullptr;
+ }
return group_voice_state;
}
diff --git a/protocols/Tox/libtox/src/toxcore/events/self_connection_status.c b/protocols/Tox/libtox/src/toxcore/events/self_connection_status.c
index 8d8bc803ea..b79d70b408 100644
--- a/protocols/Tox/libtox/src/toxcore/events/self_connection_status.c
+++ b/protocols/Tox/libtox/src/toxcore/events/self_connection_status.c
@@ -111,7 +111,10 @@ static Tox_Event_Self_Connection_Status *tox_events_add_self_connection_status(T
event.type = TOX_EVENT_SELF_CONNECTION_STATUS;
event.data.self_connection_status = self_connection_status;
- tox_events_add(events, &event);
+ if (!tox_events_add(events, &event)) {
+ tox_event_self_connection_status_free(self_connection_status, mem);
+ return nullptr;
+ }
return self_connection_status;
}
diff --git a/protocols/Tox/libtox/src/toxcore/friend_connection.c b/protocols/Tox/libtox/src/toxcore/friend_connection.c
index 33bfa40d34..f017b08888 100644
--- a/protocols/Tox/libtox/src/toxcore/friend_connection.c
+++ b/protocols/Tox/libtox/src/toxcore/friend_connection.c
@@ -1032,6 +1032,11 @@ void kill_friend_connections(Friend_Connections *fr_c)
kill_friend_connection(fr_c, i);
}
+ // there might be allocated NONE connections
+ if (fr_c->conns != nullptr) {
+ free(fr_c->conns);
+ }
+
lan_discovery_kill(fr_c->broadcast);
free(fr_c);
}
diff --git a/protocols/Tox/libtox/src/toxcore/group.c b/protocols/Tox/libtox/src/toxcore/group.c
index 14e61e6ffc..3d96b962de 100644
--- a/protocols/Tox/libtox/src/toxcore/group.c
+++ b/protocols/Tox/libtox/src/toxcore/group.c
@@ -2520,7 +2520,7 @@ static int handle_send_peers(Group_Chats *g_c, uint32_t groupnumber, const uint8
non_null(1, 3) nullable(6)
static void handle_direct_packet(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, uint16_t length,
- int connection_index, void *userdata)
+ uint32_t connection_index, void *userdata)
{
if (length == 0) {
return;
@@ -2832,7 +2832,7 @@ static bool check_message_info(uint32_t message_number, uint8_t message_id, Grou
non_null(1, 3) nullable(6)
static void handle_message_packet_group(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *data, uint16_t length,
- int connection_index, void *userdata)
+ uint32_t connection_index, void *userdata)
{
if (length < sizeof(uint16_t) + sizeof(uint32_t) + 1) {
return;
diff --git a/protocols/Tox/libtox/src/toxcore/group_chats.c b/protocols/Tox/libtox/src/toxcore/group_chats.c
index 96f647cc2e..2d64ae60ec 100644
--- a/protocols/Tox/libtox/src/toxcore/group_chats.c
+++ b/protocols/Tox/libtox/src/toxcore/group_chats.c
@@ -961,7 +961,7 @@ non_null() static bool broadcast_gc_mod_list(const GC_Chat *chat);
non_null() static bool broadcast_gc_shared_state(const GC_Chat *chat);
non_null() static bool update_gc_sanctions_list(GC_Chat *chat, const uint8_t *public_sig_key);
non_null() static bool update_gc_topic(GC_Chat *chat, const uint8_t *public_sig_key);
-non_null() static bool send_gc_set_observer(const GC_Chat *chat, const uint8_t *target_ext_pk,
+non_null() static bool send_gc_set_observer(const GC_Chat *chat, const Extended_Public_Key *target_ext_pk,
const uint8_t *sanction_data, uint16_t length, bool add_obs);
/** Returns true if peer designated by `peer_number` is in the sanctions list as an observer. */
@@ -1119,7 +1119,7 @@ static bool prune_gc_mod_list(GC_Chat *chat)
non_null()
static bool prune_gc_sanctions_list_inner(
GC_Chat *chat, const Mod_Sanction *sanction,
- const uint8_t target_ext_pk[ENC_PUBLIC_KEY_SIZE + SIG_PUBLIC_KEY_SIZE])
+ const Extended_Public_Key *target_ext_pk)
{
if (!sanctions_list_remove_observer(&chat->moderation, sanction->target_public_enc_key, nullptr)) {
LOGGER_WARNING(chat->log, "Failed to remove entry from observer list");
@@ -1159,10 +1159,10 @@ static bool prune_gc_sanctions_list(GC_Chat *chat)
if (peer_number == -1) {
const Mod_Sanction *sanction = &chat->moderation.sanctions[i];
- uint8_t target_ext_pk[ENC_PUBLIC_KEY_SIZE + SIG_PUBLIC_KEY_SIZE];
- memcpy(target_ext_pk, sanction->target_public_enc_key, ENC_PUBLIC_KEY_SIZE);
- memcpy(target_ext_pk + ENC_PUBLIC_KEY_SIZE, sanction->setter_public_sig_key, SIG_PUBLIC_KEY_SIZE);
- return prune_gc_sanctions_list_inner(chat, sanction, target_ext_pk);
+ Extended_Public_Key target_ext_pk;
+ memcpy(target_ext_pk.enc, sanction->target_public_enc_key, ENC_PUBLIC_KEY_SIZE);
+ memcpy(target_ext_pk.sig, sanction->setter_public_sig_key, SIG_PUBLIC_KEY_SIZE);
+ return prune_gc_sanctions_list_inner(chat, sanction, &target_ext_pk);
}
}
@@ -4457,10 +4457,10 @@ static int handle_gc_set_observer(const GC_Session *c, GC_Chat *chat, uint32_t p
* Returns true on success.
*/
non_null()
-static bool send_gc_set_observer(const GC_Chat *chat, const uint8_t *target_ext_pk, const uint8_t *sanction_data,
- uint16_t length, bool add_obs)
+static bool send_gc_set_observer(const GC_Chat *chat, const Extended_Public_Key *target_ext_pk,
+ const uint8_t *sanction_data, uint16_t length, bool add_obs)
{
- const uint16_t packet_len = 1 + EXT_PUBLIC_KEY_SIZE + length;
+ const uint16_t packet_len = 1 + ENC_PUBLIC_KEY_SIZE + SIG_PUBLIC_KEY_SIZE + length;
uint8_t *packet = (uint8_t *)malloc(packet_len);
if (packet == nullptr) {
@@ -4469,8 +4469,9 @@ static bool send_gc_set_observer(const GC_Chat *chat, const uint8_t *target_ext_
net_pack_bool(&packet[0], add_obs);
- memcpy(packet + 1, target_ext_pk, EXT_PUBLIC_KEY_SIZE);
- memcpy(packet + 1 + EXT_PUBLIC_KEY_SIZE, sanction_data, length);
+ memcpy(packet + 1, target_ext_pk->enc, ENC_PUBLIC_KEY_SIZE);
+ memcpy(packet + 1 + ENC_PUBLIC_KEY_SIZE, target_ext_pk->sig, SIG_PUBLIC_KEY_SIZE);
+ memcpy(packet + 1 + ENC_PUBLIC_KEY_SIZE + SIG_PUBLIC_KEY_SIZE, sanction_data, length);
if (!send_gc_broadcast_message(chat, packet, packet_len, GM_SET_OBSERVER)) {
free(packet);
@@ -4557,7 +4558,7 @@ static bool mod_gc_set_observer(GC_Chat *chat, uint32_t peer_number, bool add_ob
update_gc_peer_roles(chat);
- return send_gc_set_observer(chat, gconn->addr.public_key.enc, sanction_data, length, add_obs);
+ return send_gc_set_observer(chat, &gconn->addr.public_key, sanction_data, length, add_obs);
}
/** @brief Sets the role of `peer_number` to `new_role`. If necessary this function will first
@@ -4910,11 +4911,12 @@ int gc_send_message(const GC_Chat *chat, const uint8_t *message, uint16_t length
return -5;
}
+ free(message_raw);
+
if (message_id != nullptr) {
*message_id = pseudo_msg_id;
}
- free(message_raw);
return 0;
}
@@ -4954,7 +4956,7 @@ static int handle_gc_message(const GC_Session *c, const GC_Chat *chat, const GC_
}
int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t type, const uint8_t *message,
- uint16_t length)
+ uint16_t length, uint32_t *message_id)
{
if (length > MAX_GC_MESSAGE_SIZE) {
return -1;
@@ -4980,23 +4982,28 @@ int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t typ
return -5;
}
- uint8_t *message_with_type = (uint8_t *)malloc(length + 1);
+ const uint16_t raw_length = 1 + length + GC_MESSAGE_PSEUDO_ID_SIZE;
+ uint8_t *message_with_type = (uint8_t *)malloc(raw_length);
if (message_with_type == nullptr) {
return -6;
}
message_with_type[0] = type;
- memcpy(message_with_type + 1, message, length);
- uint8_t *packet = (uint8_t *)malloc(length + 1 + GC_BROADCAST_ENC_HEADER_SIZE);
+ const uint32_t pseudo_msg_id = random_u32(chat->rng);
+ net_pack_u32(message_with_type + 1, pseudo_msg_id);
+
+ memcpy(message_with_type + 1 + GC_MESSAGE_PSEUDO_ID_SIZE, message, length);
+
+ uint8_t *packet = (uint8_t *)malloc(raw_length + GC_BROADCAST_ENC_HEADER_SIZE);
if (packet == nullptr) {
free(message_with_type);
return -6;
}
- const uint16_t packet_len = make_gc_broadcast_header(message_with_type, length + 1, packet, GM_PRIVATE_MESSAGE);
+ const uint16_t packet_len = make_gc_broadcast_header(message_with_type, raw_length, packet, GM_PRIVATE_MESSAGE);
free(message_with_type);
@@ -5007,6 +5014,10 @@ int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t typ
free(packet);
+ if (message_id != nullptr) {
+ *message_id = pseudo_msg_id;
+ }
+
return 0;
}
@@ -5019,7 +5030,7 @@ non_null(1, 2, 3, 4) nullable(6)
static int handle_gc_private_message(const GC_Session *c, const GC_Chat *chat, const GC_Peer *peer, const uint8_t *data,
uint16_t length, void *userdata)
{
- if (data == nullptr || length > MAX_GC_MESSAGE_SIZE || length <= 1) {
+ if (data == nullptr || length > MAX_GC_MESSAGE_SIZE || length <= 1 + GC_MESSAGE_PSEUDO_ID_SIZE) {
return -1;
}
@@ -5034,8 +5045,13 @@ static int handle_gc_private_message(const GC_Session *c, const GC_Chat *chat, c
return 0;
}
+ uint32_t message_id;
+ net_unpack_u32(data + 1, &message_id);
+
if (c->private_message != nullptr) {
- c->private_message(c->messenger, chat->group_number, peer->peer_id, message_type, data + 1, length - 1, userdata);
+ c->private_message(c->messenger, chat->group_number, peer->peer_id, message_type,
+ data + 1 + GC_MESSAGE_PSEUDO_ID_SIZE, length - 1 - GC_MESSAGE_PSEUDO_ID_SIZE,
+ message_id, userdata);
}
return 0;
@@ -5066,10 +5082,6 @@ int gc_send_custom_private_packet(const GC_Chat *chat, bool lossless, GC_Peer_Id
return -3;
}
- if (gc_get_self_role(chat) >= GR_OBSERVER) {
- return -4;
- }
-
bool ret;
if (lossless) {
@@ -5078,7 +5090,7 @@ int gc_send_custom_private_packet(const GC_Chat *chat, bool lossless, GC_Peer_Id
ret = send_lossy_group_packet(chat, gconn, message, length, GP_CUSTOM_PRIVATE_PACKET);
}
- return ret ? 0 : -5;
+ return ret ? 0 : -4;
}
/** @brief Handles a custom private packet.
@@ -5098,10 +5110,6 @@ static int handle_gc_custom_private_packet(const GC_Session *c, const GC_Chat *c
return -1;
}
- if (peer->ignore || peer->role >= GR_OBSERVER) {
- return 0;
- }
-
if (c->custom_private_packet != nullptr) {
c->custom_private_packet(c->messenger, chat->group_number, peer->peer_id, data, length, userdata);
}
@@ -5119,10 +5127,6 @@ int gc_send_custom_packet(const GC_Chat *chat, bool lossless, const uint8_t *dat
return -2;
}
- if (gc_get_self_role(chat) >= GR_OBSERVER) {
- return -3;
- }
-
bool success;
if (lossless) {
@@ -5131,7 +5135,7 @@ int gc_send_custom_packet(const GC_Chat *chat, bool lossless, const uint8_t *dat
success = send_gc_lossy_packet_all_peers(chat, data, length, GP_CUSTOM_PACKET);
}
- return success ? 0 : -4;
+ return success ? 0 : -3;
}
/** @brief Handles a custom packet.
@@ -5151,10 +5155,6 @@ static int handle_gc_custom_packet(const GC_Session *c, const GC_Chat *chat, con
return -1;
}
- if (peer->ignore || peer->role >= GR_OBSERVER) {
- return 0;
- }
-
if (c->custom_packet != nullptr) {
c->custom_packet(c->messenger, chat->group_number, peer->peer_id, data, length, userdata);
}
@@ -8353,7 +8353,7 @@ bool gc_group_is_valid(const GC_Chat *chat)
/** Return true if `group_number` designates an active group in session `c`. */
static bool group_number_valid(const GC_Session *c, int group_number)
{
- if (group_number < 0 || group_number >= c->chats_index) {
+ if (group_number < 0 || (uint32_t)group_number >= c->chats_index) {
return false;
}
diff --git a/protocols/Tox/libtox/src/toxcore/group_chats.h b/protocols/Tox/libtox/src/toxcore/group_chats.h
index 32a7323dc4..d22ce400e6 100644
--- a/protocols/Tox/libtox/src/toxcore/group_chats.h
+++ b/protocols/Tox/libtox/src/toxcore/group_chats.h
@@ -181,9 +181,9 @@ int gc_send_message(const GC_Chat *chat, const uint8_t *message, uint16_t length
* Returns -5 if the sender has the observer role.
* Returns -6 if the packet fails to send.
*/
-non_null()
+non_null(1, 4) nullable(6)
int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t type, const uint8_t *message,
- uint16_t length);
+ uint16_t length, uint32_t *message_id);
/** @brief Sends a custom packet to the group. If lossless is true, the packet will be lossless.
*
@@ -192,8 +192,7 @@ int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t typ
* Returns 0 on success.
* Returns -1 if the message is too long.
* Returns -2 if the message pointer is NULL or length is zero.
- * Returns -3 if the sender has the observer role.
- * Returns -4 if the packet did not successfully send to any peer.
+ * Returns -3 if the packet did not successfully send to any peer.
*/
non_null()
int gc_send_custom_packet(const GC_Chat *chat, bool lossless, const uint8_t *data, uint16_t length);
@@ -206,8 +205,7 @@ int gc_send_custom_packet(const GC_Chat *chat, bool lossless, const uint8_t *dat
* @retval -1 if the message is too long.
* @retval -2 if the message pointer is NULL or length is zero.
* @retval -3 if the supplied peer_id does not designate a valid peer.
- * @retval -4 if the sender has the observer role.
- * @retval -5 if the packet fails to send.
+ * @retval -4 if the packet fails to send.
*/
non_null()
int gc_send_custom_private_packet(const GC_Chat *chat, bool lossless, GC_Peer_Id peer_id, const uint8_t *message,
diff --git a/protocols/Tox/libtox/src/toxcore/group_common.h b/protocols/Tox/libtox/src/toxcore/group_common.h
index bb1e6f9a64..daa8fe17c8 100644
--- a/protocols/Tox/libtox/src/toxcore/group_common.h
+++ b/protocols/Tox/libtox/src/toxcore/group_common.h
@@ -348,7 +348,7 @@ typedef struct Messenger Messenger;
typedef void gc_message_cb(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, unsigned int type,
const uint8_t *message, size_t length, uint32_t message_id, void *user_data);
typedef void gc_private_message_cb(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, unsigned int type,
- const uint8_t *message, size_t length, void *user_data);
+ const uint8_t *message, size_t length, uint32_t message_id, void *user_data);
typedef void gc_custom_packet_cb(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, const uint8_t *data,
size_t length, void *user_data);
typedef void gc_custom_private_packet_cb(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id,
diff --git a/protocols/Tox/libtox/src/toxcore/group_pack.c b/protocols/Tox/libtox/src/toxcore/group_pack.c
index e3af82c67a..c20d6a1213 100644
--- a/protocols/Tox/libtox/src/toxcore/group_pack.c
+++ b/protocols/Tox/libtox/src/toxcore/group_pack.c
@@ -26,46 +26,46 @@
#include "network.h"
#include "util.h"
-bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out)
+bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum)
{
switch (value) {
case GI_PUBLIC: {
- *out = GI_PUBLIC;
+ *out_enum = GI_PUBLIC;
return true;
}
case GI_PRIVATE: {
- *out = GI_PRIVATE;
+ *out_enum = GI_PRIVATE;
return true;
}
default: {
- *out = GI_PUBLIC;
+ *out_enum = GI_PUBLIC;
return false;
}
}
}
-bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out)
+bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum)
{
switch (value) {
case GV_ALL: {
- *out = GV_ALL;
+ *out_enum = GV_ALL;
return true;
}
case GV_MODS: {
- *out = GV_MODS;
+ *out_enum = GV_MODS;
return true;
}
case GV_FOUNDER: {
- *out = GV_FOUNDER;
+ *out_enum = GV_FOUNDER;
return true;
}
default: {
- *out = GV_ALL;
+ *out_enum = GV_ALL;
return false;
}
}
diff --git a/protocols/Tox/libtox/src/toxcore/group_pack.h b/protocols/Tox/libtox/src/toxcore/group_pack.h
index 03252fb86d..4c999132db 100644
--- a/protocols/Tox/libtox/src/toxcore/group_pack.h
+++ b/protocols/Tox/libtox/src/toxcore/group_pack.h
@@ -34,8 +34,8 @@ non_null()
bool gc_load_unpack_group(GC_Chat *chat, Bin_Unpack *bu);
non_null()
-bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out);
+bool group_privacy_state_from_int(uint8_t value, Group_Privacy_State *out_enum);
non_null()
-bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out);
+bool group_voice_state_from_int(uint8_t value, Group_Voice_State *out_enum);
#endif /* C_TOXCORE_TOXCORE_GROUP_PACK_H */
diff --git a/protocols/Tox/libtox/src/toxcore/net_crypto.c b/protocols/Tox/libtox/src/toxcore/net_crypto.c
index 1680b078b7..5aafe8a8a9 100644
--- a/protocols/Tox/libtox/src/toxcore/net_crypto.c
+++ b/protocols/Tox/libtox/src/toxcore/net_crypto.c
@@ -122,9 +122,6 @@ typedef struct Crypto_Connection {
bool maximum_speed_reached;
- /* Must be a pointer, because the struct is moved in memory */
- pthread_mutex_t *mutex;
-
dht_pk_cb *dht_pk_callback;
void *dht_pk_callback_object;
uint32_t dht_pk_callback_number;
@@ -143,10 +140,6 @@ struct Net_Crypto {
TCP_Connections *tcp_c;
Crypto_Connection *crypto_connections;
- pthread_mutex_t tcp_mutex;
-
- pthread_mutex_t connections_mutex;
- unsigned int connection_use_counter;
uint32_t crypto_connections_length; /* Length of connections array. */
@@ -691,7 +684,6 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
bool direct_send_attempt = false;
- pthread_mutex_lock(conn->mutex);
const IP_Port ip_port = return_ip_port_connection(c, crypt_connection_id);
// TODO(irungentoo): on bad networks, direct connections might not last indefinitely.
@@ -703,11 +695,9 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
if (direct_connected) {
if ((uint32_t)sendpacket(dht_get_net(c->dht), &ip_port, data, length) == length) {
- pthread_mutex_unlock(conn->mutex);
return 0;
}
- pthread_mutex_unlock(conn->mutex);
LOGGER_WARNING(c->log, "sending packet of length %d failed", length);
return -1;
}
@@ -724,19 +714,12 @@ static int send_packet_to(Net_Crypto *c, int crypt_connection_id, const uint8_t
}
}
- pthread_mutex_unlock(conn->mutex);
- pthread_mutex_lock(&c->tcp_mutex);
const int ret = send_packet_tcp_connection(c->tcp_c, conn->connection_number_tcp, data, length);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- pthread_mutex_lock(conn->mutex);
if (ret == 0) {
conn->last_tcp_sent = current_time_monotonic(c->mono_time);
}
- pthread_mutex_unlock(conn->mutex);
-
if (direct_send_attempt) {
return 0;
}
@@ -1097,7 +1080,6 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_
return -1;
}
- pthread_mutex_lock(conn->mutex);
const uint16_t packet_size = 1 + sizeof(uint16_t) + length + CRYPTO_MAC_SIZE;
VLA(uint8_t, packet, packet_size);
packet[0] = NET_PACKET_CRYPTO_DATA;
@@ -1106,12 +1088,10 @@ static int send_data_packet(Net_Crypto *c, int crypt_connection_id, const uint8_
if (len + 1 + sizeof(uint16_t) != packet_size) {
LOGGER_ERROR(c->log, "encryption failed: %d", len);
- pthread_mutex_unlock(conn->mutex);
return -1;
}
increment_nonce(conn->sent_nonce);
- pthread_mutex_unlock(conn->mutex);
return send_packet_to(c, crypt_connection_id, packet, packet_size);
}
@@ -1207,9 +1187,7 @@ static int64_t send_lossless_packet(Net_Crypto *c, int crypt_connection_id, cons
dt.sent_time = 0;
dt.length = length;
memcpy(dt.data, data, length);
- pthread_mutex_lock(conn->mutex);
const int64_t packet_num = add_data_end_of_buffer(c->log, c->mem, &conn->send_array, &dt);
- pthread_mutex_unlock(conn->mutex);
if (packet_num == -1) {
return -1;
@@ -1521,18 +1499,7 @@ static void connection_kill(Net_Crypto *c, int crypt_connection_id, void *userda
false, userdata);
}
- while (true) { /* TODO(irungentoo): is this really the best way to do this? */
- pthread_mutex_lock(&c->connections_mutex);
-
- if (c->connection_use_counter == 0) {
- break;
- }
-
- pthread_mutex_unlock(&c->connections_mutex);
- }
-
crypto_kill(c, crypt_connection_id);
- pthread_mutex_unlock(&c->connections_mutex);
}
/** @brief Handle a received data packet.
@@ -1635,9 +1602,7 @@ static int handle_data_packet_core(Net_Crypto *c, int crypt_connection_id, const
}
while (true) {
- pthread_mutex_lock(conn->mutex);
const int ret = read_data_beg_buffer(c->mem, &conn->recv_array, &dt);
- pthread_mutex_unlock(conn->mutex);
if (ret == -1) {
break;
@@ -1835,16 +1800,6 @@ static int realloc_cryptoconnection(Net_Crypto *c, uint32_t num)
non_null()
static int create_crypto_connection(Net_Crypto *c)
{
- while (true) { /* TODO(irungentoo): is this really the best way to do this? */
- pthread_mutex_lock(&c->connections_mutex);
-
- if (c->connection_use_counter == 0) {
- break;
- }
-
- pthread_mutex_unlock(&c->connections_mutex);
- }
-
int id = -1;
for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
@@ -1863,30 +1818,17 @@ static int create_crypto_connection(Net_Crypto *c)
}
if (id != -1) {
- pthread_mutex_t *mutex = (pthread_mutex_t *)mem_alloc(c->mem, sizeof(pthread_mutex_t));
-
- if (mutex == nullptr) {
- pthread_mutex_unlock(&c->connections_mutex);
- return -1;
- }
-
- if (pthread_mutex_init(mutex, nullptr) != 0) {
- mem_delete(c->mem, mutex);
- pthread_mutex_unlock(&c->connections_mutex);
- return -1;
- }
-
// Memsetting float/double to 0 is non-portable, so we explicitly set them to 0
c->crypto_connections[id].packet_recv_rate = 0.0;
c->crypto_connections[id].packet_send_rate = 0.0;
c->crypto_connections[id].last_packets_left_rem = 0.0;
c->crypto_connections[id].packet_send_rate_requested = 0.0;
c->crypto_connections[id].last_packets_left_requested_rem = 0.0;
- c->crypto_connections[id].mutex = mutex;
+
+ // TODO(Green-Sky): This enum is likely unneeded and the same as FREE.
c->crypto_connections[id].status = CRYPTO_CONN_NO_CONNECTION;
}
- pthread_mutex_unlock(&c->connections_mutex);
return id;
}
@@ -1914,8 +1856,6 @@ static int wipe_crypto_connection(Net_Crypto *c, int crypt_connection_id)
uint32_t i;
- pthread_mutex_destroy(c->crypto_connections[crypt_connection_id].mutex);
- mem_delete(c->mem, c->crypto_connections[crypt_connection_id].mutex);
crypto_memzero(&c->crypto_connections[crypt_connection_id], sizeof(Crypto_Connection));
/* check if we can resize the connections array */
@@ -2098,9 +2038,7 @@ int accept_crypto_connection(Net_Crypto *c, const New_Connection *n_c)
return -1;
}
- pthread_mutex_lock(&c->tcp_mutex);
const int connection_number_tcp = new_tcp_connection_to(c->tcp_c, n_c->dht_public_key, crypt_connection_id);
- pthread_mutex_unlock(&c->tcp_mutex);
if (connection_number_tcp == -1) {
wipe_crypto_connection(c, crypt_connection_id);
@@ -2117,9 +2055,7 @@ int accept_crypto_connection(Net_Crypto *c, const New_Connection *n_c)
conn->status = CRYPTO_CONN_NOT_CONFIRMED;
if (create_send_handshake(c, crypt_connection_id, n_c->cookie, n_c->dht_public_key) != 0) {
- pthread_mutex_lock(&c->tcp_mutex);
kill_tcp_connection_to(c->tcp_c, conn->connection_number_tcp);
- pthread_mutex_unlock(&c->tcp_mutex);
wipe_crypto_connection(c, crypt_connection_id);
return -1;
}
@@ -2155,9 +2091,7 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const u
Crypto_Connection *conn = &c->crypto_connections[crypt_connection_id];
- pthread_mutex_lock(&c->tcp_mutex);
const int connection_number_tcp = new_tcp_connection_to(c->tcp_c, dht_public_key, crypt_connection_id);
- pthread_mutex_unlock(&c->tcp_mutex);
if (connection_number_tcp == -1) {
wipe_crypto_connection(c, crypt_connection_id);
@@ -2181,9 +2115,7 @@ int new_crypto_connection(Net_Crypto *c, const uint8_t *real_public_key, const u
if (create_cookie_request(c, cookie_request, conn->dht_public_key, conn->cookie_request_number,
conn->shared_key) != sizeof(cookie_request)
|| new_temp_packet(c, crypt_connection_id, cookie_request, sizeof(cookie_request)) != 0) {
- pthread_mutex_lock(&c->tcp_mutex);
kill_tcp_connection_to(c->tcp_c, conn->connection_number_tcp);
- pthread_mutex_unlock(&c->tcp_mutex);
wipe_crypto_connection(c, crypt_connection_id);
return -1;
}
@@ -2241,11 +2173,7 @@ static int tcp_data_callback(void *object, int crypt_connection_id, const uint8_
return tcp_handle_cookie_request(c, conn->connection_number_tcp, packet, length);
}
- // This unlocks the mutex that at this point is locked by do_tcp before
- // calling do_tcp_connections.
- pthread_mutex_unlock(&c->tcp_mutex);
const int ret = handle_packet_connection(c, crypt_connection_id, packet, length, false, userdata);
- pthread_mutex_lock(&c->tcp_mutex);
if (ret != 0) {
return -1;
@@ -2295,10 +2223,7 @@ int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, const IP_Port *ip
return -1;
}
- pthread_mutex_lock(&c->tcp_mutex);
- const int ret = add_tcp_relay_connection(c->tcp_c, conn->connection_number_tcp, ip_port, public_key);
- pthread_mutex_unlock(&c->tcp_mutex);
- return ret;
+ return add_tcp_relay_connection(c->tcp_c, conn->connection_number_tcp, ip_port, public_key);
}
/** @brief Add a tcp relay to the array.
@@ -2308,10 +2233,7 @@ int add_tcp_relay_peer(Net_Crypto *c, int crypt_connection_id, const IP_Port *ip
*/
int add_tcp_relay(Net_Crypto *c, const IP_Port *ip_port, const uint8_t *public_key)
{
- pthread_mutex_lock(&c->tcp_mutex);
- const int ret = add_tcp_relay_global(c->tcp_c, ip_port, public_key);
- pthread_mutex_unlock(&c->tcp_mutex);
- return ret;
+ return add_tcp_relay_global(c->tcp_c, ip_port, public_key);
}
/** @brief Return a random TCP connection number for use in send_tcp_onion_request.
@@ -2322,13 +2244,9 @@ int add_tcp_relay(Net_Crypto *c, const IP_Port *ip_port, const uint8_t *public_k
* return TCP connection number on success.
* return -1 on failure.
*/
-int get_random_tcp_con_number(Net_Crypto *c)
+int get_random_tcp_con_number(const Net_Crypto *c)
{
- pthread_mutex_lock(&c->tcp_mutex);
- const int ret = get_random_tcp_onion_conn_number(c->tcp_c);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return get_random_tcp_onion_conn_number(c->tcp_c);
}
/** @brief Put IP_Port of a random onion TCP connection in ip_port.
@@ -2336,13 +2254,9 @@ int get_random_tcp_con_number(Net_Crypto *c)
* return true on success.
* return false on failure.
*/
-bool get_random_tcp_conn_ip_port(Net_Crypto *c, IP_Port *ip_port)
+bool get_random_tcp_conn_ip_port(const Net_Crypto *c, IP_Port *ip_port)
{
- pthread_mutex_lock(&c->tcp_mutex);
- const bool ret = tcp_get_random_conn_ip_port(c->tcp_c, ip_port);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return tcp_get_random_conn_ip_port(c->tcp_c, ip_port);
}
/** @brief Send an onion packet via the TCP relay corresponding to tcp_connections_number.
@@ -2352,11 +2266,7 @@ bool get_random_tcp_conn_ip_port(Net_Crypto *c, IP_Port *ip_port)
*/
int send_tcp_onion_request(Net_Crypto *c, unsigned int tcp_connections_number, const uint8_t *data, uint16_t length)
{
- pthread_mutex_lock(&c->tcp_mutex);
- const int ret = tcp_send_onion_request(c->tcp_c, tcp_connections_number, data, length);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return tcp_send_onion_request(c->tcp_c, tcp_connections_number, data, length);
}
/**
@@ -2371,12 +2281,8 @@ int send_tcp_forward_request(const Logger *logger, Net_Crypto *c, const IP_Port
const uint8_t *chain_keys, uint16_t chain_length,
const uint8_t *data, uint16_t data_length)
{
- pthread_mutex_lock(&c->tcp_mutex);
- const int ret = tcp_send_forward_request(logger, c->tcp_c, tcp_forwarder, dht_node,
- chain_keys, chain_length, data, data_length);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return tcp_send_forward_request(logger, c->tcp_c, tcp_forwarder, dht_node,
+ chain_keys, chain_length, data, data_length);
}
/** @brief Copy a maximum of num random TCP relays we are connected to to tcp_relays.
@@ -2386,38 +2292,28 @@ int send_tcp_forward_request(const Logger *logger, Net_Crypto *c, const IP_Port
* return number of relays copied to tcp_relays on success.
* return 0 on failure.
*/
-unsigned int copy_connected_tcp_relays(Net_Crypto *c, Node_format *tcp_relays, uint16_t num)
+unsigned int copy_connected_tcp_relays(const Net_Crypto *c, Node_format *tcp_relays, uint16_t num)
{
if (num == 0) {
return 0;
}
- pthread_mutex_lock(&c->tcp_mutex);
- const unsigned int ret = tcp_copy_connected_relays(c->tcp_c, tcp_relays, num);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return tcp_copy_connected_relays(c->tcp_c, tcp_relays, num);
}
-uint32_t copy_connected_tcp_relays_index(Net_Crypto *c, Node_format *tcp_relays, uint16_t num, uint32_t idx)
+uint32_t copy_connected_tcp_relays_index(const Net_Crypto *c, Node_format *tcp_relays, uint16_t num, uint32_t idx)
{
if (num == 0) {
return 0;
}
- pthread_mutex_lock(&c->tcp_mutex);
- const uint32_t ret = tcp_copy_connected_relays_index(c->tcp_c, tcp_relays, num, idx);
- pthread_mutex_unlock(&c->tcp_mutex);
-
- return ret;
+ return tcp_copy_connected_relays_index(c->tcp_c, tcp_relays, num, idx);
}
non_null()
static void do_tcp(Net_Crypto *c, void *userdata)
{
- pthread_mutex_lock(&c->tcp_mutex);
do_tcp_connections(c->log, c->tcp_c, userdata);
- pthread_mutex_unlock(&c->tcp_mutex);
for (uint32_t i = 0; i < c->crypto_connections_length; ++i) {
const Crypto_Connection *conn = get_crypto_connection(c, i);
@@ -2436,9 +2332,7 @@ static void do_tcp(Net_Crypto *c, void *userdata)
continue;
}
- pthread_mutex_lock(&c->tcp_mutex);
set_tcp_connection_to_status(c->tcp_c, conn->connection_number_tcp, !direct_connected);
- pthread_mutex_unlock(&c->tcp_mutex);
}
}
@@ -2593,15 +2487,12 @@ static int udp_handle_packet(void *object, const IP_Port *source, const uint8_t
return -1;
}
- pthread_mutex_lock(conn->mutex);
-
if (net_family_is_ipv4(source->ip.family)) {
conn->direct_lastrecv_timev4 = mono_time_get(c->mono_time);
} else {
conn->direct_lastrecv_timev6 = mono_time_get(c->mono_time);
}
- pthread_mutex_unlock(conn->mutex);
return 0;
}
@@ -2997,26 +2888,16 @@ int send_lossy_cryptpacket(Net_Crypto *c, int crypt_connection_id, const uint8_t
return -1;
}
- pthread_mutex_lock(&c->connections_mutex);
- ++c->connection_use_counter;
- pthread_mutex_unlock(&c->connections_mutex);
-
Crypto_Connection *conn = get_crypto_connection(c, crypt_connection_id);
int ret = -1;
if (conn != nullptr) {
- pthread_mutex_lock(conn->mutex);
const uint32_t buffer_start = conn->recv_array.buffer_start;
const uint32_t buffer_end = conn->send_array.buffer_end;
- pthread_mutex_unlock(conn->mutex);
ret = send_data_packet_helper(c, crypt_connection_id, buffer_start, buffer_end, data, length);
}
- pthread_mutex_lock(&c->connections_mutex);
- --c->connection_use_counter;
- pthread_mutex_unlock(&c->connections_mutex);
-
return ret;
}
@@ -3036,9 +2917,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id)
send_kill_packet(c, crypt_connection_id);
}
- pthread_mutex_lock(&c->tcp_mutex);
kill_tcp_connection_to(c->tcp_c, conn->connection_number_tcp);
- pthread_mutex_unlock(&c->tcp_mutex);
bs_list_remove(&c->ip_port_list, (uint8_t *)&conn->ip_portv4, crypt_connection_id);
bs_list_remove(&c->ip_port_list, (uint8_t *)&conn->ip_portv6, crypt_connection_id);
@@ -3135,13 +3014,6 @@ Net_Crypto *new_net_crypto(const Logger *log, const Memory *mem, const Random *r
set_packet_tcp_connection_callback(temp->tcp_c, &tcp_data_callback, temp);
set_oob_packet_tcp_connection_callback(temp->tcp_c, &tcp_oob_callback, temp);
- if (create_recursive_mutex(&temp->tcp_mutex) != 0 ||
- pthread_mutex_init(&temp->connections_mutex, nullptr) != 0) {
- kill_tcp_connections(temp->tcp_c);
- mem_delete(mem, temp);
- return nullptr;
- }
-
temp->dht = dht;
new_keys(temp);
@@ -3215,9 +3087,6 @@ void kill_net_crypto(Net_Crypto *c)
crypto_kill(c, i);
}
- pthread_mutex_destroy(&c->tcp_mutex);
- pthread_mutex_destroy(&c->connections_mutex);
-
kill_tcp_connections(c->tcp_c);
bs_list_free(&c->ip_port_list);
networking_registerhandler(dht_get_net(c->dht), NET_PACKET_COOKIE_REQUEST, nullptr, nullptr);
diff --git a/protocols/Tox/libtox/src/toxcore/net_crypto.h b/protocols/Tox/libtox/src/toxcore/net_crypto.h
index 0d817e4315..8368d46e39 100644
--- a/protocols/Tox/libtox/src/toxcore/net_crypto.h
+++ b/protocols/Tox/libtox/src/toxcore/net_crypto.h
@@ -40,7 +40,6 @@
/** Packets in this range are reserved for AV use. */
#define PACKET_ID_RANGE_LOSSY_START 192
#define PACKET_ID_RANGE_LOSSY_AV_START 192
-#define PACKET_ID_RANGE_LOSSY_AV_SIZE 8
#define PACKET_ID_RANGE_LOSSY_AV_END 199
/** Packets in this range can be used for anything. */
#define PACKET_ID_RANGE_LOSSY_CUSTOM_START 200
@@ -311,7 +310,7 @@ int add_tcp_relay(Net_Crypto *c, const IP_Port *ip_port, const uint8_t *public_k
* return -1 on failure.
*/
non_null()
-int get_random_tcp_con_number(Net_Crypto *c);
+int get_random_tcp_con_number(const Net_Crypto *c);
/** @brief Put IP_Port of a random onion TCP connection in ip_port.
*
@@ -319,7 +318,7 @@ int get_random_tcp_con_number(Net_Crypto *c);
* return false on failure.
*/
non_null()
-bool get_random_tcp_conn_ip_port(Net_Crypto *c, IP_Port *ip_port);
+bool get_random_tcp_conn_ip_port(const Net_Crypto *c, IP_Port *ip_port);
/** @brief Send an onion packet via the TCP relay corresponding to tcp_connections_number.
*
@@ -351,7 +350,7 @@ int send_tcp_forward_request(const Logger *logger, Net_Crypto *c, const IP_Port
* return 0 on failure.
*/
non_null()
-unsigned int copy_connected_tcp_relays(Net_Crypto *c, Node_format *tcp_relays, uint16_t num);
+unsigned int copy_connected_tcp_relays(const Net_Crypto *c, Node_format *tcp_relays, uint16_t num);
/**
* Copy a maximum of `max_num` TCP relays we are connected to starting at the index in the TCP relay array
@@ -360,7 +359,7 @@ unsigned int copy_connected_tcp_relays(Net_Crypto *c, Node_format *tcp_relays, u
* Returns the number of relays successfully copied.
*/
non_null()
-uint32_t copy_connected_tcp_relays_index(Net_Crypto *c, Node_format *tcp_relays, uint16_t num, uint32_t idx);
+uint32_t copy_connected_tcp_relays_index(const Net_Crypto *c, Node_format *tcp_relays, uint16_t num, uint32_t idx);
/** @brief Kill a crypto connection.
*
diff --git a/protocols/Tox/libtox/src/toxcore/onion_client.c b/protocols/Tox/libtox/src/toxcore/onion_client.c
index 9b0ac96102..326575963b 100644
--- a/protocols/Tox/libtox/src/toxcore/onion_client.c
+++ b/protocols/Tox/libtox/src/toxcore/onion_client.c
@@ -955,7 +955,7 @@ static int handle_announce_response(void *object, const IP_Port *source, const u
}
uint8_t plain[1 + ONION_PING_ID_SIZE + ONION_ANNOUNCE_RESPONSE_MAX_SIZE - ONION_ANNOUNCE_RESPONSE_MIN_SIZE];
- const int plain_size = 1 + ONION_PING_ID_SIZE + length - ONION_ANNOUNCE_RESPONSE_MIN_SIZE;
+ const uint32_t plain_size = 1 + ONION_PING_ID_SIZE + length - ONION_ANNOUNCE_RESPONSE_MIN_SIZE;
int len;
const uint16_t nonce_start = 1 + ONION_ANNOUNCE_SENDBACK_DATA_LENGTH;
const uint16_t ciphertext_start = nonce_start + CRYPTO_NONCE_SIZE;
diff --git a/protocols/Tox/libtox/src/toxcore/tox.c b/protocols/Tox/libtox/src/toxcore/tox.c
index 085fab2ec1..b02eb4e98b 100644
--- a/protocols/Tox/libtox/src/toxcore/tox.c
+++ b/protocols/Tox/libtox/src/toxcore/tox.c
@@ -524,7 +524,7 @@ static void tox_group_password_handler(const Messenger *m, uint32_t group_number
non_null(1, 5) nullable(8)
static void tox_group_message_handler(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id, unsigned int type,
- const uint8_t *message, size_t length, uint32_t message_id, void *user_data)
+ const uint8_t *message, size_t length, Tox_Group_Message_Id message_id, void *user_data)
{
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;
@@ -536,16 +536,16 @@ static void tox_group_message_handler(const Messenger *m, uint32_t group_number,
}
}
-non_null(1, 5) nullable(7)
+non_null(1, 5) nullable(8)
static void tox_group_private_message_handler(const Messenger *m, uint32_t group_number, GC_Peer_Id peer_id,
- unsigned int type, const uint8_t *message, size_t length, void *user_data)
+ unsigned int type, const uint8_t *message, size_t length, Tox_Group_Message_Id message_id, void *user_data)
{
struct Tox_Userdata *tox_data = (struct Tox_Userdata *)user_data;
if (tox_data->tox->group_private_message_callback != nullptr) {
tox_unlock(tox_data->tox);
tox_data->tox->group_private_message_callback(tox_data->tox, group_number, gc_peer_id_to_int(peer_id), (Tox_Message_Type)type, message,
- length, tox_data->user_data);
+ length, message_id, tox_data->user_data);
tox_lock(tox_data->tox);
}
}
@@ -712,7 +712,8 @@ static int tox_load(Tox *tox, const uint8_t *data, uint32_t length)
length - cookie_len, STATE_COOKIE_TYPE);
}
-Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
+nullable(1, 2, 3)
+static Tox *tox_new_system(const struct Tox_Options *options, Tox_Err_New *error, const Tox_System *sys)
{
struct Tox_Options *default_options = nullptr;
@@ -736,7 +737,6 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
const struct Tox_Options *const opts = options != nullptr ? options : default_options;
assert(opts != nullptr);
- const Tox_System *sys = tox_options_get_operating_system(opts);
const Tox_System default_system = tox_default_system();
if (sys == nullptr) {
@@ -1020,6 +1020,37 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
return tox;
}
+Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
+{
+ return tox_new_system(options, error, nullptr);
+}
+
+Tox *tox_new_testing(const Tox_Options *options, Tox_Err_New *error, const Tox_Options_Testing *testing, Tox_Err_New_Testing *testing_error)
+{
+ if (testing == nullptr) {
+ SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL);
+ SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL);
+ return nullptr;
+ }
+
+ if (testing->operating_system == nullptr) {
+ SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL);
+ SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL);
+ return nullptr;
+ }
+
+ const Tox_System *sys = testing->operating_system;
+
+ if (sys->rng == nullptr || sys->ns == nullptr || sys->mem == nullptr) {
+ SET_ERROR_PARAMETER(error, TOX_ERR_NEW_NULL);
+ SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_NULL);
+ return nullptr;
+ }
+
+ SET_ERROR_PARAMETER(testing_error, TOX_ERR_NEW_TESTING_OK);
+ return tox_new_system(options, error, sys);
+}
+
void tox_kill(Tox *tox)
{
if (tox == nullptr) {
@@ -1027,7 +1058,7 @@ void tox_kill(Tox *tox)
}
tox_lock(tox);
- LOGGER_ASSERT(tox->m->log, tox->m->msi_packet == nullptr, "Attempted to kill tox while toxav is still alive");
+ LOGGER_ASSERT(tox->m->log, tox->toxav_object == nullptr, "Attempted to kill tox while toxav is still alive");
kill_groupchats(tox->m->conferences_object);
kill_messenger(tox->m);
mono_time_free(tox->sys.mem, tox->mono_time);
@@ -2520,6 +2551,12 @@ uint32_t tox_conference_join(Tox *tox, uint32_t friend_number, const uint8_t *co
Tox_Err_Conference_Join *error)
{
assert(tox != nullptr);
+
+ if (cookie == nullptr) {
+ SET_ERROR_PARAMETER(error, TOX_ERR_CONFERENCE_JOIN_NULL);
+ return UINT32_MAX;
+ }
+
tox_lock(tox);
const int ret = join_groupchat(tox->m->conferences_object, friend_number, GROUPCHAT_TYPE_TEXT, cookie, length);
tox_unlock(tox);
@@ -3688,7 +3725,7 @@ bool tox_group_set_topic(Tox *tox, uint32_t group_number, const uint8_t *topic,
return false;
}
-size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error)
+size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3696,12 +3733,12 @@ size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_G
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return -1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const size_t ret = gc_get_topic_size(chat);
tox_unlock(tox);
@@ -3709,7 +3746,7 @@ size_t tox_group_get_topic_size(const Tox *tox, uint32_t group_number, Tox_Err_G
return ret;
}
-bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, Tox_Err_Group_State_Queries *error)
+bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3717,7 +3754,7 @@ bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic,
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
@@ -3725,11 +3762,11 @@ bool tox_group_get_topic(const Tox *tox, uint32_t group_number, uint8_t *topic,
gc_get_topic(chat, topic);
tox_unlock(tox);
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
return true;
}
-size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error)
+size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3737,12 +3774,12 @@ size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Gr
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return -1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const size_t ret = gc_get_group_name_size(chat);
tox_unlock(tox);
@@ -3750,7 +3787,7 @@ size_t tox_group_get_name_size(const Tox *tox, uint32_t group_number, Tox_Err_Gr
return ret;
}
-bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, Tox_Err_Group_State_Queries *error)
+bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3758,7 +3795,7 @@ bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, To
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
@@ -3766,12 +3803,12 @@ bool tox_group_get_name(const Tox *tox, uint32_t group_number, uint8_t *name, To
gc_get_group_name(chat, name);
tox_unlock(tox);
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
return true;
}
-bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], Tox_Err_Group_State_Queries *error)
+bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE], Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3779,12 +3816,12 @@ bool tox_group_get_chat_id(const Tox *tox, uint32_t group_number, uint8_t chat_i
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
gc_get_chat_id(chat, chat_id);
tox_unlock(tox);
@@ -3803,7 +3840,7 @@ uint32_t tox_group_get_number_groups(const Tox *tox)
}
Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t group_number,
- Tox_Err_Group_State_Queries *error)
+ Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3811,12 +3848,12 @@ Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t gro
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return (Tox_Group_Privacy_State) - 1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const uint8_t state = gc_get_privacy_state(chat);
tox_unlock(tox);
@@ -3824,7 +3861,7 @@ Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, uint32_t gro
return (Tox_Group_Privacy_State)state;
}
-Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error)
+Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3832,12 +3869,12 @@ Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_num
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return (Tox_Group_Topic_Lock) - 1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const Group_Topic_Lock topic_lock = gc_get_topic_lock_state(chat);
tox_unlock(tox);
@@ -3846,7 +3883,7 @@ Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, uint32_t group_num
}
Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_number,
- Tox_Err_Group_State_Queries *error)
+ Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3854,12 +3891,12 @@ Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_n
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return (Tox_Group_Voice_State) - 1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const Group_Voice_State voice_state = gc_get_voice_state(chat);
tox_unlock(tox);
@@ -3867,7 +3904,7 @@ Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, uint32_t group_n
return (Tox_Group_Voice_State)voice_state;
}
-uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error)
+uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3875,12 +3912,12 @@ uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return -1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const uint16_t ret = gc_get_max_peers(chat);
tox_unlock(tox);
@@ -3888,7 +3925,7 @@ uint16_t tox_group_get_peer_limit(const Tox *tox, uint32_t group_number, Tox_Err
return ret;
}
-size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Queries *error)
+size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3896,12 +3933,12 @@ size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Er
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return -1;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
const size_t ret = gc_get_password_size(chat);
tox_unlock(tox);
@@ -3910,7 +3947,7 @@ size_t tox_group_get_password_size(const Tox *tox, uint32_t group_number, Tox_Er
}
bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *password,
- Tox_Err_Group_State_Queries *error)
+ Tox_Err_Group_State_Query *error)
{
assert(tox != nullptr);
@@ -3918,12 +3955,12 @@ bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *pass
const GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERIES_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_STATE_QUERY_OK);
gc_get_password(chat, password);
tox_unlock(tox);
@@ -3932,7 +3969,7 @@ bool tox_group_get_password(const Tox *tox, uint32_t group_number, uint8_t *pass
}
Tox_Group_Message_Id tox_group_send_message(
- const Tox *tox, uint32_t group_number, Tox_Message_Type type, const uint8_t *message,
+ const Tox *tox, uint32_t group_number, Tox_Message_Type message_type, const uint8_t *message,
size_t length, Tox_Err_Group_Send_Message *error)
{
assert(tox != nullptr);
@@ -3953,7 +3990,7 @@ Tox_Group_Message_Id tox_group_send_message(
}
uint32_t message_id = 0;
- const int ret = gc_send_message(chat, message, length, type, &message_id);
+ const int ret = gc_send_message(chat, message, length, message_type, &message_id);
tox_unlock(tox);
switch (ret) {
@@ -3994,8 +4031,8 @@ Tox_Group_Message_Id tox_group_send_message(
return -1;
}
-bool tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type,
- const uint8_t *message, size_t length, Tox_Err_Group_Send_Private_Message *error)
+Tox_Group_Message_Id tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint32_t peer_id,
+ Tox_Message_Type message_type, const uint8_t *message, size_t length, Tox_Err_Group_Send_Private_Message *error)
{
assert(tox != nullptr);
@@ -4005,59 +4042,60 @@ bool tox_group_send_private_message(const Tox *tox, uint32_t group_number, uint3
if (chat == nullptr) {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_GROUP_NOT_FOUND);
tox_unlock(tox);
- return false;
+ return -1;
}
if (chat->connection_state == CS_DISCONNECTED) {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED);
tox_unlock(tox);
- return false;
+ return -1;
}
- const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), type, message, length);
+ uint32_t message_id = 0;
+ const int ret = gc_send_private_message(chat, gc_peer_id_from_int(peer_id), message_type, message, length, &message_id);
tox_unlock(tox);
switch (ret) {
case 0: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_OK);
- return true;
+ return message_id;
}
case -1: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_TOO_LONG);
- return false;
+ return -1;
}
case -2: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY);
- return false;
+ return -1;
}
case -3: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PEER_NOT_FOUND);
- return false;
+ return -1;
}
case -4: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE);
- return false;
+ return -1;
}
case -5: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS);
- return false;
+ return -1;
}
case -6: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_FAIL_SEND);
- return false;
+ return -1;
}
}
/* can't happen */
LOGGER_FATAL(tox->m->log, "impossible return value: %d", ret);
- return false;
+ return -1;
}
bool tox_group_send_custom_packet(const Tox *tox, uint32_t group_number, bool lossless, const uint8_t *data,
@@ -4100,11 +4138,6 @@ bool tox_group_send_custom_packet(const Tox *tox, uint32_t group_number, bool lo
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS);
- return false;
- }
-
- case -4: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PACKET_FAIL_SEND);
return false;
}
@@ -4162,11 +4195,6 @@ bool tox_group_send_custom_private_packet(const Tox *tox, uint32_t group_number,
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS);
- return false;
- }
-
- case -5: {
SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND);
return false;
}
@@ -4241,6 +4269,11 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t
{
assert(tox != nullptr);
+ if (invite_data == nullptr || name == nullptr) {
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_NULL);
+ return UINT32_MAX;
+ }
+
tox_lock(tox);
const int ret = gc_accept_invite(tox->m->group_handler, friend_number, invite_data, length, name, name_length, password,
password_length);
@@ -4278,7 +4311,7 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t
}
case -6: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_CORE);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND);
return UINT32_MAX;
}
@@ -4294,8 +4327,8 @@ uint32_t tox_group_invite_accept(Tox *tox, uint32_t friend_number, const uint8_t
return UINT32_MAX;
}
-bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8_t *password, size_t length,
- Tox_Err_Group_Founder_Set_Password *error)
+bool tox_group_set_password(Tox *tox, uint32_t group_number, const uint8_t *password, size_t length,
+ Tox_Err_Group_Set_Password *error)
{
assert(tox != nullptr);
@@ -4303,13 +4336,13 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8
GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
if (chat->connection_state == CS_DISCONNECTED) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_DISCONNECTED);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_DISCONNECTED);
tox_unlock(tox);
return false;
}
@@ -4319,27 +4352,27 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_PERMISSIONS);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_TOO_LONG);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_TOO_LONG);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_FAIL_SEND);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_MALLOC);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PASSWORD_MALLOC);
return false;
}
}
@@ -4350,8 +4383,8 @@ bool tox_group_founder_set_password(Tox *tox, uint32_t group_number, const uint8
return false;
}
-bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state,
- Tox_Err_Group_Founder_Set_Privacy_State *error)
+bool tox_group_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Group_Privacy_State privacy_state,
+ Tox_Err_Group_Set_Privacy_State *error)
{
assert(tox != nullptr);
@@ -4361,32 +4394,32 @@ bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Gr
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_GROUP_NOT_FOUND);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_PERMISSIONS);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_DISCONNECTED);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_DISCONNECTED);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SET);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SET);
return false;
}
case -5: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SEND);
return false;
}
}
@@ -4397,8 +4430,8 @@ bool tox_group_founder_set_privacy_state(Tox *tox, uint32_t group_number, Tox_Gr
return false;
}
-bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock,
- Tox_Err_Group_Founder_Set_Topic_Lock *error)
+bool tox_group_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group_Topic_Lock topic_lock,
+ Tox_Err_Group_Set_Topic_Lock *error)
{
assert(tox != nullptr);
@@ -4408,37 +4441,37 @@ bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_GROUP_NOT_FOUND);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_INVALID);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_INVALID);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_PERMISSIONS);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_DISCONNECTED);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_DISCONNECTED);
return false;
}
case -5: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SET);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SET);
return false;
}
case -6: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SEND);
return false;
}
}
@@ -4449,8 +4482,8 @@ bool tox_group_founder_set_topic_lock(Tox *tox, uint32_t group_number, Tox_Group
return false;
}
-bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state,
- Tox_Err_Group_Founder_Set_Voice_State *error)
+bool tox_group_set_voice_state(Tox *tox, uint32_t group_number, Tox_Group_Voice_State voice_state,
+ Tox_Err_Group_Set_Voice_State *error)
{
assert(tox != nullptr);
@@ -4460,32 +4493,32 @@ bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Grou
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_GROUP_NOT_FOUND);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_PERMISSIONS);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_DISCONNECTED);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_DISCONNECTED);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SET);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SET);
return false;
}
case -5: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SEND);
return false;
}
}
@@ -4496,8 +4529,8 @@ bool tox_group_founder_set_voice_state(Tox *tox, uint32_t group_number, Tox_Grou
return false;
}
-bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t peer_limit,
- Tox_Err_Group_Founder_Set_Peer_Limit *error)
+bool tox_group_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t peer_limit,
+ Tox_Err_Group_Set_Peer_Limit *error)
{
assert(tox != nullptr);
@@ -4505,13 +4538,13 @@ bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t
GC_Chat *chat = gc_get_group(tox->m->group_handler, group_number);
if (chat == nullptr) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_GROUP_NOT_FOUND);
tox_unlock(tox);
return false;
}
if (chat->connection_state == CS_DISCONNECTED) {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_DISCONNECTED);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_DISCONNECTED);
tox_unlock(tox);
return false;
}
@@ -4521,22 +4554,22 @@ bool tox_group_founder_set_peer_limit(Tox *tox, uint32_t group_number, uint16_t
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_PERMISSIONS);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SET);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SET);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SEND);
return false;
}
}
@@ -4587,8 +4620,8 @@ bool tox_group_set_ignore(Tox *tox, uint32_t group_number, uint32_t peer_id, boo
return false;
}
-bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Role role,
- Tox_Err_Group_Mod_Set_Role *error)
+bool tox_group_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Group_Role role,
+ Tox_Err_Group_Set_Role *error)
{
assert(tox != nullptr);
@@ -4598,37 +4631,37 @@ bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, T
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_GROUP_NOT_FOUND);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_PEER_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_PEER_NOT_FOUND);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_PERMISSIONS);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_ASSIGNMENT);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_ASSIGNMENT);
return false;
}
case -5: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_FAIL_ACTION);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_FAIL_ACTION);
return false;
}
case -6: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_SET_ROLE_SELF);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_SET_ROLE_SELF);
return false;
}
}
@@ -4639,8 +4672,8 @@ bool tox_group_mod_set_role(Tox *tox, uint32_t group_number, uint32_t peer_id, T
return false;
}
-bool tox_group_mod_kick_peer(const Tox *tox, uint32_t group_number, uint32_t peer_id,
- Tox_Err_Group_Mod_Kick_Peer *error)
+bool tox_group_kick_peer(const Tox *tox, uint32_t group_number, uint32_t peer_id,
+ Tox_Err_Group_Kick_Peer *error)
{
assert(tox != nullptr);
@@ -4650,37 +4683,37 @@ bool tox_group_mod_kick_peer(const Tox *tox, uint32_t group_number, uint32_t pee
switch (ret) {
case 0: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_OK);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_OK);
return true;
}
case -1: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_GROUP_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_GROUP_NOT_FOUND);
return false;
}
case -2: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_PEER_NOT_FOUND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_PEER_NOT_FOUND);
return false;
}
case -3: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_PERMISSIONS);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_PERMISSIONS);
return false;
}
case -4: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_ACTION);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_FAIL_ACTION);
return false;
}
case -5: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_SEND);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_FAIL_SEND);
return false;
}
case -6: {
- SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_MOD_KICK_PEER_SELF);
+ SET_ERROR_PARAMETER(error, TOX_ERR_GROUP_KICK_PEER_SELF);
return false;
}
}
diff --git a/protocols/Tox/libtox/src/toxcore/tox.h b/protocols/Tox/libtox/src/toxcore/tox.h
index fa887fc779..ebeed3b1f5 100644
--- a/protocols/Tox/libtox/src/toxcore/tox.h
+++ b/protocols/Tox/libtox/src/toxcore/tox.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
- * Copyright © 2016-2018 The TokTok team.
+ * Copyright © 2016-2024 The TokTok team.
* Copyright © 2013 Tox project.
*/
@@ -25,9 +25,8 @@
* could not perform any operation, because one of the required parameters was
* NULL. Some functions operate correctly or are defined as effectless on NULL.
*
- * Some functions additionally return a value outside their
- * return type domain, or a bool containing true on success and false on
- * failure.
+ * Some functions additionally return a value outside their return type domain,
+ * or a bool containing true on success and false on failure.
*
* All functions that take a Tox instance pointer will cause undefined behaviour
* when passed a NULL Tox pointer.
@@ -52,17 +51,9 @@
* event listeners, it needs to implement the dispatch functionality itself.
*
* The last argument to a callback is the user data pointer. It is passed from
- * tox_iterate to each callback in sequence.
- *
- * The user data pointer is never stored or dereferenced by any library code, so
- * can be any pointer, including NULL. Callbacks must all operate on the same
- * object type. In the apidsl code (tox.in.h), this is denoted with `any`. The
- * `any` in tox_iterate must be the same `any` as in all callbacks. In C,
- * lacking parametric polymorphism, this is a pointer to void.
- *
- * Old style callbacks that are registered together with a user data pointer
- * receive that pointer as argument when they are called. They can each have
- * their own user data pointer of their own type.
+ * tox_iterate to each callback in sequence. The user data pointer is never
+ * stored or dereferenced by any library code, so can be any pointer, including
+ * NULL.
*
* @section threading Threading implications
*
@@ -157,7 +148,7 @@ uint32_t tox_version_minor(void);
* Incremented when bugfixes are applied without changing any functionality or
* API or ABI.
*/
-#define TOX_VERSION_PATCH 18
+#define TOX_VERSION_PATCH 20
uint32_t tox_version_patch(void);
@@ -206,7 +197,7 @@ bool tox_version_is_compatible(uint32_t major, uint32_t minor, uint32_t patch);
*
* The values of these are not part of the ABI. Prefer to use the function
* versions of them for code that should remain compatible with future versions
- * of toxcore.
+ * of the Tox library.
*/
/**
@@ -468,12 +459,12 @@ typedef enum Tox_Log_Level {
TOX_LOG_LEVEL_INFO,
/**
- * Warnings about events_alloc inconsistency or logic errors.
+ * Warnings about internal inconsistency or logic errors.
*/
TOX_LOG_LEVEL_WARNING,
/**
- * Severe unexpected errors caused by external or events_alloc inconsistency.
+ * Severe unexpected errors caused by external or internal inconsistency.
*/
TOX_LOG_LEVEL_ERROR,
@@ -482,7 +473,7 @@ typedef enum Tox_Log_Level {
const char *tox_log_level_to_string(Tox_Log_Level value);
/**
- * @brief This event is triggered when the toxcore library logs an events_alloc message.
+ * @brief This event is triggered when Tox logs an internal message.
*
* This is mostly useful for debugging. This callback can be called from any
* function, not just tox_iterate. This means the user data lifetime must at
@@ -506,15 +497,6 @@ typedef void tox_log_cb(Tox *tox, Tox_Log_Level level, const char *file, uint32_
const char *message, void *user_data);
/**
- * @brief Operating system functions used by Tox.
- *
- * This struct is opaque and generally shouldn't be used in clients, but in
- * combination with tox_private.h, it allows tests to inject non-IO (hermetic)
- * versions of low level network, RNG, and time keeping functions.
- */
-typedef struct Tox_System Tox_System;
-
-/**
* @brief This struct contains all the startup options for Tox.
*
* You must tox_options_new to allocate an object of this type.
@@ -546,10 +528,11 @@ struct Tox_Options {
* Enable the use of UDP communication when available.
*
* Setting this to false will force Tox to use TCP only. Communications will
- * need to be relayed through a TCP relay node, potentially slowing them down.
+ * need to be relayed through a TCP relay node, potentially slowing them
+ * down.
*
- * If a proxy is enabled, UDP will be disabled if either toxcore or the
- * proxy don't support proxying UDP messages.
+ * If a proxy is enabled, UDP will be disabled if either the Tox library or
+ * the proxy don't support proxying UDP messages.
*/
bool udp_enabled;
@@ -576,10 +559,11 @@ struct Tox_Options {
* The IP address or DNS name of the proxy to be used.
*
* If used, this must be non-NULL and be a valid DNS name. The name must not
- * exceed TOX_MAX_HOSTNAME_LENGTH characters, and be in a NUL-terminated C string
- * format (TOX_MAX_HOSTNAME_LENGTH includes the NUL byte).
+ * exceed TOX_MAX_HOSTNAME_LENGTH characters, and be in a NUL-terminated C
+ * string format (TOX_MAX_HOSTNAME_LENGTH includes the NUL byte).
*
- * This member is ignored (it can be NULL) if proxy_type is TOX_PROXY_TYPE_NONE.
+ * This member is ignored (it can be NULL) if proxy_type is
+ * TOX_PROXY_TYPE_NONE.
*
* The data pointed at by this member is owned by the user, so must
* outlive the options object.
@@ -603,8 +587,8 @@ struct Tox_Options {
* If either start_port or end_port is 0 while the other is non-zero, the
* non-zero port will be the only port in the range.
*
- * Having start_port > end_port will yield the same behavior as if start_port
- * and end_port were swapped.
+ * Having start_port > end_port will yield the same behavior as if
+ * start_port and end_port were swapped.
*/
uint16_t start_port;
@@ -627,7 +611,7 @@ struct Tox_Options {
uint16_t tcp_port;
/**
- * Enables or disables UDP hole-punching in toxcore. (Default: enabled).
+ * Enables or disables UDP hole-punching. (Default: enabled).
*/
bool hole_punching_enabled;
@@ -639,8 +623,8 @@ struct Tox_Options {
/**
* The savedata.
*
- * The data pointed at by this member is owned by the user, so must
- * outlive the options object.
+ * The data pointed at by this member is owned by the user, so must outlive
+ * the options object.
*/
const uint8_t *savedata_data;
@@ -650,7 +634,7 @@ struct Tox_Options {
size_t savedata_length;
/**
- * Logging callback for the new tox instance.
+ * Logging callback for the new Tox instance.
*/
tox_log_cb *log_callback;
@@ -673,14 +657,9 @@ struct Tox_Options {
bool experimental_thread_safety;
/**
- * Low level operating system functionality such as send/recv, random
- * number generation, and memory allocation.
- */
- const Tox_System *operating_system;
-
- /**
- * Enable saving DHT-based group chats to Tox save data (via `tox_get_savedata`).
- * This format will change in the future, so don't rely on it.
+ * Enable saving DHT-based group chats to Tox save data (via
+ * `tox_get_savedata`). This format will change in the future, so don't rely
+ * on it.
*
* As an alternative, clients can save the group chat ID in client-owned
* savedata. Then, when the client starts, it can use `tox_group_join`
@@ -759,10 +738,6 @@ bool tox_options_get_experimental_thread_safety(const Tox_Options *options);
void tox_options_set_experimental_thread_safety(Tox_Options *options, bool experimental_thread_safety);
-const Tox_System *tox_options_get_operating_system(const Tox_Options *options);
-
-void tox_options_set_operating_system(Tox_Options *options, const Tox_System *operating_system);
-
bool tox_options_get_experimental_groups_persistence(const Tox_Options *options);
void tox_options_set_experimental_groups_persistence(Tox_Options *options, bool experimental_groups_persistence);
@@ -837,15 +812,16 @@ typedef enum Tox_Err_New {
TOX_ERR_NEW_NULL,
/**
- * The function was unable to allocate enough memory to store the events_alloc
- * structures for the Tox object.
+ * The function was unable to allocate enough memory to store the
+ * internal structures for the Tox object.
*/
TOX_ERR_NEW_MALLOC,
/**
* The function was unable to bind to a port. This may mean that all ports
* have already been bound, e.g. by other Tox instances, or it may mean
- * a permission error. You may be able to gather more information from errno.
+ * a permission error. You may be able to gather more information from
+ * errno.
*/
TOX_ERR_NEW_PORT_ALLOC,
@@ -913,7 +889,7 @@ Tox *tox_new(const Tox_Options *options, Tox_Err_New *error);
void tox_kill(Tox *tox);
/**
- * @brief Calculates the number of bytes required to store the tox instance with
+ * @brief Calculates the number of bytes required to store the Tox instance with
* tox_get_savedata.
*
* This function cannot fail. The result is always greater than 0.
@@ -923,11 +899,12 @@ void tox_kill(Tox *tox);
size_t tox_get_savedata_size(const Tox *tox);
/**
- * @brief Store all information associated with the tox instance to a byte array.
+ * @brief Store all information associated with the Tox instance to a byte
+ * array.
*
- * @param savedata A memory region large enough to store the tox instance
- * data. Call tox_get_savedata_size to find the number of bytes required. If this parameter
- * is NULL, this function has no effect.
+ * @param savedata A memory region large enough to store the Tox instance
+ * data. Call tox_get_savedata_size to find the number of bytes required. If
+ * this parameter is NULL, this function has no effect.
*/
void tox_get_savedata(const Tox *tox, uint8_t savedata[]);
@@ -1065,14 +1042,16 @@ typedef void tox_self_connection_status_cb(Tox *tox, Tox_Connection connection_s
void tox_callback_self_connection_status(Tox *tox, tox_self_connection_status_cb *callback);
/**
- * @brief Return the time in milliseconds before `tox_iterate()` should be called again
- * for optimal performance.
+ * @brief Return the time in milliseconds before `tox_iterate()` should be
+ * called again for optimal performance.
*/
uint32_t tox_iteration_interval(const Tox *tox);
/**
- * @brief The main loop that needs to be run in intervals of `tox_iteration_interval()`
- * milliseconds.
+ * @brief The main loop that needs to be run in intervals of
+ * `tox_iteration_interval()` milliseconds.
+ * @param user_data Any pointer a client wishes the Tox instance to pass into
+ * the event callbacks, including NULL.
*/
void tox_iterate(Tox *tox, void *user_data);
@@ -1172,7 +1151,8 @@ const char *tox_err_set_info_to_string(Tox_Err_Set_Info value);
bool tox_self_set_name(Tox *tox, const uint8_t name[], size_t length, Tox_Err_Set_Info *error);
/**
- * @brief Return the length of the current nickname as passed to tox_self_set_name.
+ * @brief Return the length of the current nickname as passed to
+ * tox_self_set_name.
*
* If no nickname was set before calling this function, the name is empty,
* and this function returns 0.
@@ -1206,7 +1186,8 @@ bool tox_self_set_status_message(
Tox *tox, const uint8_t status_message[], size_t length, Tox_Err_Set_Info *error);
/**
- * @brief Return the length of the current status message as passed to tox_self_set_status_message.
+ * @brief Return the length of the current status message as passed to
+ * tox_self_set_status_message.
*
* If no status message was set before calling this function, the status
* is empty, and this function returns 0.
@@ -1216,13 +1197,14 @@ bool tox_self_set_status_message(
size_t tox_self_get_status_message_size(const Tox *tox);
/**
- * @brief Write the status message set by tox_self_set_status_message to a byte array.
+ * @brief Write the status message set by tox_self_set_status_message to a byte
+ * array.
*
* If no status message was set before calling this function, the status is
* empty, and this function has no effect.
*
- * Call tox_self_get_status_message_size to find out how much memory to allocate for
- * the result.
+ * Call tox_self_get_status_message_size to find out how much memory to allocate
+ * for the result.
*
* @param status_message A valid memory location large enough to hold the
* status message. If this parameter is NULL, the function has no effect.
@@ -1279,8 +1261,8 @@ typedef enum Tox_Err_Friend_Add {
TOX_ERR_FRIEND_ADD_OWN_KEY,
/**
- * A friend request has already been sent, or the address belongs to a friend
- * that is already on the friend list.
+ * A friend request has already been sent, or the address belongs to a
+ * friend that is already on the friend list.
*/
TOX_ERR_FRIEND_ADD_ALREADY_SENT,
@@ -1360,7 +1342,8 @@ typedef enum Tox_Err_Friend_Delete {
TOX_ERR_FRIEND_DELETE_OK,
/**
- * There was no friend with the given friend number. No friends were deleted.
+ * There was no friend with the given friend number. No friends were
+ * deleted.
*/
TOX_ERR_FRIEND_DELETE_FRIEND_NOT_FOUND,
@@ -1411,14 +1394,15 @@ const char *tox_err_friend_by_public_key_to_string(Tox_Err_Friend_By_Public_Key
/**
* @brief Return the friend number associated with that Public Key.
*
- * @return the friend number on success, an unspecified value on failure.
* @param public_key A byte array containing the Public Key.
+ *
+ * @return the friend number on success, an unspecified value on failure.
*/
Tox_Friend_Number tox_friend_by_public_key(const Tox *tox, const uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Friend_By_Public_Key *error);
/**
- * @brief Checks if a friend with the given friend number exists and returns true if
- * it does.
+ * @brief Checks if a friend with the given friend number exists and returns
+ * true if it does.
*/
bool tox_friend_exists(const Tox *tox, Tox_Friend_Number friend_number);
@@ -1433,7 +1417,8 @@ size_t tox_self_get_friend_list_size(const Tox *tox);
/**
* @brief Copy a list of valid friend numbers into an array.
*
- * Call tox_self_get_friend_list_size to determine the number of elements to allocate.
+ * Call tox_self_get_friend_list_size to determine the number of elements to
+ * allocate.
*
* @param friend_list A memory region with enough space to hold the friend
* list. If this parameter is NULL, this function has no effect.
@@ -1457,7 +1442,8 @@ typedef enum Tox_Err_Friend_Get_Public_Key {
const char *tox_err_friend_get_public_key_to_string(Tox_Err_Friend_Get_Public_Key value);
/**
- * @brief Copies the Public Key associated with a given friend number to a byte array.
+ * @brief Copies the Public Key associated with a given friend number to a byte
+ * array.
*
* @param friend_number The friend number you want the Public Key of.
* @param public_key A memory region of at least TOX_PUBLIC_KEY_SIZE bytes. If
@@ -1486,8 +1472,8 @@ typedef enum Tox_Err_Friend_Get_Last_Online {
const char *tox_err_friend_get_last_online_to_string(Tox_Err_Friend_Get_Last_Online value);
/**
- * @brief Return a unix-time timestamp of the last time the friend associated with a given
- * friend number was seen online.
+ * @brief Return a unix-time timestamp of the last time the friend associated
+ * with a given friend number was seen online.
*
* This function will return UINT64_MAX on error.
*
@@ -1514,8 +1500,9 @@ typedef enum Tox_Err_Friend_Query {
/**
* The pointer parameter for storing the query result (name, message) was
- * NULL. Unlike the `_self_` variants of these functions, which have no effect
- * when a parameter is NULL, these functions return an error in that case.
+ * NULL. Unlike the `_self_` variants of these functions, which have no
+ * effect when a parameter is NULL, these functions return an error in that
+ * case.
*/
TOX_ERR_FRIEND_QUERY_NULL,
@@ -1540,8 +1527,8 @@ size_t tox_friend_get_name_size(
const Tox *tox, Tox_Friend_Number friend_number, Tox_Err_Friend_Query *error);
/**
- * @brief Write the name of the friend designated by the given friend number to a byte
- * array.
+ * @brief Write the name of the friend designated by the given friend number to
+ * a byte array.
*
* Call tox_friend_get_name_size to determine the allocation size for the `name`
* parameter.
@@ -1579,22 +1566,23 @@ void tox_callback_friend_name(Tox *tox, tox_friend_name_cb *callback);
/**
* @brief Return the length of the friend's status message.
*
- * If the friend number isinvalid, the return value is SIZE_MAX.
+ * If the friend number is invalid, the return value is SIZE_MAX.
*/
size_t tox_friend_get_status_message_size(
const Tox *tox, Tox_Friend_Number friend_number, Tox_Err_Friend_Query *error);
/**
- * @brief Write the status message of the friend designated by the given friend number to a byte
- * array.
+ * @brief Write the status message of the friend designated by the given friend
+ * number to a byte array.
*
- * Call tox_friend_get_status_message_size to determine the allocation size for the `status_message`
- * parameter.
+ * Call tox_friend_get_status_message_size to determine the allocation size for
+ * the `status_message` parameter.
*
- * The data written to `status_message` is equal to the data received by the last
- * `friend_status_message` callback.
+ * The data written to `status_message` is equal to the data received by the
+ * last `friend_status_message` callback.
*
- * @param status_message A valid memory region large enough to store the friend's status message.
+ * @param status_message A valid memory region large enough to store the
+ * friend's status message.
*/
bool tox_friend_get_status_message(
const Tox *tox, Tox_Friend_Number friend_number, uint8_t status_message[],
@@ -1604,7 +1592,8 @@ bool tox_friend_get_status_message(
* @param friend_number The friend number of the friend whose status message
* changed.
* @param message A byte array containing the same data as
- * tox_friend_get_status_message would write to its `status_message` parameter.
+ * tox_friend_get_status_message would write to its `status_message`
+ * parameter.
* @param length A value equal to the return value of
* tox_friend_get_status_message_size.
*/
@@ -1814,7 +1803,8 @@ typedef uint32_t Tox_Friend_Message_Id;
* then reassemble the fragments. Messages may not be empty.
*
* The return value of this function is the message ID. If a read receipt is
- * received, the triggered `friend_read_receipt` event will be passed this message ID.
+ * received, the triggered `friend_read_receipt` event will be passed this
+ * message ID.
*
* Message IDs are unique per friend. The first message ID is 0. Message IDs are
* incremented by 1 each time a message is sent. If UINT32_MAX messages were
@@ -1831,7 +1821,8 @@ Tox_Friend_Message_Id tox_friend_send_message(
const uint8_t message[], size_t length, Tox_Err_Friend_Send_Message *error);
/**
- * @param friend_number The friend number of the friend who received the message.
+ * @param friend_number The friend number of the friend who received the
+ * message.
* @param message_id The message ID as returned from tox_friend_send_message
* corresponding to the message sent.
*/
@@ -1875,6 +1866,7 @@ void tox_callback_friend_request(Tox *tox, tox_friend_request_cb *callback);
/**
* @param friend_number The friend number of the friend who sent the message.
+ * @param type The type of the message (normal, action, ...).
* @param message The message data they sent.
* @param length The size of the message byte array.
*/
@@ -1906,10 +1898,10 @@ typedef uint32_t Tox_File_Number;
* primarily for validating cached avatars. This use is highly recommended to
* avoid unnecessary avatar updates.
*
- * If hash is NULL or data is NULL while length is not 0 the function returns false,
- * otherwise it returns true.
+ * If hash is NULL or data is NULL while length is not 0 the function returns
+ * false, otherwise it returns true.
*
- * This function is a wrapper to events_alloc message-digest functions.
+ * This function is a wrapper to internal message-digest functions.
*
* @param hash A valid memory location the hash data. It must be at least
* TOX_HASH_LENGTH bytes in size.
@@ -1923,17 +1915,17 @@ bool tox_hash(uint8_t hash[TOX_HASH_LENGTH], const uint8_t data[], size_t length
/**
* @brief A list of pre-defined file kinds.
*
- * Toxcore itself does not behave differently for different file kinds. These
- * are a hint to the client telling it what use the sender intended for the
- * file. The `kind` parameter in the send function and recv callback are
+ * The Tox library itself does not behave differently for different file kinds.
+ * These are a hint to the client telling it what use the sender intended for
+ * the file. The `kind` parameter in the send function and recv callback are
* `uint32_t`, not Tox_File_Kind, because clients can invent their own file
* kind. Unknown file kinds should be treated as TOX_FILE_KIND_DATA.
*/
enum Tox_File_Kind {
/**
- * Arbitrary file data. Clients can choose to handle it based on the file name
- * or magic or any other way they choose.
+ * Arbitrary file data. Clients can choose to handle it based on the file
+ * name or magic or any other way they choose.
*/
TOX_FILE_KIND_DATA,
@@ -1941,21 +1933,21 @@ enum Tox_File_Kind {
* Avatar file_id. This consists of tox_hash(image).
* Avatar data. This consists of the image data.
*
- * Avatars can be sent at any time the client wishes. Generally, a client will
- * send the avatar to a friend when that friend comes online, and to all
- * friends when the avatar changed. A client can save some traffic by
- * remembering which friend received the updated avatar already and only send
- * it if the friend has an out of date avatar.
+ * Avatars can be sent at any time the client wishes. Generally, a client
+ * will send the avatar to a friend when that friend comes online, and to
+ * all friends when the avatar changed. A client can save some traffic by
+ * remembering which friend received the updated avatar already and only
+ * send it if the friend has an out of date avatar.
*
* Clients who receive avatar send requests can reject it (by sending
* TOX_FILE_CONTROL_CANCEL before any other controls), or accept it (by
- * sending TOX_FILE_CONTROL_RESUME). The file_id of length TOX_HASH_LENGTH bytes
- * (same length as TOX_FILE_ID_LENGTH) will contain the hash. A client can compare
- * this hash with a saved hash and send TOX_FILE_CONTROL_CANCEL to terminate the avatar
- * transfer if it matches.
+ * sending TOX_FILE_CONTROL_RESUME). The file_id of length TOX_HASH_LENGTH
+ * bytes (same length as TOX_FILE_ID_LENGTH) will contain the hash. A client
+ * can compare this hash with a saved hash and send TOX_FILE_CONTROL_CANCEL
+ * to terminate the avatar transfer if it matches.
*
- * When file_size is set to 0 in the transfer request it means that the client
- * has no avatar.
+ * When file_size is set to 0 in the transfer request it means that the
+ * client has no avatar.
*/
TOX_FILE_KIND_AVATAR,
@@ -1964,16 +1956,17 @@ enum Tox_File_Kind {
typedef enum Tox_File_Control {
/**
- * Sent by the receiving side to accept a file send request. Also sent after a
- * TOX_FILE_CONTROL_PAUSE command to continue sending or receiving.
+ * Sent by the receiving side to accept a file send request. Also sent after
+ * a TOX_FILE_CONTROL_PAUSE command to continue sending or receiving.
*/
TOX_FILE_CONTROL_RESUME,
/**
* Sent by clients to pause the file transfer. The initial state of a file
- * transfer is always paused on the receiving side and running on the sending
- * side. If both the sending and receiving side pause the transfer, then both
- * need to send TOX_FILE_CONTROL_RESUME for the transfer to resume.
+ * transfer is always paused on the receiving side and running on the
+ * sending side. If both the sending and receiving side pause the transfer,
+ * then both need to send TOX_FILE_CONTROL_RESUME for the transfer to
+ * resume.
*/
TOX_FILE_CONTROL_PAUSE,
@@ -2005,7 +1998,8 @@ typedef enum Tox_Err_File_Control {
TOX_ERR_FILE_CONTROL_FRIEND_NOT_CONNECTED,
/**
- * No file transfer with the given file number was found for the given friend.
+ * No file transfer with the given file number was found for the given
+ * friend.
*/
TOX_ERR_FILE_CONTROL_NOT_FOUND,
@@ -2089,7 +2083,8 @@ typedef enum Tox_Err_File_Seek {
TOX_ERR_FILE_SEEK_FRIEND_NOT_CONNECTED,
/**
- * No file transfer with the given file number was found for the given friend.
+ * No file transfer with the given file number was found for the given
+ * friend.
*/
TOX_ERR_FILE_SEEK_NOT_FOUND,
@@ -2113,7 +2108,8 @@ typedef enum Tox_Err_File_Seek {
const char *tox_err_file_seek_to_string(Tox_Err_File_Seek value);
/**
- * @brief Sends a file seek control command to a friend for a given file transfer.
+ * @brief Sends a file seek control command to a friend for a given file
+ * transfer.
*
* This function can only be called to resume a file transfer right before
* TOX_FILE_CONTROL_RESUME is sent.
@@ -2144,7 +2140,8 @@ typedef enum Tox_Err_File_Get {
TOX_ERR_FILE_GET_FRIEND_NOT_FOUND,
/**
- * No file transfer with the given file number was found for the given friend.
+ * No file transfer with the given file number was found for the given
+ * friend.
*/
TOX_ERR_FILE_GET_NOT_FOUND,
@@ -2158,8 +2155,8 @@ const char *tox_err_file_get_to_string(Tox_Err_File_Get value);
* @param friend_number The friend number of the friend the file is being
* transferred to or received from.
* @param file_number The friend-specific identifier for the file transfer.
- * @param file_id A memory region of at least TOX_FILE_ID_LENGTH bytes. If
- * this parameter is NULL, this function has no effect.
+ * @param file_id A memory region of at least TOX_FILE_ID_LENGTH bytes. If this
+ * parameter is NULL, this function has no effect.
*
* @return true on success.
*/
@@ -2202,8 +2199,8 @@ typedef enum Tox_Err_File_Send {
TOX_ERR_FILE_SEND_NAME_TOO_LONG,
/**
- * Too many ongoing transfers. The maximum number of concurrent file transfers
- * is 256 per friend per direction (sending and receiving).
+ * Too many ongoing transfers. The maximum number of concurrent file
+ * transfers is 256 per friend per direction (sending and receiving).
*/
TOX_ERR_FILE_SEND_TOO_MANY,
@@ -2214,8 +2211,8 @@ const char *tox_err_file_send_to_string(Tox_Err_File_Send value);
/**
* @brief Send a file transmission request.
*
- * Maximum filename length is TOX_MAX_FILENAME_LENGTH bytes. The filename
- * should generally just be a file name, not a path with directory names.
+ * Maximum filename length is TOX_MAX_FILENAME_LENGTH bytes. The filename should
+ * generally just be a file name, not a path with directory names.
*
* If a non-UINT64_MAX file size is provided, it can be used by both sides to
* determine the sending progress. File size can be set to UINT64_MAX for
@@ -2224,8 +2221,8 @@ const char *tox_err_file_send_to_string(Tox_Err_File_Send value);
* File transmission occurs in chunks, which are requested through the
* `file_chunk_request` event.
*
- * When a friend goes offline, all file transfers associated with the friend are
- * purged from core.
+ * When a friend goes offline, all file transfers associated with the friend get
+ * purged.
*
* If the file contents change during a transfer, the behaviour is unspecified
* in general. What will actually happen depends on the mode in which the file
@@ -2234,15 +2231,16 @@ const char *tox_err_file_send_to_string(Tox_Err_File_Send value);
* - If the file size was increased
* - and sending mode was streaming (file_size = UINT64_MAX), the behaviour
* will be as expected.
- * - and sending mode was file (file_size != UINT64_MAX), the file_chunk_request
- * callback will receive length = 0 when Core thinks the file transfer has
- * finished. If the client remembers the file size as it was when sending the
- * request, it will terminate the transfer normally. If the client re-reads the
- * size, it will think the friend cancelled the transfer.
+ * - and sending mode was file (file_size != UINT64_MAX), the
+ * file_chunk_request callback will receive length = 0 when Tox thinks the
+ * file transfer has finished. If the client remembers the file size as it
+ * was when sending the request, it will terminate the transfer normally. If
+ * the client re-reads the size, it will think the friend cancelled the
+ * transfer.
* - If the file size was decreased
* - and sending mode was streaming, the behaviour is as expected.
* - and sending mode was file, the callback will return 0 at the new
- * (earlier) end-of-file, signalling to the friend that the transfer was
+ * (earlier) end-of-file, signaling to the friend that the transfer was
* cancelled.
* - If the file contents were modified
* - at a position before the current read, the two files (local and remote)
@@ -2255,19 +2253,20 @@ const char *tox_err_file_send_to_string(Tox_Err_File_Send value);
* @param friend_number The friend number of the friend the file send request
* should be sent to.
* @param kind The meaning of the file to be sent.
- * @param file_size Size in bytes of the file the client wants to send, UINT64_MAX if
- * unknown or streaming.
- * @param file_id A file identifier of length TOX_FILE_ID_LENGTH that can be used to
- * uniquely identify file transfers across core restarts. If NULL, a random one will
- * be generated by core. It can then be obtained by using `tox_file_get_file_id()`.
+ * @param file_size Size in bytes of the file the client wants to send,
+ * UINT64_MAX if unknown or streaming.
+ * @param file_id A file identifier of length TOX_FILE_ID_LENGTH that can be
+ * used to uniquely identify file transfers across Tox restarts. If NULL, a
+ * random one will be generated by the library. It can then be obtained by
+ * using `tox_file_get_file_id()`.
* @param filename Name of the file. Does not need to be the actual name. This
* name will be sent along with the file send request.
* @param filename_length Size in bytes of the filename.
*
* @return A file number used as an identifier in subsequent callbacks. This
* number is per friend. File numbers are reused after a transfer terminates.
- * On failure, this function returns an unspecified value. Any pattern in file numbers
- * should not be relied on.
+ * On failure, this function returns an unspecified value. Any pattern in file
+ * numbers should not be relied on.
*/
Tox_File_Number tox_file_send(
Tox *tox, Tox_Friend_Number friend_number, uint32_t kind, uint64_t file_size,
@@ -2297,20 +2296,23 @@ typedef enum Tox_Err_File_Send_Chunk {
TOX_ERR_FILE_SEND_CHUNK_FRIEND_NOT_CONNECTED,
/**
- * No file transfer with the given file number was found for the given friend.
+ * No file transfer with the given file number was found for the given
+ * friend.
*/
TOX_ERR_FILE_SEND_CHUNK_NOT_FOUND,
/**
* File transfer was found but isn't in a transferring state: (paused, done,
- * broken, etc...) (happens only when not called from the request chunk callback).
+ * broken, etc...) (happens only when not called from the request chunk
+ * callback).
*/
TOX_ERR_FILE_SEND_CHUNK_NOT_TRANSFERRING,
/**
- * Attempted to send more or less data than requested. The requested data size is
- * adjusted according to maximum transmission unit and the expected end of
- * the file. Trying to send less or more than requested will return this error.
+ * Attempted to send more or less data than requested. The requested data
+ * size is adjusted according to maximum transmission unit and the expected
+ * end of the file. Trying to send less or more than requested will return
+ * this error.
*/
TOX_ERR_FILE_SEND_CHUNK_INVALID_LENGTH,
@@ -2334,10 +2336,11 @@ const char *tox_err_file_send_chunk_to_string(Tox_Err_File_Send_Chunk value);
* This function is called in response to the `file_chunk_request` callback. The
* length parameter should be equal to the one received though the callback.
* If it is zero, the transfer is assumed complete. For files with known size,
- * Core will know that the transfer is complete after the last byte has been
+ * Tox will know that the transfer is complete after the last byte has been
* received, so it is not necessary (though not harmful) to send a zero-length
- * chunk to terminate. For streams, core will know that the transfer is finished
- * if a chunk with length less than the length requested in the callback is sent.
+ * chunk to terminate. For streams, Tox will know that the transfer is finished
+ * if a chunk with length less than the length requested in the callback is
+ * sent.
*
* @param friend_number The friend number of the receiving friend for this file.
* @param file_number The file transfer identifier returned by tox_file_send.
@@ -2379,7 +2382,7 @@ typedef void tox_file_chunk_request_cb(
*
* Pass NULL to unset.
*
- * This event is triggered when Core is ready to send more file data.
+ * This event is triggered when Tox is ready to send more file data.
*/
void tox_callback_file_chunk_request(Tox *tox, tox_file_chunk_request_cb *callback);
@@ -2458,6 +2461,7 @@ void tox_callback_file_recv_chunk(Tox *tox, tox_file_recv_chunk_cb *callback);
typedef uint32_t Tox_Conference_Number;
typedef uint32_t Tox_Conference_Peer_Number;
+typedef uint32_t Tox_Conference_Offline_Peer_Number;
/**
* @brief Conference types for the conference_invite event.
@@ -2465,7 +2469,8 @@ typedef uint32_t Tox_Conference_Peer_Number;
typedef enum Tox_Conference_Type {
/**
- * Text-only conferences that must be accepted with the tox_conference_join function.
+ * Text-only conferences that must be accepted with the tox_conference_join
+ * function.
*/
TOX_CONFERENCE_TYPE_TEXT,
@@ -2502,7 +2507,8 @@ typedef void tox_conference_invite_cb(
void tox_callback_conference_invite(Tox *tox, tox_conference_invite_cb *callback);
/**
- * @param conference_number The conference number of the conference to which we have connected.
+ * @param conference_number The conference number of the conference to which we
+ * have connected.
*/
typedef void tox_conference_connected_cb(Tox *tox, Tox_Conference_Number conference_number, void *user_data);
@@ -2555,7 +2561,8 @@ typedef void tox_conference_title_cb(
*
* This event is triggered when a peer changes the conference title.
*
- * If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference).
+ * If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining
+ * the conference).
*/
void tox_callback_conference_title(Tox *tox, tox_conference_title_cb *callback);
@@ -2640,7 +2647,8 @@ const char *tox_err_conference_delete_to_string(Tox_Err_Conference_Delete value)
/**
* @brief This function deletes a conference.
*
- * @param conference_number The conference number of the conference to be deleted.
+ * @param conference_number The conference number of the conference to be
+ * deleted.
*
* @return true on success.
*/
@@ -2682,7 +2690,7 @@ const char *tox_err_conference_peer_query_to_string(Tox_Err_Conference_Peer_Quer
* peer_number for the functions querying these peers. Return value is
* unspecified on failure.
*/
-Tox_Conference_Peer_Number tox_conference_peer_count(
+uint32_t tox_conference_peer_count(
const Tox *tox, Tox_Conference_Number conference_number, Tox_Err_Conference_Peer_Query *error);
/**
@@ -2697,7 +2705,8 @@ size_t tox_conference_peer_get_name_size(
/**
* @brief Copy the name of peer_number who is in conference_number to name.
*
- * Call tox_conference_peer_get_name_size to determine the allocation size for the `name` parameter.
+ * Call tox_conference_peer_get_name_size to determine the allocation size for
+ * the `name` parameter.
*
* @param name A valid memory region large enough to store the peer's name.
*
@@ -2708,7 +2717,8 @@ bool tox_conference_peer_get_name(
uint8_t name[], Tox_Err_Conference_Peer_Query *error);
/**
- * @brief Copy the public key of peer_number who is in conference_number to public_key.
+ * @brief Copy the public key of peer_number who is in conference_number to
+ * public_key.
*
* public_key must be TOX_PUBLIC_KEY_SIZE long.
*
@@ -2744,10 +2754,11 @@ uint32_t tox_conference_offline_peer_count(
*/
size_t tox_conference_offline_peer_get_name_size(
const Tox *tox, Tox_Conference_Number conference_number,
- Tox_Conference_Peer_Number offline_peer_number, Tox_Err_Conference_Peer_Query *error);
+ Tox_Conference_Offline_Peer_Number offline_peer_number, Tox_Err_Conference_Peer_Query *error);
/**
- * @brief Copy the name of offline_peer_number who is in conference_number to name.
+ * @brief Copy the name of offline_peer_number who is in conference_number to
+ * name.
*
* Call tox_conference_offline_peer_get_name_size to determine the allocation
* size for the `name` parameter.
@@ -2757,11 +2768,12 @@ size_t tox_conference_offline_peer_get_name_size(
* @return true on success.
*/
bool tox_conference_offline_peer_get_name(
- const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Peer_Number offline_peer_number,
+ const Tox *tox, Tox_Conference_Number conference_number, Tox_Conference_Offline_Peer_Number offline_peer_number,
uint8_t name[], Tox_Err_Conference_Peer_Query *error);
/**
- * @brief Copy the public key of offline_peer_number who is in conference_number to public_key.
+ * @brief Copy the public key of offline_peer_number who is in conference_number
+ * to public_key.
*
* public_key must be TOX_PUBLIC_KEY_SIZE long.
*
@@ -2769,14 +2781,15 @@ bool tox_conference_offline_peer_get_name(
*/
bool tox_conference_offline_peer_get_public_key(
const Tox *tox, Tox_Conference_Number conference_number,
- Tox_Conference_Peer_Number offline_peer_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error);
+ Tox_Conference_Offline_Peer_Number offline_peer_number, uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Conference_Peer_Query *error);
/**
- * @brief Return a unix-time timestamp of the last time offline_peer_number was seen to be active.
+ * @brief Return a unix-time timestamp of the last time offline_peer_number was
+ * seen to be active.
*/
uint64_t tox_conference_offline_peer_get_last_active(
const Tox *tox, Tox_Conference_Number conference_number,
- Tox_Conference_Peer_Number offline_peer_number, Tox_Err_Conference_Peer_Query *error);
+ Tox_Conference_Offline_Peer_Number offline_peer_number, Tox_Err_Conference_Peer_Query *error);
typedef enum Tox_Err_Conference_Set_Max_Offline {
@@ -2831,7 +2844,8 @@ const char *tox_err_conference_invite_to_string(Tox_Err_Conference_Invite value)
* @brief Invites a friend to a conference.
*
* @param friend_number The friend number of the friend we want to invite.
- * @param conference_number The conference number of the conference we want to invite the friend to.
+ * @param conference_number The conference number of the conference we want to
+ * invite the friend to.
*
* @return true on success.
*/
@@ -2852,7 +2866,8 @@ typedef enum Tox_Err_Conference_Join {
TOX_ERR_CONFERENCE_JOIN_INVALID_LENGTH,
/**
- * The conference is not the expected type. This indicates an invalid cookie.
+ * The conference is not the expected type. This indicates an invalid
+ * cookie.
*/
TOX_ERR_CONFERENCE_JOIN_WRONG_TYPE,
@@ -2876,6 +2891,11 @@ typedef enum Tox_Err_Conference_Join {
*/
TOX_ERR_CONFERENCE_JOIN_FAIL_SEND,
+ /**
+ * The cookie passed was NULL.
+ */
+ TOX_ERR_CONFERENCE_JOIN_NULL,
+
} Tox_Err_Conference_Join;
const char *tox_err_conference_join_to_string(Tox_Err_Conference_Join value);
@@ -2887,7 +2907,7 @@ const char *tox_err_conference_join_to_string(Tox_Err_Conference_Join value);
* to it until a handshaking procedure has been completed. A
* `conference_connected` event will then occur for the conference. The client
* will then remain connected to the conference until the conference is deleted,
- * even across core restarts. Many operations on a conference will fail with a
+ * even across Tox restarts. Many operations on a conference will fail with a
* corresponding error if attempted on a conference to which the client is not
* yet connected.
*
@@ -2995,9 +3015,11 @@ size_t tox_conference_get_title_size(
const Tox *tox, Tox_Conference_Number conference_number, Tox_Err_Conference_Title *error);
/**
- * @brief Write the title designated by the given conference number to a byte array.
+ * @brief Write the title designated by the given conference number to a byte
+ * array.
*
- * Call tox_conference_get_title_size to determine the allocation size for the `title` parameter.
+ * Call tox_conference_get_title_size to determine the allocation size for the
+ * `title` parameter.
*
* The data written to `title` is equal to the data received by the last
* `conference_title` callback.
@@ -3013,7 +3035,8 @@ bool tox_conference_get_title(
Tox_Err_Conference_Title *error);
/**
- * @brief Set the conference title and broadcast it to the rest of the conference.
+ * @brief Set the conference title and broadcast it to the rest of the
+ * conference.
*
* Title length cannot be longer than TOX_MAX_NAME_LENGTH.
*
@@ -3027,7 +3050,8 @@ bool tox_conference_set_title(
/**
* @brief Return the number of conferences in the Tox instance.
*
- * This should be used to determine how much memory to allocate for `tox_conference_get_chatlist`.
+ * This should be used to determine how much memory to allocate for
+ * `tox_conference_get_chatlist`.
*/
size_t tox_conference_get_chatlist_size(const Tox *tox);
@@ -3037,8 +3061,8 @@ size_t tox_conference_get_chatlist_size(const Tox *tox);
* Determine how much space to allocate for the array with the
* `tox_conference_get_chatlist_size` function.
*
- * Note that `tox_get_savedata` saves all connected conferences;
- * when toxcore is created from savedata in which conferences were saved, those
+ * Note that `tox_get_savedata` saves all connected conferences; when a Tox
+ * instance is created from savedata in which conferences were saved, those
* conferences will be connected at startup, and will be listed by
* `tox_conference_get_chatlist`.
*
@@ -3048,7 +3072,8 @@ size_t tox_conference_get_chatlist_size(const Tox *tox);
void tox_conference_get_chatlist(const Tox *tox, Tox_Conference_Number chatlist[]);
/**
- * @brief Returns the type of conference (Tox_Conference_Type) that conference_number is.
+ * @brief Returns the type of conference (Tox_Conference_Type) that
+ * conference_number is.
*
* Return value is unspecified on failure.
*/
@@ -3123,10 +3148,12 @@ Tox_Conference_Number tox_conference_by_id(
*
* If uid is NULL, this function has no effect.
*
- * @param uid A memory region large enough to store TOX_CONFERENCE_UID_SIZE bytes.
+ * @param uid A memory region large enough to store TOX_CONFERENCE_UID_SIZE
+ * bytes.
*
* @return true on success.
- * @deprecated use tox_conference_get_id instead (exactly the same function, just renamed).
+ * @deprecated use tox_conference_get_id instead (exactly the same function,
+ * just renamed).
*/
bool tox_conference_get_uid(
const Tox *tox, Tox_Conference_Number conference_number, uint8_t uid[TOX_CONFERENCE_UID_SIZE]);
@@ -3155,10 +3182,12 @@ const char *tox_err_conference_by_uid_to_string(Tox_Err_Conference_By_Uid value)
/**
* @brief Return the conference number associated with the specified uid.
*
- * @param uid A byte array containing the conference id (TOX_CONFERENCE_UID_SIZE).
+ * @param uid A byte array containing the conference id
+ * (TOX_CONFERENCE_UID_SIZE).
*
* @return the conference number on success, an unspecified value on failure.
- * @deprecated use tox_conference_by_id instead (exactly the same function, just renamed).
+ * @deprecated use tox_conference_by_id instead (exactly the same function,
+ * just renamed).
*/
Tox_Conference_Number tox_conference_by_uid(
const Tox *tox, const uint8_t uid[TOX_CONFERENCE_UID_SIZE], Tox_Err_Conference_By_Uid *error);
@@ -3192,8 +3221,9 @@ typedef enum Tox_Err_Friend_Custom_Packet {
TOX_ERR_FRIEND_CUSTOM_PACKET_FRIEND_NOT_CONNECTED,
/**
- * The first byte of data was not in the specified range for the packet type.
- * This range is 192-254 for lossy, and 69, 160-191 for lossless packets.
+ * The first byte of data was not one of the permitted values;
+ * for lossy packets the first byte must be in the range 192-254,
+ * and for lossless packets it must be either 69 or in the range 160-191.
*/
TOX_ERR_FRIEND_CUSTOM_PACKET_INVALID,
@@ -3244,7 +3274,7 @@ bool tox_friend_send_lossy_packet(
/**
* @brief Send a custom lossless packet to a friend.
*
- * The first byte of data must be in the range 69, 160-191. Maximum length of a
+ * The first byte of data must be either 69 or in the range 160-191. Maximum length of a
* custom packet is TOX_MAX_CUSTOM_PACKET_SIZE.
*
* Lossless packet behaviour is comparable to TCP (reliability, arrive in order)
@@ -3263,6 +3293,9 @@ bool tox_friend_send_lossless_packet(
Tox_Err_Friend_Custom_Packet *error);
/**
+ * tox_callback_friend_lossy_packet is the compatibility function to
+ * set the callback for all packet IDs except those reserved for ToxAV.
+ *
* @param friend_number The friend number of the friend who sent a lossy packet.
* @param data A byte array containing the received packet data.
* @param length The length of the packet data byte array.
@@ -3322,7 +3355,8 @@ const char *tox_err_get_port_to_string(Tox_Err_Get_Port value);
* @brief Writes the temporary DHT public key of this instance to a byte array.
*
* This can be used in combination with an externally accessible IP address and
- * the bound port (from tox_self_get_udp_port) to run a temporary bootstrap node.
+ * the bound port (from tox_self_get_udp_port) to run a temporary bootstrap
+ * node.
*
* Be aware that every time a new instance is created, the DHT public key
* changes, meaning this cannot be used to run a permanent bootstrap node.
@@ -3435,22 +3469,24 @@ uint32_t tox_group_peer_public_key_size(void);
typedef enum Tox_Group_Privacy_State {
/**
- * The group is considered to be public. Anyone may join the group using the Chat ID.
+ * The group is considered to be public. Anyone may join the group using
+ * the Chat ID.
*
- * If the group is in this state, even if the Chat ID is never explicitly shared
- * with someone outside of the group, information including the Chat ID, IP addresses,
- * and peer ID's (but not Tox ID's) is visible to anyone with access to a node
- * storing a DHT entry for the given group.
+ * If the group is in this state, even if the Chat ID is never explicitly
+ * shared with someone outside of the group, information including the Chat
+ * ID, IP addresses, and peer ID's (but not Tox ID's) is visible to anyone
+ * with access to a node storing a DHT entry for the given group.
*/
TOX_GROUP_PRIVACY_STATE_PUBLIC,
/**
- * The group is considered to be private. The only way to join the group is by having
- * someone in your contact list send you an invite.
+ * The group is considered to be private. The only way to join the group is
+ * by having someone in your contact list send you an invite.
*
- * If the group is in this state, no group information (mentioned above) is present in the DHT;
- * the DHT is not used for any purpose at all. If a public group is set to private,
- * all DHT information related to the group will expire shortly.
+ * If the group is in this state, no group information (mentioned above) is
+ * present in the DHT; the DHT is not used for any purpose at all. If a
+ * public group is set to private, all DHT information related to the group
+ * will expire shortly.
*/
TOX_GROUP_PRIVACY_STATE_PRIVATE,
@@ -3460,16 +3496,20 @@ const char *tox_group_privacy_state_to_string(Tox_Group_Privacy_State value);
/**
* Represents the state of the group topic lock.
+ *
+ * The default is enabled.
*/
typedef enum Tox_Group_Topic_Lock {
/**
- * The topic lock is enabled. Only peers with the founder and moderator roles may set the topic.
+ * The topic lock is enabled. Only peers with the founder and moderator
+ * roles may set the topic.
*/
TOX_GROUP_TOPIC_LOCK_ENABLED,
/**
- * The topic lock is disabled. All peers except those with the observer role may set the topic.
+ * The topic lock is disabled. All peers except those with the observer role
+ * may set the topic.
*/
TOX_GROUP_TOPIC_LOCK_DISABLED,
@@ -3478,8 +3518,9 @@ typedef enum Tox_Group_Topic_Lock {
const char *tox_group_topic_lock_to_string(Tox_Group_Topic_Lock value);
/**
- * Represents the group voice state, which determines which Group Roles have permission to speak
- * in the group chat. The voice state does not have any effect private messages or topic setting.
+ * Represents the group voice state, which determines which Group Roles have
+ * permission to speak in the group chat. The voice state does not have any
+ * effect private messages or topic setting.
*/
typedef enum Tox_Group_Voice_State {
/**
@@ -3503,14 +3544,15 @@ const char *tox_group_voice_state_to_string(Tox_Group_Voice_State value);
/**
* Represents group roles.
*
- * Roles are hierarchical in that each role has a set of privileges plus all the privileges
- * of the roles below it.
+ * Roles are hierarchical in that each role has a set of privileges plus all the
+ * privileges of the roles below it.
*/
typedef enum Tox_Group_Role {
/**
- * May kick all other peers as well as set their role to anything (except founder).
- * Founders may also set the group password, toggle the privacy state, and set the peer limit.
+ * May kick all other peers as well as set their role to anything (except
+ * founder). Founders may also set the group password, toggle the privacy
+ * state, and set the peer limit.
*/
TOX_GROUP_ROLE_FOUNDER,
@@ -3526,7 +3568,8 @@ typedef enum Tox_Group_Role {
TOX_GROUP_ROLE_USER,
/**
- * May observe the group and ignore peers; may not communicate with other peers or with the group.
+ * May observe the group and ignore peers; may not communicate with other
+ * peers or with the group.
*/
TOX_GROUP_ROLE_OBSERVER,
@@ -3548,7 +3591,8 @@ typedef enum Tox_Err_Group_New {
TOX_ERR_GROUP_NEW_OK,
/**
- * name exceeds TOX_MAX_NAME_LENGTH or group_name exceeded TOX_GROUP_MAX_GROUP_NAME_LENGTH.
+ * name exceeds TOX_MAX_NAME_LENGTH or group_name exceeded
+ * TOX_GROUP_MAX_GROUP_NAME_LENGTH.
*/
TOX_ERR_GROUP_NEW_TOO_LONG,
@@ -3563,13 +3607,14 @@ typedef enum Tox_Err_Group_New {
TOX_ERR_GROUP_NEW_INIT,
/**
- * The group state failed to initialize. This usually indicates that something went wrong
- * related to cryptographic signing.
+ * The group state failed to initialize. This usually indicates that
+ * something went wrong related to cryptographic signing.
*/
TOX_ERR_GROUP_NEW_STATE,
/**
- * The group failed to announce to the DHT. This indicates a network related error.
+ * The group failed to announce to the DHT. This indicates a network related
+ * error.
*/
TOX_ERR_GROUP_NEW_ANNOUNCE,
@@ -3584,18 +3629,19 @@ const char *tox_err_group_new_to_string(Tox_Err_Group_New value);
*
* The caller of this function has Founder role privileges.
*
- * The client should initiate its peer list with self info after calling this function, as
- * the peer_join callback will not be triggered.
+ * The client should initiate its peer list with self info after calling this
+ * function, as the peer_join callback will not be triggered.
*
- * @param privacy_state The privacy state of the group. If this is set to TOX_GROUP_PRIVACY_STATE_PUBLIC,
- * the group will attempt to announce itself to the DHT and anyone with the Chat ID may join.
- * Otherwise a friend invite will be required to join the group.
+ * @param privacy_state The privacy state of the group. If this is set to
+ * TOX_GROUP_PRIVACY_STATE_PUBLIC, the group will attempt to announce itself
+ * to the DHT and anyone with the Chat ID may join. Otherwise a friend invite
+ * will be required to join the group.
* @param group_name The name of the group. The name must be non-NULL.
- * @param group_name_length The length of the group name. This must be greater than zero and no larger than
- * TOX_GROUP_MAX_GROUP_NAME_LENGTH.
+ * @param group_name_length The length of the group name. This must be greater
+ * than zero and no larger than TOX_GROUP_MAX_GROUP_NAME_LENGTH.
* @param name The name of the peer creating the group.
- * @param name_length The length of the peer's name. This must be greater than zero and no larger
- * than TOX_MAX_NAME_LENGTH.
+ * @param name_length The length of the peer's name. This must be greater than
+ * zero and no larger than TOX_MAX_NAME_LENGTH.
*
* @return group_number on success, UINT32_MAX on failure.
*/
@@ -3617,8 +3663,9 @@ typedef enum Tox_Err_Group_Join {
TOX_ERR_GROUP_JOIN_INIT,
/**
- * The chat_id pointer is set to NULL or a group with chat_id already exists. This usually
- * happens if the client attempts to create multiple sessions for the same group.
+ * The chat_id pointer is set to NULL or a group with chat_id already
+ * exists. This usually happens if the client attempts to create multiple
+ * sessions for the same group.
*/
TOX_ERR_GROUP_JOIN_BAD_CHAT_ID,
@@ -3633,7 +3680,8 @@ typedef enum Tox_Err_Group_Join {
TOX_ERR_GROUP_JOIN_TOO_LONG,
/**
- * Failed to set password. This usually occurs if the password exceeds TOX_GROUP_MAX_PASSWORD_SIZE.
+ * Failed to set password. This usually occurs if the password exceeds
+ * TOX_GROUP_MAX_PASSWORD_SIZE.
*/
TOX_ERR_GROUP_JOIN_PASSWORD,
@@ -3649,17 +3697,20 @@ const char *tox_err_group_join_to_string(Tox_Err_Group_Join value);
/**
* Joins a group chat with specified Chat ID.
*
- * This function creates a new group chat object, adds it to the chats array, and sends
- * a DHT announcement to find peers in the group associated with chat_id. Once a peer has been
- * found a join attempt will be initiated.
- *
- * @param chat_id The Chat ID of the group you wish to join. This must be TOX_GROUP_CHAT_ID_SIZE bytes.
- * @param password The password required to join the group. Set to NULL if no password is required.
- * @param password_length The length of the password. If length is equal to zero,
- * the password parameter is ignored. length must be no larger than TOX_GROUP_MAX_PASSWORD_SIZE.
+ * This function creates a new group chat object, adds it to the chats array,
+ * and sends a DHT announcement to find peers in the group associated with
+ * chat_id. Once a peer has been found a join attempt will be initiated.
+ *
+ * @param chat_id The Chat ID of the group you wish to join. This must be
+ * TOX_GROUP_CHAT_ID_SIZE bytes.
+ * @param password The password required to join the group. Set to NULL if no
+ * password is required.
+ * @param password_length The length of the password. If length is equal to
+ * zero, the password parameter is ignored. length must be no larger than
+ * TOX_GROUP_MAX_PASSWORD_SIZE.
* @param name The name of the peer joining the group.
- * @param name_length The length of the peer's name. This must be greater than zero and no larger
- * than TOX_MAX_NAME_LENGTH.
+ * @param name_length The length of the peer's name. This must be greater than
+ * zero and no larger than TOX_MAX_NAME_LENGTH.
*
* @return group_number on success, UINT32_MAX on failure.
*/
@@ -3686,8 +3737,8 @@ typedef enum Tox_Err_Group_Is_Connected {
const char *tox_err_group_is_connected_to_string(Tox_Err_Group_Is_Connected value);
/**
- * Returns true if the group chat is currently connected or attempting to connect to other peers
- * in the group.
+ * Returns true if the group chat is currently connected or attempting to
+ * connect to other peers in the group.
*
* @param group_number The group number of the designated group.
*/
@@ -3714,7 +3765,8 @@ typedef enum Tox_Err_Group_Disconnect {
const char *tox_err_group_disconnect_to_string(Tox_Err_Group_Disconnect value);
/**
- * Disconnects from a group chat while retaining the group state and credentials.
+ * Disconnects from a group chat while retaining the group state and
+ * credentials.
*
* Returns true if we successfully disconnect from the group.
*
@@ -3746,8 +3798,9 @@ const char *tox_err_group_reconnect_to_string(Tox_Err_Group_Reconnect value);
/**
* Reconnects to a group.
*
- * This function disconnects from all peers in the group, then attempts to reconnect with the group.
- * The caller's state is not changed (i.e. name, status, role, chat public key etc.).
+ * This function disconnects from all peers in the group, then attempts to
+ * reconnect with the group. The caller's state is not changed (i.e. name,
+ * status, role, chat public key etc.).
*
* @param group_number The group number of the group we wish to reconnect to.
*
@@ -3783,14 +3836,16 @@ const char *tox_err_group_leave_to_string(Tox_Err_Group_Leave value);
/**
* Leaves a group.
*
- * This function sends a parting packet containing a custom (non-obligatory) message to all
- * peers in a group, and deletes the group from the chat array. All group state information is permanently
- * lost, including keys and role credentials.
+ * This function sends a parting packet containing a custom (non-obligatory)
+ * message to all peers in a group, and deletes the group from the chat array.
+ * All group state information is permanently lost, including keys and role
+ * credentials.
*
* @param group_number The group number of the group we wish to leave.
- * @param part_message The parting message to be sent to all the peers. Set to NULL if we do not wish to
- * send a parting message.
- * @param length The length of the parting message. Set to 0 if we do not wish to send a parting message.
+ * @param part_message The parting message to be sent to all the peers. Set to
+ * NULL if we do not wish to send a parting message.
+ * @param length The length of the parting message. Set to 0 if we do not wish
+ * to send a parting message.
*
* @return true if the group chat instance is successfully deleted.
*/
@@ -3859,10 +3914,11 @@ typedef enum Tox_Err_Group_Self_Name_Set {
const char *tox_err_group_self_name_set_to_string(Tox_Err_Group_Self_Name_Set value);
/**
- * Set the client's nickname for the group instance designated by the given group number.
+ * Set the client's nickname for the group instance designated by the given
+ * group number.
*
- * Nickname length cannot exceed TOX_MAX_NAME_LENGTH. If length is equal to zero or name is a NULL
- * pointer, the function call will fail.
+ * Nickname length cannot exceed TOX_MAX_NAME_LENGTH. If length is equal to
+ * zero or name is a NULL pointer, the function call will fail.
*
* @param name A byte array containing the new nickname.
* @param length The size of the name byte array.
@@ -3875,8 +3931,8 @@ bool tox_group_self_set_name(
Tox_Err_Group_Self_Name_Set *error);
/**
- * Return the length of the client's current nickname for the group instance designated
- * by group_number as passed to tox_group_self_set_name.
+ * Return the length of the client's current nickname for the group instance
+ * designated by group_number as passed to tox_group_self_set_name.
*
* If no nickname was set before calling this function, the name is empty,
* and this function returns 0.
@@ -3891,7 +3947,8 @@ size_t tox_group_self_get_name_size(const Tox *tox, Tox_Group_Number group_numbe
* If no nickname was set before calling this function, the name is empty,
* and this function has no effect.
*
- * Call tox_group_self_get_name_size to find out how much memory to allocate for the result.
+ * Call tox_group_self_get_name_size to find out how much memory to allocate for
+ * the result.
*
* @param name A valid memory location large enough to hold the nickname.
* If this parameter is NULL, the function has no effect.
@@ -3927,7 +3984,8 @@ typedef enum Tox_Err_Group_Self_Status_Set {
const char *tox_err_group_self_status_set_to_string(Tox_Err_Group_Self_Status_Set value);
/**
- * Set the client's status for the group instance. Status must be a Tox_User_Status.
+ * Set the client's status for the group instance. Status must be a
+ * Tox_User_Status.
*
* @return true on success.
*/
@@ -3953,13 +4011,16 @@ Tox_Group_Role tox_group_self_get_role(const Tox *tox, Tox_Group_Number group_nu
Tox_Group_Peer_Number tox_group_self_get_peer_id(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Self_Query *error);
/**
- * Write the client's group public key designated by the given group number to a byte array.
+ * Write the client's group public key designated by the given group number to
+ * a byte array.
*
- * This key will be permanently tied to the client's identity for this particular group until
- * the client explicitly leaves the group. This key is the only way for other peers to reliably
- * identify the client across client restarts.
+ * This key will be permanently tied to the client's identity for this
+ * particular group until the client explicitly leaves the group. This key is
+ * the only way for other peers to reliably identify the client across client
+ * restarts.
*
- * `public_key` should have room for at least TOX_GROUP_PEER_PUBLIC_KEY_SIZE bytes.
+ * `public_key` should have room for at least TOX_GROUP_PEER_PUBLIC_KEY_SIZE
+ * bytes.
*
* @param public_key A valid memory region large enough to store the public key.
* If this parameter is NULL, this function call has no effect.
@@ -4000,8 +4061,8 @@ typedef enum Tox_Err_Group_Peer_Query {
const char *tox_err_group_peer_query_to_string(Tox_Err_Group_Peer_Query value);
/**
- * Return the length of the peer's name. If the group number or ID is invalid, the
- * return value is unspecified.
+ * Return the length of the peer's name. If the group number or ID is invalid,
+ * the return value is unspecified.
*
* @param group_number The group number of the group we wish to query.
* @param peer_id The ID of the peer whose name length we want to retrieve.
@@ -4016,7 +4077,8 @@ size_t tox_group_peer_get_name_size(const Tox *tox, Tox_Group_Number group_numbe
* Write the name of the peer designated by the given ID to a byte
* array.
*
- * Call tox_group_peer_get_name_size to determine the allocation size for the `name` parameter.
+ * Call tox_group_peer_get_name_size to determine the allocation size for the
+ * `name` parameter.
*
* The data written to `name` is equal to the data received by the last
* `group_peer_name` callback.
@@ -4045,8 +4107,8 @@ Tox_User_Status tox_group_peer_get_status(const Tox *tox, Tox_Group_Number group
Tox_Err_Group_Peer_Query *error);
/**
- * Return the peer's role (user/moderator/founder...). If the ID or group number is
- * invalid, the return value is unspecified.
+ * Return the peer's role (user/moderator/founder...). If the ID or group number
+ * is invalid, the return value is unspecified.
*
* @param group_number The group number of the group we wish to query.
* @param peer_id The ID of the peer whose role we wish to query.
@@ -4060,8 +4122,9 @@ Tox_Group_Role tox_group_peer_get_role(const Tox *tox, Tox_Group_Number group_nu
/**
* Return the type of connection we have established with a peer.
*
- * If `peer_id` designates ourself, the return value indicates whether we're capable
- * of making UDP connections with other peers, or are limited to TCP connections.
+ * If `peer_id` designates ourself, the return value indicates whether we're
+ * capable of making UDP connections with other peers, or are limited to TCP
+ * connections.
*
* @param group_number The group number of the group we wish to query.
* @param peer_id The ID of the peer whose connection status we wish to query.
@@ -4070,13 +4133,15 @@ Tox_Connection tox_group_peer_get_connection_status(const Tox *tox, Tox_Group_Nu
Tox_Err_Group_Peer_Query *error);
/**
- * Write the group public key with the designated peer_id for the designated group number to public_key.
+ * Write the group public key with the designated peer_id for the designated
+ * group number to public_key.
*
- * This key will be permanently tied to a particular peer until they explicitly leave the group and is
- * the only way to reliably identify the same peer across client restarts.
+ * This key will be permanently tied to a particular peer until they explicitly
+ * leave the group and is the only way to reliably identify the same peer across
+ * client restarts.
*
- * `public_key` should have room for at least TOX_GROUP_PEER_PUBLIC_KEY_SIZE bytes. If `public_key` is null
- * this function has no effect.
+ * `public_key` should have room for at least TOX_GROUP_PEER_PUBLIC_KEY_SIZE
+ * bytes. If `public_key` is NULL this function has no effect.
*
* @param group_number The group number of the group we wish to query.
* @param peer_id The ID of the peer whose public key we wish to retrieve.
@@ -4090,14 +4155,15 @@ bool tox_group_peer_get_public_key(
uint8_t public_key[TOX_PUBLIC_KEY_SIZE], Tox_Err_Group_Peer_Query *error);
/**
- * @param group_number The group number of the group the name change is intended for.
+ * @param group_number The group number of the group the name change is intended
+ * for.
* @param peer_id The ID of the peer who has changed their name.
* @param name The name data.
- * @param length The length of the name.
+ * @param name_length The length of the name.
*/
typedef void tox_group_peer_name_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
- const uint8_t name[], size_t length, void *user_data);
+ const uint8_t name[], size_t name_length, void *user_data);
/**
* Set the callback for the `group_peer_name` event. Pass NULL to unset.
@@ -4107,7 +4173,8 @@ typedef void tox_group_peer_name_cb(
void tox_callback_group_peer_name(Tox *tox, tox_group_peer_name_cb *callback);
/**
- * @param group_number The group number of the group the status change is intended for.
+ * @param group_number The group number of the group the status change is
+ * intended for.
* @param peer_id The ID of the peer who has changed their status.
* @param status The new status of the peer.
*/
@@ -4130,21 +4197,21 @@ void tox_callback_group_peer_status(Tox *tox, tox_group_peer_status_cb *callback
/**
* General error codes for group state get and size functions.
*/
-typedef enum Tox_Err_Group_State_Queries {
+typedef enum Tox_Err_Group_State_Query {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_STATE_QUERIES_OK,
+ TOX_ERR_GROUP_STATE_QUERY_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND,
-} Tox_Err_Group_State_Queries;
+} Tox_Err_Group_State_Query;
-const char *tox_err_group_state_queries_to_string(Tox_Err_Group_State_Queries value);
+const char *tox_err_group_state_query_to_string(Tox_Err_Group_State_Query value);
/**
* Error codes for group topic setting.
@@ -4172,7 +4239,8 @@ typedef enum Tox_Err_Group_Topic_Set {
TOX_ERR_GROUP_TOPIC_SET_PERMISSIONS,
/**
- * The packet could not be created. This error is usually related to cryptographic signing.
+ * The packet could not be created. This error is usually related to
+ * cryptographic signing.
*/
TOX_ERR_GROUP_TOPIC_SET_FAIL_CREATE,
@@ -4193,8 +4261,8 @@ const char *tox_err_group_topic_set_to_string(Tox_Err_Group_Topic_Set value);
/**
* Set the group topic and broadcast it to the rest of the group.
*
- * topic length cannot be longer than TOX_GROUP_MAX_TOPIC_LENGTH. If length is equal to zero or
- * topic is set to NULL, the topic will be unset.
+ * Topic length cannot be longer than TOX_GROUP_MAX_TOPIC_LENGTH. If the length
+ * is equal to zero or topic is set to NULL, the topic will be unset.
*
* @return true on success.
*/
@@ -4210,12 +4278,13 @@ bool tox_group_set_topic(
* The return value is equal to the `length` argument received by the last
* `group_topic` callback.
*/
-size_t tox_group_get_topic_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Queries *error);
+size_t tox_group_get_topic_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Query *error);
/**
* Write the topic designated by the given group number to a byte array.
*
- * Call tox_group_get_topic_size to determine the allocation size for the `topic` parameter.
+ * Call tox_group_get_topic_size to determine the allocation size for the
+ * `topic` parameter.
*
* The data written to `topic` is equal to the data received by the last
* `group_topic` callback.
@@ -4227,18 +4296,19 @@ size_t tox_group_get_topic_size(const Tox *tox, Tox_Group_Number group_number, T
*/
bool tox_group_get_topic(
const Tox *tox, Tox_Group_Number group_number,
- uint8_t topic[], Tox_Err_Group_State_Queries *error);
+ uint8_t topic[], Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group the topic change is intended for.
- * @param peer_id The ID of the peer who changed the topic. If the peer who set the topic
- * is not present in our peer list this value will be set to 0.
+ * @param group_number The group number of the group the topic change is
+ * intended for.
+ * @param peer_id The ID of the peer who changed the topic. If the peer who set
+ * the topic is not present in our peer list this value will be set to 0.
* @param topic The topic data.
- * @param length The topic length.
+ * @param topic_length The topic length.
*/
typedef void tox_group_topic_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
- const uint8_t topic[], size_t length,
+ const uint8_t topic[], size_t topic_length,
void *user_data);
/**
@@ -4252,12 +4322,14 @@ void tox_callback_group_topic(Tox *tox, tox_group_topic_cb *callback);
* Return the length of the group name. If the group number is invalid, the
* return value is unspecified.
*/
-size_t tox_group_get_name_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Queries *error);
+size_t tox_group_get_name_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Query *error);
/**
- * Write the name of the group designated by the given group number to a byte array.
+ * Write the name of the group designated by the given group number to a byte
+ * array.
*
- * Call tox_group_get_name_size to determine the allocation size for the `name` parameter.
+ * Call tox_group_get_name_size to determine the allocation size for the `name`
+ * parameter.
*
* @param name A valid memory region large enough to store the group name.
* If this parameter is NULL, this function call has no effect.
@@ -4266,7 +4338,7 @@ size_t tox_group_get_name_size(const Tox *tox, Tox_Group_Number group_number, To
*/
bool tox_group_get_name(
const Tox *tox, Tox_Group_Number group_number,
- uint8_t name[], Tox_Err_Group_State_Queries *error);
+ uint8_t name[], Tox_Err_Group_State_Query *error);
/**
* Write the Chat ID designated by the given group number to a byte array.
@@ -4280,7 +4352,7 @@ bool tox_group_get_name(
*/
bool tox_group_get_chat_id(
const Tox *tox, Tox_Group_Number group_number, uint8_t chat_id[TOX_GROUP_CHAT_ID_SIZE],
- Tox_Err_Group_State_Queries *error);
+ Tox_Err_Group_State_Query *error);
/**
* Return the number of groups in the Tox chats array.
@@ -4288,19 +4360,21 @@ bool tox_group_get_chat_id(
uint32_t tox_group_get_number_groups(const Tox *tox);
/**
- * Return the privacy state of the group designated by the given group number. If group number
- * is invalid, the return value is unspecified.
+ * Return the privacy state of the group designated by the given group number.
+ * If group number is invalid, the return value is unspecified.
*
* The value returned is equal to the data received by the last
* `group_privacy_state` callback.
*
- * @see the `Group chat founder controls` section for the respective set function.
+ * @see the `Group chat Founder controls` section for the respective set
+ * function.
*/
Tox_Group_Privacy_State tox_group_get_privacy_state(const Tox *tox, Tox_Group_Number group_number,
- Tox_Err_Group_State_Queries *error);
+ Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group the privacy state is intended for.
+ * @param group_number The group number of the group the privacy state is
+ * intended for.
* @param privacy_state The new privacy state.
*/
typedef void tox_group_privacy_state_cb(Tox *tox, Tox_Group_Number group_number, Tox_Group_Privacy_State privacy_state,
@@ -4314,18 +4388,21 @@ typedef void tox_group_privacy_state_cb(Tox *tox, Tox_Group_Number group_number,
void tox_callback_group_privacy_state(Tox *tox, tox_group_privacy_state_cb *callback);
/**
- * Return the voice state of the group designated by the given group number. If group number
- * is invalid, the return value is unspecified.
+ * Return the voice state of the group designated by the given group number. If
+ * group number is invalid, the return value is unspecified.
*
- * The value returned is equal to the data received by the last `group_voice_state` callback.
+ * The value returned is equal to the data received by the last
+ * `group_voice_state` callback.
*
- * @see the `Group chat founder controls` section for the respective set function.
+ * @see the `Group chat Founder controls` section for the respective set
+ * function.
*/
Tox_Group_Voice_State tox_group_get_voice_state(const Tox *tox, Tox_Group_Number group_number,
- Tox_Err_Group_State_Queries *error);
+ Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group the voice state change is intended for.
+ * @param group_number The group number of the group the voice state change is
+ * intended for.
* @param voice_state The new voice state.
*/
typedef void tox_group_voice_state_cb(Tox *tox, Tox_Group_Number group_number, Tox_Group_Voice_State voice_state,
@@ -4339,19 +4416,22 @@ typedef void tox_group_voice_state_cb(Tox *tox, Tox_Group_Number group_number, T
void tox_callback_group_voice_state(Tox *tox, tox_group_voice_state_cb *callback);
/**
- * Return the topic lock status of the group designated by the given group number. If group number
+ * Return the topic lock status of the group designated by the given group
+ * number. If group number
* is invalid, the return value is unspecified.
*
* The value returned is equal to the data received by the last
* `group_topic_lock` callback.
*
- * @see the `Group chat founder contols` section for the respective set function.
+ * @see the `Group chat Founder controls` section for the respective set
+ * function.
*/
Tox_Group_Topic_Lock tox_group_get_topic_lock(const Tox *tox, Tox_Group_Number group_number,
- Tox_Err_Group_State_Queries *error);
+ Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group for which the topic lock has changed.
+ * @param group_number The group number of the group for which the topic lock
+ * has changed.
* @param topic_lock The new topic lock state.
*/
typedef void tox_group_topic_lock_cb(Tox *tox, Tox_Group_Number group_number, Tox_Group_Topic_Lock topic_lock, void *user_data);
@@ -4364,18 +4444,21 @@ typedef void tox_group_topic_lock_cb(Tox *tox, Tox_Group_Number group_number, To
void tox_callback_group_topic_lock(Tox *tox, tox_group_topic_lock_cb *callback);
/**
- * Return the maximum number of peers allowed for the group designated by the given group number.
- * If the group number is invalid, the return value is unspecified.
+ * Return the maximum number of peers allowed for the group designated by the
+ * given group number. If the group number is invalid, the return value is
+ * unspecified.
*
* The value returned is equal to the data received by the last
* `group_peer_limit` callback.
*
- * @see the `Group chat founder controls` section for the respective set function.
+ * @see the `Group chat Founder controls` section for the respective set
+ * function.
*/
-uint16_t tox_group_get_peer_limit(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Queries *error);
+uint16_t tox_group_get_peer_limit(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group for which the peer limit has changed.
+ * @param group_number The group number of the group for which the peer limit
+ * has changed.
* @param peer_limit The new peer limit for the group.
*/
typedef void tox_group_peer_limit_cb(Tox *tox, Tox_Group_Number group_number, uint32_t peer_limit, void *user_data);
@@ -4383,7 +4466,8 @@ typedef void tox_group_peer_limit_cb(Tox *tox, Tox_Group_Number group_number, ui
/**
* Set the callback for the `group_peer_limit` event. Pass NULL to unset.
*
- * This event is triggered when the group founder changes the maximum peer limit.
+ * This event is triggered when the group founder changes the maximum peer
+ * limit.
*/
void tox_callback_group_peer_limit(Tox *tox, tox_group_peer_limit_cb *callback);
@@ -4391,35 +4475,39 @@ void tox_callback_group_peer_limit(Tox *tox, tox_group_peer_limit_cb *callback);
* Return the length of the group password. If the group number is invalid, the
* return value is unspecified.
*/
-size_t tox_group_get_password_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Queries *error);
+size_t tox_group_get_password_size(const Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_State_Query *error);
/**
- * Write the password for the group designated by the given group number to a byte array.
+ * Write the password for the group designated by the given group number to a
+ * byte array.
*
- * Call tox_group_get_password_size to determine the allocation size for the `password` parameter.
+ * Call tox_group_get_password_size to determine the allocation size for the
+ * `password` parameter.
*
- * The data received is equal to the data received by the last
- * `group_password` callback.
+ * The data received is equal to the data received by the last `group_password`
+ * callback.
*
- * @see the `Group chat founder controls` section for the respective set function.
+ * @see the `Group chat Founder controls` section for the respective set
+ * function.
*
- * @param password A valid memory region large enough to store the group password.
- * If this parameter is NULL, this function call has no effect.
+ * @param password A valid memory region large enough to store the group
+ * password. If this parameter is NULL, this function call has no effect.
*
* @return true on success.
*/
bool tox_group_get_password(
const Tox *tox, Tox_Group_Number group_number, uint8_t password[],
- Tox_Err_Group_State_Queries *error);
+ Tox_Err_Group_State_Query *error);
/**
- * @param group_number The group number of the group for which the password has changed.
+ * @param group_number The group number of the group for which the password has
+ * changed.
* @param password The new group password.
- * @param length The length of the password.
+ * @param password_length The length of the password.
*/
typedef void tox_group_password_cb(
Tox *tox, Tox_Group_Number group_number,
- const uint8_t password[], size_t length,
+ const uint8_t password[], size_t password_length,
void *user_data);
/**
@@ -4453,7 +4541,7 @@ typedef enum Tox_Err_Group_Send_Message {
TOX_ERR_GROUP_SEND_MESSAGE_TOO_LONG,
/**
- * The message pointer is null or length is zero.
+ * The message pointer is NULL or length is zero.
*/
TOX_ERR_GROUP_SEND_MESSAGE_EMPTY,
@@ -4487,12 +4575,13 @@ const char *tox_err_group_send_message_to_string(Tox_Err_Group_Send_Message valu
* This function creates a group message packet and pushes it into the send
* queue.
*
- * The message length may not exceed TOX_GROUP_MAX_MESSAGE_LENGTH. Larger messages
- * must be split by the client and sent as separate messages. Other clients can
- * then reassemble the fragments. Messages may not be empty.
+ * The message length may not exceed TOX_GROUP_MAX_MESSAGE_LENGTH. Larger
+ * messages must be split by the client and sent as separate messages. Other
+ * clients can then reassemble the fragments. Messages may not be empty.
*
- * @param group_number The group number of the group the message is intended for.
- * @param type Message type (normal, action, ...).
+ * @param group_number The group number of the group the message is intended
+ * for.
+ * @param message_type Message type (normal, action, ...).
* @param message A non-NULL pointer to the first element of a byte array
* containing the message text.
* @param length Length of the message to be sent.
@@ -4501,7 +4590,7 @@ const char *tox_err_group_send_message_to_string(Tox_Err_Group_Send_Message valu
* returned message ID value will be undefined.
*/
Tox_Group_Message_Id tox_group_send_message(
- const Tox *tox, Tox_Group_Number group_number, Tox_Message_Type type,
+ const Tox *tox, Tox_Group_Number group_number, Tox_Message_Type message_type,
const uint8_t message[], size_t length,
Tox_Err_Group_Send_Message *error);
@@ -4528,11 +4617,16 @@ typedef enum Tox_Err_Group_Send_Private_Message {
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_TOO_LONG,
/**
- * The message pointer is null or length is zero.
+ * The message pointer is NULL or length is zero.
*/
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY,
/**
+ * The message type is invalid.
+ */
+ TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE,
+
+ /**
* The caller does not have the required permissions to send group messages.
*/
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS,
@@ -4547,11 +4641,6 @@ typedef enum Tox_Err_Group_Send_Private_Message {
*/
TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED,
- /**
- * The message type is invalid.
- */
- TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE,
-
} Tox_Err_Group_Send_Private_Message;
const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Private_Message value);
@@ -4559,23 +4648,25 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
/**
* Send a text chat message to the specified peer in the specified group.
*
- * This function creates a group private message packet and pushes it into the send
- * queue.
+ * This function creates a group private message packet and pushes it into the
+ * send queue.
*
- * The message length may not exceed TOX_GROUP_MAX_MESSAGE_LENGTH. Larger messages
- * must be split by the client and sent as separate messages. Other clients can
- * then reassemble the fragments. Messages may not be empty.
+ * The message length may not exceed TOX_GROUP_MAX_MESSAGE_LENGTH. Larger
+ * messages must be split by the client and sent as separate messages. Other
+ * clients can then reassemble the fragments. Messages may not be empty.
*
- * @param group_number The group number of the group the message is intended for.
+ * @param group_number The group number of the group the message is intended
+ * for.
* @param peer_id The ID of the peer the message is intended for.
+ * @param message_type The type of message (normal, action, ...).
* @param message A non-NULL pointer to the first element of a byte array
* containing the message text.
* @param length Length of the message to be sent.
*
* @return true on success.
*/
-bool tox_group_send_private_message(
- const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type,
+Tox_Group_Message_Id tox_group_send_private_message(
+ const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
const uint8_t message[], size_t length,
Tox_Err_Group_Send_Private_Message *error);
@@ -4599,16 +4690,11 @@ typedef enum Tox_Err_Group_Send_Custom_Packet {
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_TOO_LONG,
/**
- * The message pointer is null or length is zero.
+ * The message pointer is NULL or length is zero.
*/
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_EMPTY,
/**
- * The caller does not have the required permissions to send group messages.
- */
- TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS,
-
- /**
* The group is disconnected.
*/
TOX_ERR_GROUP_SEND_CUSTOM_PACKET_DISCONNECTED,
@@ -4626,15 +4712,17 @@ const char *tox_err_group_send_custom_packet_to_string(Tox_Err_Group_Send_Custom
/**
* Send a custom packet to the group.
*
- * If lossless is true the packet will be lossless. Lossless packet behaviour is comparable
- * to TCP (reliability, arrive in order) but with packets instead of a stream.
+ * If lossless is true the packet will be lossless. Lossless packet behaviour is
+ * comparable to TCP (reliability, arrive in order) but with packets instead of
+ * a stream.
*
- * If lossless is false, the packet will be lossy. Lossy packets behave like UDP packets,
- * meaning they might never reach the other side or might arrive more than once (if someone
- * is messing with the connection) or might arrive in the wrong order.
+ * If lossless is false, the packet will be lossy. Lossy packets behave like UDP
+ * packets, meaning they might never reach the other side or might arrive more
+ * than once (if someone is messing with the connection) or might arrive in the
+ * wrong order.
*
- * Unless latency is an issue or message reliability is not important, it is recommended that you use
- * lossless packets.
+ * Unless latency is an issue or message reliability is not important, it is
+ * recommended that you use lossless packets.
*
* The message length may not exceed TOX_MAX_CUSTOM_PACKET_SIZE. Larger packets
* must be split by the client and sent as separate packets. Other clients can
@@ -4672,7 +4760,7 @@ typedef enum Tox_Err_Group_Send_Custom_Private_Packet {
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_TOO_LONG,
/**
- * The message pointer is null or length is zero.
+ * The message pointer is NULL or length is zero.
*/
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_EMPTY,
@@ -4682,11 +4770,6 @@ typedef enum Tox_Err_Group_Send_Custom_Private_Packet {
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PEER_NOT_FOUND,
/**
- * The caller does not have the required permissions to send group messages.
- */
- TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS,
-
- /**
* The packet failed to send.
*/
TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND,
@@ -4703,15 +4786,17 @@ const char *tox_err_group_send_custom_private_packet_to_string(Tox_Err_Group_Sen
/**
* Send a custom private packet to a designated peer in the group.
*
- * If lossless is true the packet will be lossless. Lossless packet behaviour is comparable
- * to TCP (reliability, arrive in order) but with packets instead of a stream.
+ * If lossless is true the packet will be lossless. Lossless packet behaviour is
+ * comparable to TCP (reliability, arrive in order) but with packets instead of
+ * a stream.
*
- * If lossless is false, the packet will be lossy. Lossy packets behave like UDP packets,
- * meaning they might never reach the other side or might arrive more than once (if someone
- * is messing with the connection) or might arrive in the wrong order.
+ * If lossless is false, the packet will be lossy. Lossy packets behave like UDP
+ * packets, meaning they might never reach the other side or might arrive more
+ * than once (if someone is messing with the connection) or might arrive in the
+ * wrong order.
*
- * Unless latency is an issue or message reliability is not important, it is recommended that you use
- * lossless packets.
+ * Unless latency is an issue or message reliability is not important, it is
+ * recommended that you use lossless packets.
*
* The packet length may not exceed TOX_MAX_CUSTOM_PACKET_SIZE. Larger packets
* must be split by the client and sent as separate packets. Other clients can
@@ -4736,16 +4821,18 @@ bool tox_group_send_custom_private_packet(const Tox *tox, Tox_Group_Number group
******************************************************************************/
/**
- * @param group_number The group number of the group the message is intended for.
+ * @param group_number The group number of the group the message is intended
+ * for.
* @param peer_id The ID of the peer who sent the message.
- * @param type The type of message (normal, action, ...).
+ * @param message_type The type of message (normal, action, ...).
* @param message The message data.
- * @param message_id A pseudo message id that clients can use to uniquely identify this group message.
- * @param length The length of the message.
+ * @param message_length The length of the message.
+ * @param message_id A pseudo message id that clients can use to uniquely
+ * identify this group message.
*/
typedef void tox_group_message_cb(
- Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type,
- const uint8_t message[], size_t length, Tox_Group_Message_Id message_id, void *user_data);
+ Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
+ const uint8_t message[], size_t message_length, Tox_Group_Message_Id message_id, void *user_data);
/**
* Set the callback for the `group_message` event. Pass NULL to unset.
@@ -4755,14 +4842,18 @@ typedef void tox_group_message_cb(
void tox_callback_group_message(Tox *tox, tox_group_message_cb *callback);
/**
- * @param group_number The group number of the group the private message is intended for.
+ * @param group_number The group number of the group the private message is
+ * intended for.
* @param peer_id The ID of the peer who sent the private message.
+ * @param message_type The type of message (normal, action, ...).
* @param message The message data.
- * @param length The length of the message.
+ * @param message_length The length of the message.
+ * @param message_id A pseudo message id that clients can use to uniquely
+ * identify this group message.
*/
typedef void tox_group_private_message_cb(
- Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type type,
- const uint8_t message[], size_t length, void *user_data);
+ Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Message_Type message_type,
+ const uint8_t message[], size_t message_length, Tox_Group_Message_Id message_id, void *user_data);
/**
* Set the callback for the `group_private_message` event. Pass NULL to unset.
@@ -4775,11 +4866,11 @@ void tox_callback_group_private_message(Tox *tox, tox_group_private_message_cb *
* @param group_number The group number of the group the packet is intended for.
* @param peer_id The ID of the peer who sent the packet.
* @param data The packet data.
- * @param length The length of the data.
+ * @param data_length The length of the data.
*/
typedef void tox_group_custom_packet_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
- const uint8_t data[], size_t length, void *user_data);
+ const uint8_t data[], size_t data_length, void *user_data);
/**
* Set the callback for the `group_custom_packet` event. Pass NULL to unset.
@@ -4792,14 +4883,15 @@ void tox_callback_group_custom_packet(Tox *tox, tox_group_custom_packet_cb *call
* @param group_number The group number of the group the packet is intended for.
* @param peer_id The ID of the peer who sent the packet.
* @param data The packet data.
- * @param length The length of the data.
+ * @param data_length The length of the data.
*/
typedef void tox_group_custom_private_packet_cb(
Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
- const uint8_t data[], size_t length, void *user_data);
+ const uint8_t data[], size_t data_length, void *user_data);
/**
- * Set the callback for the `group_custom_private_packet` event. Pass NULL to unset.
+ * Set the callback for the `group_custom_private_packet` event. Pass NULL to
+ * unset.
*
* This event is triggered when the client receives a custom private packet.
*/
@@ -4829,7 +4921,8 @@ typedef enum Tox_Err_Group_Invite_Friend {
TOX_ERR_GROUP_INVITE_FRIEND_FRIEND_NOT_FOUND,
/**
- * Creation of the invite packet failed. This indicates a network related error.
+ * Creation of the invite packet failed. This indicates a network related
+ * error.
*/
TOX_ERR_GROUP_INVITE_FRIEND_INVITE_FAIL,
@@ -4850,10 +4943,13 @@ const char *tox_err_group_invite_friend_to_string(Tox_Err_Group_Invite_Friend va
/**
* Invite a friend to a group.
*
- * This function creates an invite request packet and pushes it to the send queue.
+ * This function creates an invite request packet and pushes it to the send
+ * queue.
*
- * @param group_number The group number of the group the message is intended for.
- * @param friend_number The friend number of the friend the invite is intended for.
+ * @param group_number The group number of the group the message is intended
+ * for.
+ * @param friend_number The friend number of the friend the invite is intended
+ * for.
*
* @return true on success.
*/
@@ -4889,36 +4985,44 @@ typedef enum Tox_Err_Group_Invite_Accept {
TOX_ERR_GROUP_INVITE_ACCEPT_EMPTY,
/**
- * Failed to set password. This usually occurs if the password exceeds TOX_GROUP_MAX_PASSWORD_SIZE.
+ * Failed to set password. This usually occurs if the password exceeds
+ * TOX_GROUP_MAX_PASSWORD_SIZE.
*/
TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD,
/**
- * There was a core error when initiating the group.
+ * The friend number passed did not designate a valid friend.
*/
- TOX_ERR_GROUP_INVITE_ACCEPT_CORE,
+ TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND,
/**
* Packet failed to send.
*/
TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND,
+ /**
+ * Invite data or name is NULL.
+ */
+ TOX_ERR_GROUP_INVITE_ACCEPT_NULL,
+
} Tox_Err_Group_Invite_Accept;
const char *tox_err_group_invite_accept_to_string(Tox_Err_Group_Invite_Accept value);
/**
- * Accept an invite to a group chat that the client previously received from a friend. The invite
- * is only valid while the inviter is present in the group.
+ * Accept an invite to a group chat that the client previously received from a
+ * friend. The invite is only valid while the inviter is present in the group.
*
* @param invite_data The invite data received from the `group_invite` event.
* @param length The length of the invite data.
* @param name The name of the peer joining the group.
- * @param name_length The length of the peer's name. This must be greater than zero and no larger
- * than TOX_MAX_NAME_LENGTH.
- * @param password The password required to join the group. Set to NULL if no password is required.
- * @param password_length The length of the password. If password_length is equal to zero, the password
- * parameter will be ignored. password_length must be no larger than TOX_GROUP_MAX_PASSWORD_SIZE.
+ * @param name_length The length of the peer's name. This must be greater than
+ * zero and no larger than TOX_MAX_NAME_LENGTH.
+ * @param password The password required to join the group. Set to NULL if no
+ * password is required.
+ * @param password_length The length of the password. If password_length is
+ * equal to zero, the password parameter will be ignored. password_length
+ * must be no larger than TOX_GROUP_MAX_PASSWORD_SIZE.
*
* @return the group_number on success, UINT32_MAX on failure.
*/
@@ -4932,26 +5036,30 @@ Tox_Group_Number tox_group_invite_accept(
/**
* @param friend_number The friend number of the contact who sent the invite.
* @param invite_data The invite data.
- * @param length The length of invite_data.
+ * @param invite_data_length The length of invite_data.
+ * @param group_name The name of the group. In conferences, this is "title".
+ * @param group_name_length The length of the group name.
*/
typedef void tox_group_invite_cb(
Tox *tox, Tox_Friend_Number friend_number,
- const uint8_t invite_data[], size_t length,
+ const uint8_t invite_data[], size_t invite_data_length,
const uint8_t group_name[], size_t group_name_length,
void *user_data);
/**
* Set the callback for the `group_invite` event. Pass NULL to unset.
*
- * This event is triggered when the client receives a group invite from a friend. The client must store
- * invite_data which is used to join the group via tox_group_invite_accept.
+ * This event is triggered when the client receives a group invite from a
+ * friend. The client must store invite_data which is used to join the group
+ * via tox_group_invite_accept.
*/
void tox_callback_group_invite(Tox *tox, tox_group_invite_cb *callback);
/**
- * @param group_number The group number of the group in which a new peer has joined.
- * @param peer_id The permanent ID of the new peer. This id should not be relied on for
- * client behaviour and should be treated as a random value.
+ * @param group_number The group number of the group in which a new peer has
+ * joined.
+ * @param peer_id The permanent ID of the new peer. This id should not be relied
+ * on for client behaviour and should be treated as a random value.
*/
typedef void tox_group_peer_join_cb(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, void *user_data);
@@ -4963,7 +5071,8 @@ typedef void tox_group_peer_join_cb(Tox *tox, Tox_Group_Number group_number, Tox
void tox_callback_group_peer_join(Tox *tox, tox_group_peer_join_cb *callback);
/**
- * Represents peer exit events. These should be used with the `group_peer_exit` event.
+ * Represents peer exit events. These should be used with the `group_peer_exit`
+ * event.
*/
typedef enum Tox_Group_Exit_Type {
@@ -4983,8 +5092,9 @@ typedef enum Tox_Group_Exit_Type {
TOX_GROUP_EXIT_TYPE_DISCONNECTED,
/**
- * Your connection with all peers has been severed. This will occur when you are kicked from
- * a group, rejoin a group, or manually disconnect from a group.
+ * Your connection with all peers has been severed. This will occur when you
+ * are kicked from a group, rejoin a group, or manually disconnect from a
+ * group.
*/
TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED,
@@ -5004,8 +5114,8 @@ const char *tox_group_exit_type_to_string(Tox_Group_Exit_Type value);
/**
* @param group_number The group number of the group in which a peer has left.
- * @param peer_id The ID of the peer who left the group. This ID no longer designates a valid peer
- * and cannot be used for API calls.
+ * @param peer_id The ID of the peer who left the group. This ID no longer
+ * designates a valid peer and cannot be used for API calls.
* @param exit_type The type of exit event. One of Tox_Group_Exit_Type.
* @param name The nickname of the peer who left the group.
* @param name_length The length of the peer name.
@@ -5032,14 +5142,14 @@ typedef void tox_group_self_join_cb(Tox *tox, Tox_Group_Number group_number, voi
/**
* Set the callback for the `group_self_join` event. Pass NULL to unset.
*
- * This event is triggered when the client has successfully joined a group. Use this to initialize
- * any group information the client may need.
+ * This event is triggered when the client has successfully joined a group. Use
+ * this to initialize any group information the client may need.
*/
void tox_callback_group_self_join(Tox *tox, tox_group_self_join_cb *callback);
/**
- * Represents types of failed group join attempts. These are used in the tox_callback_group_rejected
- * callback when a peer fails to join a group.
+ * Represents types of failed group join attempts. These are used in the
+ * tox_callback_group_rejected callback when a peer fails to join a group.
*/
typedef enum Tox_Group_Join_Fail {
@@ -5054,8 +5164,8 @@ typedef enum Tox_Group_Join_Fail {
TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD,
/**
- * The join attempt failed due to an unspecified error. This often occurs when the group is
- * not found in the DHT.
+ * The join attempt failed due to an unspecified error. This often occurs
+ * when the group is not found in the DHT.
*/
TOX_GROUP_JOIN_FAIL_UNKNOWN,
@@ -5064,7 +5174,8 @@ typedef enum Tox_Group_Join_Fail {
const char *tox_group_join_fail_to_string(Tox_Group_Join_Fail value);
/**
- * @param group_number The group number of the group for which the join has failed.
+ * @param group_number The group number of the group for which the join has
+ * failed.
* @param fail_type The type of group rejection.
*/
typedef void tox_group_join_fail_cb(Tox *tox, Tox_Group_Number group_number, Tox_Group_Join_Fail fail_type, void *user_data);
@@ -5078,289 +5189,306 @@ void tox_callback_group_join_fail(Tox *tox, tox_group_join_fail_cb *callback);
/*******************************************************************************
*
- * :: Group chat founder controls (these only work for the group founder)
+ * :: Group chat Founder controls
*
******************************************************************************/
-typedef enum Tox_Err_Group_Founder_Set_Password {
+typedef enum Tox_Err_Group_Set_Password {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK,
+ TOX_ERR_GROUP_SET_PASSWORD_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_PASSWORD_GROUP_NOT_FOUND,
/**
* The caller does not have the required permissions to set the password.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_PERMISSIONS,
+ TOX_ERR_GROUP_SET_PASSWORD_PERMISSIONS,
/**
* Password length exceeded TOX_GROUP_MAX_PASSWORD_SIZE.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_TOO_LONG,
+ TOX_ERR_GROUP_SET_PASSWORD_TOO_LONG,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_FAIL_SEND,
+ TOX_ERR_GROUP_SET_PASSWORD_FAIL_SEND,
/**
* The function failed to allocate enough memory for the operation.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_MALLOC,
+ TOX_ERR_GROUP_SET_PASSWORD_MALLOC,
/**
* The group is disconnected.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_DISCONNECTED,
+ TOX_ERR_GROUP_SET_PASSWORD_DISCONNECTED,
-} Tox_Err_Group_Founder_Set_Password;
+} Tox_Err_Group_Set_Password;
-const char *tox_err_group_founder_set_password_to_string(Tox_Err_Group_Founder_Set_Password value);
+const char *tox_err_group_set_password_to_string(Tox_Err_Group_Set_Password value);
/**
* Set or unset the group password.
*
- * This function sets the groups password, creates a new group shared state including the change,
- * and distributes it to the rest of the group.
+ * This function allows Founders to set or unset a group password. It will
+ * create a new group shared state including the change and distribute it to the
+ * rest of the group.
*
- * @param group_number The group number of the group for which we wish to set the password.
- * @param password The password we want to set. Set password to NULL to unset the password.
- * @param length The length of the password. length must be no longer than TOX_GROUP_MAX_PASSWORD_SIZE.
+ * @param group_number The group number of the group for which we wish to set
+ * the password.
+ * @param password The password we want to set. Set password to NULL to unset
+ * the password.
+ * @param length The length of the password. length must be no longer than
+ * TOX_GROUP_MAX_PASSWORD_SIZE.
*
* @return true on success.
*/
-bool tox_group_founder_set_password(
+bool tox_group_set_password(
Tox *tox, Tox_Group_Number group_number,
const uint8_t password[], size_t length,
- Tox_Err_Group_Founder_Set_Password *error);
+ Tox_Err_Group_Set_Password *error);
-typedef enum Tox_Err_Group_Founder_Set_Topic_Lock {
+typedef enum Tox_Err_Group_Set_Topic_Lock {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_GROUP_NOT_FOUND,
/**
* Tox_Group_Topic_Lock is an invalid type.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_INVALID,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_INVALID,
/**
* The caller does not have the required permissions to set the topic lock.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_PERMISSIONS,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_PERMISSIONS,
/**
- * The topic lock could not be set. This may occur due to an error related to
- * cryptographic signing of the new shared state.
+ * The topic lock could not be set. This may occur due to an error related
+ * to cryptographic signing of the new shared state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SET,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SET,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SEND,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SEND,
/**
* The group is disconnected.
*/
- TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_DISCONNECTED,
+ TOX_ERR_GROUP_SET_TOPIC_LOCK_DISCONNECTED,
-} Tox_Err_Group_Founder_Set_Topic_Lock;
+} Tox_Err_Group_Set_Topic_Lock;
-const char *tox_err_group_founder_set_topic_lock_to_string(Tox_Err_Group_Founder_Set_Topic_Lock value);
+const char *tox_err_group_set_topic_lock_to_string(Tox_Err_Group_Set_Topic_Lock value);
/**
* Set the group topic lock state.
*
- * This function sets the group's topic lock state to enabled or disabled, creates a new shared
- * state including the change, and distributes it to the rest of the group.
+ * This function allows Founders to enable or disable the group's topic lock. It
+ * will create a new shared state including the change and distribute it to the
+ * rest of the group.
*
- * When the topic lock is enabled, only the group founder and moderators may set the topic.
- * When disabled, all peers except those with the observer role may set the topic.
+ * When the topic lock is enabled, only the group founder and moderators may set
+ * the topic. When disabled, all peers except those with the observer role may
+ * set the topic.
*
- * @param group_number The group number of the group for which we wish to change the topic lock state.
+ * @param group_number The group number of the group for which we wish to change
+ * the topic lock state.
* @param topic_lock The state we wish to set the topic lock to.
*
* @return true on success.
*/
-bool tox_group_founder_set_topic_lock(Tox *tox, Tox_Group_Number group_number, Tox_Group_Topic_Lock topic_lock,
- Tox_Err_Group_Founder_Set_Topic_Lock *error);
+bool tox_group_set_topic_lock(Tox *tox, Tox_Group_Number group_number, Tox_Group_Topic_Lock topic_lock,
+ Tox_Err_Group_Set_Topic_Lock *error);
-typedef enum Tox_Err_Group_Founder_Set_Voice_State {
+typedef enum Tox_Err_Group_Set_Voice_State {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK,
+ TOX_ERR_GROUP_SET_VOICE_STATE_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_VOICE_STATE_GROUP_NOT_FOUND,
/**
- * The caller does not have the required permissions to set the privacy state.
+ * The caller does not have the required permissions to set the privacy
+ * state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_PERMISSIONS,
+ TOX_ERR_GROUP_SET_VOICE_STATE_PERMISSIONS,
/**
- * The voice state could not be set. This may occur due to an error related to
- * cryptographic signing of the new shared state.
+ * The voice state could not be set. This may occur due to an error related
+ * to cryptographic signing of the new shared state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SET,
+ TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SET,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SEND,
+ TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SEND,
/**
* The group is disconnected.
*/
- TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_DISCONNECTED,
+ TOX_ERR_GROUP_SET_VOICE_STATE_DISCONNECTED,
-} Tox_Err_Group_Founder_Set_Voice_State;
+} Tox_Err_Group_Set_Voice_State;
-const char *tox_err_group_founder_set_voice_state_to_string(Tox_Err_Group_Founder_Set_Voice_State value);
+const char *tox_err_group_set_voice_state_to_string(Tox_Err_Group_Set_Voice_State value);
/**
* Set the group voice state.
*
- * This function sets the group's voice state, creates a new group shared state
- * including the change, and distributes it to the rest of the group.
+ * This function allows Founders to set the group's voice state. It will create
+ * a new group shared state including the change and distribute it to the rest
+ * of the group.
*
- * If an attempt is made to set the voice state to the same state that the group is already
- * in, the function call will be successful and no action will be taken.
+ * If an attempt is made to set the voice state to the same state that the group
+ * is already in, the function call will be successful and no action will be
+ * taken.
*
- * @param group_number The group number of the group for which we wish to change the voice state.
+ * @param group_number The group number of the group for which we wish to change
+ * the voice state.
* @param voice_state The voice state we wish to set the group to.
*
* @return true on success.
*/
-bool tox_group_founder_set_voice_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Voice_State voice_state,
- Tox_Err_Group_Founder_Set_Voice_State *error);
+bool tox_group_set_voice_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Voice_State voice_state,
+ Tox_Err_Group_Set_Voice_State *error);
-typedef enum Tox_Err_Group_Founder_Set_Privacy_State {
+typedef enum Tox_Err_Group_Set_Privacy_State {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_GROUP_NOT_FOUND,
/**
- * The caller does not have the required permissions to set the privacy state.
+ * The caller does not have the required permissions to set the privacy
+ * state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_PERMISSIONS,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_PERMISSIONS,
/**
- * The privacy state could not be set. This may occur due to an error related to
- * cryptographic signing of the new shared state.
+ * The privacy state could not be set. This may occur due to an error
+ * related to cryptographic signing of the new shared state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SET,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SET,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SEND,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SEND,
/**
* The group is disconnected.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_DISCONNECTED,
+ TOX_ERR_GROUP_SET_PRIVACY_STATE_DISCONNECTED,
-} Tox_Err_Group_Founder_Set_Privacy_State;
+} Tox_Err_Group_Set_Privacy_State;
-const char *tox_err_group_founder_set_privacy_state_to_string(Tox_Err_Group_Founder_Set_Privacy_State value);
+const char *tox_err_group_set_privacy_state_to_string(Tox_Err_Group_Set_Privacy_State value);
/**
* Set the group privacy state.
*
- * This function sets the group's privacy state, creates a new group shared state
- * including the change, and distributes it to the rest of the group.
+ * This function allows Founders to set the group's privacy state. It will
+ * create a new group shared state including the change and distribute it to the
+ * rest of the group.
*
- * If an attempt is made to set the privacy state to the same state that the group is already
- * in, the function call will be successful and no action will be taken.
+ * If an attempt is made to set the privacy state to the same state that the
+ * group is already in, the function call will be successful and no action will
+ * be taken.
*
- * @param group_number The group number of the group for which we wish to change the privacy state.
+ * @param group_number The group number of the group for which we wish to change
+ * the privacy state.
* @param privacy_state The privacy state we wish to set the group to.
*
* @return true on success.
*/
-bool tox_group_founder_set_privacy_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Privacy_State privacy_state,
- Tox_Err_Group_Founder_Set_Privacy_State *error);
+bool tox_group_set_privacy_state(Tox *tox, Tox_Group_Number group_number, Tox_Group_Privacy_State privacy_state,
+ Tox_Err_Group_Set_Privacy_State *error);
-typedef enum Tox_Err_Group_Founder_Set_Peer_Limit {
+typedef enum Tox_Err_Group_Set_Peer_Limit {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_GROUP_NOT_FOUND,
/**
* The caller does not have the required permissions to set the peer limit.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_PERMISSIONS,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_PERMISSIONS,
/**
- * The peer limit could not be set. This may occur due to an error related to
- * cryptographic signing of the new shared state.
+ * The peer limit could not be set. This may occur due to an error related
+ * to cryptographic signing of the new shared state.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SET,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SET,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SEND,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SEND,
/**
* The group is disconnected.
*/
- TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_DISCONNECTED,
+ TOX_ERR_GROUP_SET_PEER_LIMIT_DISCONNECTED,
-} Tox_Err_Group_Founder_Set_Peer_Limit;
+} Tox_Err_Group_Set_Peer_Limit;
-const char *tox_err_group_founder_set_peer_limit_to_string(Tox_Err_Group_Founder_Set_Peer_Limit value);
+const char *tox_err_group_set_peer_limit_to_string(Tox_Err_Group_Set_Peer_Limit value);
/**
* Set the group peer limit.
*
- * This function sets a limit for the number of peers who may be in the group, creates a new
- * group shared state including the change, and distributes it to the rest of the group.
+ * This function allows Founders to set a limit for the number of peers who may
+ * be in the group. It will create a new group shared state including the change
+ * and distribute it to the rest of the group.
*
- * @param group_number The group number of the group for which we wish to set the peer limit.
+ * @param group_number The group number of the group for which we wish to set
+ * the peer limit.
* @param peer_limit The maximum number of peers to allow in the group.
*
* @return true on success.
*/
-bool tox_group_founder_set_peer_limit(Tox *tox, Tox_Group_Number group_number, uint16_t peer_limit,
- Tox_Err_Group_Founder_Set_Peer_Limit *error);
+bool tox_group_set_peer_limit(Tox *tox, Tox_Group_Number group_number, uint16_t peer_limit,
+ Tox_Err_Group_Set_Peer_Limit *error);
/*******************************************************************************
*
- * :: Group chat moderation
+ * :: Group chat moderation controls
*
******************************************************************************/
@@ -5393,7 +5521,8 @@ const char *tox_err_group_set_ignore_to_string(Tox_Err_Group_Set_Ignore value);
/**
* Ignore or unignore a peer.
*
- * @param group_number The group number of the group in which you wish to ignore a peer.
+ * @param group_number The group number of the group in which you wish to ignore
+ * a peer.
* @param peer_id The ID of the peer who shall be ignored or unignored.
* @param ignore True to ignore the peer, false to unignore the peer.
*
@@ -5402,123 +5531,134 @@ const char *tox_err_group_set_ignore_to_string(Tox_Err_Group_Set_Ignore value);
bool tox_group_set_ignore(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, bool ignore,
Tox_Err_Group_Set_Ignore *error);
-typedef enum Tox_Err_Group_Mod_Set_Role {
+typedef enum Tox_Err_Group_Set_Role {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_OK,
+ TOX_ERR_GROUP_SET_ROLE_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_SET_ROLE_GROUP_NOT_FOUND,
/**
- * The ID passed did not designate a valid peer. Note: you cannot set your own role.
+ * The ID passed did not designate a valid peer. Note: you cannot set your
+ * own role.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_PEER_NOT_FOUND,
+ TOX_ERR_GROUP_SET_ROLE_PEER_NOT_FOUND,
/**
* The caller does not have the required permissions for this action.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_PERMISSIONS,
+ TOX_ERR_GROUP_SET_ROLE_PERMISSIONS,
/**
- * The role assignment is invalid. This will occur if you try to set a peer's role to
- * the role they already have.
+ * The role assignment is invalid. This will occur if you try to set a
+ * peer's role to the role they already have.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_ASSIGNMENT,
+ TOX_ERR_GROUP_SET_ROLE_ASSIGNMENT,
/**
- * The role was not successfully set. This may occur if the packet failed to send, or
- * if the role limit has been reached.
+ * The role was not successfully set. This may occur if the packet failed to
+ * send, or if the role limit has been reached.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_FAIL_ACTION,
+ TOX_ERR_GROUP_SET_ROLE_FAIL_ACTION,
/**
* The caller attempted to set their own role.
*/
- TOX_ERR_GROUP_MOD_SET_ROLE_SELF,
+ TOX_ERR_GROUP_SET_ROLE_SELF,
-} Tox_Err_Group_Mod_Set_Role;
+} Tox_Err_Group_Set_Role;
-const char *tox_err_group_mod_set_role_to_string(Tox_Err_Group_Mod_Set_Role value);
+const char *tox_err_group_set_role_to_string(Tox_Err_Group_Set_Role value);
/**
* Set a peer's role.
*
- * This function will first remove the peer's previous role and then assign them a new role.
- * It will also send a packet to the rest of the group, requesting that they perform
- * the role reassignment. Note: peers cannot be set to the founder role.
+ * This function will first remove the peer's previous role and then assign them
+ * a new role. It will also send a packet to the rest of the group, requesting
+ * that they perform the role reassignment.
*
- * @param group_number The group number of the group the in which you wish set the peer's role.
+ * Only Founders may promote peers to the Moderator role, and only Founders and
+ * Moderators may set peers to the Observer or User role. Moderators may not set
+ * the role of other Moderators or the Founder. Peers may not be promoted to the
+ * Founder role.
+ *
+ * @param group_number The group number of the group the in which you wish set
+ * the peer's role.
* @param peer_id The ID of the peer whose role you wish to set.
* @param role The role you wish to set the peer to.
*
* @return true on success.
*/
-bool tox_group_mod_set_role(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Group_Role role,
- Tox_Err_Group_Mod_Set_Role *error);
+bool tox_group_set_role(Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id, Tox_Group_Role role,
+ Tox_Err_Group_Set_Role *error);
-typedef enum Tox_Err_Group_Mod_Kick_Peer {
+typedef enum Tox_Err_Group_Kick_Peer {
/**
* The function returned successfully.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_OK,
+ TOX_ERR_GROUP_KICK_PEER_OK,
/**
* The group number passed did not designate a valid group.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_GROUP_NOT_FOUND,
+ TOX_ERR_GROUP_KICK_PEER_GROUP_NOT_FOUND,
/**
* The ID passed did not designate a valid peer.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_PEER_NOT_FOUND,
+ TOX_ERR_GROUP_KICK_PEER_PEER_NOT_FOUND,
/**
* The caller does not have the required permissions for this action.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_PERMISSIONS,
+ TOX_ERR_GROUP_KICK_PEER_PERMISSIONS,
/**
* The peer could not be kicked from the group.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_ACTION,
+ TOX_ERR_GROUP_KICK_PEER_FAIL_ACTION,
/**
* The packet failed to send.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_SEND,
+ TOX_ERR_GROUP_KICK_PEER_FAIL_SEND,
/**
* The caller attempted to set their own role.
*/
- TOX_ERR_GROUP_MOD_KICK_PEER_SELF,
+ TOX_ERR_GROUP_KICK_PEER_SELF,
-} Tox_Err_Group_Mod_Kick_Peer;
+} Tox_Err_Group_Kick_Peer;
-const char *tox_err_group_mod_kick_peer_to_string(Tox_Err_Group_Mod_Kick_Peer value);
+const char *tox_err_group_kick_peer_to_string(Tox_Err_Group_Kick_Peer value);
/**
* Kick a peer.
*
- * This function will remove a peer from the caller's peer list and send a packet to all
- * group members requesting them to do the same. Note: This function will not trigger
- * the `group_peer_exit` event for the caller.
+ * This function allows peers with the Founder or Moderator role to silently
+ * instruct all other peers in the group to remove a particular peer from their
+ * peer list.
+ *
+ * Note: This function will not trigger the `group_peer_exit` event for the
+ * caller.
*
* @param group_number The group number of the group the action is intended for.
* @param peer_id The ID of the peer who will be kicked.
*
* @return true on success.
*/
-bool tox_group_mod_kick_peer(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
- Tox_Err_Group_Mod_Kick_Peer *error);
+bool tox_group_kick_peer(const Tox *tox, Tox_Group_Number group_number, Tox_Group_Peer_Number peer_id,
+ Tox_Err_Group_Kick_Peer *error);
/**
- * Represents moderation events. These should be used with the `group_moderation` event.
+ * Represents moderation events. These should be used with the
+ * `group_moderation` event.
*/
typedef enum Tox_Group_Mod_Event {
@@ -5559,12 +5699,13 @@ typedef void tox_group_moderation_cb(
/**
* Set the callback for the `group_moderation` event. Pass NULL to unset.
*
- * This event is triggered when a moderator or founder executes a moderation event, with
- * the exception of the peer who initiates the event. It is also triggered when the
- * observer and moderator lists are silently modified (this may occur during group syncing).
+ * This event is triggered when a moderator or founder executes a moderation
+ * event, with the exception of the peer who initiates the event. It is also
+ * triggered when the observer and moderator lists are silently modified (this
+ * may occur during group syncing).
*
- * If either peer id does not designate a valid peer in the group chat, the client should
- * manually update all peer roles.
+ * If either peer id does not designate a valid peer in the group chat, the
+ * client should manually update all peer roles.
*/
void tox_callback_group_moderation(Tox *tox, tox_group_moderation_cb *callback);
diff --git a/protocols/Tox/libtox/src/toxcore/tox_api.c b/protocols/Tox/libtox/src/toxcore/tox_api.c
index 02791674b5..18d861c18e 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_api.c
+++ b/protocols/Tox/libtox/src/toxcore/tox_api.c
@@ -265,14 +265,6 @@ void tox_options_set_experimental_thread_safety(
{
options->experimental_thread_safety = experimental_thread_safety;
}
-const Tox_System *tox_options_get_operating_system(const Tox_Options *options)
-{
- return options->operating_system;
-}
-void tox_options_set_operating_system(Tox_Options *options, const Tox_System *operating_system)
-{
- options->operating_system = operating_system;
-}
bool tox_options_get_experimental_groups_persistence(const Tox_Options *options)
{
return options->experimental_groups_persistence;
@@ -895,6 +887,9 @@ const char *tox_err_conference_join_to_string(Tox_Err_Conference_Join value)
case TOX_ERR_CONFERENCE_JOIN_FAIL_SEND:
return "TOX_ERR_CONFERENCE_JOIN_FAIL_SEND";
+
+ case TOX_ERR_CONFERENCE_JOIN_NULL:
+ return "TOX_ERR_CONFERENCE_JOIN_NULL";
}
return "<invalid Tox_Err_Conference_Join>";
@@ -1253,17 +1248,17 @@ const char *tox_err_group_peer_query_to_string(Tox_Err_Group_Peer_Query value)
return "<invalid Tox_Err_Group_Peer_Query>";
}
-const char *tox_err_group_state_queries_to_string(Tox_Err_Group_State_Queries value)
+const char *tox_err_group_state_query_to_string(Tox_Err_Group_State_Query value)
{
switch (value) {
- case TOX_ERR_GROUP_STATE_QUERIES_OK:
- return "TOX_ERR_GROUP_STATE_QUERIES_OK";
+ case TOX_ERR_GROUP_STATE_QUERY_OK:
+ return "TOX_ERR_GROUP_STATE_QUERY_OK";
- case TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_STATE_QUERIES_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_STATE_QUERY_GROUP_NOT_FOUND";
}
- return "<invalid Tox_Err_Group_State_Queries>";
+ return "<invalid Tox_Err_Group_State_Query>";
}
const char *tox_err_group_topic_set_to_string(Tox_Err_Group_Topic_Set value)
{
@@ -1340,6 +1335,9 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_EMPTY";
+ case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE:
+ return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE";
+
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_PERMISSIONS";
@@ -1348,9 +1346,6 @@ const char *tox_err_group_send_private_message_to_string(Tox_Err_Group_Send_Priv
case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED:
return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_DISCONNECTED";
-
- case TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE:
- return "TOX_ERR_GROUP_SEND_PRIVATE_MESSAGE_BAD_TYPE";
}
return "<invalid Tox_Err_Group_Send_Private_Message>";
@@ -1370,9 +1365,6 @@ const char *tox_err_group_send_custom_packet_to_string(Tox_Err_Group_Send_Custom
case TOX_ERR_GROUP_SEND_CUSTOM_PACKET_EMPTY:
return "TOX_ERR_GROUP_SEND_CUSTOM_PACKET_EMPTY";
- case TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS:
- return "TOX_ERR_GROUP_SEND_CUSTOM_PACKET_PERMISSIONS";
-
case TOX_ERR_GROUP_SEND_CUSTOM_PACKET_DISCONNECTED:
return "TOX_ERR_GROUP_SEND_CUSTOM_PACKET_DISCONNECTED";
@@ -1400,9 +1392,6 @@ const char *tox_err_group_send_custom_private_packet_to_string(Tox_Err_Group_Sen
case TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PEER_NOT_FOUND:
return "TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PEER_NOT_FOUND";
- case TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS:
- return "TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_PERMISSIONS";
-
case TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND:
return "TOX_ERR_GROUP_SEND_CUSTOM_PRIVATE_PACKET_FAIL_SEND";
@@ -1457,11 +1446,14 @@ const char *tox_err_group_invite_accept_to_string(Tox_Err_Group_Invite_Accept va
case TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD:
return "TOX_ERR_GROUP_INVITE_ACCEPT_PASSWORD";
- case TOX_ERR_GROUP_INVITE_ACCEPT_CORE:
- return "TOX_ERR_GROUP_INVITE_ACCEPT_CORE";
+ case TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND:
+ return "TOX_ERR_GROUP_INVITE_ACCEPT_FRIEND_NOT_FOUND";
case TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND:
return "TOX_ERR_GROUP_INVITE_ACCEPT_FAIL_SEND";
+
+ case TOX_ERR_GROUP_INVITE_ACCEPT_NULL:
+ return "TOX_ERR_GROUP_INVITE_ACCEPT_NULL";
}
return "<invalid Tox_Err_Group_Invite_Accept>";
@@ -1505,131 +1497,131 @@ const char *tox_group_join_fail_to_string(Tox_Group_Join_Fail value)
return "<invalid Tox_Group_Join_Fail>";
}
-const char *tox_err_group_founder_set_password_to_string(Tox_Err_Group_Founder_Set_Password value)
+const char *tox_err_group_set_password_to_string(Tox_Err_Group_Set_Password value)
{
switch (value) {
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_OK";
+ case TOX_ERR_GROUP_SET_PASSWORD_OK:
+ return "TOX_ERR_GROUP_SET_PASSWORD_OK";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_PASSWORD_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_PASSWORD_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_PERMISSIONS:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_PASSWORD_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_PASSWORD_PERMISSIONS";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_TOO_LONG:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_TOO_LONG";
+ case TOX_ERR_GROUP_SET_PASSWORD_TOO_LONG:
+ return "TOX_ERR_GROUP_SET_PASSWORD_TOO_LONG";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_FAIL_SEND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_FAIL_SEND";
+ case TOX_ERR_GROUP_SET_PASSWORD_FAIL_SEND:
+ return "TOX_ERR_GROUP_SET_PASSWORD_FAIL_SEND";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_MALLOC:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_MALLOC";
+ case TOX_ERR_GROUP_SET_PASSWORD_MALLOC:
+ return "TOX_ERR_GROUP_SET_PASSWORD_MALLOC";
- case TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_DISCONNECTED:
- return "TOX_ERR_GROUP_FOUNDER_SET_PASSWORD_DISCONNECTED";
+ case TOX_ERR_GROUP_SET_PASSWORD_DISCONNECTED:
+ return "TOX_ERR_GROUP_SET_PASSWORD_DISCONNECTED";
}
- return "<invalid Tox_Err_Group_Founder_Set_Password>";
+ return "<invalid Tox_Err_Group_Set_Password>";
}
-const char *tox_err_group_founder_set_topic_lock_to_string(Tox_Err_Group_Founder_Set_Topic_Lock value)
+const char *tox_err_group_set_topic_lock_to_string(Tox_Err_Group_Set_Topic_Lock value)
{
switch (value) {
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_OK";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_OK:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_OK";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_INVALID:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_INVALID";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_INVALID:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_INVALID";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_PERMISSIONS:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_PERMISSIONS";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SET:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SET";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SET:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SET";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SEND:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_FAIL_SEND";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SEND:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_FAIL_SEND";
- case TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_DISCONNECTED:
- return "TOX_ERR_GROUP_FOUNDER_SET_TOPIC_LOCK_DISCONNECTED";
+ case TOX_ERR_GROUP_SET_TOPIC_LOCK_DISCONNECTED:
+ return "TOX_ERR_GROUP_SET_TOPIC_LOCK_DISCONNECTED";
}
- return "<invalid Tox_Err_Group_Founder_Set_Topic_Lock>";
+ return "<invalid Tox_Err_Group_Set_Topic_Lock>";
}
-const char *tox_err_group_founder_set_voice_state_to_string(Tox_Err_Group_Founder_Set_Voice_State value)
+const char *tox_err_group_set_voice_state_to_string(Tox_Err_Group_Set_Voice_State value)
{
switch (value) {
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_OK";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_OK:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_OK";
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_PERMISSIONS:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_PERMISSIONS";
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SET:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SET";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SET:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SET";
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SEND:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_FAIL_SEND";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SEND:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_FAIL_SEND";
- case TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_DISCONNECTED:
- return "TOX_ERR_GROUP_FOUNDER_SET_VOICE_STATE_DISCONNECTED";
+ case TOX_ERR_GROUP_SET_VOICE_STATE_DISCONNECTED:
+ return "TOX_ERR_GROUP_SET_VOICE_STATE_DISCONNECTED";
}
- return "<invalid Tox_Err_Group_Founder_Set_Voice_State>";
+ return "<invalid Tox_Err_Group_Set_Voice_State>";
}
-const char *tox_err_group_founder_set_privacy_state_to_string(Tox_Err_Group_Founder_Set_Privacy_State value)
+const char *tox_err_group_set_privacy_state_to_string(Tox_Err_Group_Set_Privacy_State value)
{
switch (value) {
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_OK";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_OK:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_OK";
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_PERMISSIONS:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_PERMISSIONS";
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SET:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SET";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SET:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SET";
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SEND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_FAIL_SEND";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SEND:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_FAIL_SEND";
- case TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_DISCONNECTED:
- return "TOX_ERR_GROUP_FOUNDER_SET_PRIVACY_STATE_DISCONNECTED";
+ case TOX_ERR_GROUP_SET_PRIVACY_STATE_DISCONNECTED:
+ return "TOX_ERR_GROUP_SET_PRIVACY_STATE_DISCONNECTED";
}
- return "<invalid Tox_Err_Group_Founder_Set_Privacy_State>";
+ return "<invalid Tox_Err_Group_Set_Privacy_State>";
}
-const char *tox_err_group_founder_set_peer_limit_to_string(Tox_Err_Group_Founder_Set_Peer_Limit value)
+const char *tox_err_group_set_peer_limit_to_string(Tox_Err_Group_Set_Peer_Limit value)
{
switch (value) {
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_OK";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_OK:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_OK";
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_PERMISSIONS:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_PERMISSIONS";
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SET:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SET";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SET:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SET";
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SEND:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_FAIL_SEND";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SEND:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_FAIL_SEND";
- case TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_DISCONNECTED:
- return "TOX_ERR_GROUP_FOUNDER_SET_PEER_LIMIT_DISCONNECTED";
+ case TOX_ERR_GROUP_SET_PEER_LIMIT_DISCONNECTED:
+ return "TOX_ERR_GROUP_SET_PEER_LIMIT_DISCONNECTED";
}
- return "<invalid Tox_Err_Group_Founder_Set_Peer_Limit>";
+ return "<invalid Tox_Err_Group_Set_Peer_Limit>";
}
const char *tox_err_group_set_ignore_to_string(Tox_Err_Group_Set_Ignore value)
{
@@ -1649,59 +1641,59 @@ const char *tox_err_group_set_ignore_to_string(Tox_Err_Group_Set_Ignore value)
return "<invalid Tox_Err_Group_Set_Ignore>";
}
-const char *tox_err_group_mod_set_role_to_string(Tox_Err_Group_Mod_Set_Role value)
+const char *tox_err_group_set_role_to_string(Tox_Err_Group_Set_Role value)
{
switch (value) {
- case TOX_ERR_GROUP_MOD_SET_ROLE_OK:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_OK";
+ case TOX_ERR_GROUP_SET_ROLE_OK:
+ return "TOX_ERR_GROUP_SET_ROLE_OK";
- case TOX_ERR_GROUP_MOD_SET_ROLE_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_ROLE_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_ROLE_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_MOD_SET_ROLE_PEER_NOT_FOUND:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_PEER_NOT_FOUND";
+ case TOX_ERR_GROUP_SET_ROLE_PEER_NOT_FOUND:
+ return "TOX_ERR_GROUP_SET_ROLE_PEER_NOT_FOUND";
- case TOX_ERR_GROUP_MOD_SET_ROLE_PERMISSIONS:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_PERMISSIONS";
+ case TOX_ERR_GROUP_SET_ROLE_PERMISSIONS:
+ return "TOX_ERR_GROUP_SET_ROLE_PERMISSIONS";
- case TOX_ERR_GROUP_MOD_SET_ROLE_ASSIGNMENT:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_ASSIGNMENT";
+ case TOX_ERR_GROUP_SET_ROLE_ASSIGNMENT:
+ return "TOX_ERR_GROUP_SET_ROLE_ASSIGNMENT";
- case TOX_ERR_GROUP_MOD_SET_ROLE_FAIL_ACTION:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_FAIL_ACTION";
+ case TOX_ERR_GROUP_SET_ROLE_FAIL_ACTION:
+ return "TOX_ERR_GROUP_SET_ROLE_FAIL_ACTION";
- case TOX_ERR_GROUP_MOD_SET_ROLE_SELF:
- return "TOX_ERR_GROUP_MOD_SET_ROLE_SELF";
+ case TOX_ERR_GROUP_SET_ROLE_SELF:
+ return "TOX_ERR_GROUP_SET_ROLE_SELF";
}
- return "<invalid Tox_Err_Group_Mod_Set_Role>";
+ return "<invalid Tox_Err_Group_Set_Role>";
}
-const char *tox_err_group_mod_kick_peer_to_string(Tox_Err_Group_Mod_Kick_Peer value)
+const char *tox_err_group_kick_peer_to_string(Tox_Err_Group_Kick_Peer value)
{
switch (value) {
- case TOX_ERR_GROUP_MOD_KICK_PEER_OK:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_OK";
+ case TOX_ERR_GROUP_KICK_PEER_OK:
+ return "TOX_ERR_GROUP_KICK_PEER_OK";
- case TOX_ERR_GROUP_MOD_KICK_PEER_GROUP_NOT_FOUND:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_GROUP_NOT_FOUND";
+ case TOX_ERR_GROUP_KICK_PEER_GROUP_NOT_FOUND:
+ return "TOX_ERR_GROUP_KICK_PEER_GROUP_NOT_FOUND";
- case TOX_ERR_GROUP_MOD_KICK_PEER_PEER_NOT_FOUND:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_PEER_NOT_FOUND";
+ case TOX_ERR_GROUP_KICK_PEER_PEER_NOT_FOUND:
+ return "TOX_ERR_GROUP_KICK_PEER_PEER_NOT_FOUND";
- case TOX_ERR_GROUP_MOD_KICK_PEER_PERMISSIONS:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_PERMISSIONS";
+ case TOX_ERR_GROUP_KICK_PEER_PERMISSIONS:
+ return "TOX_ERR_GROUP_KICK_PEER_PERMISSIONS";
- case TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_ACTION:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_ACTION";
+ case TOX_ERR_GROUP_KICK_PEER_FAIL_ACTION:
+ return "TOX_ERR_GROUP_KICK_PEER_FAIL_ACTION";
- case TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_SEND:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_FAIL_SEND";
+ case TOX_ERR_GROUP_KICK_PEER_FAIL_SEND:
+ return "TOX_ERR_GROUP_KICK_PEER_FAIL_SEND";
- case TOX_ERR_GROUP_MOD_KICK_PEER_SELF:
- return "TOX_ERR_GROUP_MOD_KICK_PEER_SELF";
+ case TOX_ERR_GROUP_KICK_PEER_SELF:
+ return "TOX_ERR_GROUP_KICK_PEER_SELF";
}
- return "<invalid Tox_Err_Group_Mod_Kick_Peer>";
+ return "<invalid Tox_Err_Group_Kick_Peer>";
}
const char *tox_group_mod_event_to_string(Tox_Group_Mod_Event value)
{
diff --git a/protocols/Tox/libtox/src/toxcore/tox_dispatch.h b/protocols/Tox/libtox/src/toxcore/tox_dispatch.h
index 2588065a4d..29ac66a412 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_dispatch.h
+++ b/protocols/Tox/libtox/src/toxcore/tox_dispatch.h
@@ -2,6 +2,13 @@
* Copyright © 2022 The TokTok team.
*/
+/**
+ * WARNING: This is an experimental API and is subject to change.
+ *
+ * At this point, it probably won't change very much anymore, but we may have
+ * small breaking changes before a stable release.
+ */
+
#ifndef C_TOXCORE_TOXCORE_TOX_DISPATCH_H
#define C_TOXCORE_TOXCORE_TOX_DISPATCH_H
diff --git a/protocols/Tox/libtox/src/toxcore/tox_event.c b/protocols/Tox/libtox/src/toxcore/tox_event.c
index b0a65503cd..f702d629fc 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_event.c
+++ b/protocols/Tox/libtox/src/toxcore/tox_event.c
@@ -725,216 +725,216 @@ bool tox_event_pack(const Tox_Event *event, Bin_Pack *bp)
}
non_null()
-static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out)
+static bool tox_event_type_from_int(uint32_t value, Tox_Event_Type *out_enum)
{
switch (value) {
case TOX_EVENT_SELF_CONNECTION_STATUS: {
- *out = TOX_EVENT_SELF_CONNECTION_STATUS;
+ *out_enum = TOX_EVENT_SELF_CONNECTION_STATUS;
return true;
}
case TOX_EVENT_FRIEND_REQUEST: {
- *out = TOX_EVENT_FRIEND_REQUEST;
+ *out_enum = TOX_EVENT_FRIEND_REQUEST;
return true;
}
case TOX_EVENT_FRIEND_CONNECTION_STATUS: {
- *out = TOX_EVENT_FRIEND_CONNECTION_STATUS;
+ *out_enum = TOX_EVENT_FRIEND_CONNECTION_STATUS;
return true;
}
case TOX_EVENT_FRIEND_LOSSY_PACKET: {
- *out = TOX_EVENT_FRIEND_LOSSY_PACKET;
+ *out_enum = TOX_EVENT_FRIEND_LOSSY_PACKET;
return true;
}
case TOX_EVENT_FRIEND_LOSSLESS_PACKET: {
- *out = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
+ *out_enum = TOX_EVENT_FRIEND_LOSSLESS_PACKET;
return true;
}
case TOX_EVENT_FRIEND_NAME: {
- *out = TOX_EVENT_FRIEND_NAME;
+ *out_enum = TOX_EVENT_FRIEND_NAME;
return true;
}
case TOX_EVENT_FRIEND_STATUS: {
- *out = TOX_EVENT_FRIEND_STATUS;
+ *out_enum = TOX_EVENT_FRIEND_STATUS;
return true;
}
case TOX_EVENT_FRIEND_STATUS_MESSAGE: {
- *out = TOX_EVENT_FRIEND_STATUS_MESSAGE;
+ *out_enum = TOX_EVENT_FRIEND_STATUS_MESSAGE;
return true;
}
case TOX_EVENT_FRIEND_MESSAGE: {
- *out = TOX_EVENT_FRIEND_MESSAGE;
+ *out_enum = TOX_EVENT_FRIEND_MESSAGE;
return true;
}
case TOX_EVENT_FRIEND_READ_RECEIPT: {
- *out = TOX_EVENT_FRIEND_READ_RECEIPT;
+ *out_enum = TOX_EVENT_FRIEND_READ_RECEIPT;
return true;
}
case TOX_EVENT_FRIEND_TYPING: {
- *out = TOX_EVENT_FRIEND_TYPING;
+ *out_enum = TOX_EVENT_FRIEND_TYPING;
return true;
}
case TOX_EVENT_FILE_CHUNK_REQUEST: {
- *out = TOX_EVENT_FILE_CHUNK_REQUEST;
+ *out_enum = TOX_EVENT_FILE_CHUNK_REQUEST;
return true;
}
case TOX_EVENT_FILE_RECV: {
- *out = TOX_EVENT_FILE_RECV;
+ *out_enum = TOX_EVENT_FILE_RECV;
return true;
}
case TOX_EVENT_FILE_RECV_CHUNK: {
- *out = TOX_EVENT_FILE_RECV_CHUNK;
+ *out_enum = TOX_EVENT_FILE_RECV_CHUNK;
return true;
}
case TOX_EVENT_FILE_RECV_CONTROL: {
- *out = TOX_EVENT_FILE_RECV_CONTROL;
+ *out_enum = TOX_EVENT_FILE_RECV_CONTROL;
return true;
}
case TOX_EVENT_CONFERENCE_INVITE: {
- *out = TOX_EVENT_CONFERENCE_INVITE;
+ *out_enum = TOX_EVENT_CONFERENCE_INVITE;
return true;
}
case TOX_EVENT_CONFERENCE_CONNECTED: {
- *out = TOX_EVENT_CONFERENCE_CONNECTED;
+ *out_enum = TOX_EVENT_CONFERENCE_CONNECTED;
return true;
}
case TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED: {
- *out = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
+ *out_enum = TOX_EVENT_CONFERENCE_PEER_LIST_CHANGED;
return true;
}
case TOX_EVENT_CONFERENCE_PEER_NAME: {
- *out = TOX_EVENT_CONFERENCE_PEER_NAME;
+ *out_enum = TOX_EVENT_CONFERENCE_PEER_NAME;
return true;
}
case TOX_EVENT_CONFERENCE_TITLE: {
- *out = TOX_EVENT_CONFERENCE_TITLE;
+ *out_enum = TOX_EVENT_CONFERENCE_TITLE;
return true;
}
case TOX_EVENT_CONFERENCE_MESSAGE: {
- *out = TOX_EVENT_CONFERENCE_MESSAGE;
+ *out_enum = TOX_EVENT_CONFERENCE_MESSAGE;
return true;
}
case TOX_EVENT_GROUP_PEER_NAME: {
- *out = TOX_EVENT_GROUP_PEER_NAME;
+ *out_enum = TOX_EVENT_GROUP_PEER_NAME;
return true;
}
case TOX_EVENT_GROUP_PEER_STATUS: {
- *out = TOX_EVENT_GROUP_PEER_STATUS;
+ *out_enum = TOX_EVENT_GROUP_PEER_STATUS;
return true;
}
case TOX_EVENT_GROUP_TOPIC: {
- *out = TOX_EVENT_GROUP_TOPIC;
+ *out_enum = TOX_EVENT_GROUP_TOPIC;
return true;
}
case TOX_EVENT_GROUP_PRIVACY_STATE: {
- *out = TOX_EVENT_GROUP_PRIVACY_STATE;
+ *out_enum = TOX_EVENT_GROUP_PRIVACY_STATE;
return true;
}
case TOX_EVENT_GROUP_VOICE_STATE: {
- *out = TOX_EVENT_GROUP_VOICE_STATE;
+ *out_enum = TOX_EVENT_GROUP_VOICE_STATE;
return true;
}
case TOX_EVENT_GROUP_TOPIC_LOCK: {
- *out = TOX_EVENT_GROUP_TOPIC_LOCK;
+ *out_enum = TOX_EVENT_GROUP_TOPIC_LOCK;
return true;
}
case TOX_EVENT_GROUP_PEER_LIMIT: {
- *out = TOX_EVENT_GROUP_PEER_LIMIT;
+ *out_enum = TOX_EVENT_GROUP_PEER_LIMIT;
return true;
}
case TOX_EVENT_GROUP_PASSWORD: {
- *out = TOX_EVENT_GROUP_PASSWORD;
+ *out_enum = TOX_EVENT_GROUP_PASSWORD;
return true;
}
case TOX_EVENT_GROUP_MESSAGE: {
- *out = TOX_EVENT_GROUP_MESSAGE;
+ *out_enum = TOX_EVENT_GROUP_MESSAGE;
return true;
}
case TOX_EVENT_GROUP_PRIVATE_MESSAGE: {
- *out = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
+ *out_enum = TOX_EVENT_GROUP_PRIVATE_MESSAGE;
return true;
}
case TOX_EVENT_GROUP_CUSTOM_PACKET: {
- *out = TOX_EVENT_GROUP_CUSTOM_PACKET;
+ *out_enum = TOX_EVENT_GROUP_CUSTOM_PACKET;
return true;
}
case TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET: {
- *out = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
+ *out_enum = TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET;
return true;
}
case TOX_EVENT_GROUP_INVITE: {
- *out = TOX_EVENT_GROUP_INVITE;
+ *out_enum = TOX_EVENT_GROUP_INVITE;
return true;
}
case TOX_EVENT_GROUP_PEER_JOIN: {
- *out = TOX_EVENT_GROUP_PEER_JOIN;
+ *out_enum = TOX_EVENT_GROUP_PEER_JOIN;
return true;
}
case TOX_EVENT_GROUP_PEER_EXIT: {
- *out = TOX_EVENT_GROUP_PEER_EXIT;
+ *out_enum = TOX_EVENT_GROUP_PEER_EXIT;
return true;
}
case TOX_EVENT_GROUP_SELF_JOIN: {
- *out = TOX_EVENT_GROUP_SELF_JOIN;
+ *out_enum = TOX_EVENT_GROUP_SELF_JOIN;
return true;
}
case TOX_EVENT_GROUP_JOIN_FAIL: {
- *out = TOX_EVENT_GROUP_JOIN_FAIL;
+ *out_enum = TOX_EVENT_GROUP_JOIN_FAIL;
return true;
}
case TOX_EVENT_GROUP_MODERATION: {
- *out = TOX_EVENT_GROUP_MODERATION;
+ *out_enum = TOX_EVENT_GROUP_MODERATION;
return true;
}
case TOX_EVENT_DHT_GET_NODES_RESPONSE: {
- *out = TOX_EVENT_DHT_GET_NODES_RESPONSE;
+ *out_enum = TOX_EVENT_DHT_GET_NODES_RESPONSE;
return true;
}
case TOX_EVENT_INVALID: {
- *out = TOX_EVENT_INVALID;
+ *out_enum = TOX_EVENT_INVALID;
return true;
}
default: {
- *out = TOX_EVENT_INVALID;
+ *out_enum = TOX_EVENT_INVALID;
return false;
}
}
diff --git a/protocols/Tox/libtox/src/toxcore/tox_events.h b/protocols/Tox/libtox/src/toxcore/tox_events.h
index 3edaa7d06b..6bbf13e8ef 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_events.h
+++ b/protocols/Tox/libtox/src/toxcore/tox_events.h
@@ -2,6 +2,13 @@
* Copyright © 2022-2024 The TokTok team.
*/
+/**
+ * WARNING: This is an experimental API and is subject to change.
+ *
+ * At this point, it probably won't change very much anymore, but we may have
+ * small breaking changes before a stable release.
+ */
+
#ifndef C_TOXCORE_TOXCORE_TOX_EVENTS_H
#define C_TOXCORE_TOXCORE_TOX_EVENTS_H
@@ -248,7 +255,7 @@ uint32_t tox_event_group_message_get_group_number(
const Tox_Event_Group_Message *group_message);
uint32_t tox_event_group_message_get_peer_id(
const Tox_Event_Group_Message *group_message);
-Tox_Message_Type tox_event_group_message_get_type(
+Tox_Message_Type tox_event_group_message_get_message_type(
const Tox_Event_Group_Message *group_message);
const uint8_t *tox_event_group_message_get_message(
const Tox_Event_Group_Message *group_message);
@@ -262,12 +269,14 @@ uint32_t tox_event_group_private_message_get_group_number(
const Tox_Event_Group_Private_Message *group_private_message);
uint32_t tox_event_group_private_message_get_peer_id(
const Tox_Event_Group_Private_Message *group_private_message);
-Tox_Message_Type tox_event_group_private_message_get_type(
+Tox_Message_Type tox_event_group_private_message_get_message_type(
const Tox_Event_Group_Private_Message *group_private_message);
const uint8_t *tox_event_group_private_message_get_message(
const Tox_Event_Group_Private_Message *group_private_message);
uint32_t tox_event_group_private_message_get_message_length(
const Tox_Event_Group_Private_Message *group_private_message);
+uint32_t tox_event_group_private_message_get_message_id(
+ const Tox_Event_Group_Private_Message *group_private_message);
typedef struct Tox_Event_Group_Custom_Packet Tox_Event_Group_Custom_Packet;
uint32_t tox_event_group_custom_packet_get_group_number(
@@ -568,6 +577,8 @@ void tox_events_free(Tox_Events *events);
uint32_t tox_events_bytes_size(const Tox_Events *events);
bool tox_events_get_bytes(const Tox_Events *events, uint8_t *bytes);
+typedef struct Tox_System Tox_System;
+
Tox_Events *tox_events_load(const Tox_System *sys, const uint8_t *bytes, uint32_t bytes_size);
bool tox_events_equal(const Tox_System *sys, const Tox_Events *a, const Tox_Events *b);
diff --git a/protocols/Tox/libtox/src/toxcore/tox_private.h b/protocols/Tox/libtox/src/toxcore/tox_private.h
index d36ab026c3..c872bfea47 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_private.h
+++ b/protocols/Tox/libtox/src/toxcore/tox_private.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
- * Copyright © 2016-2020 The TokTok team.
+ * Copyright © 2016-2024 The TokTok team.
* Copyright © 2013 Tox project.
*/
@@ -18,38 +18,49 @@ extern "C" {
typedef uint64_t tox_mono_time_cb(void *user_data);
-struct Tox_System {
+typedef struct Tox_System {
tox_mono_time_cb *mono_time_callback;
void *mono_time_user_data;
const struct Random *rng;
const struct Network *ns;
const struct Memory *mem;
-};
+} Tox_System;
Tox_System tox_default_system(void);
+const Tox_System *tox_get_system(Tox *tox);
+
+typedef struct Tox_Options_Testing {
+ const struct Tox_System *operating_system;
+} Tox_Options_Testing;
+
+typedef enum Tox_Err_New_Testing {
+ TOX_ERR_NEW_TESTING_OK,
+ TOX_ERR_NEW_TESTING_NULL,
+} Tox_Err_New_Testing;
+
+Tox *tox_new_testing(const Tox_Options *options, Tox_Err_New *error, const Tox_Options_Testing *testing, Tox_Err_New_Testing *testing_error);
+
void tox_lock(const Tox *tox);
void tox_unlock(const Tox *tox);
-const Tox_System *tox_get_system(Tox *tox);
-
/**
- * Set the callback for the `friend_lossy_packet` event for a specific packet ID.
- * Pass NULL to unset.
+ * Set the callback for the `friend_lossy_packet` event for a specific packet
+ * ID. Pass NULL to unset.
*
* allowed packet ID range:
- * from `PACKET_ID_RANGE_LOSSY_START` to `PACKET_ID_RANGE_LOSSY_END` (both inclusive)
+ * from `PACKET_ID_RANGE_LOSSY_START` to `PACKET_ID_RANGE_LOSSY_END` (both
+ * inclusive)
*/
void tox_callback_friend_lossy_packet_per_pktid(Tox *tox, tox_friend_lossy_packet_cb *callback, uint8_t pktid);
/**
- * Set the callback for the `friend_lossless_packet` event for a specific packet ID.
- * Pass NULL to unset.
+ * Set the callback for the `friend_lossless_packet` event for a specific packet
+ * ID. Pass NULL to unset.
*
* allowed packet ID range:
- * from `PACKET_ID_RANGE_LOSSLESS_CUSTOM_START` to `PACKET_ID_RANGE_LOSSLESS_CUSTOM_END` (both inclusive)
- * and
- * `PACKET_ID_MSI`
+ * from `PACKET_ID_RANGE_LOSSLESS_CUSTOM_START` to
+ * `PACKET_ID_RANGE_LOSSLESS_CUSTOM_END` (both inclusive) and `PACKET_ID_MSI`
*/
void tox_callback_friend_lossless_packet_per_pktid(Tox *tox, tox_friend_lossless_packet_cb *callback, uint8_t pktid);
@@ -78,7 +89,7 @@ uint32_t tox_dht_node_public_key_size(void);
/**
* @param public_key The node's public key.
- * @param ip The node's IP address, represented as a null terminated string.
+ * @param ip The node's IP address, represented as a NUL-terminated C string.
* @param port The node's port.
*/
typedef void tox_dht_get_nodes_response_cb(Tox *tox, const uint8_t *public_key, const char *ip, uint16_t port,
@@ -98,7 +109,8 @@ typedef enum Tox_Err_Dht_Get_Nodes {
TOX_ERR_DHT_GET_NODES_OK,
/**
- * UDP is disabled in tox options; the DHT can only be queried when UDP is enabled.
+ * UDP is disabled in Tox options; the DHT can only be queried when UDP is
+ * enabled.
*/
TOX_ERR_DHT_GET_NODES_UDP_DISABLED,
@@ -118,21 +130,24 @@ typedef enum Tox_Err_Dht_Get_Nodes {
TOX_ERR_DHT_GET_NODES_BAD_IP,
/**
- * The getnodes request failed. This usually means the packet failed to send.
+ * The getnodes request failed. This usually means the packet failed to
+ * send.
*/
TOX_ERR_DHT_GET_NODES_FAIL,
} Tox_Err_Dht_Get_Nodes;
/**
* This function sends a getnodes request to a DHT node for its peers that
- * are "close" to the passed target public key according to the distance metric used
- * by the DHT implementation.
+ * are "close" to the passed target public key according to the distance metric
+ * used by the DHT implementation.
*
- * @param public_key The public key of the node that we wish to query. This key must be
- * at least `TOX_DHT_NODE_PUBLIC_KEY_SIZE` bytes in length.
- * @param ip A NULL terminated string representing the IP address of the node we wish to query.
+ * @param public_key The public key of the node that we wish to query. This key
+ * must be at least `TOX_DHT_NODE_PUBLIC_KEY_SIZE` bytes in length.
+ * @param ip A NUL-terminated C string representing the IP address of the node
+ * we wish to query.
* @param port The port of the node we wish to query.
- * @param target_public_key The public key for which we want to find close nodes.
+ * @param target_public_key The public key for which we want to find close
+ * nodes.
*
* @return true on success.
*/
@@ -140,7 +155,6 @@ bool tox_dht_get_nodes(const Tox *tox, const uint8_t *public_key, const char *ip
const uint8_t *target_public_key, Tox_Err_Dht_Get_Nodes *error);
/**
- * This function returns the ratio of close dht nodes that are known to support announce/store.
* This function returns the number of DHT nodes in the closelist.
*
* @return number
@@ -148,8 +162,8 @@ bool tox_dht_get_nodes(const Tox *tox, const uint8_t *public_key, const char *ip
uint16_t tox_dht_get_num_closelist(const Tox *tox);
/**
- * This function returns the number of DHT nodes in the closelist,
- * that are capable to store annouce data (introduced in version 0.2.18).
+ * This function returns the number of DHT nodes in the closelist
+ * that are capable of storing announce data (introduced in version 0.2.18).
*
* @return number
*/
@@ -169,30 +183,32 @@ uint16_t tox_dht_get_num_closelist_announce_capable(const Tox *tox);
uint32_t tox_group_peer_ip_string_max_length(void);
/**
- * Return the length of the peer's IP address in string form. If the group number or ID
- * is invalid, the return value is unspecified.
+ * Return the length of the peer's IP address in string form. If the group
+ * number or ID is invalid, the return value is unspecified.
*
* @param group_number The group number of the group we wish to query.
- * @param peer_id The ID of the peer whose IP address length we want to retrieve.
+ * @param peer_id The ID of the peer whose IP address length we want to
+ * retrieve.
*/
size_t tox_group_peer_get_ip_address_size(const Tox *tox, uint32_t group_number, uint32_t peer_id,
Tox_Err_Group_Peer_Query *error);
/**
- * Write the IP address associated with the designated peer_id for the designated group number
- * to ip_addr.
+ * Write the IP address associated with the designated peer_id for the
+ * designated group number to ip_addr.
*
- * If the peer is forcing TCP connections a placeholder value will be written instead,
- * indicating that their real IP address is unknown to us.
+ * If the peer is forcing TCP connections a placeholder value will be written
+ * instead, indicating that their real IP address is unknown to us.
*
- * If `peer_id` designates ourself, it will write either our own IP address or a placeholder value,
- * depending on whether or not we're forcing TCP connections.
+ * If `peer_id` designates ourself, it will write either our own IP address or a
+ * placeholder value, depending on whether or not we're forcing TCP connections.
*
- * Call tox_group_peer_get_ip_address_size to determine the allocation size for the `ip_addr` parameter.
+ * Call tox_group_peer_get_ip_address_size to determine the allocation size for
+ * the `ip_addr` parameter.
*
* @param group_number The group number of the group we wish to query.
* @param peer_id The ID of the peer whose public key we wish to retrieve.
- * @param ip_addr A valid memory region large enough to store the IP address string.
- * If this parameter is NULL, this function call has no effect.
+ * @param ip_addr A valid memory region large enough to store the IP address
+ * string. If this parameter is NULL, this function call has no effect.
*
* @return true on success.
*/
diff --git a/protocols/Tox/libtox/src/toxcore/tox_unpack.c b/protocols/Tox/libtox/src/toxcore/tox_unpack.c
index b5e05da872..5caef02c07 100644
--- a/protocols/Tox/libtox/src/toxcore/tox_unpack.c
+++ b/protocols/Tox/libtox/src/toxcore/tox_unpack.c
@@ -11,21 +11,21 @@
#include "tox.h"
non_null()
-static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *out)
+static bool tox_conference_type_from_int(uint32_t value, Tox_Conference_Type *out_enum)
{
switch (value) {
case TOX_CONFERENCE_TYPE_TEXT: {
- *out = TOX_CONFERENCE_TYPE_TEXT;
+ *out_enum = TOX_CONFERENCE_TYPE_TEXT;
return true;
}
case TOX_CONFERENCE_TYPE_AV: {
- *out = TOX_CONFERENCE_TYPE_AV;
+ *out_enum = TOX_CONFERENCE_TYPE_AV;
return true;
}
default: {
- *out = TOX_CONFERENCE_TYPE_TEXT;
+ *out_enum = TOX_CONFERENCE_TYPE_TEXT;
return false;
}
}
@@ -38,26 +38,26 @@ bool tox_conference_type_unpack(Tox_Conference_Type *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_connection_from_int(uint32_t value, Tox_Connection *out)
+static bool tox_connection_from_int(uint32_t value, Tox_Connection *out_enum)
{
switch (value) {
case TOX_CONNECTION_NONE: {
- *out = TOX_CONNECTION_NONE;
+ *out_enum = TOX_CONNECTION_NONE;
return true;
}
case TOX_CONNECTION_TCP: {
- *out = TOX_CONNECTION_TCP;
+ *out_enum = TOX_CONNECTION_TCP;
return true;
}
case TOX_CONNECTION_UDP: {
- *out = TOX_CONNECTION_UDP;
+ *out_enum = TOX_CONNECTION_UDP;
return true;
}
default: {
- *out = TOX_CONNECTION_NONE;
+ *out_enum = TOX_CONNECTION_NONE;
return false;
}
}
@@ -71,26 +71,26 @@ bool tox_connection_unpack(Tox_Connection *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out)
+static bool tox_file_control_from_int(uint32_t value, Tox_File_Control *out_enum)
{
switch (value) {
case TOX_FILE_CONTROL_RESUME: {
- *out = TOX_FILE_CONTROL_RESUME;
+ *out_enum = TOX_FILE_CONTROL_RESUME;
return true;
}
case TOX_FILE_CONTROL_PAUSE: {
- *out = TOX_FILE_CONTROL_PAUSE;
+ *out_enum = TOX_FILE_CONTROL_PAUSE;
return true;
}
case TOX_FILE_CONTROL_CANCEL: {
- *out = TOX_FILE_CONTROL_CANCEL;
+ *out_enum = TOX_FILE_CONTROL_CANCEL;
return true;
}
default: {
- *out = TOX_FILE_CONTROL_RESUME;
+ *out_enum = TOX_FILE_CONTROL_RESUME;
return false;
}
}
@@ -104,21 +104,21 @@ bool tox_file_control_unpack(Tox_File_Control *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out)
+static bool tox_message_type_from_int(uint32_t value, Tox_Message_Type *out_enum)
{
switch (value) {
case TOX_MESSAGE_TYPE_NORMAL: {
- *out = TOX_MESSAGE_TYPE_NORMAL;
+ *out_enum = TOX_MESSAGE_TYPE_NORMAL;
return true;
}
case TOX_MESSAGE_TYPE_ACTION: {
- *out = TOX_MESSAGE_TYPE_ACTION;
+ *out_enum = TOX_MESSAGE_TYPE_ACTION;
return true;
}
default: {
- *out = TOX_MESSAGE_TYPE_NORMAL;
+ *out_enum = TOX_MESSAGE_TYPE_NORMAL;
return false;
}
}
@@ -132,26 +132,26 @@ bool tox_message_type_unpack(Tox_Message_Type *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out)
+static bool tox_user_status_from_int(uint32_t value, Tox_User_Status *out_enum)
{
switch (value) {
case TOX_USER_STATUS_NONE: {
- *out = TOX_USER_STATUS_NONE;
+ *out_enum = TOX_USER_STATUS_NONE;
return true;
}
case TOX_USER_STATUS_AWAY: {
- *out = TOX_USER_STATUS_AWAY;
+ *out_enum = TOX_USER_STATUS_AWAY;
return true;
}
case TOX_USER_STATUS_BUSY: {
- *out = TOX_USER_STATUS_BUSY;
+ *out_enum = TOX_USER_STATUS_BUSY;
return true;
}
default: {
- *out = TOX_USER_STATUS_NONE;
+ *out_enum = TOX_USER_STATUS_NONE;
return false;
}
}
@@ -165,19 +165,19 @@ bool tox_user_status_unpack(Tox_User_Status *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_State *out)
+static bool tox_group_privacy_state_from_int(uint32_t value, Tox_Group_Privacy_State *out_enum)
{
switch (value) {
case TOX_GROUP_PRIVACY_STATE_PUBLIC: {
- *out = TOX_GROUP_PRIVACY_STATE_PUBLIC;
+ *out_enum = TOX_GROUP_PRIVACY_STATE_PUBLIC;
return true;
}
case TOX_GROUP_PRIVACY_STATE_PRIVATE: {
- *out = TOX_GROUP_PRIVACY_STATE_PRIVATE;
+ *out_enum = TOX_GROUP_PRIVACY_STATE_PRIVATE;
return true;
}
default: {
- *out = TOX_GROUP_PRIVACY_STATE_PUBLIC;
+ *out_enum = TOX_GROUP_PRIVACY_STATE_PUBLIC;
return false;
}
}
@@ -189,23 +189,23 @@ bool tox_group_privacy_state_unpack(Tox_Group_Privacy_State *val, Bin_Unpack *bu
&& tox_group_privacy_state_from_int(u32, val);
}
non_null()
-static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State *out)
+static bool tox_group_voice_state_from_int(uint32_t value, Tox_Group_Voice_State *out_enum)
{
switch (value) {
case TOX_GROUP_VOICE_STATE_ALL: {
- *out = TOX_GROUP_VOICE_STATE_ALL;
+ *out_enum = TOX_GROUP_VOICE_STATE_ALL;
return true;
}
case TOX_GROUP_VOICE_STATE_MODERATOR: {
- *out = TOX_GROUP_VOICE_STATE_MODERATOR;
+ *out_enum = TOX_GROUP_VOICE_STATE_MODERATOR;
return true;
}
case TOX_GROUP_VOICE_STATE_FOUNDER: {
- *out = TOX_GROUP_VOICE_STATE_FOUNDER;
+ *out_enum = TOX_GROUP_VOICE_STATE_FOUNDER;
return true;
}
default: {
- *out = TOX_GROUP_VOICE_STATE_ALL;
+ *out_enum = TOX_GROUP_VOICE_STATE_ALL;
return false;
}
}
@@ -218,19 +218,19 @@ bool tox_group_voice_state_unpack(Tox_Group_Voice_State *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *out)
+static bool tox_group_topic_lock_from_int(uint32_t value, Tox_Group_Topic_Lock *out_enum)
{
switch (value) {
case TOX_GROUP_TOPIC_LOCK_ENABLED: {
- *out = TOX_GROUP_TOPIC_LOCK_ENABLED;
+ *out_enum = TOX_GROUP_TOPIC_LOCK_ENABLED;
return true;
}
case TOX_GROUP_TOPIC_LOCK_DISABLED: {
- *out = TOX_GROUP_TOPIC_LOCK_DISABLED;
+ *out_enum = TOX_GROUP_TOPIC_LOCK_DISABLED;
return true;
}
default: {
- *out = TOX_GROUP_TOPIC_LOCK_ENABLED;
+ *out_enum = TOX_GROUP_TOPIC_LOCK_ENABLED;
return false;
}
}
@@ -243,23 +243,23 @@ bool tox_group_topic_lock_unpack(Tox_Group_Topic_Lock *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *out)
+static bool tox_group_join_fail_from_int(uint32_t value, Tox_Group_Join_Fail *out_enum)
{
switch (value) {
case TOX_GROUP_JOIN_FAIL_PEER_LIMIT: {
- *out = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
+ *out_enum = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
return true;
}
case TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD: {
- *out = TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD;
+ *out_enum = TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD;
return true;
}
case TOX_GROUP_JOIN_FAIL_UNKNOWN: {
- *out = TOX_GROUP_JOIN_FAIL_UNKNOWN;
+ *out_enum = TOX_GROUP_JOIN_FAIL_UNKNOWN;
return true;
}
default: {
- *out = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
+ *out_enum = TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
return false;
}
}
@@ -272,27 +272,27 @@ bool tox_group_join_fail_unpack(Tox_Group_Join_Fail *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *out)
+static bool tox_group_mod_event_from_int(uint32_t value, Tox_Group_Mod_Event *out_enum)
{
switch (value) {
case TOX_GROUP_MOD_EVENT_KICK: {
- *out = TOX_GROUP_MOD_EVENT_KICK;
+ *out_enum = TOX_GROUP_MOD_EVENT_KICK;
return true;
}
case TOX_GROUP_MOD_EVENT_OBSERVER: {
- *out = TOX_GROUP_MOD_EVENT_OBSERVER;
+ *out_enum = TOX_GROUP_MOD_EVENT_OBSERVER;
return true;
}
case TOX_GROUP_MOD_EVENT_USER: {
- *out = TOX_GROUP_MOD_EVENT_USER;
+ *out_enum = TOX_GROUP_MOD_EVENT_USER;
return true;
}
case TOX_GROUP_MOD_EVENT_MODERATOR: {
- *out = TOX_GROUP_MOD_EVENT_MODERATOR;
+ *out_enum = TOX_GROUP_MOD_EVENT_MODERATOR;
return true;
}
default: {
- *out = TOX_GROUP_MOD_EVENT_KICK;
+ *out_enum = TOX_GROUP_MOD_EVENT_KICK;
return false;
}
}
@@ -305,35 +305,35 @@ bool tox_group_mod_event_unpack(Tox_Group_Mod_Event *val, Bin_Unpack *bu)
}
non_null()
-static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *out)
+static bool tox_group_exit_type_from_int(uint32_t value, Tox_Group_Exit_Type *out_enum)
{
switch (value) {
case TOX_GROUP_EXIT_TYPE_QUIT: {
- *out = TOX_GROUP_EXIT_TYPE_QUIT;
+ *out_enum = TOX_GROUP_EXIT_TYPE_QUIT;
return true;
}
case TOX_GROUP_EXIT_TYPE_TIMEOUT: {
- *out = TOX_GROUP_EXIT_TYPE_TIMEOUT;
+ *out_enum = TOX_GROUP_EXIT_TYPE_TIMEOUT;
return true;
}
case TOX_GROUP_EXIT_TYPE_DISCONNECTED: {
- *out = TOX_GROUP_EXIT_TYPE_DISCONNECTED;
+ *out_enum = TOX_GROUP_EXIT_TYPE_DISCONNECTED;
return true;
}
case TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED: {
- *out = TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED;
+ *out_enum = TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED;
return true;
}
case TOX_GROUP_EXIT_TYPE_KICK: {
- *out = TOX_GROUP_EXIT_TYPE_KICK;
+ *out_enum = TOX_GROUP_EXIT_TYPE_KICK;
return true;
}
case TOX_GROUP_EXIT_TYPE_SYNC_ERROR: {
- *out = TOX_GROUP_EXIT_TYPE_SYNC_ERROR;
+ *out_enum = TOX_GROUP_EXIT_TYPE_SYNC_ERROR;
return true;
}
default: {
- *out = TOX_GROUP_EXIT_TYPE_QUIT;
+ *out_enum = TOX_GROUP_EXIT_TYPE_QUIT;
return false;
}
}
diff --git a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.c b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.c
index c43e357528..b785c26732 100644
--- a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.c
+++ b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.c
@@ -67,7 +67,8 @@ void tox_pass_key_free(Tox_Pass_Key *key)
* produce the same key as was previously used. Any data encrypted with this
* module can be used as input.
*
- * The cipher text must be at least TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes in length.
+ * The cipher text must be at least TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes in
+ * length.
* The salt must be TOX_PASS_SALT_LENGTH bytes in length.
* If the passed byte arrays are smaller than required, the behaviour is
* undefined.
@@ -182,10 +183,11 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(
}
/**
- * Encrypt a plain text with a key produced by tox_pass_key_derive or tox_pass_key_derive_with_salt.
+ * Encrypt a plain text with a key produced by tox_pass_key_derive or
+ * tox_pass_key_derive_with_salt.
*
- * The output array must be at least `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long.
+ * The output array must be at least
+ * `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long.
*
* @param plaintext A byte array of length `plaintext_len`.
* @param plaintext_len The length of the plain text array. Bigger than 0.
@@ -229,8 +231,8 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t plaintext[], si
ciphertext += crypto_box_NONCEBYTES;
/* now encrypt */
- if (encrypt_data_symmetric(key->key, nonce, plaintext, plaintext_len, ciphertext)
- != plaintext_len + crypto_box_MACBYTES) {
+ const int32_t encrypted_len = encrypt_data_symmetric(key->key, nonce, plaintext, plaintext_len, ciphertext);
+ if (encrypted_len < 0 || (size_t)encrypted_len != plaintext_len + crypto_box_MACBYTES) {
SET_ERROR_PARAMETER(error, TOX_ERR_ENCRYPTION_FAILED);
return false;
}
@@ -242,9 +244,9 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t plaintext[], si
/**
* Encrypts the given data with the given passphrase.
*
- * The output array must be at least `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long. This delegates to tox_pass_key_derive and
- * tox_pass_key_encrypt.
+ * The output array must be at least
+ * `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long. This delegates
+ * to tox_pass_key_derive and tox_pass_key_encrypt.
*
* @param plaintext A byte array of length `plaintext_len`.
* @param plaintext_len The length of the plain text array. Bigger than 0.
@@ -280,7 +282,8 @@ bool tox_pass_encrypt(const uint8_t plaintext[], size_t plaintext_len, const uin
* tox_pass_key_derive or tox_pass_key_derive_with_salt.
*
* @param ciphertext A byte array of length `ciphertext_len`.
- * @param ciphertext_len The length of the cipher text array. At least TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
+ * @param ciphertext_len The length of the cipher text array. At least
+ * TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
* @param plaintext The plain text array to write the decrypted data to.
*
* @return true on success.
@@ -313,8 +316,8 @@ bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t ciphertext[], s
ciphertext += crypto_box_NONCEBYTES;
/* decrypt the ciphertext */
- if (decrypt_data_symmetric(key->key, nonce, ciphertext, decrypt_length + crypto_box_MACBYTES, plaintext)
- != decrypt_length) {
+ const int32_t decrypted_len = decrypt_data_symmetric(key->key, nonce, ciphertext, decrypt_length + crypto_box_MACBYTES, plaintext);
+ if (decrypted_len < 0 || (size_t)decrypted_len != decrypt_length) {
SET_ERROR_PARAMETER(error, TOX_ERR_DECRYPTION_FAILED);
return false;
}
@@ -326,11 +329,13 @@ bool tox_pass_key_decrypt(const Tox_Pass_Key *key, const uint8_t ciphertext[], s
/**
* Decrypts the given data with the given passphrase.
*
- * The output array must be at least `ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long. This delegates to tox_pass_key_decrypt.
+ * The output array must be at least
+ * `ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long. This
+ * delegates to tox_pass_key_decrypt.
*
* @param ciphertext A byte array of length `ciphertext_len`.
- * @param ciphertext_len The length of the cipher text array. At least TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
+ * @param ciphertext_len The length of the cipher text array. At least
+ * TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
* @param passphrase The user-provided password. Can be empty.
* @param passphrase_len The length of the password.
* @param plaintext The plain text array to write the decrypted data to.
diff --git a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
index b9691551c7..e4cf116c97 100644
--- a/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
+++ b/protocols/Tox/libtox/src/toxencryptsave/toxencryptsave.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
- * Copyright © 2016-2018 The TokTok team.
+ * Copyright © 2016-2024 The TokTok team.
* Copyright © 2013-2016 Tox Developers.
*/
@@ -165,9 +165,9 @@ typedef enum Tox_Err_Decryption {
/**
* Encrypts the given data with the given passphrase.
*
- * The output array must be at least `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long. This delegates to tox_pass_key_derive and
- * tox_pass_key_encrypt.
+ * The output array must be at least
+ * `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long. This delegates
+ * to tox_pass_key_derive and tox_pass_key_encrypt.
*
* @param plaintext A byte array of length `plaintext_len`.
* @param plaintext_len The length of the plain text array. Bigger than 0.
@@ -183,11 +183,13 @@ bool tox_pass_encrypt(const uint8_t plaintext[], size_t plaintext_len, const uin
/**
* Decrypts the given data with the given passphrase.
*
- * The output array must be at least `ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long. This delegates to tox_pass_key_decrypt.
+ * The output array must be at least
+ * `ciphertext_len - TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long. This
+ * delegates to tox_pass_key_decrypt.
*
* @param ciphertext A byte array of length `ciphertext_len`.
- * @param ciphertext_len The length of the cipher text array. At least TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
+ * @param ciphertext_len The length of the cipher text array. At least
+ * TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
* @param passphrase The user-provided password. Can be empty.
* @param passphrase_len The length of the password.
* @param plaintext The plain text array to write the decrypted data to.
@@ -215,7 +217,8 @@ bool tox_pass_decrypt(const uint8_t ciphertext[], size_t ciphertext_len, const u
* user-provided password.
*
* The Tox_Pass_Key structure is hidden in the implementation. It can be created
- * using tox_pass_key_derive or tox_pass_key_derive_with_salt and must be deallocated using tox_pass_key_free.
+ * using tox_pass_key_derive or tox_pass_key_derive_with_salt and must be
+ * deallocated using tox_pass_key_free.
*/
#ifndef TOX_PASS_KEY_DEFINED
#define TOX_PASS_KEY_DEFINED
@@ -261,10 +264,11 @@ Tox_Pass_Key *tox_pass_key_derive_with_salt(
const uint8_t salt[TOX_PASS_SALT_LENGTH], Tox_Err_Key_Derivation *error);
/**
- * Encrypt a plain text with a key produced by tox_pass_key_derive or tox_pass_key_derive_with_salt.
+ * Encrypt a plain text with a key produced by tox_pass_key_derive or
+ * tox_pass_key_derive_with_salt.
*
- * The output array must be at least `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH`
- * bytes long.
+ * The output array must be at least
+ * `plaintext_len + TOX_PASS_ENCRYPTION_EXTRA_LENGTH` bytes long.
*
* @param plaintext A byte array of length `plaintext_len`.
* @param plaintext_len The length of the plain text array. Bigger than 0.
@@ -280,7 +284,8 @@ bool tox_pass_key_encrypt(const Tox_Pass_Key *key, const uint8_t plaintext[], si
* tox_pass_key_derive or tox_pass_key_derive_with_salt.
*
* @param ciphertext A byte array of length `ciphertext_len`.
- * @param ciphertext_len The length of the cipher text array. At least TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
+ * @param ciphertext_len The length of the cipher text array. At least
+ * TOX_PASS_ENCRYPTION_EXTRA_LENGTH.
* @param plaintext The plain text array to write the decrypted data to.
*
* @return true on success.
@@ -315,7 +320,8 @@ typedef enum Tox_Err_Get_Salt {
* produce the same key as was previously used. Any data encrypted with this
* module can be used as input.
*
- * The cipher text must be at least TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes in length.
+ * The cipher text must be at least TOX_PASS_ENCRYPTION_EXTRA_LENGTH bytes in
+ * length.
* The salt must be TOX_PASS_SALT_LENGTH bytes in length.
* If the passed byte arrays are smaller than required, the behaviour is
* undefined.