Akonadi

agentsearchinstance.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Daniel Vrátil <dvratil@redhat.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "agentsearchinstance.h"
8#include "agentsearchinterface.h"
9#include "searchtaskmanager.h"
10
11#include "private/dbus_p.h"
12
13using namespace Akonadi;
14using namespace Akonadi::Server;
15
16AgentSearchInstance::AgentSearchInstance(const QString &id, SearchTaskManager &manager)
17 : mId(id)
18 , mInterface(nullptr)
19 , mManager(manager)
20{
21}
22
23AgentSearchInstance::~AgentSearchInstance()
24{
25 delete mInterface;
26}
27
28bool AgentSearchInstance::init()
29{
30 Q_ASSERT(!mInterface);
31
32 mInterface =
33 new OrgFreedesktopAkonadiAgentSearchInterface(DBus::agentServiceName(mId, DBus::Agent), QStringLiteral("/Search"), QDBusConnection::sessionBus());
34
35 if (!mInterface || !mInterface->isValid()) {
36 delete mInterface;
37 mInterface = nullptr;
38 return false;
39 }
40
41 mServiceWatcher = std::make_unique<QDBusServiceWatcher>(DBus::agentServiceName(mId, DBus::Agent),
44 connect(mServiceWatcher.get(), &QDBusServiceWatcher::serviceUnregistered, this, [this]() {
45 mManager.unregisterInstance(mId);
46 });
47
48 return true;
49}
50
51void AgentSearchInstance::search(const QByteArray &searchId, const QString &query, qlonglong collectionId)
52{
53 mInterface->search(searchId, query, collectionId);
54}
55
56OrgFreedesktopAkonadiAgentSearchInterface *AgentSearchInstance::interface() const
57{
58 return mInterface;
59}
60
61#include "moc_agentsearchinstance.cpp"
Helper integration between Akonadi and Qt.
QDBusConnection sessionBus()
void serviceUnregistered(const QString &serviceName)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.