From f8b979a92a8c316c49bed28e158a468a2f74346c Mon Sep 17 00:00:00 2001 From: irungentoo Date: Thu, 12 Sep 2013 20:29:30 -0400 Subject: Put group chat functions in the public API. Group chats are not complete, they seem to work very well though. This means that the functions will change. --- toxcore/tox.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'toxcore/tox.c') diff --git a/toxcore/tox.c b/toxcore/tox.c index 54bbd9f0..417f1af3 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -366,6 +366,81 @@ void tox_callback_connectionstatus(void *tox, void (*function)(Messenger *tox, i m_callback_connectionstatus(m, function, userdata); } +/**********GROUP CHAT FUNCTIONS: WARNING WILL BREAK A LOT************/ + +/* Set the callback for group invites. + * + * Function(Tox *tox, int friendnumber, uint8_t *group_public_key, void *userdata) + */ +void tox_callback_group_invite(void *tox, void (*function)(Messenger *tox, int, uint8_t *, void *), void *userdata) +{ + Messenger *m = tox; + m_callback_group_invite(m, function, userdata); +} +/* Set the callback for group messages. + * + * Function(Tox *tox, int groupnumber, uint8_t * message, uint16_t length, void *userdata) + */ +void tox_callback_group_message(void *tox, void (*function)(Messenger *tox, int, uint8_t *, uint16_t, void *), + void *userdata) +{ + Messenger *m = tox; + m_callback_group_message(m, function, userdata); +} +/* Creates a new groupchat and puts it in the chats array. + * + * return group number on success. + * return -1 on failure. + */ +int tox_add_groupchat(void *tox) +{ + Messenger *m = tox; + return add_groupchat(m); +} +/* Delete a groupchat from the chats array. + * + * return 0 on success. + * return -1 if failure. + */ +int tox_del_groupchat(void *tox, int groupnumber) +{ + Messenger *m = tox; + return del_groupchat(m, groupnumber); +} +/* invite friendnumber to groupnumber + * return 0 on success + * return -1 on failure + */ +int tox_invite_friend(void *tox, int friendnumber, int groupnumber) +{ + Messenger *m = tox; + return invite_friend(m, friendnumber, groupnumber); +} +/* Join a group (you need to have been invited first.) + * + * returns group number on success + * returns -1 on failure. + */ +int tox_join_groupchat(void *tox, int friendnumber, uint8_t *friend_group_public_key) +{ + Messenger *m = tox; + return join_groupchat(m, friendnumber, friend_group_public_key); +} + +/* send a group message + * return 0 on success + * return -1 on failure + */ +int tox_group_message_send(void *tox, int groupnumber, uint8_t *message, uint32_t length) +{ + Messenger *m = tox; + return group_message_send(m, groupnumber, message, length); +} + + + +/******************END OF GROUP CHAT FUNCTIONS************************/ + /* Use this function to bootstrap the client. * Sends a get nodes request to the given node with ip port and public_key. */ -- cgit v1.2.3