Commit 994971f1 authored by Olivier Soldano's avatar Olivier Soldano Committed by Kateryna Kostiuk

reimplement CurrentCallVC with new call model

This patch reimplements CurrentCallVC using the call model introduced
recently in LRC.

As of this patch, some minor features are missing such as conversation
time or contact picture display when receiving or starting a call.
Call panel may also appear and disappear many times during connection
establishment. All of that is meant to be fixed very soon and doesn't
prevent starting or receiving a call.

Change-Id: Ie51f75ffc267e955679a4cc75663f92e03c36eef
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent d431155b
......@@ -22,6 +22,10 @@
#import "views/CallView.h"
// LRC
#import <api/account.h>
#import <api/call.h>
class Call;
@interface CurrentCallVC : NSViewController <NSSplitViewDelegate, CallDelegate> {
......@@ -31,5 +35,7 @@ class Call;
-(void) initFrame;
-(void) animateIn;
-(void) animateOut;
-(void) setCurrentCall:(const std::string&)callUid
conversation:(const std::string&)convUid
account:(const lrc::api::account::Info*)account;
@end
This diff is collapsed.
......@@ -26,7 +26,6 @@
#import <QItemSelection>
//LRC
#import <accountmodel.h>
#import <callmodel.h>
#import <account.h>
#import <call.h>
......@@ -34,6 +33,11 @@
#import <AvailableAccountModel.h>
#import <api/lrc.h>
#import <api/account.h>
#import <api/newaccountmodel.h>
#import <api/newcallmodel.h>
#import <api/behaviorcontroller.h>
#import <api/conversation.h>
// Ring
#import "AppDelegate.h"
......@@ -109,6 +113,7 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
// Fresh run, we need to make sure RingID appears
[shareButton sendActionOn:NSLeftMouseDownMask];
[self connect];
[self updateRingID];
// display accounts to select
NSToolbar *toolbar = self.window.toolbar;
......@@ -117,55 +122,29 @@ NSString* const kTrustRequestMenuItemIdentifier = @"TrustRequestMenuItemIde
[toolbar insertItemWithItemIdentifier:kTrustRequestMenuItemIdentifier atIndex:2];
}
// TODO: Reimplement with new LRC signals
- (void) connect
{
// Update Ring ID label based on account model changes
QObject::connect(RecentModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
auto call = RecentModel::instance().getActiveCall(current);
if(!current.isValid()) {
[offlineVC animateOut];
[currentCallVC animateOut];
[chooseAccountVC enable];
return;
}
if (!call) {
[currentCallVC animateOut];
[offlineVC animateIn];
[chooseAccountVC enable];
} else {
[currentCallVC animateIn];
[offlineVC animateOut];
[chooseAccountVC disable];
}
QObject::connect(&lrc_->getBehaviorController(),
&lrc::api::BehaviorController::showCallView,
[self](const std::string accountId,
const lrc::api::conversation::Info convInfo){
auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
[currentCallVC setCurrentCall:convInfo.callId
conversation:convInfo.uid
account:accInfo];
[currentCallVC animateIn];
[offlineVC animateOut];
});
QObject::connect(CallModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid()) {
return;
}
if (previous.isValid()) {
// We were already on a call
[currentCallVC animateOut];
[chooseAccountVC enable];
} else {
// Make sure Conversation view hides when selecting a valid call
[currentCallVC animateIn];
[offlineVC animateOut];
[chooseAccountVC disable];
}
});
QObject::connect(AvailableAccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[self](const QModelIndex& idx){
[self updateRingID];
QObject::connect(&lrc_->getBehaviorController(),
&lrc::api::BehaviorController::showIncomingCallView,
[self](const std::string accountId,
const lrc::api::conversation::Info convInfo){
auto* accInfo = &lrc_->getAccountModel().getAccountInfo(accountId);
[currentCallVC setCurrentCall:convInfo.callId
conversation:convInfo.uid
account:accInfo];
[currentCallVC animateIn];
[offlineVC animateOut];
});
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D30a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="CurrentCallVC">
......@@ -56,7 +56,7 @@
<customView translatesAutoresizingMaskIntoConstraints="NO" id="d0X-cW-Xgz">
<rect key="frame" x="20" y="438" width="705" height="71"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="cIU-M7-xpN">
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cIU-M7-xpN">
<rect key="frame" x="583" y="23" width="104" height="24"/>
<constraints>
<constraint firstAttribute="width" constant="100" id="9vz-kb-6L6"/>
......@@ -70,7 +70,7 @@
<userDefinedRuntimeAttribute type="string" keyPath="layer.cornerRadius" value="15"/>
</userDefinedRuntimeAttributes>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="bg3-hB-nE8">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bg3-hB-nE8">
<rect key="frame" x="76" y="14" width="85" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="81" id="gT7-Wu-XtU"/>
......@@ -117,7 +117,7 @@
<action selector="addToContact:" target="-2" id="OI1-7U-4T7"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kFD-FB-vig">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kFD-FB-vig">
<rect key="frame" x="76" y="39" width="36" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="29" id="pft-oc-ZNh"/>
......@@ -492,7 +492,7 @@
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="se7-PJ-iwD">
<rect key="frame" x="545" y="223" width="110" height="112"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Aav-3e-AnU">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Aav-3e-AnU">
<rect key="frame" x="32" y="7" width="46" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Cancel" id="TlL-HO-5Ey">
<font key="font" metaFont="system"/>
......@@ -535,7 +535,7 @@
<customView misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="W4l-Be-bhM">
<rect key="frame" x="135" y="148" width="404" height="291"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9Cd-Vs-wtu">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9Cd-Vs-wtu">
<rect key="frame" x="234" y="18" width="43" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="39" id="6I1-DY-t1P"/>
......@@ -546,7 +546,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="neP-Vf-7Tp">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="neP-Vf-7Tp">
<rect key="frame" x="126" y="18" width="49" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="45" id="NB4-kw-0Lb"/>
......@@ -557,7 +557,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="qnn-D2-O1C">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qnn-D2-O1C">
<rect key="frame" x="139" y="121" width="127" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="123" id="hbP-yf-u6W"/>
......@@ -576,7 +576,7 @@
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSUser" id="BgV-yI-0CU"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="V2C-DZ-Ygi">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="V2C-DZ-Ygi">
<rect key="frame" x="127" y="146" width="150" height="17"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="33" id="4iv-3m-Ldv"/>
......@@ -689,7 +689,7 @@
<color key="backgroundColor" white="1" alpha="0.0" colorSpace="deviceWhite"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="369" minWidth="40" maxWidth="1000" id="nFu-qN-GHK">
<tableColumn identifier="" width="369" minWidth="40" maxWidth="1000" id="nFu-qN-GHK">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
......@@ -814,7 +814,7 @@
<binding destination="LWe-df-dS6" name="enabled" keyPath="self.message.length" id="ec2-s1-Hpt"/>
</connections>
</button>
<textField wantsLayer="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OBX-o0-u1k">
<textField wantsLayer="YES" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OBX-o0-u1k">
<rect key="frame" x="20" y="20" width="286" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" bezelStyle="round" id="QW9-Ty-ZEe">
<font key="font" metaFont="system"/>
......@@ -896,7 +896,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSUser" id="A33-8N-kr9"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lT0-mL-HHV">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lT0-mL-HHV">
<rect key="frame" x="323" y="240" width="27" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URI" id="Dqv-um-UUk">
......@@ -905,7 +905,7 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZYE-KE-soE">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ZYE-KE-soE">
<rect key="frame" x="276" y="189" width="143" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="wants to talk with you!" id="yZ6-1A-ZLT">
......
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