summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
authorzugz (tox) <mbays+tox@sdf.org>2019-02-10 00:00:00 +0000
committerzugz (tox) <mbays+tox@sdf.org>2019-02-10 00:00:00 +0000
commit49e2406ffabe2bbf04dc9416f6240ea63df4590d (patch)
treee81f432758d1f8a2aba7c037cc1c81a9550aef6f /toxcore
parent0aad180d1e1d7dae7cbf2868e139af0a4dc34fe7 (diff)
Expose api functions for enabling and disabling AV in AV groups
A group loaded from a savefile starts with AV disabled.
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/group.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index 101c1196..20ee5459 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -539,9 +539,7 @@ static int note_peer_active(Group_Chats *g_c, uint32_t groupnumber, uint16_t pee
539 539
540 ++g->numpeers; 540 ++g->numpeers;
541 541
542 if (!delete_frozen(g, frozen_index)) { 542 delete_frozen(g, frozen_index);
543 return -1;
544 }
545 543
546 if (g_c->peer_list_changed_callback) { 544 if (g_c->peer_list_changed_callback) {
547 g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata); 545 g_c->peer_list_changed_callback(g_c->m, groupnumber, userdata);
@@ -774,6 +772,7 @@ static int freeze_peer(Group_Chats *g_c, uint32_t groupnumber, int peer_index, v
774 772
775 g->frozen = temp; 773 g->frozen = temp;
776 g->frozen[g->numfrozen] = g->group[peer_index]; 774 g->frozen[g->numfrozen] = g->group[peer_index];
775 g->frozen[g->numfrozen].object = nullptr;
777 ++g->numfrozen; 776 ++g->numfrozen;
778 777
779 return delpeer(g_c, groupnumber, peer_index, userdata, true); 778 return delpeer(g_c, groupnumber, peer_index, userdata, true);
@@ -2831,6 +2830,12 @@ static unsigned int lossy_packet_not_received(const Group_c *g, int peer_index,
2831 2830
2832} 2831}
2833 2832
2833/* Does this group type make use of lossy packets? */
2834static bool type_uses_lossy(uint8_t type)
2835{
2836 return (type == GROUPCHAT_TYPE_AV);
2837}
2838
2834static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata) 2839static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uint16_t length, void *userdata)
2835{ 2840{
2836 Group_Chats *g_c = (Group_Chats *)object; 2841 Group_Chats *g_c = (Group_Chats *)object;
@@ -2857,6 +2862,10 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
2857 return -1; 2862 return -1;
2858 } 2863 }
2859 2864
2865 if (!type_uses_lossy(g->type)) {
2866 return -1;
2867 }
2868
2860 const int index = friend_in_close(g, friendcon_id); 2869 const int index = friend_in_close(g, friendcon_id);
2861 2870
2862 if (index == -1) { 2871 if (index == -1) {
@@ -2883,6 +2892,8 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
2883 ++lossy_data; 2892 ++lossy_data;
2884 --lossy_length; 2893 --lossy_length;
2885 2894
2895 send_lossy_all_close(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index);
2896
2886 if (g_c->lossy_packethandlers[message_id].function) { 2897 if (g_c->lossy_packethandlers[message_id].function) {
2887 if (g_c->lossy_packethandlers[message_id].function(g->object, groupnumber, peer_index, g->group[peer_index].object, 2898 if (g_c->lossy_packethandlers[message_id].function(g->object, groupnumber, peer_index, g->group[peer_index].object,
2888 lossy_data, lossy_length) == -1) { 2899 lossy_data, lossy_length) == -1) {
@@ -2892,7 +2903,6 @@ static int handle_lossy(void *object, int friendcon_id, const uint8_t *data, uin
2892 return -1; 2903 return -1;
2893 } 2904 }
2894 2905
2895 send_lossy_all_close(g_c, groupnumber, data + 1 + sizeof(uint16_t), length - (1 + sizeof(uint16_t)), index);
2896 return 0; 2906 return 0;
2897} 2907}
2898 2908
@@ -2934,7 +2944,7 @@ int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peer
2934 return 0; 2944 return 0;
2935} 2945}
2936 2946
2937/* Return the object tide to the group chat previously set by group_set_object. 2947/* Return the object tied to the group chat previously set by group_set_object.
2938 * 2948 *
2939 * return NULL on failure. 2949 * return NULL on failure.
2940 * return object on success. 2950 * return object on success.
@@ -2950,7 +2960,7 @@ void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber)
2950 return g->object; 2960 return g->object;
2951} 2961}
2952 2962
2953/* Return the object tide to the group chat peer previously set by group_peer_set_object. 2963/* Return the object tied to the group chat peer previously set by group_peer_set_object.
2954 * 2964 *
2955 * return NULL on failure. 2965 * return NULL on failure.
2956 * return object on success. 2966 * return object on success.