summaryrefslogtreecommitdiff
path: root/toxcore/group.h
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/group.h')
-rw-r--r--toxcore/group.h54
1 files changed, 27 insertions, 27 deletions
diff --git a/toxcore/group.h b/toxcore/group.h
index ee0829cb..1e054de3 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -56,37 +56,37 @@ typedef struct Group_Peer {
56 void *object; 56 void *object;
57} Group_Peer; 57} Group_Peer;
58 58
59#define DESIRED_CLOSE_CONNECTIONS 4 59#define DESIRED_CLOSEST 4
60#define MAX_GROUP_CONNECTIONS 16 60#define MAX_GROUP_CONNECTIONS 16
61#define GROUP_ID_LENGTH CRYPTO_SYMMETRIC_KEY_SIZE 61#define GROUP_ID_LENGTH CRYPTO_SYMMETRIC_KEY_SIZE
62 62
63typedef enum Groupchat_Close_Type { 63typedef enum Groupchat_Connection_Type {
64 GROUPCHAT_CLOSE_NONE, 64 GROUPCHAT_CONNECTION_NONE,
65 GROUPCHAT_CLOSE_CONNECTION, 65 GROUPCHAT_CONNECTION_CONNECTING,
66 GROUPCHAT_CLOSE_ONLINE, 66 GROUPCHAT_CONNECTION_ONLINE,
67} Groupchat_Close_Type; 67} Groupchat_Connection_Type;
68 68
69/* Connection is to one of the closest DESIRED_CLOSE_CONNECTIONS peers */ 69/* Connection is to one of the closest DESIRED_CLOSEST peers */
70#define GROUPCHAT_CLOSE_REASON_CLOSEST (1 << 0) 70#define GROUPCHAT_CONNECTION_REASON_CLOSEST (1 << 0)
71 71
72/* Connection is to a peer we are introducing to the conference */ 72/* Connection is to a peer we are introducing to the conference */
73#define GROUPCHAT_CLOSE_REASON_INTRODUCING (1 << 1) 73#define GROUPCHAT_CONNECTION_REASON_INTRODUCING (1 << 1)
74 74
75/* Connection is to a peer who is introducing us to the conference */ 75/* Connection is to a peer who is introducing us to the conference */
76#define GROUPCHAT_CLOSE_REASON_INTRODUCER (1 << 2) 76#define GROUPCHAT_CONNECTION_REASON_INTRODUCER (1 << 2)
77 77
78typedef struct Groupchat_Close { 78typedef struct Groupchat_Connection {
79 uint8_t type; /* `GROUPCHAT_CLOSE_*` */ 79 uint8_t type; /* `GROUPCHAT_CONNECTION_*` */
80 uint8_t reasons; /* bit field with flags `GROUPCHAT_CLOSE_REASON_*` */ 80 uint8_t reasons; /* bit field with flags `GROUPCHAT_CONNECTION_REASON_*` */
81 uint32_t number; 81 uint32_t number;
82 uint16_t group_number; 82 uint16_t group_number;
83} Groupchat_Close; 83} Groupchat_Connection;
84 84
85typedef struct Groupchat_Close_Connection { 85typedef struct Groupchat_Closest {
86 uint8_t entry; 86 uint8_t entry;
87 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE]; 87 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE];
88 uint8_t temp_pk[CRYPTO_PUBLIC_KEY_SIZE]; 88 uint8_t temp_pk[CRYPTO_PUBLIC_KEY_SIZE];
89} Groupchat_Close_Connection; 89} Groupchat_Closest;
90 90
91typedef void peer_on_join_cb(void *object, uint32_t conference_number, uint32_t peer_number); 91typedef void peer_on_join_cb(void *object, uint32_t conference_number, uint32_t peer_number);
92typedef void peer_on_leave_cb(void *object, uint32_t conference_number, void *peer_object); 92typedef void peer_on_leave_cb(void *object, uint32_t conference_number, void *peer_object);
@@ -109,11 +109,10 @@ typedef struct Group_c {
109 109
110 uint32_t maxfrozen; 110 uint32_t maxfrozen;
111 111
112 /* TODO(zugz) rename close to something more accurate - "connected"? */ 112 Groupchat_Connection connections[MAX_GROUP_CONNECTIONS];
113 Groupchat_Close close[MAX_GROUP_CONNECTIONS];
114 113
115 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE]; 114 uint8_t real_pk[CRYPTO_PUBLIC_KEY_SIZE];
116 Groupchat_Close_Connection closest_peers[DESIRED_CLOSE_CONNECTIONS]; 115 Groupchat_Closest closest_peers[DESIRED_CLOSEST];
117 uint8_t changed; 116 uint8_t changed;
118 117
119 uint8_t type; 118 uint8_t type;
@@ -245,7 +244,7 @@ int del_groupchat(Group_Chats *g_c, uint32_t groupnumber, bool leave_permanently
245 * return -1 if groupnumber is invalid. 244 * return -1 if groupnumber is invalid.
246 * return -2 if peernumber is invalid. 245 * return -2 if peernumber is invalid.
247 */ 246 */
248int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *pk, bool frozen); 247int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, uint8_t *pk, bool frozen);
249 248
250/* 249/*
251 * Return the size of (frozen, if frozen is true) peernumber's name. 250 * Return the size of (frozen, if frozen is true) peernumber's name.
@@ -253,7 +252,7 @@ int group_peer_pubkey(const Group_Chats *g_c, uint32_t groupnumber, int peernumb
253 * return -1 if groupnumber is invalid. 252 * return -1 if groupnumber is invalid.
254 * return -2 if peernumber is invalid. 253 * return -2 if peernumber is invalid.
255 */ 254 */
256int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, int32_t peernumber, bool frozen); 255int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, bool frozen);
257 256
258/* Copy the name of (frozen, if frozen is true) peernumber who is in 257/* Copy the name of (frozen, if frozen is true) peernumber who is in
259 * groupnumber to name. 258 * groupnumber to name.
@@ -263,7 +262,7 @@ int group_peername_size(const Group_Chats *g_c, uint32_t groupnumber, int32_t pe
263 * return -1 if groupnumber is invalid. 262 * return -1 if groupnumber is invalid.
264 * return -2 if peernumber is invalid. 263 * return -2 if peernumber is invalid.
265 */ 264 */
266int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, uint8_t *name, bool frozen); 265int group_peername(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, uint8_t *name, bool frozen);
267 266
268/* Copy last active timestamp of frozen peernumber who is in groupnumber to 267/* Copy last active timestamp of frozen peernumber who is in groupnumber to
269 * last_active. 268 * last_active.
@@ -272,7 +271,7 @@ int group_peername(const Group_Chats *g_c, uint32_t groupnumber, int peernumber,
272 * return -1 if groupnumber is invalid. 271 * return -1 if groupnumber is invalid.
273 * return -2 if peernumber is invalid. 272 * return -2 if peernumber is invalid.
274 */ 273 */
275int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, 274int group_frozen_last_active(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber,
276 uint64_t *last_active); 275 uint64_t *last_active);
277 276
278/* Set maximum number of frozen peers. 277/* Set maximum number of frozen peers.
@@ -292,7 +291,8 @@ int invite_friend(Group_Chats *g_c, uint32_t friendnumber, uint32_t groupnumber)
292 291
293/* Join a group (you need to have been invited first.) 292/* Join a group (you need to have been invited first.)
294 * 293 *
295 * expected_type is the groupchat type we expect the chat we are joining is. 294 * expected_type is the groupchat type we expect the chat we are joining to
295 * have.
296 * 296 *
297 * return group number on success. 297 * return group number on success.
298 * return -1 if data length is invalid. 298 * return -1 if data length is invalid.
@@ -353,7 +353,7 @@ int group_number_peers(const Group_Chats *g_c, uint32_t groupnumber, bool frozen
353 * return -2 if peernumber is invalid. 353 * return -2 if peernumber is invalid.
354 * return -3 if we are not connected to the group chat. 354 * return -3 if we are not connected to the group chat.
355 */ 355 */
356int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int peernumber); 356int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber);
357 357
358/* List all the (frozen, if frozen is true) peers in the group chat. 358/* List all the (frozen, if frozen is true) peers in the group chat.
359 * 359 *
@@ -423,7 +423,7 @@ int group_set_object(const Group_Chats *g_c, uint32_t groupnumber, void *object)
423 * return 0 on success. 423 * return 0 on success.
424 * return -1 on failure 424 * return -1 on failure
425 */ 425 */
426int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object); 426int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, void *object);
427 427
428/* Return the object tied to the group chat previously set by group_set_object. 428/* Return the object tied to the group chat previously set by group_set_object.
429 * 429 *
@@ -437,7 +437,7 @@ void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber);
437 * return NULL on failure. 437 * return NULL on failure.
438 * return object on success. 438 * return object on success.
439 */ 439 */
440void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber); 440void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber);
441 441
442/* Set a function to be called when a new peer joins a group chat. 442/* Set a function to be called when a new peer joins a group chat.
443 * 443 *