summaryrefslogtreecommitdiff
path: root/protocols/Tox/libtox/src/toxcore/group.h
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-08-17 00:29:59 +0300
committeraunsane <aunsane@gmail.com>2018-08-18 13:08:40 +0300
commit22196f3cad4751f964c56da518bb57ab0e64ae97 (patch)
tree9830ac73ecd5047aaa4ae0f67139b14cb9f8c4d2 /protocols/Tox/libtox/src/toxcore/group.h
parent28d0e917496ecfd681e8cd3e3032519867993f9b (diff)
Tox: libtox updated to v0.2.6
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/group.h')
-rw-r--r--protocols/Tox/libtox/src/toxcore/group.h75
1 files changed, 39 insertions, 36 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/group.h b/protocols/Tox/libtox/src/toxcore/group.h
index 970cf7fb04..175999ae78 100644
--- a/protocols/Tox/libtox/src/toxcore/group.h
+++ b/protocols/Tox/libtox/src/toxcore/group.h
@@ -71,7 +71,7 @@ typedef struct Group_Peer {
#define DESIRED_CLOSE_CONNECTIONS 4
#define MAX_GROUP_CONNECTIONS 16
-#define GROUP_IDENTIFIER_LENGTH (1 + CRYPTO_SYMMETRIC_KEY_SIZE) // type + CRYPTO_SYMMETRIC_KEY_SIZE so we can use new_symmetric_key(...) to fill it
+#define GROUP_ID_LENGTH CRYPTO_SYMMETRIC_KEY_SIZE
typedef enum Groupchat_Close_Type {
GROUPCHAT_CLOSE_NONE,
@@ -111,7 +111,8 @@ typedef struct Group_c {
Groupchat_Close_Connection closest_peers[DESIRED_CLOSE_CONNECTIONS];
uint8_t changed;
- uint8_t identifier[GROUP_IDENTIFIER_LENGTH];
+ uint8_t type;
+ uint8_t id[GROUP_ID_LENGTH];
uint8_t title[MAX_NAME_LENGTH];
uint8_t title_len;
@@ -131,15 +132,38 @@ typedef struct Group_c {
group_on_delete_cb *group_on_delete;
} Group_c;
+/* Callback for group invites.
+ *
+ * data of length is what needs to be passed to join_groupchat().
+ */
typedef void g_conference_invite_cb(Messenger *m, uint32_t friend_number, int type, const uint8_t *cookie,
size_t length, void *user_data);
+
+/* Callback for group connection. */
+typedef void g_conference_connected_cb(Messenger *m, uint32_t conference_number, void *user_data);
+
+/* Callback for group messages. */
typedef void g_conference_message_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, int type,
const uint8_t *message, size_t length, void *user_data);
+
+/* Callback for peer nickname changes. */
typedef void peer_name_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *name,
size_t length, void *user_data);
+
+/* Set callback function for peer list changes. */
typedef void peer_list_changed_cb(Messenger *m, uint32_t conference_number, void *user_data);
+
+/* Callback for title changes.
+ *
+ * If peer_number == -1, then author is unknown (e.g. initial joining the group).
+ */
typedef void title_cb(Messenger *m, uint32_t conference_number, uint32_t peer_number, const uint8_t *title,
size_t length, void *user_data);
+
+/* Callback for lossy packets.
+ *
+ * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed.
+ */
typedef int lossy_packet_cb(void *object, uint32_t conference_number, uint32_t peer_number, void *peer_object,
const uint8_t *packet, uint16_t length);
@@ -155,6 +179,7 @@ typedef struct Group_Chats {
uint16_t num_chats;
g_conference_invite_cb *invite_callback;
+ g_conference_connected_cb *connected_callback;
g_conference_message_cb *message_callback;
peer_name_cb *peer_name_callback;
peer_list_changed_cb *peer_list_changed_callback;
@@ -163,39 +188,28 @@ typedef struct Group_Chats {
Group_Lossy_Handler lossy_packethandlers[256];
} Group_Chats;
-/* Set the callback for group invites.
- *
- * Function(Group_Chats *g_c, uint32_t friendnumber, uint8_t type, uint8_t *data, uint16_t length, void *userdata)
- *
- * data of length is what needs to be passed to join_groupchat().
- */
+/* Set the callback for group invites. */
void g_callback_group_invite(Group_Chats *g_c, g_conference_invite_cb *function);
-/* Set the callback for group messages.
- *
- * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
- */
+/* Set the callback for group connection. */
+void g_callback_group_connected(Group_Chats *g_c, g_conference_connected_cb *function);
+
+/* Set the callback for group messages. */
void g_callback_group_message(Group_Chats *g_c, g_conference_message_cb *function);
-/* Set callback function for title changes.
- *
- * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t friendgroupnumber, uint8_t * title, uint8_t length, void *userdata)
- * if friendgroupnumber == -1, then author is unknown (e.g. initial joining the group)
- */
+/* Set callback function for title changes. */
void g_callback_group_title(Group_Chats *g_c, title_cb *function);
/* Set callback function for peer nickname changes.
*
* It gets called every time a peer changes their nickname.
- * Function(Group_Chats *g_c, uint32_t groupnumber, uint32_t peernumber, const uint8_t *nick, size_t nick_len, void *userdata)
*/
void g_callback_peer_name(Group_Chats *g_c, peer_name_cb *function);
/* Set callback function for peer list changes.
*
* It gets called every time the name list changes(new peer, deleted peer)
- * Function(Group_Chats *g_c, uint32_t groupnumber, void *userdata)
*/
void g_callback_peer_list_changed(Group_Chats *g_c, peer_list_changed_cb *function);
@@ -326,12 +340,7 @@ int group_peernumber_is_ours(const Group_Chats *g_c, uint32_t groupnumber, int p
int group_names(const Group_Chats *g_c, uint32_t groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[],
uint16_t length);
-/* Set handlers for custom lossy packets.
- *
- * NOTE: Handler must return 0 if packet is to be relayed, -1 if the packet should not be relayed.
- *
- * Function(void *group object (set with group_set_object), uint32_t groupnumber, uint32_t friendgroupnumber, void *group peer object (set with group_peer_set_object), const uint8_t *packet, uint16_t length)
- */
+/* Set handlers for custom lossy packets. */
void group_lossy_packet_registerhandler(Group_Chats *g_c, uint8_t byte, lossy_packet_cb *function);
/* High level function to send custom lossy packets.
@@ -361,14 +370,14 @@ uint32_t copy_chatlist(const Group_Chats *g_c, uint32_t *out_list, uint32_t list
*/
int group_get_type(const Group_Chats *g_c, uint32_t groupnumber);
-/* Copies the unique id of group_chat[groupnumber] into uid.
+/* Copies the unique id of group_chat[groupnumber] into id.
*
* return false on failure.
* return true on success.
*/
-bool conference_get_uid(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *uid);
+bool conference_get_id(const Group_Chats *g_c, uint32_t groupnumber, uint8_t *id);
-int32_t conference_by_uid(const Group_Chats *g_c, const uint8_t *uid);
+int32_t conference_by_id(const Group_Chats *g_c, const uint8_t *id);
/* Send current name (set in messenger) to all online groups.
*/
@@ -388,14 +397,14 @@ int group_set_object(const Group_Chats *g_c, uint32_t groupnumber, void *object)
*/
int group_peer_set_object(const Group_Chats *g_c, uint32_t groupnumber, int peernumber, void *object);
-/* Return the object tide to the group chat previously set by group_set_object.
+/* Return the object tied to the group chat previously set by group_set_object.
*
* return NULL on failure.
* return object on success.
*/
void *group_get_object(const Group_Chats *g_c, uint32_t groupnumber);
-/* Return the object tide to the group chat peer previously set by group_peer_set_object.
+/* Return the object tied to the group chat peer previously set by group_peer_set_object.
*
* return NULL on failure.
* return object on success.
@@ -404,8 +413,6 @@ void *group_peer_get_object(const Group_Chats *g_c, uint32_t groupnumber, int pe
/* Set a function to be called when a new peer joins a group chat.
*
- * Function(void *group object (set with group_set_object), int groupnumber, int friendgroupnumber)
- *
* return 0 on success.
* return -1 on failure.
*/
@@ -413,8 +420,6 @@ int callback_groupchat_peer_new(const Group_Chats *g_c, uint32_t groupnumber, pe
/* Set a function to be called when a peer leaves a group chat.
*
- * Function(void *group object (set with group_set_object), uint32_t groupnumber, void *group peer object (set with group_peer_set_object))
- *
* return 0 on success.
* return -1 on failure.
*/
@@ -422,8 +427,6 @@ int callback_groupchat_peer_delete(Group_Chats *g_c, uint32_t groupnumber, peer_
/* Set a function to be called when the group chat is deleted.
*
- * Function(void *group object (set with group_set_object), uint32_t groupnumber)
- *
* return 0 on success.
* return -1 on failure.
*/