Akonadi

agentsearchinstance.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Daniel Vrátil <[email protected]>
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 
13 using namespace Akonadi;
14 using namespace Akonadi::Server;
15 
16 AgentSearchInstance::AgentSearchInstance(const QString &id, SearchTaskManager &manager)
17  : mId(id)
18  , mInterface(nullptr)
19  , mManager(manager)
20 {
21 }
22 
23 AgentSearchInstance::~AgentSearchInstance()
24 {
25  delete mInterface;
26 }
27 
28 bool AgentSearchInstance::init()
29 {
30  Q_ASSERT(!mInterface);
31 
32  mInterface = new OrgFreedesktopAkonadiAgentSearchInterface(
33  DBus::agentServiceName(mId, DBus::Agent),
34  QStringLiteral("/Search"),
36 
37  if (!mInterface || !mInterface->isValid()) {
38  delete mInterface;
39  mInterface = nullptr;
40  return false;
41  }
42 
43  mServiceWatcher = std::make_unique<QDBusServiceWatcher>(
44  DBus::agentServiceName(mId, DBus::Agent), QDBusConnection::sessionBus(),
46  connect(mServiceWatcher.get(), &QDBusServiceWatcher::serviceUnregistered,
47  this, [this]() {
48  mManager.unregisterInstance(mId);
49  });
50 
51  return true;
52 }
53 
54 void AgentSearchInstance::search(const QByteArray &searchId, const QString &query,
55  qlonglong collectionId)
56 {
57  mInterface->search(searchId, query, collectionId);
58 }
59 
60 OrgFreedesktopAkonadiAgentSearchInterface *AgentSearchInstance::interface() const
61 {
62  return mInterface;
63 }
QDBusConnection sessionBus()
void serviceUnregistered(const QString &serviceName)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jul 8 2020 23:15:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.