Akonadi

agentsearchengine.cpp
1 /*
2  Copyright (c) 2010 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "agentsearchengine.h"
21 #include "entities.h"
22 #include "akonadiserver_search_debug.h"
23 
24 #include <private/dbus_p.h>
25 
26 #include <QDBusInterface>
27 
28 using namespace Akonadi;
29 using namespace Akonadi::Server;
30 
32 {
33  QDBusInterface agentMgr(DBus::serviceName(DBus::Control),
34  QStringLiteral(AKONADI_DBUS_AGENTMANAGER_PATH),
35  QStringLiteral("org.freedesktop.Akonadi.AgentManagerInternal"));
36  if (agentMgr.isValid()) {
37  const QList<QVariant> args = QList<QVariant>() << collection.queryString()
38  << QLatin1String("")
39  << collection.id();
40  agentMgr.callWithArgumentList(QDBus::NoBlock, QStringLiteral("addSearch"), args);
41  return;
42  }
43 
44  qCCritical(AKONADISERVER_SEARCH_LOG) << "Failed to connect to agent manager: " << agentMgr.lastError().message();
45 }
46 
48 {
49  QDBusInterface agentMgr(DBus::serviceName(DBus::Control),
50  QStringLiteral(AKONADI_DBUS_AGENTMANAGER_PATH),
51  QStringLiteral("org.freedesktop.Akonadi.AgentManagerInternal"));
52  if (agentMgr.isValid()) {
53  const QList<QVariant> args = {id};
54  agentMgr.callWithArgumentList(QDBus::NoBlock, QStringLiteral("removeSearch"), args);
55  return;
56  }
57 
58  qCCritical(AKONADISERVER_SEARCH_LOG) << "Failed to connect to agent manager: " << agentMgr.lastError().message();
59 }
bool isValid() const const
Represents a collection of PIM items.
Definition: collection.h:76
QString message() const const
void removeSearch(qint64 id) override
Removes the collection with the given id from the search.
void addSearch(const Collection &collection) override
Adds the given collection to the search.
Id id() const
Returns the unique identifier of the collection.
Definition: collection.cpp:112
Helper integration between Akonadi and Qt.
QDBusError lastError() const const
QDBusMessage callWithArgumentList(QDBus::CallMode mode, const QString &method, const QList< QVariant > &args)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:08:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.