mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-04 23:05:48 +02:00
calladapter: use infos from daemon to know if we are the conf moderator
Make the difference between a host and a moderator. The main difference for now is that the host can hang up calls, not the moderator because they don't know the calls hosted Change-Id: Iec36c4d26ae32126e8628bef6491c35d0228a45f
This commit is contained in:
parent
3ef4d3ddb1
commit
695dff3994
5 changed files with 57 additions and 21 deletions
|
@ -546,8 +546,9 @@ CallAdapter::maximizeParticipant(const QString& uri, bool isActive)
|
||||||
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
||||||
auto* convModel = LRCInstance::getCurrentConversationModel();
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
||||||
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
|
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
|
||||||
const auto confId = conversation.confId;
|
auto confId = conversation.confId;
|
||||||
|
if (confId.isEmpty())
|
||||||
|
confId = conversation.callId;
|
||||||
try {
|
try {
|
||||||
const auto call = callModel->getCall(confId);
|
const auto call = callModel->getCall(confId);
|
||||||
switch (call.layout) {
|
switch (call.layout) {
|
||||||
|
@ -576,7 +577,9 @@ CallAdapter::minimizeParticipant()
|
||||||
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
||||||
auto* convModel = LRCInstance::getCurrentConversationModel();
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
||||||
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
|
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid());
|
||||||
const auto confId = conversation.confId;
|
auto confId = conversation.confId;
|
||||||
|
if (confId.isEmpty())
|
||||||
|
confId = conversation.callId;
|
||||||
try {
|
try {
|
||||||
auto call = callModel->getCall(confId);
|
auto call = callModel->getCall(confId);
|
||||||
switch (call.layout) {
|
switch (call.layout) {
|
||||||
|
@ -619,18 +622,18 @@ CallAdapter::isRecordingThisCall()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CallAdapter::isCurrentMaster() const
|
CallAdapter::isCurrentHost() const
|
||||||
{
|
{
|
||||||
auto* convModel = LRCInstance::getCurrentConversationModel();
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
||||||
const auto convInfo = convModel->getConversationForUID(convUid_);
|
const auto convInfo = convModel->getConversationForUID(convUid_);
|
||||||
if (!convInfo.uid.isEmpty()) {
|
if (!convInfo.uid.isEmpty()) {
|
||||||
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
||||||
try {
|
try {
|
||||||
if (!convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId)) {
|
auto call = callModel->getCall(convInfo.callId);
|
||||||
|
if (call.participantsInfos.size() == 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
auto call = callModel->getCall(convInfo.callId);
|
return !convInfo.confId.isEmpty() && callModel->hasCall(convInfo.confId);
|
||||||
return call.participantsInfos.size() == 0;
|
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
@ -638,6 +641,31 @@ CallAdapter::isCurrentMaster() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
CallAdapter::isCurrentModerator() const
|
||||||
|
{
|
||||||
|
auto* convModel = LRCInstance::getCurrentConversationModel();
|
||||||
|
const auto convInfo = convModel->getConversationForUID(convUid_);
|
||||||
|
if (!convInfo.uid.isEmpty()) {
|
||||||
|
auto* callModel = LRCInstance::getAccountInfo(accountId_).callModel.get();
|
||||||
|
try {
|
||||||
|
auto call = callModel->getCall(convInfo.callId);
|
||||||
|
if (call.participantsInfos.size() == 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId_);
|
||||||
|
for (const auto& participant : call.participantsInfos) {
|
||||||
|
if (participant["uri"] == accInfo.profileInfo.uri)
|
||||||
|
return participant["isModerator"] == "true";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
CallAdapter::getCurrentLayoutType() const
|
CallAdapter::getCurrentLayoutType() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,8 @@ public:
|
||||||
Q_INVOKABLE void maximizeParticipant(const QString& uri, bool isActive);
|
Q_INVOKABLE void maximizeParticipant(const QString& uri, bool isActive);
|
||||||
Q_INVOKABLE void minimizeParticipant();
|
Q_INVOKABLE void minimizeParticipant();
|
||||||
Q_INVOKABLE void hangUpThisCall();
|
Q_INVOKABLE void hangUpThisCall();
|
||||||
Q_INVOKABLE bool isCurrentMaster() const;
|
Q_INVOKABLE bool isCurrentModerator() const;
|
||||||
|
Q_INVOKABLE bool isCurrentHost() const;
|
||||||
Q_INVOKABLE int getCurrentLayoutType() const;
|
Q_INVOKABLE int getCurrentLayoutType() const;
|
||||||
Q_INVOKABLE void holdThisCallToggle();
|
Q_INVOKABLE void holdThisCallToggle();
|
||||||
Q_INVOKABLE void muteThisCallToggle();
|
Q_INVOKABLE void muteThisCallToggle();
|
||||||
|
|
|
@ -58,8 +58,8 @@ Rectangle {
|
||||||
isConferenceCall)
|
isConferenceCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMaster() {
|
function updateMenu() {
|
||||||
callOverlayButtonGroup.updateMaster()
|
callOverlayButtonGroup.updateMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
function showOnHoldImage(visible) {
|
function showOnHoldImage(visible) {
|
||||||
|
@ -75,8 +75,9 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleParticipantsInfo(infos) {
|
function handleParticipantsInfo(infos) {
|
||||||
videoCallOverlay.updateMaster()
|
videoCallOverlay.updateMenu()
|
||||||
var isMaster = CallAdapter.isCurrentMaster()
|
var isModerator = CallAdapter.isCurrentModerator()
|
||||||
|
var isHost = CallAdapter.isCurrentHost()
|
||||||
for (var p in participantOverlays) {
|
for (var p in participantOverlays) {
|
||||||
if (participantOverlays[p])
|
if (participantOverlays[p])
|
||||||
participantOverlays[p].destroy()
|
participantOverlays[p].destroy()
|
||||||
|
@ -102,7 +103,8 @@ Rectangle {
|
||||||
hover.setParticipantName(infos[infoVariant].bestName)
|
hover.setParticipantName(infos[infoVariant].bestName)
|
||||||
hover.active = infos[infoVariant].active;
|
hover.active = infos[infoVariant].active;
|
||||||
hover.isLocal = infos[infoVariant].isLocal;
|
hover.isLocal = infos[infoVariant].isLocal;
|
||||||
hover.setMenuVisible(isMaster)
|
hover.setMenuVisible(isModerator)
|
||||||
|
hover.setEndCallVisible(isHost)
|
||||||
hover.uri = infos[infoVariant].uri
|
hover.uri = infos[infoVariant].uri
|
||||||
if (infos[infoVariant].videoMuted)
|
if (infos[infoVariant].videoMuted)
|
||||||
hover.setAvatar(infos[infoVariant].avatar)
|
hover.setAvatar(infos[infoVariant].avatar)
|
||||||
|
|
|
@ -32,22 +32,22 @@ Rectangle {
|
||||||
// ButtonCounts here is to make sure that flow layout margin is calculated correctly,
|
// ButtonCounts here is to make sure that flow layout margin is calculated correctly,
|
||||||
// since no other methods can make buttons at the layout center.
|
// since no other methods can make buttons at the layout center.
|
||||||
property int buttonPreferredSize: 24
|
property int buttonPreferredSize: 24
|
||||||
property var isMaster: true
|
property var isHost: true
|
||||||
property var isSip: false
|
property var isSip: false
|
||||||
|
|
||||||
signal chatButtonClicked
|
signal chatButtonClicked
|
||||||
signal addToConferenceButtonClicked
|
signal addToConferenceButtonClicked
|
||||||
|
|
||||||
function updateMaster() {
|
function updateMenu() {
|
||||||
root.isMaster = CallAdapter.isCurrentMaster()
|
root.isHost = CallAdapter.isCurrentHost()
|
||||||
addToConferenceButton.visible = !root.isSip && root.isMaster
|
addToConferenceButton.visible = !root.isSip && root.isHost
|
||||||
}
|
}
|
||||||
|
|
||||||
function setButtonStatus(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall) {
|
function setButtonStatus(isPaused, isAudioOnly, isAudioMuted, isVideoMuted, isRecording, isSIP, isConferenceCall) {
|
||||||
root.isMaster = CallAdapter.isCurrentMaster()
|
root.isHost = CallAdapter.isCurrentModerator()
|
||||||
root.isSip = isSIP
|
root.isSip = isSIP
|
||||||
noVideoButton.visible = !isAudioOnly
|
noVideoButton.visible = !isAudioOnly
|
||||||
addToConferenceButton.visible = !isSIP && isMaster
|
addToConferenceButton.visible = !isSIP && isHost
|
||||||
|
|
||||||
noMicButton.checked = isAudioMuted
|
noMicButton.checked = isAudioMuted
|
||||||
noVideoButton.checked = isVideoMuted
|
noVideoButton.checked = isVideoMuted
|
||||||
|
@ -161,7 +161,7 @@ Rectangle {
|
||||||
|
|
||||||
Layout.preferredWidth: buttonPreferredSize * 2
|
Layout.preferredWidth: buttonPreferredSize * 2
|
||||||
Layout.preferredHeight: buttonPreferredSize * 2
|
Layout.preferredHeight: buttonPreferredSize * 2
|
||||||
visible: !isMaster
|
visible: !isHost
|
||||||
|
|
||||||
backgroundColor: Qt.rgba(0, 0, 0, 0.75)
|
backgroundColor: Qt.rgba(0, 0, 0, 0.75)
|
||||||
onEnterColor: Qt.rgba(0, 0, 0, 0.6)
|
onEnterColor: Qt.rgba(0, 0, 0, 0.6)
|
||||||
|
|
|
@ -31,6 +31,7 @@ Rectangle {
|
||||||
property var uri: ""
|
property var uri: ""
|
||||||
property var active: true
|
property var active: true
|
||||||
property var isLocal: true
|
property var isLocal: true
|
||||||
|
property var showEndCall: true
|
||||||
property var injectedContextMenu: null
|
property var injectedContextMenu: null
|
||||||
|
|
||||||
function setParticipantName(name) {
|
function setParticipantName(name) {
|
||||||
|
@ -51,6 +52,10 @@ Rectangle {
|
||||||
optionsButton.visible = isVisible
|
optionsButton.visible = isVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setEndCallVisible(isVisible) {
|
||||||
|
showEndCall = isVisible
|
||||||
|
}
|
||||||
|
|
||||||
border.width: 1
|
border.width: 1
|
||||||
opacity: 0
|
opacity: 0
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
@ -147,7 +152,7 @@ Rectangle {
|
||||||
var layout = CallAdapter.getCurrentLayoutType()
|
var layout = CallAdapter.getCurrentLayoutType()
|
||||||
var showMaximized = layout !== 2
|
var showMaximized = layout !== 2
|
||||||
var showMinimized = !(layout === 0 || (layout === 1 && !active))
|
var showMinimized = !(layout === 0 || (layout === 1 && !active))
|
||||||
injectedContextMenu.showHangup = !root.isLocal
|
injectedContextMenu.showHangup = !root.isLocal && showEndCall
|
||||||
injectedContextMenu.showMaximize = showMaximized
|
injectedContextMenu.showMaximize = showMaximized
|
||||||
injectedContextMenu.showMinimize = showMinimized
|
injectedContextMenu.showMinimize = showMinimized
|
||||||
injectedContextMenu.uri = uri
|
injectedContextMenu.uri = uri
|
||||||
|
|
Loading…
Add table
Reference in a new issue