• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.1 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  }
81 }
82 
83 QString AgentInstance::statusMessage() const
84 {
85  return d->mStatusMessage;
86 }
87 
88 int AgentInstance::progress() const
89 {
90  return d->mProgress;
91 }
92 
93 bool AgentInstance::isOnline() const
94 {
95  return d->mIsOnline;
96 }
97 
98 void AgentInstance::setIsOnline( bool online )
99 {
100  AgentManager::self()->d->setOnline( *this, online );
101 }
102 
103 void AgentInstance::configure( QWidget *parent )
104 {
105  AgentManager::self()->d->configure( *this, parent );
106 }
107 
108 void AgentInstance::synchronize()
109 {
110  AgentManager::self()->d->synchronize( *this );
111 }
112 
113 void AgentInstance::synchronizeCollectionTree()
114 {
115  AgentManager::self()->d->synchronizeCollectionTree( *this );
116 }
117 
118 AgentInstance& AgentInstance::operator=( const AgentInstance &other )
119 {
120  if ( this != &other )
121  d = other.d;
122 
123  return *this;
124 }
125 
126 bool AgentInstance::operator==( const AgentInstance &other ) const
127 {
128  return (d->mIdentifier == other.d->mIdentifier);
129 }
130 
131 void AgentInstance::abortCurrentTask() const
132 {
133  QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Agent.%1" ).arg( identifier() ),
134  QString::fromLatin1( "/" ),
135  QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) );
136  if ( iface.isValid() ) {
137  QDBusReply<void> reply = iface.call( QString::fromLatin1( "abort" ) );
138  if ( !reply.isValid() ) {
139  kWarning() << "Failed to place D-Bus call.";
140  }
141  } else {
142  kWarning() << "Unable to obtain agent interface";
143  }
144 }
145 
146 void AgentInstance::reconfigure() const
147 {
148  QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Agent.%1" ).arg( identifier() ),
149  QString::fromLatin1( "/" ),
150  QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) );
151  if ( iface.isValid() ) {
152  QDBusReply<void> reply = iface.call( QString::fromLatin1( "reconfigure" ) );
153  if ( !reply.isValid() ) {
154  kWarning() << "Failed to place D-Bus call.";
155  }
156  } else {
157  kWarning() << "Unable to obtain agent interface";
158  }
159 }
160 
161 void Akonadi::AgentInstance::restart() const
162 {
163  QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Control" ),
164  QString::fromLatin1( "/AgentManager" ),
165  QString::fromLatin1( "org.freedesktop.Akonadi.AgentManager" ) );
166  if ( iface.isValid() ) {
167  QDBusReply<void> reply = iface.call( QString::fromLatin1( "restartAgentInstance" ), identifier() );
168  if ( !reply.isValid() ) {
169  kWarning() << "Failed to place D-Bus call.";
170  }
171  } else {
172  kWarning() << "Unable to obtain control interface" << iface.lastError().message();
173  }
174 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Sep 24 2012 09:06:24 by doxygen 1.8.1.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.9.1 API Reference

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