summaryrefslogtreecommitdiff
path: root/toxcore/group.c
AgeCommit message (Collapse)Author
2020-05-05refactor: Remove multi-declarators entirely.iphydf
We no longer allow `int a, b;`. In the few cases where we used it, we instead better * limit the scope of the identifier (e.g. in a for-init-decl) * split the line and have 2 separate declarators, because the identifiers designate different types of things (e.g. friend numbers and group numbers).
2020-05-05refactor: Disallow multiple initialised declarators per decl.iphydf
We no longer allow: ```c int a = 0, b = 0; int a[3], b[3]; int a, *b; ``` But we do still allow (for now): ```c int a, b; ```
2020-05-02Add a check that we don't have any unused functions.iphydf
This check puts all of our code in a C++ anonymous namespace, which is effectively making all functions `static`. This allows the compiler to determine that a function is unused, so we can delete it.
2020-03-18clear out old conference connectionszugz (tox)
This may fix problems with very large conferences. Sadly, it seems infeasible to test large conferences on one machine, so this is entirely theoretical.
2020-03-18Add "member" invite responsezugz (tox)
This allows invitations to work in the case that the invitee is already in the group, which can happen if the group becomes split. Such an invitation is automatically accepted, leading to the peers becoming connected in the group and sharing peer lists.
2020-03-15clean groups codezugz (tox)
* make static functions return bool rather than int to indicate success * add peer_in_list() to factor out uniformity over peer and frozen lists * reduce repetition in send_lossy_all_close * rename 'close' to 'connections' * use uint32_t for peernumber (in accord with tox.c) * explain persistence in tox_conference_get_chatlist documentation * clarify "connectedness" in group API documentation * clarify that tox_conference_peer_count counts only online peers * refactor variously
2020-03-14Standardise on having a comma at the end of enums.iphydf
Most of our enums already have one. Some didn't. Tokstyle is going to require commas at the end of enumerator lists in enum definitions.
2020-03-14Fix up comments a bit to start being more uniform.iphydf
Tokstyle (check-cimple) will start enforcing comment formats at some point. It will not support arbitrary stuff in comments, and will parse them. The result can then be semantically analysed.
2020-03-14Use spdx license identifier instead of GPL blurb.iphydf
2020-03-14use -1 rather than ~0 in unsigned integer typeszugz (tox)
Using ~0 involves a bitwise operation on int, so depends on the internal representation of signed integers.
2020-01-22handle message_number wraparoundzugz (tox)
2020-01-22workaround for message number saving (fixes #961)zugz (tox)
Put a future message number into the save file. Peers require the message numbers of messages we send to increase monotonically. If we save the current message number, then send further messages, then quit without saving (e.g. due to a crash), and then resume from the old save data, then monotonicity will fail. This commit works around this problem by introducing an offset when the current message number, so that even in the above circumstance, as long as fewer messages than the offset were sent between saving and reloading, the sent message numbers will increase monotonically. The choice of offset is a balance between wanting it to be large enough that there is room for plenty of messages to be sent in the above scenario, and wanting to avoid the following potential problem: if we repeatedly save and reload without sending any further messages, then the message number may increase so far that peers will interpret an eventual message as being old. This is not conceivably a practical issue for the 32bit lossless message numbers, but is a concern for the 16bit lossy message numbers.
2020-01-22refactorzugz (tox)
2019-11-17Fix miscellaneous small problems with groups:zugz (tox)
* unset global status callback in kill_groupchats * avoid dangling friend connections * fix num_introducer_connections leak * stop trying to keep connection alive on freeze * avoid relaying lossless messages back to sender where possible * avoid sending gratuitous online packets
2019-08-04fix overflow in peer nick lensudden6
2019-08-04fix missing group title length checksudden6
This fixes a buffer overflow when a malformed *.tox save file is loaded.
2019-05-19add configurable limit on number of stored frozen peerszugz (tox)
2019-02-10Expose api functions for enabling and disabling AV in AV groupszugz (tox)
A group loaded from a savefile starts with AV disabled.
2019-01-12Add some const qualifierszugz (tox)
(Implementing suggestions of sudden6)
2019-01-07Avoid sending group messages to a peer before we have its group numberzugz (tox)
2019-01-06Improve handling of peers entering and leaving conferenceszugz (tox)
* send freeze packet on quit * delete existing peers with same real_pk on adding a peer * record actual number of conference peers saved
2019-01-05Expose offline conference peers in APIzugz (tox)
2018-11-29Implement conferences savingzugz (tox)
* add global friend_connection status callback, used for group rejoining * stop leaving groups on killing tox
2018-11-23Return TOX_ERR_CONFERENCE_SEND_MESSAGE_NO_CONNECTION if we are not connected ↵zugz (tox)
to any peers
2018-10-20Make saving and loading the responsibility of Tox rather than Messengerzugz (tox)
2018-09-20Send rejoin packets on conference disconnectionzugz (tox)
We were mistakenly not making a rejoin attempt on freezing connections due to all closest connections going down. This fixes that, and tweaks the test. I've still only done tens rather than hundreds of tests, but I'm fairly confident that the conference test now consistently passes.
2018-09-05Add mechanism for recovering from disconnections in conferenceszugz
* add freezing and unfreezing of peers * add rejoin packet * revise handling of temporary invited connections * rename "peer kill" packet to "peer leave" packet * test rejoining in conference test * use custom clock in conference test
2018-08-26Update copyright to 2018.iphydf
2018-08-25fix leave callback calling in del_groupchatzugz (tox)
2018-08-16Use per-instance `Mono_Time` for Messenger and onion.iphydf
2018-08-13Avoid passing -1 as friend connection to new groups.iphydf
Somehow it still works because the lower levels can deal with inconsistent/broken state, but this lets us avoid that broken state in the first place. If a friend connection doesn't exist, we don't add it to our group.
2018-08-12Make `conferences_object` properly typed.iphydf
The void pointer here only adds opportunity to introduce bugs and doesn't actually make things more layered. It's just the code lying about being layered while it's actually spaghetti.
2018-08-12add callback for successful connection to a conferencezugz (tox)
2018-08-11Split out conference type (text/av) from identifier.iphydf
2018-08-10Use the crypto random functions instead of `rand()`.iphydf
Presumably the uses of `rand()` were fine because they were not used in security-sensitive places, but having to think about whether a crappy RNG is acceptable in each situation requires effort that could better be spent elsewhere. Also, this means that once we have a custom deterministic RNG for testing, that RNG is used everywhere, so all the code is deterministic. It also allowed us to delete a system-specific function that wasn't used anywhere except in a call to `srand()`.
2018-08-02Fix problems with initial connections and name-setting in conferenceszugz
* test names in conference_test * raise error on attempt to invite friend to group before we are connected * revise handling of temporary invited connections We are now careful not to prematurely delete a connection to a peer established during the invitation process; namely, before we have sufficient other connections and have confirmed that we have an alternative route to the peer. * process out-of-order messages from a peer * don't reset names when handling a Peer Response
2018-07-21Reduce nesting by doing more early returns on error.iphydf
This almost entirely avoids any else-after-return in toxcore. One case is left, and that one is more readable this way. Why no else after return: https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return Why exemptions exist: https://blog.mozilla.org/nnethercote/2009/08/31/no-else-after-return-considered-harmful/
2018-07-18Use enums for group packet types.iphydf
Also moved some macros up to the beginning of `group.c`. This change brings us closer to the PGC PR.
2018-07-13Add conference_by_uid and conference_get_uid functions.iphydf
These are useful once we have persistent group chats, so clients can store data associated with this permanent group identifier.
2018-07-12Limit number of group chats to 65536.iphydf
By changing numchats from uint32_t to uint16_t. This is done in PGC. This PR is making that change in master to reduce the diff in the PGC branch. Also: * Inverted groupnumber_not_valid and renamed to is_groupnumber_valid. * Renamed realloc_groupchats to realloc_conferences and made it return bool. * Added setup_conference function that currently just zeroes the conference structure but later will initialise more values. * Made some `i` iterator variables local to the for-loop using for-init-decl. This is also done in PGC.
2018-07-12Use named function types for group callbacks.iphydf
Also some other cleanups. This PR means that future PRs, i.e. the PGC PR, must not break the rules established here.
2018-07-09Factor out time keeping code into its own module: mono_time.c.iphydf
It turns out, `unix_time` is also monotonic, and is used as such, so I've renamed the new functions to `mono_time_*`. 2018-07-08: ``` 00:01 <@irungentoo> the idea used to be that the unix_time() function could go backward in time but I think I might have started using it like if it could not after I changed it so that it would never go back in time ```
2018-07-07Call the "peer leaves" callback only once on group delete.iphydf
We used to pass the actual peer numbers of peers leaving, but we no longer know these in the PGC world, so we don't pass them anymore.
2018-05-20Move system header includes from network.h to network.ciphydf
2018-02-27Remove deprecated conference namelist change callback.iphydf
2018-02-27Change default username to empty stringtox-user
Fixes #768
2018-02-20Make the "persistent conference" callback changes new functions.iphydf
We can now revert the changes to the callbacks and keep supporting them until clients have moved off them.
2018-02-20make groupnumber uint32_tsudden6
fixes #606
2018-02-17Send 0 as peer number in CHANGE_OCCURRED group event.iphydf
2018-02-09Adopt the "change occurred" API change from isotoxin-groupchat.iphydf
The logic and behaviour remain the same, but PEER_EXIT and PEER_JOIN are merged into LIST_CHANGED. This allows clients to take a first step to adapt to the API change without us having to actually submit the full change, yet.