Akonadi

core/agentinstance.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "agentinstance.h"
8#include "agentinstance_p.h"
9
10#include "agentmanager.h"
11#include "agentmanager_p.h"
12#include "servermanager.h"
13
14#include "akonadicore_debug.h"
15
16using namespace Akonadi;
17
18AgentInstance::AgentInstance()
19 : d(new AgentInstancePrivate)
20{
21}
22
24 : d(other.d)
25{
26}
27
29{
30}
31
33{
34 return !d->mIdentifier.isEmpty();
35}
36
38{
39 return d->mType;
40}
41
43{
44 return d->mIdentifier;
45}
46
48{
49 AgentManager::self()->d->setName(*this, name);
50}
51
53{
54 return d->mName;
55}
56
58{
59 switch (d->mStatus) {
60 case 0:
61 return Idle;
62 case 1:
63 return Running;
64 case 3:
65 return NotConfigured;
66 case 2:
67 default:
68 return Broken;
69 }
70}
71
73{
74 return d->mStatusMessage;
75}
76
78{
79 return d->mProgress;
80}
81
82bool AgentInstance::isOnline() const
83{
84 return d->mIsOnline;
85}
86
88{
89 AgentManager::self()->d->setOnline(*this, online);
90}
91
93{
94 AgentManager::self()->d->configure(*this, parent);
95}
96
98{
99 AgentManager::self()->d->synchronize(*this);
100}
101
103{
104 AgentManager::self()->d->synchronizeCollectionTree(*this);
105}
106
108{
109 AgentManager::self()->d->synchronizeTags(*this);
110}
111
113{
114 AgentManager::self()->d->synchronizeRelations(*this);
115}
116
118{
119 if (this != &other) {
120 d = other.d;
121 }
122
123 return *this;
124}
125
127{
128 return (d->mIdentifier == other.d->mIdentifier);
129}
130
132{
133 QDBusInterface iface(ServerManager::agentServiceName(ServerManager::Agent, identifier()),
134 QStringLiteral("/"),
135 QStringLiteral("org.freedesktop.Akonadi.Agent.Control"));
136 if (iface.isValid()) {
137 QDBusReply<void> reply = iface.call(QStringLiteral("abort"));
138 if (!reply.isValid()) {
139 qCWarning(AKONADICORE_LOG) << "Failed to place D-Bus call.";
140 }
141 } else {
142 qCWarning(AKONADICORE_LOG) << "Unable to obtain agent interface";
143 }
144}
145
147{
148 QDBusInterface iface(ServerManager::agentServiceName(ServerManager::Agent, identifier()),
149 QStringLiteral("/"),
150 QStringLiteral("org.freedesktop.Akonadi.Agent.Control"));
151 if (iface.isValid()) {
152 QDBusReply<void> reply = iface.call(QStringLiteral("reconfigure"));
153 if (!reply.isValid()) {
154 qCWarning(AKONADICORE_LOG) << "Failed to place D-Bus call.";
155 }
156 } else {
157 qCWarning(AKONADICORE_LOG) << "Unable to obtain agent interface";
158 }
159}
160
162{
163 QDBusInterface iface(ServerManager::serviceName(Akonadi::ServerManager::Control),
164 QStringLiteral("/AgentManager"),
165 QStringLiteral("org.freedesktop.Akonadi.AgentManager"));
166 if (iface.isValid()) {
167 QDBusReply<void> reply = iface.call(QStringLiteral("restartAgentInstance"), identifier());
168 if (!reply.isValid()) {
169 qCWarning(AKONADICORE_LOG) << "Failed to place D-Bus call.";
170 }
171 } else {
172 qCWarning(AKONADICORE_LOG) << "Unable to obtain control interface" << iface.lastError().message();
173 }
174}
A representation of an agent instance.
void restart() const
Restart the agent process.
Status status() const
Returns the status of the agent instance.
void abortCurrentTask() const
Tell the agent to abort its current operation.
AKONADICORE_DEPRECATED void configure(QWidget *parent=nullptr)
Triggers the agent instance to show its configuration dialog.
void synchronize()
Triggers the agent instance to start synchronization.
AgentInstance()
Creates a new agent instance object.
bool isValid() const
Returns whether the agent instance object is valid.
QString identifier() const
Returns the unique identifier of the agent instance.
void setIsOnline(bool online)
Sets online status of the agent instance.
AgentType type() const
Returns the agent type of this instance.
void synchronizeRelations()
Triggers a synchronization of relations by the given agent instance.
void synchronizeCollectionTree()
Triggers a synchronization of the collection tree by the given agent instance.
AgentInstance & operator=(const AgentInstance &other)
void setName(const QString &name)
Sets the user visible name of the agent instance.
~AgentInstance()
Destroys the agent instance object.
Status
Describes the status of the agent instance.
@ NotConfigured
The agent is lacking required configuration.
@ Running
The agent instance is working on something.
@ Idle
The agent instance does currently nothing.
@ Broken
The agent instance encountered an error state.
QString statusMessage() const
Returns a textual presentation of the status of the agent instance.
bool operator==(const AgentInstance &other) const
void synchronizeTags()
Triggers a synchronization of tags by the given agent instance.
void reconfigure() const
Tell the agent that its configuration has been changed remotely via D-Bus.
bool isOnline() const
Returns whether the agent instance is online currently.
int progress() const
Returns the progress of the agent instance in percent, or -1 if no progress information are available...
QString name() const
Returns the user visible name of the agent instance.
static AgentManager * self()
Returns the global instance of the agent manager.
A representation of an agent type.
static QString agentServiceName(ServiceAgentType agentType, const QString &identifier)
Returns the namespaced D-Bus service name for an agent of type agentType with agent identifier identi...
static QString serviceName(ServiceType serviceType)
Returns the namespaced D-Bus service name for serviceType.
Helper integration between Akonadi and Qt.
QDBusMessage call(QDBus::CallMode mode, const QString &method, Args &&... args)
bool isValid() const const
QDBusError lastError() const const
QString message() const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.