summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toxcore/group.c20
-rw-r--r--toxcore/group.h7
-rw-r--r--toxcore/tox.c5
-rw-r--r--toxcore/tox.h2
4 files changed, 19 insertions, 15 deletions
diff --git a/toxcore/group.c b/toxcore/group.c
index eb84703d..26df82bd 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -1025,7 +1025,7 @@ static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, cons
1025 return; 1025 return;
1026 1026
1027 uint16_t peer_number = rand(); /* TODO: what if two people enter the group at the same time and 1027 uint16_t peer_number = rand(); /* TODO: what if two people enter the group at the same time and
1028 are given the same peer_number by different nodes? */ 1028 are given the same peer_number by different nodes? */
1029 unsigned int tries = 0; 1029 unsigned int tries = 0;
1030 1030
1031 while (get_peer_index(g, peer_number) != -1) { 1031 while (get_peer_index(g, peer_number) != -1) {
@@ -1670,25 +1670,24 @@ uint32_t count_chatlist(Group_Chats *g_c)
1670 * Otherwise, returns the number of elements copied. 1670 * Otherwise, returns the number of elements copied.
1671 * If the array was too small, the contents 1671 * If the array was too small, the contents
1672 * of out_list will be truncated to list_size. */ 1672 * of out_list will be truncated to list_size. */
1673/* 1673uint32_t copy_chatlist(Group_Chats *g_c, int32_t *out_list, uint32_t list_size)
1674uint32_t copy_chatlist(const Messenger *m, int *out_list, uint32_t list_size)
1675{ 1674{
1676 if (!out_list) 1675 if (!out_list) {
1677 return 0; 1676 return 0;
1677 }
1678 1678
1679 if (m->numchats == 0) { 1679 if (g_c->num_chats == 0) {
1680 return 0; 1680 return 0;
1681 } 1681 }
1682 1682
1683 uint32_t i; 1683 uint32_t i, ret = 0;
1684 uint32_t ret = 0;
1685 1684
1686 for (i = 0; i < m->numchats; i++) { 1685 for (i = 0; i < g_c->num_chats; ++i) {
1687 if (ret >= list_size) { 1686 if (ret >= list_size) {
1688 break; *//* Abandon ship *//* 1687 break; /* Abandon ship */
1689 } 1688 }
1690 1689
1691 if (m->chats[i]) { 1690 if (g_c->chats[i].status > GROUPCHAT_STATUS_NONE) {
1692 out_list[ret] = i; 1691 out_list[ret] = i;
1693 ret++; 1692 ret++;
1694 } 1693 }
@@ -1696,4 +1695,3 @@ uint32_t copy_chatlist(const Messenger *m, int *out_list, uint32_t list_size)
1696 1695
1697 return ret; 1696 return ret;
1698} 1697}
1699*/
diff --git a/toxcore/group.h b/toxcore/group.h
index d4c77f49..3764bf94 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -214,6 +214,13 @@ int group_names(const Group_Chats *g_c, int groupnumber, uint8_t names[][MAX_NAM
214 */ 214 */
215uint32_t count_chatlist(Group_Chats *g_c); 215uint32_t count_chatlist(Group_Chats *g_c);
216 216
217/* Copy a list of valid chat IDs into the array out_list.
218 * If out_list is NULL, returns 0.
219 * Otherwise, returns the number of elements copied.
220 * If the array was too small, the contents
221 * of out_list will be truncated to list_size. */
222uint32_t copy_chatlist(Group_Chats *g_c, int32_t *out_list, uint32_t list_size);
223
217/* Send current name (set in messenger) to all online groups. 224/* Send current name (set in messenger) to all online groups.
218 */ 225 */
219void send_name_all_groups(Group_Chats *g_c); 226void send_name_all_groups(Group_Chats *g_c);
diff --git a/toxcore/tox.c b/toxcore/tox.c
index ea8c68ba..19146744 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -723,11 +723,10 @@ uint32_t tox_count_chatlist(const Tox *tox)
723 * Otherwise, returns the number of elements copied. 723 * Otherwise, returns the number of elements copied.
724 * If the array was too small, the contents 724 * If the array was too small, the contents
725 * of out_list will be truncated to list_size. */ 725 * of out_list will be truncated to list_size. */
726uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size) 726uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size)
727{ 727{
728 const Messenger *m = tox; 728 const Messenger *m = tox;
729 //return copy_chatlist(m, out_list, list_size); 729 return copy_chatlist(m->group_chat_object, out_list, list_size);
730 return 0;
731} 730}
732 731
733 732
diff --git a/toxcore/tox.h b/toxcore/tox.h
index db68fff2..4920853e 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -537,7 +537,7 @@ uint32_t tox_count_chatlist(const Tox *tox);
537 * Otherwise, returns the number of elements copied. 537 * Otherwise, returns the number of elements copied.
538 * If the array was too small, the contents 538 * If the array was too small, the contents
539 * of out_list will be truncated to list_size. */ 539 * of out_list will be truncated to list_size. */
540uint32_t tox_get_chatlist(const Tox *tox, int *out_list, uint32_t list_size); 540uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size);
541 541
542/****************AVATAR FUNCTIONS*****************/ 542/****************AVATAR FUNCTIONS*****************/
543 543