1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 06:45:45 +02:00

callview: fix incoming callview not showing when window not focused

Change-Id: I5977f4231c1cd3181412a0c25ce769b8889d508a
Gitlab: #449
This commit is contained in:
Andreas Traczyk 2021-06-10 17:51:29 -04:00
parent c8b3909d66
commit ab744e8d2a

View file

@ -356,96 +356,78 @@ CallAdapter::onShowIncomingCallView(const QString& accountId, const QString& con
{ {
const auto& convInfo = lrcInstance_->getConversationFromConvUid(convUid, accountId); const auto& convInfo = lrcInstance_->getConversationFromConvUid(convUid, accountId);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
qWarning() << Q_FUNC_INFO << "No conversation for id: " << convUid;
return; return;
} }
auto selectedAccountId = lrcInstance_->getCurrentAccountId();
auto* callModel = lrcInstance_->getCurrentCallModel();
// new call const auto& accInfo = lrcInstance_->getAccountInfo(accountId);
if (!callModel->hasCall(convInfo.callId)) { if (!accInfo.callModel->hasCall(convInfo.callId)) {
if (QApplication::focusObject() == nullptr || accountId != selectedAccountId) { qWarning() << Q_FUNC_INFO << "No call for id: " << convInfo.callId;
showNotification(accountId, convInfo.uid); return;
return; }
} auto call = accInfo.callModel->getCall(convInfo.callId);
const auto& currentConvInfo = lrcInstance_->getConversationFromConvUid( // this will update various UI elements that portray the call state
lrcInstance_->get_selectedConvUid()); Q_EMIT callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid);
// Current call auto callBelongsToSelectedAccount = accountId == lrcInstance_->getCurrentAccountId();
auto currentConvHasCall = callModel->hasCall(currentConvInfo.callId); auto accountProperties = lrcInstance_->accountModel().getAccountConfig(accountId);
if (currentConvHasCall) {
auto currentCall = callModel->getCall(currentConvInfo.callId); // do nothing but update the status UI for incoming calls on RendezVous accounts
if (currentCall.status == lrc::api::call::Status::CONNECTED if (accountProperties.isRendezVous && !call.isOutgoing) {
|| currentCall.status == lrc::api::call::Status::IN_PROGRESS) { qInfo() << Q_FUNC_INFO << "The call's associated account is a RendezVous point";
showNotification(accountId, convInfo.uid); return;
return; }
auto currentConvId = lrcInstance_->get_selectedConvUid();
auto isCallSelected = currentConvId == convInfo.uid;
// pop a notification when:
// - the window is not focused OR the call is for another account
// - the call is incoming AND the call's target account is
// not a RendezVous point
// - the call has just transitioned to the INCOMING_RINGING state
if ((QApplication::focusObject() == nullptr || !callBelongsToSelectedAccount)
&& !call.isOutgoing && !accountProperties.isRendezVous
&& call.status == call::Status::INCOMING_RINGING) {
// if the window is not focused but the call belongs to the selected account
// then select the conversation immediately to show the call view
if (callBelongsToSelectedAccount) {
if (isCallSelected) {
Q_EMIT lrcInstance_->conversationUpdated(convInfo.uid, accountId);
} else {
lrcInstance_->selectConversation(convInfo.uid);
} }
} }
// select showNotification(accountId, convInfo.uid);
lrcInstance_->selectConversation(convInfo.uid, accountId);
return; return;
} }
// this slot has been triggered as a result of either selecting a conversation // this slot has been triggered as a result of either selecting a conversation
// with an active call, placing a call, or an incoming call for the current // with an active call, placing a call, or an incoming call for the current
// or any other conversation // or any other conversation
auto call = callModel->getCall(convInfo.callId); if (isCallSelected) {
auto isCallSelected = lrcInstance_->get_selectedConvUid() == convInfo.uid; // current conversation, only update
Q_EMIT lrcInstance_->conversationUpdated(convInfo.uid, accountId);
return;
}
if (call.isOutgoing) { // pop a notification if the current conversation has an in-progress call
if (isCallSelected) { const auto& currentConvInfo = lrcInstance_->getConversationFromConvUid(currentConvId);
// don't reselect auto currentConvHasCall = accInfo.callModel->hasCall(currentConvInfo.callId);
// TODO: this signal can be renamed to conversationReselected, if (currentConvHasCall) {
// isCallSelected and any other similar logic can be removed auto currentCall = accInfo.callModel->getCall(currentConvInfo.callId);
// and calling selectConversation should be sufficient if ((currentCall.status == call::Status::CONNECTED
Q_EMIT lrcInstance_->conversationUpdated(convInfo.uid, accountId); || currentCall.status == call::Status::IN_PROGRESS)
} && !accountProperties.autoAnswer) {
} else { showNotification(accountId, convInfo.uid);
auto accountProperties = lrcInstance_->accountModel().getAccountConfig(selectedAccountId); return;
if (!accountProperties.isRendezVous) {
// App not focused or in different account
if (QApplication::focusObject() == nullptr || accountId != selectedAccountId) {
showNotification(accountId, convInfo.uid);
return;
}
const auto& currentConvInfo = lrcInstance_->getConversationFromConvUid(
lrcInstance_->get_selectedConvUid());
// Call in current conversation
auto currentConvHasCall = callModel->hasCall(currentConvInfo.callId);
// Check INCOMING / OUTGOING call in current conversation
if (isCallSelected) {
if (currentConvHasCall) {
auto currentCall = callModel->getCall(currentConvInfo.callId);
if (currentCall.status == lrc::api::call::Status::OUTGOING_RINGING) {
showNotification(accountId, convInfo.uid);
return;
} else {
// only update
Q_EMIT lrcInstance_->conversationUpdated(convInfo.uid, accountId);
}
} else {
// only update
Q_EMIT lrcInstance_->conversationUpdated(convInfo.uid, accountId);
}
} else { // Not current conversation
if (currentConvHasCall) {
auto currentCall = callModel->getCall(currentConvInfo.callId);
if ((currentCall.status == lrc::api::call::Status::CONNECTED
|| currentCall.status == lrc::api::call::Status::IN_PROGRESS)
&& !accountProperties.autoAnswer) {
showNotification(accountId, convInfo.uid);
return;
}
}
// reselect
lrcInstance_->selectConversation(convInfo.uid, accountId);
}
} }
} }
Q_EMIT callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid);
// finally, in this case, the conversation isn't selected yet
// and there are no other special conditions, so just select the conversation
lrcInstance_->selectConversation(convInfo.uid, accountId);
} }
void void