Commit 47b12a26 authored by Ghislain MARY's avatar Ghislain MARY

Allow access to Core from Participant and ParticipantDevice.

parent b085154c
...@@ -40,8 +40,8 @@ BasicChatRoom::BasicChatRoom ( ...@@ -40,8 +40,8 @@ BasicChatRoom::BasicChatRoom (
const ChatRoomId &chatRoomId const ChatRoomId &chatRoomId
) : ChatRoom(p, core, chatRoomId) { ) : ChatRoom(p, core, chatRoomId) {
L_D(); L_D();
d->me = make_shared<Participant>(getLocalAddress()); d->me = make_shared<Participant>(nullptr, getLocalAddress());
d->participants.push_back(make_shared<Participant>(getPeerAddress())); d->participants.push_back(make_shared<Participant>(nullptr, getPeerAddress()));
} }
void BasicChatRoom::allowCpim (bool value) { void BasicChatRoom::allowCpim (bool value) {
......
...@@ -130,7 +130,7 @@ void ClientGroupChatRoomPrivate::confirmJoining (SalCallOp *op) { ...@@ -130,7 +130,7 @@ void ClientGroupChatRoomPrivate::confirmJoining (SalCallOp *op) {
for (const auto &addr : identAddresses) { for (const auto &addr : identAddresses) {
auto participant = q->findParticipant(addr); auto participant = q->findParticipant(addr);
if (!participant) { if (!participant) {
participant = make_shared<Participant>(addr); participant = make_shared<Participant>(q, addr);
qConference->getPrivate()->participants.push_back(participant); qConference->getPrivate()->participants.push_back(participant);
} }
} }
...@@ -249,12 +249,12 @@ RemoteConference(core, me, nullptr) { ...@@ -249,12 +249,12 @@ RemoteConference(core, me, nullptr) {
L_D_T(RemoteConference, dConference); L_D_T(RemoteConference, dConference);
IdentityAddress focusAddr(uri); IdentityAddress focusAddr(uri);
dConference->focus = make_shared<Participant>(focusAddr); dConference->focus = make_shared<Participant>(this, focusAddr);
dConference->focus->getPrivate()->addDevice(focusAddr); dConference->focus->getPrivate()->addDevice(focusAddr);
RemoteConference::setSubject(subject); RemoteConference::setSubject(subject);
list<IdentityAddress> identAddresses = Conference::parseResourceLists(content); list<IdentityAddress> identAddresses = Conference::parseResourceLists(content);
for (const auto &addr : identAddresses) for (const auto &addr : identAddresses)
dConference->participants.push_back(make_shared<Participant>(addr)); dConference->participants.push_back(make_shared<Participant>(this, addr));
} }
ClientGroupChatRoom::ClientGroupChatRoom ( ClientGroupChatRoom::ClientGroupChatRoom (
...@@ -273,7 +273,7 @@ RemoteConference(core, me->getAddress(), nullptr) { ...@@ -273,7 +273,7 @@ RemoteConference(core, me->getAddress(), nullptr) {
d->capabilities |= capabilities & ClientGroupChatRoom::Capabilities::OneToOne; d->capabilities |= capabilities & ClientGroupChatRoom::Capabilities::OneToOne;
const IdentityAddress &peerAddress = chatRoomId.getPeerAddress(); const IdentityAddress &peerAddress = chatRoomId.getPeerAddress();
dConference->focus = make_shared<Participant>(peerAddress); dConference->focus = make_shared<Participant>(this, peerAddress);
dConference->focus->getPrivate()->addDevice(peerAddress); dConference->focus->getPrivate()->addDevice(peerAddress);
dConference->conferenceAddress = peerAddress; dConference->conferenceAddress = peerAddress;
dConference->subject = subject; dConference->subject = subject;
...@@ -628,7 +628,7 @@ void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferencePartici ...@@ -628,7 +628,7 @@ void ClientGroupChatRoom::onParticipantAdded (const shared_ptr<ConferencePartici
return; return;
} }
participant = make_shared<Participant>(addr); participant = make_shared<Participant>(this, addr);
dConference->participants.push_back(participant); dConference->participants.push_back(participant);
if (isFullState) if (isFullState)
......
...@@ -41,7 +41,7 @@ Conference::Conference ( ...@@ -41,7 +41,7 @@ Conference::Conference (
) : CoreAccessor(core), mPrivate(&p) { ) : CoreAccessor(core), mPrivate(&p) {
L_D(); L_D();
d->mPublic = this; d->mPublic = this;
d->me = make_shared<Participant>(myAddress); d->me = make_shared<Participant>(this, myAddress);
d->listener = listener; d->listener = listener;
} }
......
...@@ -48,7 +48,7 @@ void LocalConference::addParticipant (const IdentityAddress &addr, const CallSes ...@@ -48,7 +48,7 @@ void LocalConference::addParticipant (const IdentityAddress &addr, const CallSes
lInfo() << "Not adding participant '" << addr.asString() << "' because it is already a participant of the LocalConference"; lInfo() << "Not adding participant '" << addr.asString() << "' because it is already a participant of the LocalConference";
return; return;
} }
participant = make_shared<Participant>(addr); participant = make_shared<Participant>(this, addr);
participant->getPrivate()->createSession(*this, params, hasMedia, d->listener); participant->getPrivate()->createSession(*this, params, hasMedia, d->listener);
d->participants.push_back(participant); d->participants.push_back(participant);
if (!d->activeParticipant) if (!d->activeParticipant)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include "participant-device.h" #include "participant-device.h"
#include "participant-p.h"
#include "linphone/event.h" #include "linphone/event.h"
...@@ -41,6 +42,10 @@ bool ParticipantDevice::operator== (const ParticipantDevice &device) const { ...@@ -41,6 +42,10 @@ bool ParticipantDevice::operator== (const ParticipantDevice &device) const {
return (mGruu == device.getAddress()); return (mGruu == device.getAddress());
} }
shared_ptr<Core> ParticipantDevice::getCore () const {
return mParticipant ? mParticipant->getPrivate()->getCore() : nullptr;
}
void ParticipantDevice::setConferenceSubscribeEvent (LinphoneEvent *ev) { void ParticipantDevice::setConferenceSubscribeEvent (LinphoneEvent *ev) {
if (mConferenceSubscribeEvent) if (mConferenceSubscribeEvent)
linphone_event_unref(mConferenceSubscribeEvent); linphone_event_unref(mConferenceSubscribeEvent);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
class CallSession; class CallSession;
class Core;
class Participant; class Participant;
class ParticipantDevice { class ParticipantDevice {
...@@ -49,6 +50,8 @@ public: ...@@ -49,6 +50,8 @@ public:
bool operator== (const ParticipantDevice &device) const; bool operator== (const ParticipantDevice &device) const;
std::shared_ptr<Core> getCore () const;
inline const IdentityAddress &getAddress () const { return mGruu; } inline const IdentityAddress &getAddress () const { return mGruu; }
Participant *getParticipant () const { return mParticipant; } Participant *getParticipant () const { return mParticipant; }
inline std::shared_ptr<CallSession> getSession () const { return mSession; } inline std::shared_ptr<CallSession> getSession () const { return mSession; }
......
...@@ -33,6 +33,10 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -33,6 +33,10 @@ LINPHONE_BEGIN_NAMESPACE
class ParticipantPrivate : public ObjectPrivate { class ParticipantPrivate : public ObjectPrivate {
public: public:
std::shared_ptr<Core> getCore () const { return mConference ? mConference->getCore() : nullptr; }
Conference *getConference () const { return mConference; }
void setConference (Conference *conference) { mConference = conference; }
std::shared_ptr<CallSession> createSession (const Conference &conference, const CallSessionParams *params, bool hasMedia, CallSessionListener *listener); std::shared_ptr<CallSession> createSession (const Conference &conference, const CallSessionParams *params, bool hasMedia, CallSessionListener *listener);
inline std::shared_ptr<CallSession> getSession () const { return session; } inline std::shared_ptr<CallSession> getSession () const { return session; }
inline void removeSession () { session.reset(); } inline void removeSession () { session.reset(); }
...@@ -47,6 +51,7 @@ public: ...@@ -47,6 +51,7 @@ public:
void removeDevice (const IdentityAddress &gruu); void removeDevice (const IdentityAddress &gruu);
private: private:
Conference *mConference = nullptr;
IdentityAddress addr; IdentityAddress addr;
bool isAdmin = false; bool isAdmin = false;
std::shared_ptr<CallSession> session; std::shared_ptr<CallSession> session;
......
...@@ -92,8 +92,9 @@ void ParticipantPrivate::removeDevice (const IdentityAddress &gruu) { ...@@ -92,8 +92,9 @@ void ParticipantPrivate::removeDevice (const IdentityAddress &gruu) {
// ============================================================================= // =============================================================================
Participant::Participant (const IdentityAddress &address) : Object(*new ParticipantPrivate) { Participant::Participant (Conference *conference, const IdentityAddress &address) : Object(*new ParticipantPrivate) {
L_D(); L_D();
d->mConference = conference;
d->addr = address.getAddressWithoutGruu(); d->addr = address.getAddressWithoutGruu();
} }
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
class ClientGroupChatRoom; class ClientGroupChatRoom;
class Conference;
class ParticipantPrivate; class ParticipantPrivate;
class Participant : public Object { class Participant : public Object {
...@@ -49,6 +50,7 @@ class Participant : public Object { ...@@ -49,6 +50,7 @@ class Participant : public Object {
friend class MainDb; friend class MainDb;
friend class MainDbPrivate; friend class MainDbPrivate;
friend class MediaSessionPrivate; friend class MediaSessionPrivate;
friend class ParticipantDevice;
friend class RemoteConference; friend class RemoteConference;
friend class RemoteConferenceCall; friend class RemoteConferenceCall;
friend class RemoteConferenceCallPrivate; friend class RemoteConferenceCallPrivate;
...@@ -58,7 +60,7 @@ class Participant : public Object { ...@@ -58,7 +60,7 @@ class Participant : public Object {
public: public:
L_OVERRIDE_SHARED_FROM_THIS(Participant); L_OVERRIDE_SHARED_FROM_THIS(Participant);
explicit Participant (const IdentityAddress &address); explicit Participant (Conference *conference, const IdentityAddress &address);
const IdentityAddress &getAddress () const; const IdentityAddress &getAddress () const;
bool isAdmin () const; bool isAdmin () const;
......
...@@ -51,7 +51,7 @@ void RemoteConference::addParticipant (const IdentityAddress &addr, const CallSe ...@@ -51,7 +51,7 @@ void RemoteConference::addParticipant (const IdentityAddress &addr, const CallSe
lInfo() << "Not adding participant '" << addr.asString() << "' because it is already a participant of the RemoteConference"; lInfo() << "Not adding participant '" << addr.asString() << "' because it is already a participant of the RemoteConference";
return; return;
} }
participant = make_shared<Participant>(addr); participant = make_shared<Participant>(this, addr);
participant->getPrivate()->createSession(*this, params, hasMedia, d->listener); participant->getPrivate()->createSession(*this, params, hasMedia, d->listener);
d->participants.push_back(participant); d->participants.push_back(participant);
if (!d->activeParticipant) if (!d->activeParticipant)
......
...@@ -2402,7 +2402,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2402,7 +2402,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
soci::rowset<soci::row> rows = (session->prepare << query, soci::use(dbChatRoomId)); soci::rowset<soci::row> rows = (session->prepare << query, soci::use(dbChatRoomId));
shared_ptr<Participant> me; shared_ptr<Participant> me;
for (const auto &row : rows) { for (const auto &row : rows) {
shared_ptr<Participant> participant = make_shared<Participant>(IdentityAddress(row.get<string>(1))); shared_ptr<Participant> participant = make_shared<Participant>(nullptr, IdentityAddress(row.get<string>(1)));
ParticipantPrivate *dParticipant = participant->getPrivate(); ParticipantPrivate *dParticipant = participant->getPrivate();
dParticipant->setAdmin(!!row.get<int>(2)); dParticipant->setAdmin(!!row.get<int>(2));
...@@ -2426,6 +2426,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2426,6 +2426,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
participants.push_back(participant); participants.push_back(participant);
} }
Conference *conference = nullptr;
if (!linphone_core_conference_server_enabled(core->getCCore())) { if (!linphone_core_conference_server_enabled(core->getCCore())) {
bool hasBeenLeft = !!row.get<int>(8, 0); bool hasBeenLeft = !!row.get<int>(8, 0);
if (!me) { if (!me) {
...@@ -2433,7 +2434,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2433,7 +2434,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
", local=" + chatRoomId.getLocalAddress().asString() + ")."; ", local=" + chatRoomId.getLocalAddress().asString() + ").";
continue; continue;
} }
chatRoom = make_shared<ClientGroupChatRoom>( auto clientGroupChatRoom = make_shared<ClientGroupChatRoom>(
core, core,
chatRoomId, chatRoomId,
me, me,
...@@ -2443,6 +2444,8 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2443,6 +2444,8 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
lastNotifyId, lastNotifyId,
hasBeenLeft hasBeenLeft
); );
chatRoom = clientGroupChatRoom;
conference = clientGroupChatRoom.get();
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
dChatRoom->setState(ChatRoom::State::Instantiated); dChatRoom->setState(ChatRoom::State::Instantiated);
dChatRoom->setState(hasBeenLeft dChatRoom->setState(hasBeenLeft
...@@ -2450,7 +2453,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2450,7 +2453,7 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
: ChatRoom::State::Created : ChatRoom::State::Created
); );
} else { } else {
chatRoom = make_shared<ServerGroupChatRoom>( auto serverGroupChatRoom = make_shared<ServerGroupChatRoom>(
core, core,
chatRoomId.getPeerAddress(), chatRoomId.getPeerAddress(),
capabilities, capabilities,
...@@ -2458,10 +2461,14 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const { ...@@ -2458,10 +2461,14 @@ list<shared_ptr<AbstractChatRoom>> MainDb::getChatRooms () const {
move(participants), move(participants),
lastNotifyId lastNotifyId
); );
chatRoom = serverGroupChatRoom;
conference = serverGroupChatRoom.get();
AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate(); AbstractChatRoomPrivate *dChatRoom = chatRoom->getPrivate();
dChatRoom->setState(ChatRoom::State::Instantiated); dChatRoom->setState(ChatRoom::State::Instantiated);
dChatRoom->setState(ChatRoom::State::Created); dChatRoom->setState(ChatRoom::State::Created);
} }
for (auto participant : chatRoom->getParticipants())
participant->getPrivate()->setConference(conference);
} }
if (!chatRoom) if (!chatRoom)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment