From 8c25417514a1a3418cdf5da3c70ce3d789385103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 24 Jul 2020 15:14:47 -0400 Subject: [PATCH] callmodel: handle conference's informations Change-Id: Id32f6a03a7d4a7df9bc7c9b744002f847099713d --- src/api/call.h | 3 +++ src/api/newcallmodel.h | 5 ++++ src/newcallmodel.cpp | 31 ++++++++++++++++++++++- src/qtwrapper/callmanager_wrap.h | 14 ++++++++++ src/qtwrapper/configurationmanager_wrap.h | 2 +- 5 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/api/call.h b/src/api/call.h index a6545a40..c95e6fb1 100644 --- a/src/api/call.h +++ b/src/api/call.h @@ -26,6 +26,8 @@ #include <ctime> #include <chrono> +#include "typedefs.h" + namespace lrc { @@ -143,6 +145,7 @@ struct Info bool videoMuted = false; bool isAudioOnly = false; Layout layout = Layout::GRID; + VectorMapStringString participantsInfos = {}; }; static inline bool diff --git a/src/api/newcallmodel.h b/src/api/newcallmodel.h index c1fe7bac..86e1ddf0 100644 --- a/src/api/newcallmodel.h +++ b/src/api/newcallmodel.h @@ -241,6 +241,11 @@ Q_SIGNALS: * @param callId */ void callStatusChanged(const QString& callId, int code) const; + /** + * Emitted when the rendered image changed + * @param confId + */ + void onParticipantsChanged(const QString& confId) const; /** * Emitted when a call starts * @param callId diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp index 05e8ef60..13fb5a37 100644 --- a/src/newcallmodel.cpp +++ b/src/newcallmodel.cpp @@ -36,6 +36,7 @@ #include "dbus/callmanager.h" #include "vcard.h" #include "video/renderer.h" +#include "typedefs.h" // Ring daemon #include <media_const.h> @@ -183,6 +184,12 @@ public Q_SLOTS: * @param urgentCount */ void slotVoiceMailNotify(const QString& accountId, int newCount, int oldCount, int urgentCount); + /** + * Listen from CallManager when a conference layout is updated + * @param confId + * @param infos + */ + void slotOnConferenceInfosUpdated(const QString& confId, const VectorMapStringString& infos); }; NewCallModel::NewCallModel(const account::Info& owner, const CallbacksHandler& callbacksHandler) @@ -506,6 +513,7 @@ NewCallModelPimpl::NewCallModelPimpl(const NewCallModel& linked, const Callbacks connect(&callbacksHandler, &CallbacksHandler::incomingVCardChunk, this, &NewCallModelPimpl::slotincomingVCardChunk); connect(&callbacksHandler, &CallbacksHandler::conferenceCreated, this , &NewCallModelPimpl::slotConferenceCreated); connect(&callbacksHandler, &CallbacksHandler::voiceMailNotify, this, &NewCallModelPimpl::slotVoiceMailNotify); + connect(&CallManager::instance(), &CallManagerInterface::onConferenceInfosUpdated, this, &NewCallModelPimpl::slotOnConferenceInfosUpdated); #ifndef ENABLE_LIBWRAP // Only necessary with dbus since the daemon runs separately @@ -543,6 +551,8 @@ NewCallModelPimpl::initCallFromDaemon() callInfo->videoMuted = details["VIDEO_MUTED"] == "true"; callInfo->audioMuted = details["AUDIO_MUTED"] == "true"; callInfo->type = call::Type::DIALOG; + VectorMapStringString infos = CallManager::instance().getConferenceInfos(callId); + callInfo->participantsInfos = infos; calls.emplace(callId, std::move(callInfo)); // NOTE/BUG: the videorenderer can't know that the client has restarted // So, for now, a user will have to manually restart the medias until @@ -575,6 +585,8 @@ NewCallModelPimpl::initConferencesFromDaemon() } if (!isForThisAccount) break; callInfo->type = call::Type::CONFERENCE; + VectorMapStringString infos = CallManager::instance().getConferenceInfos(callId); + callInfo->participantsInfos = infos; calls.emplace(callId, std::move(callInfo)); } } @@ -832,6 +844,23 @@ NewCallModelPimpl::slotVoiceMailNotify(const QString& accountId, int newCount, i emit linked.voiceMailNotify(accountId, newCount, oldCount, urgentCount); } +void +NewCallModelPimpl::slotOnConferenceInfosUpdated(const QString& confId, const VectorMapStringString& infos) +{ + auto it = calls.find(confId); + if (it == calls.end() or not it->second) + return; + + qDebug() << "New conference layout received for call " << confId; + + // if Jami, remove @ring.dht + it->second->participantsInfos = infos; + for (auto& i: it->second->participantsInfos) + i["uri"].replace("@ring.dht", ""); + + emit linked.onParticipantsChanged(confId); +} + bool NewCallModel::hasCall(const QString& callId) const { @@ -850,7 +879,7 @@ NewCallModelPimpl::slotConferenceCreated(const QString& confId) QStringList callList = CallManager::instance().getParticipantList(confId); foreach(const auto& call, callList) { emit linked.callAddedToConference(call, confId); - // Remove acll from pendingConferences_ + // Remove call from pendingConferences_ pendingConferences_.erase(call); } diff --git a/src/qtwrapper/callmanager_wrap.h b/src/qtwrapper/callmanager_wrap.h index bd168d3b..292f28e9 100644 --- a/src/qtwrapper/callmanager_wrap.h +++ b/src/qtwrapper/callmanager_wrap.h @@ -118,6 +118,11 @@ public: LOG_DRING_SIGNAL2("onRtcpReportReceived",QString(callID.c_str()), convertStringInt(report)); Q_EMIT onRtcpReportReceived(QString(callID.c_str()), convertStringInt(report)); }), + exportable_callback<CallSignal::OnConferenceInfosUpdated>( + [this] (const std::string& confId, const std::vector<std::map<std::string, std::string>>& infos) { + LOG_DRING_SIGNAL2("onConferenceInfosUpdated",QString(confId.c_str()),convertVecMap(infos)); + Q_EMIT onConferenceInfosUpdated(QString(confId.c_str()), convertVecMap(infos)); + }), exportable_callback<CallSignal::PeerHold>( [this] (const std::string &callID, bool state) { LOG_DRING_SIGNAL2("peerHold",QString(callID.c_str()), state); @@ -201,6 +206,14 @@ public Q_SLOTS: // METHODS return temp; } + VectorMapStringString getConferenceInfos(const QString &confId) + { + VectorMapStringString temp = + convertVecMap(DRing::getConferenceInfos( + confId.toStdString())); + return temp; + } + QString getConferenceId(const QString &callID) { QString temp(DRing::getConferenceId(callID.toStdString()).c_str()); @@ -399,6 +412,7 @@ Q_SIGNALS: // SIGNALS void conferenceRemoved(const QString &confID); void recordingStateChanged(const QString &callID, bool recordingState); void onRtcpReportReceived(const QString &callID, MapStringInt report); + void onConferenceInfosUpdated(const QString &confId, VectorMapStringString infos); void audioMuted(const QString &callID, bool state); void videoMuted(const QString &callID, bool state); void peerHold(const QString &callID, bool state); diff --git a/src/qtwrapper/configurationmanager_wrap.h b/src/qtwrapper/configurationmanager_wrap.h index 3d273046..5fa19498 100644 --- a/src/qtwrapper/configurationmanager_wrap.h +++ b/src/qtwrapper/configurationmanager_wrap.h @@ -722,7 +722,7 @@ public Q_SLOTS: // METHODS } bool setMessageDisplayed(const QString& accountId, const QString& contactId, const QString& messageId, int status) { - DRing::setMessageDisplayed(accountId.toStdString(), contactId.toStdString(), messageId.toStdString(), status); + return DRing::setMessageDisplayed(accountId.toStdString(), contactId.toStdString(), messageId.toStdString(), status); } Q_SIGNALS: // SIGNALS -- GitLab