feat(conference): refactoring, use CoreAccessor and ChatRoomId

This commit is contained in:
Ronan Abhamon 2017-11-17 15:02:25 +01:00
parent 46a194d5b3
commit 6dd6e829a3
38 changed files with 227 additions and 179 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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

View file

@ -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;
}
// -----------------------------------------------------------------------------

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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)) {

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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) {

View file

@ -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
);

View file

@ -47,7 +47,6 @@ public:
inline unsigned int getLastNotify () const { return lastNotify; };
private:
LinphoneCore *core = nullptr;
LocalConference *conf = nullptr;
unsigned int lastNotify = 0;

View file

@ -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
}

View file

@ -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 ();
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);
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);
private:
L_DECLARE_PRIVATE(LocalConferenceEventHandler);
L_DISABLE_COPY(LocalConferenceEventHandler);
};
LINPHONE_END_NAMESPACE

View file

@ -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);

View file

@ -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,
addr,
gruu
@ -191,15 +200,15 @@ void RemoteConferenceEventHandler::notifyReceived (const string &xmlBody) {
}
if (isFullState)
d->listener->onFirstNotifyReceived(d->confAddress);
confListener->onFirstNotifyReceived(d->chatRoomId.getPeerAddress());
}
}
// -----------------------------------------------------------------------------
const Address &RemoteConferenceEventHandler::getConfAddress () const {
const ChatRoomId &RemoteConferenceEventHandler::getChatRoomId () const {
L_D();
return d->confAddress;
return d->chatRoomId;
}
unsigned int RemoteConferenceEventHandler::getLastNotify () const {

View file

@ -20,31 +20,33 @@
#ifndef _REMOTE_CONFERENCE_EVENT_HANDLER_H_
#define _REMOTE_CONFERENCE_EVENT_HANDLER_H_
#include <string>
#include "conference-listener.h"
#include "object/object.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class ChatRoomId;
class RemoteConference;
class RemoteConferenceEventHandlerPrivate;
class RemoteConferenceEventHandler : public Object {
public:
RemoteConferenceEventHandler (LinphoneCore *core, ConferenceListener *listener);
~RemoteConferenceEventHandler ();
public:
RemoteConferenceEventHandler (RemoteConference *remoteConference);
~RemoteConferenceEventHandler ();
void subscribe (const Address &confAddress);
void notifyReceived (const std::string &xmlBody);
void unsubscribe ();
void subscribe (const ChatRoomId &chatRoomId);
void notifyReceived (const std::string &xmlBody);
void unsubscribe ();
const Address &getConfAddress () const;
unsigned int getLastNotify () const;
void resetLastNotify ();
const ChatRoomId &getChatRoomId () const;
private:
L_DECLARE_PRIVATE(RemoteConferenceEventHandler);
L_DISABLE_COPY(RemoteConferenceEventHandler);
unsigned int getLastNotify () const;
void resetLastNotify ();
private:
L_DECLARE_PRIVATE(RemoteConferenceEventHandler);
L_DISABLE_COPY(RemoteConferenceEventHandler);
};
LINPHONE_END_NAMESPACE

View file

@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "local-conference-event-handler.h"
#include "handlers/local-conference-event-handler.h"
#include "local-conference-p.h"
#include "participant-p.h"
#include "xml/resource-lists.h"
@ -28,10 +28,10 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
LocalConference::LocalConference (LinphoneCore *core, const Address &myAddress, CallListener *listener)
: Conference(*new LocalConferencePrivate, core, myAddress, listener) {
LocalConference::LocalConference (const shared_ptr<Core> &core, const Address &myAddress, CallListener *listener)
: CoreAccessor(core), Conference(*new LocalConferencePrivate, core, myAddress, listener) {
L_D();
d->eventHandler.reset(new LocalConferenceEventHandler(core, this));
d->eventHandler.reset(new LocalConferenceEventHandler(this));
}
// -----------------------------------------------------------------------------

View file

@ -32,7 +32,7 @@ class LocalConference : public Conference {
friend class ServerGroupChatRoomPrivate;
public:
LocalConference (LinphoneCore *core, const Address &myAddress, CallListener *listener = nullptr);
LocalConference (const std::shared_ptr<Core> &core, const Address &myAddress, CallListener *listener = nullptr);
/* ConferenceInterface */
void addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) override;

View file

@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "handlers/remote-conference-event-handler.h"
#include "participant-p.h"
#include "remote-conference-event-handler.h"
#include "remote-conference-p.h"
#include "xml/resource-lists.h"
@ -28,10 +28,13 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
RemoteConference::RemoteConference (LinphoneCore *core, const Address &myAddress, CallListener *listener)
: Conference(*new RemoteConferencePrivate, core, myAddress, listener) {
RemoteConference::RemoteConference (
const shared_ptr<Core> &core,
const Address &myAddress,
CallListener *listener
) : CoreAccessor(core), Conference(*new RemoteConferencePrivate, core, myAddress, listener) {
L_D();
d->eventHandler.reset(new RemoteConferenceEventHandler(core, this));
d->eventHandler.reset(new RemoteConferenceEventHandler(this));
}
RemoteConference::~RemoteConference () {

View file

@ -22,6 +22,7 @@
#include "conference-listener.h"
#include "conference.h"
#include "core/core-accessor.h"
// =============================================================================
@ -33,7 +34,7 @@ class LINPHONE_PUBLIC RemoteConference : public Conference, public ConferenceLis
friend class ClientGroupChatRoomPrivate;
public:
RemoteConference (LinphoneCore *core, const Address &myAddress, CallListener *listener = nullptr);
RemoteConference (const std::shared_ptr<Core> &core, const Address &myAddress, CallListener *listener = nullptr);
virtual ~RemoteConference();
/* ConferenceInterface */

View file

@ -22,11 +22,11 @@
#include "c-wrapper/c-wrapper.h"
#include "address/address-p.h"
#include "conference/session/call-session-p.h"
#include "call/call-p.h"
#include "conference/params/call-session-params-p.h"
#include "conference/session/call-session-p.h"
#include "conference/session/call-session.h"
#include "core/core.h"
#include "logger/logger.h"
@ -45,7 +45,7 @@ CallSessionPrivate::CallSessionPrivate (const Conference &conference, const Call
if (params)
this->params = new CallSessionParams(*params);
currentParams = new CallSessionParams();
core = conference.getCore();
core = conference.getCore()->getCCore();
ei = linphone_error_info_new();
}

View file

@ -20,10 +20,7 @@
#include <algorithm>
#include <ctime>
// TODO: Remove me.
#ifdef SOCI_ENABLED
#undef SOCI_ENABLED
#endif
#undef SOCI_ENABLED
#ifdef SOCI_ENABLED
#include <soci/soci.h>
@ -635,7 +632,9 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
*session <<
"CREATE TABLE IF NOT EXISTS chat_room ("
// Server (for conference) or user sip address.
" peer_sip_address_id" + primaryKeyStr("BIGINT UNSIGNED") + ","
" peer_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + ","
" local_sip_address_id" + primaryKeyRefStr("BIGINT UNSIGNED") + ","
// Dialog creation date.
" creation_date DATE NOT NULL,"
@ -651,9 +650,13 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
" last_notify_id INT UNSIGNED,"
" PRIMARY KEY (peer_sip_address_id, local_sip_address_id),"
" FOREIGN KEY (peer_sip_address_id)"
" REFERENCES sip_address(id)"
" ON DELETE CASCADE"
" FOREIGN KEY (local_sip_address_id)"
" REFERENCES sip_address(id)"
" ON DELETE CASCADE"
") " + charset;
*session <<

View file

@ -18,6 +18,7 @@
*/
#include "chat/chat-message/chat-message.h"
#include "chat/chat-room/chat-room.h"
#include "conference-chat-message-event.h"
#include "conference-event-p.h"
@ -43,7 +44,7 @@ ConferenceChatMessageEvent::ConferenceChatMessageEvent (
*new ConferenceChatMessageEventPrivate,
EventLog::Type::ConferenceChatMessage,
creationTime,
chatMessage->getRemoteAddress()
chatMessage->getChatRoom()->getChatRoomId()
) {
L_D();
L_ASSERT(chatMessage);

View file

@ -20,7 +20,7 @@
#ifndef _CONFERENCE_EVENT_P_H_
#define _CONFERENCE_EVENT_P_H_
#include "address/identity-address.h"
#include "chat/chat-room/chat-room-id.h"
#include "conference-event.h"
#include "event-log/event-log-p.h"
@ -30,7 +30,7 @@ LINPHONE_BEGIN_NAMESPACE
class ConferenceEventPrivate : public EventLogPrivate {
private:
IdentityAddress conferenceAddress;
ChatRoomId chatRoomId;
L_DECLARE_PUBLIC(ConferenceEvent);
};

View file

@ -27,26 +27,26 @@ LINPHONE_BEGIN_NAMESPACE
// -----------------------------------------------------------------------------
ConferenceEvent::ConferenceEvent (Type type, time_t creationTime, const IdentityAddress &conferenceAddress) :
ConferenceEvent::ConferenceEvent (Type type, time_t creationTime, const ChatRoomId &chatRoomId) :
EventLog(*new ConferenceEventPrivate, type, creationTime) {
L_D();
L_ASSERT(type == Type::ConferenceCreated || type == Type::ConferenceDestroyed);
d->conferenceAddress = conferenceAddress;
d->chatRoomId = chatRoomId;
}
ConferenceEvent::ConferenceEvent (
ConferenceEventPrivate &p,
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress
const ChatRoomId &chatRoomId
) : EventLog(p, type, creationTime) {
L_D();
d->conferenceAddress = conferenceAddress;
d->chatRoomId = chatRoomId;
}
const IdentityAddress &ConferenceEvent::getConferenceAddress () const {
const ChatRoomId &ConferenceEvent::getChatRoomId () const {
L_D();
return d->conferenceAddress;
return d->chatRoomId;
}
LINPHONE_END_NAMESPACE

View file

@ -27,16 +27,16 @@
LINPHONE_BEGIN_NAMESPACE
class ConferenceEventPrivate;
class IdentityAddress;
class ChatRoomId;
class LINPHONE_PUBLIC ConferenceEvent : public EventLog {
public:
ConferenceEvent (Type type, time_t creationTime, const IdentityAddress &conferenceAddress);
ConferenceEvent (Type type, time_t creationTime, const ChatRoomId &chatRoomId);
const IdentityAddress &getConferenceAddress () const;
const ChatRoomId &getChatRoomId () const;
protected:
ConferenceEvent (ConferenceEventPrivate &p, Type type, time_t creationTime, const IdentityAddress &conferenceAddress);
ConferenceEvent (ConferenceEventPrivate &p, Type type, time_t creationTime, const ChatRoomId &chatRoomId);
private:
L_DECLARE_PRIVATE(ConferenceEvent);

View file

@ -30,9 +30,9 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceNotifiedEvent::ConferenceNotifiedEvent (
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId
) : ConferenceEvent(*new ConferenceNotifiedEventPrivate, type, creationTime, conferenceAddress) {
) : ConferenceEvent(*new ConferenceNotifiedEventPrivate, type, creationTime, chatRoomId) {
L_D();
d->notifyId = notifyId;
}
@ -41,9 +41,9 @@ ConferenceNotifiedEvent::ConferenceNotifiedEvent (
ConferenceNotifiedEventPrivate &p,
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId
) : ConferenceEvent(p, type, creationTime, conferenceAddress) {
) : ConferenceEvent(p, type, creationTime, chatRoomId) {
L_D();
d->notifyId = notifyId;
}

View file

@ -32,7 +32,7 @@ class LINPHONE_PUBLIC ConferenceNotifiedEvent : public ConferenceEvent {
public:
ConferenceNotifiedEvent (
Type type, time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifiyId
);
@ -43,7 +43,7 @@ protected:
ConferenceNotifiedEventPrivate &p,
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId
);

View file

@ -38,7 +38,7 @@ public:
ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress,
const IdentityAddress &deviceAddress
@ -46,7 +46,7 @@ ConferenceParticipantDeviceEvent::ConferenceParticipantDeviceEvent (
*new ConferenceParticipantDeviceEventPrivate,
type,
creationTime,
conferenceAddress,
chatRoomId,
notifyId,
participantAddress
) {

View file

@ -33,7 +33,7 @@ public:
ConferenceParticipantDeviceEvent (
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress,
const IdentityAddress &deviceAddress

View file

@ -30,14 +30,14 @@ LINPHONE_BEGIN_NAMESPACE
ConferenceParticipantEvent::ConferenceParticipantEvent (
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress
) : ConferenceNotifiedEvent(
*new ConferenceParticipantEventPrivate,
type,
creationTime,
conferenceAddress,
chatRoomId,
notifyId
) {
L_D();
@ -54,14 +54,14 @@ ConferenceParticipantEvent::ConferenceParticipantEvent (
ConferenceParticipantEventPrivate &p,
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress
) : ConferenceNotifiedEvent(
p,
type,
creationTime,
conferenceAddress,
chatRoomId,
notifyId
) {
L_D();

View file

@ -27,13 +27,14 @@
LINPHONE_BEGIN_NAMESPACE
class ConferenceParticipantEventPrivate;
class IdentityAddress;
class LINPHONE_PUBLIC ConferenceParticipantEvent : public ConferenceNotifiedEvent {
public:
ConferenceParticipantEvent (
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &ChatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress
);
@ -45,7 +46,7 @@ protected:
ConferenceParticipantEventPrivate &p,
Type type,
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &ChatRoomId,
unsigned int notifyId,
const IdentityAddress &participantAddress
);

View file

@ -37,14 +37,14 @@ public:
ConferenceSubjectEvent::ConferenceSubjectEvent (
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const string &subject
) : ConferenceNotifiedEvent(
*new ConferenceSubjectEventPrivate,
Type::ConferenceSubjectChanged,
creationTime,
conferenceAddress,
chatRoomId,
notifyId
) {
L_D();

View file

@ -34,7 +34,7 @@ class LINPHONE_PUBLIC ConferenceSubjectEvent : public ConferenceNotifiedEvent {
public:
ConferenceSubjectEvent (
time_t creationTime,
const IdentityAddress &conferenceAddress,
const ChatRoomId &chatRoomId,
unsigned int notifyId,
const std::string &subject
);