Merge branch 'get_group_title' of https://github.com/JFreegman/toxcore

This commit is contained in:
irungentoo 2014-11-15 14:25:38 -05:00
commit 1bfc3792fd
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
4 changed files with 49 additions and 0 deletions

View File

@ -1181,6 +1181,26 @@ int group_title_send(const Group_Chats *g_c, int groupnumber, const uint8_t *tit
return -1;
}
/* Get group title from groupnumber and put it in title.
* title needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
*
* return length of title if success.
* return -1 if failure.
*/
int group_title_get(const Group_Chats *g_c, int groupnumber, uint8_t *title)
{
Group_c *g = get_group_c(g_c, groupnumber);
if (!g)
return -1;
if (g->title_len == 0 || g->title_len > MAX_NAME_LENGTH)
return -1;
memcpy(title, g->title, g->title_len);
return g->title_len;
}
static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length)
{
Group_Chats *g_c = m->group_chat_object;

View File

@ -233,6 +233,15 @@ int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *ac
*/
int group_title_send(const Group_Chats *g_c, int groupnumber, const uint8_t *title, uint8_t title_len);
/* Get group title from groupnumber and put it in title.
* title needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
*
* return length of title if success.
* return -1 if failure.
*/
int group_title_get(const Group_Chats *g_c, int groupnumber, uint8_t *title);
/* Return the number of peers in the group chat on success.
* return -1 on failure
*/

View File

@ -693,6 +693,18 @@ int tox_group_set_title(Tox *tox, int groupnumber, const uint8_t *title, uint8_t
return group_title_send(m->group_chat_object, groupnumber, title, length);
}
/* Get group title from groupnumber and put it in title.
* title needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
*
* return length of title if success.
* return -1 if failure.
*/
int tox_group_get_title(Tox *tox, int groupnumber, uint8_t *title)
{
Messenger *m = tox;
return group_title_get(m->group_chat_object, groupnumber, title);
}
/* Check if the current peernumber corresponds to ours.
*
* return 1 if the peernumber corresponds to ours.

View File

@ -528,6 +528,14 @@ int tox_group_action_send(Tox *tox, int groupnumber, const uint8_t *action, uint
*/
int tox_group_set_title(Tox *tox, int groupnumber, const uint8_t *title, uint8_t length);
/* Get group title from groupnumber and put it in title.
* title needs to be a valid memory location with a size of at least MAX_NAME_LENGTH (128) bytes.
*
* return length of title if success.
* return -1 if failure.
*/
int tox_group_get_title(Tox *tox, int groupnumber, uint8_t *title);
/* Check if the current peernumber corresponds to ours.
*
* return 1 if the peernumber corresponds to ours.