From 264fb692ccd122e53c7592a26447ed8281179c8b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 21 Oct 2015 14:10:07 +0200 Subject: Avoid hardcoding a made-up resource type for config that doesn't belong to a resource --- common/clientapi.h | 13 +++++++++---- common/facadefactory.cpp | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/clientapi.h b/common/clientapi.h index 6237cfb..c4125bd 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -62,14 +62,19 @@ public: return Akonadi2::resourceName(instanceIdentifier); } - static QList getResources(const QList &resourceFilter) + static QList getResources(const QList &resourceFilter, const QByteArray &type) { + //Return the global resource (signified by an empty name) for types that don't eblong to a specific resource + if (type == "akonadiresource") { + return QList() << ""; + } QList resources; const auto configuredResources = ResourceConfig::getResources(); if (resourceFilter.isEmpty()) { for (const auto &res : configuredResources) { - //TODO filter by type - resources << res; + if (configuredResources.value(res) == type) { + resources << res; + } } } else { for (const auto &res : resourceFilter) { @@ -100,7 +105,7 @@ public: eventLoop.quit(); }); // Query all resources and aggregate results - KAsync::iterate(getResources(query.resources)) + KAsync::iterate(getResources(query.resources, ApplicationDomain::getTypeName())) .template each([query, resultSet](const QByteArray &resource, KAsync::Future &future) { auto facade = FacadeFactory::instance().getFacade(resourceName(resource), resource); if (facade) { diff --git a/common/facadefactory.cpp b/common/facadefactory.cpp index f833b06..64a466d 100644 --- a/common/facadefactory.cpp +++ b/common/facadefactory.cpp @@ -54,7 +54,7 @@ void FacadeFactory::resetFactory() void FacadeFactory::registerStaticFacades() { - registerFacade("resourceconfig"); + registerFacade(QByteArray()); } std::shared_ptr FacadeFactory::getFacade(const QByteArray &resource, const QByteArray &instanceIdentifier, const QByteArray &typeName) -- cgit v1.2.3