Commit 1ba5a019 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

refactor: remove unused code

Change-Id: Ie567c7ab73d782eff48527eb5eb11cb89b6576fb
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent e3503844
......@@ -135,12 +135,8 @@ SET(ringclient_CONTROLLERS
src/GeneralPrefsVC.h
src/ChatVC.mm
src/ChatVC.h
src/PersonLinkerVC.mm
src/PersonLinkerVC.h
src/SmartViewVC.mm
src/SmartViewVC.h
src/BrokerVC.mm
src/BrokerVC.h
src/ConversationVC.mm
src/ConversationVC.h
src/LoadingWCDelegate.h
......@@ -162,12 +158,6 @@ SET(ringclient_CONTROLLERS
src/RegisterNameWC.h
src/ChooseAccountVC.h
src/ChooseAccountVC.mm
src/ContactRequestsListVC.h
src/ContactRequestsListVC.mm
src/ContactRequestVC.h
src/ContactRequestVC.mm
src/AccBannedContactsVC.h
src/AccBannedContactsVC.mm
src/MessagesVC.h
src/MessagesVC.mm
src/PasswordChangeWC.h
......@@ -248,7 +238,6 @@ SET(ringclient_XIBS
CurrentCall
GeneralPrefs
AccSipGeneral
AccMedia
AccRingGeneral
AccAdvancedSip
AccAdvancedRing
......@@ -261,8 +250,6 @@ SET(ringclient_XIBS
RestoreAccountWindow
ExportPasswordWindow
MigrateRingAccountsWindow
PersonLinker
Broker
Conversation
RingWizardLinkAccount
RingWizardNewAccount
......@@ -270,9 +257,6 @@ SET(ringclient_XIBS
Dialpad
RegisterNameWindow
AccountMenuItemView
ContactRequestList
ContactRequest
AccBannedContacts
PasswordChange
MessageCells
AddSIPAccountVC
......
/*
* Copyright (C) 2015-2017 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>
@interface AccBannedContactsVC : NSViewController
@property (nonatomic) BOOL bannedListIsEmpty;
@end
/*
* Copyright (C) 2015-2017 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.
*/
//Qt
#import <QItemSelectionModel>
//LRC
#import <account.h>
#import <availableAccountModel.h>
#import <contactmethod.h>
#import <bannedContactmodel.h>
#import "AccBannedContactsVC.h"
#import "QNSTreeController.h"
@interface AccBannedContactsVC ()
@property QNSTreeController* bannedContactsTreeController;
@property (unsafe_unretained) IBOutlet NSOutlineView* banedContactsView;
@end
@implementation AccBannedContactsVC
@synthesize bannedContactsTreeController;
@synthesize banedContactsView;
NSInteger const TAG_NAME = 100;
NSInteger const TAG_RINGID = 200;
- (void)awakeFromNib
{
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (void)loadAccount
{
auto account = AccountModel::instance().selectedAccount();
self.bannedContactsTreeController = [[QNSTreeController alloc] initWithQModel:(QAbstractItemModel*)account->bannedContactModel()];
[self.bannedContactsTreeController setAvoidsEmptySelection:NO];
[self.bannedContactsTreeController setChildrenKeyPath:@"children"];
[self.banedContactsView bind:@"content" toObject:self.bannedContactsTreeController withKeyPath:@"arrangedObjects" options:nil];
[self.banedContactsView bind:@"sortDescriptors" toObject:self.bannedContactsTreeController withKeyPath:@"sortDescriptors" options:nil];
[self.banedContactsView bind:@"selectionIndexPaths" toObject:self.bannedContactsTreeController withKeyPath:@"selectionIndexPaths" options:nil];
NSLog(@"numberofRowsBanned, %d", account->bannedContactModel()->rowCount());
self.bannedListIsEmpty = banedContactsView.numberOfRows == 0;
}
- (IBAction)unbanContact:(NSView*)sender
{
NSInteger row = [self.banedContactsView rowForView:sender];
if(row < 0) {
return;
}
auto account = AccountModel::instance().selectedAccount();
id item = [self.banedContactsView itemAtRow:row];
QModelIndex qIdx = [self.bannedContactsTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid()) {
return;
}
auto cm = qIdx.data(static_cast<int>(ContactMethod::Role::Object)).value<ContactMethod*>();
if( account && cm) {
account->bannedContactModel()->remove(cm);
}
self.bannedListIsEmpty = banedContactsView.numberOfRows == 0;
}
#pragma mark - NSOutlineViewDelegate methods
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
return YES;
}
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
return [outlineView makeViewWithIdentifier:@"HoverRowView" owner:nil];
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSTableView* result = [outlineView makeViewWithIdentifier:@"BannedContactsCellView" owner:self];
QModelIndex qIdx = [self.bannedContactsTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return result;
NSTextField* nameLabel = [result viewWithTag:TAG_NAME];
NSTextField* deviceIDLabel = [result viewWithTag:TAG_RINGID];
auto account = AccountModel::instance().selectedAccount();
NSString* stringID = account->bannedContactModel()->data(qIdx,Qt::DisplayRole).toString().toNSString();
[nameLabel setStringValue:stringID];
[deviceIDLabel setStringValue:stringID];
return result;
}
@end
......@@ -34,7 +34,6 @@
#import <api/newaccountmodel.h>
#import <api/newdevicemodel.h>
#import <interfaces/pixmapmanipulatori.h>
#import <globalinstances.h>
#import "RegisterNameWC.h"
#import "RestoreAccountWC.h"
......
......@@ -20,7 +20,6 @@
#import <Cocoa/Cocoa.h>
#import <account.h>
#import "LrcModelsProtocol.h"
#import "AccountSettingsVC.h"
......
......@@ -32,7 +32,6 @@
#import <api/newaccountmodel.h>
#import <api/newdevicemodel.h>
#import <interfaces/pixmapmanipulatori.h>
#import <globalinstances.h>
#import "AccSipGeneralVC.h"
#import "views/NSColor+RingTheme.h"
......
......@@ -19,7 +19,6 @@
//LRC
#import <api/lrc.h>
#import <api/account.h>
#import <api/newaccountmodel.h>
#import "views/NSColor+RingTheme.h"
......
......@@ -25,7 +25,6 @@
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <account.h>
//ring
#import "AddSIPAccountVC.h"
......
......@@ -21,7 +21,6 @@
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <account.h>
//Ring
#import "views/ITProgressIndicator.h"
......
/*
* Copyright (C) 2015-2016 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-2016 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>
#import <QMimeData>
//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];
if ([self mode] == BrokerMode::TRANSFER) {
[_smartView setDoubleAction:@selector(placeTransfer:)];
} else {
[_smartView setDoubleAction:@selector(addParticipant:)];
}
}
// -------------------------------------------------------------------------------
// 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);
}
// -------------------------------------------------------------------------------
// place a call to the future participant on click on Person or ContactMethod
// -------------------------------------------------------------------------------
- (void)addParticipant:(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 participant = RecentModel::instance().getActiveCall(originIdx);
if (participant) { //join this call with the current one
QModelIndexList source_list;
source_list << CallModel::instance().getIndex(current);
auto idx_call_dest = CallModel::instance().getIndex(participant);
auto mimeData = CallModel::instance().mimeData(source_list);
auto action = Call::DropAction::Conference;
mimeData->setProperty("dropAction", action);
if (CallModel::instance().dropMimeData(mimeData, Qt::MoveAction, idx_call_dest.row(), idx_call_dest.column(), idx_call_dest.parent())) {
NSLog(@"OK");
} else {
NSLog(@"could not drop mime data");
}
return;
}
auto contactmethods = RecentModel::instance().getContactMethods(originIdx);
if (contactmethods.size() > 0) { // Before calling check if we properly extracted at least one contact method
auto call = CallModel::instance().dialingCall(contactmethods.first());
call->setParentCall(current);
call << Call::Action::ACCEPT;
CallModel::instance().selectCall(call);
}
}
// -------------------------------------------------------------------------------
// place a call to the future participant with entered URI
// -------------------------------------------------------------------------------
- (void) addParticipantFromUri:(NSString*) uri
{
auto current = CallModel::instance().selectedCall();
if (!current)
return;
auto number = PhoneDirectoryModel::instance().getNumber(QString::fromNSString(uri));
auto dialing = CallModel::instance().dialingCall(number);
dialing->setParentCall(current);
dialing << Call::Action::ACCEPT;
CallModel::instance().selectCall(dialing);
}
#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];
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(qIdx.data(Qt::DecorationRole)))];
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:@""]) {
if ([self mode] == BrokerMode::TRANSFER) {
[self transferTo:fieldEditor.textStorage.string];
} else {
[self addParticipantFromUri: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
......@@ -27,8 +27,6 @@
#import <QPixmap>
//LRC
#import <globalinstances.h>
#import <QItemSelectionModel.h>
#import <interfaces/pixmapmanipulatori.h>
#import <api/newaccountmodel.h>
#import <api/account.h>
......
/*
* Copyright (C) 2015-2017 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.