File indexing completed on 2024-11-10 04:40:28
0001 /* 0002 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "collectiondeletejob.h" 0008 #include "collection.h" 0009 #include "job_p.h" 0010 #include "private/protocol_p.h" 0011 #include "protocolhelper_p.h" 0012 0013 #include <KLocalizedString> 0014 0015 using namespace Akonadi; 0016 0017 class Akonadi::CollectionDeleteJobPrivate : public JobPrivate 0018 { 0019 public: 0020 explicit CollectionDeleteJobPrivate(CollectionDeleteJob *parent) 0021 : JobPrivate(parent) 0022 { 0023 } 0024 QString jobDebuggingString() const override; 0025 0026 Collection mCollection; 0027 }; 0028 0029 QString Akonadi::CollectionDeleteJobPrivate::jobDebuggingString() const 0030 { 0031 return QStringLiteral("Delete Collection id: %1").arg(mCollection.id()); 0032 } 0033 0034 CollectionDeleteJob::CollectionDeleteJob(const Collection &collection, QObject *parent) 0035 : Job(new CollectionDeleteJobPrivate(this), parent) 0036 { 0037 Q_D(CollectionDeleteJob); 0038 0039 d->mCollection = collection; 0040 } 0041 0042 CollectionDeleteJob::~CollectionDeleteJob() 0043 { 0044 } 0045 0046 void CollectionDeleteJob::doStart() 0047 { 0048 Q_D(CollectionDeleteJob); 0049 0050 if (!d->mCollection.isValid() && d->mCollection.remoteId().isEmpty()) { 0051 setError(Unknown); 0052 setErrorText(i18n("Invalid collection")); 0053 emitResult(); 0054 return; 0055 } 0056 0057 d->sendCommand(Protocol::DeleteCollectionCommandPtr::create(ProtocolHelper::entityToScope(d->mCollection))); 0058 } 0059 0060 bool CollectionDeleteJob::doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) 0061 { 0062 if (!response->isResponse() || response->type() != Protocol::Command::DeleteCollection) { 0063 return Job::doHandleResponse(tag, response); 0064 } 0065 0066 return true; 0067 } 0068 0069 #include "moc_collectiondeletejob.cpp"