akonadi
agentinstance.cpp
00001 /* 00002 Copyright (c) 2008 Tobias Koenig <tokoe@kde.org> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "agentinstance.h" 00021 #include "agentinstance_p.h" 00022 00023 #include "agentmanager.h" 00024 #include "agentmanager_p.h" 00025 00026 #include <KDebug> 00027 00028 using namespace Akonadi; 00029 00030 AgentInstance::AgentInstance() 00031 : d( new Private ) 00032 { 00033 } 00034 00035 AgentInstance::AgentInstance( const AgentInstance &other ) 00036 : d( other.d ) 00037 { 00038 } 00039 00040 AgentInstance::~AgentInstance() 00041 { 00042 } 00043 00044 bool AgentInstance::isValid() const 00045 { 00046 return !d->mIdentifier.isEmpty(); 00047 } 00048 00049 00050 AgentType AgentInstance::type() const 00051 { 00052 return d->mType; 00053 } 00054 00055 QString AgentInstance::identifier() const 00056 { 00057 return d->mIdentifier; 00058 } 00059 00060 void AgentInstance::setName( const QString &name ) 00061 { 00062 AgentManager::self()->d->setName( *this, name ); 00063 } 00064 00065 QString AgentInstance::name() const 00066 { 00067 return d->mName; 00068 } 00069 00070 AgentInstance::Status AgentInstance::status() const 00071 { 00072 switch ( d->mStatus ) { 00073 case 0: 00074 return Idle; 00075 case 1: 00076 return Running; 00077 case 2: 00078 default: 00079 return Broken; 00080 } 00081 } 00082 00083 QString AgentInstance::statusMessage() const 00084 { 00085 return d->mStatusMessage; 00086 } 00087 00088 int AgentInstance::progress() const 00089 { 00090 return d->mProgress; 00091 } 00092 00093 bool AgentInstance::isOnline() const 00094 { 00095 return d->mIsOnline; 00096 } 00097 00098 void AgentInstance::setIsOnline( bool online ) 00099 { 00100 AgentManager::self()->d->setOnline( *this, online ); 00101 } 00102 00103 void AgentInstance::configure( QWidget *parent ) 00104 { 00105 AgentManager::self()->d->configure( *this, parent ); 00106 } 00107 00108 void AgentInstance::synchronize() 00109 { 00110 AgentManager::self()->d->synchronize( *this ); 00111 } 00112 00113 void AgentInstance::synchronizeCollectionTree() 00114 { 00115 AgentManager::self()->d->synchronizeCollectionTree( *this ); 00116 } 00117 00118 AgentInstance& AgentInstance::operator=( const AgentInstance &other ) 00119 { 00120 if ( this != &other ) 00121 d = other.d; 00122 00123 return *this; 00124 } 00125 00126 bool AgentInstance::operator==( const AgentInstance &other ) const 00127 { 00128 return (d->mIdentifier == other.d->mIdentifier); 00129 } 00130 00131 void AgentInstance::abortCurrentTask() const 00132 { 00133 QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Agent.%1" ).arg( identifier() ), 00134 QString::fromLatin1( "/" ), 00135 QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) ); 00136 if ( iface.isValid() ) { 00137 QDBusReply<void> reply = iface.call( QString::fromLatin1( "abort" ) ); 00138 if ( !reply.isValid() ) { 00139 kWarning() << "Failed to place D-Bus call."; 00140 } 00141 } else { 00142 kWarning() << "Unable to obtain agent interface"; 00143 } 00144 } 00145 00146 void AgentInstance::reconfigure() const 00147 { 00148 QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Agent.%1" ).arg( identifier() ), 00149 QString::fromLatin1( "/" ), 00150 QString::fromLatin1( "org.freedesktop.Akonadi.Agent.Control" ) ); 00151 if ( iface.isValid() ) { 00152 QDBusReply<void> reply = iface.call( QString::fromLatin1( "reconfigure" ) ); 00153 if ( !reply.isValid() ) { 00154 kWarning() << "Failed to place D-Bus call."; 00155 } 00156 } else { 00157 kWarning() << "Unable to obtain agent interface"; 00158 } 00159 } 00160 00161 void Akonadi::AgentInstance::restart() const 00162 { 00163 QDBusInterface iface( QString::fromLatin1( "org.freedesktop.Akonadi.Control" ), 00164 QString::fromLatin1( "/AgentManager" ), 00165 QString::fromLatin1( "org.freedesktop.Akonadi.AgentManager" ) ); 00166 if ( iface.isValid() ) { 00167 QDBusReply<void> reply = iface.call( QString::fromLatin1( "restartAgentInstance" ), identifier() ); 00168 if ( !reply.isValid() ) { 00169 kWarning() << "Failed to place D-Bus call."; 00170 } 00171 } else { 00172 kWarning() << "Unable to obtain control interface" << iface.lastError().message(); 00173 } 00174 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:52:51 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:52:51 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.