diff --git a/toxcore/group.c b/toxcore/group.c index 4cb24d7a..f43dffbe 100644 --- a/toxcore/group.c +++ b/toxcore/group.c @@ -783,6 +783,21 @@ unsigned int group_peernumber_is_ours(const Group_Chats *g_c, int groupnumber, i return g->peer_number == g->group[peernumber].peer_number; } +/* return the type of groupchat (GROUPCHAT_TYPE_) that groupnumber is. + * + * return -1 on failure. + * return type on success. + */ +int group_get_type(const Group_Chats *g_c, int groupnumber) +{ + Group_c *g = get_group_c(g_c, groupnumber); + + if (!g) + return -1; + + return g->identifier[0]; +} + /* Send a group packet to friendcon_id. * * return 1 on success diff --git a/toxcore/group.h b/toxcore/group.h index ad3eeb3b..46af35e3 100644 --- a/toxcore/group.h +++ b/toxcore/group.h @@ -266,6 +266,13 @@ uint32_t count_chatlist(Group_Chats *g_c); * of out_list will be truncated to list_size. */ uint32_t copy_chatlist(Group_Chats *g_c, int32_t *out_list, uint32_t list_size); +/* return the type of groupchat (GROUPCHAT_TYPE_) that groupnumber is. + * + * return -1 on failure. + * return type on success. + */ +int group_get_type(const Group_Chats *g_c, int groupnumber); + /* Send current name (set in messenger) to all online groups. */ void send_name_all_groups(Group_Chats *g_c); diff --git a/toxcore/tox.c b/toxcore/tox.c index 9e9a5057..32d7f7a0 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -728,6 +728,16 @@ uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size) return copy_chatlist(m->group_chat_object, out_list, list_size); } +/* return the type of groupchat (TOX_GROUPCHAT_TYPE_) that groupnumber is. + * + * return -1 on failure. + * return type on success. + */ +int tox_group_get_type(const Tox *tox, int groupnumber) +{ + const Messenger *m = tox; + return group_get_type(m->group_chat_object, groupnumber); +} /****************FILE SENDING FUNCTIONS*****************/ diff --git a/toxcore/tox.h b/toxcore/tox.h index 4f93e608..e2f3bc3d 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -551,6 +551,13 @@ uint32_t tox_count_chatlist(const Tox *tox); * of out_list will be truncated to list_size. */ uint32_t tox_get_chatlist(const Tox *tox, int32_t *out_list, uint32_t list_size); +/* return the type of groupchat (TOX_GROUPCHAT_TYPE_) that groupnumber is. + * + * return -1 on failure. + * return type on success. + */ +int tox_group_get_type(const Tox *tox, int groupnumber); + /****************AVATAR FUNCTIONS*****************/ /* Set the callback function for avatar information.