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;
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 (...) {}
......
......@@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
-(void)maximizeParticipant:(NSString*)uri active:(BOOL)isActive;
-(int)getCurrentLayout;
-(BOOL)isMasterCall;
-(BOOL)isCallModerator;
@end
struct ConferenceParticipant {
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment