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) ...@@ -1345,10 +1345,38 @@ CallWidget::connectAccount(const std::string& accountId)
case lrc::api::call::Status::TIMEOUT: case lrc::api::call::Status::TIMEOUT:
case lrc::api::call::Status::TERMINATING: { case lrc::api::call::Status::TERMINATING: {
LRCInstance::renderer()->removeDistantRenderer(callId); LRCInstance::renderer()->removeDistantRenderer(callId);
ui->videoView->updateCall(); auto convInfo = LRCInstance::getConversationFromCallId(callId);
setCallPanelVisibility(false); if (convInfo.uid.empty()) {
showConversationView(); break;
callTerminating(callId); }
// 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; break;
} }
case lrc::api::call::Status::CONNECTED: case lrc::api::call::Status::CONNECTED:
......
...@@ -145,11 +145,14 @@ public: ...@@ -145,11 +145,14 @@ public:
} }
} }
static const call::Info* static const call::Info*
getCallInfoForConversation(const conversation::Info& convInfo) { getCallInfoForConversation(const conversation::Info& convInfo,
bool forceCallOnly = {}) {
try { try {
auto accountId = convInfo.accountId; auto accountId = convInfo.accountId;
auto& accInfo = LRCInstance::accountModel().getAccountInfo(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)) { if (!accInfo.callModel->hasCall(callId)) {
return nullptr; return nullptr;
} }
...@@ -354,6 +357,23 @@ public: ...@@ -354,6 +357,23 @@ public:
instance().contentDrafts_[draftKey] = content; 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: signals:
void accountListChanged(); void accountListChanged();
...@@ -372,4 +392,5 @@ private: ...@@ -372,4 +392,5 @@ private:
std::string selectedAccountId_; std::string selectedAccountId_;
std::string selectedConvUid_; std::string selectedConvUid_;
MapStringString contentDrafts_; MapStringString contentDrafts_;
std::map<std::string, std::string> lastConferencees_;
}; };
...@@ -164,6 +164,18 @@ VideoOverlay::on_hangupButton_clicked() ...@@ -164,6 +164,18 @@ VideoOverlay::on_hangupButton_clicked()
if (!convInfo.uid.empty()) { if (!convInfo.uid.empty()) {
auto callModel = LRCInstance::getCurrentCallModel(); auto callModel = LRCInstance::getCurrentCallModel();
if (callModel->hasCall(convInfo.callId)) { 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); callModel->hangUp(convInfo.callId);
} }
} }
......
...@@ -290,7 +290,8 @@ VideoView::showContextMenu(const QPoint& position) ...@@ -290,7 +290,8 @@ VideoView::showContextMenu(const QPoint& position)
void void
VideoView::updateCall(const std::string& convUid, VideoView::updateCall(const std::string& convUid,
const std::string& accountId) const std::string& accountId,
bool forceCallOnly)
{ {
accountId_ = accountId.empty() ? accountId_ : accountId; accountId_ = accountId.empty() ? accountId_ : accountId;
convUid_ = convUid.empty() ? convUid_ : convUid; convUid_ = convUid.empty() ? convUid_ : convUid;
...@@ -300,7 +301,7 @@ VideoView::updateCall(const std::string& convUid, ...@@ -300,7 +301,7 @@ VideoView::updateCall(const std::string& convUid,
return; return;
} }
auto call = LRCInstance::getCallInfoForConversation(convInfo); auto call = LRCInstance::getCallInfoForConversation(convInfo, forceCallOnly);
if (!call) { if (!call) {
return; return;
} }
...@@ -313,7 +314,7 @@ VideoView::updateCall(const std::string& convUid, ...@@ -313,7 +314,7 @@ VideoView::updateCall(const std::string& convUid,
} }
// preview // preview
previewWidget_->setVisible(shouldShowPreview()); previewWidget_->setVisible(shouldShowPreview(forceCallOnly));
// distant // distant
ui->distantWidget->setRendererId(call->id); ui->distantWidget->setRendererId(call->id);
...@@ -405,14 +406,14 @@ VideoView::slotVideoMuteStateChanged(bool state) ...@@ -405,14 +406,14 @@ VideoView::slotVideoMuteStateChanged(bool state)
} }
bool bool
VideoView::shouldShowPreview() VideoView::shouldShowPreview(bool force)
{ {
bool shouldShowPreview{ false }; bool shouldShowPreview{ false };
auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_); auto convInfo = LRCInstance::getConversationFromConvUid(convUid_, accountId_);
if (convInfo.uid.empty()) { if (convInfo.uid.empty()) {
return shouldShowPreview; return shouldShowPreview;
} }
auto call = LRCInstance::getCallInfoForConversation(convInfo); auto call = LRCInstance::getCallInfoForConversation(convInfo, force);
if (call) { if (call) {
shouldShowPreview = shouldShowPreview =
!call->isAudioOnly && !call->isAudioOnly &&
......
...@@ -45,7 +45,8 @@ public: ...@@ -45,7 +45,8 @@ public:
~VideoView(); ~VideoView();
void updateCall(const std::string& convUid = {}, void updateCall(const std::string& convUid = {},
const std::string& accountId = {}); const std::string& accountId = {},
bool forceCallOnly = false);
void simulateShowChatview(bool checked); void simulateShowChatview(bool checked);
void resetPreview(); void resetPreview();
...@@ -93,7 +94,7 @@ private: ...@@ -93,7 +94,7 @@ private:
int keyPressed_; int keyPressed_;
private: private:
bool shouldShowPreview(); bool shouldShowPreview(bool force = false);
void toggleFullScreen(); void toggleFullScreen();
signals: 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