Commit dbc9ba3b authored by mvogt's avatar mvogt

[libcontacts] Remove Qt4 support

parent b6957d6c
......@@ -3,15 +3,4 @@ include(package.pri)
CONFIG += qt link_pkgconfig
QT -= gui
equals(QT_MAJOR_VERSION, 4) {
CONFIG += mobility
MOBILITY += contacts versit
PKGCONFIG += qtcontacts-sqlite-extensions
}
equals(QT_MAJOR_VERSION, 5) {
PKGCONFIG += Qt5Contacts Qt5Versit qtcontacts-sqlite-qt5-extensions
DEFINES *= USING_QTPIM
# Needed for qt4 moc, which can't handle numeric tests
DEFINES *= QT_VERSION_5
}
PKGCONFIG += Qt5Contacts Qt5Versit qtcontacts-sqlite-qt5-extensions
equals(QT_MAJOR_VERSION, 4): PACKAGENAME=contactcache
equals(QT_MAJOR_VERSION, 5): PACKAGENAME=contactcache-qt5
PACKAGENAME=contactcache-qt5
Name: libcontacts
Summary: Nemo contact cache library
Version: 0.0.0
Release: 1
Group: System/Libraries
License: BSD
URL: https://github.com/nemomobile/libcontacts
Source0: %{name}-%{version}.tar.bz2
Requires: qtcontacts-sqlite
BuildRequires: pkgconfig(QtCore)
BuildRequires: pkgconfig(QtContacts)
BuildRequires: pkgconfig(QtVersit)
BuildRequires: pkgconfig(mlite)
BuildRequires: pkgconfig(mce)
BuildRequires: pkgconfig(qtcontacts-sqlite-extensions) >= 0.1.35
%description
%{summary}.
%package tests
Summary: Nemo contact cache library tests
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description tests
%{summary}.
%package devel
Summary: Nemo contact cache library headers
Group: System/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
%{summary}.
%prep
%setup -q -n %{name}-%{version}
%build
%qmake
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%qmake_install
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root,-)
%{_libdir}/libcontactcache.so*
%files tests
%defattr(-,root,root,-)
/opt/tests/contactcache/*
%files devel
%defattr(-,root,root,-)
%{_includedir}/contactcache/*
%{_libdir}/pkgconfig/contactcache.pc
This diff is collapsed.
......@@ -47,13 +47,8 @@
#include <QContactRelationshipFetchRequest>
#include <QContactRelationshipSaveRequest>
#include <QContactRelationshipRemoveRequest>
#ifdef USING_QTPIM
#include <QContactIdFilter>
#include <QContactIdFetchRequest>
#else
#include <QContactLocalIdFilter>
#include <QContactLocalIdFetchRequest>
#endif
#include <QBasicTimer>
#include <QSet>
......@@ -65,15 +60,9 @@
#include <mgconfitem.h>
#endif
#ifdef USING_QTPIM
QTCONTACTS_USE_NAMESPACE
typedef QContactDetail::DetailType DetailTypeId;
#else
QTM_USE_NAMESPACE
typedef QString DetailTypeId;
#endif
class CONTACTCACHE_EXPORT SeasideNameGroupChangeListener
{
......@@ -272,15 +261,9 @@ public:
static ContactIdType apiId(quint32 iid);
static bool validId(const ContactIdType &id);
#ifndef USING_QTPIM
static bool validId(const QContactId &id);
#endif
static quint32 internalId(const QContact &contact);
static quint32 internalId(const QContactId &id);
#ifndef USING_QTPIM
static quint32 internalId(QContactLocalId id);
#endif
static void registerModel(ListModel *model, FilterType type, FetchDataType requiredTypes = FetchNone, FetchDataType extraTypes = FetchNone);
static void unregisterModel(ListModel *model);
......@@ -305,13 +288,9 @@ public:
static int contactId(const QContact &contact);
static CacheItem *existingItem(const ContactIdType &id);
#ifdef USING_QTPIM
static CacheItem *existingItem(quint32 iid);
#endif
static CacheItem *itemById(const ContactIdType &id, bool requireComplete = true);
#ifdef USING_QTPIM
static CacheItem *itemById(int id, bool requireComplete = true);
#endif
static ContactIdType selfContactId();
static QContact contactById(const ContactIdType &id);
......@@ -371,17 +350,10 @@ private slots:
void relationshipsAvailable();
void requestStateChanged(QContactAbstractRequest::State state);
void updateContacts();
#ifdef USING_QTPIM
void contactsAdded(const QList<QContactId> &contactIds);
void contactsChanged(const QList<QContactId> &contactIds);
void contactsPresenceChanged(const QList<QContactId> &contactIds);
void contactsRemoved(const QList<QContactId> &contactIds);
#else
void contactsAdded(const QList<QContactLocalId> &contactIds);
void contactsChanged(const QList<QContactLocalId> &contactIds);
void contactsPresenceChanged(const QList<QContactLocalId> &contactIds);
void contactsRemoved(const QList<QContactLocalId> &contactIds);
#endif
void displayLabelOrderChanged();
void sortPropertyChanged();
void groupPropertyChanged();
......@@ -469,11 +441,7 @@ private:
QHash<ContactIdType,int> m_expiredContacts;
QContactFetchRequest m_fetchRequest;
QContactFetchByIdRequest m_fetchByIdRequest;
#ifdef USING_QTPIM
QContactIdFetchRequest m_contactIdRequest;
#else
QContactLocalIdFetchRequest m_contactIdRequest;
#endif
QContactRelationshipFetchRequest m_relationshipsFetchRequest;
QContactRemoveRequest m_removeRequest;
QContactSaveRequest m_saveRequest;
......
......@@ -57,12 +57,8 @@
#include <QContactTag>
#include <QContactUrl>
#ifdef USING_QTPIM
#include <QContactIdFilter>
#include <QContactExtendedDetail>
#else
#include <QContactLocalIdFilter>
#endif
#include <QVersitContactExporter>
#include <QVersitContactImporter>
......@@ -89,13 +85,8 @@ QContactFilter localContactFilter()
{
// Contacts that are local to the device have sync target 'local' or 'was_local'
QContactDetailFilter filterLocal, filterWasLocal;
#ifdef USING_QTPIM
filterLocal.setDetailType(QContactSyncTarget::Type, QContactSyncTarget::FieldSyncTarget);
filterWasLocal.setDetailType(QContactSyncTarget::Type, QContactSyncTarget::FieldSyncTarget);
#else
filterLocal.setDetailDefinitionName(QContactSyncTarget::DefinitionName, QContactSyncTarget::FieldSyncTarget);
filterWasLocal.setDetailDefinitionName(QContactSyncTarget::DefinitionName, QContactSyncTarget::FieldSyncTarget);
#endif
filterLocal.setValue(QString::fromLatin1("local"));
filterWasLocal.setValue(QString::fromLatin1("was_local"));
......@@ -133,32 +124,19 @@ QString contactNameString(const QContact &contact)
template<typename T, typename F>
QVariant detailValue(const T &detail, F field)
{
#ifdef USING_QTPIM
return detail.value(field);
#else
return detail.variantValue(field);
#endif
}
#ifdef USING_QTPIM
typedef QMap<int, QVariant> DetailMap;
#else
typedef QVariantMap DetailMap;
#endif
DetailMap detailValues(const QContactDetail &detail)
{
#ifdef USING_QTPIM
DetailMap rv(detail.values());
#else
DetailMap rv(detail.variantValues());
#endif
return rv;
}
static bool variantEqual(const QVariant &lhs, const QVariant &rhs)
{
#ifdef USING_QTPIM
// Work around incorrect result from QVariant::operator== when variants contain QList<int>
static const int QListIntType = QMetaType::type("QList<int>");
......@@ -170,7 +148,6 @@ static bool variantEqual(const QVariant &lhs, const QVariant &rhs)
if (lhsType == QListIntType) {
return (lhs.value<QList<int> >() == rhs.value<QList<int> >());
}
#endif
return (lhs == rhs);
}
......@@ -197,7 +174,6 @@ static void fixupDetail(QContactDetail &)
{
}
#ifdef USING_QTPIM
// Fixup QContactUrl because importer produces incorrectly typed URL field
static void fixupDetail(QContactUrl &url)
{
......@@ -236,7 +212,6 @@ static void fixupDetail(QContactOrganization &org)
}
}
}
#endif
template<typename T>
bool updateExistingDetails(QContact *updateContact, const QContact &importedContact, bool singular = false)
......@@ -288,9 +263,7 @@ bool mergeIntoExistingContact(QContact *updateContact, const QContact &importedC
rv |= updateExistingDetails<QContactRingtone>(updateContact, importedContact);
rv |= updateExistingDetails<QContactTag>(updateContact, importedContact);
rv |= updateExistingDetails<QContactUrl>(updateContact, importedContact);
#ifdef USING_QTPIM
rv |= updateExistingDetails<QContactExtendedDetail>(updateContact, importedContact);
#endif
return rv;
}
......@@ -419,11 +392,7 @@ QList<QContact> SeasideImport::buildImportContacts(const QList<QVersitDocument>
// Find all names and GUIDs for local contacts that might match these contacts
QContactFetchHint fetchHint(basicFetchHint());
#ifdef USING_QTPIM
fetchHint.setDetailTypesHint(QList<QContactDetail::DetailType>() << QContactName::Type << QContactNickname::Type << QContactGuid::Type);
#else
fetchHint.setDetailDefinitionsHint(QStringList() << QContactName::DefinitionName << QContactNickname::DefinitionName << QContactGuid::DefinitionName);
#endif
QHash<QString, QContactId> existingGuids;
QHash<QString, QContactId> existingNames;
......@@ -519,16 +488,8 @@ QList<QContact> SeasideImport::buildImportContacts(const QList<QVersitDocument>
int existingCount(existingIds.count());
if (existingCount > 0) {
// Retrieve all the contacts that we have matches for
#ifdef USING_QTPIM
QContactIdFilter idFilter;
idFilter.setIds(existingIds.keys());
#else
QContactLocalIdFilter idFilter;
QList<QContactLocalId> localIds;
foreach (const QContactId &id, existingIds.keys()) {
localids.append(id.toLocal());
}
#endif
QSet<QContactId> modifiedContacts;
QSet<QContactId> unmodifiedContacts;
......
......@@ -37,12 +37,8 @@
#include <QContact>
#include <QVersitDocument>
#ifdef USING_QTPIM
QTCONTACTS_USE_NAMESPACE
QTVERSIT_USE_NAMESPACE
#else
QTM_USE_NAMESPACE
#endif
class CONTACTCACHE_EXPORT SeasideImport
{
......
......@@ -37,11 +37,7 @@
#include <QList>
#include <QContact>
#ifdef USING_QTPIM
QTCONTACTS_USE_NAMESPACE
#else
QTM_USE_NAMESPACE
#endif
class CONTACTCACHE_EXPORT SeasideNameGrouper
{
......
......@@ -32,10 +32,6 @@
#include "seasidepropertyhandler.h"
#ifndef QT_VERSION_5
#include <QDesktopServices>
#include <QContactThumbnail>
#endif
#include <QContactAvatar>
#include <QContactOnlineAccount>
#include <QContactPresence>
......@@ -65,19 +61,6 @@ void processPhoto(const QVersitProperty &property, bool *alreadyProcessed, QList
// if the property is a PHOTO property, store the data to disk
// and then create an avatar detail which points to it.
#ifndef QT_VERSION_5
// The Qt4 / QtMobility version has QContactThumbnail support.
// We need to remove any such thumbnail detail from the output,
// as some backends (such as qtcontacts-sqlite) do not support
// that detail type.
for (int i = 0; i < updatedDetails->size(); ++i) {
if (updatedDetails->at(i).definitionName() == QContactThumbnail::DefinitionName) {
updatedDetails->removeAt(i);
--i;
}
}
#endif
// The data might be either a URL, a file path, or encoded image data
// It's hard to tell what the content is, because versit removes the encoding
// information in the process of decoding the data...
......
......@@ -40,22 +40,13 @@
#include <QContact>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
# include <QVersitContactImporterPropertyHandlerV2>
#else
# include <QVersitContactImporterPropertyHandler>
#endif
#include <QVersitContactImporterPropertyHandler>
#include <QVersitResourceHandler>
#include <QVersitDocument>
#include <QVersitProperty>
#ifdef USING_QTPIM
QTCONTACTS_USE_NAMESPACE
QTVERSIT_USE_NAMESPACE
#else
QTM_USE_NAMESPACE
#endif
/*
SeasidePropertyHandler
......
......@@ -16,24 +16,13 @@ QMAKE_PKGCONFIG_LIBDIR = $$PREFIX/lib
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
CONFIG += link_pkgconfig
equals(QT_MAJOR_VERSION, 4) {
packagesExist(mlite) {
PKGCONFIG += mlite
DEFINES += HAS_MLITE
} else {
warning("mlite not available. Some functionality may not work as expected.")
}
PKGCONFIG += mce
}
equals(QT_MAJOR_VERSION, 5) {
packagesExist(mlite5) {
PKGCONFIG += mlite5
DEFINES += HAS_MLITE
} else {
warning("mlite not available. Some functionality may not work as expected.")
}
PKGCONFIG += mlocale5 mce
packagesExist(mlite5) {
PKGCONFIG += mlite5
DEFINES += HAS_MLITE
} else {
warning("mlite not available. Some functionality may not work as expected.")
}
PKGCONFIG += mlocale5 mce
DEFINES += CONTACTCACHE_BUILD
......@@ -41,12 +30,7 @@ DEFINES += CONTACTCACHE_BUILD
QT += contacts-private
# We need the moc output for ContactManagerEngine from sqlite-extensions
equals(QT_MAJOR_VERSION, 4) {
extensionsIncludePath = $$system(pkg-config --cflags-only-I qtcontacts-sqlite-extensions)
}
equals(QT_MAJOR_VERSION, 5) {
extensionsIncludePath = $$system(pkg-config --cflags-only-I qtcontacts-sqlite-qt5-extensions)
}
extensionsIncludePath = $$system(pkg-config --cflags-only-I qtcontacts-sqlite-qt5-extensions)
VPATH += $$replace(extensionsIncludePath, -I, )
HEADERS += contactmanagerengine.h
......
......@@ -41,9 +41,7 @@
#include <QObject>
#include <QtTest>
#ifdef USING_QTPIM
QTVERSIT_USE_NAMESPACE
#endif
class tst_SeasideImport : public QObject
{
......
......@@ -4,5 +4,4 @@ TARGET = tst_seasideimport
SOURCES += tst_seasideimport.cpp
equals(QT_MAJOR_VERSION, 4): LIBS += ../../src/libcontactcache.so
equals(QT_MAJOR_VERSION, 5): LIBS += ../../src/libcontactcache-qt5.so
LIBS += ../../src/libcontactcache-qt5.so
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