Commit 8cc7fc7d authored by Andreas Traczyk's avatar Andreas Traczyk

conferences: better handling of conference participant removal

- When removing a participant, move the smarltlist selection to
  a remaining participant.

Change-Id: I4109da88363e606b0c45404919fe8c90f004881d
parent f58da367
......@@ -1345,10 +1345,38 @@ CallWidget::connectAccount(const std::string& accountId)
case lrc::api::call::Status::TIMEOUT:
case lrc::api::call::Status::TERMINATING: {
LRCInstance::renderer()->removeDistantRenderer(callId);
auto convInfo = LRCInstance::getConversationFromCallId(callId);
if (convInfo.uid.empty()) {
break;
}
// If it's a conference, change the smartlist index
// to the next remaining participant.
bool forceCallOnly{ false };
if (!convInfo.confId.empty()) {
auto callList = LRCInstance::getAPI().getConferenceSubcalls(convInfo.confId);
if (callList.empty()) {
auto lastConferencee = LRCInstance::instance().popLastConferencee(convInfo.confId);
callList.emplace_back(lastConferencee);
forceCallOnly = true;
}
for (const auto& callId : callList) {
if (!callModel->hasCall(callId)) {
continue;
}
auto otherConv = LRCInstance::getConversationFromCallId(callId);
if (!otherConv.uid.empty() && otherConv.uid != convInfo.uid) {
LRCInstance::setSelectedConvId(otherConv.uid);
selectSmartlistItem(otherConv.uid);
ui->videoView->updateCall(otherConv.uid, otherConv.accountId, forceCallOnly);
}
}
} else {
ui->videoView->updateCall();
setCallPanelVisibility(false);
showConversationView();
callTerminating(callId);
}
break;
}
case lrc::api::call::Status::CONNECTED:
......
......@@ -145,11 +145,14 @@ public:
}
}
static const call::Info*
getCallInfoForConversation(const conversation::Info& convInfo) {
getCallInfoForConversation(const conversation::Info& convInfo,
bool forceCallOnly = {}) {
try {
auto accountId = convInfo.accountId;
auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto callId = convInfo.confId.empty() ? convInfo.callId : convInfo.confId;
auto callId = forceCallOnly ?
convInfo.callId :
(convInfo.confId.empty() ? convInfo.callId : convInfo.confId);
if (!accInfo.callModel->hasCall(callId)) {
return nullptr;
}
......@@ -354,6 +357,23 @@ public:
instance().contentDrafts_[draftKey] = content;
}
static void pushLastConferencee(const std::string& confId,
const std::string& callId)
{
instance().lastConferencees_[confId] = callId;
}
static std::string popLastConferencee(const std::string& confId)
{
std::string callId = {};
auto iter = instance().lastConferencees_.find(confId);
if (iter != instance().lastConferencees_.end()) {
callId = iter->second;
instance().lastConferencees_.erase(iter);
}
return callId;
}
signals:
void accountListChanged();
......@@ -372,4 +392,5 @@ private:
std::string selectedAccountId_;
std::string selectedConvUid_;
MapStringString contentDrafts_;
std::map<std::string, std::string> lastConferencees_;
};
......@@ -164,6 +164,18 @@ VideoOverlay::on_hangupButton_clicked()
if (!convInfo.uid.empty()) {
auto callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(convInfo.callId)) {
// Store the last remaining participant of the conference
// so we can switch the smartlist index after termination.
if (!convInfo.confId.empty()) {
auto callList = LRCInstance::getAPI().getConferenceSubcalls(convInfo.confId);
if (callList.size() == 2) {
for (const auto& cId : callList) {
if (cId != convInfo.callId) {
LRCInstance::instance().pushLastConferencee(convInfo.confId, cId);
}
}
}
}
callModel->hangUp(convInfo.callId);
}
}
......
......@@ -290,7 +290,8 @@ VideoView::showContextMenu(const QPoint& position)
void
VideoView::updateCall(const std::string& convUid,
const std::string& accountId)
const std::string& accountId,
bool forceCallOnly)
{
accountId_ = accountId.empty() ? accountId_ : accountId;
convUid_ = convUid.empty() ? convUid_ : convUid;
......@@ -300,7 +301,7 @@ VideoView::updateCall(const std::string& convUid,
return;
}
auto call = LRCInstance::getCallInfoForConversation(convInfo);
auto call = LRCInstance::getCallInfoForConversation(convInfo, forceCallOnly);
if (!call) {
return;
}
......@@ -313,7 +314,7 @@ VideoView::updateCall(const std::string& convUid,
}
// preview
previewWidget_->setVisible(shouldShowPreview());
previewWidget_->setVisible(shouldShowPreview(forceCallOnly));
// distant
ui->distantWidget->setRendererId(call->id);
......@@ -405,14 +406,14 @@ VideoView::slotVideoMuteStateChanged(bool state)
}
bool
VideoView::shouldShowPreview()
VideoView::shouldShowPreview(bool force)
{
bool shouldShowPreview{ false };
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
if (convInfo.uid.empty()) {
return shouldShowPreview;
}
auto call = LRCInstance::getCallInfoForConversation(convInfo);
auto call = LRCInstance::getCallInfoForConversation(convInfo, force);
if (call) {
shouldShowPreview =
!call->isAudioOnly &&
......
......@@ -45,7 +45,8 @@ public:
~VideoView();
void updateCall(const std::string& convUid = {},
const std::string& accountId = {});
const std::string& accountId = {},
bool forceCallOnly = false);
void simulateShowChatview(bool checked);
void resetPreview();
......@@ -93,7 +94,7 @@ private:
int keyPressed_;
private:
bool shouldShowPreview();
bool shouldShowPreview(bool force = false);
void toggleFullScreen();
signals:
......
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