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