Commit 1cf7027e authored by Ghislain MARY's avatar Ghislain MARY

Add fetch of participant devices, checking of their capabilities and improve group chat tests.

parent 5b31f56f
......@@ -2143,7 +2143,7 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
if (chatRoom) {
shared_ptr<ClientGroupChatRoom> cgcr;
if (chatRoom->getCapabilities() & static_cast<int>(ChatRoom::Capabilities::Proxy))
if (chatRoom->getCapabilities() & ChatRoom::Capabilities::Proxy)
cgcr = static_pointer_cast<ClientGroupChatRoom>(
static_pointer_cast<ClientGroupToBasicChatRoom>(chatRoom)->getProxiedChatRoom());
else
......
......@@ -234,6 +234,21 @@ typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom
*/
typedef void (*LinphoneChatRoomCbsConferenceAddressGenerationCb) (LinphoneChatRoom *cr);
/**
* Callback used when a group chat room server is adding participant to fetch all device information from participant.
* @param[in] cr #LinphoneChatRoom object
* @param[in] participantAddr #LinphoneAddress object
*/
typedef void (*LinphoneChatRoomCbsParticipantDeviceFetchedCb) (LinphoneChatRoom *cr, const LinphoneAddress *participantAddr);
/**
* Callback used when a group chat room server is checking participants capabilities.
* @param[in] cr #LinphoneChatRoom object
* @param[in] deviceAddr #LinphoneAddress object
* @param[in] participantsAddr \bctbx_list{LinphoneAddress}
*/
typedef void (*LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb) (LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsAddr);
/**
* @}
**/
......
......@@ -243,6 +243,34 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsConferenceAddressGenerationCb linphone_chat_r
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_conference_address_generation (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsConferenceAddressGenerationCb cb);
/**
* Get the participant device getting callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @return The participant device getting callback
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsParticipantDeviceFetchedCb linphone_chat_room_cbs_get_participant_device_fetched (const LinphoneChatRoomCbs *cbs);
/**
* Set the participant device getting callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @param[in] cb The participant device getting callback to be used
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_participant_device_fetched (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantDeviceFetchedCb cb);
/**
* Get the participants capabilities callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @return The participants capabilities getting callback
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb linphone_chat_room_cbs_get_participants_capabilities_checked (const LinphoneChatRoomCbs *cbs);
/**
* Set the participants capabilities callback.
* @param[in] cbs LinphoneChatRoomCbs object
* @param[in] cb The participants capabilities callback to be used
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_participants_capabilities_checked (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb cb);
/**
* @}
*/
......
......@@ -317,7 +317,7 @@ LINPHONE_PUBLIC LinphoneParticipant *linphone_chat_room_find_participant (const
* @param[in] cr A LinphoneChatRoom object
* @return The capabilities of the chat room
*/
LINPHONE_PUBLIC LinphoneChatRoomCapabilities linphone_chat_room_get_capabilities (const LinphoneChatRoom *cr);
LINPHONE_PUBLIC LinphoneChatRoomCapabilitiesMask linphone_chat_room_get_capabilities (const LinphoneChatRoom *cr);
/**
* Get the conference address of the chat room.
......@@ -404,6 +404,24 @@ LINPHONE_PUBLIC const bctbx_list_t * linphone_chat_room_get_composing_addresses(
*/
LINPHONE_PUBLIC void linphone_chat_room_set_conference_address (LinphoneChatRoom *cr, const LinphoneAddress *confAddr);
/**
* Set the participant device. This function needs to be called from the
* LinphoneChatRoomCbsParticipantDeviceFetchedCb callback and only there.
* @param[in] cr A LinphoneChatRoom object
* @param[in] partAddr The participant address
* @param[in] partDevices \bctbx_list{LinphoneAddress} list of the participant devices to be used by the group chat room
*/
LINPHONE_PUBLIC void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *partDevices);
/**
* Set the participant device. This function needs to be called from the
* LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb callback and only there.
* @param[in] cr A LinphoneChatRoom object
* @param[in] deviceAddr The device address
* @param[in] participantsCompatible \bctbx_list{LinphoneAddress}
*/
LINPHONE_PUBLIC void linphone_chat_room_add_compatible_participants (LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsCompatible);
/**
* Returns back pointer to #LinphoneCore object.
* @deprecated use linphone_chat_room_get_core()
......
......@@ -117,6 +117,12 @@ typedef struct _LinphoneChatMessageCbs LinphoneChatMessageCbs;
*/
typedef struct _LinphoneChatRoom LinphoneChatRoom;
/**
* A mask of LinphoneChatRoomCapabilities
* @ingroup chatroom
*/
typedef int LinphoneChatRoomCapabilitiesMask;
/**
* An object to handle the callbacks for the handling a LinphoneChatRoom objects.
* @ingroup chatroom
......
......@@ -39,6 +39,8 @@ struct _LinphoneChatRoomCbs {
LinphoneChatRoomCbsChatMessageReceivedCb chatMessageReceivedCb;
LinphoneChatRoomCbsChatMessageSentCb chatMessageSentCb;
LinphoneChatRoomCbsConferenceAddressGenerationCb conferenceAddressGenerationCb;
LinphoneChatRoomCbsParticipantDeviceFetchedCb participantDeviceFetchedCb;
LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb participantsCapabilitiesChecked;
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneChatRoomCbs);
......@@ -178,3 +180,19 @@ LinphoneChatRoomCbsConferenceAddressGenerationCb linphone_chat_room_cbs_get_conf
void linphone_chat_room_cbs_set_conference_address_generation (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsConferenceAddressGenerationCb cb) {
cbs->conferenceAddressGenerationCb = cb;
}
LinphoneChatRoomCbsParticipantDeviceFetchedCb linphone_chat_room_cbs_get_participant_device_fetched (const LinphoneChatRoomCbs *cbs) {
return cbs->participantDeviceFetchedCb;
}
void linphone_chat_room_cbs_set_participant_device_fetched (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantDeviceFetchedCb cb) {
cbs->participantDeviceFetchedCb = cb;
}
LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb linphone_chat_room_cbs_get_participants_capabilities_checked (const LinphoneChatRoomCbs *cbs) {
return cbs->participantsCapabilitiesChecked;
}
void linphone_chat_room_cbs_set_participants_capabilities_checked (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantsCapabilitiesCheckedCb cb) {
cbs->participantsCapabilitiesChecked = cb;
}
......@@ -70,6 +70,13 @@ static void _linphone_chat_room_destructor (LinphoneChatRoom *cr) {
bctbx_list_free_with_data(cr->composingAddresses, (bctbx_list_free_func)linphone_address_unref);
}
static list<LinphonePrivate::IdentityAddress> _get_identity_address_list_from_address_list(list<LinphonePrivate::Address> addressList) {
list<LinphonePrivate::IdentityAddress> lIdent;
for (const auto &addr : addressList)
lIdent.push_back(LinphonePrivate::IdentityAddress(addr));
return lIdent;
}
// =============================================================================
// Public functions.
// =============================================================================
......@@ -265,8 +272,8 @@ LinphoneParticipant *linphone_chat_room_find_participant (const LinphoneChatRoom
));
}
LinphoneChatRoomCapabilities linphone_chat_room_get_capabilities (const LinphoneChatRoom *cr) {
return (LinphoneChatRoomCapabilities)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities();
LinphoneChatRoomCapabilitiesMask linphone_chat_room_get_capabilities (const LinphoneChatRoom *cr) {
return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getCapabilities();
}
const LinphoneAddress *linphone_chat_room_get_conference_address (const LinphoneChatRoom *cr) {
......@@ -350,6 +357,30 @@ void linphone_chat_room_set_conference_address (LinphoneChatRoom *cr, const Linp
bctbx_free(addrStr);
}
void linphone_chat_room_set_participant_devices (LinphoneChatRoom *cr, const LinphoneAddress *partAddr, const bctbx_list_t *partDevices) {
char *addrStr = linphone_address_as_string(partAddr);
list<LinphonePrivate::Address> lDevices = L_GET_RESOLVED_CPP_LIST_FROM_C_LIST(partDevices, Address);
list<LinphonePrivate::IdentityAddress> lIdentAddr;
for (const auto &addr : lDevices)
lIdentAddr.push_back(LinphonePrivate::IdentityAddress(addr));
LinphonePrivate::ServerGroupChatRoomPrivate *sgcr = dynamic_cast<LinphonePrivate::ServerGroupChatRoomPrivate *>(L_GET_PRIVATE_FROM_C_OBJECT(cr));
if (sgcr)
sgcr->setParticipantDevices(LinphonePrivate::IdentityAddress(addrStr), lIdentAddr);
bctbx_free(addrStr);
}
void linphone_chat_room_add_compatible_participants (LinphoneChatRoom *cr, const LinphoneAddress *deviceAddr, const bctbx_list_t *participantsCompatible) {
list<LinphonePrivate::Address> lPartsComp = L_GET_RESOLVED_CPP_LIST_FROM_C_LIST(participantsCompatible, Address);
LinphonePrivate::ServerGroupChatRoomPrivate *sgcr = dynamic_cast<LinphonePrivate::ServerGroupChatRoomPrivate *>(L_GET_PRIVATE_FROM_C_OBJECT(cr));
if (sgcr) {
char *deviceAddrStr = linphone_address_as_string_uri_only(deviceAddr);
sgcr->addCompatibleParticipants(LinphonePrivate::IdentityAddress(deviceAddrStr),
_get_identity_address_list_from_address_list(lPartsComp)
);
bctbx_free(deviceAddrStr);
}
}
// =============================================================================
// Reference and user data handling functions.
// =============================================================================
......
......@@ -46,7 +46,7 @@ public:
}
void onCallSessionSetReleased (const std::shared_ptr<const CallSession> &session) override {
if (!(chatRoom->getCapabilities() & static_cast<int>(ChatRoom::Capabilities::Conference)))
if (!(chatRoom->getCapabilities() & ChatRoom::Capabilities::Conference))
return;
static_pointer_cast<ClientGroupChatRoom>(chatRoom)->getPrivate()->onCallSessionSetReleased(session);
}
......
......@@ -68,7 +68,7 @@ time_t ProxyChatRoom::getLastUpdateTime () const {
ProxyChatRoom::CapabilitiesMask ProxyChatRoom::getCapabilities () const {
L_D();
return d->chatRoom->getCapabilities() | static_cast<int>(ProxyChatRoom::Capabilities::Proxy);
return d->chatRoom->getCapabilities() | ProxyChatRoom::Capabilities::Proxy;
}
ProxyChatRoom::State ProxyChatRoom::getState () const {
......
......@@ -46,6 +46,7 @@ public:
void setConferenceAddress (const IdentityAddress &conferenceAddress);
void setParticipantDevices (const IdentityAddress &addr, const std::list<IdentityAddress> &devices);
void addCompatibleParticipants (const IdentityAddress &deviceAddr, const std::list<IdentityAddress> &participantCompatible);
LinphoneReason onSipMessageReceived (SalOp *op, const SalMessage *message) override;
......
......@@ -64,6 +64,8 @@ void ServerGroupChatRoomPrivate::setConferenceAddress (const IdentityAddress &)
void ServerGroupChatRoomPrivate::setParticipantDevices (const IdentityAddress &addr, const list<IdentityAddress> &devices) {}
void ServerGroupChatRoomPrivate::addCompatibleParticipants (const IdentityAddress &deviceAddr, const list<IdentityAddress> &participantCompatible) {}
// -----------------------------------------------------------------------------
LinphoneReason ServerGroupChatRoomPrivate::onSipMessageReceived (SalOp *, const SalMessage *) {
......@@ -82,6 +84,14 @@ bool ServerGroupChatRoomPrivate::isAdminLeft () const {
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::onChatRoomInsertRequested (const shared_ptr<AbstractChatRoom> &chatRoom) {}
void ServerGroupChatRoomPrivate::onChatRoomInsertInDatabaseRequested (const shared_ptr<AbstractChatRoom> &chatRoom) {}
void ServerGroupChatRoomPrivate::onChatRoomDeleteRequested (const shared_ptr<AbstractChatRoom> &chatRoom) {}
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::onCallSessionStateChanged (
const shared_ptr<const CallSession> &,
LinphoneCallState,
......
This diff is collapsed.
......@@ -319,6 +319,8 @@ void liblinphone_tester_add_suites(void);
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, const char* phone_alias);
void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_create2(const char* rc_file, const char* phone_alias);
LinphoneCoreManager* linphone_core_manager_create(const char* rc_file);
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias);
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file);
......
......@@ -426,10 +426,18 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
}
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) {
LinphoneCoreManager* linphone_core_manager_create2(const char* rc_file, const char* phone_alias) {
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(manager, rc_file, phone_alias);
return manager;
}
LinphoneCoreManager* linphone_core_manager_create(const char* rc_file) {
return linphone_core_manager_create2(rc_file, NULL);
}
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) {
LinphoneCoreManager *manager = linphone_core_manager_create2(rc_file, phone_alias);
linphone_core_manager_start(manager, check_for_proxies);
return manager;
}
......
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