• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • akonadi
agentinstance.cpp
1/*
2 Copyright (c) 2008 Tobias Koenig <tokoe@kde.org>
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 "agentinstance.h"
21#include "agentinstance_p.h"
22
23#include "agentmanager.h"
24#include "agentmanager_p.h"
25#include "servermanager.h"
26
27#include <KDebug>
28
29using namespace Akonadi;
30
31AgentInstance::AgentInstance()
32 : d(new Private)
33{
34}
35
36AgentInstance::AgentInstance(const AgentInstance &other)
37 : d(other.d)
38{
39}
40
41AgentInstance::~AgentInstance()
42{
43}
44
45bool AgentInstance::isValid() const
46{
47 return !d->mIdentifier.isEmpty();
48}
49
50AgentType AgentInstance::type() const
51{
52 return d->mType;
53}
54
55QString AgentInstance::identifier() const
56{
57 return d->mIdentifier;
58}
59
60void AgentInstance::setName(const QString &name)
61{
62 AgentManager::self()->d->setName(*this, name);
63}
64
65QString AgentInstance::name() const
66{
67 return d->mName;
68}
69
70AgentInstance::Status AgentInstance::status() const
71{
72 switch (d->mStatus) {
73 case 0:
74 return Idle;
75 case 1:
76 return Running;
77 case 2:
78 default:
79 return Broken;
80 case 3:
81 return NotConfigured;
82 }
83}
84
85QString AgentInstance::statusMessage() const
86{
87 return d->mStatusMessage;
88}
89
90int AgentInstance::progress() const
91{
92 return d->mProgress;
93}
94
95bool AgentInstance::isOnline() const
96{
97 return d->mIsOnline;
98}
99
100void AgentInstance::setIsOnline(bool online)
101{
102 AgentManager::self()->d->setOnline(*this, online);
103}
104
105void AgentInstance::configure(QWidget *parent)
106{
107 AgentManager::self()->d->configure(*this, parent);
108}
109
110void AgentInstance::synchronize()
111{
112 AgentManager::self()->d->synchronize(*this);
113}
114
115void AgentInstance::synchronizeCollectionTree()
116{
117 AgentManager::self()->d->synchronizeCollectionTree(*this);
118}
119
120AgentInstance &AgentInstance::operator=(const AgentInstance &other)
121{
122 if (this != &other) {
123 d = other.d;
124 }
125
126 return *this;
127}
128
129bool AgentInstance::operator==(const AgentInstance &other) const
130{
131 return (d->mIdentifier == other.d->mIdentifier);
132}
133
134void AgentInstance::abortCurrentTask() const
135{
136 QDBusInterface iface(ServerManager::agentServiceName(ServerManager::Agent, identifier()),
137 QString::fromLatin1("/"),
138 QString::fromLatin1("org.freedesktop.Akonadi.Agent.Control"));
139 if (iface.isValid()) {
140 QDBusReply<void> reply = iface.call(QString::fromLatin1("abort"));
141 if (!reply.isValid()) {
142 kWarning() << "Failed to place D-Bus call.";
143 }
144 } else {
145 kWarning() << "Unable to obtain agent interface";
146 }
147}
148
149void AgentInstance::reconfigure() const
150{
151 QDBusInterface iface(ServerManager::agentServiceName(ServerManager::Agent, identifier()),
152 QString::fromLatin1("/"),
153 QString::fromLatin1("org.freedesktop.Akonadi.Agent.Control"));
154 if (iface.isValid()) {
155 QDBusReply<void> reply = iface.call(QString::fromLatin1("reconfigure"));
156 if (!reply.isValid()) {
157 kWarning() << "Failed to place D-Bus call.";
158 }
159 } else {
160 kWarning() << "Unable to obtain agent interface";
161 }
162}
163
164void Akonadi::AgentInstance::restart() const
165{
166 QDBusInterface iface(ServerManager::serviceName(Akonadi::ServerManager::Control),
167 QString::fromLatin1("/AgentManager"),
168 QString::fromLatin1("org.freedesktop.Akonadi.AgentManager"));
169 if (iface.isValid()) {
170 QDBusReply<void> reply = iface.call(QString::fromLatin1("restartAgentInstance"), identifier());
171 if (!reply.isValid()) {
172 kWarning() << "Failed to place D-Bus call.";
173 }
174 } else {
175 kWarning() << "Unable to obtain control interface" << iface.lastError().message();
176 }
177}
Akonadi::AgentInstance::Private
Definition agentinstance_p.h:35
Akonadi::AgentInstance
A representation of an agent instance.
Definition agentinstance.h:63
Akonadi::AgentInstance::configure
void configure(QWidget *parent=0)
Triggers the agent instance to show its configuration dialog.
Definition agentinstance.cpp:105
Akonadi::AgentInstance::status
Status status() const
Returns the status of the agent instance.
Definition agentinstance.cpp:70
Akonadi::AgentInstance::abortCurrentTask
void abortCurrentTask() const
Tell the agent to abort its current operation.
Definition agentinstance.cpp:134
Akonadi::AgentInstance::identifier
QString identifier() const
Returns the unique identifier of the agent instance.
Definition agentinstance.cpp:55
Akonadi::AgentInstance::synchronize
void synchronize()
Triggers the agent instance to start synchronization.
Definition agentinstance.cpp:110
Akonadi::AgentInstance::AgentInstance
AgentInstance()
Creates a new agent instance object.
Definition agentinstance.cpp:31
Akonadi::AgentInstance::isValid
bool isValid() const
Returns whether the agent instance object is valid.
Definition agentinstance.cpp:45
Akonadi::AgentInstance::setIsOnline
void setIsOnline(bool online)
Sets online status of the agent instance.
Definition agentinstance.cpp:100
Akonadi::AgentInstance::type
AgentType type() const
Returns the agent type of this instance.
Definition agentinstance.cpp:50
Akonadi::AgentInstance::synchronizeCollectionTree
void synchronizeCollectionTree()
Triggers a synchronization of the collection tree by the given agent instance.
Definition agentinstance.cpp:115
Akonadi::AgentInstance::operator=
AgentInstance & operator=(const AgentInstance &other)
Definition agentinstance.cpp:120
Akonadi::AgentInstance::~AgentInstance
~AgentInstance()
Destroys the agent instance object.
Definition agentinstance.cpp:41
Akonadi::AgentInstance::statusMessage
QString statusMessage() const
Returns a textual presentation of the status of the agent instance.
Definition agentinstance.cpp:85
Akonadi::AgentInstance::restart
void restart() const
Restart the agent process.
Definition agentinstance.cpp:164
Akonadi::AgentInstance::setName
void setName(const QString &name)
Sets the user visible name of the agent instance.
Definition agentinstance.cpp:60
Akonadi::AgentInstance::Status
Status
Describes the status of the agent instance.
Definition agentinstance.h:76
Akonadi::AgentInstance::NotConfigured
@ NotConfigured
The agent is lacking required configuration.
Definition agentinstance.h:80
Akonadi::AgentInstance::Running
@ Running
The agent instance is working on something.
Definition agentinstance.h:78
Akonadi::AgentInstance::Idle
@ Idle
The agent instance does currently nothing.
Definition agentinstance.h:77
Akonadi::AgentInstance::Broken
@ Broken
The agent instance encountered an error state.
Definition agentinstance.h:79
Akonadi::AgentInstance::operator==
bool operator==(const AgentInstance &other) const
Definition agentinstance.cpp:129
Akonadi::AgentInstance::progress
int progress() const
Returns the progress of the agent instance in percent, or -1 if no progress information are available...
Definition agentinstance.cpp:90
Akonadi::AgentInstance::reconfigure
void reconfigure() const
Tell the agent that its configuration has been changed remotely via D-Bus.
Definition agentinstance.cpp:149
Akonadi::AgentInstance::name
QString name() const
Returns the user visible name of the agent instance.
Definition agentinstance.cpp:65
Akonadi::AgentInstance::isOnline
bool isOnline() const
Returns whether the agent instance is online currently.
Definition agentinstance.cpp:95
Akonadi::AgentManager::self
static AgentManager * self()
Returns the global instance of the agent manager.
Definition agentmanager.cpp:377
Akonadi::AgentType
A representation of an agent type.
Definition agenttype.h:59
Akonadi::ServerManager::agentServiceName
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...
Definition servermanager.cpp:323
Akonadi::ServerManager::serviceName
static QString serviceName(ServiceType serviceType)
Returns the namespaced D-Bus service name for serviceType.
Definition servermanager.cpp:307
Akonadi
FreeBusyManager::Singleton.
Definition actionstatemanager_p.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal