From ead4ea11f2f9679c6539d1ff5ff750dda477ecee Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Fri, 2 Oct 2020 13:53:24 -0400 Subject: [PATCH] conference: enable actions for moderator Now moderator could minimize/maximize conference participant Change-Id: Iba23dd170568103bf368d024cbcbc59979e89e90 Gitlab: #253 --- src/CurrentCallVC.mm | 53 ++++++++++++++++++------------ src/views/ConferenceOverlayView.h | 1 + src/views/ConferenceOverlayView.mm | 45 +++++++++++++------------ 3 files changed, 57 insertions(+), 42 deletions(-) diff --git a/src/CurrentCallVC.mm b/src/CurrentCallVC.mm index 2fa5821b..dd821d22 100644 --- a/src/CurrentCallVC.mm +++ b/src/CurrentCallVC.mm @@ -1283,19 +1283,20 @@ CVPixelBufferRef pixelBufferPreview; if (accountInfo_ == nil) return; auto* callModel = accountInfo_->callModel.get(); - if (not callModel->hasCall(confUid_)) { + auto confId = [self getcallID]; + if (not callModel->hasCall(confId)) { return; } try { - auto call = callModel->getCall(confUid_); + auto call = callModel->getCall(confId); switch (call.layout) { case lrc::api::call::Layout::GRID: break; case lrc::api::call::Layout::ONE_WITH_SMALL: - callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::GRID); + callModel->setConferenceLayout(confId, lrc::api::call::Layout::GRID); break; case lrc::api::call::Layout::ONE: - callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::ONE_WITH_SMALL); + callModel->setConferenceLayout(confId, lrc::api::call::Layout::ONE_WITH_SMALL); break; }; } catch (...) {} @@ -1303,10 +1304,11 @@ CVPixelBufferRef pixelBufferPreview; -(int)getCurrentLayout { auto* callModel = accountInfo_->callModel.get(); - if (not callModel->hasCall(confUid_)){ + auto confId = [self getcallID]; + if (not callModel->hasCall(confId)){ return -1; } - return static_cast<int>(callModel->getCall(confUid_).layout); + return static_cast<int>(callModel->getCall(confId).layout); } -(BOOL)isMasterCall { @@ -1314,39 +1316,48 @@ CVPixelBufferRef pixelBufferPreview; if (conv.uid.isEmpty()) { return false; } - auto* callModel = accountInfo_->callModel.get(); - if (!conv.confId.isEmpty() && callModel->hasCall(conv.confId)) { - return true; - } else if (!callModel->hasCall(conv.callId)) { + try { + auto call = callModel->getCall(conv.callId); + if (call.participantsInfos.size() == 0) { + return true; + } + return !conv.confId.isEmpty() && callModel->hasCall(conv.confId); + } catch (...) {} + return true; +} + +-(BOOL)isCallModerator { + if (accountInfo_ == nil) return false; - } - auto call = callModel->getCall(conv.callId); - return call.participantsInfos.size() == 0; + auto* callModel = accountInfo_->callModel.get(); + return callModel->isModerator([self getcallID]); } + -(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive { if (accountInfo_ == nil) return; BOOL localVideo = accountInfo_->profileInfo.uri == QString::fromNSString(uri); auto* callModel = accountInfo_->callModel.get(); - if (not callModel->hasCall(confUid_) && !localVideo) + auto confId = [self getcallID]; + if (not callModel->hasCall(confId) && !localVideo) return; try { - auto call = callModel->getCall(confUid_); + auto call = callModel->getCall(confId); switch (call.layout) { case lrc::api::call::Layout::GRID: - callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); - callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::ONE_WITH_SMALL); + callModel->setActiveParticipant(confId, QString::fromNSString(uri)); + callModel->setConferenceLayout(confId, lrc::api::call::Layout::ONE_WITH_SMALL); break; case lrc::api::call::Layout::ONE_WITH_SMALL: - callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); - callModel->setConferenceLayout(confUid_, + callModel->setActiveParticipant(confId, QString::fromNSString(uri)); + callModel->setConferenceLayout(confId, isActive ? lrc::api::call::Layout::ONE : lrc::api::call::Layout::ONE_WITH_SMALL); break; case lrc::api::call::Layout::ONE: - callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); - callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::GRID); + callModel->setActiveParticipant(confId, QString::fromNSString(uri)); + callModel->setConferenceLayout(confId, lrc::api::call::Layout::GRID); break; }; } catch (...) {} diff --git a/src/views/ConferenceOverlayView.h b/src/views/ConferenceOverlayView.h index 6b5f2f2f..3cf19ba5 100644 --- a/src/views/ConferenceOverlayView.h +++ b/src/views/ConferenceOverlayView.h @@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN -(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive; -(int)getCurrentLayout; -(BOOL)isMasterCall; +-(BOOL)isCallModerator; @end struct ConferenceParticipant { diff --git a/src/views/ConferenceOverlayView.mm b/src/views/ConferenceOverlayView.mm index 6f37ec0c..26858e49 100644 --- a/src/views/ConferenceOverlayView.mm +++ b/src/views/ConferenceOverlayView.mm @@ -48,26 +48,26 @@ CGFloat const controlSize = 40; [self.gradientView.heightAnchor constraintEqualToConstant: controlSize].active = true; [self.gradientView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor].active = true; [self.gradientView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = true; - if ([self.delegate isMasterCall]) { - self.settingsButton = [[IconButton alloc] init]; - self.settingsButton.transparent = true; - self.settingsButton.title = @""; - NSImage* settingsImage = [NSImage imageNamed: @"ic_more.png"]; - [self.settingsButton setImage:settingsImage]; - self.settingsButton.bgColor = [NSColor clearColor]; - self.settingsButton.imageColor = [NSColor whiteColor]; - self.settingsButton.imagePressedColor = [NSColor lightGrayColor]; - self.settingsButton.imageInsets = margin; - self.settingsButton.translatesAutoresizingMaskIntoConstraints = false; - [self.gradientView addSubview:self.settingsButton]; - - [self.settingsButton.widthAnchor constraintEqualToConstant: controlSize].active = TRUE; - [self.settingsButton.heightAnchor constraintEqualToConstant: controlSize].active = true; - [self.settingsButton.trailingAnchor constraintEqualToAnchor: self.gradientView.trailingAnchor].active = true; - [self.settingsButton.bottomAnchor constraintEqualToAnchor:self.gradientView.bottomAnchor].active = true; - [self.settingsButton setAction:@selector(triggerMenu:)]; - [self.settingsButton setTarget:self]; - } + self.settingsButton = [[IconButton alloc] init]; + self.settingsButton.transparent = true; + self.settingsButton.title = @""; + NSImage* settingsImage = [NSImage imageNamed: @"ic_more.png"]; + [self.settingsButton setImage:settingsImage]; + self.settingsButton.bgColor = [NSColor clearColor]; + self.settingsButton.imageColor = [NSColor whiteColor]; + self.settingsButton.imagePressedColor = [NSColor lightGrayColor]; + self.settingsButton.imageInsets = margin; + self.settingsButton.translatesAutoresizingMaskIntoConstraints = false; + [self.gradientView addSubview:self.settingsButton]; + + [self.settingsButton.widthAnchor constraintEqualToConstant: controlSize].active = TRUE; + [self.settingsButton.heightAnchor constraintEqualToConstant: controlSize].active = true; + [self.settingsButton.trailingAnchor constraintEqualToAnchor: self.gradientView.trailingAnchor].active = true; + [self.settingsButton.bottomAnchor constraintEqualToAnchor:self.gradientView.bottomAnchor].active = true; + [self.settingsButton setAction:@selector(triggerMenu:)]; + [self.settingsButton setTarget:self]; + BOOL showSettings = [self.delegate isMasterCall] || [self.delegate isCallModerator]; + [self.settingsButton setHidden: !showSettings]; self.usernameLabel = [[NSTextView alloc] init]; self.usernameLabel.textColor = [NSColor whiteColor]; self.usernameLabel.editable = NO; @@ -87,6 +87,7 @@ CGFloat const controlSize = 40; int layout = [self.delegate getCurrentLayout]; if (layout < 0) return; + BOOL showHangUp = !self.participant.isLocal && [self.delegate isMasterCall]; BOOL showMaximized = layout != 2; BOOL showMinimized = !(layout == 0 || (layout == 1 && !self.participant.active)); contextualMenu = [[NSMenu alloc] initWithTitle:@""]; @@ -100,7 +101,7 @@ CGFloat const controlSize = 40; [menuItem setTarget:self]; [contextualMenu insertItem:menuItem atIndex:contextualMenu.itemArray.count]; } - if (!self.participant.isLocal) { + if (showHangUp) { NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Hangup", @"Conference action") action:@selector(finishCall:) keyEquivalent:@""]; [menuItem setTarget:self]; [contextualMenu insertItem:menuItem atIndex:contextualMenu.itemArray.count]; @@ -179,6 +180,8 @@ CGFloat const controlSize = 40; - (void)updateViewWithParticipant:(ConferenceParticipant) participant { self.participant = participant; + BOOL showSettings = [self.delegate isMasterCall] || [self.delegate isCallModerator]; + [self.settingsButton setHidden: !showSettings]; [self sizeChanged]; self.usernameLabel.string = self.participant.bestName; } -- GitLab