/* * conference.cpp * Copyright (C) 2010-2018 Belledonne Communications SARL * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "conference-p.h" #include "conference/session/call-session-p.h" #include "logger/logger.h" #include "participant-p.h" // ============================================================================= using namespace std; LINPHONE_BEGIN_NAMESPACE Conference::Conference ( ConferencePrivate &p, const shared_ptr &core, const IdentityAddress &myAddress, CallSessionListener *listener ) : CoreAccessor(core), mPrivate(&p) { L_D(); d->mPublic = this; d->me = make_shared(myAddress); d->listener = listener; } Conference::~Conference () { delete mPrivate; } // ----------------------------------------------------------------------------- shared_ptr Conference::getActiveParticipant () const { L_D(); return d->activeParticipant; } // ----------------------------------------------------------------------------- void Conference::addParticipant (const IdentityAddress &addr, const CallSessionParams *params, bool hasMedia) { lError() << "Conference class does not handle addParticipant() generically"; } void Conference::addParticipants (const list &addresses, const CallSessionParams *params, bool hasMedia) { list sortedAddresses(addresses); sortedAddresses.sort(); sortedAddresses.unique(); for (const auto &addr: sortedAddresses) addParticipant(addr, params, hasMedia); } bool Conference::canHandleParticipants () const { return true; } const IdentityAddress &Conference::getConferenceAddress () const { L_D(); return d->conferenceAddress; } shared_ptr Conference::getMe () const { L_D(); return d->me; } int Conference::getParticipantCount () const { return static_cast(getParticipants().size()); } const list> &Conference::getParticipants () const { L_D(); return d->participants; } const string &Conference::getSubject () const { L_D(); return d->subject; } void Conference::join () {} void Conference::leave () {} void Conference::removeParticipant (const shared_ptr &participant) { lError() << "Conference class does not handle removeParticipant() generically"; } void Conference::removeParticipants (const list> &participants) { for (const auto &p : participants) removeParticipant(p); } void Conference::setParticipantAdminStatus (const shared_ptr &participant, bool isAdmin) { lError() << "Conference class does not handle setParticipantAdminStatus() generically"; } void Conference::setSubject (const string &subject) { L_D(); d->subject = subject; } // ----------------------------------------------------------------------------- shared_ptr Conference::findParticipant (const IdentityAddress &addr) const { L_D(); IdentityAddress searchedAddr(addr); searchedAddr.setGruu(""); for (const auto &participant : d->participants) { if (participant->getAddress() == searchedAddr) return participant; } return nullptr; } shared_ptr Conference::findParticipant (const shared_ptr &session) const { L_D(); for (const auto &participant : d->participants) { if (participant->getPrivate()->getSession() == session) return participant; } return nullptr; } shared_ptr Conference::findParticipantDevice (const shared_ptr &session) const { L_D(); for (const auto &participant : d->participants) { for (const auto &device : participant->getPrivate()->getDevices()) { if (device->getSession() == session) return device; } } return nullptr; } bool Conference::isMe (const IdentityAddress &addr) const { L_D(); IdentityAddress cleanedAddr(addr); cleanedAddr.setGruu(""); IdentityAddress cleanedMeAddr(d->me->getAddress()); cleanedMeAddr.setGruu(""); return cleanedMeAddr == cleanedAddr; } LINPHONE_END_NAMESPACE