Commit be7e2e4a authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

cleanup: remove unused code

Change-Id: Ic614edbc59b90552365ca090da4b17a8daa17277
parent bce35482
......@@ -135,8 +135,6 @@ SET(ringclient_CONTROLLERS
src/AccAdvancedRingVC.h
src/CertificateWC.mm
src/CertificateWC.h
src/RestoreAccountWC.mm
src/RestoreAccountWC.h
src/AudioPrefsVC.mm
src/AudioPrefsVC.h
src/VideoPrefsVC.mm
......@@ -180,10 +178,6 @@ SET(ringclient_CONTROLLERS
src/LeaveMessageVC.h
)
SET(ringclient_BACKENDS
src/backends/AddressBookBackend.mm
src/backends/AddressBookBackend.h)
SET(ringclient_VIEWS
src/views/CallView.mm
src/views/CallView.h
......@@ -262,7 +256,6 @@ SET(ringclient_XIBS
PreferencesWindow
RingWizard
CertificateWindow
RestoreAccountWindow
ExportPasswordWindow
MigrateRingAccountsWindow
Conversation
......@@ -416,7 +409,6 @@ ENDFOREACH()
SET(TO_ADD
${ringclient_CONTROLLERS}
${ringclient_BACKENDS}
${ringclient_VIEWS}
${ringclient_OTHERS}
${ringclient_XIBS_FOR_EXECUTABLE}
......
......@@ -24,7 +24,7 @@
#import <api/newaccountmodel.h>
#import <api/newdevicemodel.h>
#import <api/newcodecmodel.h>
#import <account.h>
#import <api/account.h>
@interface AccAdvancedVC ()
......
......@@ -19,10 +19,7 @@
#import <Cocoa/Cocoa.h>
#import <certificate.h>
@interface CertificateWC : NSWindowController
- (void) setCertificate:(Certificate*) cert;
@end
......@@ -25,11 +25,6 @@
[super windowDidLoad];
}
- (void) setCertificate:(Certificate*) cert
{
NSLog(@"CertificateWC loaded");
}
- (IBAction)closePanel:(id)sender
{
[NSApp endSheet:self.window];
......
......@@ -437,7 +437,7 @@ CVPixelBufferRef pixelBufferPreview;
}
}
-(void) setupConference:(Call*) c
-(void) setupConference
{
[videoView setShouldAcceptInteractions:YES];
[self.chatButton setHidden:NO];
......
......@@ -19,14 +19,19 @@
#import <Cocoa/Cocoa.h>
//LRC
#import <account.h>
//RING
//Jami
#import "LoadingWCProtocol.h"
#import "LoadingWCDelegate.h"
#import "AbstractLoadingWC.h"
#import "string"
namespace lrc {
namespace api {
class NewAccountModel;
}
}
@protocol MigrateRingAccountsDelegate <LoadingWCDelegate>
-(void) migrationDidCompleteWithError;
......@@ -57,6 +62,7 @@
*/
@property (readonly) BOOL validatePasswords;
@property Account* account;
@property lrc::api::NewAccountModel* accountModel;
@property std::string accountToMigrate;
@end
......@@ -20,7 +20,7 @@
#import "MigrateRingAccountsWC.h"
//LRC
#import <accountmodel.h>
#import <api/newaccountmodel.h>
//RING
#import "views/ITProgressIndicator.h"
......@@ -31,12 +31,14 @@
__unsafe_unretained IBOutlet NSTextField* infoField;
__unsafe_unretained IBOutlet NSTextField* errorField;
__unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator;
__unsafe_unretained IBOutlet NSImageView* profileImage;
__unsafe_unretained IBOutlet NSTextField* alias;
}
- (IBAction)onClickComplete:(id)sender;
@end
@implementation MigrateRingAccountsWC{
@implementation MigrateRingAccountsWC {
struct {
unsigned int didComplete:1;
unsigned int didCompleteWithError:1;
......@@ -46,6 +48,8 @@
NSTimer* errorTimer;
QMetaObject::Connection stateChanged;
@synthesize accountModel, accountToMigrate;
#pragma mark - Initialise / Setters
- (id)initWithDelegate:(id <MigrateRingAccountsDelegate>) del actionCode:(NSInteger) code
{
......@@ -54,6 +58,9 @@ QMetaObject::Connection stateChanged;
- (void) awakeFromNib{
[self setInfoMessageForAccount];
[profileImage setWantsLayer: YES];
profileImage.layer.cornerRadius = 40;
profileImage.layer.masksToBounds = YES;
}
- (void)setDelegate:(id <MigrateRingAccountsDelegate>)aDelegate
......@@ -65,30 +72,43 @@ QMetaObject::Connection stateChanged;
}
}
- (void) setAccount:(Account *)aAccount
{
_account = aAccount;
}
- (void) setInfoMessageForAccount
{
NSMutableAttributedString* infoMessage = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"The following account needs to be migrated to the new Ring account format:",@"Text shown to the user")];
const lrc::api::account::Info& accountInfo = self.accountModel->getAccountInfo(accountToMigrate);
NSData *imageData = [[NSData alloc]
initWithBase64EncodedString: @(accountInfo.profileInfo.avatar.c_str())
options:NSDataBase64DecodingIgnoreUnknownCharacters];
NSImage *image = [[NSImage alloc] initWithData:imageData];
if (image) {
profileImage.image = image;
} else {
profileImage.image = [NSImage imageNamed:@"default_avatar_overlay.png"];
profileImage.layer.backgroundColor = [[NSColor grayColor] CGColor];
}
alias.stringValue = @(accountInfo.profileInfo.alias.c_str());
NSMutableAttributedString* infoMessage = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"This account needs to be migrated",@"Text shown to the user")];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Alias : ",@"Text shown to the user")]];
const CGFloat fontSize = 13;
NSDictionary *attrs = @{
NSFontAttributeName:[NSFont boldSystemFontOfSize:fontSize]
};
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:self.account->alias().toNSString() attributes:attrs]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"RingID : ",@"Text shown to the user")]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:self.account->username().toNSString() attributes:attrs]];
auto registredName = accountInfo.registeredName;
if(!registredName.empty()) {
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Registered name: ",@"Text shown to the user")
attributes:attrs]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@(registredName.c_str()) attributes:attrs]];
} else {
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"ID: ",@"Text shown to the user")
attributes:attrs]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@(accountInfo.profileInfo.uri.c_str()) attributes:attrs]];
}
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]];
[infoMessage appendAttributedString:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"To proceed with the migration, you must choose a password for your account. This password will be used to encrypt your master key. It will be required for adding new devices to your Ring account. If you are not ready to choose a password, you may close Ring and resume the migration later.",@"Text shown to the user")]];
[infoField setAttributedStringValue:infoMessage];
}
- (void) showError:(NSString*) errorMessage
{
[errorField setStringValue:errorMessage];
......@@ -107,9 +127,10 @@ QMetaObject::Connection stateChanged;
#pragma mark - Events Handlers
- (IBAction)removeAccount:(id)sender
{
AccountModel::instance().remove(self.account);
AccountModel::instance().save();
self.accountModel->removeAccount(accountToMigrate);
[self cancelPressed:sender];
if (delegateRespondsTo.didComplete)
[((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete];
}
- (IBAction)startMigration:(NSButton *)sender
......@@ -122,28 +143,21 @@ QMetaObject::Connection stateChanged;
target:self
selector:@selector(didCompleteWithError) userInfo:nil
repeats:NO];
stateChanged = QObject::connect(
self.account, &Account::stateChanged,
[=](Account::RegistrationState state){
switch(state){
case Account::RegistrationState::READY:
case Account::RegistrationState::TRYING:
case Account::RegistrationState::UNREGISTERED:{
self.account<< Account::EditAction::RELOAD;
QObject::disconnect(stateChanged);
[self didComplete];
break;
}
case Account::RegistrationState::ERROR:
case Account::RegistrationState::INITIALIZING:
case Account::RegistrationState::COUNT__:{
//DO Nothing
break;
}
stateChanged = QObject::connect(self.accountModel,
&lrc::api::NewAccountModel::migrationEnded,
[self](const std::string& accountId, bool ok) {
if (accountToMigrate != accountId) {
return;
}
if (ok) {
[self didComplete];
} else {
[self didCompleteWithError];
}
});
self.account->setArchivePassword(QString::fromNSString(self.password));
self.account->performAction(Account::EditAction::SAVE);
lrc::api::account::ConfProperties_t accountProperties = self.accountModel->getAccountConfig(accountToMigrate);
accountProperties.archivePassword = [self.password UTF8String];
self.accountModel->setAccountConfig(accountToMigrate, accountProperties);
}
}
......@@ -159,7 +173,6 @@ QMetaObject::Connection stateChanged;
return [NSSet setWithObjects:@"password", @"passwordConfirmation", nil];
}
#pragma mark - Delegates
- (void)didComplete
{
......@@ -175,11 +188,9 @@ QMetaObject::Connection stateChanged;
[((id<MigrateRingAccountsDelegate>)self.delegate) migrationDidComplete];
}
- (void)didCompleteWithError
{
[self showError:NSLocalizedString(@"Failed to migrate your account. You can retry by pressing Ok or delete your account.",@"Error message shown to user when it is impossible to migrate account")];
}
@end
......@@ -25,7 +25,8 @@
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <account.h>
#import <api/account.h>
#import <namedirectory.h>
@implementation RegisterNameWC
{
......@@ -116,7 +117,8 @@ NSInteger const PASSWORD_TAG = 3;
registeredNameFound = QObject::connect(
&NameDirectory::instance(),
&NameDirectory::registeredNameFound,
[=] ( const Account* account, NameDirectory::LookupStatus status, const QString& address, const QString& name) {
[=] (NameDirectory::LookupStatus status,
const QString& address, const QString& name) {
NSLog(@"Name lookup ended");
lookupQueued = NO;
//If this is the username we are waiting for, we can disconnect.
......@@ -170,7 +172,7 @@ NSInteger const PASSWORD_TAG = 3;
);
//Start the lookup in a second so that the UI dosen't seem to freeze
BOOL result = NameDirectory::instance().lookupName(nullptr, QString(), QString::fromNSString(usernameWaitingForLookupResult));
BOOL result = NameDirectory::instance().lookupName(QString(), QString::fromNSString(usernameWaitingForLookupResult));
}
- (void)controlTextDidChange:(NSNotification *)notif
......
/*
* Copyright (C) 2016-2019 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>
#import <QtCore/qdir.h>
#import "LoadingWCDelegate.h"
#import "AbstractLoadingWC.h"
typedef NS_ENUM(NSUInteger, Action) {
ACTION_EXPORT = 0,
ACTION_IMPORT = 1,
};
@protocol RestoreAccountDelegate <LoadingWCDelegate>
@optional
-(void) didCompleteImport;
@end
@interface RestoreAccountWC : AbstractLoadingWC
- (id)initWithDelegate:(id <LoadingWCDelegate>) del;
/**
* Allow the NSPathControl of this window to select files or not
*/
@property (nonatomic) BOOL allowFileSelection;
/**
* password string contained in passwordField.
* This is a KVO method to bind the text with the OK Button
* if password.length is > 0, button is enabled, otherwise disabled
*/
@property (retain) NSString* password;
/**
* Object uses to store account to exports
*/
@property (assign) QStringList accounts;
@end
/*
* Copyright (C) 2016-2019 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 "RestoreAccountWC.h"
//LRC
#import <accountmodel.h>
//Ring
#import "views/ITProgressIndicator.h"
@interface RestoreAccountWC() <NSTextFieldDelegate> {
__unsafe_unretained IBOutlet NSPathControl* path;
__unsafe_unretained IBOutlet NSSecureTextField* passwordField;
__unsafe_unretained IBOutlet ITProgressIndicator* progressIndicator;
}
@end
@implementation RestoreAccountWC {
struct {
unsigned int didCompleteImport:1;
} delegateRespondsTo;
}
@synthesize accounts;
- (id)initWithDelegate:(id <LoadingWCDelegate>) del
{
return [self initWithDelegate:del actionCode:0];
}
- (id)initWithDelegate:(id <RestoreAccountDelegate>) del actionCode:(NSInteger) code
{
return [super initWithWindowNibName:@"RestoreAccountWindow" delegate:del actionCode:code];
}
- (void)windowDidLoad
{
[super windowDidLoad];
[path setURL: [NSURL fileURLWithPath:NSHomeDirectory()]];
}
- (void)setDelegate:(id <RestoreAccountDelegate>)aDelegate
{
if (self.delegate != aDelegate) {
[super setDelegate: aDelegate];
delegateRespondsTo.didCompleteImport = [self.delegate respondsToSelector:@selector(didCompleteWithImport)];
}
}
- (void) setAllowFileSelection:(BOOL) b
{
_allowFileSelection = b;
[path setAllowedTypes:_allowFileSelection ? nil : [NSArray arrayWithObject:@"public.folder"]];
}
- (IBAction)completeAction:(id)sender
{
auto passwordString = passwordField.stringValue;
auto pathURL = path.URL;
[self showLoading];
SEL sel = @selector(importAccountsWithPath:andPassword:);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:sel]];
[inv setSelector:sel];
[inv setTarget:self];
//arguments 0 and 1 are self and _cmd respectively, automatically set by NSInvocation
[inv setArgument:&pathURL atIndex:2];
[inv setArgument:&passwordString atIndex:3];
// Schedule import for next iteration of event loop in order to let us start the loading anim
[inv performSelector:@selector(invoke) withObject:nil afterDelay:0];
}
- (void)showLoading
{
[progressIndicator setNumberOfLines:30];
[progressIndicator setWidthOfLine:2];
[progressIndicator setLengthOfLine:5];
[progressIndicator setInnerMargin:20];
[super showLoading];
}
- (void) importAccountsWithPath:(NSURL*) urlPath andPassword:(NSString*) password
{
int result = AccountModel::instance().importAccounts(urlPath.path.UTF8String, password.UTF8String);
switch (result) {
case 0:
if (delegateRespondsTo.didCompleteImport)
[((id<RestoreAccountDelegate>)self.delegate) didCompleteImport];
[self close];
break;
default:
{
[self showError];
}
break;
}
}
@end
......@@ -19,7 +19,6 @@
#import "RingWindowController.h"
#import <QuartzCore/QuartzCore.h>
#include <qrencode.h>
#include <memory>
//LRC
#import <api/lrc.h>
......@@ -31,7 +30,6 @@
#import <api/contactmodel.h>
#import <api/contact.h>
#import <api/datatransfermodel.h>
#import <media/recordingmodel.h>
#import <api/avmodel.h>
// Ring
......@@ -48,7 +46,6 @@
#import "utils.h"
#import "RingWizardWC.h"
#import "AccountSettingsVC.h"
#import "views/CallLayer.h"
typedef NS_ENUM(NSInteger, ViewState) {
SHOW_WELCOME_SCREEN = 0,
......@@ -99,7 +96,6 @@ typedef NS_ENUM(NSInteger, ViewState) {
self.behaviorController = behaviorController;
self.avModel = avModel;
self.avModel->useAVFrame(YES);
avModel->deactivateOldVideoModels();
}
return self;
}
......@@ -191,18 +187,9 @@ typedef NS_ENUM(NSInteger, ViewState) {
[conversationVC initFrame];
[settingsVC initFrame];
@try {
[smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
}
@catch (NSException *ex) {
NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
}
// Fresh run, we need to make sure RingID appears
[shareButton sendActionOn:NSLeftMouseDownMask];
[self checkAccountsToMigrate];
[self connect];
[self updateRingID];
// set download folder (default - 'Documents')
NSString* path = [[NSUserDefaults standardUserDefaults] stringForKey:Preferences::DownloadFolder];
if (!path || path.length == 0) {
......@@ -212,7 +199,7 @@ typedef NS_ENUM(NSInteger, ViewState) {
self.dataTransferModel->downloadDirectory = std::string([path UTF8String]);
if(appSandboxed()) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
media::RecordingModel::instance().setRecordPath(QString::fromNSString([paths objectAtIndex:0]));
avModel->setRecordPath([[paths objectAtIndex:0] UTF8String]);
}
NSToolbar *tb = [[self window] toolbar];
[tb setAllowsUserCustomization:NO];
......@@ -281,6 +268,47 @@ typedef NS_ENUM(NSInteger, ViewState) {
});
}
#pragma mark - Ring account migration
- (void) migrateRingAccount:(std::string) acc
{
self.migrateWC = [[MigrateRingAccountsWC alloc] initWithDelegate:self actionCode:1];
self.migrateWC.accountModel = self.accountModel;
self.migrateWC.accountToMigrate = acc;
[self.window beginSheet:self.migrateWC.window completionHandler:nil];
}
- (void)checkAccountsToMigrate
{
auto accounts = self.accountModel->getAccountList();
for (auto accountId: accounts) {
const lrc::api::account::Info& accountInfo = self.accountModel->getAccountInfo(accountId);
if (accountInfo.status == lrc::api::account::Status::ERROR_NEED_MIGRATION) {
[self migrateRingAccount:accountInfo.id];
return;
}
}
@try {
[smartViewVC setConversationModel: [chooseAccountVC selectedAccount].conversationModel.get()];
}
@catch (NSException *ex) {
NSLog(@"Caught exception %@: %@", [ex name], [ex reason]);
}
[shareButton sendActionOn:NSLeftMouseDownMask];
[self connect];
[self updateRingID];
}
- (void)migrationDidComplete
{
[self checkAccountsToMigrate];
}
- (void)migrationDidCompleteWithError
{
[self checkAccountsToMigrate];
}
/**
* Implement the necessary logic to choose which Ring ID to display.
* This tries to choose the "best" ID to show
......
......@@ -34,8 +34,9 @@
//LRC
#import <api/lrc.h>
#import <api/newaccountmodel.h>
#import <account.h>
#import <api/account.h>
#import <interfaces/pixmapmanipulatori.h>
#import <namedirectory.h>
#import "Constants.h"
#import "views/NSImage+Extensions.h"
......@@ -402,7 +403,8 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
registeredNameFound = QObject::connect(
&NameDirectory::instance(),
&NameDirectory::registeredNameFound,
[=] ( const Account* account, NameDirectory::LookupStatus status, const QString& address, const QString& name) {
[=] (NameDirectory::LookupStatus status,
const QString& address, const QString& name) {
NSLog(@"Name lookup ended");
lookupQueued = NO;
//If this is the username we are waiting for, we can disconnect.
......@@ -456,7 +458,7 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
});
//Start the lookup in a second so that the UI dosen't seem to freeze
BOOL result = NameDirectory::instance().lookupName(nullptr, QString(), QString::fromNSString(usernameWaitingForLookupResult));
BOOL result = NameDirectory::instance().lookupName(QString(), QString::fromNSString(usernameWaitingForLookupResult));
}
......
......@@ -27,6 +27,9 @@
#import <video/renderer.h>
#import <api/avmodel.h>
//Qt
#import <QSize>
extern "C" {
#import "libavutil/frame.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.
*/
#include <collectioninterface.h>
#include <collectioneditor.h>
class Person;
@class ABPerson;
@class NSMutableArray;
@class NSNotification;
template<typename T> class CollectionMediator;
class AddressBookBackend : public CollectionInterface
{
public:
explicit AddressBookBackend(CollectionMediator<Person>* mediator);
virtual ~AddressBookBackend();
virtual bool load() override;
virtual bool reload() override;
virtual bool clear() override;
virtual QString name () const override;
virtual QString category () const override;
virtual QVariant icon () const override;
virtual bool isEnabled() const override;
virtual QByteArray id () const override;
virtual FlagPack<SupportedFeatures> supportedFeatures() const override;
bool addNewPerson(Person *item);
bool removePerson(NSString* uid);
private:
CollectionMediator<Person>* m_pMediator;
NSMutableArray* observers;
void handleNotification(NSNotification* ns);
Person* abPersonToPerson(ABPerson* ab);
void asyncLoad(int startingPoint);
};
\ No newline at end of file
This diff is collapsed.
......@@ -26,7 +26,6 @@
//Ring
#import <interfaces/pixmapmanipulatori.h>
#import <call.h>
class Person;
class QString;
......@@ -39,7 +38,6 @@ namespace Interfaces {
static constexpr int IMG_SIZE = 80;
ImageManipulationDelegate();
QVariant contactPhoto(Person* c, const QSize& size, bool displayPresence = true) override;
virtual QByteArray toByteArray(const QVariant& pxm) override;
virtual QVariant personPhoto(const QByteArray& data, const QString& type = nil) override;
QVariant conversationPhoto(const lrc::api::conversation::Info& conversation,
......@@ -47,20 +45,10 @@ namespace Interfaces {
const QSize& size = QSize(IMG_SIZE, IMG_SIZE),
bool displayPresence = true) override;
QVariant callPhoto(Call* c, const QSize& size, bool displayPresence = true) override;
QVariant callPhoto(const ContactMethod* n, const QSize& size, bool displayPresence = true) override;
/* TODO: the following methods return an empty QVariant/QByteArray */
QVariant numberCategoryIcon(const QVariant& p, const QSize& size, bool displayPresence = false, bool isPresent = false) override;
QVariant securityIssueIcon(const QModelIndex& index) override;
QVariant collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const override;
QVariant securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const override;
QVariant userActionIcon(const UserActionElement& state) const override;
QVariant decorationRole(const QModelIndex& index) override;
QVariant decorationRole(const Call* c) override;
QVariant decorationRole(const ContactMethod* cm) override;
QVariant decorationRole(const Person* p) override;
QVariant decorationRole(const Account* acc) override;
private:
//Helper
......
......@@ -34,9 +34,6 @@
#import <QtGui/QPalette>
//LRC
#import <person.h>
#import <profile.h>
#import <contactmethod.h>
#import <api/conversation.h>
#import <api/account.h>
#import <api/contactmodel.h>
......@@ -67,81 +64,6 @@ namespace Interfaces {
ImageManipulationDelegate::ImageManipulationDelegate() {}
QVariant ImageManipulationDelegate::contactPhoto(Person* c, const QSize& size, bool displayPresence) {
const int radius = size.height() / 2;
QPixmap pxm;
if (c && c->photo().isValid()) {
// Check cache
auto index = QStringLiteral("%1%2%3").arg(size.width())
.arg(size.height())
.arg(QString::fromUtf8(c->uid()));
if (m_hContactsPixmap.contains(index)) {
return m_hContactsPixmap.value(index).second;
}
QPixmap contactPhoto(qvariant_cast<QPixmap>(c->photo()).scaled(size, Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation));
QPixmap finalImg;
if (contactPhoto.size() != size) {
finalImg = crop(contactPhoto, size);
} else
finalImg = contactPhoto;
pxm = QPixmap(size);