• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 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 
29 using namespace Akonadi;
30 
31 AgentInstance::AgentInstance()
32  : d( new Private )
33 {
34 }
35 
36 AgentInstance::AgentInstance( const AgentInstance &other )
37  : d( other.d )
38 {
39 }
40 
41 AgentInstance::~AgentInstance()
42 {
43 }
44 
45 bool AgentInstance::isValid() const
46 {
47  return !d->mIdentifier.isEmpty();
48 }
49 
50 
51 AgentType AgentInstance::type() const
52 {
53  return d->mType;
54 }
55 
56 QString AgentInstance::identifier() const
57 {
58  return d->mIdentifier;
59 }
60 
61 void AgentInstance::setName( const QString &name )
62 {
63  AgentManager::self()->d->setName( *this, name );
64 }
65 
66 QString AgentInstance::name() const
67 {
68  return d->mName;
69 }
70 
71 AgentInstance::Status AgentInstance::status() const
72 {
73  switch ( d->mStatus ) {
74  case 0:
75  return Idle;
76  case 1:
77  return Running;
78  case 2:
79  default:
80  return Broken;
81  case 3:
82  return NotConfigured;
83  }
84 }
85 
86 QString AgentInstance::statusMessage() const
87 {
88  return d->mStatusMessage;
89 }
90 
91 int AgentInstance::progress() const
92 {
93  return d->mProgress;
94 }
95 
96 bool AgentInstance::isOnline() const
97 {
98  return d->mIsOnline;
99 }
100 
101 void AgentInstance::setIsOnline( bool online )
102 {
103  AgentManager::self()->d->setOnline( *this, online );
104 }
105 
106 void AgentInstance::configure( QWidget *parent )
107 {
108  AgentManager::self()->d->configure( *this, parent );
109 }
110 
111 void AgentInstance::synchronize()
112 {
113  AgentManager::self()->d->synchronize( *this );
114 }
115 
116 void AgentInstance::synchronizeCollectionTree()
117 {
118  AgentManager::self()->d->synchronizeCollectionTree( *this );
119 }
120 
121 AgentInstance& AgentInstance::operator=( const AgentInstance &other )
122 {
123  if ( this != &other ) {
124  d = other.d;
125  }
126 
127  return *this;
128 }
129 
130 bool AgentInstance::operator==( const AgentInstance &other ) const
131 {
132  return ( d->mIdentifier == other.d->mIdentifier );
133 }
134 
135 void AgentInstance::abortCurrentTask() const
136 {
137  QDBusInterface iface( ServerManager::agentServiceName( ServerManager::Agent, identifier() ),
138  QString::fromLatin1( "/" ),
139  QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) );
140  if ( iface.isValid() ) {
141  QDBusReply<void> reply = iface.call( QString::fromLatin1( "abort" ) );
142  if ( !reply.isValid() ) {
143  kWarning() << "Failed to place D-Bus call.";
144  }
145  } else {
146  kWarning() << "Unable to obtain agent interface";
147  }
148 }
149 
150 void AgentInstance::reconfigure() const
151 {
152  QDBusInterface iface( ServerManager::agentServiceName( ServerManager::Agent, identifier() ),
153  QString::fromLatin1( "/" ),
154  QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) );
155  if ( iface.isValid() ) {
156  QDBusReply<void> reply = iface.call( QString::fromLatin1( "reconfigure" ) );
157  if ( !reply.isValid() ) {
158  kWarning() << "Failed to place D-Bus call.";
159  }
160  } else {
161  kWarning() << "Unable to obtain agent interface";
162  }
163 }
164 
165 void Akonadi::AgentInstance::restart() const
166 {
167  QDBusInterface iface( ServerManager::serviceName( Akonadi::ServerManager::Control ),
168  QString::fromLatin1( "/AgentManager" ),
169  QString::fromLatin1( "org.freedesktop.Akonadi.AgentManager" ) );
170  if ( iface.isValid() ) {
171  QDBusReply<void> reply = iface.call( QString::fromLatin1( "restartAgentInstance" ), identifier() );
172  if ( !reply.isValid() ) {
173  kWarning() << "Failed to place D-Bus call.";
174  }
175  } else {
176  kWarning() << "Unable to obtain control interface" << iface.lastError().message();
177  }
178 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:31 by doxygen 1.8.3.1 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
  • Modules
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 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