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

Skip menu "kdepimlibs-4.9.4 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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