Commit 4db61096 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

call: conference

Change-Id: I728f11a1f7e62e71be8a85e9f05f715708b394af
parent 2aa39237
......@@ -178,6 +178,10 @@ SET(ringclient_CONTROLLERS
src/LeaveMessageVC.h
src/RecordFileVC.mm
src/RecordFileVC.h
src/ChooseContactVC.mm
src/ChooseContactVC.h
src/CallInConferenceVC.mm
src/CallInConferenceVC.h
)
SET(ringclient_VIEWS
......@@ -277,6 +281,8 @@ SET(ringclient_XIBS
AccountSettings
LeaveMessageVC
RecordFileVC
ChooseContactVC
CallInConferenceVC
)
# Icons
......
/*
* Copyright (C) 2019 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#include <string>
namespace lrc {
namespace api {
namespace account {
struct Info;
}
}
}
@protocol CallInConferenceVCDelegate
-(void)removePreviewForContactUri:(std::string)uri forCall:(std::string) callId;
@end
@interface CallInConferenceVC: NSViewController
-(id) initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil
callId:(const std::string)callId
accountInfo:(const lrc::api::account::Info *)accInfo;
@property (retain, nonatomic) id <CallInConferenceVCDelegate> delegate;
@property std::string initiatorCallId;
@end
/*
* Copyright (C) 2019 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "CallInConferenceVC.h"
#import "views/IconButton.h"
#import "NSString+Extensions.h"
///LRC
#import <api/newcallmodel.h>
#import <api/account.h>
#import <api/contactmodel.h>
#import <api/contact.h>
@interface CallInConferenceVC () {
std::string callUId;
const lrc::api::account::Info *accountInfo;
}
@property (unsafe_unretained) IBOutlet NSTextField* contactNameLabel;
@property (unsafe_unretained) IBOutlet NSTextField* callStateLabel;
@property (unsafe_unretained) IBOutlet IconButton* cancelCallButton;
@property QMetaObject::Connection callStateChanged;
@end
@implementation CallInConferenceVC
@synthesize cancelCallButton,callStateLabel,contactNameLabel;
-(id) initWithNibName:(NSString *)nibNameOrNil
bundle:(NSBundle *)nibBundleOrNil
callId:(const std::string)callId
accountInfo:(const lrc::api::account::Info *)accInfo {
if (self = [self initWithNibName: nibNameOrNil bundle:nibBundleOrNil])
{
callUId = callId;
accountInfo = accInfo;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
auto* callModel = accountInfo->callModel.get();
auto currentCall = callModel->getCall(callUId);
auto uri = currentCall.peerUri;
auto contact = accountInfo->contactModel->getContact(uri);
NSString *name = @(contact.profileInfo.alias.c_str());
name = [name removeEmptyLinesAtBorders];
if (name.length == 0) {
name = @(contact.registeredName.c_str());
}
name = [name removeEmptyLinesAtBorders];
if (name.length == 0) {
name = @(contact.profileInfo.uri.c_str());
}
self.contactNameLabel.stringValue = [name removeEmptyLinesAtBorders];
QObject::disconnect(self.callStateChanged);
self.callStateChanged = QObject::connect(callModel,
&lrc::api::NewCallModel::callStatusChanged,
[self](const std::string callId) {
if (callId == callUId) {
[self updateCall];
}
});
}
-(void) updateCall
{
if (accountInfo == nil)
return;
auto* callModel = accountInfo->callModel.get();
if (not callModel->hasCall(callUId)) {
return;
}
auto currentCall = callModel->getCall(callUId);
using Status = lrc::api::call::Status;
callStateLabel.stringValue = @(to_string(currentCall.status).c_str());
switch (currentCall.status) {
case Status::IN_PROGRESS:
case Status::ENDED:
case Status::TERMINATING:
case Status::PEER_BUSY:
case Status::TIMEOUT:
case Status::INVALID: {
QObject::disconnect(self.callStateChanged);
[self.delegate removePreviewForContactUri: currentCall.peerUri forCall: self.initiatorCallId];
break;
}
}
}
- (void)awakeFromNib
{
contactNameLabel.textColor = [NSColor textColor];
callStateLabel.textColor = [NSColor textColor];
}
- (IBAction)hangUp:(id)sender {
if (accountInfo == nil)
return;
auto* callModel = accountInfo->callModel.get();
callModel->hangUp(callUId);
}
@end
/*
* Copyright (C) 2019 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
#include <string>
@protocol ChooseContactVCDelegate <NSObject>
-(void)callToContact:(std::string)contactUri convUID:(std::string)convID;
-(void)joinCall:(std::string)callId;
@end
namespace lrc {
namespace api {
class ConversationModel;
namespace conversation {
struct Info;
}
}
}
@interface ChooseContactVC: NSViewController
@property (retain, nonatomic) id <ChooseContactVCDelegate> delegate;
- (void)setConversationModel:(lrc::api::ConversationModel *)conversationModel
andCurrentConversation:(std::string)conversation;
@end
This diff is collapsed.
......@@ -23,6 +23,9 @@
#import "views/CallView.h"
#import <api/account.h>
#import "ChooseContactVC.h"
#import "CallInConferenceVC.h"
namespace lrc {
namespace api {
class AVModel;
......@@ -32,10 +35,11 @@ namespace lrc {
@protocol CallViewControllerDelegate
-(void) conversationInfoUpdatedFor:(const std::string&) conversationID;
-(void) callFinished;
@end
@interface CurrentCallVC : NSViewController <NSSplitViewDelegate, CallDelegate> {
@interface CurrentCallVC : NSViewController <NSSplitViewDelegate, CallDelegate, ChooseContactVCDelegate, CallInConferenceVCDelegate> {
}
@property (retain, nonatomic) id <CallViewControllerDelegate> delegate;
......
This diff is collapsed.
......@@ -59,6 +59,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
@property (retain) MigrateRingAccountsWC* migrateWC;
@property RingWizardWC* wizard;
@property QMetaObject::Connection callState;
@end
......@@ -229,6 +230,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
account:accInfo
avModel: avModel];
[self changeViewTo:SHOW_CALL_SCREEN];
[conversationVC setConversationUid:convInfo.uid model:accInfo->conversationModel.get()];
});
......@@ -241,13 +243,13 @@ typedef NS_ENUM(NSInteger, ViewState) {
[smartViewVC selectPendingList];
else
[smartViewVC selectConversationList];
[currentCallVC setCurrentCall:convInfo.callId
conversation:convInfo.uid
account:accInfo
avModel: avModel];
[smartViewVC selectConversation: convInfo model:accInfo->conversationModel.get()];
[self changeViewTo:SHOW_CALL_SCREEN];
[conversationVC setConversationUid:convInfo.uid model:accInfo->conversationModel.get()];
});
QObject::connect(self.behaviorController,
......@@ -299,6 +301,25 @@ typedef NS_ENUM(NSInteger, ViewState) {
[shareButton sendActionOn:NSLeftMouseDownMask];
[self connect];
[self updateRingID];
[self connectCallSignalsForAccount];
}
- (void)connectCallSignalsForAccount
{
@try {
auto& account = [chooseAccountVC selectedAccount];
QObject::disconnect(self.callState);
auto *callModel = account.callModel.get();
self.callState = QObject::connect(callModel,
&lrc::api::NewCallModel::callStatusChanged,
[self, callModel](const std::string callId) {
if (callModel->hasCall(callId)) {
auto call = callModel->getCall(callId);
[smartViewVC reloadConversationWithURI: @(call.peerUri.c_str())];
}
});
} @catch (NSException *ex) {
}
}
- (void)migrationDidComplete
......@@ -479,6 +500,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
[self updateRingID];
[settingsVC setSelectedAccount:accInfo.id];
[self changeViewTo: ([settingsVC.view isHidden] || removed) ? SHOW_WELCOME_SCREEN : SHOW_SETTINGS_SCREEN];
[self connectCallSignalsForAccount];
}
-(void)allAccountsDeleted
......@@ -489,6 +511,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
qrcodeView.animator.alphaValue = 0.0;
[centerYQRCodeConstraint.animator setConstant: 0];
[centerYWelcomeContainerConstraint.animator setConstant: 0];
QObject::disconnect(self.callState);
[self close];
AppDelegate* delegate = (AppDelegate*)[[NSApplication sharedApplication] delegate];
[delegate showWizard];
......@@ -541,6 +564,10 @@ typedef NS_ENUM(NSInteger, ViewState) {
[smartViewVC reloadConversationWithUid:@(conversationID.c_str())];
}
-(void) callFinished {
[self changeViewTo:SHOW_CONVERSATION_SCREEN];
}
-(void) showConversation:(NSString* )conversationId forAccount:(NSString*)accountId {
auto& accInfo = self.accountModel->getAccountInfo([accountId UTF8String]);
[chooseAccountVC selectAccount: accountId];
......
......@@ -66,5 +66,6 @@ namespace lrc {
-(void) clearConversationModel;
-(void) reloadConversationWithUid:(NSString *)uid;
-(void) reloadConversationWithURI:(NSString *)uri;
@end
......@@ -207,6 +207,14 @@ NSInteger const REQUEST_SEG = 1;
}
}
-(void) reloadConversationWithURI:(NSString *)uri
{
if (convModel_ == nil) {
return;
}
[smartView reloadData];
}
- (BOOL)setConversationModel:(lrc::api::ConversationModel *)conversationModel
{
if (convModel_ == conversationModel) {
......@@ -487,6 +495,20 @@ NSInteger const REQUEST_SEG = 1;
[interactionSnippet setHidden:false];
auto lastUid = conversation.lastMessageUid;
auto callId = conversation.confId.empty() ? conversation.callId : conversation.confId;
NSString *callInfo = @"";
if (!callId.empty()) {
if ([self chosenAccount].callModel.get()->hasCall(callId)) {
auto call = [self chosenAccount].callModel.get()->getCall(callId);
callInfo = (call.status == lrc::api::call::Status::IN_PROGRESS) ? @"Talking" : @(to_string(call.status).c_str());
}
}
if (callInfo.length > 0) {
[lastInteractionDate setStringValue: callInfo];
[interactionSnippet setHidden:true];
return result;
}
if (conversation.interactions.find(lastUid) != conversation.interactions.end()) {
// last interaction snippet
std::string lastInteractionSnippet = conversation.interactions[lastUid].body;
......
......@@ -51,6 +51,4 @@
*/
@property (nonatomic) id <CallDelegate> callDelegate;
@property std::string callId;
@end
......@@ -56,6 +56,8 @@
@property BOOL highlightable;
- (void) drawSelection: (BOOL) isSelected;
-(void)setBlurType:(int)type;
@end
// Used by the HoverTableRowView and the RingTableView
......
......@@ -91,6 +91,10 @@
[self.effect_view setMaterial: static_cast<NSVisualEffectMaterial>(6)];
}
-(void)setBlurType:(int)type {
[self.effect_view setMaterial: static_cast<NSVisualEffectMaterial>(type)];
}
- (void)setMouseInside:(BOOL)value {
if (mouseInside != value) {
mouseInside = value;
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CallInConferenceVC">
<connections>
<outlet property="callStateLabel" destination="beR-Kp-sIl" id="8CN-UX-lj3"/>
<outlet property="cancelCallButton" destination="QST-BA-uVx" id="rIn-Pp-lcq"/>
<outlet property="contactNameLabel" destination="vOY-7r-Xx0" id="XDc-8Y-Zxe"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="170" height="102"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<box boxType="custom" borderWidth="0.0" cornerRadius="5" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="XkB-R1-Jz7">
<rect key="frame" x="0.0" y="0.0" width="170" height="102"/>
<view key="contentView" id="DVn-uM-94p">
<rect key="frame" x="0.0" y="0.0" width="170" height="102"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
<color key="fillColor" red="0.99999600649999998" green="1" blue="1" alpha="0.35846532534246578" colorSpace="custom" customColorSpace="sRGB"/>
</box>
<stackView distribution="fill" orientation="vertical" alignment="centerX" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NJR-wA-MJL">
<rect key="frame" x="0.0" y="0.0" width="170" height="102"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="l1c-Lf-7R2">
<rect key="frame" x="85" y="101" width="1" height="1"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="VzI-Tn-FIB"/>
<constraint firstAttribute="height" constant="1" id="vxm-nR-dxO"/>
</constraints>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="beR-Kp-sIl">
<rect key="frame" x="55" y="77" width="61" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Searching" id="ZOf-xw-eee">
<font key="font" metaFont="systemThin" size="12"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vOY-7r-Xx0">
<rect key="frame" x="58" y="52" width="54" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" usesSingleLineMode="YES" id="pXv-4x-nAB">
<font key="font" metaFont="systemLight" size="13"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button toolTip="Hang up" horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QST-BA-uVx" userLabel="Hang Up" customClass="IconButton">
<rect key="frame" x="68" y="9" width="35" height="35"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="73s-Cs-nb8"/>
<constraint firstAttribute="height" constant="35" id="Tig-gB-Tyg"/>
</constraints>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" image="ic_action_cancel" imagePosition="overlaps" alignment="center" transparent="YES" imageScaling="proportionallyDown" id="CWe-O0-PXI">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="bgColor">
<color key="value" red="0.94509803920000002" green="0.16078431369999999" blue="0.0" alpha="0.83999999999999997" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
<userDefinedRuntimeAttribute type="number" keyPath="imageInsets">
<integer key="value" value="6"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="hangUp:" target="-2" id="xfb-x5-yjW"/>
</connections>
</button>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="AEC-dd-E6M">
<rect key="frame" x="85" y="0.0" width="1" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="HGw-F6-bWa"/>
<constraint firstAttribute="width" constant="1" id="bL7-ZC-cUE"/>
</constraints>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="170" id="06r-s6-HAH"/>
</constraints>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="XkB-R1-Jz7" secondAttribute="bottom" id="984-Rd-008"/>
<constraint firstItem="NJR-wA-MJL" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="C2D-nn-ozv"/>
<constraint firstAttribute="trailing" secondItem="XkB-R1-Jz7" secondAttribute="trailing" id="CRy-6g-USo"/>
<constraint firstItem="NJR-wA-MJL" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="LlO-bV-oO9"/>
<constraint firstAttribute="bottom" secondItem="NJR-wA-MJL" secondAttribute="bottom" id="PiE-dx-miY"/>
<constraint firstItem="XkB-R1-Jz7" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="SXT-9n-Ux2"/>
<constraint firstItem="XkB-R1-Jz7" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="kKi-JP-GhK"/>
<constraint firstAttribute="trailing" secondItem="NJR-wA-MJL" secondAttribute="trailing" id="uKU-u0-DGc"/>
</constraints>
</customView>
</objects>
<resources>
<image name="ic_action_cancel" width="72" height="72"/>
</resources>
</document>
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment