Commit 6dd6e829 authored by Ronan's avatar Ronan

feat(conference): refactoring, use CoreAccessor and ChatRoomId

parent 46a194d5
......@@ -50,7 +50,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "chat/chat-room/client-group-chat-room-p.h"
#include "chat/chat-room/server-group-chat-room-p.h"
#include "conference/remote-conference-event-handler.h"
#include "conference/handlers/remote-conference-event-handler.h"
#include "core/core.h"
// For migration purpose.
......
......@@ -66,11 +66,18 @@ LINPHONE_PUBLIC time_t linphone_event_log_get_creation_time (const LinphoneEvent
// -----------------------------------------------------------------------------
/**
* Returns the conference address of a conference event.
* Returns the peer address of a conference event.
* @param[in] event_log A #LinphoneEventLog object.
* @return The conference address.
* @return The peer address.
*/
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_conference_address (const LinphoneEventLog *event_log);
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_peer_address (const LinphoneEventLog *event_log);
/**
* Returns the local address of a conference event.
* @param[in] event_log A #LinphoneEventLog object.
* @return The local address.
*/
LINPHONE_PUBLIC const LinphoneAddress *linphone_event_log_get_local_address (const LinphoneEventLog *event_log);
// -----------------------------------------------------------------------------
// ConferenceNotifiedEvent.
......
......@@ -63,8 +63,10 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
conference/conference-listener.h
conference/conference-p.h
conference/conference.h
conference/local-conference-event-handler-p.h
conference/local-conference-event-handler.h
conference/handlers/local-conference-event-handler-p.h
conference/handlers/local-conference-event-handler.h
conference/handlers/remote-conference-event-handler-p.h
conference/handlers/remote-conference-event-handler.h
conference/local-conference-p.h
conference/local-conference.h
conference/params/call-session-params-p.h
......@@ -74,8 +76,6 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
conference/participant-device.h
conference/participant-p.h
conference/participant.h
conference/remote-conference-event-handler-p.h
conference/remote-conference-event-handler.h
conference/remote-conference-p.h
conference/remote-conference.h
conference/session/call-session-listener.h
......@@ -178,13 +178,13 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
chat/notification/imdn.cpp
chat/notification/is-composing.cpp
conference/conference.cpp
conference/local-conference-event-handler.cpp
conference/handlers/local-conference-event-handler.cpp
conference/handlers/remote-conference-event-handler.cpp
conference/local-conference.cpp
conference/params/call-session-params.cpp
conference/params/media-session-params.cpp
conference/participant-device.cpp
conference/participant.cpp
conference/remote-conference-event-handler.cpp
conference/remote-conference.cpp
conference/session/call-session.cpp
conference/session/media-session.cpp
......
......@@ -22,6 +22,7 @@
#include "c-wrapper/c-wrapper.h"
#include "call/call.h"
#include "chat/chat-message/chat-message.h"
#include "chat/chat-room/chat-room-id.h"
#include "event-log/events.h"
// =============================================================================
......@@ -35,7 +36,8 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(
EventLog,
_linphone_event_log_constructor,
_linphone_event_log_destructor,
mutable LinphoneAddress *conferenceAddressCache;
mutable LinphoneAddress *peerAddressCache;
mutable LinphoneAddress *localAddressCache;
mutable LinphoneAddress *participantAddressCache;
mutable LinphoneAddress *deviceAddressCache;
);
......@@ -43,8 +45,10 @@ L_DECLARE_C_OBJECT_IMPL_WITH_XTORS(
void _linphone_event_log_constructor (LinphoneEventLog *) {}
void _linphone_event_log_destructor (LinphoneEventLog *event_log) {
if (event_log->conferenceAddressCache)
linphone_address_unref(event_log->conferenceAddressCache);
if (event_log->peerAddressCache)
linphone_address_unref(event_log->peerAddressCache);
if (event_log->localAddressCache)
linphone_address_unref(event_log->localAddressCache);
if (event_log->participantAddressCache)
linphone_address_unref(event_log->participantAddressCache);
if (event_log->deviceAddressCache)
......@@ -190,18 +194,32 @@ time_t linphone_event_log_get_creation_time (const LinphoneEventLog *event_log)
// ConferenceEvent.
// -----------------------------------------------------------------------------
const LinphoneAddress *linphone_event_log_get_conference_address (const LinphoneEventLog *event_log) {
const LinphoneAddress *linphone_event_log_get_peer_address (const LinphoneEventLog *event_log) {
if (!isConferenceType(linphone_event_log_get_type(event_log)))
return nullptr;
if (!event_log->conferenceAddressCache)
event_log->conferenceAddressCache = linphone_address_new(
if (!event_log->peerAddressCache)
event_log->peerAddressCache = linphone_address_new(
static_pointer_cast<const LinphonePrivate::ConferenceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getConferenceAddress().asString().c_str()
)->getChatRoomId().getPeerAddress().asString().c_str()
);
return event_log->conferenceAddressCache;
return event_log->peerAddressCache;
}
const LinphoneAddress *linphone_event_log_get_local_address (const LinphoneEventLog *event_log) {
if (!isConferenceType(linphone_event_log_get_type(event_log)))
return nullptr;
if (!event_log->localAddressCache)
event_log->localAddressCache = linphone_address_new(
static_pointer_cast<const LinphonePrivate::ConferenceEvent>(
L_GET_CPP_PTR_FROM_C_OBJECT(event_log)
)->getChatRoomId().getLocalAddress().asString().c_str()
);
return event_log->localAddressCache;
}
// -----------------------------------------------------------------------------
......
......@@ -227,9 +227,9 @@ Call::Call (
const Address *myAddress = (direction == LinphoneCallIncoming) ? &to : &from;
string confType = lp_config_get_string(linphone_core_get_config(core), "misc", "conference_type", "local");
if (confType == "remote") {
d->conference = new RemoteConference(core, *myAddress, d);
d->conference = new RemoteConference(core->cppCore, *myAddress, d);
} else {
d->conference = new LocalConference(core, *myAddress, d);
d->conference = new LocalConference(core->cppCore, *myAddress, d);
}
const Address *remoteAddress = (direction == LinphoneCallIncoming) ? &from : &to;
d->conference->addParticipant(*remoteAddress, msp, true);
......
......@@ -30,13 +30,13 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
BasicChatRoom::BasicChatRoom (const shared_ptr<Core> &core, const ChatRoomId &chatRoomId) :
ChatRoom(*new BasicChatRoomPrivate, core, chatRoomId) {}
BasicChatRoom(*new BasicChatRoomPrivate, core, chatRoomId) {}
BasicChatRoom::BasicChatRoom (
BasicChatRoomPrivate &p,
const std::shared_ptr<Core> &core,
const ChatRoomId &chatRoomId
) : ChatRoom(p, core, chatRoomId) {}
) : CoreAccessor(core), ChatRoom(p, core, chatRoomId) {}
BasicChatRoom::CapabilitiesMask BasicChatRoom::getCapabilities () const {
return static_cast<CapabilitiesMask>(Capabilities::Basic);
......
......@@ -449,7 +449,7 @@ void ChatRoomPrivate::onIsComposingRefreshNeeded () {
// =============================================================================
ChatRoom::ChatRoom (ChatRoomPrivate &p, const shared_ptr<Core> &core, const ChatRoomId &chatRoomId) :
Object(p), CoreAccessor(core) {
CoreAccessor(core), Object(p) {
L_D();
d->chatRoomId = chatRoomId;
......
......@@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE
class ChatRoomPrivate;
class LINPHONE_PUBLIC ChatRoom : public Object, public CoreAccessor, public ConferenceInterface {
class LINPHONE_PUBLIC ChatRoom : public Object, virtual public CoreAccessor, public ConferenceInterface {
friend class Core;
friend class CorePrivate;
friend class ChatMessage;
......
......@@ -22,8 +22,8 @@
#include "address/address-p.h"
#include "c-wrapper/c-wrapper.h"
#include "client-group-chat-room-p.h"
#include "conference/handlers/remote-conference-event-handler.h"
#include "conference/participant-p.h"
#include "conference/remote-conference-event-handler.h"
#include "conference/remote-conference-p.h"
#include "conference/session/call-session-p.h"
#include "core/core-p.h"
......@@ -81,9 +81,9 @@ ClientGroupChatRoom::ClientGroupChatRoom (
const std::string &factoryUri,
const IdentityAddress &me,
const std::string &subject
) :
) : CoreAccessor(core),
ChatRoom(*new ClientGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(), me)),
RemoteConference(core->getCCore(), me, nullptr) {
RemoteConference(core, me, nullptr) {
L_D_T(RemoteConference, dConference);
dConference->focus = make_shared<Participant>(Address(factoryUri));
RemoteConference::setSubject(subject);
......@@ -141,7 +141,7 @@ void ClientGroupChatRoom::addParticipants (
}
void ClientGroupChatRoom::removeParticipant (const shared_ptr<const Participant> &participant) {
LinphoneCore *cCore = CoreAccessor::getCore()->getCCore();
LinphoneCore *cCore = getCore()->getCCore();
SalReferOp *referOp = new SalReferOp(cCore->sal);
LinphoneAddress *lAddr = linphone_address_new(getConferenceAddress().asString().c_str());
......@@ -183,7 +183,7 @@ void ClientGroupChatRoom::setParticipantAdminStatus (shared_ptr<Participant> &pa
return;
}
LinphoneCore *cCore = CoreAccessor::getCore()->getCCore();
LinphoneCore *cCore = getCore()->getCCore();
SalReferOp *referOp = new SalReferOp(cCore->sal);
LinphoneAddress *lAddr = linphone_address_new(getConferenceAddress().asString().c_str());
......@@ -261,7 +261,7 @@ void ClientGroupChatRoom::onConferenceCreated (const Address &addr) {
L_D_T(RemoteConference, dConference);
dConference->conferenceAddress = addr;
d->chatRoomId = ChatRoomId(addr, d->chatRoomId.getLocalAddress());
CoreAccessor::getCore()->getPrivate()->insertChatRoom(getSharedFromThis());
getCore()->getPrivate()->insertChatRoom(getSharedFromThis());
}
void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) {
......@@ -274,7 +274,7 @@ void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) {
void ClientGroupChatRoom::onFirstNotifyReceived (const Address &addr) {
L_D();
d->setState(ChatRoom::State::Created);
CoreAccessor::getCore()->getPrivate()->insertChatRoomWithDb(getSharedFromThis());
getCore()->getPrivate()->insertChatRoomWithDb(getSharedFromThis());
}
void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferenceParticipantEvent> &event, bool isFullState) {
......@@ -299,7 +299,7 @@ void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferencePartici
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantAddedCb cb = linphone_chat_room_cbs_get_participant_added(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -322,7 +322,7 @@ void ClientGroupChatRoom::onParticipantRemoved (const shared_ptr<ConferenceParti
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantRemovedCb cb = linphone_chat_room_cbs_get_participant_removed(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -351,7 +351,7 @@ void ClientGroupChatRoom::onParticipantSetAdmin (const shared_ptr<ConferencePart
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantAdminStatusChangedCb cb = linphone_chat_room_cbs_get_participant_admin_status_changed(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -368,7 +368,7 @@ void ClientGroupChatRoom::onSubjectChanged (const shared_ptr<ConferenceSubjectEv
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsSubjectChangedCb cb = linphone_chat_room_cbs_get_subject_changed(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -393,7 +393,7 @@ void ClientGroupChatRoom::onParticipantDeviceAdded (const shared_ptr<ConferenceP
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantDeviceAddedCb cb = linphone_chat_room_cbs_get_participant_device_added(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -416,7 +416,7 @@ void ClientGroupChatRoom::onParticipantDeviceRemoved (const shared_ptr<Conferenc
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(this);
LinphoneChatRoomCbs *cbs = linphone_chat_room_get_callbacks(cr);
LinphoneChatRoomCbsParticipantDeviceRemovedCb cb = linphone_chat_room_cbs_get_participant_device_removed(cbs);
Conference::getCore()->cppCore->getPrivate()->mainDb->addEvent(event);
getCore()->getPrivate()->mainDb->addEvent(event);
if (cb)
cb(cr, L_GET_C_BACK_PTR(event));
......@@ -445,7 +445,7 @@ void ClientGroupChatRoom::onCallSessionStateChanged (
Address addr(session->getRemoteContactAddress()->asStringUriOnly());
onConferenceCreated(addr);
if (session->getRemoteContactAddress()->hasParam("isfocus"))
dConference->eventHandler->subscribe(getConferenceAddress());
dConference->eventHandler->subscribe(getChatRoomId());
} else if (d->state == ChatRoom::State::TerminationPending)
dConference->focus->getPrivate()->getSession()->terminate();
} else if ((state == LinphoneCallReleased) && (d->state == ChatRoom::State::TerminationPending)) {
......
......@@ -104,7 +104,7 @@ void RealTimeTextChatRoomPrivate::sendMessage (const shared_ptr<ChatMessage> &ms
// =============================================================================
RealTimeTextChatRoom::RealTimeTextChatRoom (const shared_ptr<Core> &core, const ChatRoomId &chatRoomId) :
BasicChatRoom(*new RealTimeTextChatRoomPrivate, core, chatRoomId) {}
CoreAccessor(core), BasicChatRoom(*new RealTimeTextChatRoomPrivate, core, chatRoomId) {}
RealTimeTextChatRoom::CapabilitiesMask RealTimeTextChatRoom::getCapabilities () const {
return BasicChatRoom::getCapabilities() | static_cast<CapabilitiesMask>(Capabilities::RealTimeText);
......
......@@ -77,9 +77,9 @@ bool ServerGroupChatRoomPrivate::isAdminLeft () const {
// =============================================================================
ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr<Core> &core, SalCallOp *op) :
ChatRoom(*new ServerGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))),
LocalConference(core->getCCore(), Address(op->get_to()), nullptr) {}
ServerGroupChatRoom::ServerGroupChatRoom (const shared_ptr<Core> &core, SalCallOp *op) : CoreAccessor(core),
ChatRoom(*new ServerGroupChatRoomPrivate, core, ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))),
LocalConference(core, Address(op->get_to()), nullptr) {}
int ServerGroupChatRoom::getCapabilities () const {
return 0;
......
......@@ -20,11 +20,6 @@
#ifndef _CONFERENCE_P_H_
#define _CONFERENCE_P_H_
#include <list>
#include <memory>
#include "linphone/types.h"
#include "address/address.h"
#include "conference.h"
......@@ -41,7 +36,6 @@ public:
std::list<std::shared_ptr<Participant>> participants;
protected:
LinphoneCore *core = nullptr;
CallListener *callListener = nullptr;
std::shared_ptr<Participant> activeParticipant;
......
......@@ -29,10 +29,14 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
Conference::Conference (ConferencePrivate &p, LinphoneCore *core, const Address &myAddress, CallListener *listener) : mPrivate(&p) {
Conference::Conference (
ConferencePrivate &p,
const shared_ptr<Core> &core,
const Address &myAddress,
CallListener *listener
) : CoreAccessor(core), mPrivate(&p) {
L_D();
d->mPublic = this;
d->core = core;
d->callListener = listener;
d->me = make_shared<Participant>(myAddress);
}
......@@ -48,11 +52,6 @@ shared_ptr<Participant> Conference::getActiveParticipant () const {
return d->activeParticipant;
}
LinphoneCore *Conference::getCore () const {
L_D();
return d->core;
}
// -----------------------------------------------------------------------------
void Conference::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) {
......
......@@ -24,6 +24,7 @@
#include "conference/conference-interface.h"
#include "conference/session/call-session-listener.h"
#include "core/core-accessor.h"
// =============================================================================
......@@ -33,7 +34,10 @@ class CallListener;
class CallSessionPrivate;
class ConferencePrivate;
class LINPHONE_PUBLIC Conference : public ConferenceInterface, public CallSessionListener {
class LINPHONE_PUBLIC Conference :
public ConferenceInterface,
public CallSessionListener,
virtual public CoreAccessor {
friend class CallSessionPrivate;
public:
......@@ -41,8 +45,6 @@ public:
std::shared_ptr<Participant> getActiveParticipant () const;
LinphoneCore * getCore () const;
std::shared_ptr<Participant> findParticipant (const std::shared_ptr<const CallSession> &session) const;
/* ConferenceInterface */
......@@ -82,7 +84,7 @@ private:
protected:
explicit Conference (
ConferencePrivate &p,
LinphoneCore *core,
const std::shared_ptr<Core> &core,
const Address &myAddress,
CallListener *listener = nullptr
);
......
......@@ -47,7 +47,6 @@ public:
inline unsigned int getLastNotify () const { return lastNotify; };
private:
LinphoneCore *core = nullptr;
LocalConference *conf = nullptr;
unsigned int lastNotify = 0;
......
......@@ -19,12 +19,15 @@
#include <ctime>
#include "linphone/utils/utils.h"
#include "conference/local-conference.h"
#include "conference/participant-p.h"
#include "linphone/utils/utils.h"
#include "local-conference-event-handler-p.h"
#include "logger/logger.h"
#include "object/object-p.h"
// TODO: remove me.
#include "private.h"
// =============================================================================
......@@ -247,12 +250,11 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantDeviceRemoved
// =============================================================================
LocalConferenceEventHandler::LocalConferenceEventHandler (LinphoneCore *core, LocalConference *localConf) :
LocalConferenceEventHandler::LocalConferenceEventHandler (LocalConference *localConference) :
Object(*new LocalConferenceEventHandlerPrivate) {
L_D();
xercesc::XMLPlatformUtils::Initialize();
d->conf = localConf;
d->core = core;
d->conf = localConference;
// TODO : init d->lastNotify = last notify
}
......
......@@ -20,31 +20,35 @@
#ifndef _LOCAL_CONFERENCE_EVENT_HANDLER_H_
#define _LOCAL_CONFERENCE_EVENT_HANDLER_H_
#include "address/address.h"
#include "linphone/types.h"
#include "address/address.h"
#include "core/core-accessor.h"
#include "object/object.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class LocalConference;
class LocalConferenceEventHandlerPrivate;
class LocalConferenceEventHandler : public Object {
public:
LocalConferenceEventHandler (LinphoneCore *core, LocalConference *localConf);
~LocalConferenceEventHandler ();
void subscribeReceived (LinphoneEvent *lev);
void notifyParticipantAdded (const Address &addr);
void notifyParticipantRemoved (const Address &addr);
void notifyParticipantSetAdmin (const Address &addr, bool isAdmin);
void notifySubjectChanged ();
void notifyParticipantDeviceAdded (const Address &addr, const Address &gruu);
void notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu);
private:
L_DECLARE_PRIVATE(LocalConferenceEventHandler);
L_DISABLE_COPY(LocalConferenceEventHandler);
public:
LocalConferenceEventHandler (LocalConference *localConference);
~LocalConferenceEventHandler ();
void subscribeReceived (LinphoneEvent *lev);
void notifyParticipantAdded (const Address &addr);
void notifyParticipantRemoved (const Address &addr);
void notifyParticipantSetAdmin (const Address &addr, bool isAdmin);
void notifySubjectChanged ();
void notifyParticipantDeviceAdded (const Address &addr, const Address &gruu);
void notifyParticipantDeviceRemoved (const Address &addr, const Address &gruu);
private:
L_DECLARE_PRIVATE(LocalConferenceEventHandler);
L_DISABLE_COPY(LocalConferenceEventHandler);
};
LINPHONE_END_NAMESPACE
......
......@@ -20,7 +20,9 @@
#ifndef _REMOTE_CONFERENCE_EVENT_HANDLER_P_H_
#define _REMOTE_CONFERENCE_EVENT_HANDLER_P_H_
#include "address/address.h"
#include "linphone/types.h"
#include "chat/chat-room/chat-room-id.h"
#include "object/object-p.h"
#include "remote-conference-event-handler.h"
......@@ -30,10 +32,11 @@ LINPHONE_BEGIN_NAMESPACE
class RemoteConferenceEventHandlerPrivate : public ObjectPrivate {
private:
LinphoneCore *core = nullptr;
ConferenceListener *listener = nullptr;
Address confAddress;
ChatRoomId chatRoomId;
RemoteConference *conf = nullptr;
LinphoneEvent *lev = nullptr;
unsigned int lastNotify = 0;
L_DECLARE_PUBLIC(RemoteConferenceEventHandler);
......
......@@ -17,13 +17,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "address/identity-address.h"
#include "private.h"
#include "linphone/utils/utils.h"
#include "conference/remote-conference.h"
#include "core/core.h"
#include "logger/logger.h"
#include "remote-conference-event-handler-p.h"
#include "linphone/utils/utils.h"
#include "xml/conference-info.h"
// TODO: Remove me later.
#include "private.h"
// =============================================================================
using namespace std;
......@@ -34,12 +38,11 @@ using namespace Xsd::ConferenceInfo;
// -----------------------------------------------------------------------------
RemoteConferenceEventHandler::RemoteConferenceEventHandler (LinphoneCore *core, ConferenceListener *listener)
: Object(*new RemoteConferenceEventHandlerPrivate) {
RemoteConferenceEventHandler::RemoteConferenceEventHandler (RemoteConference *remoteConference) :
Object(*new RemoteConferenceEventHandlerPrivate) {
L_D();
xercesc::XMLPlatformUtils::Initialize();
d->core = core;
d->listener = listener;
d->conf = remoteConference;
// TODO : d->lastNotify = lastNotify
}
......@@ -49,11 +52,11 @@ RemoteConferenceEventHandler::~RemoteConferenceEventHandler () {
// -----------------------------------------------------------------------------
void RemoteConferenceEventHandler::subscribe (const Address &addr) {
void RemoteConferenceEventHandler::subscribe (const ChatRoomId &chatRoomId) {
L_D();
d->confAddress = addr;
LinphoneAddress *lAddr = linphone_address_new(d->confAddress.asString().c_str());
d->lev = linphone_core_create_subscribe(d->core, lAddr, "conference", 600);
d->chatRoomId = chatRoomId;
LinphoneAddress *lAddr = linphone_address_new(d->chatRoomId.getPeerAddress().asString().c_str());
d->lev = linphone_core_create_subscribe(d->conf->getCore()->getCCore(), lAddr, "conference", 600);
linphone_event_add_custom_header(d->lev, "Last-Notify-Version", Utils::toString(d->lastNotify).c_str());
linphone_address_unref(lAddr);
linphone_event_set_internal(d->lev, TRUE);
......@@ -71,7 +74,10 @@ void RemoteConferenceEventHandler::unsubscribe () {
void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
L_D();
lInfo() << "NOTIFY received for conference " << d->confAddress.asString();
lInfo() << "NOTIFY received for conference: (remote=" << d->chatRoomId.getPeerAddress().asString() <<
", local=" << d->chatRoomId.getLocalAddress().asString() << ").";
istringstream data(xmlBody);
unique_ptr<ConferenceType> confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate);
time_t tm = time(nullptr);
......@@ -79,20 +85,23 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
tm = static_cast<time_t>(Utils::stoll(confInfo->getConferenceDescription()->getFreeText().get()));
bool isFullState = (confInfo->getState() == StateType::full);
IdentityAddress simpleConfAddress(d->confAddress);
// Temporary workaround
ConferenceListener *confListener = static_cast<ConferenceListener *>(d->conf);
// TODO: Temporary workaround, remove me.
const IdentityAddress &peerAddress = d->chatRoomId.getPeerAddress();
IdentityAddress entityAddress(confInfo->getEntity().c_str());
IdentityAddress simpleConfAddress2(simpleConfAddress);
simpleConfAddress2.setDomain(entityAddress.getDomain());
if ((entityAddress == simpleConfAddress) || (entityAddress == simpleConfAddress2)) {
IdentityAddress peerAddressWorkaround = peerAddress;
peerAddressWorkaround.setDomain(entityAddress.getDomain());
if ((entityAddress == peerAddress) || (entityAddress == peerAddressWorkaround)) {
if (
confInfo->getConferenceDescription().present() &&
confInfo->getConferenceDescription().get().getSubject().present()
)
d->listener->onSubjectChanged(
confListener->onSubjectChanged(
make_shared<ConferenceSubjectEvent>(
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,
confInfo->getConferenceDescription().get().getSubject().get()
),
......@@ -105,16 +114,16 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
return;
for (const auto &user : confInfo->getUsers()->getUser()) {
LinphoneAddress *cAddr = linphone_core_interpret_url(d->core, user.getEntity()->c_str());
LinphoneAddress *cAddr = linphone_core_interpret_url(d->conf->getCore()->getCCore(), user.getEntity()->c_str());
char *cAddrStr = linphone_address_as_string(cAddr);
Address addr(cAddrStr);
bctbx_free(cAddrStr);
if (user.getState() == StateType::deleted) {
d->listener->onParticipantRemoved(
confListener->onParticipantRemoved(
make_shared<ConferenceParticipantEvent>(
EventLog::Type::ConferenceParticipantRemoved,
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,
addr
),
......@@ -132,11 +141,11 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
}
if (user.getState() == StateType::full) {
d->listener->onParticipantAdded(
confListener->onParticipantAdded(
make_shared<ConferenceParticipantEvent>(
EventLog::Type::ConferenceParticipantAdded,
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,
addr
),
......@@ -144,11 +153,11 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
);
}
d->listener->onParticipantSetAdmin(
confListener->onParticipantSetAdmin(
make_shared<ConferenceParticipantEvent>(
isAdmin ? EventLog::Type::ConferenceParticipantSetAdmin : EventLog::Type::ConferenceParticipantUnsetAdmin,
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,
addr
),
......@@ -161,11 +170,11 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
Address gruu(endpoint.getEntity().get());
if (endpoint.getState() == StateType::deleted) {
d->listener->onParticipantDeviceRemoved(
confListener->onParticipantDeviceRemoved(
make_shared<ConferenceParticipantDeviceEvent>(
EventLog::Type::ConferenceParticipantDeviceRemoved,
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,
addr,
gruu
......@@ -173,11 +182,11 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
isFullState
);
} else if (endpoint.getState() == StateType::full) {
d->listener->onParticipantDeviceAdded(
confListener->onParticipantDeviceAdded(
make_shared<ConferenceParticipantDeviceEvent>(
EventLog::Type::ConferenceParticipantDeviceAdded,
tm,
d->confAddress,
d->chatRoomId,
d->lastNotify,