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

conference: update when one of the call finished

Change-Id: I1884bbe96c8327045c47abd903f422131601afb6
parent 23ed02ec
No related branches found
No related tags found
No related merge requests found
...@@ -162,8 +162,11 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -162,8 +162,11 @@ CVPixelBufferRef pixelBufferPreview;
callUid_ = callUid; callUid_ = callUid;
convUid_ = convUid; convUid_ = convUid;
accountInfo_ = account; accountInfo_ = account;
auto convIt = getConversationFromUid(convUid_, *accountInfo_->conversationModel); auto conv = accountInfo_->conversationModel->getConversationForUID(convUid_);
confUid_ = convIt->confId; if (conv.uid.isEmpty()) {
return;
}
confUid_ = conv.confId;
[self.chatVC setConversationUid:convUid model:account->conversationModel.get()]; [self.chatVC setConversationUid:convUid model:account->conversationModel.get()];
[self connectSignals]; [self connectSignals];
} }
...@@ -190,17 +193,14 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -190,17 +193,14 @@ CVPixelBufferRef pixelBufferPreview;
} }
} }
-(void)switchToNextConferenceCall { -(void)switchToNextConferenceCall:(QString)confId {
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (!callModel->hasCall(confUid_)) {
return;
}
AppDelegate* appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate]; AppDelegate* appDelegate = (AppDelegate *)[[NSApplication sharedApplication] delegate];
auto activeCalls = [appDelegate getActiveCalls]; auto activeCalls = [appDelegate getActiveCalls];
if (activeCalls.isEmpty()) { if (activeCalls.isEmpty()) {
return; return;
} }
auto subcalls = [appDelegate getConferenceSubcalls: confUid_]; auto subcalls = [appDelegate getConferenceSubcalls: confId];
QString callId; QString callId;
if (subcalls.isEmpty()) { if (subcalls.isEmpty()) {
for(auto subcall: activeCalls) { for(auto subcall: activeCalls) {
...@@ -271,15 +271,11 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -271,15 +271,11 @@ CVPixelBufferRef pixelBufferPreview;
QObject::connect(accountInfo_->contactModel.get(), QObject::connect(accountInfo_->contactModel.get(),
&lrc::api::ContactModel::contactAdded, &lrc::api::ContactModel::contactAdded,
[self](const QString &contactUri) { [self](const QString &contactUri) {
auto convIt = getConversationFromUid(convUid_, *accountInfo_->conversationModel.get()); auto conv = accountInfo_->conversationModel->getConversationForUID(convUid_);
if (convIt == accountInfo_->conversationModel->allFilteredConversations().end()) { if (conv.uid.isEmpty() || conv.participants.empty()) {
return; return;
} }
if (convIt->participants.empty()) { auto& contact = accountInfo_->contactModel->getContact(conv.participants[0]);
return;
}
auto& contact = accountInfo_->contactModel->getContact(convIt->participants[0]);
if (contact.profileInfo.type == lrc::api::profile::Type::RING && contact.profileInfo.uri == contactUri) if (contact.profileInfo.type == lrc::api::profile::Type::RING && contact.profileInfo.uri == contactUri)
accountInfo_->conversationModel->makePermanent(convUid_); accountInfo_->conversationModel->makePermanent(convUid_);
[contactPhoto setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]]; [contactPhoto setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]];
...@@ -448,18 +444,18 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -448,18 +444,18 @@ CVPixelBufferRef pixelBufferPreview;
} }
auto currentCall = callModel->getCall(callUid_); auto currentCall = callModel->getCall(callUid_);
auto convIt = getConversationFromUid(convUid_, *accountInfo_->conversationModel); auto convIt = accountInfo_->conversationModel->getConversationForUID(convUid_);
if (conversationExists(convIt, *accountInfo_->conversationModel)) { if (!convIt.uid.isEmpty()) {
NSString* bestName = bestNameForConversation(*convIt, *accountInfo_->conversationModel); NSString* bestName = bestNameForConversation(convIt, *accountInfo_->conversationModel);
[contactNameLabel setStringValue:bestName]; [contactNameLabel setStringValue:bestName];
NSString* ringID = bestIDForConversation(*convIt, *accountInfo_->conversationModel); NSString* ringID = bestIDForConversation(convIt, *accountInfo_->conversationModel);
if([bestName isEqualToString:ringID]) { if([bestName isEqualToString:ringID]) {
ringID = @""; ringID = @"";
} }
[contactIdLabel setStringValue:ringID]; [contactIdLabel setStringValue:ringID];
} }
[self setupContactInfo:contactPhoto]; [self setupContactInfo:contactPhoto];
confUid_ = convIt->confId; confUid_ = convIt.confId;
[muteAudioButton setHidden:!confUid_.isEmpty()]; [muteAudioButton setHidden:!confUid_.isEmpty()];
[muteVideoButton setHidden:!confUid_.isEmpty()]; [muteVideoButton setHidden:!confUid_.isEmpty()];
[recordOnOffButton setHidden:!confUid_.isEmpty()]; [recordOnOffButton setHidden:!confUid_.isEmpty()];
...@@ -563,7 +559,7 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -563,7 +559,7 @@ CVPixelBufferRef pixelBufferPreview;
connectingCalls[callUid_.toNSString()] = nil; connectingCalls[callUid_.toNSString()] = nil;
[self removeConferenceLayout ]; [self removeConferenceLayout ];
[self.delegate callFinished]; [self.delegate callFinished];
[self switchToNextConferenceCall]; [self switchToNextConferenceCall: confUid_];
break; break;
} }
} }
...@@ -621,16 +617,16 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -621,16 +617,16 @@ CVPixelBufferRef pixelBufferPreview;
-(NSImage *) getContactImageOfSize: (double) size withDefaultAvatar:(BOOL) shouldDrawDefault { -(NSImage *) getContactImageOfSize: (double) size withDefaultAvatar:(BOOL) shouldDrawDefault {
auto* convModel = accountInfo_->conversationModel.get(); auto* convModel = accountInfo_->conversationModel.get();
auto convIt = getConversationFromUid(convUid_, *convModel); auto conv = accountInfo_->conversationModel->getConversationForUID(convUid_);
if (convIt == convModel->allFilteredConversations().end()) { if (conv.uid.isEmpty() || conv.participants.empty()) {
return nil; return nil;
} }
if(shouldDrawDefault) { if(shouldDrawDefault) {
auto& imgManip = reinterpret_cast<Interfaces::ImageManipulationDelegate&>(GlobalInstances::pixmapManipulator()); auto& imgManip = reinterpret_cast<Interfaces::ImageManipulationDelegate&>(GlobalInstances::pixmapManipulator());
QVariant photo = imgManip.conversationPhoto(*convIt, *accountInfo_, QSize(size, size), NO); QVariant photo = imgManip.conversationPhoto(conv, *accountInfo_, QSize(size, size), NO);
return QtMac::toNSImage(qvariant_cast<QPixmap>(photo)); return QtMac::toNSImage(qvariant_cast<QPixmap>(photo));
} }
auto contact = accountInfo_->contactModel->getContact(convIt->participants[0]); auto contact = accountInfo_->contactModel->getContact(conv.participants[0]);
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:contact.profileInfo.avatar.toNSString() options:NSDataBase64DecodingIgnoreUnknownCharacters]; NSData *imageData = [[NSData alloc] initWithBase64EncodedString:contact.profileInfo.avatar.toNSString() options:NSDataBase64DecodingIgnoreUnknownCharacters];
return [[NSImage alloc] initWithData:imageData]; return [[NSImage alloc] initWithData:imageData];
} }
...@@ -949,15 +945,16 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -949,15 +945,16 @@ CVPixelBufferRef pixelBufferPreview;
return; return;
// If we accept a conversation with a non trusted contact, we first accept it // If we accept a conversation with a non trusted contact, we first accept it
auto convIt = getConversationFromUid(convUid_, *accountInfo_->conversationModel.get()); auto conv = accountInfo_->conversationModel->getConversationForUID(convUid_);
if (convIt != accountInfo_->conversationModel->allFilteredConversations().end()) { if (conv.uid.isEmpty() || conv.participants.empty()) {
auto& contact = accountInfo_->contactModel->getContact(convIt->participants[0]); return;
if (contact.profileInfo.type == lrc::api::profile::Type::PENDING) }
auto& contact = accountInfo_->contactModel->getContact(conv.participants[0]);
if (contact.profileInfo.type == lrc::api::profile::Type::PENDING) {
accountInfo_->conversationModel->makePermanent(convUid_); accountInfo_->conversationModel->makePermanent(convUid_);
} }
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
callModel->accept(callUid_); callModel->accept(callUid_);
} }
...@@ -1311,15 +1308,16 @@ CVPixelBufferRef pixelBufferPreview; ...@@ -1311,15 +1308,16 @@ CVPixelBufferRef pixelBufferPreview;
} }
-(BOOL)isMasterCall { -(BOOL)isMasterCall {
auto convIt = getConversationFromUid(convUid_, *accountInfo_->conversationModel); auto conv = accountInfo_->conversationModel->getConversationForUID(convUid_);
if (convIt->uid.isEmpty()) { if (conv.uid.isEmpty()) {
return true; return false;
} }
auto* callModel = accountInfo_->callModel.get(); auto* callModel = accountInfo_->callModel.get();
if (!convIt->confId.isEmpty() && callModel->hasCall(convIt->confId)) { if (!conv.confId.isEmpty() && callModel->hasCall(conv.confId)) {
return true; return true;
} else { } else {
auto call = callModel->getCall(convIt->callId); auto call = callModel->getCall(conv.callId);
return call.participantsInfos.size() == 0; return call.participantsInfos.size() == 0;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment