File indexing completed on 2024-11-10 04:40:31
0001 /* 0002 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "relationdeletejob.h" 0008 #include "akonadicore_debug.h" 0009 #include "job_p.h" 0010 #include "private/protocol_p.h" 0011 #include "protocolhelper_p.h" 0012 #include "relation.h" 0013 #include <KLocalizedString> 0014 0015 using namespace Akonadi; 0016 0017 class Akonadi::RelationDeleteJobPrivate : public JobPrivate 0018 { 0019 public: 0020 explicit RelationDeleteJobPrivate(RelationDeleteJob *parent) 0021 : JobPrivate(parent) 0022 { 0023 } 0024 0025 Relation mRelation; 0026 }; 0027 0028 RelationDeleteJob::RelationDeleteJob(const Akonadi::Relation &relation, QObject *parent) 0029 : Job(new RelationDeleteJobPrivate(this), parent) 0030 { 0031 Q_D(RelationDeleteJob); 0032 d->mRelation = relation; 0033 } 0034 0035 void RelationDeleteJob::doStart() 0036 { 0037 Q_D(RelationDeleteJob); 0038 0039 if (!d->mRelation.isValid()) { 0040 qCWarning(AKONADICORE_LOG) << "The relation is invalid"; 0041 setError(Job::Unknown); 0042 setErrorText(i18n("Failed to create relation.")); 0043 emitResult(); 0044 return; 0045 } 0046 0047 d->sendCommand(Protocol::RemoveRelationsCommandPtr::create(d->mRelation.left().id(), d->mRelation.right().id(), d->mRelation.type())); 0048 } 0049 0050 bool RelationDeleteJob::doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) 0051 { 0052 if (!response->isResponse() || response->type() != Protocol::Command::RemoveRelations) { 0053 return Job::doHandleResponse(tag, response); 0054 } 0055 0056 return true; 0057 } 0058 0059 Relation RelationDeleteJob::relation() const 0060 { 0061 Q_D(const RelationDeleteJob); 0062 return d->mRelation; 0063 } 0064 0065 #include "moc_relationdeletejob.cpp"