Commit 067dec6d authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Anthony Léonard

SmartList: one entry for Ring and Mac contact

If MAC Address Book is available when user save contact two persons
are created. It may be unclear for user because those entries looks
similar and point to the same ringID. And it could cause other duplication
in future if user will select contact related to Address Book to make
call. This patch use same person for Ring and Mac contact, by assigning
person UID from MAC when user create new contact and also it checks if
person exists before adding new from Mac contacts.

Change-Id: I80daccba1bcbcfc8eed27b6962e692171012fdd9
Reviewed-by: default avatarAnthony Léonard <>
parent fd179e5a
......@@ -32,6 +32,7 @@
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
#import "backends/AddressBookBackend.h"
class OnlyPersonProxyModel : public QSortFilterProxyModel
......@@ -206,6 +206,9 @@ bool AddressBookEditor::addNew( Person* item)
bool AddressBookEditor::addExisting(const Person* item)
m_lItems << const_cast<Person*>(item);
if(auto existingPerson = PersonModel::instance().getPersonByUid(item->uid())) {
return false;
return true;
......@@ -268,17 +271,21 @@ void AddressBookBackend::asyncLoad(int startingPoint)
Person* AddressBookBackend::abPersonToPerson(ABPerson* ab)
if(auto existingPerson = PersonModel::instance().getPersonByUid([[ab uniqueId] UTF8String])) {
return existingPerson;
auto person = new Person(QByteArray::fromNSData(ab.vCardRepresentation),
if(ab.imageData) {
QPixmap p;
if (p.loadFromData(QByteArray::fromNSData(ab.imageData))) {
person->setUid([[ab uniqueId] UTF8String]);
return person;
......@@ -291,6 +298,7 @@ bool AddressBookBackend::addNewPerson(Person *item)
ABAddressBook *book = [ABAddressBook sharedAddressBook];
ABPerson* person = [[ABPerson alloc] initWithVCardRepresentation:item->toVCard().toNSData()];
item->setUid([[person uniqueId] UTF8String]);
[book addRecord:person];
return [book save];
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