Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace
640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. 6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) 5047ae5a2 chore: make the source tarball exhibit the old behavior 14804a4b8 chore: Fix sonar-scan CI action. e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project. 3accade67 chore: Fix CI, disabling some tests that no longer run on CI. ef8d767e6 cleanup: Fix comment formatting errors. 34ec822da cleanup: Fix some clang-19 format warnings. 40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes. f81e30679 refactor: Use per-parameter nullability annotations. REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
@@ -115,12 +115,10 @@ typedef enum Group_Message_Ack_Type {
|
||||
/** @brief Returns the GC_Connection object associated with `peer_number`.
|
||||
* Returns null if peer_number does not designate a valid peer.
|
||||
*/
|
||||
non_null()
|
||||
GC_Connection *get_gc_connection(const GC_Chat *chat, int peer_number);
|
||||
GC_Connection *_Nullable get_gc_connection(const GC_Chat *_Nonnull chat, int peer_number);
|
||||
|
||||
/** @brief Returns the jenkins hash of a 32 byte public encryption key. */
|
||||
non_null()
|
||||
uint32_t gc_get_pk_jenkins_hash(const uint8_t *public_key);
|
||||
uint32_t gc_get_pk_jenkins_hash(const uint8_t *_Nonnull public_key);
|
||||
|
||||
/** @brief Check if peer with the public encryption key is in peer list.
|
||||
*
|
||||
@@ -129,8 +127,7 @@ uint32_t gc_get_pk_jenkins_hash(const uint8_t *public_key);
|
||||
*
|
||||
* If `confirmed` is true the peer number will only be returned if the peer is confirmed.
|
||||
*/
|
||||
non_null()
|
||||
int get_peer_number_of_enc_pk(const GC_Chat *chat, const uint8_t *public_enc_key, bool confirmed);
|
||||
int get_peer_number_of_enc_pk(const GC_Chat *_Nonnull chat, const uint8_t *_Nonnull public_enc_key, bool confirmed);
|
||||
|
||||
/** @brief Encrypts `data` of size `length` using the peer's shared key and a new nonce.
|
||||
*
|
||||
@@ -142,12 +139,10 @@ int get_peer_number_of_enc_pk(const GC_Chat *chat, const uint8_t *public_enc_key
|
||||
* Return -2 if malloc fails.
|
||||
* Return -3 if encryption fails.
|
||||
*/
|
||||
non_null(1, 2, 3, 4, 5, 6) nullable(8)
|
||||
int group_packet_wrap(
|
||||
const Logger *log, const Memory *mem, const Random *rng, const uint8_t *self_pk, const uint8_t *shared_key, uint8_t *packet,
|
||||
uint16_t packet_size, const uint8_t *data, uint16_t length, uint64_t message_id,
|
||||
const Logger *_Nonnull log, const Memory *_Nonnull mem, const Random *_Nonnull rng, const uint8_t *_Nonnull self_pk, const uint8_t *_Nonnull shared_key, uint8_t *_Nonnull packet,
|
||||
uint16_t packet_size, const uint8_t *_Nullable data, uint16_t length, uint64_t message_id,
|
||||
uint8_t gp_packet_type, Net_Packet_Type net_packet_type);
|
||||
|
||||
/** @brief Returns the size of a wrapped/encrypted packet with a plain size of `length`.
|
||||
*
|
||||
* `packet_type` should be either NET_PACKET_GC_LOSSY or NET_PACKET_GC_LOSSLESS.
|
||||
@@ -166,10 +161,8 @@ uint16_t gc_get_wrapped_packet_size(uint16_t length, Net_Packet_Type packet_type
|
||||
* Returns -4 if the sender does not have permission to speak.
|
||||
* Returns -5 if the packet fails to send.
|
||||
*/
|
||||
non_null(1, 2) nullable(5)
|
||||
int gc_send_message(const GC_Chat *chat, const uint8_t *message, uint16_t length, uint8_t type,
|
||||
uint32_t *message_id);
|
||||
|
||||
int gc_send_message(const GC_Chat *_Nonnull chat, const uint8_t *_Nonnull message, uint16_t length, uint8_t type,
|
||||
uint32_t *_Nullable message_id);
|
||||
/** @brief Sends a private message to peer_id.
|
||||
*
|
||||
* `length` must not exceed MAX_GC_MESSAGE_SIZE and must not be equal to zero.
|
||||
@@ -182,10 +175,8 @@ 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(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, uint32_t *message_id);
|
||||
|
||||
int gc_send_private_message(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id, uint8_t type, const uint8_t *_Nonnull message,
|
||||
uint16_t length, uint32_t *_Nullable message_id);
|
||||
/** @brief Sends a custom packet to the group. If lossless is true, the packet will be lossless.
|
||||
*
|
||||
* `length` must not exceed MAX_GC_MESSAGE_SIZE and must not be equal to zero.
|
||||
@@ -195,8 +186,7 @@ int gc_send_private_message(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t typ
|
||||
* Returns -2 if the message pointer is NULL or length is zero.
|
||||
* 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);
|
||||
int gc_send_custom_packet(const GC_Chat *_Nonnull chat, bool lossless, const uint8_t *_Nonnull data, uint16_t length);
|
||||
|
||||
/** @brief Sends a custom private packet to the peer designated by peer_id.
|
||||
*
|
||||
@@ -208,9 +198,7 @@ int gc_send_custom_packet(const GC_Chat *chat, bool lossless, const uint8_t *dat
|
||||
* @retval -3 if the supplied peer_id does not designate a valid peer.
|
||||
* @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,
|
||||
uint16_t length);
|
||||
int gc_send_custom_private_packet(const GC_Chat *_Nonnull chat, bool lossless, GC_Peer_Id peer_id, const uint8_t *_Nonnull message, uint16_t length);
|
||||
|
||||
/** @brief Sets ignore for peer_id.
|
||||
*
|
||||
@@ -218,8 +206,7 @@ int gc_send_custom_private_packet(const GC_Chat *chat, bool lossless, GC_Peer_Id
|
||||
* Returns -1 if the peer_id is invalid.
|
||||
* Returns -2 if the caller attempted to ignore himself.
|
||||
*/
|
||||
non_null()
|
||||
int gc_set_ignore(const GC_Chat *chat, GC_Peer_Id peer_id, bool ignore);
|
||||
int gc_set_ignore(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id, bool ignore);
|
||||
|
||||
/** @brief Sets the group topic and broadcasts it to the group.
|
||||
*
|
||||
@@ -231,36 +218,29 @@ int gc_set_ignore(const GC_Chat *chat, GC_Peer_Id peer_id, bool ignore);
|
||||
* Returns -3 if the packet cannot be created or signing fails.
|
||||
* Returns -4 if the packet fails
|
||||
*/
|
||||
non_null(1) nullable(2)
|
||||
int gc_set_topic(GC_Chat *chat, const uint8_t *topic, uint16_t length);
|
||||
|
||||
int gc_set_topic(GC_Chat *_Nonnull chat, const uint8_t *_Nullable topic, uint16_t length);
|
||||
/** @brief Copies the group topic to `topic`. If topic is null this function has no effect.
|
||||
*
|
||||
* Call `gc_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 topic callback.
|
||||
*/
|
||||
non_null(1) nullable(2)
|
||||
void gc_get_topic(const GC_Chat *chat, uint8_t *topic);
|
||||
|
||||
void gc_get_topic(const GC_Chat *_Nonnull chat, uint8_t *_Nullable topic);
|
||||
/** @brief Returns the topic length.
|
||||
*
|
||||
* The return value is equal to the `length` agument received by the last topic callback.
|
||||
*/
|
||||
non_null()
|
||||
uint16_t gc_get_topic_size(const GC_Chat *chat);
|
||||
uint16_t gc_get_topic_size(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Copies group name to `group_name`. If `group_name` is null this function has no effect.
|
||||
*
|
||||
* Call `gc_get_group_name_size` to determine the allocation size for the `group_name`
|
||||
* parameter.
|
||||
*/
|
||||
non_null()
|
||||
void gc_get_group_name(const GC_Chat *chat, uint8_t *group_name);
|
||||
void gc_get_group_name(const GC_Chat *_Nonnull chat, uint8_t *_Nonnull group_name);
|
||||
|
||||
/** @brief Returns the group name length. */
|
||||
non_null()
|
||||
uint16_t gc_get_group_name_size(const GC_Chat *chat);
|
||||
uint16_t gc_get_group_name_size(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Copies the group password to password.
|
||||
*
|
||||
@@ -271,40 +251,34 @@ uint16_t gc_get_group_name_size(const GC_Chat *chat);
|
||||
*
|
||||
* The data received is equal to the data received by the last password callback.
|
||||
*/
|
||||
non_null()
|
||||
void gc_get_password(const GC_Chat *chat, uint8_t *password);
|
||||
void gc_get_password(const GC_Chat *_Nonnull chat, uint8_t *_Nonnull password);
|
||||
|
||||
/** @brief Returns the group password length. */
|
||||
non_null()
|
||||
uint16_t gc_get_password_size(const GC_Chat *chat);
|
||||
uint16_t gc_get_password_size(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns the group privacy state.
|
||||
*
|
||||
* The value returned is equal to the data receieved by the last privacy_state callback.
|
||||
*/
|
||||
non_null()
|
||||
Group_Privacy_State gc_get_privacy_state(const GC_Chat *chat);
|
||||
Group_Privacy_State gc_get_privacy_state(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns the group topic lock state.
|
||||
*
|
||||
* The value returned is equal to the data received by the last last topic_lock callback.
|
||||
*/
|
||||
non_null()
|
||||
Group_Topic_Lock gc_get_topic_lock_state(const GC_Chat *chat);
|
||||
Group_Topic_Lock gc_get_topic_lock_state(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns the group voice state.
|
||||
*
|
||||
* The value returned is equal to the data received by the last voice_state callback.
|
||||
*/
|
||||
non_null()
|
||||
Group_Voice_State gc_get_voice_state(const GC_Chat *chat);
|
||||
Group_Voice_State gc_get_voice_state(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns the group peer limit.
|
||||
*
|
||||
* The value returned is equal to the data receieved by the last peer_limit callback.
|
||||
*/
|
||||
non_null()
|
||||
uint16_t gc_get_max_peers(const GC_Chat *chat);
|
||||
uint16_t gc_get_max_peers(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Sets your own nick to `nick`.
|
||||
*
|
||||
@@ -317,34 +291,28 @@ uint16_t gc_get_max_peers(const GC_Chat *chat);
|
||||
* Returns -3 if the length is zero or nick is a NULL pointer.
|
||||
* Returns -4 if the packet fails to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_set_self_nick(const Messenger *m, int group_number, const uint8_t *nick, uint16_t length);
|
||||
int gc_set_self_nick(const Messenger *_Nonnull m, int group_number, const uint8_t *_Nonnull nick, uint16_t length);
|
||||
|
||||
/** @brief Copies your own name to `nick`.
|
||||
*
|
||||
* If `nick` is null this function has no effect.
|
||||
*/
|
||||
non_null()
|
||||
void gc_get_self_nick(const GC_Chat *chat, uint8_t *nick);
|
||||
void gc_get_self_nick(const GC_Chat *_Nonnull chat, uint8_t *_Nonnull nick);
|
||||
|
||||
/** @brief Return your own nick length.
|
||||
*
|
||||
* If no nick was set before calling this function it will return 0.
|
||||
*/
|
||||
non_null()
|
||||
uint16_t gc_get_self_nick_size(const GC_Chat *chat);
|
||||
uint16_t gc_get_self_nick_size(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns your own group role. */
|
||||
non_null()
|
||||
Group_Role gc_get_self_role(const GC_Chat *chat);
|
||||
Group_Role gc_get_self_role(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Return your own status. */
|
||||
non_null()
|
||||
uint8_t gc_get_self_status(const GC_Chat *chat);
|
||||
uint8_t gc_get_self_status(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns your own peer id. */
|
||||
non_null()
|
||||
GC_Peer_Id gc_get_self_peer_id(const GC_Chat *chat);
|
||||
GC_Peer_Id gc_get_self_peer_id(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Copies self public key to `public_key`.
|
||||
*
|
||||
@@ -354,9 +322,7 @@ GC_Peer_Id gc_get_self_peer_id(const GC_Chat *chat);
|
||||
* exit the group. This key is the only way for other peers to reliably identify
|
||||
* us across client restarts.
|
||||
*/
|
||||
non_null(1) nullable(2)
|
||||
void gc_get_self_public_key(const GC_Chat *chat, uint8_t *public_key);
|
||||
|
||||
void gc_get_self_public_key(const GC_Chat *_Nonnull chat, uint8_t *_Nullable public_key);
|
||||
/** @brief Copies nick designated by `peer_id` to `name`.
|
||||
*
|
||||
* Call `gc_get_peer_nick_size` to determine the allocation size for the `name` parameter.
|
||||
@@ -366,17 +332,14 @@ void gc_get_self_public_key(const GC_Chat *chat, uint8_t *public_key);
|
||||
* Returns true on success.
|
||||
* Returns false if peer_id is invalid.
|
||||
*/
|
||||
non_null(1) nullable(3)
|
||||
bool gc_get_peer_nick(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t *name);
|
||||
|
||||
bool gc_get_peer_nick(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id, uint8_t *_Nullable name);
|
||||
/** @brief Returns the length of the nick for the peer designated by `peer_id`.
|
||||
* Returns -1 if peer_id is invalid.
|
||||
*
|
||||
* The value returned is equal to the `length` argument received by the last
|
||||
* nick_change callback.
|
||||
*/
|
||||
non_null()
|
||||
int gc_get_peer_nick_size(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
int gc_get_peer_nick_size(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Copies peer_id's public key to `public_key`.
|
||||
*
|
||||
@@ -390,14 +353,11 @@ int gc_get_peer_nick_size(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
* Returns -1 if peer_id is invalid or doesn't correspond to a valid peer connection.
|
||||
* Returns -2 if `public_key` is null.
|
||||
*/
|
||||
non_null(1) nullable(3)
|
||||
int gc_get_peer_public_key_by_peer_id(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t *public_key);
|
||||
|
||||
int gc_get_peer_public_key_by_peer_id(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id, uint8_t *_Nullable public_key);
|
||||
/** @brief Returns the length of the IP address for the peer designated by `peer_id`.
|
||||
* Returns -1 if peer_id is invalid.
|
||||
*/
|
||||
non_null()
|
||||
int gc_get_peer_ip_address_size(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
int gc_get_peer_ip_address_size(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Copies peer_id's IP address to `ip_addr`.
|
||||
*
|
||||
@@ -413,9 +373,7 @@ int gc_get_peer_ip_address_size(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
* Returns -1 if peer_id is invalid or doesn't correspond to a valid peer connection.
|
||||
* Returns -2 if `ip_addr` is null.
|
||||
*/
|
||||
non_null(1) nullable(3)
|
||||
int gc_get_peer_ip_address(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t *ip_addr);
|
||||
|
||||
int gc_get_peer_ip_address(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id, uint8_t *_Nullable ip_addr);
|
||||
/** @brief Gets the connection status for peer associated with `peer_id`.
|
||||
*
|
||||
* If `peer_id` designates ourself, the return value indicates whether we're capable
|
||||
@@ -427,8 +385,7 @@ int gc_get_peer_ip_address(const GC_Chat *chat, GC_Peer_Id peer_id, uint8_t *ip_
|
||||
*
|
||||
* Note: Return values must correspond to Tox_Connection enum in API.
|
||||
*/
|
||||
non_null()
|
||||
unsigned int gc_get_peer_connection_status(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
unsigned int gc_get_peer_connection_status(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Sets the caller's status to `status`.
|
||||
*
|
||||
@@ -436,8 +393,7 @@ unsigned int gc_get_peer_connection_status(const GC_Chat *chat, GC_Peer_Id peer_
|
||||
* Returns -1 if the group_number is invalid.
|
||||
* Returns -2 if the packet failed to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_set_self_status(const Messenger *m, int group_number, Group_Peer_Status status);
|
||||
int gc_set_self_status(const Messenger *_Nonnull m, int group_number, Group_Peer_Status status);
|
||||
|
||||
/** @brief Returns the status of peer designated by `peer_id`.
|
||||
* Returns UINT8_MAX on failure.
|
||||
@@ -445,16 +401,14 @@ int gc_set_self_status(const Messenger *m, int group_number, Group_Peer_Status s
|
||||
* The status returned is equal to the last status received through the status_change
|
||||
* callback.
|
||||
*/
|
||||
non_null()
|
||||
uint8_t gc_get_status(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
uint8_t gc_get_status(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Returns the group role of peer designated by `peer_id`.
|
||||
* Returns UINT8_MAX on failure.
|
||||
*
|
||||
* The role returned is equal to the last role received through the moderation callback.
|
||||
*/
|
||||
non_null()
|
||||
uint8_t gc_get_role(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
uint8_t gc_get_role(const GC_Chat *_Nonnull chat, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Sets the role of peer_id. role must be one of: GR_MODERATOR, GR_USER, GR_OBSERVER
|
||||
*
|
||||
@@ -466,8 +420,7 @@ uint8_t gc_get_role(const GC_Chat *chat, GC_Peer_Id peer_id);
|
||||
* Returns -5 if the role failed to be set.
|
||||
* Returns -6 if the caller attempted to kick himself.
|
||||
*/
|
||||
non_null()
|
||||
int gc_set_peer_role(const Messenger *m, int group_number, GC_Peer_Id peer_id, Group_Role new_role);
|
||||
int gc_set_peer_role(const Messenger *_Nonnull m, int group_number, GC_Peer_Id peer_id, Group_Role new_role);
|
||||
|
||||
/** @brief Sets the group password and distributes the new shared state to the group.
|
||||
*
|
||||
@@ -481,9 +434,7 @@ int gc_set_peer_role(const Messenger *m, int group_number, GC_Peer_Id peer_id, G
|
||||
* Returns -3 if the packet failed to send.
|
||||
* Returns -4 if malloc failed.
|
||||
*/
|
||||
non_null(1) nullable(2)
|
||||
int gc_founder_set_password(GC_Chat *chat, const uint8_t *password, uint16_t password_length);
|
||||
|
||||
int gc_founder_set_password(GC_Chat *_Nonnull chat, const uint8_t *_Nullable password, uint16_t password_length);
|
||||
/** @brief Sets the topic lock and distributes the new shared state to the group.
|
||||
*
|
||||
* When the topic lock is enabled, only the group founder and moderators may set the topic.
|
||||
@@ -499,8 +450,7 @@ int gc_founder_set_password(GC_Chat *chat, const uint8_t *password, uint16_t pas
|
||||
* Returns -5 if the topic lock could not be set.
|
||||
* Returns -6 if the packet failed to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_founder_set_topic_lock(const Messenger *m, int group_number, Group_Topic_Lock new_lock_state);
|
||||
int gc_founder_set_topic_lock(const Messenger *_Nonnull m, int group_number, Group_Topic_Lock new_lock_state);
|
||||
|
||||
/** @brief Sets the group privacy state and distributes the new shared state to the group.
|
||||
*
|
||||
@@ -516,8 +466,7 @@ int gc_founder_set_topic_lock(const Messenger *m, int group_number, Group_Topic_
|
||||
* Returns -4 if the privacy state could not be set.
|
||||
* Returns -5 if the packet failed to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_founder_set_privacy_state(const Messenger *m, int group_number, Group_Privacy_State new_privacy_state);
|
||||
int gc_founder_set_privacy_state(const Messenger *_Nonnull m, int group_number, Group_Privacy_State new_privacy_state);
|
||||
|
||||
/** @brief Sets the group voice state and distributes the new shared state to the group.
|
||||
*
|
||||
@@ -533,8 +482,7 @@ int gc_founder_set_privacy_state(const Messenger *m, int group_number, Group_Pri
|
||||
* Returns -4 if the voice state could not be set.
|
||||
* Returns -5 if the packet failed to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_founder_set_voice_state(const Messenger *m, int group_number, Group_Voice_State new_voice_state);
|
||||
int gc_founder_set_voice_state(const Messenger *_Nonnull m, int group_number, Group_Voice_State new_voice_state);
|
||||
|
||||
/** @brief Sets the peer limit to maxpeers and distributes the new shared state to the group.
|
||||
*
|
||||
@@ -545,8 +493,7 @@ int gc_founder_set_voice_state(const Messenger *m, int group_number, Group_Voice
|
||||
* Returns -2 if the peer limit could not be set.
|
||||
* Returns -3 if the packet failed to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_founder_set_max_peers(GC_Chat *chat, uint16_t max_peers);
|
||||
int gc_founder_set_max_peers(GC_Chat *_Nonnull chat, uint16_t max_peers);
|
||||
|
||||
/** @brief Removes peer designated by `peer_id` from peer list and sends a broadcast instructing
|
||||
* all other peers to remove the peer from their peerlist as well.
|
||||
@@ -561,51 +508,42 @@ int gc_founder_set_max_peers(GC_Chat *chat, uint16_t max_peers);
|
||||
* Returns -5 if the packet failed to send.
|
||||
* Returns -6 if the caller attempted to kick himself.
|
||||
*/
|
||||
non_null()
|
||||
int gc_kick_peer(const Messenger *m, int group_number, GC_Peer_Id peer_id);
|
||||
int gc_kick_peer(const Messenger *_Nonnull m, int group_number, GC_Peer_Id peer_id);
|
||||
|
||||
/** @brief Copies the chat_id to dest. If dest is null this function has no effect.
|
||||
*
|
||||
* `dest` should have room for at least CHAT_ID_SIZE bytes.
|
||||
*/
|
||||
non_null(1) nullable(2)
|
||||
void gc_get_chat_id(const GC_Chat *chat, uint8_t *dest);
|
||||
|
||||
void gc_get_chat_id(const GC_Chat *_Nonnull chat, uint8_t *_Nullable dest);
|
||||
/** Group callbacks */
|
||||
non_null(1) nullable(2) void gc_callback_message(const Messenger *m, gc_message_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_private_message(const Messenger *m, gc_private_message_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_custom_packet(const Messenger *m, gc_custom_packet_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_custom_private_packet(const Messenger *m,
|
||||
gc_custom_private_packet_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_moderation(const Messenger *m, gc_moderation_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_nick_change(const Messenger *m, gc_nick_change_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_status_change(const Messenger *m, gc_status_change_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_topic_change(const Messenger *m, gc_topic_change_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_peer_limit(const Messenger *m, gc_peer_limit_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_privacy_state(const Messenger *m, gc_privacy_state_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_topic_lock(const Messenger *m, gc_topic_lock_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_password(const Messenger *m, gc_password_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_peer_join(const Messenger *m, gc_peer_join_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_peer_exit(const Messenger *m, gc_peer_exit_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_self_join(const Messenger *m, gc_self_join_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_rejected(const Messenger *m, gc_rejected_cb *function);
|
||||
non_null(1) nullable(2) void gc_callback_voice_state(const Messenger *m, gc_voice_state_cb *function);
|
||||
void gc_callback_message(const Messenger *_Nonnull m, gc_message_cb *_Nullable function);
|
||||
void gc_callback_private_message(const Messenger *_Nonnull m, gc_private_message_cb *_Nullable function);
|
||||
void gc_callback_custom_packet(const Messenger *_Nonnull m, gc_custom_packet_cb *_Nullable function);
|
||||
void gc_callback_custom_private_packet(const Messenger *_Nonnull m,
|
||||
gc_custom_private_packet_cb *_Nullable function);
|
||||
void gc_callback_moderation(const Messenger *_Nonnull m, gc_moderation_cb *_Nullable function);
|
||||
void gc_callback_nick_change(const Messenger *_Nonnull m, gc_nick_change_cb *_Nullable function);
|
||||
void gc_callback_status_change(const Messenger *_Nonnull m, gc_status_change_cb *_Nullable function);
|
||||
void gc_callback_topic_change(const Messenger *_Nonnull m, gc_topic_change_cb *_Nullable function);
|
||||
void gc_callback_peer_limit(const Messenger *_Nonnull m, gc_peer_limit_cb *_Nullable function);
|
||||
void gc_callback_privacy_state(const Messenger *_Nonnull m, gc_privacy_state_cb *_Nullable function);
|
||||
void gc_callback_topic_lock(const Messenger *_Nonnull m, gc_topic_lock_cb *_Nullable function);
|
||||
void gc_callback_password(const Messenger *_Nonnull m, gc_password_cb *_Nullable function);
|
||||
void gc_callback_peer_join(const Messenger *_Nonnull m, gc_peer_join_cb *_Nullable function);
|
||||
void gc_callback_peer_exit(const Messenger *_Nonnull m, gc_peer_exit_cb *_Nullable function);
|
||||
void gc_callback_self_join(const Messenger *_Nonnull m, gc_self_join_cb *_Nullable function);
|
||||
void gc_callback_rejected(const Messenger *_Nonnull m, gc_rejected_cb *_Nullable function);
|
||||
void gc_callback_voice_state(const Messenger *_Nonnull m, gc_voice_state_cb *_Nullable function);
|
||||
|
||||
/** @brief The main loop. Should be called with every Messenger iteration. */
|
||||
non_null(1) nullable(2)
|
||||
void do_gc(GC_Session *c, void *userdata);
|
||||
|
||||
void do_gc(GC_Session *_Nonnull c, void *_Nullable userdata);
|
||||
/**
|
||||
* Make sure that DHT is initialized before calling this.
|
||||
* Returns a NULL pointer on failure.
|
||||
*/
|
||||
nullable(1)
|
||||
GC_Session *new_dht_groupchats(Messenger *m);
|
||||
|
||||
GC_Session *_Nullable new_dht_groupchats(Messenger *_Nullable m);
|
||||
/** @brief Cleans up groupchat structures and calls `gc_group_exit()` for every group chat */
|
||||
nullable(1)
|
||||
void kill_dht_groupchats(GC_Session *c);
|
||||
|
||||
void kill_dht_groupchats(GC_Session *_Nullable c);
|
||||
/** @brief Loads a previously saved group and attempts to join it.
|
||||
*
|
||||
* `bu` is the packed group info.
|
||||
@@ -613,14 +551,12 @@ void kill_dht_groupchats(GC_Session *c);
|
||||
* Returns group_number on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
non_null()
|
||||
int gc_group_load(GC_Session *c, Bin_Unpack *bu);
|
||||
int gc_group_load(GC_Session *_Nonnull c, Bin_Unpack *_Nonnull bu);
|
||||
|
||||
/**
|
||||
* @brief Saves info from `chat` to `bp` in binary format.
|
||||
*/
|
||||
non_null()
|
||||
void gc_group_save(const GC_Chat *chat, Bin_Pack *bp);
|
||||
void gc_group_save(const GC_Chat *_Nonnull chat, Bin_Pack *_Nonnull bp);
|
||||
|
||||
/** @brief Creates a new group and adds it to the group sessions group array.
|
||||
*
|
||||
@@ -635,10 +571,7 @@ void gc_group_save(const GC_Chat *chat, Bin_Pack *bp);
|
||||
* Return -4 if the group state fails to initialize.
|
||||
* Return -5 if the Messenger friend connection fails to initialize.
|
||||
*/
|
||||
non_null()
|
||||
int gc_group_add(GC_Session *c, Group_Privacy_State privacy_state, const uint8_t *group_name,
|
||||
uint16_t group_name_length,
|
||||
const uint8_t *nick, size_t nick_length);
|
||||
int gc_group_add(GC_Session *_Nonnull c, Group_Privacy_State privacy_state, const uint8_t *_Nonnull group_name, uint16_t group_name_length, const uint8_t *_Nonnull nick, size_t nick_length);
|
||||
|
||||
/** @brief Joins a group designated by `chat_id`.
|
||||
*
|
||||
@@ -656,17 +589,14 @@ int gc_group_add(GC_Session *c, Group_Privacy_State privacy_state, const uint8_t
|
||||
* Return -5 if there is an error setting the group password.
|
||||
* Return -6 if the Messenger friend connection fails to initialize.
|
||||
*/
|
||||
non_null(1, 2, 3) nullable(5)
|
||||
int gc_group_join(GC_Session *c, const uint8_t *chat_id, const uint8_t *nick, size_t nick_length, const uint8_t *passwd,
|
||||
int gc_group_join(GC_Session *_Nonnull c, const uint8_t *_Nonnull chat_id, const uint8_t *_Nonnull nick, size_t nick_length, const uint8_t *_Nullable passwd,
|
||||
uint16_t passwd_len);
|
||||
|
||||
/** @brief Disconnects from all peers in a group but saves the group state for later use.
|
||||
*
|
||||
* Return true on sucess.
|
||||
* Return false if the group handler object or chat object is null.
|
||||
*/
|
||||
non_null()
|
||||
bool gc_disconnect_from_group(const GC_Session *c, GC_Chat *chat);
|
||||
bool gc_disconnect_from_group(const GC_Session *_Nonnull c, GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Disconnects from all peers in a group and attempts to reconnect.
|
||||
*
|
||||
@@ -676,9 +606,7 @@ bool gc_disconnect_from_group(const GC_Session *c, GC_Chat *chat);
|
||||
* Returns -1 if the group handler object or chat object is null.
|
||||
* Returns -2 if the Messenger friend connection fails to initialize.
|
||||
*/
|
||||
non_null(1, 2) nullable(3)
|
||||
int gc_rejoin_group(GC_Session *c, GC_Chat *chat, const uint8_t *passwd, uint16_t passwd_len);
|
||||
|
||||
int gc_rejoin_group(GC_Session *_Nonnull c, GC_Chat *_Nonnull chat, const uint8_t *_Nullable passwd, uint16_t passwd_len);
|
||||
/** @brief Joins a group using the invite data received in a friend's group invite.
|
||||
*
|
||||
* The invite is only valid while the inviter is present in the group.
|
||||
@@ -692,11 +620,9 @@ int gc_rejoin_group(GC_Session *c, GC_Chat *chat, const uint8_t *passwd, uint16_
|
||||
* Return -6 if friend doesn't exist.
|
||||
* Return -7 if sending packet failed.
|
||||
*/
|
||||
non_null(1, 3, 5) nullable(7)
|
||||
int gc_accept_invite(GC_Session *c, int32_t friend_number, const uint8_t *data, uint16_t length, const uint8_t *nick,
|
||||
size_t nick_length, const uint8_t *passwd, uint16_t passwd_len);
|
||||
|
||||
typedef bool gc_send_group_invite_packet_cb(const Messenger *m, uint32_t friendnumber, const uint8_t *packet,
|
||||
int gc_accept_invite(GC_Session *_Nonnull c, int32_t friend_number, const uint8_t *_Nonnull data, uint16_t length, const uint8_t *_Nonnull nick,
|
||||
size_t nick_length, const uint8_t *_Nullable passwd, uint16_t passwd_len);
|
||||
typedef bool gc_send_group_invite_packet_cb(const Messenger *_Nonnull m, uint32_t friendnumber, const uint8_t *_Nonnull packet,
|
||||
uint16_t length);
|
||||
|
||||
/** @brief Invites friend designated by `friendnumber` to chat.
|
||||
@@ -707,9 +633,7 @@ typedef bool gc_send_group_invite_packet_cb(const Messenger *m, uint32_t friendn
|
||||
* Return -2 on failure to create the invite data.
|
||||
* Return -3 if the packet fails to send.
|
||||
*/
|
||||
non_null()
|
||||
int gc_invite_friend(const GC_Session *c, GC_Chat *chat, int32_t friend_number,
|
||||
gc_send_group_invite_packet_cb *callback);
|
||||
int gc_invite_friend(const GC_Session *_Nonnull c, GC_Chat *_Nonnull chat, int32_t friend_number, gc_send_group_invite_packet_cb *_Nonnull callback);
|
||||
|
||||
/** @brief Leaves a group and sends an exit broadcast packet with an optional parting message.
|
||||
*
|
||||
@@ -719,31 +643,25 @@ int gc_invite_friend(const GC_Session *c, GC_Chat *chat, int32_t friend_number,
|
||||
* Return -1 if the parting message is too long.
|
||||
* Return -2 if the parting message failed to send.
|
||||
*/
|
||||
non_null(1, 2) nullable(3)
|
||||
int gc_group_exit(GC_Session *c, GC_Chat *chat, const uint8_t *message, uint16_t length);
|
||||
|
||||
int gc_group_exit(GC_Session *_Nonnull c, GC_Chat *_Nonnull chat, const uint8_t *_Nullable message, uint16_t length);
|
||||
/** @brief Returns true if `chat` is a valid group chat.
|
||||
*
|
||||
* A valid group chat constitutes an initialized chat instance with a non-zero shared state version.
|
||||
* The shared state version will be non-zero either if a peer has created the group, or if
|
||||
* they have ever successfully connected to the group.
|
||||
*/
|
||||
non_null()
|
||||
bool gc_group_is_valid(const GC_Chat *chat);
|
||||
bool gc_group_is_valid(const GC_Chat *_Nonnull chat);
|
||||
|
||||
/** @brief Returns the number of active groups in `c`. */
|
||||
non_null()
|
||||
uint32_t gc_count_groups(const GC_Session *c);
|
||||
uint32_t gc_count_groups(const GC_Session *_Nonnull c);
|
||||
|
||||
/** @brief Returns true if peer_number exists */
|
||||
non_null()
|
||||
bool gc_peer_number_is_valid(const GC_Chat *chat, int peer_number);
|
||||
bool gc_peer_number_is_valid(const GC_Chat *_Nonnull chat, int peer_number);
|
||||
|
||||
/** @brief Return group_number's GC_Chat pointer on success
|
||||
* Return NULL on failure
|
||||
*/
|
||||
non_null()
|
||||
GC_Chat *gc_get_group(const GC_Session *c, int group_number);
|
||||
GC_Chat *_Nullable gc_get_group(const GC_Session *_Nonnull c, int group_number);
|
||||
|
||||
/** @brief Sends a lossy message acknowledgement to peer associated with `gconn`.
|
||||
*
|
||||
@@ -754,8 +672,7 @@ GC_Chat *gc_get_group(const GC_Session *c, int group_number);
|
||||
*
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null()
|
||||
bool gc_send_message_ack(const GC_Chat *chat, GC_Connection *gconn, uint64_t message_id, Group_Message_Ack_Type type);
|
||||
bool gc_send_message_ack(const GC_Chat *_Nonnull chat, GC_Connection *_Nonnull gconn, uint64_t message_id, Group_Message_Ack_Type type);
|
||||
|
||||
/** @brief Helper function for `handle_gc_lossless_packet()`.
|
||||
*
|
||||
@@ -763,23 +680,19 @@ bool gc_send_message_ack(const GC_Chat *chat, GC_Connection *gconn, uint64_t mes
|
||||
*
|
||||
* @retval true if packet is successfully handled.
|
||||
*/
|
||||
non_null(1, 2) nullable(4, 7)
|
||||
bool handle_gc_lossless_helper(const GC_Session *c, GC_Chat *chat, uint32_t peer_number, const uint8_t *data,
|
||||
uint16_t length, uint8_t packet_type, void *userdata);
|
||||
|
||||
bool handle_gc_lossless_helper(const GC_Session *_Nonnull c, GC_Chat *_Nonnull chat, uint32_t peer_number, const uint8_t *_Nullable data,
|
||||
uint16_t length, uint8_t packet_type, void *_Nullable userdata);
|
||||
/** @brief Handles an invite accept packet.
|
||||
*
|
||||
* @retval true on success.
|
||||
*/
|
||||
non_null()
|
||||
bool handle_gc_invite_accepted_packet(const GC_Session *c, int friend_number, const uint8_t *data, uint16_t length);
|
||||
bool handle_gc_invite_accepted_packet(const GC_Session *_Nonnull c, int friend_number, const uint8_t *_Nonnull data, uint16_t length);
|
||||
|
||||
/** @brief Return true if `chat_id` is not present in our group sessions array.
|
||||
*
|
||||
* `length` must be at least CHAT_ID_SIZE bytes in length.
|
||||
*/
|
||||
non_null()
|
||||
bool group_not_added(const GC_Session *c, const uint8_t *chat_id, uint32_t length);
|
||||
bool group_not_added(const GC_Session *_Nonnull c, const uint8_t *_Nonnull chat_id, uint32_t length);
|
||||
|
||||
/** @brief Handles an invite confirmed packet.
|
||||
*
|
||||
@@ -790,21 +703,18 @@ bool group_not_added(const GC_Session *c, const uint8_t *chat_id, uint32_t lengt
|
||||
* Return -4 if `friend_number` does not designate a valid friend.
|
||||
* Return -5 if data contains invalid connection info.
|
||||
*/
|
||||
non_null()
|
||||
int handle_gc_invite_confirmed_packet(const GC_Session *c, int friend_number, const uint8_t *data, uint16_t length);
|
||||
int handle_gc_invite_confirmed_packet(const GC_Session *_Nonnull c, int friend_number, const uint8_t *_Nonnull data, uint16_t length);
|
||||
|
||||
/** @brief Returns the group designated by `public_key`.
|
||||
* Returns null if group does not exist.
|
||||
*/
|
||||
non_null()
|
||||
GC_Chat *gc_get_group_by_public_key(const GC_Session *c, const uint8_t *public_key);
|
||||
GC_Chat *_Nullable gc_get_group_by_public_key(const GC_Session *_Nonnull c, const uint8_t *_Nonnull public_key);
|
||||
|
||||
/** @brief Attempts to add peers from `announces` to our peer list and initiate an invite request.
|
||||
*
|
||||
* Returns the number of peers added on success.
|
||||
* Returns -1 on failure.
|
||||
*/
|
||||
non_null()
|
||||
int gc_add_peers_from_announces(GC_Chat *chat, const GC_Announce *announces, uint8_t gc_announces_count);
|
||||
int gc_add_peers_from_announces(GC_Chat *_Nonnull chat, const GC_Announce *_Nonnull announces, uint8_t gc_announces_count);
|
||||
|
||||
#endif /* C_TOXCORE_TOXCORE_GROUP_CHATS_H */
|
||||
|
Reference in New Issue
Block a user