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 =
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 
51 void AgentSearchInstance::search(const QByteArray &searchId, const QString &query, qlonglong collectionId)
52 {
53  mInterface->search(searchId, query, collectionId);
54 }
55 
56 OrgFreedesktopAkonadiAgentSearchInterface *AgentSearchInstance::interface() const
57 {
58  return mInterface;
59 }
void serviceUnregistered(const QString &serviceName)
QDBusConnection sessionBus()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jun 27 2022 04:01:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.