Commit 3b0bd33c authored by Alexandre Lision's avatar Alexandre Lision Committed by Alexandre Lision

contacts: display reachable contacts

This commits introduces integration with user's contacts
Only reachable contacts are displayed, based on accounts available.
No edition is provided within Ring.

Change-Id: I8d897802b086eccc42446d58f3efa83cb953e14b
parent 74dd47f9
......@@ -16,10 +16,12 @@ ADD_DEFINITIONS("-std=c++11")
PROJECT(${PROJ_NAME})
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5MacExtras REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(LibRingClient REQUIRED)
INCLUDE_DIRECTORIES(SYSTEM ${Qt5Core_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(SYSTEM ${Qt5MacExtras_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE_DIRECTORIES(${LIB_RING_CLIENT_INCLUDE_DIR})
......@@ -48,9 +50,14 @@ SET(ringclient_SRCS
src/GeneralPrefsVC.mm
src/RingWizardWC.mm
src/HistoryViewController.mm
src/PersonsVC.mm
src/delegates/ImageManipulationDelegate.mm
src/views/PersonCell.mm
src/views/CallView.mm
src/backends/AddressBookBackend.mm
src/backends/MinimalHistoryBackend.mm)
SET(ringclient_XIBS
......@@ -89,9 +96,14 @@ SET(ringclient_HDRS
src/HistoryViewController.h
src/RingWizardWC.h
src/QNSTreeController.h
src/PersonsVC.h
src/delegates/ImageManipulationDelegate.h
src/views/PersonCell.h
src/views/CallView.h
src/backends/AddressBookBackend.h
src/backends/MinimalHistoryBackend.h)
# Icons
......@@ -134,6 +146,7 @@ ADD_EXECUTABLE(${PROJ_NAME} MACOSX_BUNDLE
TARGET_LINK_LIBRARIES( ${PROJ_NAME}
${LIB_RING_CLIENT_LIBRARY}
${Qt5Core_LIBRARIES}
${Qt5MacExtras_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)
......
......@@ -78,15 +78,14 @@
[historyView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[historyView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
[historyView setTarget:self];
[historyView setDoubleAction:@selector(placeCall:)];
[historyView setDoubleAction:@selector(placeHistoryCall:)];
CategorizedHistoryModel::instance()->addCollection<MinimalHistoryBackend>(LoadOptions::FORCE_ENABLED);
}
- (void)placeCall:(id)sender
- (void)placeHistoryCall:(id)sender
{
if([[treeController selectedNodes] count] > 0) {
Call* c = CallModel::instance()->dialingCall();
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
QVariant var = historyProxyModel->data(qIdx, (int)Call::Role::ContactMethod);
ContactMethod* m = qvariant_cast<ContactMethod*>(var);
......
/*
* Copyright (C) 2004-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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import <Cocoa/Cocoa.h>
@interface PersonsVC : NSViewController <NSOutlineViewDelegate>
@end
/*
* Copyright (C) 2004-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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "PersonsVC.h"
#import <personmodel.h>
#import <callmodel.h>
#import <categorizedcontactmodel.h>
#import <QSortFilterProxyModel>
#import <person.h>
#import <contactmethod.h>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
#import "backends/AddressBookBackend.h"
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
#import "views/PersonCell.h"
#define COLUMNID_NAME @"NameColumn"
class ReachablePersonModel : public QSortFilterProxyModel
{
public:
ReachablePersonModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
{
setSourceModel(parent);
}
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
return sourceModel()->index(source_row,0,source_parent).flags() & Qt::ItemIsEnabled;
}
};
@interface PersonsVC ()
@property NSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *personsView;
@property QSortFilterProxyModel *contactProxyModel;
@end
@implementation PersonsVC
@synthesize treeController;
@synthesize personsView;
@synthesize contactProxyModel;
-(void) awakeFromNib
{
new ImageManipulationDelegate();
NSLog(@"INIT PersonsVC");
contactProxyModel = new ReachablePersonModel(CategorizedContactModel::instance());
contactProxyModel->setSortRole(static_cast<int>(Qt::DisplayRole));
contactProxyModel->sort(0,Qt::AscendingOrder);
treeController = [[QNSTreeController alloc] initWithQModel:contactProxyModel];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
[personsView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[personsView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[personsView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
[personsView setTarget:self];
[personsView setDoubleAction:@selector(callContact:)];
CategorizedContactModel::instance()->setUnreachableHidden(YES);
PersonModel::instance()->addCollection<AddressBookBackend>(LoadOptions::FORCE_ENABLED);
}
- (IBAction)callContact:(id)sender
{
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
ContactMethod* m = nil;
if(((NSTreeNode*)[treeController selectedNodes][0]).indexPath.length == 2) {
// Person
QVariant var = qIdx.data((int)Person::Role::Object);
if (var.isValid()) {
Person *c = var.value<Person*>();
if (c->phoneNumbers().size() == 1) {
m = c->phoneNumbers().first();
}
}
} else if (((NSTreeNode*)[treeController selectedNodes][0]).indexPath.length == 3) {
//ContactMethod
QVariant var = qIdx.data(static_cast<int>(ContactMethod::Role::Object));
if (var.isValid()) {
m = var.value<ContactMethod *>();
}
}
if(m){
Call* c = CallModel::instance()->dialingCall();
c->setDialNumber(m);
c << Call::Action::ACCEPT;
}
}
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
// shouldSelectItem:item
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return NO;
if(!qIdx.parent().isValid()) {
return NO;
} else {
return YES;
}
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
PersonCell *returnCell = [tableColumn dataCell];
if(!qIdx.isValid())
return returnCell;
if(!qIdx.parent().isValid()) {
[returnCell setDrawsBackground:YES];
[returnCell setBackgroundColor:[NSColor selectedControlColor]];
} else {
[returnCell setDrawsBackground:NO];
}
return returnCell;
}
// -------------------------------------------------------------------------------
// textShouldEndEditing:fieldEditor
// -------------------------------------------------------------------------------
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
if ([[fieldEditor string] length] == 0)
{
// don't allow empty node names
return NO;
}
else
{
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;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return;
if ([[tableColumn identifier] isEqualToString:COLUMNID_NAME])
{
PersonCell *pCell = (PersonCell *)cell;
[pCell setPersonImage:nil];
if(!qIdx.parent().isValid()) {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
} else {
pCell.title = qIdx.data(Qt::DisplayRole).toString().toNSString();
if(((NSTreeNode*)item).indexPath.length == 2) {
Person* p = qvariant_cast<Person*>(qIdx.data((int)Person::Role::Object));
QVariant photo = ImageManipulationDelegate::instance()->contactPhoto(p, QSize(35,35));
[pCell setPersonImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
}
}
}
}
// -------------------------------------------------------------------------------
// outlineViewSelectionDidChange:notification
// -------------------------------------------------------------------------------
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return 0.0f;
if(!qIdx.parent().isValid()) {
return 20.0;
} else {
return 45.0;
}
}
@end
......@@ -84,13 +84,33 @@
NSUInteger myArray[[idx length]];
[idx getIndexes:myArray];
QModelIndex toReturn;
if(idx.length == 2)
toReturn = self->privateQModel->index(myArray[1], 0, self->privateQModel->index(myArray[0], 0));
else
toReturn = self->privateQModel->index(myArray[0], 0);
for (int i = 0; i < idx.length; ++i) {
toReturn = self->privateQModel->index(myArray[i], 0, toReturn);
}
return toReturn;
}
- (void) insertChildAtQIndex:(QModelIndex) qIdx
{
Node* child = [[Node alloc] init];
QModelIndex tmp = qIdx.parent();
NSMutableArray* allIndexes = [NSMutableArray array];
while (tmp.isValid()) {
[allIndexes insertObject:@(tmp.row()) atIndex:0];
tmp = tmp.parent();
}
[allIndexes insertObject:@(qIdx.row()) atIndex:allIndexes.count];
NSUInteger indexes[allIndexes.count];
for (int i = 0 ; i < allIndexes.count ; ++i) {
indexes[i] = [[allIndexes objectAtIndex:i] intValue];
}
[self insertObject:child atArrangedObjectIndexPath:[[NSIndexPath alloc] initWithIndexes:indexes length:allIndexes.count]];
}
- (void)connect
{
QObject::connect(self->privateQModel,
......@@ -102,9 +122,7 @@
Node* n = [[Node alloc] init];
[self insertObject:n atArrangedObjectIndexPath:[[NSIndexPath alloc] initWithIndex:row]];
} else {
Node* child = [[Node alloc] init];
NSUInteger indexes[] = { (NSUInteger)parent.row(), (NSUInteger)row};
[self insertObject:child atArrangedObjectIndexPath:[[NSIndexPath alloc] initWithIndexes:indexes length:2]];
[self insertChildAtQIndex:self->privateQModel->index(row, 0, parent)];
}
}
}
......
/*
* Copyright (C) 2004-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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef ADDRESSBOOKBACKEND_H
#define ADDRESSBOOKBACKEND_H
#include <collectioninterface.h>
#include <collectioneditor.h>
class Person;
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 SupportedFeatures supportedFeatures() const override;
private:
CollectionMediator<Person>* m_pMediator;
void asyncLoad(int startingPoint);
};
#endif // ADDRESSBOOKBACKEND_H
/*
* Copyright (C) 2004-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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall import the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#import "AddressBookBackend.h"
#import <AddressBook/AddressBook.h>
//Qt
#import <QtCore/QFile>
#import <QtCore/QDir>
#import <QtCore/QHash>
#import <QtWidgets/QApplication>
#import <QtCore/QStandardPaths>
#import <QTimer>
#import <QtGlobal>
//Ring
#import <Person.h>
#import <account.h>
#import <person.h>
#import <contactmethod.h>
/**
*
*kABFirstNameProperty
kABLastNameProperty
kABFirstNamePhoneticProperty
kABLastNamePhoneticProperty
kABBirthdayProperty
kABOrganizationProperty
kABJobTitleProperty
kABHomePageProperty
kABEmailProperty
kABAddressProperty
kABPhoneProperty
kABAIMInstantProperty
kABJabberInstantProperty
kABMSNInstantProperty
kABYahooInstantProperty
kABICQInstantProperty
kABNoteProperty
kABMiddleNameProperty
kABMiddleNamePhoneticProperty
kABTitleProperty
kABSuffixProperty
kABNicknameProperty
kABMaidenNameProperty
*/
class AddressBookEditor : public CollectionEditor<Person>
{
public:
AddressBookEditor(CollectionMediator<Person>* m, AddressBookBackend* parent);
virtual bool save ( const Person* item ) override;
virtual bool remove ( const Person* item ) override;
virtual bool edit ( Person* item ) override;
virtual bool addNew ( const Person* item ) override;
virtual bool addExisting( const Person* item ) override;
private:
virtual QVector<Person*> items() const override;
//Helpers
void savePerson(QTextStream& stream, const Person* Person);
bool regenFile(const Person* toIgnore);
//Attributes
QVector<Person*> m_lItems;
AddressBookBackend* m_pCollection;
};
AddressBookEditor::AddressBookEditor(CollectionMediator<Person>* m, AddressBookBackend* parent) :
CollectionEditor<Person>(m),m_pCollection(parent)
{
}
AddressBookBackend::AddressBookBackend(CollectionMediator<Person>* mediator) :
CollectionInterface(new AddressBookEditor(mediator,this)),m_pMediator(mediator)
{
}
AddressBookBackend::~AddressBookBackend()
{
}
void AddressBookEditor::savePerson(QTextStream& stream, const Person* Person)
{
qDebug() << "Saving Person!";
}
bool AddressBookEditor::regenFile(const Person* toIgnore)
{
QDir dir(QString('/'));
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QString());
return false;
}
bool AddressBookEditor::save(const Person* Person)
{
//if (Person->collection()->editor<Person>() != this)
// return addNew(Person);
return regenFile(nullptr);
}
bool AddressBookEditor::remove(const Person* item)
{
return regenFile(item);
}
bool AddressBookEditor::edit( Person* item)
{
Q_UNUSED(item)
return false;
}
bool AddressBookEditor::addNew(const Person* Person)
{
QDir dir(QString('/'));
dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + QString());
return false;
}
bool AddressBookEditor::addExisting(const Person* item)
{
m_lItems << const_cast<Person*>(item);
mediator()->addItem(item);
return true;
}
QVector<Person*> AddressBookEditor::items() const
{
return m_lItems;
}
QString AddressBookBackend::name () const
{
return QObject::tr("AddressBook backend");
}
QString AddressBookBackend::category () const
{
return QObject::tr("Persons");
}
QVariant AddressBookBackend::icon() const
{
return QVariant();
}
bool AddressBookBackend::isEnabled() const
{
return true;
}
bool AddressBookBackend::load()
{
QTimer::singleShot(100, [=] {
asyncLoad(0);
});
return false;
}
void AddressBookBackend::asyncLoad(int startingPoint)
{
ABAddressBook *book = [ABAddressBook sharedAddressBook];
NSArray *everyone = [book people];
int endPoint = qMin(startingPoint + 10, (int)everyone.count);
for (int i = startingPoint; i < endPoint; ++i) {
Person* person = new Person(QByteArray::fromNSData(((ABPerson*)[everyone objectAtIndex:i]).vCardRepresentation),
Person::Encoding::vCard,
this);
if([person->formattedName().toNSString() isEqualToString:@""] &&
[person->secondName().toNSString() isEqualToString:@""] &&
[person->firstName().toNSString() isEqualToString:@""]) {
continue;
}
person->setCollection(this);
editor<Person>()->addExisting(person);
}
if(endPoint < everyone.count) {
QTimer::singleShot(100, [=] {
asyncLoad(endPoint);
});
}
}
bool AddressBookBackend::reload()
{
return false;
}
CollectionInterface::SupportedFeatures AddressBookBackend::supportedFeatures() const
{
return (CollectionInterface::SupportedFeatures) (
CollectionInterface::SupportedFeatures::NONE |
CollectionInterface::SupportedFeatures::LOAD |
CollectionInterface::SupportedFeatures::CLEAR |
CollectionInterface::SupportedFeatures::REMOVE|
CollectionInterface::SupportedFeatures::ADD );
}
bool AddressBookBackend::clear()
{
/* TODO: insert confirm dialog? */
return true;
}
QByteArray AddressBookBackend::id() const
{
return "abb";
}
/*
* 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.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef IMAGEMANIPULATION_H
#define IMAGEMANIPULATION_H
#import <QuartzCore/QuartzCore.h>
#import <delegates/pixmapmanipulationdelegate.h>
#import <call.h>
class Person;
class QPixmap;
class ImageManipulationDelegate : public PixmapManipulationDelegate {
public:
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 = "PNG") override;
private:
//Helper
QPixmap drawDefaultUserPixmap(const QSize& size, bool displayPresence, bool isPresent);
CGImageRef resizeCGImage(CGImageRef image, const QSize& size);
};
#endif // IMAGEMANIPULATION_H
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*