Akonadi

relationdeletejob.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Christian Mollekopf <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "relationdeletejob.h"
8 #include "akonadicore_debug.h"
9 #include "job_p.h"
10 #include "private/protocol_p.h"
11 #include "protocolhelper_p.h"
12 #include "relation.h"
13 #include <KLocalizedString>
14 
15 using namespace Akonadi;
16 
17 class Akonadi::RelationDeleteJobPrivate : public JobPrivate
18 {
19 public:
20  explicit RelationDeleteJobPrivate(RelationDeleteJob *parent)
21  : JobPrivate(parent)
22  {
23  }
24 
25  Relation mRelation;
26 };
27 
29  : Job(new RelationDeleteJobPrivate(this), parent)
30 {
32  d->mRelation = relation;
33 }
34 
36 {
38 
39  if (!d->mRelation.isValid()) {
40  qCWarning(AKONADICORE_LOG) << "The relation is invalid";
42  setErrorText(i18n("Failed to create relation."));
43  emitResult();
44  return;
45  }
46 
47  d->sendCommand(Protocol::RemoveRelationsCommandPtr::create(d->mRelation.left().id(), d->mRelation.right().id(), d->mRelation.type()));
48 }
49 
51 {
52  if (!response->isResponse() || response->type() != Protocol::Command::RemoveRelations) {
53  return Job::doHandleResponse(tag, response);
54  }
55 
56  return true;
57 }
58 
60 {
61  Q_D(const RelationDeleteJob);
62  return d->mRelation;
63 }
void doStart() override
This method must be reimplemented in the concrete jobs.
@ Unknown
Unknown error.
Definition: job.h:102
void setErrorText(const QString &errorText)
RelationDeleteJob(const Relation &relation, QObject *parent=nullptr)
Creates a new relation delete job.
Relation relation() const
Returns the relation.
An Akonadi Relation.
Definition: relation.h:39
QString i18n(const char *text, const TYPE &arg...)
Job that deletes a relation in the Akonadi storage.
Base class for all actions in the Akonadi storage.
Definition: job.h:80
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 emitResult()
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.
void setError(int errorCode)
Q_D(Todo)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.