From 28c1cbbb340e264e29d91e9a09c0de3be2a74099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 28 Feb 2024 15:09:51 -0500 Subject: [PATCH] call-swarm: follow daemon changes Change-Id: I32e83c2ccf82be78fbdd6e9932105228dd6dee8b --- daemon | 2 +- src/app/calladapter.cpp | 3 +- src/app/calladapter.h | 2 +- src/libclient/api/callmodel.h | 3 +- src/libclient/callbackshandler.cpp | 4 +- src/libclient/callbackshandler.h | 7 +-- src/libclient/callmodel.cpp | 50 ++++++++++++---------- src/libclient/conversationmodel.cpp | 8 ++-- src/libclient/qtwrapper/callmanager_wrap.h | 9 ++-- 9 files changed, 49 insertions(+), 39 deletions(-) diff --git a/daemon b/daemon index d15b4f796..e2107772f 160000 --- a/daemon +++ b/daemon @@ -1 +1 @@ -Subproject commit d15b4f79613a3cbbd427ea331958f48e4a34f0a4 +Subproject commit e2107772fd3d0b11f0721dec98f95a610b7f9a77 diff --git a/src/app/calladapter.cpp b/src/app/calladapter.cpp index 169ba6cf7..0cc2aaa6a 100644 --- a/src/app/calladapter.cpp +++ b/src/app/calladapter.cpp @@ -354,10 +354,11 @@ CallAdapter::onCallInfosChanged(const QString& accountId, const QString& callId) } void -CallAdapter::onCallAddedToConference(const QString& callId, const QString& confId) +CallAdapter::onCallAddedToConference(const QString& callId, const QString& conversationId, const QString& confId) { Q_UNUSED(callId) Q_UNUSED(confId) + Q_UNUSED(conversationId) saveConferenceSubcalls(); } diff --git a/src/app/calladapter.h b/src/app/calladapter.h index a3ebf6153..a1b98de46 100644 --- a/src/app/calladapter.h +++ b/src/app/calladapter.h @@ -122,7 +122,7 @@ public Q_SLOTS: void onAccountChanged(); void onCallStatusChanged(const QString& accountId, const QString& callId); void onCallStatusChanged(const QString& callId, int code); - void onCallAddedToConference(const QString& callId, const QString& confId); + void onCallAddedToConference(const QString& callId, const QString& conversationId, const QString& confId); void onCallStarted(const QString& callId); void onCallEnded(const QString& callId); void onCallInfosChanged(const QString& accountId, const QString& callId); diff --git a/src/libclient/api/callmodel.h b/src/libclient/api/callmodel.h index e9a077895..e2d0fdc24 100644 --- a/src/libclient/api/callmodel.h +++ b/src/libclient/api/callmodel.h @@ -480,9 +480,10 @@ Q_SIGNALS: /** * Emitted when a call is added to a conference * @param callId + * @param conversationId * @param confId */ - void callAddedToConference(const QString& callId, const QString& confId) const; + void callAddedToConference(const QString& callId, const QString& conversationId, const QString& confId) const; /** * Emitted when a voice mail notice arrives diff --git a/src/libclient/callbackshandler.cpp b/src/libclient/callbackshandler.cpp index 06c7df295..51acb43c8 100644 --- a/src/libclient/callbackshandler.cpp +++ b/src/libclient/callbackshandler.cpp @@ -548,9 +548,9 @@ CallbacksHandler::slotIncomingMessage(const QString& accountId, } void -CallbacksHandler::slotConferenceCreated(const QString& accountId, const QString& callId) +CallbacksHandler::slotConferenceCreated(const QString& accountId, const QString& convId, const QString& callId) { - Q_EMIT conferenceCreated(accountId, callId); + Q_EMIT conferenceCreated(accountId, convId, callId); } void diff --git a/src/libclient/callbackshandler.h b/src/libclient/callbackshandler.h index 78c73a639..d96c13936 100644 --- a/src/libclient/callbackshandler.h +++ b/src/libclient/callbackshandler.h @@ -173,7 +173,7 @@ Q_SIGNALS: * Connect this signal to know when a new conference is created * @param callId of the conference */ - void conferenceCreated(const QString& accountId, const QString& callId); + void conferenceCreated(const QString& accountId, const QString& conversationId, const QString& callId); void conferenceChanged(const QString& accountId, const QString& confId, const QString& state); /** * Connect this signal to know when a conference is removed @@ -500,9 +500,10 @@ private Q_SLOTS: /** * Emit conferenceCreated * @param accountId - * @param callId of the conference + * @param callId of the conference + * @param conversationId of the conference */ - void slotConferenceCreated(const QString& accountId, const QString& callId); + void slotConferenceCreated(const QString& accountId, const QString& conversationId, const QString& callId); /** * Emit conferenceRemove * @param accountId diff --git a/src/libclient/callmodel.cpp b/src/libclient/callmodel.cpp index 1befc4b69..83513d500 100644 --- a/src/libclient/callmodel.cpp +++ b/src/libclient/callmodel.cpp @@ -236,7 +236,7 @@ public Q_SLOTS: * Listen from CallbacksHandler when a conference is created. * @param callId */ - void slotConferenceCreated(const QString& accountId, const QString& callId); + void slotConferenceCreated(const QString& accountId, const QString& conversationId, const QString& callId); void slotConferenceChanged(const QString& accountId, const QString& callId, const QString& state); @@ -839,12 +839,12 @@ CallModel::joinCalls(const QString& callIdA, const QString& callIdB) const try { auto& accountInfo = owner.accountModel->getAccountInfo(accountIdCall1); if (accountInfo.callModel->hasCall(callIdA)) { - Q_EMIT accountInfo.callModel->callAddedToConference(callIdA, callIdB); + Q_EMIT accountInfo.callModel->callAddedToConference(callIdA, "", callIdB); } } catch (...) { } } else { - Q_EMIT callAddedToConference(callIdA, callIdB); + Q_EMIT callAddedToConference(callIdA, "", callIdB); } } else if (call1.type == call::Type::CONFERENCE || call2.type == call::Type::CONFERENCE) { auto call = call1.type == call::Type::CONFERENCE ? callIdB : callIdA; @@ -863,12 +863,12 @@ CallModel::joinCalls(const QString& callIdA, const QString& callIdB) const try { auto& accountInfo = owner.accountModel->getAccountInfo(accountCall); if (accountInfo.callModel->hasCall(call)) { - accountInfo.callModel->pimpl_->slotConferenceCreated(owner.id, conf); + accountInfo.callModel->pimpl_->slotConferenceCreated(owner.id, "", conf); } } catch (...) { } } else - Q_EMIT callAddedToConference(call, conf); + Q_EMIT callAddedToConference(call, "", conf); // Remove from pendingConferences_ for (int i = 0; i < pimpl_->pendingConferencees_.size(); ++i) { @@ -1169,7 +1169,7 @@ CallModelPimpl::initConferencesFromDaemon() ? call::Status::IN_PROGRESS : call::Status::PAUSED; callInfo->startTime = now - std::chrono::seconds(diff); - Q_EMIT linked.callAddedToConference(call, callId); + Q_EMIT linked.callAddedToConference(call, "", callId); } callInfo->type = call::Type::CONFERENCE; VectorMapStringString infos = CallManager::instance().getConferenceInfos(linked.owner.id, @@ -1660,7 +1660,7 @@ CallModelPimpl::slotOnConferenceInfosUpdated(const QString& confId, // And must be notified when a new QStringList callList = CallManager::instance().getParticipantList(linked.owner.id, confId); Q_FOREACH (const auto& call, callList) { - Q_EMIT linked.callAddedToConference(call, confId); + Q_EMIT linked.callAddedToConference(call, "", confId); if (calls.find(call) == calls.end()) { qWarning() << "Call not found"; } else { @@ -1710,11 +1710,10 @@ CallModel::hasCall(const QString& callId) const } void -CallModelPimpl::slotConferenceCreated(const QString& accountId, const QString& confId) +CallModelPimpl::slotConferenceCreated(const QString& accountId, const QString& conversationId, const QString& confId) { if (accountId != linked.owner.id) return; - QStringList callList = CallManager::instance().getParticipantList(linked.owner.id, confId); auto callInfo = std::make_shared<call::Info>(); callInfo->id = confId; @@ -1734,22 +1733,27 @@ CallModelPimpl::slotConferenceCreated(const QString& accountId, const QString& c calls[confId] = callInfo; QString currentCallId = currentCall_; - Q_FOREACH (const auto& call, callList) { - Q_EMIT linked.callAddedToConference(call, confId); - // Remove call from pendingConferences_ - for (int i = 0; i < pendingConferencees_.size(); ++i) { - if (pendingConferencees_.at(i).callId == call) { - Q_EMIT linked.beginRemovePendingConferenceesRows(i); - pendingConferencees_.removeAt(i); - Q_EMIT linked.endRemovePendingConferenceesRows(); - break; + if (!conversationId.isEmpty()) { + Q_EMIT linked.callAddedToConference("", conversationId, confId); + } else { + QStringList callList = CallManager::instance().getParticipantList(linked.owner.id, confId); + Q_FOREACH (const auto& call, callList) { + Q_EMIT linked.callAddedToConference(call, "", confId); + // Remove call from pendingConferences_ + for (int i = 0; i < pendingConferencees_.size(); ++i) { + if (pendingConferencees_.at(i).callId == call) { + Q_EMIT linked.beginRemovePendingConferenceesRows(i); + pendingConferencees_.removeAt(i); + Q_EMIT linked.endRemovePendingConferenceesRows(); + break; + } } + if (call == currentCall_) + currentCall_ = confId; } - if (call == currentCall_) - currentCall_ = confId; + if (currentCallId != currentCall_) + Q_EMIT linked.currentCallChanged(confId); } - if (currentCallId != currentCall_) - Q_EMIT linked.currentCallChanged(confId); } void @@ -1763,7 +1767,7 @@ CallModelPimpl::slotConferenceChanged(const QString& accountId, QStringList callList = CallManager::instance().getParticipantList(linked.owner.id, confId); QString currentCallId = currentCall_; Q_FOREACH (const auto& call, callList) { - Q_EMIT linked.callAddedToConference(call, confId); + Q_EMIT linked.callAddedToConference(call, "", confId); if (call == currentCall_) currentCall_ = confId; } diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index 63d644dae..093f1d7d0 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -310,9 +310,10 @@ public Q_SLOTS: /** * Listen from CallModel when a call is added to a conference * @param callId + * @param conversationId * @param confId */ - void slotCallAddedToConference(const QString& callId, const QString& confId); + void slotCallAddedToConference(const QString& callId, const QString& conversationId, const QString& confId); /** * Listen from CallbacksHandler when a conference is deleted. * @param accountId @@ -3457,10 +3458,11 @@ ConversationModelPimpl::addIncomingMessage(const QString& peerId, } void -ConversationModelPimpl::slotCallAddedToConference(const QString& callId, const QString& confId) +ConversationModelPimpl::slotCallAddedToConference(const QString& callId, const QString& conversationId, const QString& confId) { for (auto& conversation : conversations) { - if (conversation.callId == callId && conversation.confId != confId) { + if ((conversationId == conversation.uid) + || (!callId.isEmpty() && conversation.callId == callId && conversation.confId != confId)) { conversation.confId = confId; invalidateModel(); // Refresh the conference status only if attached diff --git a/src/libclient/qtwrapper/callmanager_wrap.h b/src/libclient/qtwrapper/callmanager_wrap.h index 735d2446c..1a7ac966c 100644 --- a/src/libclient/qtwrapper/callmanager_wrap.h +++ b/src/libclient/qtwrapper/callmanager_wrap.h @@ -144,11 +144,12 @@ public: QString(filepath.c_str())); }), exportable_callback<CallSignal::ConferenceCreated>( - [this](const std::string& accountId, const std::string& confId) { - LOG_LIBJAMI_SIGNAL2("conferenceCreated", + [this](const std::string& accountId, const std::string& conversationId, const std::string& confId) { + LOG_LIBJAMI_SIGNAL3("conferenceCreated", QString(accountId.c_str()), + QString(conversationId.c_str()), QString(confId.c_str())); - Q_EMIT conferenceCreated(QString(accountId.c_str()), QString(confId.c_str())); + Q_EMIT conferenceCreated(QString(accountId.c_str()), QString(conversationId.c_str()), QString(confId.c_str())); }), exportable_callback<CallSignal::ConferenceChanged>([this](const std::string& accountId, const std::string& confId, @@ -628,7 +629,7 @@ Q_SIGNALS: // SIGNALS const QString& callId, const VectorMapStringString& mediaList); void recordPlaybackFilepath(const QString& callId, const QString& filepath); - void conferenceCreated(const QString& accountId, const QString& confId); + void conferenceCreated(const QString& accountId, const QString& conversationId, const QString& confId); void conferenceChanged(const QString& accountId, const QString& confId, const QString& state); void updatePlaybackScale(const QString& filepath, int position, int size); void conferenceRemoved(const QString& accountId, const QString& confId); -- GitLab