Commit 5fb8f968 authored by Ghislain MARY's avatar Ghislain MARY

Handle incoming INVITE from conference server to create ClientGroupChatRoom.

parent d1a68a0e
This diff is collapsed.
......@@ -919,8 +919,11 @@ void linphone_core_report_call_log(LinphoneCore *lc, LinphoneCallLog *call_log){
}
linphone_address_unref(conference_factory_addr);
}
const char *username = linphone_address_get_username(call_log->to);
if (username && (strstr(username, "chatroom-") == username))
const char *usernameFrom = linphone_address_get_username(call_log->from);
const char *usernameTo = linphone_address_get_username(call_log->to);
if ((usernameFrom && (strstr(usernameFrom, "chatroom-") == usernameFrom))
|| (usernameTo && (strstr(usernameTo, "chatroom-") == usernameTo))
)
return;
// End of workaround
......
......@@ -288,6 +288,7 @@ void _linphone_chat_room_notify_participant_device_removed(LinphoneChatRoom *cr,
void _linphone_chat_room_notify_participant_admin_status_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState);
void _linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_all_information_received(LinphoneChatRoom *cr);
void _linphone_chat_room_notify_undecryptable_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg);
void _linphone_chat_room_notify_chat_message_received(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
void _linphone_chat_room_notify_chat_message_sent(LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
......
......@@ -235,6 +235,12 @@ typedef void (*LinphoneChatRoomCbsParticipantDeviceAddedCb) (LinphoneChatRoom *c
*/
typedef void (*LinphoneChatRoomCbsParticipantDeviceRemovedCb) (LinphoneChatRoom *cr, const LinphoneEventLog *event_log);
/**
* Callback used to notify a chat room has received all its information.
* @param[in] cr #LinphoneChatRoom object
*/
typedef void (*LinphoneChatRoomCbsAllInformationReceivedCb) (LinphoneChatRoom *cr);
/**
* Callback used when a group chat room is created server-side to generate the address of the chat room.
* The function linphone_chat_room_set_conference_address() needs to be called by this callback.
......
......@@ -229,6 +229,20 @@ LINPHONE_PUBLIC LinphoneChatRoomCbsParticipantDeviceRemovedCb linphone_chat_room
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_participant_device_removed (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsParticipantDeviceRemovedCb cb);
/**
* Get the all information received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @return The current all information received callback.
*/
LINPHONE_PUBLIC LinphoneChatRoomCbsAllInformationReceivedCb linphone_chat_room_cbs_get_all_information_received (const LinphoneChatRoomCbs *cbs);
/**
* Set the all information received callback.
* @param[in] cbs LinphoneChatRoomCbs object.
* @param[in] cb The all information received callback to be used.
*/
LINPHONE_PUBLIC void linphone_chat_room_cbs_set_all_information_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsAllInformationReceivedCb cb);
/**
* Get the conference address generation callback.
* @param[in] cbs LinphoneChatRoomCbs object
......
......@@ -35,6 +35,7 @@ struct _LinphoneChatRoomCbs {
LinphoneChatRoomCbsParticipantAdminStatusChangedCb participantAdminStatusChangedCb;
LinphoneChatRoomCbsStateChangedCb stateChangedCb;
LinphoneChatRoomCbsSubjectChangedCb subjectChangedCb;
LinphoneChatRoomCbsAllInformationReceivedCb allInformationReceivedCb;
LinphoneChatRoomCbsUndecryptableMessageReceivedCb undecryptableMessageReceivedCb;
LinphoneChatRoomCbsChatMessageReceivedCb chatMessageReceivedCb;
LinphoneChatRoomCbsChatMessageSentCb chatMessageSentCb;
......@@ -176,6 +177,14 @@ void linphone_chat_room_cbs_set_participant_device_removed (LinphoneChatRoomCbs
cbs->participantDeviceRemovedCb = cb;
}
LinphoneChatRoomCbsAllInformationReceivedCb linphone_chat_room_cbs_get_all_information_received (const LinphoneChatRoomCbs *cbs) {
return cbs->allInformationReceivedCb;
}
void linphone_chat_room_cbs_set_all_information_received (LinphoneChatRoomCbs *cbs, LinphoneChatRoomCbsAllInformationReceivedCb cb) {
cbs->allInformationReceivedCb = cb;
}
LinphoneChatRoomCbsConferenceAddressGenerationCb linphone_chat_room_cbs_get_conference_address_generation (const LinphoneChatRoomCbs *cbs) {
return cbs->conferenceAddressGenerationCb;
}
......
......@@ -480,6 +480,10 @@ void _linphone_chat_room_notify_subject_changed(LinphoneChatRoom *cr, const Linp
NOTIFY_IF_EXIST(SubjectChanged, subject_changed, cr, event_log)
}
void _linphone_chat_room_notify_all_information_received(LinphoneChatRoom *cr) {
NOTIFY_IF_EXIST(AllInformationReceived, all_information_received, cr)
}
void _linphone_chat_room_notify_undecryptable_message_received(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
NOTIFY_IF_EXIST(UndecryptableMessageReceived, undecryptable_message_received, cr, msg)
}
......
......@@ -88,7 +88,7 @@ void BasicChatRoom::addParticipants (const list<IdentityAddress> &, const CallSe
lError() << "addParticipants() is not allowed on a BasicChatRoom";
}
void BasicChatRoom::removeParticipant (const shared_ptr<const Participant> &) {
void BasicChatRoom::removeParticipant (const shared_ptr<Participant> &) {
lError() << "removeParticipant() is not allowed on a BasicChatRoom";
}
......
......@@ -48,7 +48,7 @@ public:
void addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) override;
void addParticipants (const std::list<IdentityAddress> &addresses, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
std::shared_ptr<Participant> findParticipant (const IdentityAddress &addr) const override;
......
......@@ -78,7 +78,7 @@ public:
}
migrationRealTime = currentRealTime;
clientGroupChatRoom = static_pointer_cast<ClientGroupChatRoom>(
chatRoom->getCore()->getPrivate()->createClientGroupChatRoom(chatRoom->getSubject(), "", false)
chatRoom->getCore()->getPrivate()->createClientGroupChatRoom(chatRoom->getSubject(), "", Content(), false)
);
clientGroupChatRoom->getPrivate()->setCallSessionListener(this);
clientGroupChatRoom->getPrivate()->setChatRoomListener(this);
......
......@@ -35,6 +35,7 @@ public:
void notifyReceived (const std::string &body);
void multipartNotifyReceived (const std::string &body);
void confirmJoining (SalCallOp *op);
void setCallSessionListener (CallSessionListener *listener);
void setChatRoomListener (ChatRoomListener *listener) { chatRoomListener = listener; }
......@@ -47,12 +48,16 @@ public:
void onCallSessionSetReleased (const std::shared_ptr<CallSession> &session) override;
void onCallSessionStateChanged (const std::shared_ptr<CallSession> &session, CallSession::State state, const std::string &message) override;
void onChatRoomCreated (const Address &remoteContact);
private:
void acceptSession (const std::shared_ptr<CallSession> &session);
CallSessionListener *callSessionListener = this;
ChatRoomListener *chatRoomListener = this;
ClientGroupChatRoom::CapabilitiesMask capabilities = ClientGroupChatRoom::Capabilities::Conference;
bool deletionOnTerminationEnabled = false;
BackgroundTask bgTask;
BackgroundTask bgTask { "Subscribe/notify of full state conference" };
L_DECLARE_PUBLIC(ClientGroupChatRoom);
};
......
......@@ -101,6 +101,31 @@ void ClientGroupChatRoomPrivate::setCallSessionListener (CallSessionListener *li
}
}
void ClientGroupChatRoomPrivate::confirmJoining (SalCallOp *op) {
L_Q();
L_Q_T(RemoteConference, qConference);
auto focus = qConference->getPrivate()->focus;
bool previousSession = (focus->getPrivate()->getSession() != nullptr);
auto session = focus->getPrivate()->createSession(*q, nullptr, false, this);
session->configure(LinphoneCallIncoming, nullptr, op, Address(op->get_from()), Address(op->get_to()));
session->startIncomingNotification(false);
if (!previousSession) {
setState(ClientGroupChatRoom::State::CreationPending);
// Handle participants addition
list<IdentityAddress> identAddresses = ClientGroupChatRoom::parseResourceLists(op->get_remote_body());
for (const auto &addr : identAddresses) {
auto participant = q->findParticipant(addr);
if (!participant) {
participant = make_shared<Participant>(addr);
qConference->getPrivate()->participants.push_back(participant);
}
}
}
acceptSession(session);
}
// -----------------------------------------------------------------------------
void ClientGroupChatRoomPrivate::onChatRoomInsertRequested (const shared_ptr<AbstractChatRoom> &chatRoom) {
......@@ -139,14 +164,11 @@ void ClientGroupChatRoomPrivate::onCallSessionStateChanged (
if (newState == CallSession::State::Connected) {
if (q->getState() == ChatRoom::State::CreationPending) {
IdentityAddress addr(session->getRemoteContactAddress()->asStringUriOnly());
q->onConferenceCreated(addr);
if (session->getRemoteContactAddress()->hasParam("isfocus")) {
bgTask.start(q->getCore(), 32); // It will be stopped when receiving the first notify
qConference->getPrivate()->eventHandler->subscribe(q->getChatRoomId());
}
onChatRoomCreated(*session->getRemoteContactAddress());
} else if (q->getState() == ChatRoom::State::TerminationPending)
qConference->getPrivate()->focus->getPrivate()->getSession()->terminate();
} else if (newState == CallSession::State::End) {
q->onConferenceTerminated(q->getConferenceAddress());
} else if (newState == CallSession::State::Released) {
if (q->getState() == ChatRoom::State::TerminationPending) {
if (session->getReason() == LinphoneReasonNone) {
......@@ -174,23 +196,46 @@ void ClientGroupChatRoomPrivate::onCallSessionStateChanged (
}
}
void ClientGroupChatRoomPrivate::onChatRoomCreated (const Address &remoteContact) {
L_Q();
L_Q_T(RemoteConference, qConference);
IdentityAddress addr(remoteContact);
q->onConferenceCreated(addr);
if (remoteContact.hasParam("isfocus")) {
bgTask.start(q->getCore(), 32); // It will be stopped when receiving the first notify
qConference->getPrivate()->eventHandler->subscribe(q->getChatRoomId());
}
}
// -----------------------------------------------------------------------------
void ClientGroupChatRoomPrivate::acceptSession (const shared_ptr<CallSession> &session) {
if (session->getState() == CallSession::State::UpdatedByRemote)
session->acceptUpdate();
else
session->accept();
}
// =============================================================================
ClientGroupChatRoom::ClientGroupChatRoom (
const shared_ptr<Core> &core,
const string &uri,
const IdentityAddress &me,
const string &subject
const string &subject,
const Content &content
) : ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)),
RemoteConference(core, me, nullptr) {
L_D_T(RemoteConference, dConference);
L_D();
IdentityAddress focusAddr(uri);
dConference->focus = make_shared<Participant>(focusAddr);
dConference->focus->getPrivate()->addDevice(focusAddr);
RemoteConference::setSubject(subject);
d->bgTask.setName("Subscribe/notify of full state conference");
list<IdentityAddress> identAddresses = Conference::parseResourceLists(content);
for (const auto &addr : identAddresses)
dConference->participants.push_back(make_shared<Participant>(addr));
}
ClientGroupChatRoom::ClientGroupChatRoom (
......@@ -251,7 +296,7 @@ ClientGroupChatRoom::CapabilitiesMask ClientGroupChatRoom::getCapabilities () co
}
bool ClientGroupChatRoom::hasBeenLeft () const {
return getState() != State::Created;
return (getState() != State::Created);
}
bool ClientGroupChatRoom::canHandleParticipants () const {
......@@ -328,7 +373,7 @@ void ClientGroupChatRoom::addParticipants (
}
}
void ClientGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
void ClientGroupChatRoom::removeParticipant (const shared_ptr<Participant> &participant) {
LinphoneCore *cCore = getCore()->getCCore();
SalReferOp *referOp = new SalReferOp(cCore->sal);
......@@ -422,7 +467,8 @@ void ClientGroupChatRoom::join () {
if (session) {
if (getState() != ChatRoom::State::TerminationPending)
session->startInvite(nullptr, "", nullptr);
d->setState(ChatRoom::State::CreationPending);
if (getState() != ChatRoom::State::Created)
d->setState(ChatRoom::State::CreationPending);
}
}
......@@ -454,6 +500,7 @@ void ClientGroupChatRoom::onConferenceCreated (const IdentityAddress &addr) {
dConference->focus->getPrivate()->addDevice(addr);
d->chatRoomId = ChatRoomId(addr, d->chatRoomId.getLocalAddress());
d->chatRoomListener->onChatRoomInsertRequested(getSharedFromThis());
d->setState(ChatRoom::State::Created);
}
void ClientGroupChatRoom::onConferenceKeywordsChanged (const vector<string> &keywords) {
......@@ -464,6 +511,7 @@ void ClientGroupChatRoom::onConferenceKeywordsChanged (const vector<string> &key
void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
L_D();
L_D_T(RemoteConference, dConference);
dConference->eventHandler->unsubscribe();
dConference->eventHandler->resetLastNotify();
d->setState(ChatRoom::State::Terminated);
d->addEvent(make_shared<ConferenceEvent>(
......@@ -479,21 +527,26 @@ void ClientGroupChatRoom::onConferenceTerminated (const IdentityAddress &addr) {
void ClientGroupChatRoom::onFirstNotifyReceived (const IdentityAddress &addr) {
L_D();
d->setState(ChatRoom::State::Created);
bool performMigration = false;
shared_ptr<AbstractChatRoom> chatRoom;
if (getParticipantCount() == 1) {
ChatRoomId id(getParticipants().front()->getAddress(), getMe()->getAddress());
shared_ptr<AbstractChatRoom> chatRoom = getCore()->findChatRoom(id);
if (chatRoom && (chatRoom->getCapabilities() & ChatRoom::Capabilities::Basic)) {
BasicToClientGroupChatRoom::migrate(getSharedFromThis(), chatRoom);
d->bgTask.stop();
return;
}
chatRoom = getCore()->findChatRoom(id);
if (chatRoom && (chatRoom->getCapabilities() & ChatRoom::Capabilities::Basic))
performMigration = true;
}
d->chatRoomListener->onChatRoomInsertInDatabaseRequested(getSharedFromThis());
if (performMigration)
BasicToClientGroupChatRoom::migrate(getSharedFromThis(), chatRoom);
else
d->chatRoomListener->onChatRoomInsertInDatabaseRequested(getSharedFromThis());
LinphoneChatRoom *cr = d->getCChatRoom();
_linphone_chat_room_notify_all_information_received(cr);
d->bgTask.stop();
// TODO: Bug. Event is inserted many times.
// Avoid this in the future. Deal with signals/slots system.
#if 0
......
......@@ -43,7 +43,8 @@ public:
const std::shared_ptr<Core> &core,
const std::string &factoryUri,
const IdentityAddress &me,
const std::string &subject
const std::string &subject,
const Content &content
);
ClientGroupChatRoom (
......@@ -77,7 +78,7 @@ public:
void addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) override;
void addParticipants (const std::list<IdentityAddress> &addresses, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
std::shared_ptr<Participant> findParticipant (const IdentityAddress &addr) const override;
......
......@@ -248,7 +248,7 @@ void ProxyChatRoom::addParticipants (
return d->chatRoom->addParticipants(addresses, params, hasMedia);
}
void ProxyChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
void ProxyChatRoom::removeParticipant (const shared_ptr<Participant> &participant) {
L_D();
d->chatRoom->removeParticipant(participant);
}
......
......@@ -97,7 +97,7 @@ public:
bool hasMedia
) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
std::shared_ptr<Participant> findParticipant (const IdentityAddress &participantAddress) const override;
......
......@@ -91,6 +91,7 @@ private:
static void copyMessageHeaders (const std::shared_ptr<Message> &fromMessage, const std::shared_ptr<ChatMessage> &toMessage);
void byeDevice (const std::shared_ptr<ParticipantDevice> &device);
void designateAdmin ();
void dispatchMessage (const std::shared_ptr<Message> &message, const std::string &uri);
void finalizeCreation ();
......@@ -100,7 +101,7 @@ private:
void queueMessage (const std::shared_ptr<Message> &msg, const IdentityAddress &deviceAddress);
void removeNonPresentParticipants (const std::list <IdentityAddress> &compatibleParticipants);
void onParticipantDeviceLeft (const std::shared_ptr<const CallSession> &session);
void onParticipantDeviceLeft (const std::shared_ptr<ParticipantDevice> &device);
// ChatRoomListener
void onChatRoomInsertRequested (const std::shared_ptr<AbstractChatRoom> &chatRoom) override;
......
......@@ -92,6 +92,8 @@ LinphoneReason ServerGroupChatRoomPrivate::onSipMessageReceived (SalOp *, const
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::byeDevice (const shared_ptr<ParticipantDevice> &device) {}
void ServerGroupChatRoomPrivate::designateAdmin () {}
void ServerGroupChatRoomPrivate::dispatchMessage (const shared_ptr<Message> &message, const string &uri) {}
......@@ -112,7 +114,7 @@ void ServerGroupChatRoomPrivate::removeNonPresentParticipants (const list <Ident
// -----------------------------------------------------------------------------
void ServerGroupChatRoomPrivate::onParticipantDeviceLeft (const shared_ptr<const CallSession> &session) {}
void ServerGroupChatRoomPrivate::onParticipantDeviceLeft (const shared_ptr<ParticipantDevice> &device) {}
// -----------------------------------------------------------------------------
......@@ -187,7 +189,7 @@ void ServerGroupChatRoom::addParticipant (const IdentityAddress &, const CallSes
void ServerGroupChatRoom::addParticipants (const list<IdentityAddress> &, const CallSessionParams *, bool) {}
void ServerGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &) {}
void ServerGroupChatRoom::removeParticipant (const shared_ptr<Participant> &participant) {}
void ServerGroupChatRoom::removeParticipants (const list<shared_ptr<Participant>> &) {}
......
......@@ -68,7 +68,7 @@ public:
bool hasMedia
) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
std::shared_ptr<Participant> findParticipant (const IdentityAddress &participantAddress) const override;
......
......@@ -55,7 +55,7 @@ public:
virtual const std::string &getSubject () const = 0;
virtual void join () = 0;
virtual void leave () = 0;
virtual void removeParticipant (const std::shared_ptr<const Participant> &participant) = 0;
virtual void removeParticipant (const std::shared_ptr<Participant> &participant) = 0;
virtual void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) = 0;
virtual void setParticipantAdminStatus (const std::shared_ptr<Participant> &participant, bool isAdmin) = 0;
virtual void setSubject (const std::string &subject) = 0;
......
......@@ -19,8 +19,12 @@
#include "conference-p.h"
#include "conference/session/call-session-p.h"
#include "content/content.h"
#include "content/content-disposition.h"
#include "content/content-type.h"
#include "logger/logger.h"
#include "participant-p.h"
#include "xml/resource-lists.h"
// =============================================================================
......@@ -97,7 +101,7 @@ void Conference::join () {}
void Conference::leave () {}
void Conference::removeParticipant (const shared_ptr<const Participant> &participant) {
void Conference::removeParticipant (const shared_ptr<Participant> &participant) {
lError() << "Conference class does not handle removeParticipant() generically";
}
......@@ -154,6 +158,8 @@ shared_ptr<ParticipantDevice> Conference::findParticipantDevice (const shared_pt
return nullptr;
}
// -----------------------------------------------------------------------------
bool Conference::isMe (const IdentityAddress &addr) const {
L_D();
IdentityAddress cleanedAddr(addr);
......@@ -163,4 +169,46 @@ bool Conference::isMe (const IdentityAddress &addr) const {
return cleanedMeAddr == cleanedAddr;
}
// -----------------------------------------------------------------------------
string Conference::getResourceLists (const list<IdentityAddress> &addresses) const {
Xsd::ResourceLists::ResourceLists rl = Xsd::ResourceLists::ResourceLists();
Xsd::ResourceLists::ListType l = Xsd::ResourceLists::ListType();
for (const auto &addr : addresses) {
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asString());
l.getEntry().push_back(entry);
}
rl.getList().push_back(l);
Xsd::XmlSchema::NamespaceInfomap map;
stringstream xmlBody;
serializeResourceLists(xmlBody, rl, map);
return xmlBody.str();
}
// -----------------------------------------------------------------------------
list<IdentityAddress> Conference::parseResourceLists (const Content &content) {
if ((content.getContentType() == ContentType::ResourceLists)
&& ((content.getContentDisposition().weakEqual(ContentDisposition::RecipientList))
|| (content.getContentDisposition().weakEqual(ContentDisposition::RecipientListHistory))
)
) {
istringstream data(content.getBodyAsString());
unique_ptr<Xsd::ResourceLists::ResourceLists> rl(Xsd::ResourceLists::parseResourceLists(
data,
Xsd::XmlSchema::Flags::dont_validate
));
list<IdentityAddress> addresses;
for (const auto &l : rl->getList()) {
for (const auto &entry : l.getEntry()) {
IdentityAddress addr(entry.getUri());
addresses.push_back(move(addr));
}
}
return addresses;
}
return list<IdentityAddress>();
}
LINPHONE_END_NAMESPACE
......@@ -34,6 +34,7 @@ class CallSession;
class CallSessionListener;
class CallSessionPrivate;
class ConferencePrivate;
class Content;
class ParticipantDevice;
class LINPHONE_PUBLIC Conference :
......@@ -62,11 +63,14 @@ public:
const std::string &getSubject () const override;
void join () override;
void leave () override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
void removeParticipants (const std::list<std::shared_ptr<Participant>> &participants) override;
void setParticipantAdminStatus (const std::shared_ptr<Participant> &participant, bool isAdmin) override;
void setSubject (const std::string &subject) override;
std::string getResourceLists (const std::list<IdentityAddress> &addresses) const;
static std::list<IdentityAddress> parseResourceLists (const Content &content);
protected:
explicit Conference (
ConferencePrivate &p,
......
......@@ -17,14 +17,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "content/content.h"
#include "content/content-disposition.h"
#include "content/content-type.h"
#include "handlers/local-conference-event-handler.h"
#include "local-conference-p.h"
#include "logger/logger.h"
#include "participant-p.h"
#include "xml/resource-lists.h"
// =============================================================================
......@@ -59,7 +55,7 @@ void LocalConference::addParticipant (const IdentityAddress &addr, const CallSes
d->activeParticipant = participant;
}
void LocalConference::removeParticipant (const shared_ptr<const Participant> &participant) {
void LocalConference::removeParticipant (const shared_ptr<Participant> &participant) {
L_D();
for (const auto &p : d->participants) {
if (participant->getAddress() == p->getAddress()) {
......@@ -69,25 +65,4 @@ void LocalConference::removeParticipant (const shared_ptr<const Participant> &pa
}
}
list<IdentityAddress> LocalConference::parseResourceLists (const Content &content) {
if ((content.getContentType() == ContentType::ResourceLists)
&& (content.getContentDisposition() == ContentDisposition::RecipientList)
) {
istringstream data(content.getBodyAsString());
unique_ptr<Xsd::ResourceLists::ResourceLists> rl(Xsd::ResourceLists::parseResourceLists(
data,
Xsd::XmlSchema::Flags::dont_validate
));
list<IdentityAddress> addresses;
for (const auto &l : rl->getList()) {
for (const auto &entry : l.getEntry()) {
IdentityAddress addr(entry.getUri());
addresses.push_back(move(addr));
}
}
return addresses;
}
return list<IdentityAddress>();
}
LINPHONE_END_NAMESPACE
......@@ -26,7 +26,6 @@
LINPHONE_BEGIN_NAMESPACE
class Content;
class LocalConferencePrivate;
class LocalConference : public Conference {
......@@ -38,9 +37,7 @@ public:
/* ConferenceInterface */
void addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
static std::list<IdentityAddress> parseResourceLists (const Content &content);
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
private:
L_DECLARE_PRIVATE(LocalConference);
......
......@@ -29,7 +29,7 @@ LINPHONE_BEGIN_NAMESPACE
ParticipantDevice::ParticipantDevice () {}
ParticipantDevice::ParticipantDevice (const Participant *participant, const IdentityAddress &gruu)
ParticipantDevice::ParticipantDevice (Participant *participant, const IdentityAddress &gruu)
: mParticipant(participant), mGruu(gruu) {}
ParticipantDevice::~ParticipantDevice () {
......
......@@ -44,13 +44,13 @@ public:
};
ParticipantDevice ();
explicit ParticipantDevice (const Participant *participant, const IdentityAddress &gruu);
explicit ParticipantDevice (Participant *participant, const IdentityAddress &gruu);
virtual ~ParticipantDevice ();
bool operator== (const ParticipantDevice &device) const;
inline const IdentityAddress &getAddress () const { return mGruu; }
const Participant *getParticipant () const { return mParticipant; }
Participant *getParticipant () const { return mParticipant; }
inline std::shared_ptr<CallSession> getSession () const { return mSession; }
inline void setSession (std::shared_ptr<CallSession> session) { mSession = session; }
inline State getState () const { return mState; }
......@@ -63,7 +63,7 @@ public:
bool isValid () const { return mGruu.isValid(); }
private:
const Participant *mParticipant = nullptr;
Participant *mParticipant = nullptr;
IdentityAddress mGruu;
std::shared_ptr<CallSession> mSession;
LinphoneEvent *mConferenceSubscribeEvent = nullptr;
......
......@@ -21,7 +21,6 @@
#include "logger/logger.h"
#include "participant-p.h"
#include "remote-conference-p.h"
#include "xml/resource-lists.h"
// =============================================================================
......@@ -59,7 +58,7 @@ void RemoteConference::addParticipant (const IdentityAddress &addr, const CallSe
d->activeParticipant = participant;
}
void RemoteConference::removeParticipant (const shared_ptr<const Participant> &participant) {
void RemoteConference::removeParticipant (const shared_ptr<Participant> &participant) {
L_D();
for (const auto &p : d->participants) {
if (participant->getAddress() == p->getAddress()) {
......@@ -69,21 +68,6 @@ void RemoteConference::removeParticipant (const shared_ptr<const Participant> &p
}
}
string RemoteConference::getResourceLists (const list<IdentityAddress> &addresses) const {
Xsd::ResourceLists::ResourceLists rl = Xsd::ResourceLists::ResourceLists();
Xsd::ResourceLists::ListType l = Xsd::ResourceLists::ListType();
for (const auto &addr : addresses) {
Xsd::ResourceLists::EntryType entry = Xsd::ResourceLists::EntryType(addr.asString());
l.getEntry().push_back(entry);
}
rl.getList().push_back(l);
Xsd::XmlSchema::NamespaceInfomap map;
stringstream xmlBody;
serializeResourceLists(xmlBody, rl, map);
return xmlBody.str();
}
// -----------------------------------------------------------------------------
void RemoteConference::onConferenceCreated (const IdentityAddress &) {}
......
......@@ -38,9 +38,7 @@ public:
/* ConferenceInterface */
void addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) override;
void removeParticipant (const std::shared_ptr<const Participant> &participant) override;
std::string getResourceLists (const std::list<IdentityAddress> &addresses) const;
void removeParticipant (const std::shared_ptr<Participant> &participant) override;
protected:
/* ConferenceListener */
......
......@@ -63,10 +63,13 @@ ContentDisposition &ContentDisposition::operator= (const ContentDisposition &oth
return *this;
}
bool ContentDisposition::