File indexing completed on 2024-11-10 04:40:53
0001 /* 0002 SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "agentsearchengine.h" 0008 #include "akonadiserver_search_debug.h" 0009 #include "entities.h" 0010 0011 #include "private/dbus_p.h" 0012 0013 #include <QDBusInterface> 0014 0015 using namespace Akonadi; 0016 using namespace Akonadi::Server; 0017 0018 void AgentSearchEngine::addSearch(const Collection &collection) 0019 { 0020 QDBusInterface agentMgr(DBus::serviceName(DBus::Control), 0021 QStringLiteral(AKONADI_DBUS_AGENTMANAGER_PATH), 0022 QStringLiteral("org.freedesktop.Akonadi.AgentManagerInternal")); 0023 if (agentMgr.isValid()) { 0024 const QList<QVariant> args = QList<QVariant>() << collection.queryString() << QLatin1StringView("") << collection.id(); 0025 agentMgr.callWithArgumentList(QDBus::NoBlock, QStringLiteral("addSearch"), args); 0026 return; 0027 } 0028 0029 qCCritical(AKONADISERVER_SEARCH_LOG) << "Failed to connect to agent manager: " << agentMgr.lastError().message(); 0030 } 0031 0032 void AgentSearchEngine::removeSearch(qint64 id) 0033 { 0034 QDBusInterface agentMgr(DBus::serviceName(DBus::Control), 0035 QStringLiteral(AKONADI_DBUS_AGENTMANAGER_PATH), 0036 QStringLiteral("org.freedesktop.Akonadi.AgentManagerInternal")); 0037 if (agentMgr.isValid()) { 0038 const QList<QVariant> args = {id}; 0039 agentMgr.callWithArgumentList(QDBus::NoBlock, QStringLiteral("removeSearch"), args); 0040 return; 0041 } 0042 0043 qCCritical(AKONADISERVER_SEARCH_LOG) << "Failed to connect to agent manager: " << agentMgr.lastError().message(); 0044 }