forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from adbd5b32d8..e29e185c03
e29e185c03 feat: add ngc events 2b0dc0f46b add ngc related unpack functions b2315c50e0 Add groupchat API function that returns an IP address string for a peer 5f863a5492 feat: Add `to_string` functions for all public enums. 0c998a7598 add real timeout test 68c827609a chore: Move s390x build to post-merge. 028b017d79 perf: Slightly reduce bandwidth usage when there are few nodes. 90f7496819 feat: Enable ubsan on bootstrap nodes. 89b6450d66 test: Add check-c run to bazel build. REVERT: adbd5b32d8 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: e29e185c03fea7337036e5ef4d1d9080a6cee721
This commit is contained in:
@ -130,6 +130,17 @@ bool tox_unpack_user_status(Bin_Unpack *bu, Tox_User_Status *val)
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Privacy_State tox_group_privacy_state_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_PRIVACY_STATE_PUBLIC;
|
||||
case 1:
|
||||
return TOX_GROUP_PRIVACY_STATE_PRIVATE;
|
||||
default:
|
||||
return TOX_GROUP_PRIVACY_STATE_PRIVATE;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_privacy_state(Bin_Unpack *bu, Tox_Group_Privacy_State *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -138,10 +149,22 @@ bool tox_unpack_group_privacy_state(Bin_Unpack *bu, Tox_Group_Privacy_State *val
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Privacy_State)u32;
|
||||
*val = tox_group_privacy_state_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Voice_State tox_group_voice_state_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_VOICE_STATE_ALL;
|
||||
case 1:
|
||||
return TOX_GROUP_VOICE_STATE_MODERATOR;
|
||||
case 2:
|
||||
return TOX_GROUP_VOICE_STATE_FOUNDER;
|
||||
default:
|
||||
return TOX_GROUP_VOICE_STATE_FOUNDER;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_voice_state(Bin_Unpack *bu, Tox_Group_Voice_State *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -150,10 +173,21 @@ bool tox_unpack_group_voice_state(Bin_Unpack *bu, Tox_Group_Voice_State *val)
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Voice_State)u32;
|
||||
*val = tox_group_voice_state_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Topic_Lock tox_group_topic_lock_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_TOPIC_LOCK_ENABLED;
|
||||
case 1:
|
||||
return TOX_GROUP_TOPIC_LOCK_DISABLED;
|
||||
default:
|
||||
return TOX_GROUP_TOPIC_LOCK_ENABLED;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_topic_lock(Bin_Unpack *bu, Tox_Group_Topic_Lock *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -162,10 +196,23 @@ bool tox_unpack_group_topic_lock(Bin_Unpack *bu, Tox_Group_Topic_Lock *val)
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Topic_Lock)u32;
|
||||
*val = tox_group_topic_lock_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Join_Fail tox_group_join_fail_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_JOIN_FAIL_PEER_LIMIT;
|
||||
case 1:
|
||||
return TOX_GROUP_JOIN_FAIL_INVALID_PASSWORD;
|
||||
case 2:
|
||||
return TOX_GROUP_JOIN_FAIL_UNKNOWN;
|
||||
default:
|
||||
return TOX_GROUP_JOIN_FAIL_UNKNOWN;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_join_fail(Bin_Unpack *bu, Tox_Group_Join_Fail *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -174,10 +221,25 @@ bool tox_unpack_group_join_fail(Bin_Unpack *bu, Tox_Group_Join_Fail *val)
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Join_Fail)u32;
|
||||
*val = tox_group_join_fail_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Mod_Event tox_group_mod_event_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_MOD_EVENT_KICK;
|
||||
case 1:
|
||||
return TOX_GROUP_MOD_EVENT_OBSERVER;
|
||||
case 2:
|
||||
return TOX_GROUP_MOD_EVENT_USER;
|
||||
case 3:
|
||||
return TOX_GROUP_MOD_EVENT_MODERATOR;
|
||||
default:
|
||||
return TOX_GROUP_MOD_EVENT_MODERATOR;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_mod_event(Bin_Unpack *bu, Tox_Group_Mod_Event *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -186,10 +248,29 @@ bool tox_unpack_group_mod_event(Bin_Unpack *bu, Tox_Group_Mod_Event *val)
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Mod_Event)u32;
|
||||
*val = tox_group_mod_event_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Tox_Group_Exit_Type tox_group_exit_type_from_int(uint32_t value)
|
||||
{
|
||||
switch (value) {
|
||||
case 0:
|
||||
return TOX_GROUP_EXIT_TYPE_QUIT;
|
||||
case 1:
|
||||
return TOX_GROUP_EXIT_TYPE_TIMEOUT;
|
||||
case 2:
|
||||
return TOX_GROUP_EXIT_TYPE_DISCONNECTED;
|
||||
case 3:
|
||||
return TOX_GROUP_EXIT_TYPE_SELF_DISCONNECTED;
|
||||
case 4:
|
||||
return TOX_GROUP_EXIT_TYPE_KICK;
|
||||
case 5:
|
||||
return TOX_GROUP_EXIT_TYPE_SYNC_ERROR;
|
||||
default:
|
||||
return TOX_GROUP_EXIT_TYPE_QUIT;
|
||||
}
|
||||
}
|
||||
bool tox_unpack_group_exit_type(Bin_Unpack *bu, Tox_Group_Exit_Type *val)
|
||||
{
|
||||
uint32_t u32;
|
||||
@ -198,6 +279,6 @@ bool tox_unpack_group_exit_type(Bin_Unpack *bu, Tox_Group_Exit_Type *val)
|
||||
return false;
|
||||
}
|
||||
|
||||
*val = (Tox_Group_Exit_Type)u32;
|
||||
*val = tox_group_exit_type_from_int(u32);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user