Akonadi

collectiondeletejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2006 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "collectiondeletejob.h"
8 #include "collection.h"
9 #include "job_p.h"
10 #include "private/protocol_p.h"
11 #include "protocolhelper_p.h"
12 
13 #include <KLocalizedString>
14 
15 using namespace Akonadi;
16 
17 class Akonadi::CollectionDeleteJobPrivate : public JobPrivate
18 {
19 public:
20  explicit CollectionDeleteJobPrivate(CollectionDeleteJob *parent)
21  : JobPrivate(parent)
22  {
23  }
24  QString jobDebuggingString() const override;
25 
26  Collection mCollection;
27 };
28 
29 QString Akonadi::CollectionDeleteJobPrivate::jobDebuggingString() const
30 {
31  return QStringLiteral("Delete Collection id: %1").arg(mCollection.id());
32 }
33 
35  : Job(new CollectionDeleteJobPrivate(this), parent)
36 {
38 
39  d->mCollection = collection;
40 }
41 
43 {
44 }
45 
47 {
49 
50  if (!d->mCollection.isValid() && d->mCollection.remoteId().isEmpty()) {
52  setErrorText(i18n("Invalid collection"));
53  emitResult();
54  return;
55  }
56 
57  d->sendCommand(Protocol::DeleteCollectionCommandPtr::create(ProtocolHelper::entityToScope(d->mCollection)));
58 }
59 
61 {
62  if (!response->isResponse() || response->type() != Protocol::Command::DeleteCollection) {
63  return Job::doHandleResponse(tag, response);
64  }
65 
66  return true;
67 }
void emitResult()
Unknown error.
Definition: job.h:102
Represents a collection of PIM items.
Definition: collection.h:61
virtual bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response)
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
Definition: job.cpp:381
void setError(int errorCode)
Base class for all actions in the Akonadi storage.
Definition: job.h:80
CollectionDeleteJob(const Collection &collection, QObject *parent=nullptr)
Creates a new collection delete job.
~CollectionDeleteJob() override
Destroys the collection delete job.
void setErrorText(const QString &errorText)
Job that deletes a collection in the Akonadi storage.
void doStart() override
This method must be reimplemented in the concrete jobs.
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
Q_D(Todo)
bool doHandleResponse(qint64 tag, const Protocol::CommandPtr &response) override
This method should be reimplemented in the concrete jobs in case you want to handle incoming data...
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jan 15 2022 23:08:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.