diff --git a/src/address/address.h b/src/address/address.h index 86549e8f9..134f7601b 100644 --- a/src/address/address.h +++ b/src/address/address.h @@ -32,6 +32,7 @@ class LINPHONE_PUBLIC Address : public ClonableObject { // TODO: Remove me later. friend class CallSession; friend class ClientGroupChatRoom; + friend class ClientGroupChatRoomPrivate; public: Address (const std::string &address = ""); diff --git a/src/chat/client-group-chat-room-p.h b/src/chat/client-group-chat-room-p.h index 346faf869..416dd29b0 100644 --- a/src/chat/client-group-chat-room-p.h +++ b/src/chat/client-group-chat-room-p.h @@ -29,11 +29,15 @@ LINPHONE_BEGIN_NAMESPACE +class CallSession; + class ClientGroupChatRoomPrivate : public ChatRoomPrivate { public: ClientGroupChatRoomPrivate (LinphoneCore *core); virtual ~ClientGroupChatRoomPrivate () = default; + std::shared_ptr createSession (); + private: L_DECLARE_PUBLIC(ClientGroupChatRoom); }; diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index 30753dbed..7afe7c70e 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -34,6 +34,21 @@ LINPHONE_BEGIN_NAMESPACE ClientGroupChatRoomPrivate::ClientGroupChatRoomPrivate (LinphoneCore *core) : ChatRoomPrivate(core) {} +// ----------------------------------------------------------------------------- + +shared_ptr ClientGroupChatRoomPrivate::createSession () { + L_Q(); + CallSessionParams csp; + csp.addCustomHeader("Require", "recipient-list-invite"); + shared_ptr session = q->focus->getPrivate()->createSession(*q, &csp, false, q); + session->configure(LinphoneCallOutgoing, nullptr, nullptr, q->me->getAddress(), q->focus->getAddress()); + session->initiateOutgoing(); + Address addr = q->me->getAddress(); + addr.setParam("text"); + session->getPrivate()->getOp()->set_contact_address(addr.getPrivate()->getInternalAddress()); + return session; +} + // ============================================================================= ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me, const string &subject) @@ -55,28 +70,27 @@ void ClientGroupChatRoom::addParticipants (const list
&addresses, const L_D(); if (addresses.empty()) return; + if ((d->state != ChatRoom::State::Instantiated) && (d->state != ChatRoom::State::Created)) { + lError() << "Cannot add participants to the ClientGroupChatRoom in a state other than Instantiated or Created"; + return; + } list
sortedAddresses(addresses); sortedAddresses.sort(); sortedAddresses.unique(); - if (d->state == ChatRoom::State::Instantiated) { - Content content; - content.setBody(getResourceLists(sortedAddresses)); - content.setContentType("application/resource-lists+xml"); - content.setContentDisposition("recipient-list"); - CallSessionParams csp; - if (params) - csp = *params; - csp.addCustomHeader("Require", "recipient-list-invite"); - shared_ptr session = focus->getPrivate()->createSession(*this, &csp, false, this); - session->configure(LinphoneCallOutgoing, nullptr, nullptr, me->getAddress(), focus->getAddress()); - session->initiateOutgoing(); - Address addr = me->getAddress(); - addr.setParam("text"); - session->getPrivate()->getOp()->set_contact_address(addr.getPrivate()->getInternalAddress()); + Content content; + content.setBody(getResourceLists(sortedAddresses)); + content.setContentType("application/resource-lists+xml"); + content.setContentDisposition("recipient-list"); + shared_ptr session = focus->getPrivate()->getSession(); + if (session) + session->update(nullptr, subject, &content); + else { + session = d->createSession(); session->startInvite(nullptr, subject, &content); - d->setState(ChatRoom::State::CreationPending); + if (d->state == ChatRoom::State::Instantiated) { + d->setState(ChatRoom::State::CreationPending); + } } - // TODO } bool ClientGroupChatRoom::canHandleParticipants () const { @@ -118,7 +132,12 @@ void ClientGroupChatRoom::setSubject (const string &subject) { return; } shared_ptr session = focus->getPrivate()->getSession(); - session->update(nullptr, subject); + if (session) + session->update(nullptr, subject); + else { + session = d->createSession(); + session->startInvite(nullptr, subject, nullptr); + } } // ----------------------------------------------------------------------------- diff --git a/src/conference/participant.h b/src/conference/participant.h index 0fbef9f00..37cbb24a1 100644 --- a/src/conference/participant.h +++ b/src/conference/participant.h @@ -35,6 +35,7 @@ class Participant : public Object { friend class Call; friend class CallPrivate; friend class ClientGroupChatRoom; + friend class ClientGroupChatRoomPrivate; friend class LocalConference; friend class MediaSessionPrivate; friend class RemoteConference; diff --git a/src/conference/session/call-session.h b/src/conference/session/call-session.h index dd8e27f2f..d09435a92 100644 --- a/src/conference/session/call-session.h +++ b/src/conference/session/call-session.h @@ -37,6 +37,7 @@ class Content; class LINPHONE_PUBLIC CallSession : public Object { friend class CallPrivate; friend class ClientGroupChatRoom; + friend class ClientGroupChatRoomPrivate; public: L_OVERRIDE_SHARED_FROM_THIS(CallSession);