Commit 3ea05c4b authored by Benjamin REIS's avatar Benjamin REIS

add api

parent 117ff964
......@@ -1735,6 +1735,10 @@ int linphone_friend_get_capabilities(const LinphoneFriend *lf) {
return lf->capabilities;
}
bool_t linphone_friend_has_capability(const LinphoneFriend *lf, const LinphoneFriendCapability capability) {
return lf->capabilities & capability;
}
namespace {
const std::unordered_map<std::string, LinphoneFriendCapability> StringToCapability{
{ "groupchat", LinphoneFriendCapabilityGroupChat },
......
......@@ -339,10 +339,19 @@ LINPHONE_PUBLIC void linphone_friend_save(LinphoneFriend *fr, LinphoneCore *lc);
/**
* Returns the capabilities associated to this friend
* @param[in] fr #LinphoneFriend object
* @param[in] lf #LinphoneFriend object
* @return an int representing the capabilities of the friend
*/
LINPHONE_PUBLIC int linphone_friend_get_capabilities(const LinphoneFriend *lf);
/**
* Returns whether or not a friend has a capbility
* @param[in] lf #LinphoneFriend object
* @param[in] capability #LinphoneFriendCapability object
* @return whether or not a friend has a capbility
*/
LINPHONE_PUBLIC bool_t linphone_friend_has_capability(const LinphoneFriend *lf, const LinphoneFriendCapability capability);
/**
* @}
*/
......
......@@ -298,8 +298,7 @@ LinphoneChatRoomCapabilitiesMask linphone_chat_room_get_capabilities (const Linp
}
bool_t linphone_chat_room_has_capability(const LinphoneChatRoom *cr, int mask) {
if (L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & mask) return true;
return false;
return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities() & mask;
}
const LinphoneAddress *linphone_chat_room_get_conference_address (const LinphoneChatRoom *cr) {
......
......@@ -1911,13 +1911,19 @@ static void notify_friend_capabilities(void) {
BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 5000));
BC_ASSERT_TRUE(linphone_friend_get_capabilities(paulineFriend) & LinphoneFriendCapabilityGroupChat);
BC_ASSERT_TRUE(linphone_friend_has_capability(paulineFriend, LinphoneFriendCapabilityGroupChat));
BC_ASSERT_TRUE(linphone_friend_get_capabilities(paulineFriend) & LinphoneFriendCapabilityLimeX3dh);
BC_ASSERT_TRUE(linphone_friend_has_capability(paulineFriend, LinphoneFriendCapabilityLimeX3dh));
BC_ASSERT_TRUE(linphone_friend_get_capabilities(laureFriend) & LinphoneFriendCapabilityGroupChat);
BC_ASSERT_TRUE(linphone_friend_has_capability(laureFriend, LinphoneFriendCapabilityGroupChat));
BC_ASSERT_FALSE(linphone_friend_get_capabilities(laureFriend) & LinphoneFriendCapabilityLimeX3dh);
BC_ASSERT_FALSE(linphone_friend_has_capability(laureFriend, LinphoneFriendCapabilityLimeX3dh));
BC_ASSERT_TRUE(linphone_friend_get_capabilities(chloeFriend) & LinphoneFriendCapabilityGroupChat);
BC_ASSERT_TRUE(linphone_friend_has_capability(chloeFriend, LinphoneFriendCapabilityGroupChat));
BC_ASSERT_TRUE(linphone_friend_get_capabilities(chloeFriend) & LinphoneFriendCapabilityLimeX3dh);
BC_ASSERT_TRUE(linphone_friend_has_capability(chloeFriend, LinphoneFriendCapabilityLimeX3dh));
linphone_friend_unref(paulineFriend);
linphone_friend_unref(laureFriend);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment