summaryrefslogtreecommitdiff
path: root/toxcore/group.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/group.h')
-rw-r--r--toxcore/group.h25
1 files changed, 18 insertions, 7 deletions
diff --git a/toxcore/group.h b/toxcore/group.h
index 1a51f83b..a9e6e8e9 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -33,6 +33,11 @@ enum {
33 GROUPCHAT_STATUS_CONNECTED 33 GROUPCHAT_STATUS_CONNECTED
34}; 34};
35 35
36enum {
37 GROUPCHAT_TYPE_TEXT,
38 GROUPCHAT_TYPE_AV
39};
40
36#define MAX_LOSSY_COUNT 256 41#define MAX_LOSSY_COUNT 256
37 42
38typedef struct { 43typedef struct {
@@ -55,7 +60,7 @@ typedef struct {
55 60
56#define DESIRED_CLOSE_CONNECTIONS 4 61#define DESIRED_CLOSE_CONNECTIONS 4
57#define MAX_GROUP_CONNECTIONS 16 62#define MAX_GROUP_CONNECTIONS 16
58#define GROUP_IDENTIFIER_LENGTH crypto_box_KEYBYTES /* So we can use new_symmetric_key(...) to fill it */ 63#define GROUP_IDENTIFIER_LENGTH (1 + crypto_box_KEYBYTES) /* crypto_box_KEYBYTES so we can use new_symmetric_key(...) to fill it */
59 64
60enum { 65enum {
61 GROUPCHAT_CLOSE_NONE, 66 GROUPCHAT_CLOSE_NONE,
@@ -107,7 +112,7 @@ typedef struct {
107 Group_c *chats; 112 Group_c *chats;
108 uint32_t num_chats; 113 uint32_t num_chats;
109 114
110 void (*invite_callback)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *); 115 void (*invite_callback)(Messenger *m, int32_t, uint8_t, const uint8_t *, uint16_t, void *);
111 void *invite_callback_userdata; 116 void *invite_callback_userdata;
112 void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *); 117 void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
113 void *message_callback_userdata; 118 void *message_callback_userdata;
@@ -119,16 +124,18 @@ typedef struct {
119 struct { 124 struct {
120 int (*function)(void *, int, int, void *, const uint8_t *, uint16_t); 125 int (*function)(void *, int, int, void *, const uint8_t *, uint16_t);
121 } lossy_packethandlers[256]; 126 } lossy_packethandlers[256];
127
128 void *av_object;
122} Group_Chats; 129} Group_Chats;
123 130
124/* Set the callback for group invites. 131/* Set the callback for group invites.
125 * 132 *
126 * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata) 133 * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata)
127 * 134 *
128 * data of length is what needs to be passed to join_groupchat(). 135 * data of length is what needs to be passed to join_groupchat().
129 */ 136 */
130void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, 137void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, int32_t, uint8_t, const uint8_t *,
131 void *), void *userdata); 138 uint16_t, void *), void *userdata);
132 139
133/* Set the callback for group messages. 140/* Set the callback for group messages.
134 * 141 *
@@ -159,10 +166,12 @@ void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenge
159 166
160/* Creates a new groupchat and puts it in the chats array. 167/* Creates a new groupchat and puts it in the chats array.
161 * 168 *
169 * type is one of GROUPCHAT_TYPE_*
170 *
162 * return group number on success. 171 * return group number on success.
163 * return -1 on failure. 172 * return -1 on failure.
164 */ 173 */
165int add_groupchat(Group_Chats *g_c); 174int add_groupchat(Group_Chats *g_c, uint8_t type);
166 175
167/* Delete a groupchat from the chats array. 176/* Delete a groupchat from the chats array.
168 * 177 *
@@ -187,10 +196,12 @@ int invite_friend(Group_Chats *g_c, int32_t friendnumber, int groupnumber);
187 196
188/* Join a group (you need to have been invited first.) 197/* Join a group (you need to have been invited first.)
189 * 198 *
199 * expected_type is the groupchat type we expect the chat we are joining is.
200 *
190 * returns group number on success 201 * returns group number on success
191 * returns -1 on failure. 202 * returns -1 on failure.
192 */ 203 */
193int join_groupchat(Group_Chats *g_c, int32_t friendnumber, const uint8_t *data, uint16_t length); 204int join_groupchat(Group_Chats *g_c, int32_t friendnumber, uint8_t expected_type, const uint8_t *data, uint16_t length);
194 205
195/* send a group message 206/* send a group message
196 * return 0 on success 207 * return 0 on success