Akonadi

relationdeletejob.cpp
1/*
2 SPDX-FileCopyrightText: 2014 Christian Mollekopf <mollekopf@kolabsys.com>
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
15using namespace Akonadi;
16
17class Akonadi::RelationDeleteJobPrivate : public JobPrivate
18{
19public:
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) {
54 }
55
56 return true;
57}
58
60{
62 return d->mRelation;
63}
64
65#include "moc_relationdeletejob.cpp"
Base class for all actions in the Akonadi storage.
Definition job.h:81
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
@ Unknown
Unknown error.
Definition job.h:102
Job that deletes a relation in the Akonadi storage.
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 doStart() override
This method must be reimplemented in the concrete jobs.
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:41
void setErrorText(const QString &errorText)
void emitResult()
void setError(int errorCode)
QString i18n(const char *text, const TYPE &arg...)
Helper integration between Akonadi and Qt.
T qobject_cast(QObject *object)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.