/* * client-group-chat-room.cpp * Copyright (C) 2017 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 3 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, see . */ #include "client-group-chat-room-p.h" #include "c-wrapper/c-wrapper.h" #include "conference/participant-p.h" #include "logger/logger.h" // ============================================================================= using namespace std; LINPHONE_BEGIN_NAMESPACE ClientGroupChatRoomPrivate::ClientGroupChatRoomPrivate (LinphoneCore *core) : ChatRoomPrivate(core) {} // ============================================================================= ClientGroupChatRoom::ClientGroupChatRoom (LinphoneCore *core, const Address &me) : ChatRoom(*new ChatRoomPrivate(core)), RemoteConference(core, me, nullptr) { string factoryUri = linphone_core_get_chat_conference_factory_uri(core); focus = make_shared(factoryUri); CallSessionParams csp; shared_ptr session = focus->getPrivate()->createSession(*this, &csp, false, this); session->configure(LinphoneCallOutgoing, nullptr, nullptr, me, focus->getAddress()); // TODO } // ----------------------------------------------------------------------------- shared_ptr ClientGroupChatRoom::addParticipant (const Address &addr, const CallSessionParams *params, bool hasMedia) { activeParticipant = make_shared(addr); activeParticipant->getPrivate()->createSession(*this, params, hasMedia, this); return activeParticipant; } void ClientGroupChatRoom::addParticipants (const list
&addresses, const CallSessionParams *params, bool hasMedia) { L_D(ClientGroupChatRoom); if (d->state == ChatRoom::State::Instantiated) { shared_ptr session = focus->getPrivate()->getSession(); session->initiateOutgoing(); session->startInvite(nullptr); d->setState(ChatRoom::State::CreationPending); } // TODO } bool ClientGroupChatRoom::canHandleParticipants () const { return RemoteConference::canHandleParticipants(); } const string& ClientGroupChatRoom::getId () const { return RemoteConference::getId(); } int ClientGroupChatRoom::getNbParticipants () const { return RemoteConference::getNbParticipants(); } list> ClientGroupChatRoom::getParticipants () const { return RemoteConference::getParticipants(); } void ClientGroupChatRoom::removeParticipant (const shared_ptr &participant) { // TODO } void ClientGroupChatRoom::removeParticipants (const list> &participants) { // TODO } // ----------------------------------------------------------------------------- void ClientGroupChatRoom::onConferenceCreated (const Address &addr) { // TODO } void ClientGroupChatRoom::onConferenceTerminated (const Address &addr) { // TODO } void ClientGroupChatRoom::onParticipantAdded (const Address &addr) { shared_ptr participant = findParticipant(addr); if (participant) { lWarning() << "Participant " << participant << " added but already in the list of participants!"; return; } participant = make_shared(addr); participants.push_back(participant); 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); if (cb) cb(cr, L_GET_C_BACK_PTR(participant)); } void ClientGroupChatRoom::onParticipantRemoved (const Address &addr) { shared_ptr participant = findParticipant(addr); if (!participant) { lWarning() << "Participant " << participant << " removed but not in the list of participants!"; return; } 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); if (cb) cb(cr, L_GET_C_BACK_PTR(participant)); participants.remove(participant); } void ClientGroupChatRoom::onParticipantSetAdmin (const Address &addr, bool isAdmin) { shared_ptr participant = findParticipant(addr); if (!participant) { lWarning() << "Participant " << participant << " admin status has been changed but is not in the list of participants!"; return; } participant->setAdmin(isAdmin); 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); if (cb) cb(cr, L_GET_C_BACK_PTR(participant), isAdmin); } LINPHONE_END_NAMESPACE