Skip to content

Commit

Permalink
Merge branch 'jb50658-qtpim-ugprade' into 'master'
Browse files Browse the repository at this point in the history
[libcommhistory] Make build with latest qtpim. JB#50658

See merge request mer-core/libcommhistory!43
  • Loading branch information
chriadam committed Sep 25, 2020
2 parents 5fbec3d + 16ead80 commit 9b85010
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
6 changes: 3 additions & 3 deletions rpm/libcommhistory-qt5.spec
@@ -1,6 +1,6 @@
Name: libcommhistory-qt5
Summary: Communications event history database API
Version: 1.9.44
Version: 1.11.0
Release: 1
License: LGPLv2
URL: https://git.sailfishos.org/mer-core/libcommhistory
Expand All @@ -11,8 +11,8 @@ BuildRequires: pkgconfig(Qt5Contacts)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions) >= 0.1.41
BuildRequires: pkgconfig(contactcache-qt5) >= 0.2.12
BuildRequires: pkgconfig(qtcontacts-sqlite-qt5-extensions) >= 0.3.0
BuildRequires: pkgconfig(contactcache-qt5) >= 0.3.0
BuildRequires: libphonenumber-devel

%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
Expand Down
5 changes: 1 addition & 4 deletions src/contactlistener.cpp
Expand Up @@ -31,7 +31,6 @@
#include <QContactOnlineAccount>
#include <QContactPhoneNumber>
#include <QContactEmailAddress>
#include <QContactSyncTarget>

#include "commonutils.h"
#include "contactresolver.h"
Expand Down Expand Up @@ -163,9 +162,7 @@ void ContactListenerPrivate::itemUpdated(SeasideCache::CacheItem *item)
Q_Q(ContactListener);

// Only aggregate contacts are relevant
static const QString aggregateTarget(QString::fromLatin1("aggregate"));
QContactSyncTarget syncTarget(item->contact.detail<QContactSyncTarget>());
if (syncTarget.syncTarget() != aggregateTarget)
if (item->contact.collectionId() != SeasideCache::aggregateCollectionId())
return;

// Make a list of Recipient from the contacts addresses to compare against
Expand Down
28 changes: 10 additions & 18 deletions tests/common.cpp
Expand Up @@ -41,7 +41,6 @@
#include <QContactNickname>
#include <QContactOnlineAccount>
#include <QContactPhoneNumber>
#include <QContactSyncTarget>

#include <QEventLoop>
#include <QFile>
Expand Down Expand Up @@ -88,13 +87,6 @@ QContact createTestContact(const QString &name, const QString &remoteUid, const
{
QContact contact;

QContactSyncTarget syncTarget;
syncTarget.setSyncTarget(QLatin1String("commhistory-tests"));
if (!contact.saveDetail(&syncTarget)) {
qWarning() << "Unable to add sync target to contact:" << contactUri;
return QContact();
}

if (!localUid.isEmpty() && !localUidComparesPhoneNumbers(localUid)) {
// Create a metadata detail to link the contact with the account
QContactOriginMetadata metadata;
Expand Down Expand Up @@ -234,8 +226,8 @@ int addTestContact(const QString &name, const QString &remoteUid, const QString
return -1;
}

foreach (const QContactRelationship &relationship, manager()->relationships(QContactRelationship::Aggregates(), contact, QContactRelationship::Second)) {
const QContactId &aggId = relationship.first().id();
foreach (const QContactRelationship &relationship, manager()->relationships(QContactRelationship::Aggregates(), contact.id(), QContactRelationship::Second)) {
const QContactId &aggId = relationship.first();
qDebug() << "********** contact id" << aggId;
addedContactIds.insert(aggId);
return internalContactId(aggId);
Expand Down Expand Up @@ -269,8 +261,8 @@ QList<int> addTestContacts(const QList<QPair<QString, QPair<QString, QString> >
constituentIds.insert(contact.id());
}
foreach (const QContactRelationship &relationship, manager()->relationships(QContactRelationship::Aggregates())) {
if (constituentIds.contains(relationship.second().id())) {
const QContactId &aggId = relationship.first().id();
if (constituentIds.contains(relationship.second())) {
const QContactId &aggId = relationship.first();
qDebug() << "********** contact id" << aggId;
addedContactIds.insert(aggId);
ids.append(internalContactId(aggId));
Expand All @@ -282,7 +274,7 @@ QList<int> addTestContacts(const QList<QPair<QString, QPair<QString, QString> >

bool addTestContactAddress(int contactId, const QString &remoteUid, const QString &localUid)
{
QContact existing = manager()->contact(apiContactId(contactId));
QContact existing = manager()->contact(apiContactId(contactId, manager()->managerUri()));
if (internalContactId(existing.id()) != (unsigned)contactId) {
qWarning() << "Could not retrieve contact:" << contactId;
return false;
Expand Down Expand Up @@ -329,7 +321,7 @@ void modifyTestContact(int id, const QString &name, bool favorite)
{
qDebug() << Q_FUNC_INFO << id << name;

QContact contact = manager()->contact(apiContactId(id));
QContact contact = manager()->contact(apiContactId(id, manager()->managerUri()));
if (internalContactId(contact.id()) != (unsigned)id) {
qWarning() << "Could not retrieve contact:" << id;
return;
Expand Down Expand Up @@ -361,10 +353,10 @@ void modifyTestContact(int id, const QString &name, bool favorite)

void deleteTestContact(int id)
{
if (!manager()->removeContact(apiContactId(id))) {
if (!manager()->removeContact(apiContactId(id, manager()->managerUri()))) {
qWarning() << "error deleting contact:" << id;
}
addedContactIds.remove(apiContactId(id));
addedContactIds.remove(apiContactId(id, manager()->managerUri()));
}

void cleanUpTestContacts()
Expand All @@ -373,8 +365,8 @@ void cleanUpTestContacts()
QString aggregatesType = QContactRelationship::Aggregates();

foreach (const QContactRelationship &rel, manager()->relationships(aggregatesType)) {
QContactId firstId = rel.first().id();
QContactId secondId = rel.second().id();
QContactId firstId = rel.first();
QContactId secondId = rel.second();
if (addedContactIds.contains(firstId)) {
addedContactIds.insert(secondId);
}
Expand Down

0 comments on commit 9b85010

Please sign in to comment.