From 4eb16ce346c2347809382c8046d77b391ffdfa7d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 4 Oct 2017 14:18:53 +0200 Subject: [PATCH] Do not return a Participant in the addParticipant() method of the conference interface because the addition can be done asynchronously. --- include/linphone/api/c-chat-room.h | 3 +-- src/c-wrapper/api/c-chat-room.cpp | 6 ++---- src/call/call.cpp | 3 ++- src/chat/basic-chat-room.cpp | 3 +-- src/chat/basic-chat-room.h | 2 +- src/chat/client-group-chat-room.cpp | 8 ++++---- src/chat/client-group-chat-room.h | 2 +- src/chat/real-time-text-chat-room.cpp | 3 +-- src/chat/real-time-text-chat-room.h | 2 +- src/conference/conference-interface.h | 2 +- src/conference/conference.cpp | 3 +-- src/conference/conference.h | 2 +- src/conference/local-conference.cpp | 5 ++--- src/conference/local-conference.h | 2 +- src/conference/remote-conference.cpp | 5 ++--- src/conference/remote-conference.h | 2 +- 16 files changed, 23 insertions(+), 30 deletions(-) diff --git a/include/linphone/api/c-chat-room.h b/include/linphone/api/c-chat-room.h index d98c05de9..af54a32cf 100644 --- a/include/linphone/api/c-chat-room.h +++ b/include/linphone/api/c-chat-room.h @@ -242,9 +242,8 @@ LINPHONE_PUBLIC LinphoneChatRoomState linphone_chat_room_get_state (const Linpho * Use linphone_chat_room_can_handle_participants() to know if this chat room handles participants. * @param[in] cr A LinphoneChatRoom object * @param[in] addr The address of the participant to add to the chat room - * @return The newly added participant or NULL in case of failure */ -LINPHONE_PUBLIC LinphoneParticipant * linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr); +LINPHONE_PUBLIC void linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr); /** * Add several participants to a chat room at once. This may fail if this type of chat room does not handle participants. diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index 816fbd7c2..8d5ea33b5 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -211,10 +211,8 @@ LinphoneChatRoomState linphone_chat_room_get_state (const LinphoneChatRoom *cr) return (LinphoneChatRoomState)L_GET_CPP_PTR_FROM_C_OBJECT(cr)->getState(); } -LinphoneParticipant *linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) { - return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant( - *L_GET_CPP_PTR_FROM_C_OBJECT(addr), nullptr, false) - ); +void linphone_chat_room_add_participant (LinphoneChatRoom *cr, const LinphoneAddress *addr) { + L_GET_CPP_PTR_FROM_C_OBJECT(cr)->addParticipant(*L_GET_CPP_PTR_FROM_C_OBJECT(addr), nullptr, false); } void linphone_chat_room_add_participants (LinphoneChatRoom *cr, const bctbx_list_t *addresses) { diff --git a/src/call/call.cpp b/src/call/call.cpp index ba0f12951..85e9e92ba 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -231,7 +231,8 @@ Call::Call ( d->conference = new LocalConference(core, *myAddress, d); } const Address *remoteAddress = (direction == LinphoneCallIncoming) ? &from : &to; - shared_ptr participant = d->conference->addParticipant(*remoteAddress, msp, true); + d->conference->addParticipant(*remoteAddress, msp, true); + shared_ptr participant = d->conference->getParticipants().front(); participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to); } diff --git a/src/chat/basic-chat-room.cpp b/src/chat/basic-chat-room.cpp index 949f02a39..94a30f7ae 100644 --- a/src/chat/basic-chat-room.cpp +++ b/src/chat/basic-chat-room.cpp @@ -35,9 +35,8 @@ BasicChatRoom::BasicChatRoom (LinphoneCore *core, const Address &peerAddress) : // ----------------------------------------------------------------------------- -shared_ptr BasicChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { +void BasicChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { lError() << "addParticipant() is not allowed on a BasicChatRoom"; - return nullptr; } void BasicChatRoom::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { diff --git a/src/chat/basic-chat-room.h b/src/chat/basic-chat-room.h index b80a771de..eac039d58 100644 --- a/src/chat/basic-chat-room.h +++ b/src/chat/basic-chat-room.h @@ -33,7 +33,7 @@ public: virtual ~BasicChatRoom () = default; /* ConferenceInterface. */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void addParticipants (const std::list
&addresses, const CallSessionParams *params, bool hasMedia) override; bool canHandleParticipants () const override; const Address *getConferenceAddress () const override; diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index 5b2246a5d..30753dbed 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -45,10 +45,10 @@ ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me, // ----------------------------------------------------------------------------- -shared_ptr ClientGroupChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { - activeParticipant = ObjectFactory::create(addr); - activeParticipant->getPrivate()->createSession(*this, params, hasMedia, this); - return activeParticipant; +void ClientGroupChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { + list
addresses; + addresses.push_back(addr); + addParticipants(addresses, params, hasMedia); } void ClientGroupChatRoom::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { diff --git a/src/chat/client-group-chat-room.h b/src/chat/client-group-chat-room.h index 064cc27de..ff060bf0f 100644 --- a/src/chat/client-group-chat-room.h +++ b/src/chat/client-group-chat-room.h @@ -41,7 +41,7 @@ public: public: /* ConferenceInterface */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void addParticipants (const std::list
&addresses, const CallSessionParams *params, bool hasMedia) override; bool canHandleParticipants () const override; const Address *getConferenceAddress () const override; diff --git a/src/chat/real-time-text-chat-room.cpp b/src/chat/real-time-text-chat-room.cpp index 321a0fe56..063887017 100644 --- a/src/chat/real-time-text-chat-room.cpp +++ b/src/chat/real-time-text-chat-room.cpp @@ -131,9 +131,8 @@ LinphoneCall *RealTimeTextChatRoom::getCall () const { // ----------------------------------------------------------------------------- -shared_ptr RealTimeTextChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { +void RealTimeTextChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { lError() << "addParticipant() is not allowed on a RealTimeTextChatRoom"; - return nullptr; } void RealTimeTextChatRoom::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { diff --git a/src/chat/real-time-text-chat-room.h b/src/chat/real-time-text-chat-room.h index f9a7c077c..3f2dd2edf 100644 --- a/src/chat/real-time-text-chat-room.h +++ b/src/chat/real-time-text-chat-room.h @@ -43,7 +43,7 @@ public: LinphoneCall *getCall () const; /* ConferenceInterface */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void addParticipants (const std::list
&addresses, const CallSessionParams *params, bool hasMedia) override; bool canHandleParticipants () const override; const Address *getConferenceAddress () const override; diff --git a/src/conference/conference-interface.h b/src/conference/conference-interface.h index 1058ff8e6..43e711d68 100644 --- a/src/conference/conference-interface.h +++ b/src/conference/conference-interface.h @@ -34,7 +34,7 @@ class LINPHONE_PUBLIC ConferenceInterface { public: virtual ~ConferenceInterface() = default; - virtual std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) = 0; + virtual void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) = 0; virtual void addParticipants (const std::list
&addresses, const CallSessionParams *params, bool hasMedia) = 0; virtual bool canHandleParticipants () const = 0; virtual const Address *getConferenceAddress () const = 0; diff --git a/src/conference/conference.cpp b/src/conference/conference.cpp index 2ae674663..1496fa327 100644 --- a/src/conference/conference.cpp +++ b/src/conference/conference.cpp @@ -40,9 +40,8 @@ shared_ptr Conference::getActiveParticipant () const { // ----------------------------------------------------------------------------- -shared_ptr Conference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { +void Conference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { lError() << "Conference class does not handle addParticipant() generically"; - return nullptr; } void Conference::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { diff --git a/src/conference/conference.h b/src/conference/conference.h index e83debbbe..fe4b2f80d 100644 --- a/src/conference/conference.h +++ b/src/conference/conference.h @@ -47,7 +47,7 @@ public: public: /* ConferenceInterface */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void addParticipants (const std::list
&addresses, const CallSessionParams *params, bool hasMedia) override; bool canHandleParticipants () const override; const Address *getConferenceAddress () const override; diff --git a/src/conference/local-conference.cpp b/src/conference/local-conference.cpp index baad5dda5..f4de96ccd 100644 --- a/src/conference/local-conference.cpp +++ b/src/conference/local-conference.cpp @@ -38,16 +38,15 @@ LocalConference::~LocalConference () { // ----------------------------------------------------------------------------- -shared_ptr LocalConference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { +void LocalConference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { shared_ptr participant = findParticipant(addr); if (participant) - return participant; + return; participant = ObjectFactory::create(addr); participant->getPrivate()->createSession(*this, params, hasMedia, this); participants.push_back(participant); if (!activeParticipant) activeParticipant = participant; - return participant; } void LocalConference::removeParticipant (const shared_ptr &participant) { diff --git a/src/conference/local-conference.h b/src/conference/local-conference.h index c36bf9064..7e74992be 100644 --- a/src/conference/local-conference.h +++ b/src/conference/local-conference.h @@ -35,7 +35,7 @@ public: public: /* ConferenceInterface */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void removeParticipant (const std::shared_ptr &participant) override; std::list
parseResourceLists (std::string xmlBody); diff --git a/src/conference/remote-conference.cpp b/src/conference/remote-conference.cpp index d3e1b2f04..e2cafec44 100644 --- a/src/conference/remote-conference.cpp +++ b/src/conference/remote-conference.cpp @@ -39,16 +39,15 @@ RemoteConference::~RemoteConference () { // ----------------------------------------------------------------------------- -shared_ptr RemoteConference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { +void RemoteConference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { shared_ptr participant = findParticipant(addr); if (participant) - return participant; + return; participant = ObjectFactory::create(addr); participant->getPrivate()->createSession(*this, params, hasMedia, this); participants.push_back(participant); if (!activeParticipant) activeParticipant = participant; - return participant; } void RemoteConference::removeParticipant (const shared_ptr &participant) { diff --git a/src/conference/remote-conference.h b/src/conference/remote-conference.h index cf2956fed..5a31c119f 100644 --- a/src/conference/remote-conference.h +++ b/src/conference/remote-conference.h @@ -36,7 +36,7 @@ protected: public: /* ConferenceInterface */ - std::shared_ptr addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; + void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override; void removeParticipant (const std::shared_ptr &participant) override; std::string getResourceLists (const std::list
&addresses);