Skip to content
Snippets Groups Projects
Commit ead4ea11 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

conference: enable actions for moderator

Now moderator could minimize/maximize conference participant

Change-Id: Iba23dd170568103bf368d024cbcbc59979e89e90
Gitlab: #253
parent 63d766d1
No related branches found
No related tags found
No related merge requests found
...@@ -1283,19 +1283,20 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -1283,19 +1283,20 @@ CVPixelBufferRef pixelBufferPreview;
if (accountInfo_ == nil) if (accountInfo_ == nil)
return; return;
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (not callModel->hasCall(confUid_)) { auto confId = [self getcallID];
if (not callModel->hasCall(confId)) {
return; return;
} }
try { try {
auto call = callModel->getCall(confUid_); auto call = callModel->getCall(confId);
switch (call.layout) { switch (call.layout) {
case lrc::api::call::Layout::GRID: case lrc::api::call::Layout::GRID:
break; break;
case lrc::api::call::Layout::ONE_WITH_SMALL: 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; break;
case lrc::api::call::Layout::ONE: 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; break;
}; };
} catch (...) {} } catch (...) {}
...@@ -1303,10 +1304,11 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -1303,10 +1304,11 @@ CVPixelBufferRef pixelBufferPreview;
-(int)getCurrentLayout { -(int)getCurrentLayout {
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (not callModel->hasCall(confUid_)){ auto confId = [self getcallID];
if (not callModel->hasCall(confId)){
return -1; return -1;
} }
return static_cast<int>(callModel->getCall(confUid_).layout); return static_cast<int>(callModel->getCall(confId).layout);
} }
-(BOOL)isMasterCall { -(BOOL)isMasterCall {
...@@ -1314,39 +1316,48 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -1314,39 +1316,48 @@ CVPixelBufferRef pixelBufferPreview;
if (conv.uid.isEmpty()) { if (conv.uid.isEmpty()) {
return false; return false;
} }
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (!conv.confId.isEmpty() && callModel->hasCall(conv.confId)) { try {
auto call = callModel->getCall(conv.callId);
if (call.participantsInfos.size() == 0) {
return true; return true;
} else if (!callModel->hasCall(conv.callId)) {
return false;
} }
auto call = callModel->getCall(conv.callId); return !conv.confId.isEmpty() && callModel->hasCall(conv.confId);
return call.participantsInfos.size() == 0; } catch (...) {}
return true;
} }
-(BOOL)isCallModerator {
if (accountInfo_ == nil)
return false;
auto* callModel = accountInfo_->callModel.get();
return callModel->isModerator([self getcallID]);
}
-(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive { -(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive {
if (accountInfo_ == nil) if (accountInfo_ == nil)
return; return;
BOOL localVideo = accountInfo_->profileInfo.uri == QString::fromNSString(uri); BOOL localVideo = accountInfo_->profileInfo.uri == QString::fromNSString(uri);
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (not callModel->hasCall(confUid_) && !localVideo) auto confId = [self getcallID];
if (not callModel->hasCall(confId) && !localVideo)
return; return;
try { try {
auto call = callModel->getCall(confUid_); auto call = callModel->getCall(confId);
switch (call.layout) { switch (call.layout) {
case lrc::api::call::Layout::GRID: case lrc::api::call::Layout::GRID:
callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); callModel->setActiveParticipant(confId, QString::fromNSString(uri));
callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::ONE_WITH_SMALL); callModel->setConferenceLayout(confId, lrc::api::call::Layout::ONE_WITH_SMALL);
break; break;
case lrc::api::call::Layout::ONE_WITH_SMALL: case lrc::api::call::Layout::ONE_WITH_SMALL:
callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); callModel->setActiveParticipant(confId, QString::fromNSString(uri));
callModel->setConferenceLayout(confUid_, callModel->setConferenceLayout(confId,
isActive ? lrc::api::call::Layout::ONE : lrc::api::call::Layout::ONE_WITH_SMALL); isActive ? lrc::api::call::Layout::ONE : lrc::api::call::Layout::ONE_WITH_SMALL);
break; break;
case lrc::api::call::Layout::ONE: case lrc::api::call::Layout::ONE:
callModel->setActiveParticipant(confUid_, QString::fromNSString(uri)); callModel->setActiveParticipant(confId, QString::fromNSString(uri));
callModel->setConferenceLayout(confUid_, lrc::api::call::Layout::GRID); callModel->setConferenceLayout(confId, lrc::api::call::Layout::GRID);
break; break;
}; };
} catch (...) {} } catch (...) {}
......
...@@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive; -(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive;
-(int)getCurrentLayout; -(int)getCurrentLayout;
-(BOOL)isMasterCall; -(BOOL)isMasterCall;
-(BOOL)isCallModerator;
@end @end
struct ConferenceParticipant { struct ConferenceParticipant {
......
...@@ -48,7 +48,6 @@ CGFloat const controlSize = 40; ...@@ -48,7 +48,6 @@ CGFloat const controlSize = 40;
[self.gradientView.heightAnchor constraintEqualToConstant: controlSize].active = true; [self.gradientView.heightAnchor constraintEqualToConstant: controlSize].active = true;
[self.gradientView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor].active = true; [self.gradientView.trailingAnchor constraintEqualToAnchor:self.trailingAnchor].active = true;
[self.gradientView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = true; [self.gradientView.bottomAnchor constraintEqualToAnchor:self.bottomAnchor].active = true;
if ([self.delegate isMasterCall]) {
self.settingsButton = [[IconButton alloc] init]; self.settingsButton = [[IconButton alloc] init];
self.settingsButton.transparent = true; self.settingsButton.transparent = true;
self.settingsButton.title = @""; self.settingsButton.title = @"";
...@@ -67,7 +66,8 @@ CGFloat const controlSize = 40; ...@@ -67,7 +66,8 @@ CGFloat const controlSize = 40;
[self.settingsButton.bottomAnchor constraintEqualToAnchor:self.gradientView.bottomAnchor].active = true; [self.settingsButton.bottomAnchor constraintEqualToAnchor:self.gradientView.bottomAnchor].active = true;
[self.settingsButton setAction:@selector(triggerMenu:)]; [self.settingsButton setAction:@selector(triggerMenu:)];
[self.settingsButton setTarget:self]; [self.settingsButton setTarget:self];
} BOOL showSettings = [self.delegate isMasterCall] || [self.delegate isCallModerator];
[self.settingsButton setHidden: !showSettings];
self.usernameLabel = [[NSTextView alloc] init]; self.usernameLabel = [[NSTextView alloc] init];
self.usernameLabel.textColor = [NSColor whiteColor]; self.usernameLabel.textColor = [NSColor whiteColor];
self.usernameLabel.editable = NO; self.usernameLabel.editable = NO;
...@@ -87,6 +87,7 @@ CGFloat const controlSize = 40; ...@@ -87,6 +87,7 @@ CGFloat const controlSize = 40;
int layout = [self.delegate getCurrentLayout]; int layout = [self.delegate getCurrentLayout];
if (layout < 0) if (layout < 0)
return; return;
BOOL showHangUp = !self.participant.isLocal && [self.delegate isMasterCall];
BOOL showMaximized = layout != 2; BOOL showMaximized = layout != 2;
BOOL showMinimized = !(layout == 0 || (layout == 1 && !self.participant.active)); BOOL showMinimized = !(layout == 0 || (layout == 1 && !self.participant.active));
contextualMenu = [[NSMenu alloc] initWithTitle:@""]; contextualMenu = [[NSMenu alloc] initWithTitle:@""];
...@@ -100,7 +101,7 @@ CGFloat const controlSize = 40; ...@@ -100,7 +101,7 @@ CGFloat const controlSize = 40;
[menuItem setTarget:self]; [menuItem setTarget:self];
[contextualMenu insertItem:menuItem atIndex:contextualMenu.itemArray.count]; [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:@""]; NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Hangup", @"Conference action") action:@selector(finishCall:) keyEquivalent:@""];
[menuItem setTarget:self]; [menuItem setTarget:self];
[contextualMenu insertItem:menuItem atIndex:contextualMenu.itemArray.count]; [contextualMenu insertItem:menuItem atIndex:contextualMenu.itemArray.count];
...@@ -179,6 +180,8 @@ CGFloat const controlSize = 40; ...@@ -179,6 +180,8 @@ CGFloat const controlSize = 40;
- (void)updateViewWithParticipant:(ConferenceParticipant) participant { - (void)updateViewWithParticipant:(ConferenceParticipant) participant {
self.participant = participant; self.participant = participant;
BOOL showSettings = [self.delegate isMasterCall] || [self.delegate isCallModerator];
[self.settingsButton setHidden: !showSettings];
[self sizeChanged]; [self sizeChanged];
self.usernameLabel.string = self.participant.bestName; self.usernameLabel.string = self.participant.bestName;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment