Commit 883719f5 authored by Alexandre Lision's avatar Alexandre Lision Committed by Stepan Salenikovich

call: add transfer ability

This commit adds attended/unattended transfer capability
It also improves call controls visibility

Tuleap: #56
Change-Id: I66c2bc22f015f12dc58cf98768b8b3c689e6fdcb
parent 61db3557
......@@ -111,7 +111,9 @@ SET(ringclient_CONTROLLERS
src/PersonLinkerVC.mm
src/PersonLinkerVC.h
src/SmartViewVC.mm
src/SmartViewVC.h)
src/SmartViewVC.h
src/BrokerVC.mm
src/BrokerVC.h)
SET(ringclient_BACKENDS
src/backends/AddressBookBackend.mm
......@@ -160,7 +162,8 @@ SET(ringclient_XIBS
PreferencesWindow
RingWizard
CertificateWindow
PersonLinker)
PersonLinker
Broker)
# Icons
# This part tells CMake where to find and install the file itself
......@@ -186,6 +189,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_record.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_received.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_missed.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_made.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_transfer.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ancrage.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_person_add.png
......
/*
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@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>
@interface BrokerVC : NSViewController
enum class BrokerMode {
TRANSFER = 0,
//CONFERENCE
};
- (instancetype)initWithMode:(BrokerMode) m;
@end
/*
* Copyright (C) 2015 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@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 "BrokerVC.h"
#import <QSortFilterProxyModel>
#import <QItemSelectionModel>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
//LRC
#import <recentmodel.h>
#import <callmodel.h>
#import <call.h>
#import <person.h>
#import <globalinstances.h>
#import <contactmethod.h>
#import <phonedirectorymodel.h>
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
// Display all items from peopleproxy() except current call
class NotCurrentItemModel : public QSortFilterProxyModel
{
public:
NotCurrentItemModel(QSortFilterProxyModel* parent) : QSortFilterProxyModel(parent)
{
setSourceModel(parent);
}
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
auto originIdx = ((QSortFilterProxyModel*)sourceModel())->mapToSource(sourceModel()->index(source_row,0,source_parent));
auto c = RecentModel::instance().getActiveCall(originIdx);
return (!c || (c && (c->state() != Call::State::CURRENT))) &&
QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
};
@interface BrokerVC ()
@property BrokerMode mode;
@property (unsafe_unretained) IBOutlet NSOutlineView *smartView;
@property (strong) QNSTreeController *treeController;
@property QSortFilterProxyModel* recentFilterModel;
@end
@implementation BrokerVC
// Tags for views
NSInteger const IMAGE_TAG = 100;
NSInteger const DISPLAYNAME_TAG = 200;
NSInteger const DETAILS_TAG = 300;
NSInteger const CALL_BUTTON_TAG = 400;
NSInteger const TXT_BUTTON_TAG = 500;
- (instancetype)initWithMode:(BrokerMode)m {
self = [super init];
if (self) {
[self setMode:m];
}
return self;
}
- (NSString *)nibName
{
return @"Broker";
}
- (void)dealloc
{
delete _recentFilterModel;
}
- (void)loadView
{
[super loadView];
_recentFilterModel = new NotCurrentItemModel(RecentModel::instance().peopleProxy());
_treeController = [[QNSTreeController alloc] initWithQModel:_recentFilterModel];
[_treeController setAvoidsEmptySelection:NO];
[_treeController setChildrenKeyPath:@"children"];
[_smartView bind:@"content" toObject:_treeController withKeyPath:@"arrangedObjects" options:nil];
[_smartView bind:@"sortDescriptors" toObject:_treeController withKeyPath:@"sortDescriptors" options:nil];
[_smartView bind:@"selectionIndexPaths" toObject:_treeController withKeyPath:@"selectionIndexPaths" options:nil];
[_smartView setTarget:self];
[_smartView setDoubleAction:@selector(placeTransfer:)];
}
// -------------------------------------------------------------------------------
// transfer on click on Person or ContactMethod
// -------------------------------------------------------------------------------
- (void)placeTransfer:(id)sender
{
auto current = CallModel::instance().selectedCall();
if (!current || [_treeController selectedNodes].count == 0)
return;
QModelIndex qIdx = [_treeController toQIdx:[_treeController selectedNodes][0]];
auto originIdx = RecentModel::instance().peopleProxy()->mapToSource(_recentFilterModel->mapToSource(qIdx));
auto transfer = RecentModel::instance().getActiveCall(originIdx);
if (transfer) { //realise an attended transfer between the two calls
CallModel::instance().attendedTransfer(current, transfer);
return;
}
ContactMethod* m = nil;
auto contactmethods = RecentModel::instance().getContactMethods(originIdx);
if (contactmethods.size() > 0) { // Before calling check if we properly extracted at least one contact method
m = contactmethods.first();
CallModel::instance().transfer(current, m);
}
}
// -------------------------------------------------------------------------------
// transfer to unknown URI
// -------------------------------------------------------------------------------
- (void) transferTo:(NSString*) uri
{
auto current = CallModel::instance().selectedCall();
if (!current)
return;
auto number = PhoneDirectoryModel::instance().getNumber(QString::fromNSString(uri));
CallModel::instance().transfer(current, number);
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
// shouldSelectItem:item
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
return YES;
}
// -------------------------------------------------------------------------------
// shouldEditTableColumn:tableColumn:item
//
// Decide to allow the edit of the given outline view "item".
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
return NO;
}
// -------------------------------------------------------------------------------
// View Based OutlineView: See the delegate method -tableView:viewForTableColumn:row: in NSTableView.
// -------------------------------------------------------------------------------
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
auto qIdx = [_treeController toQIdx:((NSTreeNode*)item)];
NSTableCellView *result;
if (!qIdx.parent().isValid()) {
result = [outlineView makeViewWithIdentifier:@"MainCell" owner:outlineView];
} else {
result = [outlineView makeViewWithIdentifier:@"CallCell" owner:outlineView];
}
auto finalIdx = RecentModel::instance().peopleProxy()->mapToSource(_recentFilterModel->mapToSource(qIdx));
NSTextField* details = [result viewWithTag:DETAILS_TAG];
if (auto call = RecentModel::instance().getActiveCall(finalIdx)) {
[details setStringValue:call->roleData((int)Ring::Role::FormattedState).toString().toNSString()];
} else {
[details setStringValue:qIdx.data((int)Ring::Role::FormattedLastUsed).toString().toNSString()];
}
NSTextField* displayName = [result viewWithTag:DISPLAYNAME_TAG];
[displayName setStringValue:qIdx.data(Qt::DisplayRole).toString().toNSString()];
NSImageView* photoView = [result viewWithTag:IMAGE_TAG];
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(p, QSize(40,40));
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
return result;
}
// -------------------------------------------------------------------------------
// View Based OutlineView: See the delegate method -tableView:rowViewForRow: in NSTableView.
// -------------------------------------------------------------------------------
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
return [outlineView makeViewWithIdentifier:@"HoverRowView" owner:nil];
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
QModelIndex qIdx = [_treeController toQIdx:((NSTreeNode*)item)];
return (((NSTreeNode*)item).indexPath.length == 1) ? 60.0 : 45.0;
}
#pragma mark - NSTextFieldDelegate
- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector
{
if (commandSelector == @selector(insertNewline:)) {
if([fieldEditor.textStorage.string isNotEqualTo:@""]) {
[self transferTo:fieldEditor.textStorage.string];
return YES;
}
}
return NO;
}
- (void)controlTextDidChange:(NSNotification *) notification
{
NSTextView *textView = notification.userInfo[@"NSFieldEditor"];
_recentFilterModel->setFilterRegExp(QRegExp(QString::fromNSString(textView.textStorage.string), Qt::CaseInsensitive, QRegExp::FixedString));
[_smartView scrollToBeginningOfDocument:nil];
}
@end
......@@ -36,6 +36,7 @@
#import "views/CallView.h"
#import "PersonLinkerVC.h"
#import "ChatVC.h"
#import "BrokerVC.h"
@interface RendererConnectionsHolder : NSObject
......@@ -51,28 +52,30 @@
@interface CurrentCallVC () <NSPopoverDelegate, ContactLinkedDelegate>
@property (unsafe_unretained) IBOutlet NSTextField *personLabel;
@property (unsafe_unretained) IBOutlet NSTextField *stateLabel;
@property (unsafe_unretained) IBOutlet NSButton *holdOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton *hangUpButton;
@property (unsafe_unretained) IBOutlet NSButton *recordOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton *pickUpButton;
@property (unsafe_unretained) IBOutlet NSButton *muteAudioButton;
@property (unsafe_unretained) IBOutlet NSButton *muteVideoButton;
@property (unsafe_unretained) IBOutlet NSButton *addContactButton;
@property (unsafe_unretained) IBOutlet NSView *headerContainer;
@property (unsafe_unretained) IBOutlet NSButton *qualityButton;
@property (unsafe_unretained) IBOutlet NSTextField* personLabel;
@property (unsafe_unretained) IBOutlet NSTextField* stateLabel;
@property (unsafe_unretained) IBOutlet NSButton* holdOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton* hangUpButton;
@property (unsafe_unretained) IBOutlet NSButton* recordOnOffButton;
@property (unsafe_unretained) IBOutlet NSButton* pickUpButton;
@property (unsafe_unretained) IBOutlet NSButton* muteAudioButton;
@property (unsafe_unretained) IBOutlet NSButton* muteVideoButton;
@property (unsafe_unretained) IBOutlet NSButton* addContactButton;
@property (unsafe_unretained) IBOutlet NSButton* qualityButton;
@property (unsafe_unretained) IBOutlet NSButton* transferButton;
@property (unsafe_unretained) IBOutlet NSView* headerContainer;
@property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator;
@property (unsafe_unretained) IBOutlet NSTextField *timeSpentLabel;
@property (unsafe_unretained) IBOutlet NSView *controlsPanel;
@property (unsafe_unretained) IBOutlet NSSplitView *splitView;
@property (unsafe_unretained) IBOutlet NSButton *chatButton;
@property (unsafe_unretained) IBOutlet NSTextField* timeSpentLabel;
@property (unsafe_unretained) IBOutlet NSView* controlsPanel;
@property (unsafe_unretained) IBOutlet NSSplitView* splitView;
@property (unsafe_unretained) IBOutlet NSButton* chatButton;
@property (strong) IBOutlet NSPopover *qualityPopOver;
@property (strong) IBOutlet NSPopover* qualityPopOver;
@property (strong) NSPopover* addToContactPopover;
@property (strong) IBOutlet ChatVC *chatVC;
@property (strong) NSPopover* transferPopoverVC;
@property (strong) IBOutlet ChatVC* chatVC;
@property QHash<int, NSButton*> actionHash;
......@@ -92,8 +95,9 @@
@implementation CurrentCallVC
@synthesize personLabel, actionHash, stateLabel, holdOnOffButton, hangUpButton,
recordOnOffButton, pickUpButton, chatButton, timeSpentLabel,
muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView, videoLayer, previewLayer, previewView, splitView, loadingIndicator;
recordOnOffButton, pickUpButton, chatButton, transferButton, timeSpentLabel,
muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView,
videoLayer, previewLayer, previewView, splitView, loadingIndicator;
@synthesize previewHolder;
@synthesize videoHolder;
......@@ -188,6 +192,7 @@
actionHash[ (int)UserActionModel::Action::HANGUP] = hangUpButton;
actionHash[ (int)UserActionModel::Action::MUTE_AUDIO] = muteAudioButton;
actionHash[ (int)UserActionModel::Action::MUTE_VIDEO] = muteVideoButton;
actionHash[ (int)UserActionModel::Action::SERVER_TRANSFER] = transferButton;
videoLayer = [CALayer layer];
[videoView setWantsLayer:YES];
......@@ -456,6 +461,12 @@
QObject::disconnect(previewHolder.started);
[videoView.layer setContents:nil];
[previewView.layer setContents:nil];
[self.transferPopoverVC performClose:self];
[self.addToContactPopover performClose:self];
[self.qualityPopOver performClose:self];
[self.chatButton setState:NSOffState];
[self collapseRightView];
}
-(void) animateOut
......@@ -538,8 +549,6 @@
if (self.addToContactPopover != nullptr) {
[self.addToContactPopover performClose:self];
self.addToContactPopover = NULL;
[self.addContactButton setState:NSOffState];
} else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
[editorVC setMethodToLink:contactmethod];
......@@ -553,6 +562,8 @@
[self.addToContactPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxXEdge];
}
[videoView setCallDelegate:nil];
}
- (IBAction)hangUp:(id)sender {
......@@ -597,22 +608,50 @@
- (IBAction)displayQualityPopUp:(id)sender {
[self.qualityPopOver showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
[videoView setCallDelegate:nil];
}
- (IBAction)toggleTransferView:(id)sender {
if (self.transferPopoverVC != nullptr) {
[self.transferPopoverVC performClose:self];
self.transferPopoverVC = NULL;
[self.transferButton setState:NSOffState];
} else {
auto* transferVC = [[BrokerVC alloc] initWithMode:BrokerMode::TRANSFER];
self.transferPopoverVC = [[NSPopover alloc] init];
[self.transferPopoverVC setContentSize:transferVC.view.frame.size];
[self.transferPopoverVC setContentViewController:transferVC];
[self.transferPopoverVC setAnimates:YES];
[self.transferPopoverVC setBehavior:NSPopoverBehaviorTransient];
[self.transferPopoverVC setDelegate:self];
[self.transferPopoverVC showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMinYEdge];
[videoView setCallDelegate:nil];
}
}
#pragma mark - NSPopOverDelegate
- (void)popoverWillClose:(NSNotification *)notification
{
if (self.transferPopoverVC != nullptr) {
[self.transferPopoverVC performClose:self];
self.transferPopoverVC = NULL;
}
if (self.addToContactPopover != nullptr) {
[self.addToContactPopover performClose:self];
self.addToContactPopover = NULL;
}
[self.qualityButton setState:NSOffState];
[self.addContactButton setState:NSOffState];
[self.transferButton setState:NSOffState];
}
- (void)popoverDidClose:(NSNotification *)notification
{
if (self.addToContactPopover != nullptr) {
[self.addToContactPopover performClose:self];
self.addToContactPopover = NULL;
}
[videoView setCallDelegate:self];
}
#pragma mark - ContactLinkedDelegate
......
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